Esempio n. 1
0
InfoView::InfoView()
	:
	BGroupView(B_TRANSLATE("Information"), B_HORIZONTAL)
{
	BStringView* rendererView = new BStringView(NULL,
		(const char*)glGetString(GL_RENDERER));
	rendererView->SetExplicitAlignment(kLabelAlignment);
	rendererView->SetFont(be_bold_font);

	BStringView* vendorNameView = new BStringView(NULL,
		(const char*)glGetString(GL_VENDOR));
		vendorNameView->SetExplicitAlignment(kLabelAlignment);

	BStringView* glVersionView = new BStringView(NULL,
		(const char*)glGetString(GL_VERSION));
	glVersionView->SetExplicitAlignment(kLabelAlignment);

	BString apiString("GLU ");
	apiString << (const char*)gluGetString(GLU_VERSION);
	apiString << ", GLUT ";
	apiString << (int32)GLUT_API_VERSION;
	BStringView* apiVersionView = new BStringView(NULL, apiString.String());
	apiVersionView->SetExplicitAlignment(kLabelAlignment);

	BLayoutBuilder::Group<>(this)
		.AddGroup(B_VERTICAL, 0)
			.Add(rendererView)
			.Add(vendorNameView)
			.Add(glVersionView)
			.Add(apiVersionView)
			.End();
}
Esempio n. 2
0
HVIFView::HVIFView(const char* name, uint32 flags, TranslatorSettings *settings)
	:
	BView(name, flags, new BGroupLayout(B_VERTICAL)),
	fSettings(settings)
{
	BAlignment labelAlignment(B_ALIGN_LEFT, B_ALIGN_NO_VERTICAL);

	BStringView* title= new BStringView("title",
		B_TRANSLATE("Native Haiku icon format translator"));
	title->SetFont(be_bold_font);
	title->SetExplicitAlignment(labelAlignment);

	char versionString[256];
	snprintf(versionString, sizeof(versionString), 
		B_TRANSLATE("Version %d.%d.%d, %s"),
		int(B_TRANSLATION_MAJOR_VERSION(HVIF_TRANSLATOR_VERSION)),
		int(B_TRANSLATION_MINOR_VERSION(HVIF_TRANSLATOR_VERSION)),
		int(B_TRANSLATION_REVISION_VERSION(HVIF_TRANSLATOR_VERSION)),
		__DATE__);
	BStringView* version = new BStringView("version", versionString);
	version->SetExplicitAlignment(labelAlignment);

	BStringView* copyright = new BStringView("copyright",
		B_UTF8_COPYRIGHT"2009 Haiku Inc.");
	copyright->SetExplicitAlignment(labelAlignment);


	int32 renderSize = fSettings->SetGetInt32(HVIF_SETTING_RENDER_SIZE);
	BString label = B_TRANSLATE("Render size:");
	label << " " << renderSize;

	fRenderSize = new BSlider("renderSize", label.String(),
		NULL, 1, 32, B_HORIZONTAL);
	fRenderSize->SetValue(renderSize / 8);
	fRenderSize->SetHashMarks(B_HASH_MARKS_BOTTOM);
	fRenderSize->SetHashMarkCount(16);
	fRenderSize->SetModificationMessage(
		new BMessage(HVIF_SETTING_RENDER_SIZE_CHANGED));
	fRenderSize->SetExplicitAlignment(labelAlignment);

	float padding = 5.0f;
	BLayoutBuilder::Group<>(this, B_VERTICAL, padding)
		.SetInsets(padding)
		.Add(title)
		.Add(version)
		.Add(copyright)
		.Add(fRenderSize)
		.AddGlue();

 	BFont font;
 	GetFont(&font);
 	SetExplicitPreferredSize(
		BSize((font.Size() * 270) / 12, (font.Size() * 100) / 12));
}
Esempio n. 3
0
LookAndFeelSettingsView::LookAndFeelSettingsView(const char* name)
	:
	BView(name, 0),
	fDecorInfoButton(NULL),
	fDecorMenuField(NULL),
	fDecorMenu(NULL)
{
	// Decorator menu
	_BuildDecorMenu();
	fDecorMenuField = new BMenuField("decorator",
		B_TRANSLATE("Decorator:"), fDecorMenu);

	fDecorInfoButton = new BButton(B_TRANSLATE("About"),
		new BMessage(kMsgDecorInfo));

	// scroll bar arrow style
	BBox* arrowStyleBox = new BBox("arrow style");
	arrowStyleBox->SetLabel(B_TRANSLATE("Arrow style"));

	fSavedDoubleArrowsValue = _DoubleScrollBarArrows();

	fArrowStyleSingle = new FakeScrollBar(true, false,
		new BMessage(kMsgArrowStyleSingle));
	fArrowStyleDouble = new FakeScrollBar(true, true,
		new BMessage(kMsgArrowStyleDouble));

	BView* arrowStyleView;
	arrowStyleView = BLayoutBuilder::Group<>()
		.AddGroup(B_VERTICAL, 1)
			.Add(new BStringView("single", B_TRANSLATE("Single:")))
			.Add(fArrowStyleSingle)
			.AddStrut(B_USE_DEFAULT_SPACING)
			.Add(new BStringView("double", B_TRANSLATE("Double:")))
			.Add(fArrowStyleDouble)
			.SetInsets(B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING,
				B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING)
			.End()
		.View();
	arrowStyleBox->AddChild(arrowStyleView);
	arrowStyleBox->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT,
		B_ALIGN_VERTICAL_CENTER));
	arrowStyleBox->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));

	BStringView* scrollBarLabel
		= new BStringView("scroll bar", B_TRANSLATE("Scroll bar:"));
	scrollBarLabel->SetExplicitAlignment(
		BAlignment(B_ALIGN_LEFT, B_ALIGN_TOP));

	// control layout
	BLayoutBuilder::Grid<>(this, B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING)
		.Add(fDecorMenuField->CreateLabelLayoutItem(), 0, 0)
		.Add(fDecorMenuField->CreateMenuBarLayoutItem(), 1, 0)
		.Add(fDecorInfoButton, 2, 0)
		.Add(scrollBarLabel, 0, 1)
		.Add(arrowStyleBox, 1, 1)
		.AddGlue(0, 2)
		.SetInsets(B_USE_WINDOW_SPACING);

	// TODO : Decorator Preview Image?
}
Esempio n. 4
0
BView*
AboutView::_CreateLabel(const char* name, const char* label)
{
	BStringView* labelView = new BStringView(name, label);
	labelView->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT,
		B_ALIGN_VERTICAL_UNSET));
	labelView->SetFont(be_bold_font);
	return labelView;
}
Esempio n. 5
0
void
MediaWindow::_MakeEmptyParamView()
{
	fParamWeb = NULL;

	BStringView* stringView = new BStringView("noControls",
		B_TRANSLATE("This hardware has no controls."));

	BSize unlimited(B_SIZE_UNLIMITED, B_SIZE_UNLIMITED);
	stringView->SetExplicitMaxSize(unlimited);

	BAlignment centered(B_ALIGN_HORIZONTAL_CENTER,
		B_ALIGN_VERTICAL_CENTER);
	stringView->SetExplicitAlignment(centered);
	stringView->SetAlignment(B_ALIGN_CENTER);

	fContentLayout->AddView(stringView);
	fContentLayout->SetVisibleItem(fContentLayout->CountItems() - 1);

	rgb_color panel = stringView->LowColor();
	stringView->SetHighColor(tint_color(panel,
		B_DISABLED_LABEL_TINT));
}
Esempio n. 6
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());
}
Esempio n. 7
0
SettingsWindow::SettingsWindow(BRect frame)
 	:
 	BWindow(frame, B_TRANSLATE("MediaPlayer settings"), B_FLOATING_WINDOW_LOOK,
 		B_FLOATING_ALL_WINDOW_FEEL,
 		B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_NOT_RESIZABLE
 			| B_AUTO_UPDATE_SIZE_LIMITS)
{
	const float kSpacing = be_control_look->DefaultItemSpacing();

	BBox* settingsBox = new BBox(B_PLAIN_BORDER, NULL);
	BGroupLayout* settingsLayout = new BGroupLayout(B_VERTICAL, kSpacing / 2);
	settingsBox->SetLayout(settingsLayout);
	BBox* buttonBox = new BBox(B_PLAIN_BORDER, NULL);
	BGroupLayout* buttonLayout = new BGroupLayout(B_HORIZONTAL, kSpacing / 2);
	buttonBox->SetLayout(buttonLayout);

	BStringView* playModeLabel = new BStringView("stringViewPlayMode",
		B_TRANSLATE("Play mode"));
	BStringView* viewOptionsLabel = new BStringView("stringViewViewOpions",
		B_TRANSLATE("View options"));
	BStringView* bgMoviesModeLabel = new BStringView("stringViewPlayBackg",
		B_TRANSLATE("Volume of background clips"));
	BAlignment alignment(B_ALIGN_LEFT, B_ALIGN_VERTICAL_CENTER);
	playModeLabel->SetExplicitAlignment(alignment);
	playModeLabel->SetFont(be_bold_font);
	viewOptionsLabel->SetExplicitAlignment(alignment);
	viewOptionsLabel->SetFont(be_bold_font);
	bgMoviesModeLabel->SetExplicitAlignment(alignment);
	bgMoviesModeLabel->SetFont(be_bold_font);

	fAutostartCB = new BCheckBox("chkboxAutostart",
		B_TRANSLATE("Automatically start playing"),
		new BMessage(M_SETTINGS_CHANGED));

	fCloseWindowMoviesCB = new BCheckBox("chkBoxCloseWindowMovies",
		B_TRANSLATE("Close window after playing video"),
		new BMessage(M_SETTINGS_CHANGED));
	fCloseWindowSoundsCB = new BCheckBox("chkBoxCloseWindowSounds",
		B_TRANSLATE("Close window after playing audio"),
		new BMessage(M_SETTINGS_CHANGED));

	fLoopMoviesCB = new BCheckBox("chkBoxLoopMovie",
		B_TRANSLATE("Loop video"),
		new BMessage(M_SETTINGS_CHANGED));
	fLoopSoundsCB = new BCheckBox("chkBoxLoopSounds",
		B_TRANSLATE("Loop audio"),
		new BMessage(M_SETTINGS_CHANGED));

	fUseOverlaysCB = new BCheckBox("chkBoxUseOverlays",
		B_TRANSLATE("Use hardware video overlays if available"),
		new BMessage(M_SETTINGS_CHANGED));
	fScaleBilinearCB = new BCheckBox("chkBoxScaleBilinear",
		B_TRANSLATE("Scale movies smoothly (non-overlay mode)"),
		new BMessage(M_SETTINGS_CHANGED));

	fScaleFullscreenControlsCB = new BCheckBox("chkBoxScaleControls",
		B_TRANSLATE("Scale controls in full screen mode"),
		new BMessage(M_SETTINGS_CHANGED));

	fSubtitleSizeOP = new BOptionPopUp("subtitleSize",
		B_TRANSLATE("Subtitle size:"), new BMessage(M_SETTINGS_CHANGED));
	fSubtitleSizeOP->AddOption(
		B_TRANSLATE("Small"), mpSettings::SUBTITLE_SIZE_SMALL);
	fSubtitleSizeOP->AddOption(
		B_TRANSLATE("Medium"), mpSettings::SUBTITLE_SIZE_MEDIUM);
	fSubtitleSizeOP->AddOption(
		B_TRANSLATE("Large"), mpSettings::SUBTITLE_SIZE_LARGE);

	fSubtitlePlacementOP = new BOptionPopUp("subtitlePlacement",
		B_TRANSLATE("Subtitle placement:"), new BMessage(M_SETTINGS_CHANGED));
	fSubtitlePlacementOP->AddOption(B_TRANSLATE("Bottom of video"),
		mpSettings::SUBTITLE_PLACEMENT_BOTTOM_OF_VIDEO);
	fSubtitlePlacementOP->AddOption(B_TRANSLATE("Bottom of screen"),
		mpSettings::SUBTITLE_PLACEMENT_BOTTOM_OF_SCREEN);

	fFullVolumeBGMoviesRB = new BRadioButton("rdbtnfullvolume",
		B_TRANSLATE("Full volume"), new BMessage(M_SETTINGS_CHANGED));

	fHalfVolumeBGMoviesRB = new BRadioButton("rdbtnhalfvolume",
		B_TRANSLATE("Low volume"), new BMessage(M_SETTINGS_CHANGED));

	fMutedVolumeBGMoviesRB = new BRadioButton("rdbtnfullvolume",
		B_TRANSLATE("Muted"), new BMessage(M_SETTINGS_CHANGED));

	fRevertB = new BButton("revert", B_TRANSLATE("Revert"),
		new BMessage(M_SETTINGS_REVERT));

	BButton* cancelButton = new BButton("cancel", B_TRANSLATE("Cancel"),
		new BMessage(M_SETTINGS_CANCEL));

	BButton* okButton = new BButton("ok", B_TRANSLATE("OK"),
		new BMessage(M_SETTINGS_SAVE));
	okButton->MakeDefault(true);

	// Build the layout
	BGroupLayout* volumeGroup;
	BGroupLayout* startGroup;
	BGroupLayout* playGroup;
	BLayoutBuilder::Group<>(this, B_VERTICAL, 0)
		.AddGroup(settingsLayout)
			.SetInsets(B_USE_WINDOW_SPACING, B_USE_WINDOW_SPACING,
				B_USE_WINDOW_SPACING, B_USE_DEFAULT_SPACING)
			.Add(playModeLabel)
			.AddGroup(B_HORIZONTAL, 0)
				.GetLayout(&playGroup)
				.AddStrut(10)
				.AddGroup(B_VERTICAL, 0)
					.GetLayout(&startGroup)
					.Add(fAutostartCB)
					.AddGrid(kSpacing, 0)
						.Add(BSpaceLayoutItem::CreateHorizontalStrut(kSpacing), 0, 0)
						.Add(fCloseWindowMoviesCB, 1, 0)
						.Add(BSpaceLayoutItem::CreateHorizontalStrut(kSpacing), 0, 1)
						.Add(fCloseWindowSoundsCB, 1, 1)
					.End()
					.Add(fLoopMoviesCB)
					.Add(fLoopSoundsCB)
				.End()
			.End()
			.AddStrut(kSpacing)

			.Add(viewOptionsLabel)
			.AddGroup(B_HORIZONTAL, 0)
				.AddStrut(10)
				.AddGroup(B_VERTICAL, 0)
					.Add(fUseOverlaysCB)
					.Add(fScaleBilinearCB)
					.Add(fScaleFullscreenControlsCB)
					.Add(fSubtitleSizeOP)
					.Add(fSubtitlePlacementOP)
				.End()
			.End()
			.AddStrut(kSpacing)

			.Add(bgMoviesModeLabel)
			.AddGroup(B_HORIZONTAL, 0)
				.AddStrut(10)
				.AddGroup(B_VERTICAL, 0)
					.GetLayout(&volumeGroup)
					.Add(fFullVolumeBGMoviesRB)
					.Add(fHalfVolumeBGMoviesRB)
					.Add(fMutedVolumeBGMoviesRB)
				.End()
			.End()
			.AddStrut(kSpacing)
		.End()
		.AddGroup(buttonLayout)
			.SetInsets(B_USE_WINDOW_SPACING, B_USE_DEFAULT_SPACING,
				B_USE_WINDOW_SPACING, B_USE_WINDOW_SPACING)
			.Add(fRevertB)
			.AddGlue()
			.Add(cancelButton)
			.Add(okButton);

	startGroup->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));
	playGroup->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));
	volumeGroup->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));
}
Esempio n. 8
0
SettingsWindow::SettingsWindow(BRect frame)
 	: BWindow(frame, "MediaPlayer settings", B_FLOATING_WINDOW_LOOK,
 		B_FLOATING_APP_WINDOW_FEEL,
 		B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_NOT_RESIZABLE
#ifdef __ANTARES__
 			| B_AUTO_UPDATE_SIZE_LIMITS)
