Exemplo n.º 1
0
DocInfoWindow::DocInfoWindow(BMessage *docInfo)
	: HWindow(BRect(0, 0, 400, 250), "Document Information", B_TITLED_WINDOW_LOOK,
		B_MODAL_APP_WINDOW_FEEL, B_NOT_MINIMIZABLE),
	fDocInfo(docInfo)
{
	BRect bounds(Bounds());
	BView *background = new BView(bounds, "bachground", B_FOLLOW_ALL, B_WILL_DRAW);
	background->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	AddChild(background);

	bounds.InsetBy(10.0, 10.0);
	BButton *button = new BButton(bounds, "ok", "OK", new BMessage(OK_MSG),
		B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
	background->AddChild(button);
	button->ResizeToPreferred();
	button->MoveTo(bounds.right - button->Bounds().Width(),
		bounds.bottom - button->Bounds().Height());

	BRect buttonFrame(button->Frame());
	button = new BButton(buttonFrame, "cancel", "Cancel", new BMessage(CANCEL_MSG),
		B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
	background->AddChild(button);
	button->ResizeToPreferred();
	button->MoveTo(buttonFrame.left - (button->Bounds().Width() + 10.0),
		buttonFrame.top);

	bounds.bottom = buttonFrame.top - 10.0;

#if HAVE_FULLVERSION_PDF_LIB
	BString permissions;
	if (_DocInfo()->FindString("permissions", &permissions) == B_OK)
		fPermissions.Decode(permissions.String());

	BTabView *tabView = new BTabView(bounds, "tabView");
	_SetupDocInfoView(_CreateTabPanel(tabView, "Information"));
	_SetupPasswordView(_CreateTabPanel(tabView, "Password"));
	_SetupPermissionsView(_CreateTabPanel(tabView, "Permissions"));

	background->AddChild(tabView);
#else
	BBox* panel = new BBox(bounds, "top_panel", B_FOLLOW_ALL,
		B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP, B_NO_BORDER);

	_SetupDocInfoView(panel);
	background->AddChild(panel);
#endif

	if (fTable->ChildAt(0))
		fTable->ChildAt(0)->MakeFocus();

	BRect winFrame(Frame());
	BRect screenFrame(BScreen().Frame());
	MoveTo((screenFrame.right - winFrame.right) / 2,
		(screenFrame.bottom - winFrame.bottom) / 2);

	SetSizeLimits(400.0, 10000.0, 250.0, 10000.0);
}
Exemplo n.º 2
0
AlertView::AlertView(BRect frame, const char *name)
	: BView(frame, name, B_FOLLOW_ALL, B_WILL_DRAW | B_PULSE_NEEDED),
	// we will wait 12 seconds until we send a message
	fSeconds(12)
{
	SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	fBitmap = InitIcon();

	BRect rect(60, 8, 400, 36);
	BStringView *stringView = new BStringView(rect, NULL,
		"Do you wish to keep these settings?");
	stringView->SetFont(be_bold_font);
	stringView->ResizeToPreferred();
	AddChild(stringView);

	rect = stringView->Frame();
	rect.OffsetBy(0, rect.Height());
	fCountdownView = new BStringView(rect, "countdown", NULL);
	UpdateCountdownView();
	fCountdownView->ResizeToPreferred();
	AddChild(fCountdownView);

	BButton* keepButton = new BButton(rect, "keep", "Keep",
		new BMessage(BUTTON_KEEP_MSG), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
	keepButton->ResizeToPreferred();
	AddChild(keepButton);

	BButton* button = new BButton(rect, "undo", "Undo",
		new BMessage(BUTTON_UNDO_MSG), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
	button->ResizeToPreferred();
	AddChild(button);

	// we're resizing ourselves to the right size
	// (but we're not implementing GetPreferredSize(), bad style!)
	float width = stringView->Frame().right;
	if (fCountdownView->Frame().right > width)
		width = fCountdownView->Frame().right;
	if (width < Bounds().Width())
		width = Bounds().Width();

	float height
		= fCountdownView->Frame().bottom + 24 + button->Bounds().Height();
	ResizeTo(width, height);

	keepButton->MoveTo(Bounds().Width() - 8 - keepButton->Bounds().Width(),
		Bounds().Height() - 8 - keepButton->Bounds().Height());
	button->MoveTo(keepButton->Frame().left - button->Bounds().Width() - 8,
		keepButton->Frame().top);

	keepButton->MakeDefault(true);
}
Exemplo n.º 3
0
StringInputWindow::StringInputWindow(const char *title, const char *text, BMessage msg,
									BMessenger target)
	:	DWindow(BRect(0,0,300,200),title,B_TITLED_WINDOW,
				B_ASYNCHRONOUS_CONTROLS | B_NOT_V_RESIZABLE),
		fMessage(msg),
		fMessenger(target)
{
	MakeCenteredOnShow(true);
	BView *top = GetBackgroundView();
	
	BRect r = Bounds().InsetByCopy(10,10);
	r.bottom = r.top + 10;
	BRect textRect = r.OffsetToCopy(0,0);
	textRect.InsetBy(10,10);
	fTextView = new BTextView(r,"paneltext",textRect,B_FOLLOW_LEFT | B_FOLLOW_TOP);
	top->AddChild(fTextView);
	fTextView->MakeEditable(false);
	fTextView->SetText(text);
	fTextView->ResizeTo(r.Width(), 20.0 + (fTextView->CountLines() * 
									fTextView->TextHeight(0,fTextView->TextLength())));
	fTextView->SetViewColor(top->ViewColor());
	
	fText = new BTextControl(BRect(10,10,11,11),"nametext","", "", new BMessage);
	top->AddChild(fText);
	fText->ResizeToPreferred();
	fText->ResizeTo(Bounds().Width() - 20,fText->Bounds().Height());
	fText->SetDivider(0.0);
	fText->MoveTo(10,fTextView->Frame().bottom + 10.0);
	
	r = fText->Frame();
	r.OffsetBy(0,r.Height() + 10.0);
	BButton *cancel = new BButton(r,"cancel","Cancel",
									new BMessage(B_QUIT_REQUESTED));
	cancel->ResizeToPreferred();
	top->AddChild(cancel);
	
	ResizeTo(300, cancel->Frame().bottom + 10);
	cancel->MoveTo( Bounds().Width() - (cancel->Bounds().Width() * 2) - 20,
					cancel->Frame().top);
	
	r = cancel->Frame();
	r.OffsetBy(r.Width() + 10,0);
	BButton *open = new BButton(r,"ok","OK", new BMessage(M_INVOKE));
	top->AddChild(open);
	open->MakeDefault(true);
	fText->MakeFocus(true);
	
	open->MakeDefault(true);
}
Exemplo n.º 4
0
PasswordWindow::PasswordWindow()
	: BWindow(BRect(100, 100, 400, 230), "Enter password",
		B_NO_BORDER_WINDOW_LOOK, kPasswordWindowFeel
			/* TODO: B_MODAL_APP_WINDOW_FEEL should also behave correctly */,
		B_NOT_MOVABLE | B_NOT_CLOSABLE | B_NOT_ZOOMABLE | B_NOT_MINIMIZABLE
		| B_NOT_RESIZABLE | B_ASYNCHRONOUS_CONTROLS, B_ALL_WORKSPACES)
{
	BView* topView = new BView(Bounds(), "topView", B_FOLLOW_ALL, B_WILL_DRAW);
	topView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	AddChild(topView);

	BRect bounds(Bounds());
	bounds.InsetBy(10.0, 10.0);

	BBox *customBox = new BBox(bounds, "customBox", B_FOLLOW_NONE);
	topView->AddChild(customBox);
	customBox->SetLabel("Unlock screen saver");

	bounds.top += 10.0;
	fPassword = new BTextControl(bounds, "password", "Enter password:"******"VeryLongPasswordPossible", B_FOLLOW_NONE);
	customBox->AddChild(fPassword);
	fPassword->MakeFocus(true);
	fPassword->ResizeToPreferred();
	fPassword->TextView()->HideTyping(true);
	fPassword->SetDivider(be_plain_font->StringWidth("Enter password:"******"unlock", "Unlock",
		new BMessage(kMsgUnlock), B_FOLLOW_NONE);
	customBox->AddChild(button);
	button->MakeDefault(true);
	button->ResizeToPreferred();
	button->SetTarget(NULL, be_app);

	BRect frame = fPassword->Frame();
	button->MoveTo(frame.right - button->Bounds().Width(), frame.bottom + 10.0);
	customBox->ResizeTo(frame.right + 10.0,	button->Frame().bottom + 10.0);

	frame = customBox->Frame();
	ResizeTo(frame.right + 10.0, frame.bottom + 10.0);

	BScreen screen(this);
	MoveTo(screen.Frame().left + (screen.Frame().Width() - Bounds().Width()) / 2,
		screen.Frame().top + (screen.Frame().Height() - Bounds().Height()) / 2);
}
Exemplo n.º 5
0
FindWindow::FindWindow(BRect _rect, BMessage& previous, BMessenger& target,
		const BMessage* settings)
	: BWindow(_rect, B_TRANSLATE("Find"), B_TITLED_WINDOW,
		B_ASYNCHRONOUS_CONTROLS | B_CLOSE_ON_ESCAPE),
	fTarget(target)
{
	BView* view = new BView(Bounds(), "main", B_FOLLOW_ALL, 0);
	view->SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
	AddChild(view);

	int8 mode = kAsciiMode;
	if (previous.FindInt8("find_mode", &mode) != B_OK && settings != NULL)
		settings->FindInt8("find_mode", &mode);

	// add the top widgets

	fMenu = new BPopUpMenu("mode");
	BMessage* message;
	BMenuItem* item;
	fMenu->AddItem(item = new BMenuItem(B_TRANSLATE("Text"),
		message = new BMessage(kMsgFindMode)));
	message->AddInt8("mode", kAsciiMode);
	if (mode == kAsciiMode)
		item->SetMarked(true);
	fMenu->AddItem(item = new BMenuItem(B_TRANSLATE_COMMENT("Hexadecimal", 
		"A menu item, as short as possible, noun is recommended if it is "
		"shorter than adjective."), message = new BMessage(kMsgFindMode)));
	message->AddInt8("mode", kHexMode);
	if (mode == kHexMode)
		item->SetMarked(true);

	BRect rect = Bounds().InsetByCopy(5, 5);
	BMenuField* menuField = new BMenuField(rect, B_EMPTY_STRING,
		B_TRANSLATE("Mode:"), fMenu, B_FOLLOW_LEFT | B_FOLLOW_TOP);
	menuField->SetDivider(menuField->StringWidth(menuField->Label()) + 8);
	menuField->ResizeToPreferred();
	view->AddChild(menuField);

	// add the bottom widgets

	BButton* button = new BButton(rect, B_EMPTY_STRING, B_TRANSLATE("Find"),
		new BMessage(kMsgStartFind), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
	button->MakeDefault(true);
	button->ResizeToPreferred();
	button->MoveTo(rect.right - button->Bounds().Width(),
		rect.bottom - button->Bounds().Height());
	view->AddChild(button);

	fCaseCheckBox = new BCheckBox(rect, B_EMPTY_STRING, B_TRANSLATE("Case sensitive"),
		NULL, B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
	fCaseCheckBox->ResizeToPreferred();
	fCaseCheckBox->MoveTo(5, button->Frame().top);
	bool caseSensitive;
	if (previous.FindBool("case_sensitive", &caseSensitive) != B_OK) {
		if (settings == NULL
			|| settings->FindBool("case_sensitive", &caseSensitive) != B_OK)
			caseSensitive = true;
	}
	fCaseCheckBox->SetValue(caseSensitive);
	view->AddChild(fCaseCheckBox);

	// and now those inbetween

	rect.top = menuField->Frame().bottom + 5;
	rect.bottom = fCaseCheckBox->Frame().top - 8;
	rect.InsetBy(2, 2);
	fTextView = new FindTextView(rect, B_EMPTY_STRING,
		rect.OffsetToCopy(B_ORIGIN).InsetByCopy(3, 3), B_FOLLOW_ALL);
	fTextView->SetWordWrap(true);
	fTextView->SetMode((find_mode)mode);
	fTextView->SetData(previous);

	BScrollView* scrollView = new BScrollView("scroller", fTextView,
		B_FOLLOW_ALL, B_WILL_DRAW, false, false);
	view->AddChild(scrollView);

	ResizeTo(290, button->Frame().Height() * 3 + 30);

	SetSizeLimits(fCaseCheckBox->Bounds().Width() + button->Bounds().Width()
			+ 20, 32768, button->Frame().Height() * 3 + 10, 32768);
}
Exemplo n.º 6
0
FileTypesWindow::FileTypesWindow(const BMessage& settings)
	: BWindow(_Frame(settings), "FileTypes", B_TITLED_WINDOW,
		B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS),
	fNewTypeWindow(NULL)
{
	bool showIcons;
	bool showRule;
	if (settings.FindBool("show_icons", &showIcons) != B_OK)
		showIcons = true;
	if (settings.FindBool("show_rule", &showRule) != B_OK)
		showRule = false;

	// add the menu

	BMenuBar* menuBar = new BMenuBar(BRect(0, 0, 0, 0), NULL);
	AddChild(menuBar);

	BMenu* menu = new BMenu("File");
	BMenuItem* item;
	menu->AddItem(item = new BMenuItem("New resource file" B_UTF8_ELLIPSIS,
		NULL, 'N', B_COMMAND_KEY));
	item->SetEnabled(false);

	BMenu* recentsMenu = BRecentFilesList::NewFileListMenu("Open" B_UTF8_ELLIPSIS,
		NULL, NULL, be_app, 10, false, NULL, kSignature);
	item = new BMenuItem(recentsMenu, new BMessage(kMsgOpenFilePanel));
	item->SetShortcut('O', B_COMMAND_KEY);
	menu->AddItem(item);
	menu->AddItem(new BMenuItem("Application types" B_UTF8_ELLIPSIS,
		new BMessage(kMsgOpenApplicationTypesWindow)));
	menu->AddSeparatorItem();

	menu->AddItem(new BMenuItem("About FileTypes" B_UTF8_ELLIPSIS,
		new BMessage(B_ABOUT_REQUESTED)));
	menu->AddSeparatorItem();

	menu->AddItem(new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED),
		'Q', B_COMMAND_KEY));
	menu->SetTargetForItems(be_app);
	menuBar->AddItem(menu);

	menu = new BMenu("Settings");
	item = new BMenuItem("Show icons in list", new BMessage(kMsgToggleIcons));
	item->SetMarked(showIcons);
	item->SetTarget(this);
	menu->AddItem(item);

	item = new BMenuItem("Show recognition rule", new BMessage(kMsgToggleRule));
	item->SetMarked(showRule);
	item->SetTarget(this);
	menu->AddItem(item);
	menuBar->AddItem(menu);

	// MIME Types list

	BRect rect = Bounds();
	rect.top = menuBar->Bounds().Height() + 1.0f;
	BView* topView = new BView(rect, NULL, B_FOLLOW_ALL, B_WILL_DRAW);
	topView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	AddChild(topView);

	BButton* button = new BButton(rect, "add", "Add" B_UTF8_ELLIPSIS,
		new BMessage(kMsgAddType), B_FOLLOW_BOTTOM);
	button->ResizeToPreferred();
	button->MoveTo(8.0f, topView->Bounds().bottom - 8.0f - button->Bounds().Height());
	topView->AddChild(button);

	rect = button->Frame();
	rect.OffsetBy(rect.Width() + 8.0f, 0.0f);
	fRemoveTypeButton = new BButton(rect, "remove", "Remove",
		new BMessage(kMsgRemoveType), B_FOLLOW_BOTTOM);
	fRemoveTypeButton->ResizeToPreferred();
	topView->AddChild(fRemoveTypeButton);

	rect.bottom = rect.top - 10.0f;
	rect.top = 10.0f;
	rect.left = 10.0f;
	rect.right -= B_V_SCROLL_BAR_WIDTH + 2.0f;
	if (rect.right < 180)
		rect.right = 180;

	fTypeListView = new MimeTypeListView(rect, "typeview", NULL, showIcons, false,
		B_FOLLOW_LEFT | B_FOLLOW_TOP_BOTTOM);
	fTypeListView->SetSelectionMessage(new BMessage(kMsgTypeSelected));

	BScrollView* scrollView = new BScrollView("scrollview", fTypeListView,
		B_FOLLOW_LEFT | B_FOLLOW_TOP_BOTTOM, B_FRAME_EVENTS | B_WILL_DRAW, false, true);
	topView->AddChild(scrollView);

	// "Icon" group

	font_height plainHeight;
	be_plain_font->GetHeight(&plainHeight);
	float height = ceilf(plainHeight.ascent + plainHeight.descent
		+ plainHeight.leading) + 2.0f;

	BFont font(be_bold_font);
	float labelWidth = font.StringWidth("Icon");
	font_height boldHeight;
	font.GetHeight(&boldHeight);

	BRect innerRect;
	fIconView = new TypeIconView(innerRect, "icon",
		B_FOLLOW_LEFT | B_FOLLOW_V_CENTER);
	fIconView->ResizeToPreferred();

	rect.left = rect.right + 12.0f + B_V_SCROLL_BAR_WIDTH;
	rect.right = rect.left + max_c(fIconView->Bounds().Width(), labelWidth) + 16.0f;
	rect.bottom = rect.top + ceilf(boldHeight.ascent)
		+ max_c(fIconView->Bounds().Height(),
			button->Bounds().Height() * 2.0f + height + 4.0f) + 12.0f;
	rect.top -= 2.0f;
	fIconBox = new BBox(rect);
	fIconBox->SetLabel("Icon");
	topView->AddChild(fIconBox);

	innerRect.left = 8.0f;
	innerRect.top = plainHeight.ascent + 3.0f
		+ (rect.Height() - boldHeight.ascent - fIconView->Bounds().Height()) / 2.0f;
	if (innerRect.top + fIconView->Bounds().Height() > fIconBox->Bounds().Height() - 6.0f)
		innerRect.top = fIconBox->Bounds().Height() - 6.0f - fIconView->Bounds().Height();
	fIconView->MoveTo(innerRect.LeftTop());
	fIconBox->AddChild(fIconView);

	// "File Recognition" group

	BRect rightRect(rect);
	rightRect.left = rect.right + 8.0f;
	rightRect.right = topView->Bounds().Width() - 8.0f;
	fRecognitionBox = new BBox(rightRect, NULL, B_FOLLOW_LEFT_RIGHT);
	fRecognitionBox->SetLabel("File recognition");
	topView->AddChild(fRecognitionBox);

	innerRect = fRecognitionBox->Bounds().InsetByCopy(8.0f, 4.0f);
	innerRect.top += ceilf(boldHeight.ascent);
	fExtensionLabel = new StringView(innerRect, "extension", "Extensions:", NULL);
	fExtensionLabel->SetAlignment(B_ALIGN_LEFT, B_ALIGN_LEFT);
	fExtensionLabel->ResizeToPreferred();
	fRecognitionBox->AddChild(fExtensionLabel);

	innerRect.top += fExtensionLabel->Bounds().Height() + 2.0f;
	innerRect.left = innerRect.right - button->StringWidth("Remove") - 16.0f;
	innerRect.bottom = innerRect.top + button->Bounds().Height();
	fAddExtensionButton = new BButton(innerRect, "add ext", "Add" B_UTF8_ELLIPSIS,
		new BMessage(kMsgAddExtension), B_FOLLOW_RIGHT);
	fRecognitionBox->AddChild(fAddExtensionButton);

	innerRect.OffsetBy(0, innerRect.Height() + 4.0f);
	fRemoveExtensionButton = new BButton(innerRect, "remove ext", "Remove",
		new BMessage(kMsgRemoveExtension), B_FOLLOW_RIGHT);
	fRecognitionBox->AddChild(fRemoveExtensionButton);

	innerRect.right = innerRect.left - 10.0f - B_V_SCROLL_BAR_WIDTH;
	innerRect.left = 10.0f;
	innerRect.top = fAddExtensionButton->Frame().top + 2.0f;
	innerRect.bottom = innerRect.bottom - 2.0f;
		// take scrollview border into account
	fExtensionListView = new ExtensionListView(innerRect, "listview ext",
		B_SINGLE_SELECTION_LIST, B_FOLLOW_LEFT_RIGHT);
	fExtensionListView->SetSelectionMessage(new BMessage(kMsgExtensionSelected));
	fExtensionListView->SetInvocationMessage(new BMessage(kMsgExtensionInvoked));

	scrollView = new BScrollView("scrollview ext", fExtensionListView,
		B_FOLLOW_LEFT_RIGHT, B_FRAME_EVENTS | B_WILL_DRAW, false, true);
	fRecognitionBox->AddChild(scrollView);

	innerRect.left = 8.0f;
	innerRect.top = innerRect.bottom + 10.0f;
	innerRect.right = fRecognitionBox->Bounds().right - 8.0f;
	innerRect.bottom = innerRect.top + 20.0f;
	fRuleControl = new BTextControl(innerRect, "rule", "Rule:", "",
		new BMessage(kMsgRuleEntered), B_FOLLOW_LEFT_RIGHT);
	//fRuleControl->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT);
	fRuleControl->SetDivider(fRuleControl->StringWidth(fRuleControl->Label()) + 6.0f);
	fRuleControl->Hide();
	fRecognitionBox->AddChild(fRuleControl);

	// "Description" group

	rect.top = rect.bottom + 8.0f;
	rect.bottom = rect.top + ceilf(boldHeight.ascent) + 24.0f;
	rect.right = rightRect.right;
	fDescriptionBox = new BBox(rect, NULL, B_FOLLOW_LEFT_RIGHT);
	fDescriptionBox->SetLabel("Description");
	topView->AddChild(fDescriptionBox);

	innerRect = fDescriptionBox->Bounds().InsetByCopy(8.0f, 6.0f);
	innerRect.top += ceilf(boldHeight.ascent);
	innerRect.bottom = innerRect.top + button->Bounds().Height();
	fInternalNameView = new StringView(innerRect, "internal", "Internal name:", "",
		B_FOLLOW_LEFT_RIGHT);
	labelWidth = fInternalNameView->StringWidth(fInternalNameView->Label()) + 2.0f;
	fInternalNameView->SetDivider(labelWidth);
	fInternalNameView->SetEnabled(false);
	fInternalNameView->ResizeToPreferred();
	fDescriptionBox->AddChild(fInternalNameView);

	innerRect.OffsetBy(0, fInternalNameView->Bounds().Height() + 5.0f);
	fTypeNameControl = new BTextControl(innerRect, "type", "Type name:", "",
		new BMessage(kMsgTypeEntered), B_FOLLOW_LEFT_RIGHT);
	fTypeNameControl->SetDivider(labelWidth);
	fTypeNameControl->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT);
	fDescriptionBox->ResizeBy(0, fInternalNameView->Bounds().Height()
		+ fTypeNameControl->Bounds().Height() * 2.0f);
	fDescriptionBox->AddChild(fTypeNameControl);

	innerRect.OffsetBy(0, fTypeNameControl->Bounds().Height() + 5.0f);
	fDescriptionControl = new BTextControl(innerRect, "description", "Description:", "",
		new BMessage(kMsgDescriptionEntered), B_FOLLOW_LEFT_RIGHT);
	fDescriptionControl->SetDivider(labelWidth);
	fDescriptionControl->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT);
	fDescriptionBox->AddChild(fDescriptionControl);

	// "Preferred Application" group

	rect = fDescriptionBox->Frame();
	rect.top = rect.bottom + 8.0f;
	rect.bottom = rect.top + ceilf(boldHeight.ascent)
		+ button->Bounds().Height() + 14.0f;
	fPreferredBox = new BBox(rect, NULL, B_FOLLOW_LEFT_RIGHT);
	fPreferredBox->SetLabel("Preferred application");
	topView->AddChild(fPreferredBox);

	innerRect = fPreferredBox->Bounds().InsetByCopy(8.0f, 6.0f);
	innerRect.top += ceilf(boldHeight.ascent);
	innerRect.left = innerRect.right - button->StringWidth(
		"Same as" B_UTF8_ELLIPSIS) - 24.0f;
	innerRect.bottom = innerRect.top + button->Bounds().Height();
	fSameAsButton = new BButton(innerRect, "same as",
		"Same as" B_UTF8_ELLIPSIS,
		new BMessage(kMsgSamePreferredAppAs), B_FOLLOW_RIGHT);
	fPreferredBox->AddChild(fSameAsButton);

	innerRect.OffsetBy(-innerRect.Width() - 6.0f, 0.0f);
	fSelectButton = new BButton(innerRect, "select", "Select" B_UTF8_ELLIPSIS,
		new BMessage(kMsgSelectPreferredApp), B_FOLLOW_RIGHT);
	fPreferredBox->AddChild(fSelectButton);

	menu = new BPopUpMenu("preferred");
	menu->AddItem(item = new BMenuItem("None",
		new BMessage(kMsgPreferredAppChosen)));
	item->SetMarked(true);

	innerRect.right = innerRect.left - 6.0f;
	innerRect.left = 8.0f;

	fPreferredField = new BMenuField(innerRect, "preferred", NULL, menu, true,
		B_FOLLOW_LEFT_RIGHT);
	float width;
	fPreferredField->GetPreferredSize(&width, &height);
	fPreferredField->ResizeTo(innerRect.Width(), height);
	fPreferredField->MoveBy(0.0f, (innerRect.Height() - height) / 2.0f);

	fPreferredBox->AddChild(fPreferredField);

	// "Extra Attributes" group

	rect.top = rect.bottom + 8.0f;
	rect.bottom = topView->Bounds().Height() - 8.0f;
	fAttributeBox = new BBox(rect, NULL, B_FOLLOW_LEFT_RIGHT
		| B_FOLLOW_TOP_BOTTOM);
	fAttributeBox->SetLabel("Extra attributes");
	topView->AddChild(fAttributeBox);

	innerRect = fAttributeBox->Bounds().InsetByCopy(8.0f, 6.0f);
	innerRect.top += ceilf(boldHeight.ascent);
	innerRect.left = innerRect.right - button->StringWidth("Remove") - 16.0f;
	innerRect.bottom = innerRect.top + button->Bounds().Height();
	fAddAttributeButton = new BButton(innerRect, "add attr",
		"Add" B_UTF8_ELLIPSIS, new BMessage(kMsgAddAttribute), B_FOLLOW_RIGHT);
	fAttributeBox->AddChild(fAddAttributeButton);

	innerRect.OffsetBy(0, innerRect.Height() + 4.0f);
	fRemoveAttributeButton = new BButton(innerRect, "remove attr", "Remove",
		new BMessage(kMsgRemoveAttribute), B_FOLLOW_RIGHT);
	fAttributeBox->AddChild(fRemoveAttributeButton);
/*
	innerRect.OffsetBy(0, innerRect.Height() + 4.0f);
	button = new BButton(innerRect, "push attr", "Push Up",
		new BMessage(kMsgRemoveAttribute), B_FOLLOW_RIGHT);
	fAttributeBox->AddChild(button);
*/
	innerRect.right = innerRect.left - 10.0f - B_V_SCROLL_BAR_WIDTH;
	innerRect.left = 10.0f;
	innerRect.top = 8.0f + ceilf(boldHeight.ascent);
	innerRect.bottom = fAttributeBox->Bounds().bottom - 10.0f;
		// take scrollview border into account
	fAttributeListView = new AttributeListView(innerRect, "listview attr",
		B_FOLLOW_ALL);
	fAttributeListView->SetSelectionMessage(new BMessage(kMsgAttributeSelected));
	fAttributeListView->SetInvocationMessage(new BMessage(kMsgAttributeInvoked));

	scrollView = new BScrollView("scrollview attr", fAttributeListView,
		B_FOLLOW_ALL, B_FRAME_EVENTS | B_WILL_DRAW, false, true);
	fAttributeBox->AddChild(scrollView);

	SetSizeLimits(rightRect.left + 72.0f + font.StringWidth("jpg")
		+ font.StringWidth(fRecognitionBox->Label()), 32767.0f,
		rect.top + 2.0f * button->Bounds().Height() + boldHeight.ascent
		+ 32.0f + menuBar->Bounds().Height(), 32767.0f);

	_SetType(NULL);
	_ShowSnifferRule(showRule);

	BMimeType::StartWatching(this);
}
Exemplo n.º 7
0
AttributeWindow::AttributeWindow(FileTypesWindow* target, BMimeType& mimeType,
		AttributeItem* attributeItem)
	: BWindow(BRect(100, 100, 350, 200), "Attribute", B_MODAL_WINDOW_LOOK,
		B_MODAL_SUBSET_WINDOW_FEEL, B_NOT_ZOOMABLE | B_NOT_V_RESIZABLE
			| B_ASYNCHRONOUS_CONTROLS),
	fTarget(target),
	fMimeType(mimeType.Type())
{
	if (attributeItem != NULL)
		fAttribute = *attributeItem;

	BRect rect = Bounds();
	BView* topView = new BView(rect, NULL, B_FOLLOW_ALL, B_WILL_DRAW);
	topView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	AddChild(topView);

	rect.InsetBy(8.0f, 8.0f);
	fPublicNameControl = new BTextControl(rect, "public", "Attribute name:",
		fAttribute.PublicName(), NULL, B_FOLLOW_LEFT_RIGHT);
	fPublicNameControl->SetModificationMessage(new BMessage(kMsgAttributeUpdated));

	float labelWidth = fPublicNameControl->StringWidth(fPublicNameControl->Label()) + 2.0f;
	fPublicNameControl->SetDivider(labelWidth);
	fPublicNameControl->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT);

	float width, height;
	fPublicNameControl->GetPreferredSize(&width, &height);
	fPublicNameControl->ResizeTo(rect.Width(), height);
	topView->AddChild(fPublicNameControl);

	rect = fPublicNameControl->Frame();
	rect.OffsetBy(0.0f, rect.Height() + 5.0f);
	fAttributeControl = new BTextControl(rect, "internal", "Internal name:",
		fAttribute.Name(), NULL, B_FOLLOW_LEFT_RIGHT);
	fAttributeControl->SetModificationMessage(new BMessage(kMsgAttributeUpdated));
	fAttributeControl->SetDivider(labelWidth);
	fAttributeControl->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT);

	// filter out invalid characters that can't be part of an attribute
	BTextView* textView = fAttributeControl->TextView();
	const char* disallowedCharacters = "/";
	for (int32 i = 0; disallowedCharacters[i]; i++) {
		textView->DisallowChar(disallowedCharacters[i]);
	}

	topView->AddChild(fAttributeControl);

	fTypeMenu = new BPopUpMenu("type");
	BMenuItem* item = NULL;
	for (int32 i = 0; kTypeMap[i].name != NULL; i++) {
		BMessage* message = new BMessage(kMsgTypeChosen);
		message->AddInt32("type", kTypeMap[i].type);

		item = new BMenuItem(kTypeMap[i].name, message);
		fTypeMenu->AddItem(item);

		if (kTypeMap[i].type == fAttribute.Type())
			item->SetMarked(true);
	}

	rect.OffsetBy(0.0f, rect.Height() + 4.0f);
	BMenuField* menuField = new BMenuField(rect, "types",
		"Type:", fTypeMenu);
	menuField->SetDivider(labelWidth);
	menuField->SetAlignment(B_ALIGN_RIGHT);
	menuField->GetPreferredSize(&width, &height);
	menuField->ResizeTo(rect.Width(), height);
	topView->AddChild(menuField);

	rect.OffsetBy(0.0f, rect.Height() + 4.0f);
	rect.bottom = rect.top + fAttributeControl->Bounds().Height() * 2.0f + 18.0f;
	BBox* box = new BBox(rect, "", B_FOLLOW_LEFT_RIGHT);
	topView->AddChild(box);

	fVisibleCheckBox = new BCheckBox(rect, "visible", "Visible",
		new BMessage(kMsgVisibilityChanged));
	fVisibleCheckBox->SetValue(fAttribute.Visible());
	fVisibleCheckBox->ResizeToPreferred();
	box->SetLabel(fVisibleCheckBox);

	labelWidth -= 8.0f;

	BMenu* menu = new BPopUpMenu("display as");
	for (int32 i = 0; kDisplayAsMap[i].name != NULL; i++) {
		BMessage* message = new BMessage(kMsgDisplayAsChosen);
		if (kDisplayAsMap[i].identifier != NULL) {
			message->AddString("identifier", kDisplayAsMap[i].identifier);
			for (int32 j = 0; kDisplayAsMap[i].supported[j]; j++) {
				message->AddInt32("supports", kDisplayAsMap[i].supported[j]);
			}
		}

		item = new BMenuItem(kDisplayAsMap[i].name, message);
		menu->AddItem(item);

		if (compare_display_as(kDisplayAsMap[i].identifier, fAttribute.DisplayAs()))
			item->SetMarked(true);
	}

	rect.OffsetTo(8.0f, fVisibleCheckBox->Bounds().Height());
	rect.right -= 18.0f;
	fDisplayAsMenuField = new BMenuField(rect, "display as",
		"Display as:", menu);
	fDisplayAsMenuField->SetDivider(labelWidth);
	fDisplayAsMenuField->SetAlignment(B_ALIGN_RIGHT);
	fDisplayAsMenuField->ResizeTo(rect.Width(), height);
	box->AddChild(fDisplayAsMenuField);

	fEditableCheckBox = new BCheckBox(rect, "editable", "Editable",
		new BMessage(kMsgAttributeUpdated), B_FOLLOW_RIGHT);
	fEditableCheckBox->SetValue(fAttribute.Editable());
	fEditableCheckBox->ResizeToPreferred();
	fEditableCheckBox->MoveTo(rect.right - fEditableCheckBox->Bounds().Width(),
		rect.top + (fDisplayAsMenuField->Bounds().Height()
		- fEditableCheckBox->Bounds().Height()) / 2.0f);
	box->AddChild(fEditableCheckBox);

	rect.OffsetBy(0.0f, menuField->Bounds().Height() + 4.0f);
	rect.bottom = rect.top + fPublicNameControl->Bounds().Height();
	fSpecialControl = new BTextControl(rect, "special", "Special:",
		display_as_parameter(fAttribute.DisplayAs()), NULL,
		B_FOLLOW_LEFT_RIGHT);
	fSpecialControl->SetModificationMessage(new BMessage(kMsgAttributeUpdated));
	fSpecialControl->SetDivider(labelWidth);
	fSpecialControl->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT);
	fSpecialControl->SetEnabled(false);
	box->AddChild(fSpecialControl);

	char text[64];
	snprintf(text, sizeof(text), "%ld", fAttribute.Width());
	rect.OffsetBy(0.0f, fSpecialControl->Bounds().Height() + 4.0f);
	fWidthControl = new BTextControl(rect, "width", "Width:",
		text, NULL, B_FOLLOW_LEFT_RIGHT);
	fWidthControl->SetModificationMessage(new BMessage(kMsgAttributeUpdated));
	fWidthControl->SetDivider(labelWidth);
	fWidthControl->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT);

	// filter out invalid characters that can't be part of a width
	textView = fWidthControl->TextView();
	for (int32 i = 0; i < 256; i++) {
		if (!isdigit(i))
			textView->DisallowChar(i);
	}
	textView->SetMaxBytes(4);

	box->AddChild(fWidthControl);

	const struct alignment_map {
		int32		alignment;
		const char*	name;
	} kAlignmentMap[] = {
		{B_ALIGN_LEFT, "Left"},
		{B_ALIGN_RIGHT, "Right"},
		{B_ALIGN_CENTER, "Center"},
		{0, NULL}
	};

	menu = new BPopUpMenu("alignment");
	for (int32 i = 0; kAlignmentMap[i].name != NULL; i++) {
		BMessage* message = new BMessage(kMsgAlignmentChosen);
		message->AddInt32("alignment", kAlignmentMap[i].alignment);

		item = new BMenuItem(kAlignmentMap[i].name, message);
		menu->AddItem(item);

		if (kAlignmentMap[i].alignment == fAttribute.Alignment())
			item->SetMarked(true);
	}

	rect.OffsetBy(0.0f, menuField->Bounds().Height() + 1.0f);
	fAlignmentMenuField = new BMenuField(rect, "alignment",
		"Alignment:", menu);
	fAlignmentMenuField->SetDivider(labelWidth);
	fAlignmentMenuField->SetAlignment(B_ALIGN_RIGHT);
	fAlignmentMenuField->ResizeTo(rect.Width(), height);
	box->AddChild(fAlignmentMenuField);
	box->ResizeBy(0.0f, fAlignmentMenuField->Bounds().Height() * 2.0f
		+ fVisibleCheckBox->Bounds().Height());

	fAcceptButton = new BButton(rect, "add", item ? "Done" : "Add",
		new BMessage(kMsgAccept), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
	fAcceptButton->ResizeToPreferred();
	fAcceptButton->MoveTo(Bounds().Width() - 8.0f - fAcceptButton->Bounds().Width(),
		Bounds().Height() - 8.0f - fAcceptButton->Bounds().Height());
	fAcceptButton->SetEnabled(false);
	topView->AddChild(fAcceptButton);

	BButton* button = new BButton(rect, "cancel", "Cancel",
		new BMessage(B_QUIT_REQUESTED), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
	button->ResizeToPreferred();
	button->MoveTo(fAcceptButton->Frame().left - 10.0f - button->Bounds().Width(),
		fAcceptButton->Frame().top);
	topView->AddChild(button);

	ResizeTo(labelWidth * 4.0f + 24.0f, box->Frame().bottom
		+ button->Bounds().Height() + 20.0f);
	SetSizeLimits(fEditableCheckBox->Bounds().Width() + button->Bounds().Width()
		+ fAcceptButton->Bounds().Width() + labelWidth + 24.0f,
		32767.0f, Frame().Height(), Frame().Height());

	fAcceptButton->MakeDefault(true);
	fPublicNameControl->MakeFocus(true);

	target->PlaceSubWindow(this);
	AddToSubset(target);
}
Exemplo n.º 8
0
OpenWithContainerWindow::OpenWithContainerWindow(BMessage* entriesToOpen,
	LockingList<BWindow>* windowList, window_look look, window_feel feel,
	uint32 flags, uint32 workspace)
	:
	BContainerWindow(windowList, 0, look, feel, flags, workspace),
	fEntriesToOpen(entriesToOpen)
{
	AutoLock<BWindow> lock(this);

	BRect windowRect(85, 50, 718, 296);
	MoveTo(windowRect.LeftTop());
	ResizeTo(windowRect.Width(), windowRect.Height());

	// add a background view; use the standard BackgroundView here, the same
	// as the file panel is using
	BRect rect(Bounds());
	BackgroundView* backgroundView = new BackgroundView(rect);
	AddChild(backgroundView);

	rect = Bounds();

	// add buttons

	fLaunchButton = new BButton(rect, "ok",	B_TRANSLATE("Open"),
		new BMessage(kDefaultButton), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
	fLaunchButton->ResizeToPreferred();
	fLaunchButton->MoveTo(rect.right - 10 - kDocumentKnobWidth
		- fLaunchButton->Bounds().Width(),
		rect.bottom - 10.0f - fLaunchButton->Bounds().Height());
	backgroundView->AddChild(fLaunchButton);

	BRect buttonRect = fLaunchButton->Frame();
	fLaunchAndMakeDefaultButton = new BButton(buttonRect, "make default",
		B_TRANSLATE("Open and make preferred"),
		new BMessage(kOpenAndMakeDefault), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
	// wide button, have to resize to fit text
	fLaunchAndMakeDefaultButton->ResizeToPreferred();
	fLaunchAndMakeDefaultButton->MoveBy(-10.0f
		- fLaunchAndMakeDefaultButton->Bounds().Width(), 0.0f);
	backgroundView->AddChild(fLaunchAndMakeDefaultButton);
	fLaunchAndMakeDefaultButton->SetEnabled(false);

	buttonRect = fLaunchAndMakeDefaultButton->Frame();
	BButton* button = new BButton(buttonRect, "cancel", B_TRANSLATE("Cancel"),
		new BMessage(kCancelButton), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
	button->ResizeToPreferred();
	button->MoveBy(-10.0f - button->Bounds().Width(), 0.0f);
	backgroundView->AddChild(button);

	fMinimalWidth = button->Bounds().Width() + fLaunchButton->Bounds().Width()
		+ fLaunchAndMakeDefaultButton->Bounds().Width() + kDocumentKnobWidth
		+ 40.0f;

	fLaunchButton->MakeDefault(true);

	// add pose view

	rect.OffsetTo(10.0f, 10.0f);
	rect.bottom = buttonRect.top - 15.0f;

	rect.right -= B_V_SCROLL_BAR_WIDTH + 20.0f;
	rect.bottom -= B_H_SCROLL_BAR_HEIGHT;
		// make room for scrollbars and a margin
	fPoseView = NewPoseView(0, rect, kListMode);
	backgroundView->AddChild(fPoseView);

	fPoseView->SetFlags(fPoseView->Flags() | B_NAVIGABLE);
	fPoseView->SetPoseEditing(false);

	// set the window title
	if (CountRefs(fEntriesToOpen) == 1) {
		// if opening just one file, use it in the title
		entry_ref ref;
		fEntriesToOpen->FindRef("refs", &ref);
		BString buffer(B_TRANSLATE("Open %name with:"));
		buffer.ReplaceFirst("%name", ref.name);

		SetTitle(buffer.String());
	} else {
		// use generic title
		SetTitle(B_TRANSLATE("Open selection with:"));
	}

	AddCommonFilter(new BMessageFilter(B_KEY_DOWN,
		&OpenWithContainerWindow::KeyDownFilter));
}
Exemplo n.º 9
0
void
AlertTestWindow::Test()
{
	BAlert *pAlert = new BAlert(
		"alert1",
		k60X,
		k20X, "OK", "Cancel",
		B_WIDTH_AS_USUAL, // widthStyle
		B_OFFSET_SPACING,
		B_EMPTY_ALERT		// alert_type		
	);
	if (fAlertType == 'H') {
		BView *master = pAlert->ChildAt(0);
		master->SetViewColor(ui_color(B_MENU_BACKGROUND_COLOR));
	}
	
	BPoint pt;
	BString strLabel;
	BButton *pBtns[3] = { NULL };
	pBtns[0] = pAlert->ButtonAt(0);
	pBtns[1] = pAlert->ButtonAt(1);
	pBtns[2] = pAlert->ButtonAt(2);
	
	BTextView *pTextView = pAlert->TextView();
	
	// Window info
	printf("wi.width = %.1ff;\n"
		"wi.height = %.1ff;\n"
		"ati.SetWinInfo(wi);\n",
		pAlert->Bounds().Width(), pAlert->Bounds().Height());
		
	// TextView info
	printf("\n");
	which_label(pTextView->Text(), strLabel);
	pt = pTextView->ConvertToParent(BPoint(0, 0));
	printf("ti.label = %s;\n"
		"ti.width = %.1ff;\n"
		"ti.height = %.1ff;\n"
		"ti.topleft.Set(%.1ff, %.1ff);\n"
		"ati.SetTextViewInfo(ti);\n",
		strLabel.String(), pTextView->Bounds().Width(),
		pTextView->Bounds().Height(), pt.x, pt.y);
		
	// Button info
	printf("\n");
	int32 i = 0;
	while (i < 3 && pBtns[i] != NULL) {
		BButton *pb = pBtns[i];
		which_label(pb->Label(), strLabel);
		pt = pb->ConvertToParent(BPoint(0, 0));
		printf("bi.label = %s;\n"
			"bi.width = %.1ff;\n"
			"bi.height = %.1ff;\n"
			"bi.topleft.Set(%.1ff, %.1ff);\n"
			"ati.SetButtonInfo(%d, bi);\n",
			strLabel.String(), pb->Bounds().Width(),
			pb->Bounds().Height(), pt.x, pt.y,
			(int)i);
		i++;
	}

	int32 result = pAlert->Go();
	printf("%c<Clicked: %d\n", fAlertType, static_cast<int>(result));
	pAlert = NULL;
}
Exemplo n.º 10
0
JobSetupWindow::JobSetupWindow(BMessage *msg, const char * printerName)
	:	BlockingWindow(BRect(0, 0, 300, 200), "Job Setup", B_TITLED_WINDOW_LOOK,
 			B_MODAL_APP_WINDOW_FEEL, B_NOT_RESIZABLE | B_NOT_MINIMIZABLE |
 			B_NOT_ZOOMABLE),
	fPrinterName(printerName),
	fSetupMsg(msg)
{
	if (printerName)
		SetTitle(BString(printerName).Append(" Job Setup").String());

	int32 firstPage;
	fSetupMsg->FindInt32("first_page", &firstPage);

	int32 lastPage;
	fSetupMsg->FindInt32("last_page", &lastPage);
	bool allPages = firstPage == 1 && lastPage == LONG_MAX;

	BRect bounds(Bounds());
	BBox *panel = new BBox(bounds, "background", B_FOLLOW_ALL,
		B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP, B_PLAIN_BORDER);
	AddChild(panel);

	bounds.InsetBy(10.0, 10.0);

	fAll = new BRadioButton(bounds, "allPages", "Print all pages",
		new BMessage(ALL_PAGES_MGS));
	panel->AddChild(fAll);
	fAll->ResizeToPreferred();
	fAll->SetValue(allPages);

	bounds.OffsetBy(0.0, fAll->Bounds().Height() + 10.0);
	fRange = new BRadioButton(bounds, "pagesRange", "Print pages:",
		new BMessage(RANGE_SELECTION_MSG));
	panel->AddChild(fRange);
	fRange->ResizeToPreferred();
	fRange->SetValue(!allPages);

	bounds.OffsetBy(0.0, fRange->Bounds().Height() + 5.0);
	BRect rect(bounds);
	rect.right = be_plain_font->StringWidth("From: SomeSpaceHere");
	fFrom = new BTextControl(rect, "from", "From:", "SomeSpaceHere", NULL);
	panel->AddChild(fFrom);
	fFrom->SetAlignment(B_ALIGN_LEFT, B_ALIGN_RIGHT);
	fFrom->ResizeToPreferred();
	fFrom->SetDivider(be_plain_font->StringWidth("From: "));
	fFrom->SetEnabled(!allPages);

	rect = fFrom->Frame();
	fTo = new BTextControl(rect, "to", "To:", "SomeSpaceHere", NULL);
	panel->AddChild(fTo);
	fTo->SetAlignment(B_ALIGN_LEFT, B_ALIGN_RIGHT);
	fTo->SetDivider(be_plain_font->StringWidth("To: "));
	fTo->MoveTo(fFrom->Frame().right + 10.0, fTo->Frame().top);
	fTo->SetEnabled(!allPages);

	BString buffer;
	buffer << firstPage;
	fFrom->SetText(buffer.String());

	buffer = "";
	buffer << lastPage;
	fTo->SetText(buffer.String());

	for (uint32 i = 0; i < '0'; i++) {
		fTo->TextView()->DisallowChar(i);
		fFrom->TextView()->DisallowChar(i);
	}

	for (uint32 i = '9' + 1; i < 255; i++) {
		fTo->TextView()->DisallowChar(i);
		fFrom->TextView()->DisallowChar(i);
	}

	bounds.OffsetBy(0.0, fTo->Bounds().Height() + 10.0);
	BBox *line = new BBox(BRect(bounds.left - 5.0, bounds.top, bounds.right + 5.0,
		bounds.top + 1.0), NULL, B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP );
	panel->AddChild(line);

	bounds.OffsetBy(0.0, 11.0);
	BButton *cancel = new BButton(bounds, NULL, "Cancel", new BMessage(CANCEL_MSG));
	panel->AddChild(cancel);
	cancel->ResizeToPreferred();

	BButton *ok = new BButton(bounds, NULL, "OK", new BMessage(OK_MSG));
	panel->AddChild(ok, cancel);
	ok->ResizeToPreferred();

	bounds.right = fTo->Frame().right;
	ok->MoveTo(bounds.right - ok->Bounds().Width(), ok->Frame().top);

	bounds = ok->Frame();
	cancel->MoveTo(bounds.left - cancel->Bounds().Width() - 10.0, bounds.top);

	ok->MakeDefault(true);
	ResizeTo(bounds.right + 10.0, bounds.bottom + 10.0);

	BRect winFrame(Frame());
	BRect screenFrame(BScreen().Frame());
	MoveTo((screenFrame.right - winFrame.right) / 2,
		(screenFrame.bottom - winFrame.bottom) / 2);
}
Exemplo n.º 11
0
void 
PasswordWindow::_Setup()
{
	BRect bounds = Bounds();
	BView* topView = new BView(bounds, "topView", B_FOLLOW_ALL, B_WILL_DRAW);
	topView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	AddChild(topView);

	bounds.InsetBy(10.0, 10.0);
	fUseNetwork = new BRadioButton(bounds, "useNetwork", "Use network password",
		new BMessage(kMsgPasswordTypeChanged), B_FOLLOW_NONE);
	topView->AddChild(fUseNetwork);
	fUseNetwork->ResizeToPreferred();
	fUseNetwork->MoveBy(10.0, 0.0);

	bounds.OffsetBy(0.0, fUseNetwork->Bounds().Height());
	BBox *customBox = new BBox(bounds, "customBox", B_FOLLOW_NONE);
	topView->AddChild(customBox);

	fUseCustom = new BRadioButton(BRect(), "useCustom", "Use custom password",
		new BMessage(kMsgPasswordTypeChanged), B_FOLLOW_NONE);
	customBox->SetLabel(fUseCustom);
	fUseCustom->ResizeToPreferred();

	fPasswordControl = new BTextControl(bounds, "passwordControl", "Password:"******"confirmControl", 
		"Confirm password:"******"VeryLongPasswordPossible", B_FOLLOW_NONE);
	customBox->AddChild(fConfirmControl);
	fConfirmControl->TextView()->HideTyping(true);
	fConfirmControl->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT);

	float width, height;
	fConfirmControl->GetPreferredSize(&width, &height);
	fPasswordControl->ResizeTo(width, height);
	fConfirmControl->ResizeTo(width, height);
	
	float divider = be_plain_font->StringWidth("Confirm password:"******"done", "Done", new BMessage(kMsgDone));
	topView->AddChild(button);
	button->ResizeToPreferred();

	BRect frame = customBox->Frame();
	button->MoveTo(frame.right - button->Bounds().Width(), frame.bottom + 10.0);

	frame = button->Frame();
	button->MakeDefault(true);

	button = new BButton(frame, "cancel", "Cancel", new BMessage(B_CANCEL));
	topView->AddChild(button);
	button->ResizeToPreferred();
	button->MoveBy(-(button->Bounds().Width() + 10.0), 0.0);

	ResizeTo(customBox->Frame().right + 10.0, frame.bottom + 10.0);
}
Exemplo n.º 12
0
// SavePanel class
SavePanel::SavePanel(const char* name,
					 BMessenger* target,
					 entry_ref* startDirectory,
					 uint32 nodeFlavors,
					 bool allowMultipleSelection,
					 BMessage* message,
					 BRefFilter* filter,
					 bool modal,
					 bool hideWhenDone)
	: BFilePanel(B_SAVE_PANEL, target, startDirectory,
				 nodeFlavors, allowMultipleSelection,
				 message, filter, modal, hideWhenDone),
	  BHandler(name),
	  fConfigWindow(NULL),
	  fFormatM(NULL),
	  fExportMode(EXPORT_MODE_ICON_RDEF)
{
	BWindow* window = Window();
	if (!window || !window->Lock())
		return;

	window->SetTitle(B_TRANSLATE("Save image"));

	// add this instance as BHandler to the window's looper
	window->AddHandler(this);
	
	// find a couple of important views and mess with their layout
	BView* background = Window()->ChildAt(0);
	BButton* cancel = dynamic_cast<BButton*>(background->FindView("cancel button"));
	BView* textview = background->FindView("text view");
	BScrollBar* hscrollbar = dynamic_cast<BScrollBar*>(background->FindView("HScrollBar"));

	if (!background || !cancel || !textview || !hscrollbar) {
		printf("SavePanel::SavePanel() - couldn't find necessary controls.\n");
		return;
	}

	_BuildMenu();

	BRect rect = textview->Frame();
	rect.top = cancel->Frame().top;
	font_height fh;
	be_plain_font->GetHeight(&fh);
	rect.bottom = rect.top + fh.ascent + fh.descent + 5.0;

	fFormatMF = new BMenuField(rect, "format popup", B_TRANSLATE("Format"),
								fFormatM, true,	
								B_FOLLOW_LEFT | B_FOLLOW_BOTTOM,
								B_WILL_DRAW | B_NAVIGABLE);
	fFormatMF->SetDivider(be_plain_font->StringWidth(
		B_TRANSLATE("Format")) + 7);
	fFormatMF->MenuBar()->ResizeToPreferred();
	fFormatMF->ResizeToPreferred();

	float height = fFormatMF->Bounds().Height() + 8.0;

	// find all the views that are in the way and
	// move up them up the height of the menu field
	BView *poseview = background->FindView("PoseView");
	if (poseview) poseview->ResizeBy(0, -height);
	BButton *insert = (BButton *)background->FindView("default button");
	if (hscrollbar) hscrollbar->MoveBy(0, -height);
	BScrollBar *vscrollbar = (BScrollBar *)background->FindView("VScrollBar");
	if (vscrollbar) vscrollbar->ResizeBy(0, -height);
	BView *countvw = (BView *)background->FindView("CountVw");
	if (countvw) countvw->MoveBy(0, -height);
	textview->MoveBy(0, -height);

#if HAIKU_TARGET_PLATFORM_DANO
	fFormatMF->MoveTo(textview->Frame().left, fFormatMF->Frame().top + 2);
#else
	fFormatMF->MoveTo(textview->Frame().left, fFormatMF->Frame().top);
#endif

	background->AddChild(fFormatMF);

	// Build the "Settings" button relative to the format menu
	rect = cancel->Frame();
	rect.OffsetTo(fFormatMF->Frame().right + 5.0, rect.top);
	fSettingsB = new BButton(rect, "settings", 
							 B_TRANSLATE("Settings"B_UTF8_ELLIPSIS),
							 new BMessage(MSG_SETTINGS),
							 B_FOLLOW_LEFT | B_FOLLOW_BOTTOM,
							 B_WILL_DRAW | B_NAVIGABLE);
	fSettingsB->ResizeToPreferred();
	background->AddChild(fSettingsB);
	fSettingsB->SetTarget(this);

	textview->ResizeTo(fSettingsB->Frame().right - fFormatMF->Frame().left,
					   textview->Frame().Height());

	// Make sure the smallest window won't draw the "Settings" button over anything else
	float minWindowWidth = textview->Bounds().Width()
							+ cancel->Bounds().Width()
							+ (insert ? insert->Bounds().Width() : 0.0)
							+ 90;
	Window()->SetSizeLimits(minWindowWidth, 10000, 250, 10000);
	if (Window()->Bounds().IntegerWidth() + 1 < minWindowWidth)
		Window()->ResizeTo(minWindowWidth, Window()->Bounds().Height());


	window->Unlock();
}
Exemplo n.º 13
0
PageSetupWindow::PageSetupWindow(BMessage *msg, const char *printerName)
	:	BlockingWindow(BRect(0,0,400,220), "Page setup", B_TITLED_WINDOW_LOOK,
 			B_MODAL_APP_WINDOW_FEEL, B_NOT_RESIZABLE | B_NOT_MINIMIZABLE |
 			B_NOT_ZOOMABLE),
	fSetupMsg(msg),
	fPrinterDirName(printerName)
{
	if (printerName)
		SetTitle(BString(printerName).Append(" Page setup").String());

	// load orientation
	if (fSetupMsg->FindInt32("orientation", &fCurrentOrientation) != B_OK)
		fCurrentOrientation = PrinterDriver::PORTRAIT_ORIENTATION;

	// load page rect
	BRect page;
	float width = letter_width;
	float height = letter_height;
	if (fSetupMsg->FindRect("preview:paper_rect", &page) == B_OK) {
		width = page.Width();
		height = page.Height();
	} else {
		page.Set(0, 0, width, height);
	}

	BString label;
	if (fSetupMsg->FindString("preview:paper_size", &label) != B_OK)
		label = "Letter";

	// Load units
	int32 units;
	if (fSetupMsg->FindInt32("units", &units) != B_OK)
		units = kUnitInch;

	// re-calculate the margin from the printable rect in points
	BRect margin = page;
	if (fSetupMsg->FindRect("preview:printable_rect", &margin) == B_OK) {
		margin.top -= page.top;
		margin.left -= page.left;
		margin.right = page.right - margin.right;
		margin.bottom = page.bottom - margin.bottom;
	} else {
		margin.Set(28.34, 28.34, 28.34, 28.34);		// 28.34 dots = 1cm
	}

	BRect bounds(Bounds());
	BBox *panel = new BBox(bounds, "background", B_FOLLOW_ALL,
		B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP, B_PLAIN_BORDER);
	AddChild(panel);

	bounds.InsetBy(10.0, 10.0);
	bounds.right = 230.0;
	bounds.bottom = 160.0;
	fMarginView = new MarginView(bounds, int32(width), int32(height), margin,
		MarginUnit(units));
	panel->AddChild(fMarginView);
	fMarginView->SetResizingMode(B_FOLLOW_NONE);

	BPopUpMenu* m = new BPopUpMenu("Page size");
	m->SetRadioMode(true);

	bounds.OffsetBy(bounds.Width() + 10.0, 5.0);
	float divider = be_plain_font->StringWidth("Orientation: ");
	fPageSizeMenu = new BMenuField(bounds, "page_size", "Page size:", m);
	panel->AddChild(fPageSizeMenu);
	fPageSizeMenu->ResizeToPreferred();
	fPageSizeMenu->SetDivider(divider);
	fPageSizeMenu->Menu()->SetLabelFromMarked(true);

	for (int32 i = 0; pageFormat[i].label != NULL; i++) {
		BMessage* message = new BMessage(PAGE_SIZE_CHANGED);
		message->AddFloat("width", pageFormat[i].width);
		message->AddFloat("height", pageFormat[i].height);
		BMenuItem* item = new BMenuItem(pageFormat[i].label, message);
		m->AddItem(item);

		if (label.Compare(pageFormat[i].label) == 0)
			item->SetMarked(true);
	}

	m = new BPopUpMenu("Orientation");
	m->SetRadioMode(true);

	bounds.OffsetBy(0.0, fPageSizeMenu->Bounds().Height() + 10.0);
	fOrientationMenu = new BMenuField(bounds, "orientation", "Orientation:", m);
	panel->AddChild(fOrientationMenu);
	fOrientationMenu->ResizeToPreferred();
	fOrientationMenu->SetDivider(divider);
	fOrientationMenu->Menu()->SetLabelFromMarked(true);

	for (int32 i = 0; orientation[i].label != NULL; i++) {
	 	BMessage* message = new BMessage(ORIENTATION_CHANGED);
		message->AddInt32("orientation", orientation[i].orientation);
		BMenuItem* item = new BMenuItem(orientation[i].label, message);
		m->AddItem(item);

		if (fCurrentOrientation == orientation[i].orientation)
			item->SetMarked(true);
	}

	float scale0;
	BString scale;
	if (fSetupMsg->FindFloat("scale", &scale0) == B_OK)
		scale << (int)scale0;
	else
		scale = "100";

	bounds.OffsetBy(0.0, fOrientationMenu->Bounds().Height() + 10.0);
	bounds.right -= 30.0;
	fScaleControl = new BTextControl(bounds, "scale", "Scale [%]:",
		scale.String(), NULL);
	panel->AddChild(fScaleControl);
	fScaleControl->ResizeToPreferred();
	fScaleControl->SetDivider(divider);

	for (uint32 i = 0; i < '0'; i++)
		fScaleControl->TextView()->DisallowChar(i);

	for (uint32 i = '9' + 1; i < 255; i++)
		fScaleControl->TextView()->DisallowChar(i);

	fScaleControl->TextView()->SetMaxBytes(3);

	bounds = Bounds();
	bounds.InsetBy(5.0, 0.0);
	bounds.top =
		MAX(fScaleControl->Frame().bottom, fMarginView->Frame().bottom) + 10.0;
	BBox *line = new BBox(BRect(bounds.left, bounds.top, bounds.right,
		bounds.top + 1.0), NULL, B_FOLLOW_LEFT_RIGHT);
	panel->AddChild(line);

	bounds.InsetBy(5.0, 0.0);
	bounds.OffsetBy(0.0, 11.0);
	BButton *cancel = new BButton(bounds, NULL, "Cancel", new BMessage(CANCEL_MSG));
	panel->AddChild(cancel);
	cancel->ResizeToPreferred();

	BButton *ok = new BButton(bounds, NULL, "OK", new BMessage(OK_MSG));
	panel->AddChild(ok, cancel);
	ok->ResizeToPreferred();

	bounds.right = fScaleControl->Frame().right;
	ok->MoveTo(bounds.right - ok->Bounds().Width(), ok->Frame().top);

	bounds = ok->Frame();
	cancel->MoveTo(bounds.left - cancel->Bounds().Width() - 10.0, bounds.top);

	ok->MakeDefault(true);
	ResizeTo(bounds.right + 10.0, bounds.bottom + 10.0);

	BRect winFrame(Frame());
	BRect screenFrame(BScreen().Frame());
	MoveTo((screenFrame.right - winFrame.right) / 2,
		(screenFrame.bottom - winFrame.bottom) / 2);
}
Exemplo n.º 14
0
ExtensionWindow::ExtensionWindow(FileTypesWindow* target, BMimeType& type,
		const char* extension)
	: BWindow(BRect(100, 100, 350, 200), "Extension", B_MODAL_WINDOW_LOOK,
		B_MODAL_SUBSET_WINDOW_FEEL, B_NOT_ZOOMABLE | B_NOT_V_RESIZABLE
			| B_ASYNCHRONOUS_CONTROLS),
	fTarget(target),
	fMimeType(type.Type()),
	fExtension(extension)
{
	BRect rect = Bounds();
	BView* topView = new BView(rect, NULL, B_FOLLOW_ALL, B_WILL_DRAW);
	topView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	AddChild(topView);

	rect.InsetBy(8.0f, 8.0f);
	fExtensionControl = new BTextControl(rect, "extension", "Extension:", extension,
		NULL, B_FOLLOW_LEFT_RIGHT);

	float labelWidth = fExtensionControl->StringWidth(fExtensionControl->Label()) + 2.0f;
	fExtensionControl->SetModificationMessage(new BMessage(kMsgExtensionUpdated));
	fExtensionControl->SetDivider(labelWidth);
	fExtensionControl->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT);

	// filter out invalid characters that can't be part of an extension
	BTextView* textView = fExtensionControl->TextView();
	const char* disallowedCharacters = "/:";
	for (int32 i = 0; disallowedCharacters[i]; i++) {
		textView->DisallowChar(disallowedCharacters[i]);
	}

	float width, height;
	fExtensionControl->GetPreferredSize(&width, &height);
	fExtensionControl->ResizeTo(rect.Width(), height);
	topView->AddChild(fExtensionControl);

	fAcceptButton = new BButton(rect, "add", extension ? "Done" : "Add",
		new BMessage(kMsgAccept), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
	fAcceptButton->ResizeToPreferred();
	fAcceptButton->MoveTo(Bounds().Width() - 8.0f - fAcceptButton->Bounds().Width(),
		Bounds().Height() - 8.0f - fAcceptButton->Bounds().Height());
	fAcceptButton->SetEnabled(false);
	topView->AddChild(fAcceptButton);

	BButton* button = new BButton(rect, "cancel", "Cancel",
		new BMessage(B_QUIT_REQUESTED), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
	button->ResizeToPreferred();
	button->MoveTo(fAcceptButton->Frame().left - 10.0f - button->Bounds().Width(),
		fAcceptButton->Frame().top);
	topView->AddChild(button);

	ResizeTo(labelWidth * 4.0f + 24.0f, fExtensionControl->Bounds().Height()
		+ fAcceptButton->Bounds().Height() + 28.0f);
	SetSizeLimits(button->Bounds().Width() + fAcceptButton->Bounds().Width() + 26.0f,
		32767.0f, Frame().Height(), Frame().Height());

	// omit the leading dot
	if (fExtension.ByteAt(0) == '.')
		fExtension.Remove(0, 1);

	fAcceptButton->MakeDefault(true);
	fExtensionControl->MakeFocus(true);

	target->PlaceSubWindow(this);
	AddToSubset(target);
}
Exemplo n.º 15
0
PageSetupWindow::PageSetupWindow(BMessage *msg, const char *printerName)
	: HWindow(BRect(0,0,400,220), "Page setup", B_TITLED_WINDOW_LOOK,
 		B_MODAL_APP_WINDOW_FEEL, B_NOT_RESIZABLE | B_NOT_MINIMIZABLE |
 		B_NOT_ZOOMABLE),
	 fResult(B_ERROR),
	 fSetupMsg(msg),
	 fAdvancedSettings(*msg),
	 fPrinterDirName(printerName)
{
	fExitSem 	= create_sem(0, "PageSetup");

	if (printerName)
		SetTitle(BString(printerName).Append(" page setup").String());

	if (fSetupMsg->FindInt32("orientation", &fCurrentOrientation) != B_OK)
		fCurrentOrientation = PrinterDriver::PORTRAIT_ORIENTATION;

	BRect page;
	float width = letter_width;
	float height = letter_height;
	if (fSetupMsg->FindRect("paper_rect", &page) == B_OK) {
		width = page.Width();
		height = page.Height();
	} else {
		page.Set(0, 0, width, height);
	}

	BString label;
	if (fSetupMsg->FindString("pdf_paper_size", &label) != B_OK)
		label = "Letter";

	int32 compression;
	fSetupMsg->FindInt32("pdf_compression", &compression);

	int32 units;
	if (fSetupMsg->FindInt32("units", &units) != B_OK)
		units = kUnitInch;

	// re-calculate the margin from the printable rect in points
	BRect margin = page;
	if (fSetupMsg->FindRect("printable_rect", &margin) == B_OK) {
		margin.top -= page.top;
		margin.left -= page.left;
		margin.right = page.right - margin.right;
		margin.bottom = page.bottom - margin.bottom;
	} else {
		margin.Set(28.34, 28.34, 28.34, 28.34);		// 28.34 dots = 1cm
	}

	BString setting_value;
	if (fSetupMsg->FindString("pdf_compatibility", &setting_value) != B_OK)
		setting_value = "1.3";

	// Load font settings
	fFonts = new Fonts();
	fFonts->CollectFonts();
	BMessage fonts;
	if (fSetupMsg->FindMessage("fonts", &fonts) == B_OK)
		fFonts->SetTo(&fonts);

	// add a *dialog* background
	BRect bounds(Bounds());
	BBox *panel = new BBox(bounds, "background", B_FOLLOW_ALL,
		B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP, B_PLAIN_BORDER);
	AddChild(panel);

	bounds.InsetBy(10.0, 10.0);
	bounds.right = 230.0;
	bounds.bottom = 160.0;
	fMarginView = new MarginView(bounds, int32(width), int32(height), margin,
		MarginUnit(units));
	panel->AddChild(fMarginView);
	fMarginView->SetResizingMode(B_FOLLOW_NONE);

	BPopUpMenu* m = new BPopUpMenu("Page size");
	m->SetRadioMode(true);

	bounds.OffsetBy(bounds.Width() + 10.0, 5.0);
	float divider = be_plain_font->StringWidth("PDF compatibility: ");
	fPageSizeMenu = new BMenuField(bounds, "page_size", "Page size:", m);
	panel->AddChild(fPageSizeMenu);
	fPageSizeMenu->ResizeToPreferred();
	fPageSizeMenu->SetDivider(divider);
	fPageSizeMenu->Menu()->SetLabelFromMarked(true);

	for (int32 i = 0; pageFormat[i].label != NULL; i++) {
		BMessage* message = new BMessage(PAGE_SIZE_CHANGED);
		message->AddFloat("width", pageFormat[i].width);
		message->AddFloat("height", pageFormat[i].height);
		BMenuItem* item = new BMenuItem(pageFormat[i].label, message);
		m->AddItem(item);

		if (label.Compare(pageFormat[i].label) == 0)
			item->SetMarked(true);
	}

	m = new BPopUpMenu("Orientation");
	m->SetRadioMode(true);

	bounds.OffsetBy(0.0, fPageSizeMenu->Bounds().Height() + 10.0);
	fOrientationMenu = new BMenuField(bounds, "orientation", "Orientation:", m);
	panel->AddChild(fOrientationMenu);
	fOrientationMenu->ResizeToPreferred();
	fOrientationMenu->SetDivider(divider);
	fOrientationMenu->Menu()->SetLabelFromMarked(true);

	for (int32 i = 0; orientation[i].label != NULL; i++) {
	 	BMessage* message = new BMessage(ORIENTATION_CHANGED);
		message->AddInt32("orientation", orientation[i].orientation);
		BMenuItem* item = new BMenuItem(orientation[i].label, message);
		m->AddItem(item);

		if (fCurrentOrientation == orientation[i].orientation)
			item->SetMarked(true);
	}

	m = new BPopUpMenu("PDF compatibility");
	m->SetRadioMode(true);

	bounds.OffsetBy(0.0, fOrientationMenu->Bounds().Height() + 10.0);
	fPDFCompatibilityMenu = new BMenuField(bounds, "pdf_compatibility",
		"PDF compatibility:", m);
	panel->AddChild(fPDFCompatibilityMenu);
	fPDFCompatibilityMenu->ResizeToPreferred();
	fPDFCompatibilityMenu->SetDivider(divider);
	fPDFCompatibilityMenu->Menu()->SetLabelFromMarked(true);

	for (int32 i = 0; pdf_compatibility[i] != NULL; i++) {
		BMenuItem* item = new BMenuItem(pdf_compatibility[i], NULL);
		m->AddItem(item);
		if (setting_value == pdf_compatibility[i])
			item->SetMarked(true);
	}

	bounds.OffsetBy(0.0, fPDFCompatibilityMenu->Bounds().Height() + 10.0);
	fPDFCompressionSlider = new BSlider(bounds, "pdf_compression",
		"Compression:", NULL, 0, 9);
	panel->AddChild(fPDFCompressionSlider);
	fPDFCompressionSlider->SetLimitLabels("None", "Best");
	fPDFCompressionSlider->SetHashMarks(B_HASH_MARKS_BOTTOM);
	fPDFCompressionSlider->SetValue(compression);
	fPDFCompressionSlider->ResizeToPreferred();

	bounds = Bounds();
	bounds.InsetBy(5.0, 0.0);
	bounds.top = MAX(fPDFCompressionSlider->Frame().bottom,
		fMarginView->Frame().bottom) + 10.0;
	BBox *line = new BBox(BRect(bounds.left, bounds.top, bounds.right,
		bounds.top + 1.0), NULL, B_FOLLOW_LEFT_RIGHT);
	panel->AddChild(line);

	bounds.InsetBy(5.0, 0.0);
	bounds.OffsetBy(0.0, 11.0);
	BButton *cancel = new BButton(bounds, NULL, "Cancel", new BMessage(CANCEL_MSG));
	panel->AddChild(cancel);
	cancel->ResizeToPreferred();

	BButton *ok = new BButton(bounds, NULL, "OK", new BMessage(OK_MSG));
	panel->AddChild(ok, cancel);
	ok->ResizeToPreferred();

	bounds.right = fPDFCompressionSlider->Frame().right;
	ok->MoveTo(bounds.right - ok->Bounds().Width(), ok->Frame().top);

	bounds = ok->Frame();
	cancel->MoveTo(bounds.left - cancel->Bounds().Width() - 10.0, bounds.top);

	ok->MakeDefault(true);
	ResizeTo(bounds.right + 10.0, bounds.bottom + 10.0);

	BButton *button = new BButton(bounds, NULL, "Fonts" B_UTF8_ELLIPSIS,
		new BMessage(FONTS_MSG));
	panel->AddChild(button);
	button->ResizeToPreferred();
	button->MoveTo(fMarginView->Frame().left, bounds.top);

	bounds = button->Frame();
	button = new BButton(bounds, NULL, "Advanced" B_UTF8_ELLIPSIS,
		new BMessage(ADVANCED_MSG));
	panel->AddChild(button);
	button->ResizeToPreferred();
	button->MoveTo(bounds.right + 10, bounds.top);

	BRect winFrame(Frame());
	BRect screenFrame(BScreen().Frame());
	MoveTo((screenFrame.right - winFrame.right) / 2,
		(screenFrame.bottom - winFrame.bottom) / 2);
}