当前位置: 首页>>代码示例>>C++>>正文


C++ BButton::ResizeToPreferred方法代码示例

本文整理汇总了C++中BButton::ResizeToPreferred方法的典型用法代码示例。如果您正苦于以下问题:C++ BButton::ResizeToPreferred方法的具体用法?C++ BButton::ResizeToPreferred怎么用?C++ BButton::ResizeToPreferred使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BButton的用法示例。


在下文中一共展示了BButton::ResizeToPreferred方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: BView

TView::TView(BRect frame, const char *name, uint32 resizingMode, uint32 flags)
		: BView(frame, name, resizingMode, flags)
{
	BFont font;

	BButton *btn = new BButton(BRect(10, 10, 150, 50), NULL, "Hello World", new BMessage(BTN_HELLO_WORLD_EN_MSG));
	btn->ForceFontAliasing(true);
	if (font.SetFamilyAndStyle("SimSun", "Regular") == B_OK) btn->SetFont(&font, B_FONT_FAMILY_AND_STYLE);
	btn->SetFontSize(20);
	AddChild(btn);

	btn = new BButton(BRect(10, 100, 50, 120), NULL, "Ciao Mondo", new BMessage(BTN_HELLO_WORLD_IT_MSG));
	btn->ForceFontAliasing(true);
	if (font.SetFamilyAndStyle("SimHei", "Regular") == B_OK) {
		btn->SetFont(&font, B_FONT_FAMILY_AND_STYLE);
		btn->SetFontSize(24);
	}
	AddChild(btn);
	btn->ResizeToPreferred();

	btn = new BButton(BRect(10, 150, 40, 180), NULL, "Disabled", new BMessage(BTN_NOT_ENABLED_MSG));
	btn->SetEnabled(false);
	AddChild(btn);
	btn->ResizeToPreferred();
}
开发者ID:D-os,项目名称:BeFree,代码行数:25,代码来源:button-test.cpp

示例2: bounds

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);
}
开发者ID:mariuz,项目名称:haiku,代码行数:57,代码来源:DocInfoWindow.cpp

示例3: rect

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);
}
开发者ID:mmanley,项目名称:Antares,代码行数:51,代码来源:AlertView.cpp

示例4: BWindow

TWindow::TWindow(BRect frame, const char *title, window_type type, uint32 flags, uint32 workspace)
		: BWindow(frame, title, type, flags, workspace), quited(false)
{
//	SetBackgroundColor(0, 255, 255);

	BButton *btn = new BButton(BRect(10, 200, 40, 230), NULL, "Focus Button", new BMessage(BTN_FOCUS_MSG));
	AddChild(btn);
	btn->ResizeToPreferred();
	btn->MakeFocus(true);

	BView *view = new TView(frame.OffsetToCopy(B_ORIGIN), NULL, B_FOLLOW_ALL, B_WILL_DRAW |B_FRAME_EVENTS);
	AddChild(view);
}
开发者ID:D-os,项目名称:BeFree,代码行数:13,代码来源:button-test.cpp

示例5: BMessage

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);
}
开发者ID:HaikuArchives,项目名称:Paladin,代码行数:49,代码来源:StringInputWindow.cpp

示例6: bounds

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:") + 5.0);

	BButton* button = new BButton(BRect(), "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);
}
开发者ID:mariuz,项目名称:haiku,代码行数:45,代码来源:PasswordWindow.cpp

示例7: BMessage

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());
//.........这里部分代码省略.........
开发者ID:mmanley,项目名称:Antares,代码行数:101,代码来源:AttributeWindow.cpp

示例8: windowRect

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));
}
开发者ID:,项目名称:,代码行数:86,代码来源:

示例9: bounds

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);
//.........这里部分代码省略.........
开发者ID:mmanley,项目名称:Antares,代码行数:101,代码来源:JobSetupWindow.cpp

示例10: BWindow

