Exemplo n.º 1
0
void
TimeZoneView::_InitView()
{
	fZoneList = new BOutlineListView("cityList", B_SINGLE_SELECTION_LIST);
	fZoneList->SetSelectionMessage(new BMessage(H_CITY_CHANGED));
	fZoneList->SetInvocationMessage(new BMessage(H_SET_TIME_ZONE));
	_BuildZoneMenu();
	BScrollView* scrollList = new BScrollView("scrollList", fZoneList,
		B_FRAME_EVENTS | B_WILL_DRAW, false, true);
	scrollList->SetExplicitMinSize(BSize(200, 0));

	fCurrent = new TTZDisplay("currentTime", B_TRANSLATE("Current time:"));
	fPreview = new TTZDisplay("previewTime", B_TRANSLATE("Preview time:"));

	fSetZone = new BButton("setTimeZone", B_TRANSLATE("Set time zone"),
		new BMessage(H_SET_TIME_ZONE));
	fSetZone->SetEnabled(false);
	fSetZone->SetExplicitAlignment(
		BAlignment(B_ALIGN_RIGHT, B_ALIGN_BOTTOM));

	BStringView* text = new BStringView("clockSetTo",
		B_TRANSLATE("Hardware clock set to:"));
	fLocalTime = new BRadioButton("localTime",
		B_TRANSLATE("Local time (Windows compatible)"), new BMessage(kRTCUpdate));
	fGmtTime = new BRadioButton("greenwichMeanTime",
		B_TRANSLATE("GMT (UNIX compatible)"), new BMessage(kRTCUpdate));

	if (fUseGmtTime)
		fGmtTime->SetValue(B_CONTROL_ON);
	else
		fLocalTime->SetValue(B_CONTROL_ON);
	_ShowOrHidePreview();
	fOldUseGmtTime = fUseGmtTime;


	const float kInset = be_control_look->DefaultItemSpacing();
	BLayoutBuilder::Group<>(this)
		.Add(scrollList)
		.AddGroup(B_VERTICAL, kInset)
			.Add(text)
			.AddGroup(B_VERTICAL, kInset)
				.Add(fLocalTime)
				.Add(fGmtTime)
			.End()
			.AddGlue()
			.Add(fCurrent)
			.Add(fPreview)
			.Add(fSetZone)
		.End()
		.SetInsets(kInset, kInset, kInset, kInset);
}
Exemplo n.º 2
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);
}
Exemplo n.º 3
0
ProjectSettingsWindow::ProjectSettingsWindow(BRect frame, Project* project)
	:
	BWindow(frame, TR("Project settings"), B_TITLED_WINDOW,
		B_NOT_ZOOMABLE | B_NOT_RESIZABLE | B_AUTO_UPDATE_SIZE_LIMITS),
	fProject(project),
	fDirty(false)
{
	if (fProject == NULL)
		debugger("Bad project given to Project Settings window");

	fRefFilter = new TypedRefFilter(NULL, B_DIRECTORY_NODE);

	BMessenger messenger(this);
	entry_ref projectFolderRef;
	BEntry(fProject->GetPath().GetFolder()).GetRef(&projectFolderRef);
	fFilePanel = new BFilePanel(B_OPEN_PANEL, &messenger, &projectFolderRef,
		B_DIRECTORY_NODE, true, new BMessage(M_ADD_PATH), fRefFilter);

	fAutolock = new BAutolock(fProject);

	AddCommonFilter(new EscapeCancelFilter());

	fTargetText = new AutoTextControl("targetname", TR("Target name:"),
		fProject->GetTargetName(), new BMessage(M_TARGET_NAME_CHANGED));

	BPopUpMenu* targetTypeMenu = new BPopUpMenu(TR("Target type"));
	targetTypeMenu->AddItem(new BMenuItem(TR("Application"),
		new BMessage(M_SET_TARGET_TYPE)));
	targetTypeMenu->AddItem(new BMenuItem(TR("Shared library"),
		new BMessage(M_SET_TARGET_TYPE)));
	targetTypeMenu->AddItem(new BMenuItem(TR("Static library"),
		new BMessage(M_SET_TARGET_TYPE)));
	targetTypeMenu->AddItem(new BMenuItem(TR("Device driver"),
		new BMessage(M_SET_TARGET_TYPE)));

	fTypeField = new BMenuField("type", TR("Target type:"), targetTypeMenu);
	SetToolTip(fTypeField, TR("The kind of program you want to build"));

	BMenuItem* item = targetTypeMenu->ItemAt(fProject->TargetType());
	if (item != NULL)
		item->SetMarked(true);

	fIncludeList = new IncludeList(fProject->GetPath().GetFolder());
	SetToolTip(fIncludeList,
		TR("The folders you want Paladin to search for header files"));

	BScrollView* includeScrollView = new BScrollView("includescrollview",
		fIncludeList, B_WILL_DRAW, true, true);
	includeScrollView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	includeScrollView->SetExplicitMinSize(
		BSize(be_plain_font->StringWidth("M") * 34.0f,
			be_plain_font->StringWidth("M") * 12.0f));

	for (int32 i = 0; i < fProject->CountLocalIncludes(); i++) {
		fIncludeList->AddItem(new BStringItem(
			fProject->LocalIncludeAt(i).Relative().String()));
	}

	float buttonWidth = be_plain_font->StringWidth("+") * 2.0f + 3.0f;

	BButton* addButton = new BButton("addbutton", TR("+"),
		new BMessage(M_SHOW_ADD_PATH));
	addButton->SetExplicitSize(BSize(buttonWidth, buttonWidth));
	addButton->SetToolTip(TR("Add a file to the include path list"));

	BButton* removeButton = new BButton("removebutton", TR("−"),
		new BMessage(M_REMOVE_PATH));
	removeButton->SetExplicitSize(BSize(buttonWidth, buttonWidth));
	removeButton->SetToolTip(TR("Remove the selected path"));

	// general tab

	fGeneralView = new BView(TR("General"), B_WILL_DRAW);
	fGeneralView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));

	BLayoutBuilder::Group<>(fGeneralView, B_VERTICAL, 0)
		.AddGrid(B_USE_DEFAULT_SPACING, B_USE_SMALL_SPACING)
			.Add(fTargetText->CreateLabelLayoutItem(), 0, 0)
			.Add(fTargetText->CreateTextViewLayoutItem(), 1, 0)

			.Add(fTypeField->CreateLabelLayoutItem(), 0, 1)
			.AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING, 1, 1)
				.Add(fTypeField->CreateMenuBarLayoutItem())
				.AddGlue()
				.End()
			.End()
		.AddStrut(B_USE_DEFAULT_SPACING)
		.AddGroup(B_VERTICAL, 2.0f)
			.Add(new BStringView("include paths", TR("Include paths:")))
			.AddGroup(B_HORIZONTAL, B_USE_SMALL_SPACING)
				.Add(includeScrollView)
				.AddGroup(B_VERTICAL, B_USE_SMALL_SPACING)
					.Add(addButton)
					.Add(removeButton)
					.AddGlue()
					.End()
				.End()
			.End()
		.SetInsets(B_USE_DEFAULT_SPACING)
		.End();

	BPopUpMenu* optimizationMenu = new BPopUpMenu(TR("Optimization"));
	optimizationMenu->AddItem(new BMenuItem(TR("None"),
		new BMessage(M_SET_OP_VALUE)));
	optimizationMenu->AddItem(new BMenuItem(TR("Some"),
		new BMessage(M_SET_OP_VALUE)));
	optimizationMenu->AddItem(new BMenuItem(TR("More"),
		new BMessage(M_SET_OP_VALUE)));
	optimizationMenu->AddItem(new BMenuItem(TR("Full"),
		new BMessage(M_SET_OP_VALUE)));

	fOpField = new BMenuField("optimize", TR("Optimize:"), optimizationMenu);
	SetToolTip(fOpField, TR("Compiler optimization level. "
		"Disabled when debugging info is checked."));

	item = optimizationMenu->ItemAt(fProject->OpLevel());
	if (item != NULL)
		item->SetMarked(true);

	fOpSizeBox = new BCheckBox("opsizebox", TR("Optimize for size over speed"),
		new BMessage(M_TOGGLE_OPSIZE));

	if (fProject->OpForSize())
		fOpSizeBox->SetValue(B_CONTROL_ON);
	
	if (fProject->Debug()) {
		fOpField->SetEnabled(false);
		fOpSizeBox->SetEnabled(false);
	}

	fDebugBox = new BCheckBox("debugbox", TR("Build debugging information"),
		new BMessage(M_TOGGLE_DEBUG));
	SetToolTip(fDebugBox,
		TR("Check this if you want to use your program in a debugger "
		   "during development. You'll want to rebuild your project "
		   "after change this."));

	if (fProject->Debug())
		fDebugBox->SetValue(B_CONTROL_ON);

	fProfileBox = new BCheckBox("profilebox", TR("Build profiling information"),
		new BMessage(M_TOGGLE_PROFILE));
	SetToolTip(fProfileBox,
		TR("Check this if you want to use your program "
		   "with gprof or bprof for profiling."));

	if (fProject->Profiling())
		fProfileBox->SetValue(B_CONTROL_ON);

	fCompileText = new AutoTextControl("extracc", "Extra compiler options:",
		fProject->ExtraCompilerOptions(), new BMessage(M_CCOPTS_CHANGED));
	SetToolTip(fCompileText,
		TR("Extra GCC flags you wish included when each file is compiled."));

	fLinkText = new AutoTextControl("extrald" ,TR("Extra linker options:"),
		fProject->ExtraLinkerOptions(), new BMessage(M_LDOPTS_CHANGED));
	SetToolTip(fLinkText,
		TR("Extra GCC linker flags you wish included when your project "
		   "is linked."));

	// build tab

	fBuildView = new BView("Build", B_WILL_DRAW);
	fBuildView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));

	BLayoutBuilder::Group<>(fBuildView, B_VERTICAL)
		.AddGrid(B_USE_DEFAULT_SPACING, B_USE_SMALL_SPACING)
			.Add(fOpField->CreateLabelLayoutItem(), 0, 0)
			.AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING, 1, 0)
				.Add(fOpField->CreateMenuBarLayoutItem())
				.AddGlue()
				.End()
			.AddGroup(B_VERTICAL, 0.0f, 1, 2)
				.Add(fOpSizeBox)
				.AddStrut(B_USE_SMALL_SPACING)
				.Add(fDebugBox)
				.Add(fProfileBox)
				.End()
			.End()
		.AddGlue()
		.AddGroup(B_VERTICAL, 0)
			.Add(fCompileText->CreateLabelLayoutItem())
			.Add(fCompileText->CreateTextViewLayoutItem())
			.End()
		.AddGroup(B_VERTICAL, 0)
			.Add(fLinkText->CreateLabelLayoutItem())
			.Add(fLinkText->CreateTextViewLayoutItem())
			.End()
		.SetInsets(B_USE_DEFAULT_SPACING)
		.End();

	fTabView = new BTabView("tabview", B_WIDTH_FROM_LABEL);
	fTabView->SetBorder(B_NO_BORDER);
	fTabView->AddTab(fGeneralView);
	fTabView->AddTab(fBuildView);
	fTabView->Select(0L);

	BLayoutBuilder::Group<>(this, B_VERTICAL, 0)
		.AddStrut(B_USE_SMALL_SPACING)
		.Add(fTabView)
		.End();

	targetTypeMenu->SetTargetForItems(this);
	optimizationMenu->SetTargetForItems(this);

	fIncludeList->Select(0);
	fTargetText->MakeFocus(true);
}
Exemplo n.º 4
0
int
main(int argc, char** argv)
{
	BApplication app("application/x-vnd.antares-look");

	BWindow* window = new Window(BRect(50, 50, 100, 100),
		"Look at these pretty controls!", B_TITLED_WINDOW,
		B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS
			| B_QUIT_ON_WINDOW_CLOSE);

	window->SetLayout(new BGroupLayout(B_HORIZONTAL));

	// create some controls

	// BListView
	BListView* listView = new BListView();
	for (int32 i = 0; i < 20; i++) {
		BString itemLabel("List item ");
		itemLabel << i + 1;
		listView->AddItem(new BStringItem(itemLabel.String()));
	}
	BScrollView* scrollView = new BScrollView("scroller", listView, 0,
		true, true);
	scrollView->SetExplicitMinSize(BSize(300, 140));

	// BColumnListView
	BColumnListView* columnListView = new BColumnListView("clv", 0,
		B_FANCY_BORDER);
//	for (int32 i = 0; i < 20; i++) {
//		BString itemLabel("List Item ");
//		itemLabel << i + 1;
//		columnListView->AddItem(new BStringItem(itemLabel.String()));
//	}


	BGridView* controls = new BGridView(kInset, kInset);
	BGridLayout* layout = controls->GridLayout();
	controls->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNLIMITED));

	int32 row = 0;
	add_controls<BButton>(layout, row);
	add_controls<BCheckBox>(layout, row);
	add_controls<BRadioButton>(layout, row);
	add_menu_fields(layout, row);
	add_text_controls(layout, row);
	add_sliders(layout, row);
	add_status_bars(layout, row);

	BColorControl* colorControl = new BColorControl(B_ORIGIN, B_CELLS_32x8,
		8.0f, "color control");
	layout->AddView(colorControl, 0, row, 4);

	BTabView* tabView = new BTabView("tab view", B_WIDTH_FROM_WIDEST);
	BView* content = BGroupLayoutBuilder(B_VERTICAL, kInset)
		.Add(scrollView)
		.Add(columnListView)
		.Add(controls)
		.SetInsets(kInset, kInset, kInset, kInset);

	content->SetName("Tab 1");

	tabView->AddTab(content);
	BView* tab2 = new BView("Tab 2", 0);
	tab2->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	tabView->AddTab(tab2);
	tabView->AddTab(new BView("Tab 3", 0));

	BMenuBar* menuBar = new BMenuBar("menu bar");
	BMenu* menu = new BMenu("File");
	menu->AddItem(new BMenuItem("Test Open BFilePanel",
		new BMessage(MSG_TEST_OPEN_FILE_PANEL)));
	menu->AddItem(new BMenuItem("Test Save BFilePanel",
		new BMessage(MSG_TEST_SAVE_FILE_PANEL)));
	menu->AddItem(new BMenuItem("Click me!", NULL));
	menu->AddItem(new BMenuItem("Another option", NULL));
	menu->AddSeparatorItem();
	menu->AddItem(new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED)));
	menuBar->AddItem(menu);
	menu = new BMenu("Edit");
	menu->SetEnabled(false);
	menu->AddItem(new BMenuItem("Cut", NULL));
	menu->AddItem(new BMenuItem("Copy", NULL));
	menu->AddSeparatorItem();
	menu->AddItem(new BMenuItem("Past", NULL));
	menuBar->AddItem(menu);
	menu = new BMenu("One Item");
	menu->AddItem(new BMenuItem("Only", NULL));
	menuBar->AddItem(menu);
	menu = new BMenu("Sub Menu");
	BMenu* subMenu = new BMenu("Click me");
	subMenu->AddItem(new BMenuItem("Either", NULL));
	subMenu->AddItem(new BMenuItem("Or", NULL));
	subMenu->SetRadioMode(true);
	menu->AddItem(subMenu);
	menuBar->AddItem(menu);

	BButton* okButton = new BButton("OK", new BMessage(B_QUIT_REQUESTED));

	window->AddChild(BGroupLayoutBuilder(B_VERTICAL)
		.Add(menuBar)
		.Add(BGroupLayoutBuilder(B_VERTICAL, kInset)
			.Add(tabView)
			.Add(BGroupLayoutBuilder(B_HORIZONTAL, kInset)
				.Add(new BButton("Revert", new BMessage(MSG_TOGGLE_LOOK)))
				.Add(BSpaceLayoutItem::CreateGlue())
				.Add(new BButton("Cancel", NULL))
				.Add(okButton)
			)
			.SetInsets(kInset, kInset, kInset, kInset)
		)
	);

	window->SetDefaultButton(okButton);

	window->Show();
	app.Run();
	return 0;
}
Exemplo n.º 5
0
TeamMonitorWindow::TeamMonitorWindow()
	:
	BWindow(BRect(0, 0, 350, 100), B_TRANSLATE("Team monitor"),
		B_TITLED_WINDOW_LOOK, B_MODAL_ALL_WINDOW_FEEL,
		B_NOT_MINIMIZABLE | B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS
			| B_CLOSE_ON_ESCAPE | B_AUTO_UPDATE_SIZE_LIMITS,
		B_ALL_WORKSPACES),
	fQuitting(false),
	fUpdateRunner(NULL)
{
	BGroupLayout* layout = new BGroupLayout(B_VERTICAL);
	float inset = 10;
	layout->SetInsets(inset, inset, inset, inset);
	layout->SetSpacing(inset);
	SetLayout(layout);

	layout->View()->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));

	fListView = new BListView("teams");
	fListView->SetSelectionMessage(new BMessage(TM_SELECTED_TEAM));

	BScrollView* scrollView = new BScrollView("scroll_teams", fListView,
		0, B_SUPPORTS_LAYOUT, false, true, B_FANCY_BORDER);
	scrollView->SetExplicitMinSize(BSize(B_SIZE_UNSET, 150));

	fKillButton = new BButton("kill", B_TRANSLATE("Kill application"),
		new BMessage(TM_KILL_APPLICATION));
	fKillButton->SetEnabled(false);

	fQuitButton = new BButton("quit", B_TRANSLATE("Quit application"),
		new BMessage(TM_QUIT_APPLICATION));
	fQuitButton->SetEnabled(false);

	fDescriptionView = new TeamDescriptionView;

	BButton* forceReboot = new BButton("force", B_TRANSLATE("Force reboot"),
		new BMessage(TM_FORCE_REBOOT));

	fRestartButton = new BButton("restart", B_TRANSLATE("Restart the desktop"),
		new BMessage(TM_RESTART_DESKTOP));

	fCancelButton = new BButton("cancel", B_TRANSLATE("Cancel"),
		new BMessage(TM_CANCEL));
	SetDefaultButton(fCancelButton);

	BGroupLayoutBuilder(layout)
		.Add(scrollView)
		.AddGroup(B_HORIZONTAL)
			.Add(fKillButton)
			.Add(fQuitButton)
			.AddGlue()
			.End()
		.Add(fDescriptionView)
		.AddGroup(B_HORIZONTAL)
			.Add(forceReboot)
			.AddGlue()
			.Add(fRestartButton)
			.AddGlue(inset)
			.Add(fCancelButton);

	CenterOnScreen();

	fRestartButton->Hide();

	AddShortcut('T', B_COMMAND_KEY | B_OPTION_KEY,
		new BMessage(kMsgLaunchTerminal));
	AddShortcut('W', B_COMMAND_KEY, new BMessage(B_QUIT_REQUESTED));

	gLocalizedNamePreferred
		= BLocaleRoster::Default()->IsFilesystemTranslationPreferred();

	gTeamMonitorWindow = this;

	this->AddCommonFilter(new BMessageFilter(B_ANY_DELIVERY,
		B_ANY_SOURCE, B_KEY_DOWN, FilterKeyDown));

	if (be_app->Lock()) {
		be_app->AddCommonFilter(new BMessageFilter(B_ANY_DELIVERY,
			B_ANY_SOURCE, B_LOCALE_CHANGED, FilterLocaleChanged));
		be_app->Unlock();
	}
}
Exemplo n.º 6
0
FindWindow::FindWindow(BString workingDir)
	:	DWindow(BRect(100,100,600,500), B_TRANSLATE("Find in project"), B_TITLED_WINDOW,
				B_CLOSE_ON_ESCAPE),
		fIsRegEx(false),
		fIgnoreCase(true),
		fMatchWord(false),
		fThreadID(-1),
		fThreadMode(0),
		fThreadQuitFlag(0),
		fFileList(20, true),
		fWorkingDir(""),
		fProject(NULL)
{
	SetSizeLimits(650, 30000, 400, 30000);
	
	MakeCenteredOnShow(true);
	fMenuBar = new BMenuBar("menubar");
	
	fFindButton = new BButton("findbutton", B_TRANSLATE("Replace all"),
								new BMessage(M_FIND));
	fFindButton->SetLabel(B_TRANSLATE("Find"));
	fFindButton->SetEnabled(false);
	
	fFindBox = new DTextView("findbox");
	fFindBox->SetFlags(fFindBox->Flags() | B_NAVIGABLE_JUMP);
	
	BScrollView *findBoxScroll = fFindBox->MakeScrollView("findscroll", true, true);
	
	fReplaceBox = new DTextView("replacebox");
	fReplaceBox->SetFlags(fFindBox->Flags() | B_NAVIGABLE_JUMP);	
	BScrollView *replaceBoxScroll = fReplaceBox->MakeScrollView("replacescroll", true, true);
	
	BGroupLayout* hGroup = new BGroupLayout(B_HORIZONTAL,0);
	BView* hView = new BView("hview",0,hGroup);
	
	fReplaceButton = new BButton("replacebutton", B_TRANSLATE("Replace"),
								new BMessage(M_REPLACE));
	fReplaceButton->SetEnabled(false);
	//hGroup->AddView(fReplaceButton);
	// hidden until we decide we need an individual replace in a multi
	//   file dialog box (doubtful - could click on file and do it from
	//   within pe)
	
	fReplaceAllButton = new BButton("replaceallbutton", B_TRANSLATE("Replace all"),
								new BMessage(M_REPLACE_ALL));
	fReplaceAllButton->SetEnabled(false);
	hGroup->AddView(fReplaceAllButton);
	
	BStringView *resultLabel = new BStringView("resultlabel", B_TRANSLATE("Results:"));
	
	fResultList = new DListView("resultlist", B_MULTIPLE_SELECTION_LIST);
	BScrollView* resultsScroll = fResultList->MakeScrollView("resultscroll", true, true);
	resultsScroll->SetExplicitMinSize(BSize(650,150));
	fResultList->SetInvocationMessage(new BMessage(M_SHOW_RESULT));
	
	BLayoutBuilder::Group<>(this, B_VERTICAL)
		.Add(fMenuBar)
		.Add(findBoxScroll)
		.Add(fFindButton)
		.Add(replaceBoxScroll)
		.Add(hView)
		.Add(resultLabel)
		.Add(resultsScroll)
	.End();
	
	BMenu *menu = new BMenu(B_TRANSLATE("Search"));
	menu->AddItem(new BMenuItem(B_TRANSLATE("Find"), new BMessage(M_FIND), 'F', B_COMMAND_KEY));
	menu->AddSeparatorItem();
	menu->AddItem(new BMenuItem(B_TRANSLATE("Replace"), new BMessage(M_REPLACE), 'R', B_COMMAND_KEY));
	menu->AddItem(new BMenuItem(B_TRANSLATE("Replace all"), new BMessage(M_REPLACE_ALL), 'R',
								B_COMMAND_KEY | B_SHIFT_KEY));
	fMenuBar->AddItem(menu);
	
	menu = new BMenu(B_TRANSLATE("Options"));
	menu->AddItem(new BMenuItem(B_TRANSLATE("Regular expression"), new BMessage(M_TOGGLE_REGEX)));
	menu->AddItem(new BMenuItem(B_TRANSLATE("Ignore case"), new BMessage(M_TOGGLE_CASE_INSENSITIVE)));
	menu->AddItem(new BMenuItem(B_TRANSLATE("Match whole word"), new BMessage(M_TOGGLE_MATCH_WORD)));
	fMenuBar->AddItem(menu);
	
	BMenuItem *item = fMenuBar->FindItem(B_TRANSLATE("Ignore case"));
	if (fIgnoreCase)
		item->SetMarked(true);
	
	menu = new BMenu(B_TRANSLATE("Project"));
	menu->SetRadioMode(true);
	gProjectList->Lock();
	for (int32 i = 0; i < gProjectList->CountItems(); i++)
	{
		Project *proj = gProjectList->ItemAt(i);
		BMessage *msg = new BMessage(M_SET_PROJECT);
		msg->AddPointer("project", proj);
		BMenuItem *projItem = new BMenuItem(proj->GetName(), msg);
		menu->AddItem(projItem);
		if (gCurrentProject == proj)
		{
			projItem->SetMarked(true);
			fProject = proj;
		}
	}
	gProjectList->Unlock();
	fMenuBar->AddItem(menu);
	
	SetProject(fProject);
	
	EnableReplace(false);
	
	SetWorkingDirectory(workingDir);
	
	// The search terms box will tell us whenever it has been changed at every keypress
	fFindBox->SetMessage(new BMessage(M_FIND_CHANGED));
	fFindBox->SetTarget(this);
	fFindBox->SetChangeNotifications(true);
	fFindBox->MakeFocus(true);
	
	fReplaceBox->SetMessage(new BMessage(M_REPLACE_CHANGED));
	fReplaceBox->SetTarget(this);
	fReplaceBox->SetChangeNotifications(true);
}