DecorSettingsView::DecorSettingsView(const char* name)
	:
	BView(name, 0)
{
	// Decorator menu
	_BuildDecorMenu();
	fDecorMenuField = new BMenuField("decorator",
		B_TRANSLATE("Window Decorator:"), fDecorMenu);

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

	SetLayout(new BGroupLayout(B_VERTICAL));

	// control layout
	AddChild(BGridLayoutBuilder(10, 10)
		.Add(fDecorMenuField->CreateLabelLayoutItem(), 0, 0)
        .Add(fDecorMenuField->CreateMenuBarLayoutItem(), 1, 0)
		.Add(fDecorInfoButton, 2, 0)

        .Add(BSpaceLayoutItem::CreateGlue(), 0, 3, 2)
        .SetInsets(10, 10, 10, 10)
    );
	// TODO : Decorator Preview Image?
}
DisplayView::DisplayView(SettingsHost* host)
	:
	SettingsPane("display", host)
{
	// Window width
	fWindowWidth = new BTextControl(B_TRANSLATE("Window width:"), NULL,
		new BMessage(kSettingChanged));

	// Icon size
	fIconSize = new BMenu("iconSize");
	fIconSize->AddItem(new BMenuItem(B_TRANSLATE("Mini icon"),
		new BMessage(kSettingChanged)));
	fIconSize->AddItem(new BMenuItem(B_TRANSLATE("Large icon"),
		new BMessage(kSettingChanged)));
	fIconSize->SetLabelFromMarked(true);
	fIconSizeField = new BMenuField(B_TRANSLATE("Icon size:"), fIconSize);

	// Load settings
	Load();

	// Calculate inset
	float inset = ceilf(be_plain_font->Size() * 0.7f);

	SetLayout(new BGroupLayout(B_VERTICAL));
	AddChild(BGridLayoutBuilder(inset, inset)
		.Add(fWindowWidth->CreateLabelLayoutItem(), 0, 0)
		.Add(fWindowWidth->CreateTextViewLayoutItem(), 1, 0)
		.Add(fIconSizeField->CreateLabelLayoutItem(), 0, 1)
		.Add(fIconSizeField->CreateMenuBarLayoutItem(), 1, 1)
		.Add(BSpaceLayoutItem::CreateGlue(), 0, 2, 2, 1)
		.SetInsets(inset, inset, inset, inset)
	);
}
SaveIdea::SaveIdea(const BMessage &msg, const BMessenger &msgr, float mainX, float mainY, int currentID)
	:	BWindow(BRect(0, 0, 358, 60), "Save As", B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS, B_CURRENT_WORKSPACE), updatetitleMessage(msg), updatetitleMessenger(msgr)
{
	// initialize controls
	AddShortcut(B_TAB, B_COMMAND_KEY, new BMessage(END_SAVE_IDEA));
	AddShortcut(B_ENTER, B_COMMAND_KEY, new BMessage(SAVE_IDEA));
	AddShortcut(B_ESCAPE, B_COMMAND_KEY, new BMessage(CANCEL_SAVE));
	SetDefaultButton(saveButton);
	BRect textFrame(0, 0, 300, 10);
	titleText = new BTextView(textFrame, NULL, textFrame, B_FOLLOW_LEFT_RIGHT, B_WILL_DRAW);
	titleText->MakeResizable(false);
	titleText->SetWordWrap(false);
	titleText->DisallowChar(B_ENTER);
	titleString = new BStringView(BRect(10, 10, 200, 30), NULL, "Enter Thought Title:");
	saveButton = new BButton(BRect(190, 50, 270, 75), NULL, "Save", new BMessage(SAVE_IDEA));
	cancelButton = new BButton(BRect(190, 50, 270, 75), NULL, "Cancel", new BMessage(CANCEL_SAVE));
	backView = new BView(Bounds(), "backview", B_FOLLOW_ALL, B_WILL_DRAW);
	backView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	AddChild(backView);
	// gui layout builder
	backView->SetLayout(new BGroupLayout(B_HORIZONTAL, 0.0));
	backView->AddChild(BGridLayoutBuilder()
		.Add(titleString, 0, 0, 2, 1)
		.Add(titleText, 2, 0, 3, 1)
		.Add(cancelButton, 3, 1)
		.Add(saveButton, 4, 1)
		.Add(BSpaceLayoutItem::CreateGlue(), 0, 2, 2, 1)
		.SetInsets(2, 5, 2, 2)
	);
	MoveTo(mainX, mainY); // move to window position
	
	currentideaID = currentID; // make current idea id available to 
}
BView*
SettingsWindow::_CreateFontsPage(float spacing)
{
	fStandardFontView = new FontSelectionView("standard",
		B_TRANSLATE("Standard font:"), true, be_plain_font);
	BFont defaultSerifFont = _FindDefaultSerifFont();
	fSerifFontView = new FontSelectionView("serif",
		B_TRANSLATE("Serif font:"), true, &defaultSerifFont);
	fSansSerifFontView = new FontSelectionView("sans serif",
		B_TRANSLATE("Sans serif font:"), true, be_plain_font);
	fFixedFontView = new FontSelectionView("fixed",
		B_TRANSLATE("Fixed font:"), true, be_fixed_font);

	fStandardSizesMenu =  new BMenuField("standard font size",
		B_TRANSLATE("Default standard font size:"), new BPopUpMenu("sizes"),
		B_WILL_DRAW);
	_BuildSizesMenu(fStandardSizesMenu->Menu(),
		MSG_STANDARD_FONT_SIZE_SELECTED);

	fFixedSizesMenu =  new BMenuField("fixed font size",
		B_TRANSLATE("Default fixed font size:"), new BPopUpMenu("sizes"),
		B_WILL_DRAW);
	_BuildSizesMenu(fFixedSizesMenu->Menu(), MSG_FIXED_FONT_SIZE_SELECTED);

	BView* view = BGridLayoutBuilder(spacing / 2, spacing / 2)
		.Add(fStandardFontView->CreateFontsLabelLayoutItem(), 0, 0)
		.Add(fStandardFontView->CreateFontsMenuBarLayoutItem(), 1, 0)
		.Add(fStandardFontView->PreviewBox(), 0, 1, 2)
		.Add(BSpaceLayoutItem::CreateHorizontalStrut(spacing), 0, 2, 2)

		.Add(fSerifFontView->CreateFontsLabelLayoutItem(), 0, 3)
		.Add(fSerifFontView->CreateFontsMenuBarLayoutItem(), 1, 3)
		.Add(fSerifFontView->PreviewBox(), 0, 4, 2)
		.Add(BSpaceLayoutItem::CreateHorizontalStrut(spacing), 0, 5, 2)

		.Add(fSansSerifFontView->CreateFontsLabelLayoutItem(), 0, 6)
		.Add(fSansSerifFontView->CreateFontsMenuBarLayoutItem(), 1, 6)
		.Add(fSansSerifFontView->PreviewBox(), 0, 7, 2)
		.Add(BSpaceLayoutItem::CreateHorizontalStrut(spacing), 0, 8, 2)

		.Add(fFixedFontView->CreateFontsLabelLayoutItem(), 0, 9)
		.Add(fFixedFontView->CreateFontsMenuBarLayoutItem(), 1, 9)
		.Add(fFixedFontView->PreviewBox(), 0, 10, 2)
		.Add(BSpaceLayoutItem::CreateHorizontalStrut(spacing), 0, 11, 2)

		.Add(fStandardSizesMenu->CreateLabelLayoutItem(), 0, 12)
		.Add(fStandardSizesMenu->CreateMenuBarLayoutItem(), 1, 12)
		.Add(fFixedSizesMenu->CreateLabelLayoutItem(), 0, 13)
		.Add(fFixedSizesMenu->CreateMenuBarLayoutItem(), 1, 13)

		.SetInsets(spacing, spacing, spacing, spacing)

		.View()
	;

	view->SetName(B_TRANSLATE("Fonts"));
	return view;
}
void
MidiPlayerWindow::CreateViews()
{
	// Set up needed views
	scopeView = new ScopeView;

	showScope = new BCheckBox("showScope", B_TRANSLATE("Scope"),
		new BMessage(MSG_SHOW_SCOPE));
	showScope->SetValue(B_CONTROL_ON);

	CreateInputMenu();
	CreateReverbMenu();

	volumeSlider = new BSlider("volumeSlider", NULL, NULL, 0, 100,
		B_HORIZONTAL);
	rgb_color col = { 152, 152, 255 };
	volumeSlider->UseFillColor(true, &col);
	volumeSlider->SetModificationMessage(new BMessage(MSG_VOLUME));

	playButton = new BButton("playButton", B_TRANSLATE("Play"),
		new BMessage(MSG_PLAY_STOP));
	playButton->SetEnabled(false);

	BBox* divider = new BBox(B_EMPTY_STRING, B_WILL_DRAW | B_FRAME_EVENTS,
		B_FANCY_BORDER);
	divider->SetExplicitMaxSize(
		BSize(B_SIZE_UNLIMITED, 1));

	BStringView* volumeLabel = new BStringView(NULL, B_TRANSLATE("Volume:"));
	volumeLabel->SetAlignment(B_ALIGN_LEFT);
	volumeLabel->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));

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

	AddChild(BGroupLayoutBuilder(B_VERTICAL, 10)
		.Add(scopeView)
		.Add(BGridLayoutBuilder(10, 10)
			.Add(BSpaceLayoutItem::CreateGlue(), 0, 0)
			.Add(showScope, 1, 0)

			.Add(reverbMenu->CreateLabelLayoutItem(), 0, 1)
			.Add(reverbMenu->CreateMenuBarLayoutItem(), 1, 1)

			.Add(inputMenu->CreateLabelLayoutItem(), 0, 2)
			.Add(inputMenu->CreateMenuBarLayoutItem(), 1, 2)

			.Add(volumeLabel, 0, 3)
			.Add(volumeSlider, 1, 3)
		)
		.AddGlue()
		.Add(divider)
		.AddGlue()
		.Add(playButton)
		.AddGlue()
		.SetInsets(5, 5, 5, 5)
	);
}
Example #6
0
MainWindow::MainWindow()
	:
	BWindow(BRect(0, 0, 300, 400), "Caya", B_TITLED_WINDOW, 0),
	fWorkspaceChanged(false)
{
	fStatusView = new StatusView("statusView");

	SearchBarTextControl* searchBox = 
		new SearchBarTextControl(new BMessage(kSearchContact));

	fListView = new RosterListView("buddyView");
	fListView->SetInvocationMessage(new BMessage(CAYA_OPEN_CHAT_WINDOW));
	BScrollView* scrollView = new BScrollView("scrollview", fListView,
		B_WILL_DRAW, false, true);

	// Wrench menu
	BPopUpMenu* wrenchMenu = new BPopUpMenu("Wrench");
	(void)wrenchMenu->AddItem(new BMenuItem("About" B_UTF8_ELLIPSIS,
		new BMessage(B_ABOUT_REQUESTED)));
	(void)wrenchMenu->AddItem(new BSeparatorItem());
	(void)wrenchMenu->AddItem(new BMenuItem("Preferences" B_UTF8_ELLIPSIS,
		new BMessage(CAYA_SHOW_SETTINGS)));
	(void)wrenchMenu->AddItem(new BSeparatorItem());
	(void)wrenchMenu->AddItem(new BMenuItem("Quit",
		new BMessage(B_QUIT_REQUESTED)));
	wrenchMenu->SetTargetForItems(this);

	// Tool icon
	BResources* res = CayaResources();
	BBitmap* toolIcon = IconFromResources(res, kToolIcon);
	delete res;

	// Wrench tool button
	ToolButton* wrench = new ToolButton(NULL, NULL);
	wrench->SetBitmap(toolIcon);
	wrench->SetMenu(wrenchMenu);

	SetLayout(new BGridLayout(1, 2));
	AddChild(BGridLayoutBuilder(1, 2)
		.Add(searchBox, 0, 0)
		.Add(wrench, 1, 0)
		.Add(scrollView, 0, 1, 2)
		.Add(fStatusView, 0, 2, 2)
		.SetInsets(5, 5, 5, 10)
	);

	AddShortcut('a', B_COMMAND_KEY, new BMessage(B_ABOUT_REQUESTED));
	MoveTo(BAlert::AlertPosition(Bounds().Width(), Bounds().Height() / 2));

	// Filter messages using Server
	fServer = new Server();
	AddFilter(fServer);

	CenterOnScreen();

	//TODO check for errors here
	ReplicantStatusView::InstallReplicant();
}
BluetoothSettingsView::BluetoothSettingsView(const char* name)
	: BView(name, 0),
	fLocalDevicesMenu(NULL)
{
	_BuildConnectionPolicy();
	fPolicyMenuField = new BMenuField("policy",
		B_TRANSLATE("Incoming connections policy:"), fPolicyMenu);

	fInquiryTimeControl = new BSlider("time",
		B_TRANSLATE("Default inquiry time:"), new BMessage(kMsgSetInquiryTime),
		0, 255, B_HORIZONTAL);
	fInquiryTimeControl->SetLimitLabels(B_TRANSLATE("15 secs"),
		B_TRANSLATE("61 secs"));
	fInquiryTimeControl->SetHashMarks(B_HASH_MARKS_BOTTOM);
	fInquiryTimeControl->SetHashMarkCount(255 / 15);
	fInquiryTimeControl->SetEnabled(true);

	// hinting menu
	_BuildClassMenu();
	fClassMenuField = new BMenuField("class", B_TRANSLATE("Identify host as:"),
		fClassMenu);

	// localdevices menu
	_BuildLocalDevicesMenu();
	fLocalDevicesMenuField = new BMenuField("devices",
		B_TRANSLATE("Local devices found on system:"),
		fLocalDevicesMenu);

	fExtDeviceView = new ExtendedLocalDeviceView(BRect(0, 0, 5, 5), NULL);

	SetLayout(new BGroupLayout(B_VERTICAL));

	// controls pane
	AddChild(BGridLayoutBuilder(10, 10)

		.Add(fClassMenuField->CreateLabelLayoutItem(), 0, 0)
		.Add(fClassMenuField->CreateMenuBarLayoutItem(), 1, 0)

		.Add(fPolicyMenuField->CreateLabelLayoutItem(), 0, 1)
		.Add(fPolicyMenuField->CreateMenuBarLayoutItem(), 1, 1)

		.Add(BSpaceLayoutItem::CreateGlue(), 0, 2, 2)

		.Add(fInquiryTimeControl, 0, 3, 2)
		.Add(BSpaceLayoutItem::CreateGlue(), 0, 4, 2)

		.Add(fLocalDevicesMenuField->CreateLabelLayoutItem(), 0, 5)
		.Add(fLocalDevicesMenuField->CreateMenuBarLayoutItem(), 1, 5)

		.Add(fExtDeviceView, 0, 6, 2)
		.Add(BSpaceLayoutItem::CreateGlue(), 0, 7, 2)

		.SetInsets(10, 10, 10, 10)
	);

}
void
InitializeBFSEditor::_CreateViewControls()
{
	fNameControl = new BTextControl(B_TRANSLATE("Name:"), "Haiku", NULL);
	fNameControl->SetModificationMessage(new BMessage(MSG_NAME_CHANGED));
	fNameControl->TextView()->SetMaxBytes(31);

	BPopUpMenu* blocksizeMenu = new BPopUpMenu("blocksize");
	BMessage* message = new BMessage(MSG_BLOCK_SIZE);
	message->AddString("size", "1024");
	blocksizeMenu->AddItem(new BMenuItem(
		B_TRANSLATE("1024 (Mostly small files)"), message));
	message = new BMessage(MSG_BLOCK_SIZE);
	message->AddString("size", "2048");
	BMenuItem* defaultItem = new BMenuItem(B_TRANSLATE("2048 (Recommended)"),
		message);
	blocksizeMenu->AddItem(defaultItem);
	message = new BMessage(MSG_BLOCK_SIZE);
	message->AddString("size", "4096");
	blocksizeMenu->AddItem(new BMenuItem("4096", message));
	message = new BMessage(MSG_BLOCK_SIZE);
	message->AddString("size", "8192");
	blocksizeMenu->AddItem(new BMenuItem(
		B_TRANSLATE("8192 (Mostly large files)"), message));

	fBlockSizeMenuField = new BMenuField(B_TRANSLATE("Blocksize:"),
		blocksizeMenu);
	defaultItem->SetMarked(true);

	fUseIndicesCheckBox = new BCheckBox(B_TRANSLATE("Enable query support"),
		NULL);
	fUseIndicesCheckBox->SetValue(true);
	fUseIndicesCheckBox->SetToolTip(B_TRANSLATE("Disabling query support may "
		"speed up certain file system operations, but should only be used "
		"if one is absolutely certain that one will not need queries.\n"
		"Any volume that is intended for booting Haiku must have query "
		"support enabled."));

	float spacing = be_control_look->DefaultItemSpacing();

	fView = BGridLayoutBuilder(spacing, spacing)
		// row 1
		.Add(fNameControl->CreateLabelLayoutItem(), 0, 0)
		.Add(fNameControl->CreateTextViewLayoutItem(), 1, 0)

		// row 2
		.Add(fBlockSizeMenuField->CreateLabelLayoutItem(), 0, 1)
		.Add(fBlockSizeMenuField->CreateMenuBarLayoutItem(), 1, 1)

		// row 3
		.Add(fUseIndicesCheckBox, 0, 2, 2).View()
	;
}
Example #9
0
ResizerWindow::ResizerWindow(BMessenger target, int32 width, int32 height)
	:
	BWindow(BRect(100, 100, 300, 300), B_TRANSLATE("Resize"),
		B_FLOATING_WINDOW,
		B_NOT_ZOOMABLE | B_NOT_RESIZABLE | B_AUTO_UPDATE_SIZE_LIMITS),
	fOriginalWidth(width),
	fOriginalHeight(height),
	fTarget(target)
{
	BString widthValue;
	widthValue << width;
	fWidth = new BTextControl("width", B_TRANSLATE("Width:"),
		widthValue.String(), NULL);
	fWidth->SetModificationMessage(new BMessage(kWidthModifiedMsg));

	BString heightValue;
	heightValue << height;
	fHeight = new BTextControl("height",
		B_TRANSLATE("Height:"), heightValue.String(), NULL);
	fHeight->SetModificationMessage(new BMessage(kHeightModifiedMsg));

	fAspectRatio = new BCheckBox("Ratio",
		B_TRANSLATE("Keep original proportions"),
		new BMessage(kWidthModifiedMsg));
	fAspectRatio->SetValue(B_CONTROL_ON);

	fApply = new BButton("apply", B_TRANSLATE("Apply"),
		new BMessage(kApplyMsg));
	fApply->MakeDefault(true);

	const float spacing = be_control_look->DefaultItemSpacing();
	const float labelspacing = be_control_look->DefaultLabelSpacing();

	SetLayout(new BGroupLayout(B_HORIZONTAL));
	AddChild(BGroupLayoutBuilder(B_VERTICAL, 0)
		.Add(BGridLayoutBuilder(labelspacing, 0)
				.Add(fWidth->CreateLabelLayoutItem(), 0, 0)
				.Add(fWidth->CreateTextViewLayoutItem(), 1, 0)
				.Add(fHeight->CreateLabelLayoutItem(), 0, 1)
				.Add(fHeight->CreateTextViewLayoutItem(), 1, 1)
				)
		.Add(fAspectRatio)
		.AddGroup(B_HORIZONTAL, 0)
			.AddGlue()
			.Add(fApply)
		.End()
		.SetInsets(spacing, spacing, spacing, spacing)
	);

	fWidth->MakeFocus();

}
void
InitializeNTFSEditor::_CreateViewControls()
{
	fNameControl = new BTextControl(B_TRANSLATE("Name:"), "New NTFS Volume",
		NULL);
	fNameControl->SetModificationMessage(new BMessage(MSG_NAME_CHANGED));
	fNameControl->TextView()->SetMaxBytes(127);

	float spacing = be_control_look->DefaultItemSpacing();

	fView = BGridLayoutBuilder(spacing, spacing)
		.Add(fNameControl->CreateLabelLayoutItem(), 0, 0)
		.Add(fNameControl->CreateTextViewLayoutItem(), 1, 0).View()
	;
}
Example #11
0
BView*
SettingsWindow::_CreateFontsPage(float spacing)
{
	fStandardFontView = new FontSelectionView("standard",
		B_TRANSLATE("Standard font:"), true, be_plain_font);
	BFont defaultSerifFont = _FindDefaultSerifFont();
	fSerifFontView = new FontSelectionView("serif",
		B_TRANSLATE("Serif font:"), true, &defaultSerifFont);
	fSansSerifFontView = new FontSelectionView("sans serif",
		B_TRANSLATE("Sans serif font:"), true, be_plain_font);
	fFixedFontView = new FontSelectionView("fixed",
		B_TRANSLATE("Fixed font:"), true, be_fixed_font);

	fStandardSizesSpinner = new BSpinner("standard font size",
		B_TRANSLATE("Default standard font size:"),
		new BMessage(MSG_STANDARD_FONT_SIZE_SELECTED));
	fStandardSizesSpinner->SetAlignment(B_ALIGN_RIGHT);

	fFixedSizesSpinner = new BSpinner("fixed font size",
		B_TRANSLATE("Default fixed font size:"),
		new BMessage(MSG_FIXED_FONT_SIZE_SELECTED));
	fFixedSizesSpinner->SetAlignment(B_ALIGN_RIGHT);

	BView* view = BGridLayoutBuilder(spacing / 2, spacing / 2)
		.Add(fStandardFontView->CreateFontsLabelLayoutItem(), 0, 0)
		.Add(fStandardFontView->CreateFontsMenuBarLayoutItem(), 1, 0)
		.Add(fStandardSizesSpinner->CreateLabelLayoutItem(), 2, 0)
		.Add(fStandardSizesSpinner->CreateTextViewLayoutItem(), 3, 0)
		.Add(fStandardFontView->PreviewBox(), 1, 1, 3)
		.Add(fSerifFontView->CreateFontsLabelLayoutItem(), 0, 2)
		.Add(fSerifFontView->CreateFontsMenuBarLayoutItem(), 1, 2)
		.Add(fSerifFontView->PreviewBox(), 1, 3, 3)
		.Add(fSansSerifFontView->CreateFontsLabelLayoutItem(), 0, 4)
		.Add(fSansSerifFontView->CreateFontsMenuBarLayoutItem(), 1, 4)
		.Add(fSansSerifFontView->PreviewBox(), 1, 5, 3)
		.Add(BSpaceLayoutItem::CreateVerticalStrut(spacing / 2), 0, 6, 2)
		.Add(fFixedFontView->CreateFontsLabelLayoutItem(), 0, 7)
		.Add(fFixedFontView->CreateFontsMenuBarLayoutItem(), 1, 7)
		.Add(fFixedSizesSpinner->CreateLabelLayoutItem(), 2, 7)
		.Add(fFixedSizesSpinner->CreateTextViewLayoutItem(), 3, 7)
		.Add(fFixedFontView->PreviewBox(), 1, 8, 3)
		.SetInsets(B_USE_WINDOW_SPACING, B_USE_WINDOW_SPACING,
			B_USE_WINDOW_SPACING, B_USE_DEFAULT_SPACING)
		.View();

	view->SetName(B_TRANSLATE("Fonts"));
	return view;
}
Example #12
0
BView*
SettingsWindow::_CreateProxyPage(float spacing)
{
	fUseProxyCheckBox = new BCheckBox("use proxy",
		B_TRANSLATE("Use proxy server to connect to the internet."),
		new BMessage(MSG_USE_PROXY_CHANGED));
	fUseProxyCheckBox->SetValue(B_CONTROL_ON);

	fProxyAddressControl = new BTextControl("proxy address",
		B_TRANSLATE("Proxy server address:"), "",
		new BMessage(MSG_PROXY_ADDRESS_CHANGED));
	fProxyAddressControl->SetModificationMessage(
		new BMessage(MSG_PROXY_ADDRESS_CHANGED));
	fProxyAddressControl->SetText(
		fSettings->GetValue(kSettingsKeyProxyAddress, ""));

	fProxyPortControl = new BTextControl("proxy port",
		B_TRANSLATE("Proxy server port:"), "",
		new BMessage(MSG_PROXY_PORT_CHANGED));
	fProxyPortControl->SetModificationMessage(
		new BMessage(MSG_PROXY_PORT_CHANGED));
	fProxyPortControl->SetText(
		fSettings->GetValue(kSettingsKeyProxyAddress, ""));

	BView* view = BGroupLayoutBuilder(B_VERTICAL, spacing / 2)
		.Add(fUseProxyCheckBox)
		.Add(BGridLayoutBuilder(spacing / 2, spacing / 2)
			.Add(fProxyAddressControl->CreateLabelLayoutItem(), 0, 0)
			.Add(fProxyAddressControl->CreateTextViewLayoutItem(), 1, 0)

			.Add(fProxyPortControl->CreateLabelLayoutItem(), 0, 1)
			.Add(fProxyPortControl->CreateTextViewLayoutItem(), 1, 1)
		)
		.Add(BSpaceLayoutItem::CreateGlue())

		.SetInsets(spacing, spacing, spacing, spacing)

		.TopView()
	;
	view->SetName(B_TRANSLATE("Proxy server"));
	return view;
}
void
InitializeFATEditor::_CreateViewControls()
{
	fNameControl = new BTextControl(B_TRANSLATE("Name:"), "New FAT Vol",
		NULL);
	fNameControl->SetModificationMessage(new BMessage(MSG_NAME_CHANGED));
	// TODO find out what is the max length for this specific FS partition name
	fNameControl->TextView()->SetMaxBytes(11);

	BPopUpMenu* fatBitsMenu = new BPopUpMenu("fat size");
	BMessage* message = new BMessage(MSG_FAT_BITS);
	message->AddString("fat", "0");
	BMenuItem* defaultItem = new BMenuItem(
		B_TRANSLATE("Auto (default)"), message);
	fatBitsMenu->AddItem(defaultItem);
	message = new BMessage(MSG_FAT_BITS);
	message->AddString("fat", "12");
	fatBitsMenu->AddItem(new BMenuItem("12", message));
	message = new BMessage(MSG_FAT_BITS);
	message->AddString("fat", "16");
	fatBitsMenu->AddItem(new BMenuItem("16", message));
	message = new BMessage(MSG_FAT_BITS);
	message->AddString("fat", "32");
	fatBitsMenu->AddItem(new BMenuItem("32", message));

	fFatBitsMenuField = new BMenuField(B_TRANSLATE("FAT bits:"),
		fatBitsMenu);
	defaultItem->SetMarked(true);

	float spacing = be_control_look->DefaultItemSpacing();

	fView = BGridLayoutBuilder(spacing, spacing)
		// row 1
		.Add(fNameControl->CreateLabelLayoutItem(), 0, 0)
		.Add(fNameControl->CreateTextViewLayoutItem(), 1, 0)

		// row 2
		.Add(fFatBitsMenuField->CreateLabelLayoutItem(), 0, 1)
		.Add(fFatBitsMenuField->CreateMenuBarLayoutItem(), 1, 1).View()
	;
}
Example #14
0
FrissWindow::FrissWindow(FrissConfig* config, XmlNode* theList, BRect frame,
	const char* Title) : 
	BWindow(frame, Title, B_TITLED_WINDOW,
		B_FRAME_EVENTS | B_AUTO_UPDATE_SIZE_LIMITS)
{	
	SetLayout(new BGroupLayout(B_VERTICAL));
	BGridView* background = new BGridView("background");
	background->GridLayout()->SetSpacing(0, 0);
	background->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	AddChild(background);

	feedList = new BListView("feedlist", B_SINGLE_SELECTION_LIST);
	myf = new FrissView(config, theList);

	/* Nun noch den Dragger einbauen.
	 * B_ORIGIN scheint unten rechts zu sein, also noch entsprechend
	 * die linke obere Ecke setzen (ich wusste vorher auch nicht, dass
	 * der Dragger 7x7 Pixel groß ist :-)
	 */
	BDragger* myd = new BDragger(myf, B_WILL_DRAW );
	myd->SetExplicitMaxSize(BSize(7, 7));

	BGridLayoutBuilder(background)
		.SetInsets(7, 7, 0, 0)
		.Add(new BScrollView("scroll", feedList, 0, false, true), 0, 0)
		.Add(myf, 1, 0)
		.Add(myd, 2, 1);

	background->GridLayout()->SetColumnWeight(0, 0.4);
	background->GridLayout()->SetMaxColumnWidth(0, 200);

	BMessage* m = new BMessage(msg_SelFeed);
	feedList->SetSelectionMessage(m);

	m = new BMessage(msg_EditFeed);
	feedList->SetInvocationMessage(m);

	PopulateFeeds(theList);
}
MarkupWindow::MarkupWindow(BRect frame, const char* title)
	:	BWindow(frame, title, B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS, B_CURRENT_WORKSPACE)
{
	// initialize controls      s
	AddShortcut('q', B_COMMAND_KEY, new BMessage(B_QUIT_REQUESTED));
	BRect r = Bounds();
	topicListView = new BListView(BRect(10, 10, 30, 30), NULL, B_SINGLE_SELECTION_LIST, B_FOLLOW_ALL, B_WILL_DRAW | B_NAVIGABLE);
	contentTextView = new BTextView(BRect(0, 0, r.right, 100), NULL, BRect(10, 10, r.right, 100), B_FOLLOW_ALL, B_WILL_DRAW | B_NAVIGABLE);
	contentTextView->SetWordWrap(true);
	contentTextView->MakeEditable(false);
	backView = new BView(Bounds(), "backview", B_FOLLOW_ALL, B_WILL_DRAW | B_NAVIGABLE);
	backView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	backView->SetHighColor((rgb_color){0, 0, 0, 255});
	AddChild(backView);
	// gui layout builder
	backView->SetLayout(new BGroupLayout(B_HORIZONTAL, 0.0));
	backView->AddChild(BGridLayoutBuilder()
		.Add(new BScrollView("scroll_topic", topicListView, B_FOLLOW_TOP | B_FOLLOW_LEFT, 0, false, true, B_FANCY_BORDER), 0, 0, 2, 3)
		.Add(new BScrollView("scroll_content", contentTextView, B_FOLLOW_ALL_SIDES, 0, false, true, B_FANCY_BORDER), 2, 0, 6, 10)
		.SetInsets(0, 0, 0, 0)
	);
	topicListView->SetSelectionMessage(new BMessage(LOAD_CONTENT));
}
OpenWindow::OpenWindow()
	:
	BWindow(BRect(0, 0, 35, 10), B_TRANSLATE_SYSTEM_NAME("DiskProbe"),
		B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE
		| B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS)
{
	fDevicesMenu = new BPopUpMenu("devices");
	CollectDevices(fDevicesMenu);
	if (BMenuItem *item = fDevicesMenu->ItemAt(0))
		item->SetMarked(true);

	BMenuField *field = new BMenuField(B_TRANSLATE("Examine device:"),
		fDevicesMenu);

	BButton *probeDeviceButton = new BButton("device",
		B_TRANSLATE("Probe device"), new BMessage(kMsgProbeDevice));
	probeDeviceButton->MakeDefault(true);

	BButton *probeFileButton = new BButton("file",
		B_TRANSLATE("Probe file" B_UTF8_ELLIPSIS),
		new BMessage(kMsgProbeFile));

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

	SetLayout(new BGroupLayout(B_HORIZONTAL));

	AddChild(BGridLayoutBuilder(8, 8)
		.Add(field, 0, 0, 3)
		.Add(cancelButton, 0, 1)
		.Add(probeFileButton, 1, 1)
		.Add(probeDeviceButton, 2, 1)
		.SetInsets(8, 8, 8, 8)
	);

	CenterOnScreen();
}
Example #17
0
void
CreateParamsPanel::_CreateViewControls(BPartition* parent, off_t offset,
	off_t size)
{
	// Setup the controls
	fSizeSlider = new SizeSlider("Slider", TR("Partition size"), NULL, offset,
		offset + size);
	fSizeSlider->SetPosition(1.0);

	fNameTextControl = new BTextControl("Name Control", TR("Partition name:"),
		"", NULL);
	if (!parent->SupportsChildName())
		fNameTextControl->SetEnabled(false);

	fTypePopUpMenu = new BPopUpMenu("Partition Type");

	int32 cookie = 0;
	BString supportedType;
	while (parent->GetNextSupportedChildType(&cookie, &supportedType)
			== B_OK) {
		BMessage* message = new BMessage(MSG_PARTITION_TYPE);
		message->AddString("type", supportedType);
		BMenuItem* item = new BMenuItem(supportedType, message);
		fTypePopUpMenu->AddItem(item);

		if (strcmp(supportedType, kPartitionTypeBFS) == 0)
			item->SetMarked(true);
	}

	fTypeMenuField = new BMenuField(TR("Partition type:"), fTypePopUpMenu,
		NULL);

	const float spacing = be_control_look->DefaultItemSpacing();
	BGroupLayout* layout = new BGroupLayout(B_VERTICAL, spacing);
	layout->SetInsets(spacing, spacing, spacing, spacing);

	SetLayout(layout);

	AddChild(BGroupLayoutBuilder(B_VERTICAL, spacing)
		.Add(fSizeSlider)
		.Add(BGridLayoutBuilder(0.0, 5.0)
			.Add(fNameTextControl->CreateLabelLayoutItem(), 0, 0)
			.Add(fNameTextControl->CreateTextViewLayoutItem(), 1, 0)
			.Add(fTypeMenuField->CreateLabelLayoutItem(), 0, 1)
			.Add(fTypeMenuField->CreateMenuBarLayoutItem(), 1, 1)
		)
	);

	parent->GetChildCreationParameterEditor(NULL, &fEditor);
	if (fEditor)
		AddChild(fEditor->View());

	BButton* okButton = new BButton(TR("Create"), new BMessage(MSG_OK));
	AddChild(BGroupLayoutBuilder(B_HORIZONTAL, spacing)
		.AddGlue()
		.Add(new BButton(TR("Cancel"), new BMessage(MSG_CANCEL)))
		.Add(okButton)
	);
	SetDefaultButton(okButton);

	AddToSubset(fWindow);
	layout->View()->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
}
Example #18
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);
}
void
AddPrinterDialog::_BuildGUI(int stage)
{
	// add a "printer name" input field
	fName = new BTextControl("printer_name", B_TRANSLATE("Printer name:"),
		B_EMPTY_STRING, NULL);
	fName->SetFont(be_bold_font);
	fName->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT);
	fName->SetModificationMessage(new BMessage(kNameChangedMsg));

	// add a "driver" popup menu field
	fPrinter = new BPopUpMenu(B_TRANSLATE("<pick one>"));
	BMenuField *printerMenuField = new BMenuField("drivers_list",
		B_TRANSLATE("Printer type:"), fPrinter);
	printerMenuField->SetAlignment(B_ALIGN_RIGHT);
	_FillMenu(fPrinter, "Print", kPrinterSelectedMsg);

	// add a "connected to" (aka transports list) menu field
	fTransport = new BPopUpMenu(B_TRANSLATE("<pick one>"));
	BMenuField *transportMenuField = new BMenuField("transports_list",
		B_TRANSLATE("Connected to:"), fTransport);
	transportMenuField->SetAlignment(B_ALIGN_RIGHT);
	_FillTransportMenu(fTransport);

	// add a "OK" button
	fOk = new BButton(NULL, B_TRANSLATE("Add"), new BMessage((uint32)B_OK),
		B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);

	// add a "Cancel button
	BButton *cancel = new BButton(NULL, B_TRANSLATE("Cancel"),
		new BMessage(B_CANCEL));

	SetLayout(new BGridLayout());

	AddChild(BGridLayoutBuilder(0, 4)
		.Add(fName->CreateLabelLayoutItem(), 0, 0)
		.Add(fName->CreateTextViewLayoutItem(), 1, 0)
		.Add(printerMenuField->CreateLabelLayoutItem(), 0, 1)
		.Add(printerMenuField->CreateMenuBarLayoutItem(), 1, 1)
		.Add(transportMenuField->CreateLabelLayoutItem(), 0, 2)
		.Add(transportMenuField->CreateMenuBarLayoutItem(), 1, 2)
		.Add(BGroupLayoutBuilder(B_HORIZONTAL)
			.AddGlue()
			.Add(cancel)
			.Add(fOk)
			, 0, 3, 2)
		.SetInsets(8, 8, 8, 8)
		);

	SetDefaultButton(fOk);
	fOk->MakeDefault(true);

	fName->MakeFocus(true);

	_Update();