#else
 			)
#endif
{
#ifdef __ANTARES__

	BBox* settingsBox = new BBox(B_PLAIN_BORDER, NULL);
	BGroupLayout* settingsLayout = new BGroupLayout(B_VERTICAL, 5);
	settingsBox->SetLayout(settingsLayout);
	BBox* buttonBox = new BBox(B_PLAIN_BORDER, NULL);
	BGroupLayout* buttonLayout = new BGroupLayout(B_HORIZONTAL, 5);
	buttonBox->SetLayout(buttonLayout);

	BStringView* playModeLabel = new BStringView("stringViewPlayMode",
		"Play mode");
	BStringView* viewOptionsLabel = new BStringView("stringViewViewOpions", 
		"View options");
	BStringView* bgMoviesModeLabel = new BStringView("stringViewPlayBackg", 
		"Play background clips at");
	BAlignment alignment(B_ALIGN_LEFT, B_ALIGN_VERTICAL_CENTER);
	playModeLabel->SetExplicitAlignment(alignment);
	playModeLabel->SetFont(be_bold_font);
	viewOptionsLabel->SetExplicitAlignment(alignment);
	viewOptionsLabel->SetFont(be_bold_font);
	bgMoviesModeLabel->SetExplicitAlignment(alignment);
	bgMoviesModeLabel->SetFont(be_bold_font);

	fAutostartCB = new BCheckBox("chkboxAutostart", 
		"Automatically start playing", new BMessage(M_AUTOSTART));

	fCloseWindowMoviesCB = new BCheckBox("chkBoxCloseWindowMovies", 
		"Close window when done playing movies",
		new BMessage(M_CLOSE_WINDOW_MOVIE));
	fCloseWindowSoundsCB = new BCheckBox("chkBoxCloseWindowSounds", 
		"Close window when done playing sounds",
		new BMessage(M_CLOSE_WINDOW_SOUNDS));

	fLoopMoviesCB = new BCheckBox("chkBoxLoopMovie",
		"Loop movies by default", new BMessage(M_LOOP_MOVIE));
	fLoopSoundsCB = new BCheckBox("chkBoxLoopSounds",
		"Loop sounds by default", new BMessage(M_LOOP_SOUND));

	fUseOverlaysCB = new BCheckBox("chkBoxUseOverlays",
		"Use hardware video overlays if available",
		new BMessage(M_USE_OVERLAYS));
	fScaleBilinearCB = new BCheckBox("chkBoxScaleBilinear",
		"Scale movies smoothly (non-overlay mode)",
		new BMessage(M_SCALE_BILINEAR));

	fFullVolumeBGMoviesRB = new BRadioButton("rdbtnfullvolume",
		"Full volume", new BMessage(M_START_FULL_VOLUME));
	
	fHalfVolumeBGMoviesRB = new BRadioButton("rdbtnhalfvolume", 
		"Low volume", new BMessage(M_START_HALF_VOLUME));
	
	fMutedVolumeBGMoviesRB = new BRadioButton("rdbtnfullvolume",
		"Muted", new BMessage(M_START_MUTE_VOLUME));

	fRevertB = new BButton("revert", "Revert", 
		new BMessage(M_SETTINGS_REVERT));

	BButton* cancelButton = new BButton("cancel", "Cancel", 
		new BMessage(M_SETTINGS_CANCEL));

	BButton* okButton = new BButton("ok", "OK",
		new BMessage(M_SETTINGS_SAVE));
	okButton->MakeDefault(true);


	// Build the layout
	SetLayout(new BGroupLayout(B_HORIZONTAL));

	AddChild(BGroupLayoutBuilder(B_VERTICAL, 0)
		.Add(BGroupLayoutBuilder(settingsLayout)
			.Add(playModeLabel)
			.Add(BGroupLayoutBuilder(B_HORIZONTAL, 0)
				.Add(BSpaceLayoutItem::CreateHorizontalStrut(10))
				.Add(BGroupLayoutBuilder(B_VERTICAL, 0)
					.Add(fAutostartCB)
					.Add(BGridLayoutBuilder(5, 0)
						.Add(BSpaceLayoutItem::CreateHorizontalStrut(10), 0, 0)
						.Add(fCloseWindowMoviesCB, 1, 0)
						.Add(BSpaceLayoutItem::CreateHorizontalStrut(10), 0, 1)
						.Add(fCloseWindowSoundsCB, 1, 1)
					)
					.Add(fLoopMoviesCB)
					.Add(fLoopSoundsCB)
				)
			)
			.Add(BSpaceLayoutItem::CreateVerticalStrut(5))

			.Add(viewOptionsLabel)
			.Add(BGroupLayoutBuilder(B_HORIZONTAL, 0)
				.Add(BSpaceLayoutItem::CreateHorizontalStrut(10))
				.Add(BGroupLayoutBuilder(B_VERTICAL, 0)
					.Add(fUseOverlaysCB)
					.Add(fScaleBilinearCB)
				)
			)
			.Add(BSpaceLayoutItem::CreateVerticalStrut(5))

			.Add(bgMoviesModeLabel)
			.Add(BGroupLayoutBuilder(B_HORIZONTAL, 0)
				.Add(BSpaceLayoutItem::CreateHorizontalStrut(10))
				.Add(BGroupLayoutBuilder(B_VERTICAL, 0)
					.Add(fFullVolumeBGMoviesRB)
					.Add(fHalfVolumeBGMoviesRB)
					.Add(fMutedVolumeBGMoviesRB)
				)
			)
			.Add(BSpaceLayoutItem::CreateVerticalStrut(5))

			.SetInsets(5, 5, 15, 5)
		)
		.Add(BGroupLayoutBuilder(buttonLayout)
			.Add(fRevertB)
			.AddGlue()
			.Add(cancelButton)
			.Add(okButton)
			.SetInsets(5, 5, 5, 5)
		)
	);

#else

	frame = Bounds();
	BView* view = new BView(frame,"SettingsView",B_FOLLOW_ALL_SIDES,B_WILL_DRAW);
	view->SetViewColor(216, 216, 216);
	
	BRect btnRect(80.00, frame.bottom - (SPACE + BUTTONHEIGHT), 145.00, 
		frame.bottom-SPACE);

	fRevertB = new BButton(btnRect, "revert", "Revert", 
		new BMessage(M_SETTINGS_REVERT));
	view->AddChild(fRevertB);

	btnRect.OffsetBy(btnRect.Width() + SPACE, 0);
	BButton* btn = new BButton(btnRect, "btnCancel", "Cancel", 
		new BMessage(M_SETTINGS_CANCEL));
	view->AddChild(btn);
	
	btnRect.OffsetBy(btnRect.Width() + SPACE, 0);
	btn = new BButton(btnRect, "btnOK", "OK", new BMessage(M_SETTINGS_SAVE));
	view->AddChild(btn);
	
	BRect rectBox(frame.left + SPACE, frame.top + SPACE, frame.right - SPACE, 
		btnRect.top- SPACE);
	BBox* bbox = new BBox(rectBox, "box1", B_FOLLOW_ALL_SIDES,B_WILL_DRAW | B_NAVIGABLE,
		B_FANCY_BORDER);
	bbox->SetLabel("MediaPlayer Settings");
	
	BFont font;
	font_height fh1;
	font.GetHeight(&fh1);

	BString str("Play Mode:");
	BRect rect(rectBox.left, rectBox.top + SPACE, rectBox.right - (12*2), 
		rectBox.top + fh1.leading + fh1.ascent + 10);
	bbox->AddChild(new BStringView(rect, "stringViewPlayMode", str.String()));
	
	rect.OffsetBy(0, rect.Height());
	bbox->AddChild(fAutostartCB = new BCheckBox(rect, "chkboxAutostart", 
		"Automatically start playing", new BMessage(M_AUTOSTART)));

	rect.OffsetBy(SPACE, rect.Height() + SPACEING);
	bbox->AddChild(fCloseWindowMoviesCB = new BCheckBox(rect, "chkBoxCloseWindowMovies", 
		"Close window when done playing movies", new BMessage(M_CLOSE_WINDOW_MOVIE)));
	
	rect.OffsetBy(0, rect.Height() + SPACEING);
	bbox->AddChild(fCloseWindowSoundsCB = new BCheckBox(rect, "chkBoxCloseWindowSounds", 
		"Close window when done playing sounds", new BMessage(M_CLOSE_WINDOW_SOUNDS)));
	
	rect.OffsetBy(-SPACE, rect.Height() + SPACEING);
	bbox->AddChild(fLoopMoviesCB = new BCheckBox(rect, "chkBoxLoopMovie", "Loop movies by default",
		new BMessage(M_LOOP_MOVIE)));
	
	rect.OffsetBy(0, rect.Height() + SPACEING);
	bbox->AddChild(fLoopSoundsCB = new BCheckBox(rect, "chkBoxLoopSounds", "Loop sounds by default",
		new BMessage(M_LOOP_SOUND)));

	rect.OffsetBy(0, rect.Height() + SPACEING);
	bbox->AddChild(fUseOverlaysCB = new BCheckBox(rect, "chkBoxUseOverlays", "Use hardware video overlays if available",
		new BMessage(M_USE_OVERLAYS)));

	rect.OffsetBy(0, rect.Height() + SPACEING);
	bbox->AddChild(fScaleBilinearCB = new BCheckBox(rect, "chkBoxScaleBilinear", "Scale movies smoothly (non-overlay mode)",
		new BMessage(M_SCALE_BILINEAR)));

	rect.OffsetBy(0, rect.Height() + SPACE + SPACEING);
	bbox->AddChild(new BStringView(rect, "stringViewPlayBackg", 
		"Play backgrounds clips at:"));
	
	rect.OffsetBy(SPACE, rect.Height() + SPACEING);
	fFullVolumeBGMoviesRB = new BRadioButton(rect, "rdbtnfullvolume", 
		"Full Volume", new BMessage(M_START_FULL_VOLUME));
	bbox->AddChild(fFullVolumeBGMoviesRB);
	
	rect.OffsetBy(0, rect.Height() + SPACEING);
	fHalfVolumeBGMoviesRB = new BRadioButton(rect, "rdbtnhalfvolume", 
		"Low Volume", new BMessage(M_START_HALF_VOLUME));
	bbox->AddChild(fHalfVolumeBGMoviesRB);
	
	rect.OffsetBy(0, rect.Height() + SPACEING);
	fMutedVolumeBGMoviesRB = new BRadioButton(rect, "rdbtnfullvolume", "Muted",
		new BMessage(M_START_MUTE_VOLUME));
	bbox->AddChild(fMutedVolumeBGMoviesRB);

	view->AddChild(bbox);
	AddChild(view);
#endif

	// disable currently unsupported features
	fLoopMoviesCB->SetEnabled(false);
	fLoopSoundsCB->SetEnabled(false);
}
Esempio n. 9
0
AboutView::AboutView()
	: BView("aboutview", B_WILL_DRAW | B_PULSE_NEEDED),
	fLastActionTime(system_time()),
	fScrollRunner(NULL)
{
	// Begin Construction of System Information controls

	system_info systemInfo;
	get_system_info(&systemInfo);

	// Create all the various labels for system infomation

	// OS Version

	char string[1024];
	strcpy(string, B_TRANSLATE("Unknown"));

	// the version is stored in the BEOS:APP_VERSION attribute of libbe.so
	BPath path;
	if (find_directory(B_BEOS_LIB_DIRECTORY, &path) == B_OK) {
		path.Append("libbe.so");

		BAppFileInfo appFileInfo;
		version_info versionInfo;
		BFile file;
		if (file.SetTo(path.Path(), B_READ_ONLY) == B_OK
			&& appFileInfo.SetTo(&file) == B_OK
			&& appFileInfo.GetVersionInfo(&versionInfo,
				B_APP_VERSION_KIND) == B_OK
			&& versionInfo.short_info[0] != '\0')
			strcpy(string, versionInfo.short_info);
	}

	// Add revision from uname() info
	utsname unameInfo;
	if (uname(&unameInfo) == 0) {
		long revision;
		if (sscanf(unameInfo.version, "r%ld", &revision) == 1) {
			char version[16];
			snprintf(version, sizeof(version), "%ld", revision);
			strlcat(string, " (", sizeof(string));
			strlcat(string, B_TRANSLATE("Revision"), sizeof(string));
			strlcat(string, " ", sizeof(string));
			strlcat(string, version, sizeof(string));
			strlcat(string, ")", sizeof(string));
		}
	}

	BStringView* versionView = new BStringView("ostext", string);
	versionView->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT,
		B_ALIGN_VERTICAL_UNSET));

	// GCC version
	BEntry gccFourHybrid("/boot/system/lib/gcc2/libstdc++.r4.so");
	BEntry gccTwoHybrid("/boot/system/lib/gcc4/libsupc++.so");
	if (gccFourHybrid.Exists() || gccTwoHybrid.Exists())
		snprintf(string, sizeof(string), B_TRANSLATE("GCC %d Hybrid"),
			__GNUC__);
	else
		snprintf(string, sizeof(string), "GCC %d", __GNUC__);

	BStringView* gccView = new BStringView("gcctext", string);
	gccView->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT,
		B_ALIGN_VERTICAL_UNSET));

	// CPU count, type and clock speed
	char processorLabel[256];
	if (systemInfo.cpu_count > 1) {
		snprintf(processorLabel, sizeof(processorLabel),
			B_TRANSLATE("%ld Processors:"), systemInfo.cpu_count);
	} else
		strlcpy(processorLabel, B_TRANSLATE("Processor:"),
			sizeof(processorLabel));

	BString cpuType;
	cpuType << get_cpu_vendor_string(systemInfo.cpu_type)
		<< " " << get_cpu_model_string(&systemInfo);

	BStringView* cpuView = new BStringView("cputext", cpuType.String());
	cpuView->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT,
		B_ALIGN_VERTICAL_UNSET));

	int32 clockSpeed = get_rounded_cpu_speed();
	if (clockSpeed < 1000)
		sprintf(string, B_TRANSLATE("%ld MHz"), clockSpeed);
	else
		sprintf(string, B_TRANSLATE("%.2f GHz"), clockSpeed / 1000.0f);

	BStringView* frequencyView = new BStringView("frequencytext", string);
	frequencyView->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT,
		B_ALIGN_VERTICAL_UNSET));

	// RAM
	BStringView *memSizeView = new BStringView("ramsizetext",
		MemSizeToString(string, sizeof(string), &systemInfo));
	memSizeView->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT,
		B_ALIGN_VERTICAL_UNSET));
	fMemView = new BStringView("ramtext",
		MemUsageToString(string, sizeof(string), &systemInfo));
	fMemView->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT,
		B_ALIGN_VERTICAL_UNSET));

	// Kernel build time/date
	snprintf(string, sizeof(string), "%s %s",
		systemInfo.kernel_build_date, systemInfo.kernel_build_time);

	BStringView* kernelView = new BStringView("kerneltext", string);
	kernelView->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT,
		B_ALIGN_VERTICAL_UNSET));

	// Uptime
	fUptimeView = new BTextView("uptimetext");
	fUptimeView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	fUptimeView->MakeEditable(false);
	fUptimeView->MakeSelectable(false);
	fUptimeView->SetWordWrap(true);

	fUptimeView->SetText(UptimeToString(string, sizeof(string)));

	const float offset = 5;

	SetLayout(new BGroupLayout(B_HORIZONTAL));

	BLayoutBuilder::Group<>((BGroupLayout*)GetLayout())
		.AddGroup(B_VERTICAL)
			.Add(new LogoView())
			.AddGroup(B_VERTICAL)
				.Add(_CreateLabel("oslabel", B_TRANSLATE("Version:")))
				.Add(versionView)
				.Add(gccView)
				.AddStrut(offset)
				.Add(_CreateLabel("cpulabel", processorLabel))
				.Add(cpuView)
				.Add(frequencyView)
				.AddStrut(offset)
				.Add(_CreateLabel("memlabel", B_TRANSLATE("Memory:")))
				.Add(memSizeView)
				.Add(fMemView)
				.AddStrut(offset)
				.Add(_CreateLabel("kernellabel", B_TRANSLATE("Kernel:")))
				.Add(kernelView)
				.AddStrut(offset)
				.Add(_CreateLabel("uptimelabel",
					B_TRANSLATE("Time running:")))
				.Add(fUptimeView)
				.SetInsets(5, 5, 5, 5)
			.End()
			// TODO: investigate: adding this causes the time to be cut
			//.AddGlue()
		.End()
		.Add(_CreateCreditsView());

	float min = fMemView->MinSize().width * 1.1f;
	fCreditsView->SetExplicitMinSize(BSize(min, min));
}
Esempio n. 10
0
ApplicationTypeWindow::ApplicationTypeWindow(BPoint position,
	const BEntry& entry)
	:
	BWindow(BRect(0.0f, 0.0f, 250.0f, 340.0f).OffsetBySelf(position),
		B_TRANSLATE("Application type"), B_TITLED_WINDOW,
		B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS |
			B_FRAME_EVENTS | B_AUTO_UPDATE_SIZE_LIMITS),
	fChangedProperties(0)
{
	float padding = be_control_look->DefaultItemSpacing();
	BAlignment labelAlignment = be_control_look->DefaultLabelAlignment();

	BMenuBar* menuBar = new BMenuBar((char*)NULL);
	menuBar->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_TOP));

	BMenu* menu = new BMenu(B_TRANSLATE("File"));
	fSaveMenuItem = new BMenuItem(B_TRANSLATE("Save"),
		new BMessage(kMsgSave), 'S');
	fSaveMenuItem->SetEnabled(false);
	menu->AddItem(fSaveMenuItem);
	BMenuItem* item;
	menu->AddItem(item = new BMenuItem(
		B_TRANSLATE("Save into resource file" B_UTF8_ELLIPSIS), NULL));
	item->SetEnabled(false);

	menu->AddSeparatorItem();
	menu->AddItem(new BMenuItem(B_TRANSLATE("Close"),
		new BMessage(B_QUIT_REQUESTED), 'W', B_COMMAND_KEY));
	menuBar->AddItem(menu);

	// Signature

	fSignatureControl = new BTextControl(B_TRANSLATE("Signature:"), NULL,
		new BMessage(kMsgSignatureChanged));
	fSignatureControl->SetModificationMessage(
		new BMessage(kMsgSignatureChanged));

	// filter out invalid characters that can't be part of a MIME type name
	BTextView* textView = fSignatureControl->TextView();
	textView->SetMaxBytes(B_MIME_TYPE_LENGTH);
	const char* disallowedCharacters = "<>@,;:\"()[]?=";
	for (int32 i = 0; disallowedCharacters[i]; i++) {
		textView->DisallowChar(disallowedCharacters[i]);
	}

	// "Application Flags" group

	BBox* flagsBox = new BBox("flagsBox");

	fFlagsCheckBox = new BCheckBox("flags", B_TRANSLATE("Application flags"),
		new BMessage(kMsgToggleAppFlags));
	fFlagsCheckBox->SetValue(B_CONTROL_ON);

	fSingleLaunchButton = new BRadioButton("single",
		B_TRANSLATE("Single launch"), new BMessage(kMsgAppFlagsChanged));

	fMultipleLaunchButton = new BRadioButton("multiple",
		B_TRANSLATE("Multiple launch"), new BMessage(kMsgAppFlagsChanged));

	fExclusiveLaunchButton = new BRadioButton("exclusive",
		B_TRANSLATE("Exclusive launch"), new BMessage(kMsgAppFlagsChanged));

	fArgsOnlyCheckBox = new BCheckBox("args only", B_TRANSLATE("Args only"),
		new BMessage(kMsgAppFlagsChanged));

	fBackgroundAppCheckBox = new BCheckBox("background",
		B_TRANSLATE("Background app"), new BMessage(kMsgAppFlagsChanged));

	flagsBox->AddChild(BGridLayoutBuilder()
		.Add(fSingleLaunchButton, 0, 0).Add(fArgsOnlyCheckBox, 1, 0)
		.Add(fMultipleLaunchButton, 0, 1).Add(fBackgroundAppCheckBox, 1, 1)
		.Add(fExclusiveLaunchButton, 0, 2)
		.SetInsets(padding, padding, padding, padding));
	flagsBox->SetLabel(fFlagsCheckBox);

	// "Icon" group

	BBox* iconBox = new BBox("IconBox");
	iconBox->SetLabel(B_TRANSLATE("Icon"));
	fIconView = new IconView("icon");
	fIconView->SetModificationMessage(new BMessage(kMsgIconChanged));
	iconBox->AddChild(BGroupLayoutBuilder(B_HORIZONTAL)
		.Add(fIconView)
		.SetInsets(padding, padding, padding, padding));

	// "Supported Types" group

	BBox* typeBox = new BBox("typesBox");
	typeBox->SetLabel(B_TRANSLATE("Supported types"));

	fTypeListView = new SupportedTypeListView("Suppported Types",
		B_SINGLE_SELECTION_LIST);
	fTypeListView->SetSelectionMessage(new BMessage(kMsgTypeSelected));

	BScrollView* scrollView = new BScrollView("type scrollview", fTypeListView,
		B_FRAME_EVENTS | B_WILL_DRAW, false, true);

	fAddTypeButton = new BButton("add type",
		B_TRANSLATE("Add" B_UTF8_ELLIPSIS), new BMessage(kMsgAddType));

	fRemoveTypeButton = new BButton("remove type", B_TRANSLATE("Remove"),
		new BMessage(kMsgRemoveType));

	fTypeIconView = new IconView("type icon");
	BView* iconHolder = BGroupLayoutBuilder(B_HORIZONTAL).Add(fTypeIconView);
	fTypeIconView->SetModificationMessage(new BMessage(kMsgTypeIconsChanged));

	typeBox->AddChild(BGridLayoutBuilder(padding, padding)
		.Add(scrollView, 0, 0, 1, 4)
		.Add(fAddTypeButton, 1, 0, 1, 2)
		.Add(fRemoveTypeButton, 1, 2, 1, 2)
		.Add(iconHolder, 2, 1, 1, 2)
		.SetInsets(padding, padding, padding, padding)
		.SetColumnWeight(0, 3)
		.SetColumnWeight(1, 2)
		.SetColumnWeight(2, 1));
	iconHolder->SetExplicitAlignment(
		BAlignment(B_ALIGN_CENTER, B_ALIGN_MIDDLE));

	// "Version Info" group

	BBox* versionBox = new BBox("versionBox");
	versionBox->SetLabel(B_TRANSLATE("Version info"));

	fMajorVersionControl = new BTextControl(B_TRANSLATE("Version:"),
		NULL, NULL);
	_MakeNumberTextControl(fMajorVersionControl);

	fMiddleVersionControl = new BTextControl(".", NULL, NULL);
	_MakeNumberTextControl(fMiddleVersionControl);

	fMinorVersionControl = new BTextControl(".", NULL, NULL);
	_MakeNumberTextControl(fMinorVersionControl);

	fVarietyMenu = new BPopUpMenu("variety", true, true);
	fVarietyMenu->AddItem(new BMenuItem(B_TRANSLATE("Development"), NULL));
	fVarietyMenu->AddItem(new BMenuItem(B_TRANSLATE("Alpha"), NULL));
	fVarietyMenu->AddItem(new BMenuItem(B_TRANSLATE("Beta"), NULL));
	fVarietyMenu->AddItem(new BMenuItem(B_TRANSLATE("Gamma"), NULL));
	item = new BMenuItem(B_TRANSLATE("Golden master"), NULL);
	fVarietyMenu->AddItem(item);
	item->SetMarked(true);
	fVarietyMenu->AddItem(new BMenuItem(B_TRANSLATE("Final"), NULL));

	BMenuField* varietyField = new BMenuField("", fVarietyMenu);
	fInternalVersionControl = new BTextControl("/", NULL, NULL);
	fShortDescriptionControl =
		new BTextControl(B_TRANSLATE("Short description:"), NULL, NULL);

	// TODO: workaround for a GCC 4.1.0 bug? Or is that really what the standard says?
	version_info versionInfo;
	fShortDescriptionControl->TextView()->SetMaxBytes(
		sizeof(versionInfo.short_info));

	BStringView* longLabel = new BStringView(NULL,
		B_TRANSLATE("Long description:"));
	longLabel->SetExplicitAlignment(labelAlignment);
	fLongDescriptionView = new TabFilteringTextView("long desc");
	fLongDescriptionView->SetMaxBytes(sizeof(versionInfo.long_info));

	scrollView = new BScrollView("desc scrollview", fLongDescriptionView,
		B_FRAME_EVENTS | B_WILL_DRAW, false, true);

	// TODO: remove workaround (bug #5678)
	BSize minScrollSize = scrollView->ScrollBar(B_VERTICAL)->MinSize();
	minScrollSize.width += fLongDescriptionView->MinSize().width;
	scrollView->SetExplicitMinSize(minScrollSize);

	versionBox->AddChild(BGridLayoutBuilder(padding / 2, padding)
		.Add(fMajorVersionControl->CreateLabelLayoutItem(), 0, 0)
		.Add(fMajorVersionControl->CreateTextViewLayoutItem(), 1, 0)
		.Add(fMiddleVersionControl, 2, 0, 2)
		.Add(fMinorVersionControl, 4, 0, 2)
		.Add(varietyField, 6, 0, 3)
		.Add(fInternalVersionControl, 9, 0, 2)
		.Add(fShortDescriptionControl->CreateLabelLayoutItem(), 0, 1)
		.Add(fShortDescriptionControl->CreateTextViewLayoutItem(), 1, 1, 10)
		.Add(longLabel, 0, 2)
		.Add(scrollView, 1, 2, 10, 3)
		.SetInsets(padding, padding, padding, padding)
		.SetRowWeight(3, 3));

	// put it all together
	SetLayout(new BGroupLayout(B_VERTICAL));
	AddChild(menuBar);
	AddChild(BGroupLayoutBuilder(B_VERTICAL, padding)
		.Add(fSignatureControl)
		.Add(BGroupLayoutBuilder(B_HORIZONTAL, padding)
			.Add(flagsBox, 3)
			.Add(iconBox, 1))
		.Add(typeBox)
		.Add(versionBox)
		.SetInsets(padding, padding, padding, padding));

	SetKeyMenuBar(menuBar);

	fSignatureControl->MakeFocus(true);
	BMimeType::StartWatching(this);
	_SetTo(entry);
}
FormatSettingsView::FormatSettingsView()
	:
	BView("WindowsSettingsView", B_FRAME_EVENTS)
{
	fUseLanguageStringsCheckBox = new BCheckBox(
		B_TRANSLATE("Use month/day-names from preferred language"),
		new BMessage(kStringsLanguageChange));

	BStringView* fullDateLabel
		= new BStringView("", B_TRANSLATE("Full format:"));
	fullDateLabel->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT,
		B_ALIGN_VERTICAL_UNSET));
	BStringView* longDateLabel
		= new BStringView("", B_TRANSLATE("Long format:"));
	longDateLabel->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT,
		B_ALIGN_VERTICAL_UNSET));
	BStringView* mediumDateLabel
		= new BStringView("", B_TRANSLATE("Medium format:"));
	mediumDateLabel->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT,
		B_ALIGN_VERTICAL_UNSET));
	BStringView* shortDateLabel
		= new BStringView("", B_TRANSLATE("Short format:"));
	shortDateLabel->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT,
		B_ALIGN_VERTICAL_UNSET));

	fFullDateExampleView = new BStringView("", "");
	fFullDateExampleView->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT,
		B_ALIGN_VERTICAL_UNSET));
	fLongDateExampleView = new BStringView("", "");
	fLongDateExampleView->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT,
		B_ALIGN_VERTICAL_UNSET));
	fMediumDateExampleView = new BStringView("", "");
	fMediumDateExampleView->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT,
		B_ALIGN_VERTICAL_UNSET));
	fShortDateExampleView = new BStringView("", "");
	fShortDateExampleView->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT,
		B_ALIGN_VERTICAL_UNSET));

	f24HourRadioButton = new BRadioButton("", B_TRANSLATE("24 hour"),
		new BMessage(kClockFormatChange));
	f12HourRadioButton = new BRadioButton("", B_TRANSLATE("12 hour"),
		new BMessage(kClockFormatChange));

	float spacing = be_control_look->DefaultItemSpacing();

	BStringView* fullTimeLabel
		= new BStringView("", B_TRANSLATE("Full format:"));
	fullTimeLabel->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT,
		B_ALIGN_VERTICAL_UNSET));
	BStringView* longTimeLabel
		= new BStringView("", B_TRANSLATE("Long format:"));
	longTimeLabel->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT,
		B_ALIGN_VERTICAL_UNSET));
	BStringView* mediumTimeLabel
		= new BStringView("", B_TRANSLATE("Medium format:"));
	mediumTimeLabel->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT,
		B_ALIGN_VERTICAL_UNSET));
	BStringView* shortTimeLabel
		= new BStringView("", B_TRANSLATE("Short format:"));
	shortTimeLabel->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT,
		B_ALIGN_VERTICAL_UNSET));

	fFullTimeExampleView = new BStringView("", "");
	fFullTimeExampleView->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT,
		B_ALIGN_VERTICAL_UNSET));
	fLongTimeExampleView = new BStringView("", "");
	fLongTimeExampleView->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT,
		B_ALIGN_VERTICAL_UNSET));
	fMediumTimeExampleView = new BStringView("", "");
	fMediumTimeExampleView->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT,
		B_ALIGN_VERTICAL_UNSET));
	fShortTimeExampleView = new BStringView("", "");
	fShortTimeExampleView->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT,
		B_ALIGN_VERTICAL_UNSET));

	BStringView* positiveNumberLabel
		= new BStringView("", B_TRANSLATE("Positive:"));
	positiveNumberLabel->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT,
		B_ALIGN_VERTICAL_UNSET));
	BStringView* negativeNumberLabel
		= new BStringView("", B_TRANSLATE("Negative:"));
	negativeNumberLabel->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT,
		B_ALIGN_VERTICAL_UNSET));

	fPositiveNumberExampleView = new BStringView("", "");
	fPositiveNumberExampleView->SetExplicitAlignment(BAlignment(B_ALIGN_RIGHT,
		B_ALIGN_VERTICAL_UNSET));
	fNegativeNumberExampleView = new BStringView("", "");
	fNegativeNumberExampleView->SetExplicitAlignment(BAlignment(B_ALIGN_RIGHT,
		B_ALIGN_VERTICAL_UNSET));

	BStringView* positiveMonetaryLabel
		= new BStringView("", B_TRANSLATE("Positive:"));
	positiveMonetaryLabel->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT,
		B_ALIGN_VERTICAL_UNSET));
	BStringView* negativeMonetaryLabel
		= new BStringView("", B_TRANSLATE("Negative:"));
	negativeMonetaryLabel->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT,
		B_ALIGN_VERTICAL_UNSET));

	fPositiveMonetaryExampleView = new BStringView("", "");
	fPositiveMonetaryExampleView->SetExplicitAlignment(BAlignment(B_ALIGN_RIGHT,
		B_ALIGN_VERTICAL_UNSET));
	fNegativeMonetaryExampleView = new BStringView("", "");
	fNegativeMonetaryExampleView->SetExplicitAlignment(BAlignment(B_ALIGN_RIGHT,
		B_ALIGN_VERTICAL_UNSET));

	Refresh(true);

	fDateBox = new BBox(B_TRANSLATE("Date"));
	fTimeBox = new BBox(B_TRANSLATE("Time"));
	fNumberBox = new BBox(B_TRANSLATE("Numbers"));
	fMonetaryBox = new BBox(B_TRANSLATE("Currency"));

	fDateBox->SetLabel(B_TRANSLATE("Date"));
	fTimeBox->SetLabel(B_TRANSLATE("Time"));
	fNumberBox->SetLabel(B_TRANSLATE("Numbers"));
	fMonetaryBox->SetLabel(B_TRANSLATE("Currency"));

	fDateBox->AddChild(BLayoutBuilder::Grid<>(spacing, spacing / 2)
		.SetInsets(spacing, spacing, spacing, spacing)
		.Add(fullDateLabel, 0, 0)
		.Add(fFullDateExampleView, 1, 0)
		.Add(BSpaceLayoutItem::CreateGlue(), 2, 0)
		.Add(longDateLabel, 0, 1)
		.Add(fLongDateExampleView, 1, 1)
		.Add(BSpaceLayoutItem::CreateGlue(), 2, 1)
		.Add(mediumDateLabel, 0, 2)
		.Add(fMediumDateExampleView, 1, 2)
		.Add(BSpaceLayoutItem::CreateGlue(), 2, 2)
		.Add(shortDateLabel, 0, 3)
		.Add(fShortDateExampleView, 1, 3)
		.Add(BSpaceLayoutItem::CreateGlue(), 2, 3)
		.View());

	fTimeBox->AddChild(BLayoutBuilder::Grid<>(spacing, spacing / 2)
		.SetInsets(spacing, spacing, spacing, spacing)
		.AddGroup(B_HORIZONTAL, spacing, 0, 0, 2)
			.Add(f24HourRadioButton, 0)
			.Add(f12HourRadioButton, 0)
			.AddGlue()
			.End()
		.Add(fullTimeLabel, 0, 1)
		.Add(fFullTimeExampleView, 1, 1)
		.Add(BSpaceLayoutItem::CreateGlue(), 2, 1)
		.Add(longTimeLabel, 0, 2)
		.Add(fLongTimeExampleView, 1, 2)
		.Add(BSpaceLayoutItem::CreateGlue(), 2, 2)
		.Add(mediumTimeLabel, 0, 3)
		.Add(fMediumTimeExampleView, 1, 3)
		.Add(BSpaceLayoutItem::CreateGlue(), 2, 3)
		.Add(shortTimeLabel, 0, 4)
		.Add(fShortTimeExampleView, 1, 4)
		.Add(BSpaceLayoutItem::CreateGlue(), 2, 4)
		.View());

	fNumberBox->AddChild(BLayoutBuilder::Grid<>(spacing, spacing / 2)
		.SetInsets(spacing, spacing, spacing, spacing)
		.Add(positiveNumberLabel, 0, 0)
		.Add(fPositiveNumberExampleView, 1, 0)
		.Add(BSpaceLayoutItem::CreateGlue(), 2, 0)
		.Add(negativeNumberLabel, 0, 1)
		.Add(fNegativeNumberExampleView, 1, 1)
		.Add(BSpaceLayoutItem::CreateGlue(), 2, 1)
		.View());

	fMonetaryBox->AddChild(BLayoutBuilder::Grid<>(spacing, spacing / 2)
		.SetInsets(spacing, spacing, spacing, spacing)
		.Add(positiveMonetaryLabel, 0, 0)
		.Add(fPositiveMonetaryExampleView, 1, 0)
		.Add(BSpaceLayoutItem::CreateGlue(), 2, 0)
		.Add(negativeMonetaryLabel, 0, 1)
		.Add(fNegativeMonetaryExampleView, 1, 1)
		.Add(BSpaceLayoutItem::CreateGlue(), 2, 1)
		.View());

	BGroupLayout* rootLayout = new BGroupLayout(B_VERTICAL, spacing);
	SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	SetLayout(rootLayout);
	BLayoutBuilder::Group<>(rootLayout)
		.Add(fUseLanguageStringsCheckBox)
		.Add(fDateBox)
		.Add(fTimeBox)
		.AddGroup(B_HORIZONTAL, spacing)
			.Add(fNumberBox)
			.Add(fMonetaryBox)
			.AddGlue()
			.End()
		.AddGlue();
}
Esempio n. 12
0
ConfigView::ConfigView(TranslatorSettings *settings)
	: BGroupView("ICNSTranslator Settings", B_VERTICAL, 0)
{
	fSettings = settings;
	
	BAlignment leftAlignment(B_ALIGN_LEFT, B_ALIGN_VERTICAL_UNSET);

	BStringView *stringView = new BStringView("title", "OptiPNG Translator");
	stringView->SetFont(be_bold_font);
	stringView->SetExplicitAlignment(leftAlignment);
	AddChild(stringView);

	float spacing = be_control_look->DefaultItemSpacing();
	AddChild(BSpaceLayoutItem::CreateVerticalStrut(spacing));

	char version[256];
	sprintf(version, "Version %d.%d.%d, %s",
		int(B_TRANSLATION_MAJOR_VERSION(OPTIPNG_TRANSLATOR_VERSION)),
		int(B_TRANSLATION_MINOR_VERSION(OPTIPNG_TRANSLATOR_VERSION)),
		int(B_TRANSLATION_REVISION_VERSION(OPTIPNG_TRANSLATOR_VERSION)),
		__DATE__);
	stringView = new BStringView("version", version);
	stringView->SetExplicitAlignment(leftAlignment);
	AddChild(stringView);

	stringView = new BStringView("my_copyright",
		B_UTF8_COPYRIGHT "2013 Luke <*****@*****.**>.");
	stringView->SetExplicitAlignment(leftAlignment);
	AddChild(stringView);

	AddChild(BSpaceLayoutItem::CreateVerticalStrut(spacing));
	
	fOptimizationLevel = new BSlider(
		"optimization",
		"Optimization level:", new BMessage(kMsgOptim),
		0, 7, B_HORIZONTAL, B_BLOCK_THUMB);
	fOptimizationLevel->SetHashMarks(B_HASH_MARKS_BOTTOM);
	fOptimizationLevel->SetHashMarkCount(8);
	fOptimizationLevel->SetLimitLabels("Low", "High");
	fOptimizationLevel->SetValue(
		fSettings->SetGetInt32(OPTIPNG_SETTING_OPTIMIZATION_LEVEL));
	AddChild(fOptimizationLevel);
	
	fBitDepthCheckBox = new BCheckBox((char*)OPTIPNG_SETTING_BIT_DEPTH_REDUCTION,
		"Reduce bit depth:", new BMessage(kMsgBitDepth));
	if (fSettings->SetGetBool(OPTIPNG_SETTING_BIT_DEPTH_REDUCTION))
		fBitDepthCheckBox->SetValue(B_CONTROL_ON);
	AddChild(fBitDepthCheckBox);
	
	fColorTypeCheckBox = new BCheckBox((char*)OPTIPNG_SETTING_COLOR_TYPE_REDUCTION,
		"Reduce color type:", new BMessage(kMsgColorType));
	if (fSettings->SetGetBool(OPTIPNG_SETTING_COLOR_TYPE_REDUCTION))
		fColorTypeCheckBox->SetValue(B_CONTROL_ON);
	AddChild(fColorTypeCheckBox);
	
	fPaletteCheckBox = new BCheckBox((char*)OPTIPNG_SETTING_PALETTE_REDUCTION,
		"Reduce palette size:", new BMessage(kMsgPaletteReduc));
	if (fSettings->SetGetBool(OPTIPNG_SETTING_PALETTE_REDUCTION))
		fPaletteCheckBox->SetValue(B_CONTROL_ON);
	AddChild(fPaletteCheckBox);
	
	AddChild(BSpaceLayoutItem::CreateGlue());
	GroupLayout()->SetInsets(B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING, 
		B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING);

	SetExplicitPreferredSize(GroupLayout()->MinSize());		
}
void
PartitionsPage::_FillPartitionsView(BView* view)
{
	// show | name | type | size | path

	int32 rowNumber = 0;

	BMessage message;
	for (int32 i = 0; fSettings->FindMessage("partition", i, &message) == B_OK;
			i++, rowNumber++) {
		// get partition data
		bool show;
		BString name;
		BString type;
		BString path;
		int64 size;
		message.FindBool("show", &show);
		message.FindString("name", &name);
		message.FindString("type", &type);
		message.FindString("path", &path);
		message.FindInt64("size", &size);

		// check box
		BCheckBox* checkBox = new BCheckBox("show", "",
			_CreateControlMessage(kMessageShow, i));
		if (show)
			checkBox->SetValue(1);

		// name
		BTextControl* nameControl = new BTextControl("name", "",
			name.String(), _CreateControlMessage(kMessageName, i));
		nameControl->SetExplicitMinSize(BSize(StringWidth("WWWWWWWWWWWWWW"),
			B_SIZE_UNSET));

		// size
		BString sizeText;
		_CreateSizeText(size, &sizeText);
		sizeText << ", " << type.String();
		BStringView* typeView = new BStringView("type", sizeText.String());
		typeView->SetExplicitAlignment(
			BAlignment(B_ALIGN_LEFT, B_ALIGN_VERTICAL_UNSET));

		// path
		BStringView* pathView = new BStringView("path", path.String());
		pathView->SetExplicitAlignment(
			BAlignment(B_ALIGN_LEFT, B_ALIGN_VERTICAL_UNSET));

		if (rowNumber > 0) {
			BLayoutBuilder::Grid<>((BGridLayout*)view->GetLayout())
				.Add(new BSeparatorView(B_HORIZONTAL), 0, rowNumber, 4, 1)
				.SetRowWeight(rowNumber, 0);
			rowNumber++;
		}

		BLayoutBuilder::Grid<>((BGridLayout*)view->GetLayout())
			.Add(checkBox, 0, rowNumber, 1, 2)
			.Add(nameControl, 1, rowNumber, 1, 2)
			.Add(BSpaceLayoutItem::CreateHorizontalStrut(10), 2, rowNumber)
			.Add(typeView, 3, rowNumber)
			.Add(pathView, 3, rowNumber + 1)
			.SetRowWeight(rowNumber + 1, 1);
		rowNumber++;
	}
}