Example #1
0
// ---------------------------------------------------------------
// Constructor
//
// Sets up the view settings
//
// Preconditions:
//
// Parameters:
//
// Postconditions:
//
// Returns:
// ---------------------------------------------------------------
SGIView::SGIView(const BRect &frame, const char *name,
	uint32 resize, uint32 flags, TranslatorSettings *settings)
	:	BView(frame, name, resize, flags),
		fSettings(settings)
{
	SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	SetLowColor(ViewColor());

	BPopUpMenu* menu = new BPopUpMenu("pick compression");

	uint32 currentCompression = fSettings->SetGetInt32(SGI_SETTING_COMPRESSION);
	// create the menu items with the various compression methods
	add_menu_item(menu, SGI_COMP_NONE, "None", currentCompression);
//	menu->AddSeparatorItem();
	add_menu_item(menu, SGI_COMP_RLE, "RLE", currentCompression);

// DON'T turn this on, it's so slow that I didn't wait long enough
// the one time I tested this. So I don't know if the code even works.
// Supposedly, this would look for an already written scanline, and
// modify the scanline tables so that the current row is not written
// at all...

//	add_menu_item(menu, SGI_COMP_ARLE, "Agressive RLE", currentCompression);

	BRect menuFrame = Bounds();
	menuFrame.bottom = menuFrame.top + menu->Bounds().Height();
	fCompressionMF = new BMenuField(menuFrame, "compression",
									"Use compression:", menu, true/*,
									B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP*/);
	if (fCompressionMF->MenuBar())
		fCompressionMF->MenuBar()->ResizeToPreferred();
	fCompressionMF->ResizeToPreferred();

	// figure out where the text ends
	font_height fh;
	be_bold_font->GetHeight(&fh);
	float xbold, ybold;
	xbold = fh.descent + 1;
	ybold = fh.ascent + fh.descent * 2 + fh.leading;

	font_height plainh;
	be_plain_font->GetHeight(&plainh);
	float yplain;
	yplain = plainh.ascent + plainh.descent * 2 + plainh.leading;

	// position the menu field below all the text we draw in Draw()
	BPoint textOffset(0.0, yplain * 2 + ybold);
	fCompressionMF->MoveTo(textOffset);

	AddChild(fCompressionMF);

	ResizeToPreferred();
}