// Stage == 0
// init_icon 64x114  Add a Local or Network Printer
//                   ------------------------------
//                   I would like to add a...
//                              Local Printer
//                              Network Printer
// ------------------------------------------------
//                                Cancel   Continue

// Add local printer:

// Stage == 1
// local_icon        Add a Local Printer
//                   ------------------------------
//                   Printer Name: ________________
//                   Printer Type: pick one
//                   Connected to: pick one
// ------------------------------------------------
//                                Cancel        Add

// This seems to be hard coded into the preferences dialog:
// Don't show Network transport add-on in Printer Type menu.
// If Printer Type == Preview disable Connect to popup menu.
// If Printer Type == Serial Port add a submenu to menu item
//    with names in /dev/ports (if empty remove item from menu)
// If Printer Type == Parallel Port add a submenu to menu item
//    with names in /dev/parallel (if empty remove item from menu)

// Printer Driver Setup

// Dialog Info
// Would you like to make X the default printer?
//                                        No Yes

// Add network printer:

// Dialog Info
// Apple Talk networking isn't currenty enabled. If you
// wish to install a network printer you should enable
// AppleTalk in the Network preferences.
//                               Cancel   Open Network

// Stage == 2

// network_icon      Add a Network Printer
//                   ------------------------------
//                   Printer Name: ________________
//                   Printer Type: pick one
//              AppleTalk Printer: pick one
// ------------------------------------------------
//                                Cancel        Add
}
Example #20
0
// constructor
DimensionsControl::DimensionsControl(BMessage* message, BHandler* target,
		float horizontalSpacing, float verticalSpacing)
	:
	BGridView(horizontalSpacing, verticalSpacing),
	fMessage(message),
	fTarget(target),
	fWidthTC(NULL),
	fHeightTC(NULL),
	fLockView(NULL),
	fCommonFormatsPU(NULL),
	fPreviousWidth(0),
	fPreviousHeight(0),
	fMinWidth(0),
	fMaxWidth(0),
	fMinHeight(0),
	fMaxHeight(0)
{
	// build common formats menu
	fCommonFormatsPU = new ArrowPopup(NULL);

	message = new BMessage(MSG_COMMON_FORMAT);
	message->AddInt32("format", FORMAT_160_120);
	BMenuItem* item = new BMenuItem("160 x 120", message);
	fCommonFormatsPU->Menu()->AddItem(item);

	message = new BMessage(MSG_COMMON_FORMAT);
	message->AddInt32("format", FORMAT_320_240);
	item = new BMenuItem("320 x 240", message);
	fCommonFormatsPU->Menu()->AddItem(item);

	message = new BMessage(MSG_COMMON_FORMAT);
	message->AddInt32("format", FORMAT_400_300);
	item = new BMenuItem("400 x 300", message);
	fCommonFormatsPU->Menu()->AddItem(item);

	message = new BMessage(MSG_COMMON_FORMAT);
	message->AddInt32("format", FORMAT_640_480);
	item = new BMenuItem("640 x 480", message);
	fCommonFormatsPU->Menu()->AddItem(item);

	message = new BMessage(MSG_COMMON_FORMAT);
	message->AddInt32("format", FORMAT_800_600);
	item = new BMenuItem("800 x 600", message);
	fCommonFormatsPU->Menu()->AddItem(item);

	message = new BMessage(MSG_COMMON_FORMAT);
	message->AddInt32("format", FORMAT_1024_768);
	item = new BMenuItem("1024 x 768", message);
	fCommonFormatsPU->Menu()->AddItem(item);

	message = new BMessage(MSG_COMMON_FORMAT);
	message->AddInt32("format", FORMAT_1152_864);
	item = new BMenuItem("1152 x 864", message);
	fCommonFormatsPU->Menu()->AddItem(item);

	message = new BMessage(MSG_COMMON_FORMAT);
	message->AddInt32("format", FORMAT_1280_800);
	item = new BMenuItem("1280 x 800", message);
	fCommonFormatsPU->Menu()->AddItem(item);

	message = new BMessage(MSG_COMMON_FORMAT);
	message->AddInt32("format", FORMAT_1280_960);
	item = new BMenuItem("1280 x 960 (4:3)", message);
	fCommonFormatsPU->Menu()->AddItem(item);

	message = new BMessage(MSG_COMMON_FORMAT);
	message->AddInt32("format", FORMAT_1280_1024);
	item = new BMenuItem("1280 x 1024 (5:4)", message);
	fCommonFormatsPU->Menu()->AddItem(item);

	message = new BMessage(MSG_COMMON_FORMAT);
	message->AddInt32("format", FORMAT_1400_1050);
	item = new BMenuItem("1400 x 1050", message);
	fCommonFormatsPU->Menu()->AddItem(item);

	message = new BMessage(MSG_COMMON_FORMAT);
	message->AddInt32("format", FORMAT_1600_1200);
	item = new BMenuItem("1600 x 1200", message);
	fCommonFormatsPU->Menu()->AddItem(item);

	message = new BMessage(MSG_COMMON_FORMAT);
	message->AddInt32("format", FORMAT_1920_1200);
	item = new BMenuItem("1920 x 1200", message);
	fCommonFormatsPU->Menu()->AddItem(item);

	message = new BMessage(MSG_COMMON_FORMAT);
	message->AddInt32("format", FORMAT_2048_1536);
	item = new BMenuItem("2048 x 1536", message);
	fCommonFormatsPU->Menu()->AddItem(item);

	fCommonFormatsPU->Menu()->AddSeparatorItem();

	message = new BMessage(MSG_COMMON_FORMAT);
	message->AddInt32("format", FORMAT_384_288);
	item = new BMenuItem("384 x 288 (1/4 PAL)", message);
	fCommonFormatsPU->Menu()->AddItem(item);

	message = new BMessage(MSG_COMMON_FORMAT);
	message->AddInt32("format", FORMAT_768_576);
	item = new BMenuItem("768 x 576 (PAL)", message);
	fCommonFormatsPU->Menu()->AddItem(item);

	message = new BMessage(MSG_COMMON_FORMAT);
	message->AddInt32("format", FORMAT_720_540);
	item = new BMenuItem("720 x 540 (PAL TV cropped)", message);
	fCommonFormatsPU->Menu()->AddItem(item);

	fCommonFormatsPU->Menu()->AddSeparatorItem();

	message = new BMessage(MSG_COMMON_FORMAT);
	message->AddInt32("format", FORMAT_1280_720);
	item = new BMenuItem("1280 x 720 (HDTV 16:9)", message);
	fCommonFormatsPU->Menu()->AddItem(item);

	message = new BMessage(MSG_COMMON_FORMAT);
	message->AddInt32("format", FORMAT_1920_1080);
	item = new BMenuItem("1920 x 1080 (HDTV 16:9)", message);
	fCommonFormatsPU->Menu()->AddItem(item);

/*	fCommonFormatsPU->Menu()->AddSeparatorItem();

	message = new BMessage(MSG_COMMON_FORMAT);
	message->AddInt32("format", FORMAT_352_240);
	item = new BMenuItem("352 x 240 (1/4 NTSC)", message);
	fCommonFormatsPU->Menu()->AddItem(item);

	message = new BMessage(MSG_COMMON_FORMAT);
	message->AddInt32("format", FORMAT_768_524);
	item = new BMenuItem("768 x 524 (NTSC)", message);
	fCommonFormatsPU->Menu()->AddItem(item);

	message = new BMessage(MSG_COMMON_FORMAT);
	message->AddInt32("format", FORMAT_720_492);
	item = new BMenuItem("720 x 492 (TV cropped NTSC)", message);
	fCommonFormatsPU->Menu()->AddItem(item);*/

	fCommonFormatsPU->Menu()->AddSeparatorItem();

	message = new BMessage(MSG_COMMON_FORMAT);
	message->AddInt32("format", FORMAT_720_576);
	item = new BMenuItem("720 x 576 (DV PAL)", message);
	fCommonFormatsPU->Menu()->AddItem(item);

	message = new BMessage(MSG_COMMON_FORMAT);
	message->AddInt32("format", FORMAT_720_480);
	item = new BMenuItem("720 x 480 (DV NTSC)", message);
	fCommonFormatsPU->Menu()->AddItem(item);

	fCommonFormatsPU->Menu()->AddSeparatorItem();

	message = new BMessage(MSG_COMMON_FORMAT);
	message->AddInt32("format", FORMAT_384_216);
	item = new BMenuItem("384 x 216 (1/4 PAL 16:9)", message);
	fCommonFormatsPU->Menu()->AddItem(item);

	message = new BMessage(MSG_COMMON_FORMAT);
	message->AddInt32("format", FORMAT_768_432);
	item = new BMenuItem("768 x 432 (PAL 16:9)", message);
	fCommonFormatsPU->Menu()->AddItem(item);

	message = new BMessage(MSG_COMMON_FORMAT);
	message->AddInt32("format", FORMAT_720_405);
	item = new BMenuItem("720 x 405 (PAL 16:9 TV cropped)", message);
	fCommonFormatsPU->Menu()->AddItem(item);

	fCommonFormatsPU->Menu()->AddSeparatorItem();

	message = new BMessage(MSG_COMMON_FORMAT);
	message->AddInt32("format", FORMAT_384_164);
	item = new BMenuItem("384 x 164 (1/4 PAL 2.35:1)", message);
	fCommonFormatsPU->Menu()->AddItem(item);

	message = new BMessage(MSG_COMMON_FORMAT);
	message->AddInt32("format", FORMAT_768_327);
	item = new BMenuItem("768 x 327 (PAL 2.35:1)", message);
	fCommonFormatsPU->Menu()->AddItem(item);

	message = new BMessage(MSG_COMMON_FORMAT);
	message->AddInt32("format", FORMAT_720_306);
	item = new BMenuItem("720 x 306 (PAL 2.35:1 TV cropped)", message);
	fCommonFormatsPU->Menu()->AddItem(item);

	fWidthTC = new BTextControl("Width:", "",
		new BMessage(MSG_WIDTH_CHANGED));
	fHeightTC = new BTextControl("Height:", "",
		new BMessage(MSG_HEIGHT_CHANGED));

	fLockView = new LockView();

	BGridLayoutBuilder(this)
		.Add(fWidthTC->CreateLabelLayoutItem(), 0, 0)
		.Add(fWidthTC->CreateTextViewLayoutItem(), 1, 0)
		.Add(fHeightTC->CreateLabelLayoutItem(), 0, 1)
		.Add(fHeightTC->CreateTextViewLayoutItem(), 1, 1)
		.Add(fLockView, 2, 0, 1, 2)
		.Add(fCommonFormatsPU, 3, 0)
	;

	// only accept numbers in text views
	for (uint32 i = 0; i < '0'; i++) {
		fWidthTC->TextView()->DisallowChar(i);
		fHeightTC->TextView()->DisallowChar(i);
	}
	for (uint32 i = '9' + 1; i < 255; i++) {
		fWidthTC->TextView()->DisallowChar(i);
		fHeightTC->TextView()->DisallowChar(i);
	}
	// set bubble help texts
//	helper->SetHelp(fWidthTC, "");
//	helper->SetHelp(fHeightTC, "");
//	helper->SetHelp(fLockView, "Lock proportion of Width and Height.");
//	helper->SetHelp(fCommonFormatsPU, "Pick one of many common formats.");

	// put something in the textviews
	_SetDimensions(fMinWidth, fMinHeight, false);
}
ReplaceWindow::ReplaceWindow(BRect frame, BHandler* _handler,
	BString* searchString, 	BString *replaceString,
	bool caseState, bool wrapState, bool backState)
	: BWindow(frame, "ReplaceWindow", B_MODAL_WINDOW,
		B_NOT_RESIZABLE | B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS,
		B_CURRENT_WORKSPACE)
{
	AddShortcut('W', B_COMMAND_KEY, new BMessage(B_QUIT_REQUESTED));

	fSearchString = new BTextControl("", B_TRANSLATE("Find:"), NULL, NULL);
	fReplaceString = new BTextControl("", B_TRANSLATE("Replace with:"),
		NULL, NULL);
	fCaseSensBox = new BCheckBox("", B_TRANSLATE("Case-sensitive"), NULL);
	fWrapBox = new BCheckBox("", B_TRANSLATE("Wrap-around search"), NULL);
	fBackSearchBox = new BCheckBox("", B_TRANSLATE("Search backwards"), NULL);
	fAllWindowsBox = new BCheckBox("", B_TRANSLATE("Replace in all windows"),
		new BMessage(CHANGE_WINDOW));
	fUIchange = false;

	fReplaceAllButton = new BButton("", B_TRANSLATE("Replace all"),
		new BMessage(MSG_REPLACE_ALL));
	fCancelButton = new BButton("", B_TRANSLATE("Cancel"),
		new BMessage(B_QUIT_REQUESTED));
	fReplaceButton = new BButton("", B_TRANSLATE("Replace"),
		new BMessage(MSG_REPLACE));

	SetLayout(new BGroupLayout(B_HORIZONTAL));
	AddChild(BGroupLayoutBuilder(B_VERTICAL, 4)
		.Add(BGridLayoutBuilder(6, 2)
				.Add(fSearchString->CreateLabelLayoutItem(), 0, 0)
				.Add(fSearchString->CreateTextViewLayoutItem(), 1, 0)
				.Add(fReplaceString->CreateLabelLayoutItem(), 0, 1)
				.Add(fReplaceString->CreateTextViewLayoutItem(), 1, 1)
				.Add(fCaseSensBox, 1, 2)
				.Add(fWrapBox, 1, 3)
				.Add(fBackSearchBox, 1, 4)
				.Add(fAllWindowsBox, 1, 5)
				)
		.AddGroup(B_HORIZONTAL, 10)
			.Add(fReplaceAllButton)
			.AddGlue()
			.Add(fCancelButton)
			.Add(fReplaceButton)
		.End()
		.SetInsets(10, 10, 10, 10)
	);

	fReplaceButton->MakeDefault(true);

	fHandler = _handler;

	const char* searchtext = searchString->String();
	const char* replacetext = replaceString->String();

	fSearchString->SetText(searchtext);
	fReplaceString->SetText(replacetext);
	fSearchString->MakeFocus(true);

	fCaseSensBox->SetValue(caseState ? B_CONTROL_ON : B_CONTROL_OFF);
	fWrapBox->SetValue(wrapState ? B_CONTROL_ON : B_CONTROL_OFF);
	fBackSearchBox->SetValue(backState ? B_CONTROL_ON : B_CONTROL_OFF);
}
BView*
SettingsWindow::_CreateGeneralPage(float spacing)
{
	fStartPageControl = new BTextControl("start page",
		B_TRANSLATE("Start page:"), "", new BMessage(MSG_START_PAGE_CHANGED));
	fStartPageControl->SetModificationMessage(
		new BMessage(MSG_START_PAGE_CHANGED));
	fStartPageControl->SetText(
		fSettings->GetValue(kSettingsKeyStartPageURL, kDefaultStartPageURL));

	fSearchPageControl = new BTextControl("search page",
		B_TRANSLATE("Search page:"), "",
		new BMessage(MSG_SEARCH_PAGE_CHANGED));
	fSearchPageControl->SetModificationMessage(
		new BMessage(MSG_SEARCH_PAGE_CHANGED));
	fSearchPageControl->SetText(
		fSettings->GetValue(kSettingsKeySearchPageURL, kDefaultSearchPageURL));

	fDownloadFolderControl = new BTextControl("download folder",
		B_TRANSLATE("Download folder:"), "",
		new BMessage(MSG_DOWNLOAD_FOLDER_CHANGED));
	fDownloadFolderControl->SetModificationMessage(
		new BMessage(MSG_DOWNLOAD_FOLDER_CHANGED));
	fDownloadFolderControl->SetText(
		fSettings->GetValue(kSettingsKeyDownloadPath, kDefaultDownloadPath));

	fNewWindowBehaviorOpenHomeItem = new BMenuItem(
		B_TRANSLATE("Open start page"),
		new BMessage(MSG_NEW_WINDOWS_BEHAVIOR_CHANGED));
	fNewWindowBehaviorOpenSearchItem = new BMenuItem(
		B_TRANSLATE("Open search page"),
		new BMessage(MSG_NEW_WINDOWS_BEHAVIOR_CHANGED));
	fNewWindowBehaviorOpenBlankItem = new BMenuItem(
		B_TRANSLATE("Open blank page"),
		new BMessage(MSG_NEW_WINDOWS_BEHAVIOR_CHANGED));

	fNewTabBehaviorCloneCurrentItem = new BMenuItem(
		B_TRANSLATE("Clone current page"),
		new BMessage(MSG_NEW_TABS_BEHAVIOR_CHANGED));
	fNewTabBehaviorOpenHomeItem = new BMenuItem(
		B_TRANSLATE("Open start page"),
		new BMessage(MSG_NEW_TABS_BEHAVIOR_CHANGED));
	fNewTabBehaviorOpenSearchItem = new BMenuItem(
		B_TRANSLATE("Open search page"),
		new BMessage(MSG_NEW_TABS_BEHAVIOR_CHANGED));
	fNewTabBehaviorOpenBlankItem = new BMenuItem(
		B_TRANSLATE("Open blank page"),
		new BMessage(MSG_NEW_TABS_BEHAVIOR_CHANGED));

	fNewWindowBehaviorOpenHomeItem->SetMarked(true);
	fNewTabBehaviorOpenBlankItem->SetMarked(true);

	BPopUpMenu* newWindowBehaviorMenu = new BPopUpMenu("New windows");
	newWindowBehaviorMenu->AddItem(fNewWindowBehaviorOpenHomeItem);
	newWindowBehaviorMenu->AddItem(fNewWindowBehaviorOpenSearchItem);
	newWindowBehaviorMenu->AddItem(fNewWindowBehaviorOpenBlankItem);
	fNewWindowBehaviorMenu = new BMenuField("new window behavior",
		B_TRANSLATE("New windows:"), newWindowBehaviorMenu);

	BPopUpMenu* newTabBehaviorMenu = new BPopUpMenu("New tabs");
	newTabBehaviorMenu->AddItem(fNewTabBehaviorOpenBlankItem);
	newTabBehaviorMenu->AddItem(fNewTabBehaviorOpenHomeItem);
	newTabBehaviorMenu->AddItem(fNewTabBehaviorOpenSearchItem);
	newTabBehaviorMenu->AddItem(fNewTabBehaviorCloneCurrentItem);
	fNewTabBehaviorMenu = new BMenuField("new tab behavior",
		B_TRANSLATE("New tabs:"), newTabBehaviorMenu);

	fDaysInHistoryMenuControl = new BTextControl("days in history",
		B_TRANSLATE("Number of days to keep links in History menu:"), "",
		new BMessage(MSG_HISTORY_MENU_DAYS_CHANGED));
	fDaysInHistoryMenuControl->SetModificationMessage(
		new BMessage(MSG_HISTORY_MENU_DAYS_CHANGED));
	BString maxHistoryAge;
	maxHistoryAge << BrowsingHistory::DefaultInstance()->MaxHistoryItemAge();
	fDaysInHistoryMenuControl->SetText(maxHistoryAge.String());
	for (uchar i = 0; i < '0'; i++)
		fDaysInHistoryMenuControl->TextView()->DisallowChar(i);
	for (uchar i = '9' + 1; i <= 128; i++)
		fDaysInHistoryMenuControl->TextView()->DisallowChar(i);

	fShowTabsIfOnlyOnePage = new BCheckBox("show tabs if only one page",
		B_TRANSLATE("Show tabs if only one page is open"),
		new BMessage(MSG_TAB_DISPLAY_BEHAVIOR_CHANGED));
	fShowTabsIfOnlyOnePage->SetValue(B_CONTROL_ON);

	fAutoHideInterfaceInFullscreenMode = new BCheckBox("auto-hide interface",
		B_TRANSLATE("Auto-hide interface in full screen mode"),
		new BMessage(MSG_AUTO_HIDE_INTERFACE_BEHAVIOR_CHANGED));
	fAutoHideInterfaceInFullscreenMode->SetValue(B_CONTROL_OFF);

	fAutoHidePointer = new BCheckBox("auto-hide pointer",
		B_TRANSLATE("Auto-hide mouse pointer"),
		new BMessage(MSG_AUTO_HIDE_POINTER_BEHAVIOR_CHANGED));
	fAutoHidePointer->SetValue(B_CONTROL_OFF);

	fShowHomeButton = new BCheckBox("show home button",
		B_TRANSLATE("Show home button"),
		new BMessage(MSG_SHOW_HOME_BUTTON_CHANGED));
	fShowHomeButton->SetValue(B_CONTROL_ON);

	BView* view = BGroupLayoutBuilder(B_VERTICAL, spacing / 2)
		.Add(BGridLayoutBuilder(spacing / 2, spacing / 2)
			.Add(fStartPageControl->CreateLabelLayoutItem(), 0, 0)
			.Add(fStartPageControl->CreateTextViewLayoutItem(), 1, 0)

			.Add(fSearchPageControl->CreateLabelLayoutItem(), 0, 1)
			.Add(fSearchPageControl->CreateTextViewLayoutItem(), 1, 1)

			.Add(fDownloadFolderControl->CreateLabelLayoutItem(), 0, 2)
			.Add(fDownloadFolderControl->CreateTextViewLayoutItem(), 1, 2)

			.Add(fNewWindowBehaviorMenu->CreateLabelLayoutItem(), 0, 3)
			.Add(fNewWindowBehaviorMenu->CreateMenuBarLayoutItem(), 1, 3)

			.Add(fNewTabBehaviorMenu->CreateLabelLayoutItem(), 0, 4)
			.Add(fNewTabBehaviorMenu->CreateMenuBarLayoutItem(), 1, 4)
		)
		.Add(BSpaceLayoutItem::CreateHorizontalStrut(spacing))
		.Add(new BSeparatorView(B_HORIZONTAL, B_PLAIN_BORDER))
		.Add(BSpaceLayoutItem::CreateHorizontalStrut(spacing))
		.Add(fShowTabsIfOnlyOnePage)
		.Add(fAutoHideInterfaceInFullscreenMode)
		.Add(fAutoHidePointer)
		.Add(fShowHomeButton)
		.Add(fDaysInHistoryMenuControl)
		.Add(BSpaceLayoutItem::CreateHorizontalStrut(spacing))

		.SetInsets(spacing, spacing, spacing, spacing)

		.TopView()
	;
	view->SetName(B_TRANSLATE("General"));
	return view;
}
Example #23
0
BView* PreferencesWindow::_CreateConnectionPage(float spacing)
{
/*
	BStringView* addingLabel 		= new BStringView("", B_TRANSLATE("Adding"));
	BStringView* downloadingLabel 	= new BStringView("", B_TRANSLATE("Downloading"));
	//BStringView* seedingLabel 	= new BStringView("", B_TRANSLATE("Seeding Limits"));
	
	addingLabel->SetFont(be_bold_font);
	downloadingLabel->SetFont(be_bold_font);
*/
	BStringView* peerPortLabel = new BStringView("", B_TRANSLATE("Peer Port"));
	BStringView* limitsLabel = new BStringView("", B_TRANSLATE("Limits"));
	BStringView* otherLabel = new BStringView("", B_TRANSLATE("Other"));
	peerPortLabel->SetFont(be_bold_font);
	limitsLabel->SetFont(be_bold_font);
	otherLabel->SetFont(be_bold_font);
	

	BStringView* fListeningPortLabel = new BStringView("", B_TRANSLATE("Incoming port:"));
	BStringView* fMaxConnectionLabel = new BStringView("", B_TRANSLATE("Max connections:"));
	BStringView* fTorrentMaxConnectionLabel	= new BStringView("", B_TRANSLATE("Connected peers limit:"));
	//BStringView* fTorrentUploadSlotsLabel = new BStringView("", B_TRANSLATE("Connected peers per torrent limit:"));

	
	
	fListeningPort = new BTextControl("_name", NULL, "", NULL);
	fRandomPort = new BButton("", B_TRANSLATE("Random"), new BMessage(MSG_INCOMING_PORT_RANDOM_BEHAVIOR_CHANGED));
	fApplyPort = new BButton("", B_TRANSLATE("Apply"), new BMessage(MSG_INCOMING_PORT_BEHAVIOR_CHANGED));
	fEnableForwardingPort = new BCheckBox("", B_TRANSLATE("Enable UPnP / NAT-PMP port forwarding"), new BMessage(MSG_PORT_FORWARDING_BEHAVIOR_CHANGED));	
	fMaxConnection = new BTextControl("_name", "", "", NULL);
	fApplyMaxConnection = new BButton("", B_TRANSLATE("Apply"), new BMessage(MSG_PEER_LIMIT_BEHAVIOR_CHANGED));
	fTorrentMaxConnection = new BTextControl("_name", "", "", NULL);
	fApplyTorrentMaxConnection = new BButton("", B_TRANSLATE("Apply"), new BMessage(MSG_PEER_LIMIT_PER_TORRENT_BEHAVIOR_CHANGED));
	//BTextControl* fTorrentUploadSlots = new BTextControl("_name", "", "", NULL);
	BCheckBox* fEnableDHTValue = new BCheckBox("", B_TRANSLATE("Enable Distributed Hash Table (DHT)"), new BMessage(MSG_DISTRIBUTED_HASH_TABLE_BEHAVIOR_CHANGED));
	BCheckBox* fEnablePEXValue = new BCheckBox("", B_TRANSLATE("Enable Bit Torrent Peer EXchange (PEX)"), new BMessage(MSG_TORRENT_PEER_EXCHANGE_BEHAVIOR_CHANGED));
	BCheckBox* fEnableUTPValue = new BCheckBox("", B_TRANSLATE("Enable Micro Transport Protocol (" UTF8_GREEK_MU_LETTER "TP)"), new BMessage(MSG_MICRO_TRANSPORT_PROTOCOL_BEHAVIOR_CHANGED));
	BCheckBox* fEnableLPDValue = new BCheckBox("", B_TRANSLATE("Enable Local Peer Discovery (LPD)"), new BMessage(MSG_LOCAL_PEER_DISCOVERY_BEHAVIOR_CHANGED));
	
	//
	BPopUpMenu* menu = new BPopUpMenu("");
	
	
	fEncryptionMenuItem[0] = new BMenuItem(B_TRANSLATE("Off"), _CreateEncryptionMenuMessage(0));
	fEncryptionMenuItem[1] = new BMenuItem(B_TRANSLATE("Enabled"), _CreateEncryptionMenuMessage(1));
	fEncryptionMenuItem[2] = new BMenuItem(B_TRANSLATE("Required"), _CreateEncryptionMenuMessage(2));
	
	menu->AddItem(fEncryptionMenuItem[0]);
	menu->AddItem(fEncryptionMenuItem[1]);
	menu->AddItem(fEncryptionMenuItem[2]);
	
	fEncryptionMenu = new BMenuField("", B_TRANSLATE("Encryption:"), menu);
	
	//
	BString textBuffer;	
	
	textBuffer << (int32)fTorrentPreferences->IncomingPort();
	fListeningPort->SetText(textBuffer);
	
	textBuffer = B_EMPTY_STRING;
	textBuffer << (int32)fTorrentPreferences->PeerLimit();
	fMaxConnection->SetText(textBuffer);
	
	textBuffer = B_EMPTY_STRING;
	textBuffer << (int32)fTorrentPreferences->PeerLimitPerTorrent();
	fTorrentMaxConnection->SetText(textBuffer);
	
	//textBuffer << (int32)fTorrentPreferences->IncomingPort();
	//fTorrentUploadSlots->SetText(textBuffer);
	

	fEnableForwardingPort->SetValue(fTorrentPreferences->PortForwardingEnabled() ? B_CONTROL_ON : B_CONTROL_OFF);
	fEnableDHTValue->SetValue(fTorrentPreferences->DistributedHashTableEnabled() ? B_CONTROL_ON : B_CONTROL_OFF);
	fEnablePEXValue->SetValue(fTorrentPreferences->PeerExchangeEnabled() ? B_CONTROL_ON : B_CONTROL_OFF);
	fEnableUTPValue->SetValue(fTorrentPreferences->MicroTransportProtocolEnabled() ? B_CONTROL_ON : B_CONTROL_OFF);
	fEnableLPDValue->SetValue(fTorrentPreferences->LocalPeerDiscoveryEnabled() ? B_CONTROL_ON : B_CONTROL_OFF);
	fEncryptionMenuItem[fTorrentPreferences->EncryptionMode()]->SetMarked(true);
	
	//
	fListeningPort->SetExplicitMaxSize(BSize(60, 40));
	fMaxConnection->SetExplicitMaxSize(BSize(60, 40));
	fTorrentMaxConnection->SetExplicitMaxSize(BSize(60, 40));
	//fTorrentUploadSlots->SetExplicitMaxSize(BSize(60, 40));
	
	//
	//
	BView* view = BGroupLayoutBuilder(B_VERTICAL, spacing / 2)
		.Add(peerPortLabel)
		.Add(BGridLayoutBuilder(-1, spacing / 2)
			.SetInsets(spacing / 2, -1, -1, -1)
			.Add(fListeningPortLabel, 0, 0)
			//.Add(BSpaceLayoutItem::CreateHorizontalStrut(spacing), 1, 0)
			.Add(fListeningPort, 1, 0)
			.Add(fRandomPort, 2, 0)
			.Add(fApplyPort, 3, 0)
			
			//.Add(BSpaceLayoutItem::CreateGlue(), 2, 0)
			//.Add(BSpaceLayoutItem::CreateGlue(), 3, 0)
			//.Add(BSpaceLayoutItem::CreateGlue(), 4, 0)
			
			//
			.Add(fEnableForwardingPort, 0, 1, 3, 1)
			
			//
		)
		.Add(limitsLabel)
		.Add(BGridLayoutBuilder(spacing / 2, spacing / 2)
			.SetInsets(spacing / 2, -1, -1, -1)
			.Add(fMaxConnectionLabel, 0, 0)
			.Add(fMaxConnection, 1, 0)
			.Add(fApplyMaxConnection, 2, 0)
			// padding
			//.Add(BSpaceLayoutItem::CreateGlue(), 3, 0)
			//.Add(BSpaceLayoutItem::CreateGlue(), 4, 0)
			
			//
			.Add(fTorrentMaxConnectionLabel, 0, 1)
			.Add(fTorrentMaxConnection, 1, 1)
			.Add(fApplyTorrentMaxConnection, 2, 1)
			//
			//.Add(fTorrentUploadSlotsLabel, 0, 2)
			//.Add(fTorrentUploadSlots, 1, 2)
		)
		.Add(otherLabel)
		.Add(BGridLayoutBuilder(spacing / 2, spacing / 2)
			.SetInsets(spacing / 2, -1, -1, -1)
			.Add(fEnableDHTValue, 0, 0, 3, 1)
			.Add(fEnablePEXValue, 0, 1, 3, 1)
			.Add(fEnableUTPValue, 0, 2, 3, 1)
			.Add(fEnableLPDValue, 0, 3, 3, 1)
			
			
			//
			.Add(fEncryptionMenu->CreateLabelLayoutItem(), 0, 4)
			.Add(fEncryptionMenu->CreateMenuBarLayoutItem(), 1, 4)
		)
		.SetInsets(spacing, spacing, spacing, spacing)
		.TopView()
	;
	view->SetName("Connection");
	return view;
}
Example #24
0
FindWindow::FindWindow(BMessenger messenger, const BString& str,
	bool findSelection, bool matchWord, bool matchCase, bool forwardSearch)
	:
	BWindow(kWindowFrame, B_TRANSLATE("Find"), B_FLOATING_WINDOW,
		B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_CLOSE_ON_ESCAPE
		| B_AUTO_UPDATE_SIZE_LIMITS),
	fFindDlgMessenger(messenger)
{
	SetLayout(new BGroupLayout(B_VERTICAL));

	BBox* separator = new BBox("separator");
	separator->SetExplicitMinSize(BSize(250.0, B_SIZE_UNSET));
	separator->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, 1.0));

	BRadioButton* useSelection = NULL;
	const float spacing = be_control_look->DefaultItemSpacing();
	AddChild(BGroupLayoutBuilder(B_VERTICAL, B_USE_SMALL_SPACING)
		.SetInsets(spacing, spacing, spacing, spacing)
		.Add(BGridLayoutBuilder(B_USE_SMALL_SPACING, B_USE_SMALL_SPACING)
			.Add(fTextRadio = new BRadioButton(B_TRANSLATE("Use text:"),
				new BMessage(TOGGLE_FIND_CONTROL)), 0, 0)
			.Add(fFindLabel = new BTextControl(NULL, NULL, NULL), 1, 0)
			.Add(useSelection = new BRadioButton(B_TRANSLATE("Use selection"),
				new BMessage(TOGGLE_FIND_CONTROL)), 0, 1))
		.Add(BSpaceLayoutItem::CreateVerticalStrut(spacing / 4))
		.Add(separator)
		.Add(BSpaceLayoutItem::CreateVerticalStrut(spacing / 4))
		.Add(fForwardSearchBox = new BCheckBox(B_TRANSLATE("Search forward")))
		.Add(fMatchCaseBox = new BCheckBox(B_TRANSLATE("Match case")))
		.Add(fMatchWordBox = new BCheckBox(B_TRANSLATE("Match word")))
		.AddGroup(B_HORIZONTAL)
			.AddGlue()
			.Add(fFindButton = new BButton(B_TRANSLATE("Find"),
				new BMessage(MSG_FIND)))
			.End()
		.TopView());

	fFindLabel->SetDivider(0.0);

	if (!findSelection) {
		fFindLabel->SetText(str.String());
		fFindLabel->MakeFocus(true);
	} else {
		fFindLabel->SetEnabled(false);
	}

	if (findSelection)
		useSelection->SetValue(B_CONTROL_ON);
	else
		fTextRadio->SetValue(B_CONTROL_ON);

	if (forwardSearch)
		fForwardSearchBox->SetValue(B_CONTROL_ON);

	if (matchCase)
		fMatchCaseBox->SetValue(B_CONTROL_ON);

	if (matchWord)
		fMatchWordBox->SetValue(B_CONTROL_ON);

	fFindButton->MakeDefault(true);

	AddShortcut((uint32)'W', B_COMMAND_KEY, new BMessage(MSG_FIND_HIDE));
}
Example #25
0
bool AuthenticationPanel::getAuthentication(const BString& text,
    const BString& previousUser, const BString& previousPass,
	bool previousRememberCredentials, bool badPassword,
	BString& user, BString&  pass, bool* rememberCredentials)
{
	// Configure panel and layout controls.
	rgb_color infoColor = ui_color(B_PANEL_TEXT_COLOR);
	BRect textBounds(0, 0, 250, 200);
	BTextView* textView = new BTextView(textBounds, "text", textBounds,
	    be_plain_font, &infoColor, B_FOLLOW_NONE, B_WILL_DRAW | B_SUPPORTS_LAYOUT);
	textView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	textView->SetText(text.String());
	textView->MakeEditable(false);
	textView->MakeSelectable(false);

    m_usernameTextControl->SetText(previousUser.String());
	m_passwordTextControl->TextView()->HideTyping(true);
	// Ignore the previous password, if it didn't work.
	if (!badPassword)
	    m_passwordTextControl->SetText(previousPass.String());
	m_hidePasswordCheckBox->SetValue(B_CONTROL_ON);
	m_rememberCredentialsCheckBox->SetValue(previousRememberCredentials);

	// create layout
	SetLayout(new BGroupLayout(B_VERTICAL, 0.0));
	float spacing = be_control_look->DefaultItemSpacing();
	AddChild(BGroupLayoutBuilder(B_VERTICAL, 0.0)
	    .Add(BGridLayoutBuilder(0, spacing)
	        .Add(textView, 0, 0, 2)
	        .Add(m_usernameTextControl->CreateLabelLayoutItem(), 0, 1)
	        .Add(m_usernameTextControl->CreateTextViewLayoutItem(), 1, 1)
	        .Add(m_passwordTextControl->CreateLabelLayoutItem(), 0, 2)
	        .Add(m_passwordTextControl->CreateTextViewLayoutItem(), 1, 2)
	        .Add(BSpaceLayoutItem::CreateGlue(), 0, 3)
	        .Add(m_hidePasswordCheckBox, 1, 3)
	        .Add(m_rememberCredentialsCheckBox, 0, 4, 2)
	        .SetInsets(spacing, spacing, spacing, spacing)
	    )
	    .Add(new BSeparatorView(B_HORIZONTAL, B_PLAIN_BORDER))
	    .Add(BGroupLayoutBuilder(B_HORIZONTAL, spacing)
	        .AddGlue()
	        .Add(m_cancelButton)
	        .Add(m_okButton)
	        .SetInsets(spacing, spacing, spacing, spacing)
	    )
	);

	float textHeight = textView->LineHeight(0) * textView->CountLines();
	textView->SetExplicitMinSize(BSize(B_SIZE_UNSET, textHeight));

	SetDefaultButton(m_okButton);
	if (badPassword && previousUser.Length())
	    m_passwordTextControl->MakeFocus(true);
	else
	    m_usernameTextControl->MakeFocus(true);

    if (m_parentWindowFrame.IsValid())
        CenterIn(m_parentWindowFrame);
    else
        CenterOnScreen();

	// Start AuthenticationPanel window thread
	Show();

	// Let the window jitter, if the previous password was invalid
	if (badPassword)
		PostMessage(kMsgJitter);

	// Block calling thread
	// Get the originating window, if it exists, to let it redraw itself.
	BWindow* window = dynamic_cast<BWindow*>(BLooper::LooperForThread(find_thread(NULL)));
	if (window) {
		status_t err;
		for (;;) {
			do {
				err = acquire_sem_etc(m_exitSemaphore, 1, B_RELATIVE_TIMEOUT, 10000);
				// We've (probably) had our time slice taken away from us
			} while (err == B_INTERRUPTED);

			if (err != B_TIMED_OUT) {
				// Semaphore was finally released or nuked.
				break;
			}
			window->UpdateIfNeeded();
		}
	} else {
		// No window to update, so just hang out until we're done.
		while (acquire_sem(m_exitSemaphore) == B_INTERRUPTED) {
		}
	}

	// AuthenticationPanel wants to quit.
	Lock();

	user = m_usernameTextControl->Text();
	pass = m_passwordTextControl->Text();
	if (rememberCredentials)
        *rememberCredentials = m_rememberCredentialsCheckBox->Value() == B_CONTROL_ON;

    bool canceled = m_cancelled;
	Quit();
	// AuthenticationPanel object is TOAST here.
	return !canceled;
}
Example #26
0
void
PrintOptionsWindow::Setup()
{
    BString value;
    enum PrintOptions::Option op = fCurrentOptions.Option();
    BRadioButton* rbFit;
    BRadioButton* rbZoom;
    BRadioButton* rbDpi;
    BRadioButton* rbResize;
    BBox* line;
    BButton* button;

    rbFit = AddRadioButton("fit_to_page", B_TRANSLATE("Fit image to page"),
                           kMsgFitToPageSelected, op == PrintOptions::kFitToPage);

    rbZoom = AddRadioButton("zoom_factor", B_TRANSLATE("Zoom factor in %:"),
                            kMsgZoomFactorSelected, op == PrintOptions::kZoomFactor);

    fZoomFactor = AddTextControl("zoom_factor_text", "",
                                 fCurrentOptions.ZoomFactor() * 100, kMsgZoomFactorChanged);

    rbDpi = AddRadioButton("dpi", B_TRANSLATE("DPI:"), kMsgDPISelected,
                           op == PrintOptions::kDPI);

    fDPI = AddTextControl("dpi_text", "", fCurrentOptions.DPI(),
                          kMsgDPIChanged);

    rbResize = AddRadioButton("width_and_height",
                              B_TRANSLATE("Resize to (in 1/72 inches):"), kMsgWidthAndHeightSelected,
                              op == PrintOptions::kWidth || op == PrintOptions::kHeight);

    fWidth = AddTextControl("width", B_TRANSLATE("Width:"),
                            fCurrentOptions.Width(), kMsgWidthChanged);

    fHeight = AddTextControl("height", B_TRANSLATE("Height: "),
                             fCurrentOptions.Height(), kMsgHeightChanged);

    line = new BBox(B_EMPTY_STRING, B_WILL_DRAW | B_FRAME_EVENTS,
                    B_FANCY_BORDER);
    line->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, 1));

    button = new BButton("job setup", B_TRANSLATE("Job setup"),
                         new BMessage(kMsgJobSetup));
    SetDefaultButton(button);

    const float spacing = be_control_look->DefaultItemSpacing();

    SetLayout(new BGroupLayout(B_HORIZONTAL));
    AddChild(BGroupLayoutBuilder(B_VERTICAL, 0)
             .Add(BGridLayoutBuilder()
                  .Add(rbFit, 0, 0)
                  .Add(rbZoom, 0, 1)
                  .Add(fZoomFactor, 1, 1)
                  .Add(rbDpi, 0, 2)
                  .Add(fDPI, 1, 2)
                  .Add(rbResize, 0, 3)
                 )
             .AddGroup(B_HORIZONTAL, spacing)
             .Add(fWidth)
             .Add(fHeight)
             .AddGlue()
             .SetInsets(22, 0, 0, 0)
             .End()
             .Add(line)
             .AddGroup(B_HORIZONTAL, 0)
             .Add(button)
             .End()
             .SetInsets(spacing, spacing, spacing, spacing)
            );
}
Example #27
0
void
CreateParamsPanel::_CreateViewControls(BPartition* parent, off_t offset,
	off_t size)
{
	// Setup the controls
	fSizeSlider = new SizeSlider("Slider", B_TRANSLATE("Partition size"), NULL,
		offset, offset + size);
	fSizeSlider->SetPosition(1.0);
	fSizeSlider->SetModificationMessage(new BMessage(MSG_SIZE_SLIDER));

	fSizeTextControl = new BTextControl("Size Control", "", "", NULL);
	for(int32 i = 0; i < 256; i++)
		fSizeTextControl->TextView()->DisallowChar(i);
	for(int32 i = '0'; i <= '9'; i++)
		fSizeTextControl->TextView()->AllowChar(i);
	_UpdateSizeTextControl();
	fSizeTextControl->SetModificationMessage(
		new BMessage(MSG_SIZE_TEXTCONTROL));

	fNameTextControl = new BTextControl("Name Control",
		B_TRANSLATE("Partition name:"),	"", NULL);
	if (!parent->SupportsChildName())
		fNameTextControl->SetEnabled(false);

	fTypePopUpMenu = new BPopUpMenu("Partition Type");

	int32 cookie = 0;
	BString supportedType;
	while (parent->GetNextSupportedChildType(&cookie, &supportedType)
			== B_OK) {
		BMessage* message = new BMessage(MSG_PARTITION_TYPE);
		message->AddString("type", supportedType);
		BMenuItem* item = new BMenuItem(supportedType, message);
		fTypePopUpMenu->AddItem(item);

		if (strcmp(supportedType, kPartitionTypeBFS) == 0)
			item->SetMarked(true);
	}

	fTypeMenuField = new BMenuField(B_TRANSLATE("Partition type:"),
		fTypePopUpMenu);

	const float spacing = be_control_look->DefaultItemSpacing();
	BGroupLayout* layout = new BGroupLayout(B_VERTICAL, spacing);
	layout->SetInsets(spacing, spacing, spacing, spacing);

	SetLayout(layout);

	AddChild(BGroupLayoutBuilder(B_VERTICAL, spacing)
		.Add(fSizeSlider)
		.Add(fSizeTextControl)
		.Add(BGridLayoutBuilder(0.0, 5.0)
			.Add(fNameTextControl->CreateLabelLayoutItem(), 0, 0)
			.Add(fNameTextControl->CreateTextViewLayoutItem(), 1, 0)
			.Add(fTypeMenuField->CreateLabelLayoutItem(), 0, 1)
			.Add(fTypeMenuField->CreateMenuBarLayoutItem(), 1, 1)
		)
	);

	status_t err = parent->GetParameterEditor(B_CREATE_PARAMETER_EDITOR,
		&fEditor);
	if (err == B_OK && fEditor != NULL)
		AddChild(fEditor->View());
	else
		fEditor = NULL;

	BButton* okButton = new BButton(B_TRANSLATE("Create"),
		new BMessage(MSG_OK));
	AddChild(BGroupLayoutBuilder(B_HORIZONTAL, spacing)
		.AddGlue()
		.Add(new BButton(B_TRANSLATE("Cancel"), new BMessage(MSG_CANCEL)))
		.Add(okButton)
	);
	SetDefaultButton(okButton);

	AddToSubset(fWindow);
	layout->View()->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
}
Example #28
0
BView* PreferencesWindow::_CreateTorrentsPage(float spacing)
{
	BStringView* addingLabel 		= new BStringView("", B_TRANSLATE("Adding"));
	BStringView* downloadingLabel 	= new BStringView("", B_TRANSLATE("Downloading"));
	//BStringView* seedingLabel 	= new BStringView("", B_TRANSLATE("Seeding Limits"));
	
	addingLabel->SetFont(be_bold_font);
	downloadingLabel->SetFont(be_bold_font);
	
	//
	//
	//
	//fAutoAddTorrentsFrom = new BCheckBox("auto_add_torrents_from",
	//	B_TRANSLATE("Automatically add torrents from:"), 
	//	new BMessage(MSG_ADD_TORRENT_FROM_FOLDER_CHANGED));
	//fAutoAddTorrentsFrom->SetValue(B_CONTROL_OFF);
	//
	//
	//fAutoAddTorrentsFromFolder = new FolderSelect("auto_add_torrents_from_folder",
	//	NULL, "/test/path"/*new BMessage(MSG_DOWNLOAD_FOLDER_CHANGED)*/);
	//
	//fAutoAddTorrentsFromFolder->SetEnabled(false);


	BCheckBox* fShowOptionsDialog = new BCheckBox("Show options dialog",
		B_TRANSLATE("Show options dialog"),
		NULL /*new BMessage(MSG_AUTO_HIDE_INTERFACE_BEHAVIOR_CHANGED)*/);
	fShowOptionsDialog->SetValue(B_CONTROL_OFF);
	
	BCheckBox* fStartWhenAdded = new BCheckBox("start_when_added",
		B_TRANSLATE("Start when added"),
		new BMessage(MSG_START_WHEN_ADDED_BEHAVIOR_CHANGED));
	fStartWhenAdded->SetValue(fTorrentPreferences->StartWhenAddedEnabled() ? B_CONTROL_ON : B_CONTROL_OFF);
	
	fIncompleteFileNaming = new BCheckBox("incomplete_file_naming",
		B_TRANSLATE("Append \".part\" to incomplete files' names"), 
		new BMessage(MSG_INCOMPLETE_FILENAMING_BEHAVIOR_CHANGED));
	fIncompleteFileNaming->SetValue(fTorrentPreferences->IncompleteFileNamingEnabled() ? B_CONTROL_ON : B_CONTROL_OFF);
	
	BStringView* fTorrentSaveLocation = new BStringView("", B_TRANSLATE("Save to Location:"));
	fTorrentSaveLocationPath = new FolderSelect("download_folder_select", 
		fTorrentPreferences->DownloadFolder(), new BMessage(MSG_DOWNLOAD_FOLDER_BEHAVIOR_CHANGED));
		
	fIncompleteDirEnabled = new BCheckBox("incomplete_torrent_folder",
		B_TRANSLATE("Incomplete torrents folder"),
		new BMessage(MSG_INCOMPLETE_FOLDER_BEHAVIOR_CHANGED));
	fIncompleteDirEnabled->SetValue(fTorrentPreferences->IncompleteFolderEnabled() ? B_CONTROL_ON : B_CONTROL_OFF);
	
	fIncompleteDirPath = new FolderSelect("incomplete_torrent_folder_path", 
		fTorrentPreferences->IncompleteFolder(), new BMessage(MSG_INCOMPLETE_FOLDER_PATH_BEHAVIOR_CHANGED));
	fIncompleteDirPath->SetEnabled(fTorrentPreferences->IncompleteFolderEnabled());
	
	//
	//
	//
	BView* view = BGroupLayoutBuilder(B_VERTICAL, spacing / 2)
		.Add(addingLabel)
		//.Add(BGridLayoutBuilder(spacing / 2, spacing / 2)
		//	.Add(fAutoAddTorrentsFrom, 0, 0)
		//	.Add(fAutoAddTorrentsFromFolder, 1, 0)
		//)
		.Add(BGridLayoutBuilder(spacing, spacing / 2)
			.SetInsets(spacing / 2, -1, -1, -1)
			.Add(fShowOptionsDialog, 0, 0)
			.Add(fStartWhenAdded, 0, 1)
		)
		.Add(downloadingLabel)
		.Add(BGridLayoutBuilder(spacing, spacing / 2)
			.SetInsets(spacing / 2, -1, -1, -1)
			.Add(fIncompleteFileNaming, 0, 0, 2, 1)
			.Add(fTorrentSaveLocation, 0, 1)
			.Add(fTorrentSaveLocationPath, 1, 1)
			.Add(fIncompleteDirEnabled, 0, 2)
			.Add(fIncompleteDirPath, 1, 2)
		)
		.Add(BSpaceLayoutItem::CreateHorizontalStrut(spacing))
		.SetInsets(spacing, spacing, spacing, spacing)
		.TopView()
	;
	view->SetName("Torrents");
	return view;

}
Example #29
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);
}
Example #30
0
AntialiasingSettingsView::AntialiasingSettingsView(const char* name)
	: BView(name, 0)
{
	// collect the current system settings
	if (get_subpixel_antialiasing(&fCurrentSubpixelAntialiasing) != B_OK)
		fCurrentSubpixelAntialiasing = false;
	fSavedSubpixelAntialiasing = fCurrentSubpixelAntialiasing;

	if (get_hinting_mode(&fCurrentHinting) != B_OK)
		fCurrentHinting = HINTING_MODE_ON;
	fSavedHinting = fCurrentHinting;

	if (get_average_weight(&fCurrentAverageWeight) != B_OK)
		fCurrentAverageWeight = 100;
	fSavedAverageWeight = fCurrentAverageWeight;

	// create the controls

	// antialiasing menu
	_BuildAntialiasingMenu();
	fAntialiasingMenuField = new BMenuField("antialiasing",
		B_TRANSLATE("Antialiasing type:"), fAntialiasingMenu, NULL);

	// "average weight" in subpixel filtering
	fAverageWeightControl = new BSlider("averageWeightControl",
		B_TRANSLATE("Reduce colored edges filter strength:"),
		new BMessage(kMsgSetAverageWeight), 0, 255, B_HORIZONTAL);
	fAverageWeightControl->SetLimitLabels(B_TRANSLATE("Off"),
		B_TRANSLATE("Strong"));
	fAverageWeightControl->SetHashMarks(B_HASH_MARKS_BOTTOM);
	fAverageWeightControl->SetHashMarkCount(255 / 15);
	fAverageWeightControl->SetEnabled(false);

	// hinting menu
	_BuildHintingMenu();
	fHintingMenuField = new BMenuField("hinting", B_TRANSLATE("Glyph hinting:"),
		fHintingMenu, NULL);

#ifdef DISABLE_HINTING_CONTROL
	fHintingMenuField->SetEnabled(false);
#endif

#ifndef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
	// subpixelAntialiasingDisabledLabel
	BFont infoFont(*be_plain_font);
	infoFont.SetFace(B_ITALIC_FACE);
	rgb_color infoColor = tint_color(ui_color(B_PANEL_BACKGROUND_COLOR),
		B_DARKEN_4_TINT);
	// TODO: Replace with layout friendly constructor once available.
	BRect textBounds = Bounds();
	BTextView* subpixelAntialiasingDisabledLabel = new BTextView(
		textBounds, "unavailable label", textBounds, &infoFont, &infoColor,
		B_FOLLOW_NONE, B_WILL_DRAW | B_SUPPORTS_LAYOUT);
	subpixelAntialiasingDisabledLabel->SetText(B_TRANSLATE(
		"Subpixel based anti-aliasing in combination with glyph hinting is not "
		"available in this build of Haiku to avoid possible patent issues. To "
		"enable this feature, you have to build Haiku yourself and enable "
		"certain options in the libfreetype configuration header."));
	subpixelAntialiasingDisabledLabel->SetViewColor(
		ui_color(B_PANEL_BACKGROUND_COLOR));
	subpixelAntialiasingDisabledLabel->MakeEditable(false);
	subpixelAntialiasingDisabledLabel->MakeSelectable(false);
#endif // !FT_CONFIG_OPTION_SUBPIXEL_RENDERING

	SetLayout(new BGroupLayout(B_VERTICAL));

	// controls pane
	AddChild(BGridLayoutBuilder(10, 10)
		.Add(fHintingMenuField->CreateLabelLayoutItem(), 0, 0)
		.Add(fHintingMenuField->CreateMenuBarLayoutItem(), 1, 0)

		.Add(fAntialiasingMenuField->CreateLabelLayoutItem(), 0, 1)
		.Add(fAntialiasingMenuField->CreateMenuBarLayoutItem(), 1, 1)

		.Add(fAverageWeightControl, 0, 2, 2)

#ifndef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
		// hinting+subpixel unavailable info
		.Add(subpixelAntialiasingDisabledLabel, 0, 3, 2)
#else
		.Add(BSpaceLayoutItem::CreateGlue(), 0, 3, 2)
#endif

		.SetInsets(10, 10, 10, 10)
	);

	_SetCurrentAntialiasing();
	_SetCurrentHinting();
	_SetCurrentAverageWeight();
}