//--------------------------------------------------------------------
PrefWindow::PrefWindow(BWindow *main) 
	: BWindow(BRect(0, 0, PREF_W-1, PREF_H-1), StringsRsrc[STR_PREFERENCES_TITLE], 
              B_FLOATING_WINDOW_LOOK, B_MODAL_APP_WINDOW_FEEL, 0, B_ALL_WORKSPACES)
{
	mainWin = main;

	// Set windows attributes
	MoveTo(28, 80);
	SetSizeLimits(300., 10000., 200., 10000.);
	SetFlags(B_NOT_RESIZABLE | B_NOT_ZOOMABLE);

	// Create background view
	BView *view = new BView(BRect(0, 0, PREF_W-1, PREF_H-1), "", B_FOLLOW_ALL_SIDES, B_WILL_DRAW | B_FRAME_EVENTS);
	AddChild(view);
	view->SetViewColor(222, 222, 222);

	BBox *box;
	box = new BBox (BRect(10., 10., 300., 100.), "", B_FOLLOW_ALL_SIDES, B_WILL_DRAW|B_FULL_UPDATE_ON_RESIZE);
	box->SetLabel(StringsRsrc[STR_INFOBAR_COLOR]);
	view->AddChild(box);

	colSelector = new BColorControl(BPoint(10., 20.), B_CELLS_32x8, 2., "", new BMessage(MSG_PREF_COLOR), false);
	box->AddChild(colSelector);
	colSelector->SetValue(((InterApp*)be_app)->prefs->GetInfobarColor());


	box = new BBox (BRect(10., 110., 300., 175.), "", B_FOLLOW_ALL_SIDES, B_WILL_DRAW|B_FULL_UPDATE_ON_RESIZE);
	box->SetLabel(StringsRsrc[STR_PAN_MODE]);
	view->AddChild(box);

	radFollow = new BRadioButton(BRect(10., 15., 100., 35.), "", StringsRsrc[STR_PICTURE_FOLLOW_MOUSE], NULL);
	radFollow->ResizeToPreferred();
	box->AddChild(radFollow);
	radFlee = new BRadioButton(BRect(10., 35., 100., 55.), "", StringsRsrc[STR_PICTURE_FLEE_MOUSE], NULL);
	radFlee->ResizeToPreferred();
	box->AddChild(radFlee);

	if (((InterApp*)be_app)->prefs->GetMouseMode() == PIC_FOLLOW_MOUSE)
		radFollow->SetValue(1);
	else
		radFlee->SetValue(1);

	// Language
	box = new BBox(BRect(10., 185., 300., 230.), "", B_FOLLOW_ALL_SIDES, B_WILL_DRAW|B_FULL_UPDATE_ON_RESIZE);
	box->SetLabel(StringsRsrc[STR_CHOOSE_LANGUAGE]);
	view->AddChild(box);
	
	BPopUpMenu* menu = new BPopUpMenu("languages menu");
	BMenuItem* item;

	item = new BMenuItem("[BR] Português-Brasileiro", NULL);
	menu->AddItem(item);
	if (((InterApp*)be_app)->prefs->GetLanguage() == PORTUGUES)
		item->SetMarked(true);
		
	item = new BMenuItem("[DE] Deutsch", NULL);
	menu->AddItem(item);
	if (((InterApp*)be_app)->prefs->GetLanguage() == GERMAN)
		item->SetMarked(true);

	item = new BMenuItem("[EN] English", NULL);
	menu->AddItem(item);
	if (((InterApp*)be_app)->prefs->GetLanguage() == ENGLISH)
		item->SetMarked(true);

	item = new BMenuItem("[ES] Spanish/Castellano", NULL);
	menu->AddItem(item);
	if (((InterApp*)be_app)->prefs->GetLanguage() == SPANISH)
		item->SetMarked(true);
		
	item = new BMenuItem("[EU] Euskera/Basque", NULL);
	menu->AddItem(item);
	if (((InterApp*)be_app)->prefs->GetLanguage() == BASQUE)
		item->SetMarked(true);
	
	item = new BMenuItem("[FR] Français", NULL);
	menu->AddItem(item);
	if (((InterApp*)be_app)->prefs->GetLanguage() == FRENCH)
		item->SetMarked(true);
		
	item = new BMenuItem("[IT] Italiano", NULL);
	menu->AddItem(item);
	if (((InterApp*)be_app)->prefs->GetLanguage() == ITALIAN)
		item->SetMarked(true);
		
	item = new BMenuItem("[RU] Русский", NULL);
	menu->AddItem(item);
	if (((InterApp*)be_app)->prefs->GetLanguage() == RUSSIAN)
		item->SetMarked(true);
				
	languageMenu = new BMenuField(BRect(10,15,150,35),"","",menu);
	languageMenu->SetDivider(0);
	box->AddChild(languageMenu);	

	BButton *but;
	but = new BButton(BRect(145., 240., 150., 260.), "", StringsRsrc[STR_OK], new BMessage(MSG_PREF_OK));
	but->ResizeToPreferred();
	but->MakeDefault(true);
	view->AddChild(but);
//.........这里部分代码省略.........
开发者ID:HaikuArchives,项目名称:Butterfly,代码行数:101,代码来源:PrefWindow.cpp

示例11: BMessage

void OptionsPanel :: AttachedToWindow( void )
{
	SetViewColor( ui_color(B_PANEL_BACKGROUND_COLOR) ) ;
	
	BRect fr ;
	if( Parent() )
		fr = Parent()->Frame() ;
	else
		fr = Window()->Frame() ;
	
	fr.top = Frame().top ;
	fr.right = fr.Width() ;
	fr.left = 0 ;  
	fr.bottom = fr.top + 5 ; // Set Later
			
	MoveTo( fr.left, fr.top ) ;
	ResizeTo( fr.Width(), fr.Height() ) ;

	font_height fh ;
	GetFontHeight( &fh ) ;
	
	BRect r ;
	
	r.top = 5 ;
	r.left = fr.Width() * 2/3 ;

	r.right   = r.left + ( r.Height() * 2 ) + 1  ; 
	r.bottom  = r.top + 10 ;
	
	BButton * addButton = new
					BButton( r, "Add", "+",
							  new BMessage( Messages::AddPanel ) ,
							  B_FOLLOW_RIGHT | B_FOLLOW_TOP ) ;
	AddChild( addButton ) ;

	float h , w ;
	addButton->GetPreferredSize( &h, &w ) ;
	if( h > w )
		h = w ;
	else
		w = h ;
	addButton->ResizeTo( w, h ) ;
	
	r.left += ( w + 4 ) ;
	r.right += ( w + 4 ) ; 
	BButton * rmButton = new BButton( r, "Remove", "-",
							  new BMessage( Messages::RemovePanel ) ,
							  B_FOLLOW_RIGHT | B_FOLLOW_TOP ) ;
	AddChild( rmButton ) ;
	rmButton->ResizeTo( w, h ) ;

	r.left = 10 ;
	r.top = addButton->Frame().bottom + 2 ;

	r.right   = r.left + 10 ; 
	r.bottom  = r.top + 10 ;
	
	fpMaxDepthCheck = new BCheckBox( r, "depth_check", kMaxDepthString ,
							NULL, B_FOLLOW_LEFT | B_FOLLOW_TOP ) ;
	AddChild( fpMaxDepthCheck ) ;
	fpMaxDepthCheck->ResizeToPreferred() ;

	r = fpMaxDepthCheck->Frame() ;
 	float centre = r.top + r.Height()/2 ;

	r.left   = r.right + 5 ;
	r.top    = centre - (fh.ascent + fh.descent + fh.leading) * 3/4 ;
	r.bottom = centre + (fh.ascent + fh.descent + fh.leading) * 3/4 ;
	r.right  = r.left + StringWidth( "xx37xx" ) ;

	fpMaxDepthEdit = new EditBox( r, "depth_edit", B_FOLLOW_LEFT | B_FOLLOW_TOP ) ;
	AddChild( fpMaxDepthEdit ) ;

	r.top    = r.bottom + 7 ;
	r.bottom = r.top + 20 ;
	r.left   = 10 ;
	r.right  = r.left + 50 ;
	
	BButton * settingsButton = new BButton( r, "settings", "Settings" B_UTF8_ELLIPSIS,
								new BMessage( Messages::Settings ) ,
								B_FOLLOW_LEFT | B_FOLLOW_TOP ) ;
	AddChild( settingsButton ) ;
	settingsButton->ResizeToPreferred() ;
	settingsButton->SetTarget( Window() ) ;
		
	r.right = fr.Width() - 25 ;
	r.left  = r.right - 50 ;

	fpFindButton = new BButton( r, "go", "Find",
							  new BMessage( Messages::StartFind ) ,
							  B_FOLLOW_RIGHT | B_FOLLOW_TOP ) ;
	AddChild( fpFindButton ) ;
	fpFindButton->ResizeToPreferred() ;
	r = fpFindButton->Frame() ;
	fpFindButton->MoveTo( fr.Width() - 20 - r.Width(), r.top ) ;
	fpFindButton->SetTarget( Window() ) ;
	fpFindButton->MakeDefault(true) ;

	r = fpFindButton->Frame() ;
	r.bottom = r.top - 3 ;
//.........这里部分代码省略.........
开发者ID:HaikuArchives,项目名称:TraX,代码行数:101,代码来源:OptionsPanel.cpp

示例12: BMessage

// constructor
ColorPickerPanel::ColorPickerPanel(BRect frame, rgb_color color,
                                   selected_color_mode mode,
                                   BWindow* window,
                                   BMessage* message, BHandler* target)
    : Panel(frame, "Pick Color",
            B_FLOATING_WINDOW_LOOK, B_FLOATING_SUBSET_WINDOW_FEEL,
            B_ASYNCHRONOUS_CONTROLS |
            B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_NOT_CLOSABLE),
      fWindow(window),
      fMessage(message),
      fTarget(target)
{
    SetTitle(B_TRANSLATE("Pick a color"));

    fColorPickerView = new ColorPickerView("color picker", color, mode);

#if LIB_LAYOUT
    MButton* defaultButton = new MButton(B_TRANSLATE("OK"),
                                         new BMessage(MSG_DONE), this);

    // interface layout
    BView* topView = new VGroup (
        fColorPickerView,
        new MBorder (
            M_RAISED_BORDER, 5, "buttons",
            new HGroup (
                new Space(minimax(0.0, 0.0, 10000.0, 10000.0, 5.0)),
                new MButton(B_TRANSLATE("Cancel"), new BMessage(MSG_CANCEL),
                            this),
                new Space(minimax(5.0, 0.0, 10.0, 10000.0, 1.0)),
                defaultButton,
                new Space(minimax(2.0, 0.0, 2.0, 10000.0, 0.0)),
                0
            )
        ),
        0
    );
#else // LIB_LAYOUT
    frame = BRect(0, 0, 40, 15);
    BButton* defaultButton = new BButton(frame, "ok button",
                                         B_TRANSLATE("OK"), new BMessage(MSG_DONE),
                                         B_FOLLOW_RIGHT | B_FOLLOW_TOP);
    defaultButton->ResizeToPreferred();
    BButton* cancelButton = new BButton(frame, "cancel button",
                                        B_TRANSLATE("Cancel"), new BMessage(MSG_CANCEL),
                                        B_FOLLOW_RIGHT | B_FOLLOW_TOP);
    cancelButton->ResizeToPreferred();

    frame.bottom = frame.top + (defaultButton->Frame().Height() + 16);
    frame.right = frame.left + fColorPickerView->Frame().Width();
    BBox* buttonBox = new BBox(frame, "button group",
                               B_FOLLOW_LEFT_RIGHT | B_FOLLOW_BOTTOM,
                               B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP,
                               B_PLAIN_BORDER);

    ResizeTo(frame.Width(),
             fColorPickerView->Frame().Height() + frame.Height() + 1);

    frame = Bounds();
    BView* topView = new BView(frame, "bg", B_FOLLOW_ALL, 0);
    topView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));

    buttonBox->MoveTo(frame.left, frame.bottom - buttonBox->Frame().Height());

    defaultButton->MoveTo(frame.right - defaultButton->Frame().Width() - 10,
                          frame.top + 8);
    buttonBox->AddChild(defaultButton);

    cancelButton->MoveTo(defaultButton->Frame().left - 10
                         - cancelButton->Frame().Width(),
                         frame.top + 8);
    buttonBox->AddChild(cancelButton);

    topView->AddChild(fColorPickerView);
    topView->AddChild(buttonBox);
#endif // LIB_LAYOUT

    SetDefaultButton(defaultButton);

    if (fWindow)
        AddToSubset(fWindow);
    else
        SetFeel(B_FLOATING_APP_WINDOW_FEEL);

    AddChild(topView);
}
开发者ID:yunxiaoxiao110,项目名称:haiku,代码行数:87,代码来源:ColorPickerPanel.cpp

