本文整理汇总了C++中BMenuBar::ResizeToPreferred方法的典型用法代码示例。如果您正苦于以下问题:C++ BMenuBar::ResizeToPreferred方法的具体用法?C++ BMenuBar::ResizeToPreferred怎么用?C++ BMenuBar::ResizeToPreferred使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BMenuBar
的用法示例。
在下文中一共展示了BMenuBar::ResizeToPreferred方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: msg
TeapotWindow::TeapotWindow(BRect rect, const char* name, window_type wt,
ulong something)
:
BDirectWindow(rect, name, wt, something)
{
GLenum type = BGL_RGB | BGL_DEPTH | BGL_DOUBLE;
Lock();
BRect bounds = Bounds();
bounds.bottom = bounds.top + 14;
BMenuBar* menuBar = new BMenuBar(bounds, "main menu");
BMenu* menu;
BMessage msg(kMsgAddModel);
menuBar->AddItem(menu = new BMenu(B_TRANSLATE("File")));
AddChild(menuBar);
menuBar->ResizeToPreferred();
bounds = Bounds();
bounds.top = menuBar->Bounds().bottom + 1;
BView *subView = new BView(bounds, "subview", B_FOLLOW_ALL, 0);
AddChild(subView);
bounds = subView->Bounds();
fObjectView = new(std::nothrow) ObjectView(bounds, "objectView",
B_FOLLOW_ALL_SIDES, type);
subView->AddChild(fObjectView);
BMenuItem* item;
msg.AddInt32("num", 256);
menu->AddItem(item = new BMenuItem(B_TRANSLATE("Add a teapot"),
new BMessage(msg), 'N'));
item->SetTarget(fObjectView);
menu->AddSeparatorItem();
menu->AddItem(item = new BMenuItem(B_TRANSLATE("Quit"),
new BMessage(B_QUIT_REQUESTED), 'Q'));
item->SetTarget(be_app);
msg.RemoveName("num");
menuBar->AddItem(menu = new BMenu(B_TRANSLATE("Options")));
menu->AddItem(item = new BMenuItem(B_TRANSLATE("Perspective"),
new BMessage(kMsgPerspective)));
item->SetTarget(fObjectView);
item->SetMarked(false);
menu->AddItem(item = new BMenuItem(B_TRANSLATE("FPS display"),
new BMessage(kMsgFPS)));
item->SetTarget(fObjectView);
item->SetMarked(true);
menu->AddItem(item = new BMenuItem(B_TRANSLATE("Filled polygons"),
new BMessage(kMsgFilled)));
item->SetTarget(fObjectView);
item->SetMarked(true);
menu->AddItem(item = new BMenuItem(B_TRANSLATE("Lighting"),
new BMessage(kMsgLighting)));
item->SetTarget(fObjectView);
item->SetMarked(true);
menu->AddItem(item = new BMenuItem(B_TRANSLATE("Backface culling"),
new BMessage(kMsgCulling)));
item->SetTarget(fObjectView);
item->SetMarked(true);
menu->AddItem(item = new BMenuItem(B_TRANSLATE("Z-buffered"),
new BMessage(kMsgZBuffer)));
item->SetTarget(fObjectView);
item->SetMarked(true);
menu->AddItem(item = new BMenuItem(B_TRANSLATE("Gouraud shading"),
new BMessage(kMsgGouraud)));
item->SetTarget(fObjectView);
item->SetMarked(true);
// menu->AddItem(item = new BMenuItem("Texture mapped", new BMessage(kMsgTextured)));
// item->SetTarget(fObjectView);
menu->AddItem(item = new BMenuItem(B_TRANSLATE("Fog"),
new BMessage(kMsgFog)));
item->SetTarget(fObjectView);
BMenu *subMenu;
menuBar->AddItem(menu = new BMenu(B_TRANSLATE("Lights")));
msg.what = kMsgLights;
msg.AddInt32("num", 1);
menu->AddItem(item = new BMenuItem(subMenu =
new BMenu(B_TRANSLATE("Upper center")), NULL));
item->SetTarget(fObjectView);
msg.AddInt32("color", lightNone);
subMenu->AddItem(item = new BMenuItem(B_TRANSLATE("Off"),
new BMessage(msg)));
item->SetTarget(fObjectView);
subMenu->AddSeparatorItem();
msg.ReplaceInt32("color", lightWhite);
subMenu->AddItem(item = new BMenuItem(B_TRANSLATE("White"),
new BMessage(msg)));
item->SetTarget(fObjectView);
item->SetMarked(true);
msg.ReplaceInt32("color", lightYellow);
subMenu->AddItem(item = new BMenuItem(B_TRANSLATE("Yellow"),
new BMessage(msg)));
item->SetTarget(fObjectView);
msg.ReplaceInt32("color", lightBlue);
subMenu->AddItem(item = new BMenuItem(B_TRANSLATE("Blue"),
new BMessage(msg)));
//.........这里部分代码省略.........
示例2: BMessage
SerialWindow::SerialWindow()
: BWindow(BRect(100, 100, 400, 400), SerialWindow::kWindowTitle,
B_DOCUMENT_WINDOW, B_QUIT_ON_WINDOW_CLOSE | B_AUTO_UPDATE_SIZE_LIMITS)
, fLogFilePanel(NULL)
{
BMenuBar* menuBar = new BMenuBar(Bounds(), "menuBar");
menuBar->ResizeToPreferred();
BRect r = Bounds();
r.top = menuBar->Bounds().bottom + 1;
r.right -= B_V_SCROLL_BAR_WIDTH;
fTermView = new TermView(r);
fTermView->ResizeToPreferred();
r = fTermView->Frame();
r.left = r.right + 1;
r.right = r.left + B_V_SCROLL_BAR_WIDTH;
r.top -= 1;
r.bottom -= B_H_SCROLL_BAR_HEIGHT - 1;
BScrollBar* scrollBar = new BScrollBar(r, "scrollbar", NULL, 0, 0,
B_VERTICAL);
scrollBar->SetTarget(fTermView);
ResizeTo(r.right - 1, r.bottom + B_H_SCROLL_BAR_HEIGHT - 1);
AddChild(menuBar);
AddChild(fTermView);
AddChild(scrollBar);
fConnectionMenu = new BMenu("Connection");
BMenu* fileMenu = new BMenu("File");
BMenu* settingsMenu = new BMenu("Settings");
fConnectionMenu->SetRadioMode(true);
menuBar->AddItem(fConnectionMenu);
menuBar->AddItem(fileMenu);
menuBar->AddItem(settingsMenu);
// TODO edit menu - what's in it ?
//BMenu* editMenu = new BMenu("Edit");
//menuBar->AddItem(editMenu);
BMenuItem* logFile = new BMenuItem("Log to file" B_UTF8_ELLIPSIS,
new BMessage(kMsgLogfile));
fileMenu->AddItem(logFile);
#if 0
// TODO implement these
BMenuItem* xmodemSend = new BMenuItem("X/Y/ZModem send" B_UTF8_ELLIPSIS,
NULL);
fileMenu->AddItem(xmodemSend);
BMenuItem* xmodemReceive = new BMenuItem(
"X/Y/Zmodem receive" B_UTF8_ELLIPSIS, NULL);
fileMenu->AddItem(xmodemReceive);
#endif
// Configuring all this by menus may be a bit unhandy. Make a setting
// window instead ?
fBaudrateMenu = new BMenu("Baud rate");
fBaudrateMenu->SetRadioMode(true);
settingsMenu->AddItem(fBaudrateMenu);
fParityMenu = new BMenu("Parity");
fParityMenu->SetRadioMode(true);
settingsMenu->AddItem(fParityMenu);
fStopbitsMenu = new BMenu("Stop bits");
fStopbitsMenu->SetRadioMode(true);
settingsMenu->AddItem(fStopbitsMenu);
fFlowcontrolMenu = new BMenu("Flow control");
fFlowcontrolMenu->SetRadioMode(true);
settingsMenu->AddItem(fFlowcontrolMenu);
fDatabitsMenu = new BMenu("Data bits");
fDatabitsMenu->SetRadioMode(true);
settingsMenu->AddItem(fDatabitsMenu);
BMessage* message = new BMessage(kMsgSettings);
message->AddInt32("parity", B_NO_PARITY);
BMenuItem* parityNone = new BMenuItem("None", message);
message = new BMessage(kMsgSettings);
message->AddInt32("parity", B_ODD_PARITY);
BMenuItem* parityOdd = new BMenuItem("Odd", message);
message = new BMessage(kMsgSettings);
message->AddInt32("parity", B_EVEN_PARITY);
BMenuItem* parityEven = new BMenuItem("Even", message);
fParityMenu->AddItem(parityNone);
fParityMenu->AddItem(parityOdd);
fParityMenu->AddItem(parityEven);
fParityMenu->SetTargetForItems(be_app);
message = new BMessage(kMsgSettings);
message->AddInt32("databits", B_DATA_BITS_7);
BMenuItem* data7 = new BMenuItem("7", message);
//.........这里部分代码省略.........