Example #1
0
SGIView::SGIView(const char* name, uint32 flags, TranslatorSettings* settings)
	:
	BView(name, flags, new BGroupLayout(B_VERTICAL)),
	fSettings(settings)
{
	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, B_TRANSLATE("None"), 
		currentCompression);
	//menu->AddSeparatorItem();
	add_menu_item(menu, SGI_COMP_RLE, B_TRANSLATE("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);

	fCompressionMF = new BMenuField("compression", 
		B_TRANSLATE("Use compression:"), menu);

	BAlignment labelAlignment(B_ALIGN_LEFT, B_ALIGN_NO_VERTICAL);

	BStringView* titleView = new BStringView("title", 
		B_TRANSLATE("SGI image translator"));
	titleView->SetFont(be_bold_font);
	titleView->SetExplicitAlignment(labelAlignment);

	char detail[100];
	sprintf(detail, B_TRANSLATE("Version %d.%d.%d %s"),
		static_cast<int>(B_TRANSLATION_MAJOR_VERSION(SGI_TRANSLATOR_VERSION)),
		static_cast<int>(B_TRANSLATION_MINOR_VERSION(SGI_TRANSLATOR_VERSION)),
		static_cast<int>(B_TRANSLATION_REVISION_VERSION(
			SGI_TRANSLATOR_VERSION)), __DATE__);
	BStringView* detailView = new BStringView("details", detail);
	detailView->SetExplicitAlignment(labelAlignment);

	BTextView* infoView = new BTextView("info");
	infoView->SetText(BString(B_TRANSLATE("written by:\n"))
			.Append(author)
			.Append(B_TRANSLATE("\n\nbased on GIMP SGI plugin v1.5:\n"))
			.Append(kSGICopyright).String());
	infoView->SetExplicitAlignment(labelAlignment);
	infoView->SetWordWrap(false);
	infoView->MakeEditable(false);
	infoView->MakeResizable(true);
	infoView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));

	float padding = 5.0f;
	BLayoutBuilder::Group<>(this, B_VERTICAL, padding)
		.SetInsets(padding)
		.Add(titleView)
		.Add(detailView)
		.AddGroup(B_HORIZONTAL)
			.Add(fCompressionMF)
			.AddGlue()
			.End()
		.Add(infoView)
		.AddGlue();

	BFont font;
	GetFont(&font);
	SetExplicitPreferredSize(BSize((font.Size() * 390) / 12,
		(font.Size() * 180) / 12));

	// TODO: remove this workaround for ticket #4217
	infoView->SetExplicitPreferredSize(
		BSize(infoView->LineWidth(4), infoView->TextHeight(0, 80)));
	infoView->SetExplicitMaxSize(infoView->ExplicitPreferredSize());
	infoView->SetExplicitMinSize(infoView->ExplicitPreferredSize());
}