示例13: BMessage

// --------------------------------------------------
JobSetupWindow::JobSetupWindow(BMessage *msg, const char * printerName)
	:	HWindow(BRect(0, 0, 320, 160), "Job Setup", B_TITLED_WINDOW_LOOK,
 			B_MODAL_APP_WINDOW_FEEL, B_NOT_RESIZABLE | B_NOT_MINIMIZABLE |
 			B_NOT_ZOOMABLE)
{
	fSetupMsg	= msg;
	fExitSem 	= create_sem(0, "JobSetup");
	fResult 	= B_ERROR;
	
	if (printerName) {
		BString	title;
		title << printerName << " Job Setup";
		SetTitle(title.String());
		fPrinterName = printerName;
	}
	
	// ---- Ok, build a default job setup user interface
	BRect			r;
	BBox			*panel;
	BBox			*line;
	BButton	 		*ok;
	BButton			*cancel;
	BStringView		*sv;
	float			x, y, w, h;
	float			indent;
	int32           copies;
	int32           firstPage;
	int32           lastPage;
	bool            allPages;
	char            buffer[80];
	
	// PrinterDriver ensures that property exists
	fSetupMsg->FindInt32("copies",     &copies);
	fSetupMsg->FindInt32("first_page", &firstPage);
	fSetupMsg->FindInt32("last_page",  &lastPage);
	BMessage doc_info;
	if (B_OK != fSetupMsg->FindMessage("doc_info", &doc_info)) {
		// default fields
		doc_info.AddString("Author", "");
		doc_info.AddString("Subject", "");
		doc_info.AddString("Keywords", "");
		fSetupMsg->AddMessage("doc_info", &doc_info);
	}
	AddFields(&fDocInfo, fSetupMsg, NULL, includeKeys);
	
	allPages = firstPage == 1 && lastPage == MAX_INT32;

	r = Bounds();

	// add a *dialog* background
	panel = new BBox(r, "top_panel", B_FOLLOW_ALL, 
		B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP,
		B_PLAIN_BORDER);

	const int kMargin = 6;

	//const char *kCopiesLabel				= "Copies:";
	const char *kCopiesLabelExtraSpace		= "Copies:##";
	const char *kPagesRangeLabel			= "Pages:";
	const char *kAllPagesLabel				= "All";
	const char *kPagesRangeSelectionLabel	= "";
	const char *kFromLabel					= "From:";
	const char *kFromLabelExtraSpace		= "From:##";
	const char *kToLabel					= "To:";
	const char *kToLabelExtraSpace			= "To:##";

	r = panel->Bounds();

	x = r.left + kMargin;
	y = r.top + kMargin;
	
	
	// add a "copies" input field

/* Simon: temporarily removed this code
	sprintf(buffer, "%d", (int)copies);
	fCopies = new BTextControl(BRect(x, y, x+100, y+20), "copies", kCopiesLabel,
								buffer, new BMessage(NB_COPIES_MSG));
	fCopies->SetAlignment(B_ALIGN_LEFT, B_ALIGN_RIGHT);
	fCopies->ResizeToPreferred();
	fCopies->GetPreferredSize(&w, &h);
	panel->AddChild(fCopies);
	
	y += h + kMargin;	// "new line"
*/
	// add a "pages" label
	sv = new BStringView(BRect(x, y, x+100, y+20), "pages_range", kPagesRangeLabel);
	panel->AddChild(sv);
	sv->ResizeToPreferred();
	sv->GetPreferredSize(&w, &h);

	// align "copies" textcontrol field on the "allPages" radiobutton bellow...
	indent = be_plain_font->StringWidth(kCopiesLabelExtraSpace);
	w += kMargin;
	if ( w > indent )
		indent = w;
	// fCopies->SetDivider(indent);

	x += indent;
//.........这里部分代码省略.........
开发者ID:mariuz,项目名称:haiku,代码行数:101,代码来源:JobSetupWindow.cpp

示例14: BMessage

// --------------------------------------------------------------
NetworkSetupWindow::NetworkSetupWindow(const char *title)
	:
	BWindow(BRect(100, 100, 600, 600), title, B_TITLED_WINDOW,
		B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS)
{
	BMenu 		*show_menu;
	BMenu		*profiles_menu;
	BMenuField 	*menu_field;
	BBox 		*top_box, *bottom_box, *line;	// *group
	BButton		*button;
	BCheckBox 	*check;
	BRect		r;
	float		x, w, h;
	float		size, min_size = 360;

	// TODO: cleanup this mess!
	show_menu = new BPopUpMenu("<please select me!>");
	_BuildShowMenu(show_menu, SHOW_MSG);
	
#define H_MARGIN	10
#define V_MARGIN	10
#define SMALL_MARGIN	3

	// Resize the window to minimal width
	ResizeTo(fMinAddonViewRect.Width() + 2 * H_MARGIN, Bounds().Height());

	top_box = new BBox(Bounds(), NULL, B_FOLLOW_NONE,
						B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP,
						B_PLAIN_BORDER);
	AddChild(top_box); 

	r = top_box->Bounds();
	r.InsetBy(H_MARGIN, V_MARGIN);

	// ---- Profiles section
	profiles_menu = new BPopUpMenu("<none>");
	menu_field = new BMenuField(r, "profiles_menu", PROFILE_LABEL, 
		profiles_menu);

	menu_field->SetFont(be_bold_font);
	menu_field->SetDivider(be_bold_font->StringWidth(PROFILE_LABEL "#"));
	top_box->AddChild(menu_field);
	menu_field->ResizeToPreferred();
	menu_field->GetPreferredSize(&w, &h);

	size = w;

	button = new BButton(r, "manage_profiles", MANAGE_PROFILES_LABEL,
					new BMessage(MANAGE_PROFILES_MSG),
					B_FOLLOW_TOP | B_FOLLOW_RIGHT);
	button->GetPreferredSize(&w, &h);
	button->ResizeToPreferred();
	button->MoveTo(r.right - w, r.top);
	top_box->AddChild(button);
	
	size += SMALL_MARGIN + w;
	
	min_size = max_c(min_size, (H_MARGIN + size + H_MARGIN));
	
	r.top += h + V_MARGIN;

	// ---- Separator line between Profiles section and Settings section
	line = new BBox(BRect(r.left, r.top, r.right, r.top + 1), NULL,
						 B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP );
	top_box->AddChild(line);

	_BuildProfilesMenu(profiles_menu, SELECT_PROFILE_MSG);

	r.top += 2 + V_MARGIN;

	// ---- Settings section

	// Make the show popup field half the whole width and centered
	menu_field = new BMenuField(r, "show_menu", SHOW_LABEL, show_menu);
	menu_field->SetFont(be_bold_font);
	menu_field->SetDivider(be_bold_font->StringWidth(SHOW_LABEL "#"));
	top_box->AddChild(menu_field);

	menu_field->ResizeToPreferred();
	menu_field->GetPreferredSize(&w, &h);
	r.top += h+1 + V_MARGIN;
	
	min_size = max_c(min_size, (H_MARGIN + w + H_MARGIN));
	

	r = fMinAddonViewRect.OffsetByCopy(H_MARGIN, r.top);
	fPanel = new BBox(r, "showview_box", B_FOLLOW_NONE,
						B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP,
						B_PLAIN_BORDER);
	top_box->AddChild(fPanel);
	top_box->ResizeTo(Bounds().Width(), r.bottom + 1 + V_MARGIN);

	// ---- Bottom globals buttons section
	r = Bounds();
	r.top = top_box->Frame().bottom + 1;
	bottom_box = new BBox(r, NULL, B_FOLLOW_NONE,
						B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP,
						B_PLAIN_BORDER);
	AddChild(bottom_box); 
//.........这里部分代码省略.........
开发者ID:mmanley,项目名称:Antares,代码行数:101,代码来源:NetworkSetupWindow.cpp

示例15: bounds

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);
//.........这里部分代码省略.........
开发者ID:mmanley,项目名称:Antares,代码行数:101,代码来源:PageSetupWindow.cpp


注:本文中的BButton::ResizeToPreferred方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。