本文整理汇总了C++中BButton::Frame方法的典型用法代码示例。如果您正苦于以下问题:C++ BButton::Frame方法的具体用法?C++ BButton::Frame怎么用?C++ BButton::Frame使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BButton
的用法示例。
在下文中一共展示了BButton::Frame方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
示例2: 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);
}
示例3: 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);
}
示例4: 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);
}
示例5: BMessage
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);
}
示例6: BMessage
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);
//.........这里部分代码省略.........
示例7: 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);
//.........这里部分代码省略.........
示例8: bounds
//.........这里部分代码省略.........
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);
}
示例9: BMessage
// 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());
//.........这里部分代码省略.........
示例10: msgr
ProjectSettingsWindow::ProjectSettingsWindow(BRect frame, Project *proj)
: DWindow(frame,TR("Project Settings"),B_TITLED_WINDOW,
B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_NOT_H_RESIZABLE),
fProject(proj),
fDirty(false)
{
if (!fProject)
debugger("Bad project given to Project Settings window");
fRefFilter = new TypedRefFilter(NULL,B_DIRECTORY_NODE);
BMessenger msgr(this);
entry_ref projfolder_ref;
BEntry(fProject->GetPath().GetFolder()).GetRef(&projfolder_ref);
fFilePanel = new BFilePanel(B_OPEN_PANEL,&msgr,&projfolder_ref,B_DIRECTORY_NODE,
true, new BMessage(M_ADD_PATH),fRefFilter);
fAutolock = new BAutolock(fProject);
AddCommonFilter(new EscapeCancelFilter());
BView *top = GetBackgroundView();
BRect r(Bounds());
fTabView = new BTabView(r,"tabview");
top->AddChild(fTabView);
r.InsetBy(5,5);
r.bottom -= fTabView->TabHeight();
BRect bounds = r.OffsetToCopy(0,0);
fGeneralView = new BView(r,TR("General"),B_FOLLOW_ALL,B_WILL_DRAW);
fGeneralView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
fTabView->AddTab(fGeneralView);
r.right -= 10.0;
fTargetText = new AutoTextControl(r,"targetname",TR("Target Name:"),
fProject->GetTargetName(),
new BMessage(M_TARGET_NAME_CHANGED),
B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
fGeneralView->AddChild(fTargetText);
float pwidth, pheight;
fTargetText->GetPreferredSize(&pwidth, &pheight);
fTargetText->ResizeTo(r.Width(),pheight);
r.bottom = r.top + pheight;
fTargetText->SetDivider(fTargetText->StringWidth(TR("Target Name:")) + 5.0);
r = fTargetText->Frame();
r.OffsetBy(0,r.Height() + 10.0);
BMenu *menu = new BMenu(TR("Target Type"));
menu->AddItem(new BMenuItem(TR("Application"),new BMessage(M_SET_TARGET_TYPE)));
menu->AddItem(new BMenuItem(TR("Shared Library"),new BMessage(M_SET_TARGET_TYPE)));
menu->AddItem(new BMenuItem(TR("Static Library"),new BMessage(M_SET_TARGET_TYPE)));
menu->AddItem(new BMenuItem(TR("Device Driver"),new BMessage(M_SET_TARGET_TYPE)));
r.right = (bounds.right - 5.0) / 2.0;
r.bottom = r.top + 25;
fTypeField = new BMenuField(r,"type",TR("Target Type:"),menu);
fGeneralView->AddChild(fTypeField);
fTypeField->SetDivider(fTypeField->StringWidth(TR("Target Type:")) + 5.0);
SetToolTip(fTypeField,TR("The kind of program you want to build"));
menu->SetTargetForItems(this);
menu->SetLabelFromMarked(true);
BMenuItem *item = menu->ItemAt(fProject->TargetType());
if (item)
item->SetMarked(true);
r.OffsetBy(0,r.Height() + 10.0);
BStringView *label = new BStringView(r,"label",TR("Include Paths:"));
label->ResizeToPreferred();
fGeneralView->AddChild(label);
r = label->Frame();
r.OffsetBy(0,r.Height() + 5.0);
// We create a button now so that the list expands to fill the entire window
// while leaving space for the two buttons at the bottom. Note that we do not
// actually add the button to the window until later to preserve proper
// keyboard navigation order
BButton *add = new BButton(BRect(0,0,1,1),"addbutton",TR("Add…"),
new BMessage(M_SHOW_ADD_PATH),
B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
add->ResizeToPreferred();
add->MoveTo(5,fGeneralView->Bounds().bottom - 10.0 - add->Frame().Height());
r.right = bounds.right - 10.0 - B_V_SCROLL_BAR_WIDTH;
r.bottom = add->Frame().top - 10.0 - B_H_SCROLL_BAR_HEIGHT;
fIncludeList = new IncludeList(r,fProject->GetPath().GetFolder());
BScrollView *scrollView = new BScrollView("scrollview",fIncludeList,
B_FOLLOW_ALL,0, true, true);
scrollView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
fGeneralView->AddChild(scrollView);
//.........这里部分代码省略.........
示例11: bounds
//.........这里部分代码省略.........
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);
}
示例12: 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 ;
//.........这里部分代码省略.........
示例13: 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);
}
示例14: BMessage
//.........这里部分代码省略.........
// 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;
// add a "all" radiobutton
fAll = new BRadioButton(BRect(x, y, x+100, y+20), "all_pages", kAllPagesLabel,
new BMessage(ALL_PAGES_MGS));
fAll->ResizeToPreferred();
fAll->GetPreferredSize(&w, &h);
fAll->SetValue(allPages);
panel->AddChild(fAll);
y += h + kMargin; // "new line"
// add a range selection raddiobutton
fRange = new BRadioButton(BRect(x, y, x+100, y+20), "pages_range_selection", kPagesRangeSelectionLabel,
new BMessage(RANGE_SELECTION_MSG));
fRange->ResizeToPreferred();
fRange->GetPreferredSize(&w, &h);
fRange->SetValue(!allPages);
panel->AddChild(fRange);
x += w + kMargin;
// add a "from" field
if (allPages) {
buffer[0] = 0;
} else {
sprintf(buffer, "%d", (int)firstPage);
}
fFrom = new BTextControl(BRect(x, y, x+100, y+20), "from_field", kFromLabel, buffer,
new BMessage(RANGE_FROM_MSG));
fFrom->SetAlignment(B_ALIGN_LEFT, B_ALIGN_RIGHT);
fFrom->SetDivider(be_plain_font->StringWidth(kFromLabelExtraSpace));
fFrom->ResizeToPreferred();
fFrom->GetPreferredSize(&w, &h);
panel->AddChild(fFrom);
x += w + kMargin;
// add a "to" field
if (allPages) {
buffer[0] = 0;
} else {
sprintf(buffer, "%d", (int)lastPage);
}
fTo = new BTextControl(BRect(x, y, x+100, y+20), "to_field", kToLabel, buffer,
new BMessage(RANGE_TO_MSG));
fTo->SetAlignment(B_ALIGN_LEFT, B_ALIGN_RIGHT);
fTo->SetDivider(be_plain_font->StringWidth(kToLabelExtraSpace));
fTo->ResizeToPreferred();
fTo->GetPreferredSize(&w, &h);
panel->AddChild(fTo);
y += h + kMargin + kMargin; // "new line"
x = r.left + kMargin;
// add a separator line...
line = new BBox(BRect(r.left, y - 1, r.right, y), NULL,
B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP );
panel->AddChild(line);
y += 2 + kMargin + kMargin; // "new line"
// add a "OK" button, and make it default
ok = new BButton(BRect(x, y, x+100, y+20), NULL, "OK", new BMessage(OK_MSG), B_FOLLOW_RIGHT | B_FOLLOW_TOP);
ok->MakeDefault(true);
ok->ResizeToPreferred();
ok->GetPreferredSize(&w, &h);
x = r.right - w - kMargin;
ok->MoveTo(x, ok->Frame().top); // put the ok bottom at bottom right corner
panel->AddChild(ok);
// add a "Cancel" button
cancel = new BButton(BRect(x, y, x + 100, y + 20), NULL, "Cancel", new BMessage(CANCEL_MSG), B_FOLLOW_RIGHT | B_FOLLOW_TOP);
cancel->ResizeToPreferred();
cancel->GetPreferredSize(&w, &h);
cancel->MoveTo(x - w - kMargin, y); // put cancel button left next the ok button
panel->AddChild(cancel);
// add a "DocInfo" button
BButton *button = new BButton(r, NULL, "Doc Info", new BMessage(DOC_INFO_MSG),
B_FOLLOW_RIGHT | B_FOLLOW_TOP);
button->GetPreferredSize(&w, &h);
button->ResizeToPreferred();
button->MoveTo(8, y);
panel->AddChild(button);
// Finally, add our panel to window
AddChild(panel);
// Auto resize window
ResizeTo(ok->Frame().right + kMargin, ok->Frame().bottom + kMargin);
}
示例15: rect
ConfigWindow::ConfigWindow()
: BWindow(BRect(200.0, 200.0, 640.0, 640.0),
"E-mail", B_TITLED_WINDOW,
B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_NOT_RESIZABLE),
fLastSelectedAccount(NULL),
fSaveSettings(false)
{
/*** create controls ***/
BRect rect(Bounds());
BView *top = new BView(rect,NULL,B_FOLLOW_ALL,0);
top->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
AddChild(top);
// determine font height
font_height fontHeight;
top->GetFontHeight(&fontHeight);
int32 height = (int32)(fontHeight.ascent + fontHeight.descent + fontHeight.leading) + 5;
rect.InsetBy(5,5); rect.bottom -= 11 + height;
BTabView *tabView = new BTabView(rect,NULL);
BView *view,*generalView;
rect = tabView->Bounds(); rect.bottom -= tabView->TabHeight() + 4;
tabView->AddTab(view = new BView(rect,NULL,B_FOLLOW_ALL,0));
tabView->TabAt(0)->SetLabel(MDR_DIALECT_CHOICE ("Accounts","アカウント"));
view->SetViewColor(top->ViewColor());
// accounts listview
rect = view->Bounds().InsetByCopy(8,8);
rect.right = 140 - B_V_SCROLL_BAR_WIDTH;
rect.bottom -= height + 12;
fAccountsListView = new AccountsListView(rect);
view->AddChild(new BScrollView(NULL,fAccountsListView,B_FOLLOW_ALL,0,false,true));
rect.right += B_V_SCROLL_BAR_WIDTH;
rect.top = rect.bottom + 8; rect.bottom = rect.top + height;
BRect sizeRect = rect;
sizeRect.right = sizeRect.left + 30 + view->StringWidth(MDR_DIALECT_CHOICE ("Add","追加"));
view->AddChild(new BButton(sizeRect,NULL,MDR_DIALECT_CHOICE ("Add","追加"),
new BMessage(kMsgAddAccount),B_FOLLOW_BOTTOM));
sizeRect.left = sizeRect.right+3;
sizeRect.right = sizeRect.left + 30 + view->StringWidth(MDR_DIALECT_CHOICE ("Remove","削除"));
view->AddChild(fRemoveButton = new BButton(sizeRect,NULL,MDR_DIALECT_CHOICE ("Remove","削除"),
new BMessage(kMsgRemoveAccount),B_FOLLOW_BOTTOM));
// accounts config view
rect = view->Bounds();
rect.left = fAccountsListView->Frame().right + B_V_SCROLL_BAR_WIDTH + 16;
rect.right -= 10;
view->AddChild(fConfigView = new CenterContainer(rect));
MakeHowToView();
// general settings
rect = tabView->Bounds(); rect.bottom -= tabView->TabHeight() + 4;
tabView->AddTab(view = new CenterContainer(rect));
tabView->TabAt(1)->SetLabel(MDR_DIALECT_CHOICE ("General","一般"));
rect = view->Bounds().InsetByCopy(8,8);
rect.right -= 1; rect.bottom = rect.top + height * 5 + 15;
BBox *box = new BBox(rect);
box->SetLabel(MDR_DIALECT_CHOICE ("Retrieval Frequency","メールチェック間隔"));
view->AddChild(box);
rect = box->Bounds().InsetByCopy(8,8);
rect.top += 7; rect.bottom = rect.top + height + 5;
BRect tile = rect.OffsetByCopy(0,1);
int32 labelWidth = (int32)view->StringWidth(MDR_DIALECT_CHOICE ("Check every:","メールチェック間隔:"))+6;
tile.right = 80 + labelWidth;
fIntervalControl = new BTextControl(tile,"time",MDR_DIALECT_CHOICE ("Check every:","メールチェック間隔:"),
NULL,NULL);
fIntervalControl->SetDivider(labelWidth);
box->AddChild(fIntervalControl);
BPopUpMenu *frequencyPopUp = new BPopUpMenu(B_EMPTY_STRING);
const char *frequencyStrings[] = {
MDR_DIALECT_CHOICE ("Never","チェックしない"),
MDR_DIALECT_CHOICE ("Minutes","分毎チェック"),
MDR_DIALECT_CHOICE ("Hours","時間毎チェック"),
MDR_DIALECT_CHOICE ("Days","日間毎チェック")};
BMenuItem *item;
for (int32 i = 0;i < 4;i++)
{
frequencyPopUp->AddItem(item = new BMenuItem(frequencyStrings[i],new BMessage(kMsgIntervalUnitChanged)));
if (i == 1)
item->SetMarked(true);
}
tile.left = tile.right + 5; tile.right = rect.right;
tile.OffsetBy(0,-1);
fIntervalUnitField = new BMenuField(tile,"frequency", B_EMPTY_STRING, frequencyPopUp);
fIntervalUnitField->SetDivider(0.0);
box->AddChild(fIntervalUnitField);
rect.OffsetBy(0,height + 9); rect.bottom -= 2;
fPPPActiveCheckBox = new BCheckBox(rect,"ppp active",
MDR_DIALECT_CHOICE ("only when PPP is active","PPP接続中時のみ"), NULL);
//.........这里部分代码省略.........