本文整理汇总了C++中BMenuBar::GetPreferredSize方法的典型用法代码示例。如果您正苦于以下问题:C++ BMenuBar::GetPreferredSize方法的具体用法?C++ BMenuBar::GetPreferredSize怎么用?C++ BMenuBar::GetPreferredSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BMenuBar
的用法示例。
在下文中一共展示了BMenuBar::GetPreferredSize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BOutlineListView
TestWindow::TestWindow(BApplication* myApp)
: BWindow(BRect(20,20,100,100),
"Code Profile", B_TITLED_WINDOW, 0)
{
BRect frm = Bounds();
BView* myview = new BView(BRect(),"testView",0,0);
BOutlineListView* olist =
new BOutlineListView(BRect(),"MyList",
B_SINGLE_SELECTION_LIST,B_FOLLOW_NONE);
if( myview && olist ) {
myview->AddChild(olist);
BView* vw = olist;
vw->SetViewColor(0xc0,0xc0,0xc0);
vw->Invalidate();
vw->SetLowColor(0xc0,0xc0,0xc0);
vw->Invalidate();
vw->SetHighColor(0x00,0x00,0x00);
vw->Invalidate();
vw->SetFont(be_bold_font);
this->AddChild(myview);
BRect frm = vw->Frame();
vw->ResizeTo(1,1);
vw->Draw(vw->Bounds());
vw->ResizeToPreferred();
float w=0,h=0;
vw->GetPreferredSize(&w,&h);
printf("Preferred size = %f x %f\n",w,h);
}
string = new BStringView(BRect(0,0,100,20),"String",
"Ready to profile...");
if( string ) {
string->SetViewColor(0xc0,0xc0,0xc0);
this->AddChild(string);
float w=0, h=0;
string->GetPreferredSize(&w,&h);
MoveTo(30,30);
ResizeTo(w,h);
}
BMenuBar* menu = new BMenuBar(BRect(),"MainMenu",B_FOLLOW_NONE);
if( menu ) {
this->AddChild(menu);
float w=0, h=0;
menu->GetPreferredSize(&w,&h);
printf("Preferred Size = (%f,%f)\n",w,h);
menu->SetFont(be_plain_font);
menu->GetPreferredSize(&w,&h);
printf("Preferred Size = (%f,%f)\n",w,h);
menu->SetFont(be_bold_font);
menu->GetPreferredSize(&w,&h);
printf("Preferred Size = (%f,%f)\n",w,h);
menu->SetFont(be_fixed_font);
menu->GetPreferredSize(&w,&h);
printf("Preferred Size = (%f,%f)\n",w,h);
}
}
示例2: BWindow
Fenster::Fenster() : BWindow( BRect( 20, 40, 620, 460), "PecoRename", B_TITLED_WINDOW, 0){
// Menü
BMenuBar* MenuBar = new BMenuBar( BRect( 0, 0, 0, 0 ), "MenuBar" );
BMenu* Menu;
Menu = new BMenu(STR_MENU_FILE);
MenuBar->AddItem(Menu);
Menu->AddItem(new BMenuItem(STR_MENU_NEW, new BMessage(MSG_MENU_NEW), 'N'));
Menu->AddItem(new BMenuItem(STR_MENU_OPEN, new BMessage(MSG_SELECT_FILES), 'O'));
Menu->AddSeparatorItem();
Menu->AddItem(new BMenuItem(STR_MENU_ABOUT, new BMessage(B_ABOUT_REQUESTED)));
Menu->AddSeparatorItem();
Menu->AddItem(new BMenuItem(STR_MENU_QUIT, new BMessage(B_QUIT_REQUESTED), 'Q'));
Menu = new BMenu(STR_MENU_TOOLS);
MenuBar->AddItem(Menu);
Menu->AddItem(new BMenuItem(STR_MENU_CREATE_SCRIPT, new BMessage(MSG_MENU_SCRIPT)));
Menu = new BMenu(STR_MENU_HELP);
MenuBar->AddItem(Menu);
Menu->AddItem(new BMenuItem(STR_MENU_DOCU, new BMessage(MSG_MENU_DOCU)));
AddChild( MenuBar );
// Größe bestimmen + Fenster anpassen
float BarWidth, BarHeight;
MenuBar->GetPreferredSize ( &BarWidth, &BarHeight );
SetSizeLimits( 600, 600, 10000, 155 + BarHeight + 5 * be_plain_font->Size() + 2 * be_bold_font->Size());
// Main Frame
BRect MainFrame = Bounds();
MainFrame.top += BarHeight;
MainView* mainView = new MainView( MainFrame );
AddChild( mainView );
BTextControl* TextControl = (BTextControl *)FindView("pfadView");
TextControl->TextView()->MakeEditable(false);
};
示例3: name
THeaderView::THeaderView(BRect rect, BRect windowRect, bool incoming,
bool resending, uint32 defaultCharacterSet, int32 defaultAccount)
:
BBox(rect, "m_header", B_FOLLOW_LEFT_RIGHT, B_WILL_DRAW, B_NO_BORDER),
fAccountMenu(NULL),
fEncodingMenu(NULL),
fAccountID(defaultAccount),
fAccountTo(NULL),
fAccount(NULL),
fBcc(NULL),
fCc(NULL),
fSubject(NULL),
fTo(NULL),
fDateLabel(NULL),
fDate(NULL),
fIncoming(incoming),
fCharacterSetUserSees(defaultCharacterSet),
fResending(resending),
fBccMenu(NULL),
fCcMenu(NULL),
fToMenu(NULL),
fEmailList(NULL)
{
BMenuField* field;
BMessage* msg;
float x = StringWidth( /* The longest title string in the header area */
B_TRANSLATE("Attachments: ")) + 9;
float y = TO_FIELD_V;
BMenuBar* dummy = new BMenuBar(BRect(0, 0, 100, 15), "Dummy");
AddChild(dummy);
float width, menuBarHeight;
dummy->GetPreferredSize(&width, &menuBarHeight);
dummy->RemoveSelf();
delete dummy;
float menuFieldHeight = menuBarHeight + 6;
float controlHeight = menuBarHeight + floorf(be_plain_font->Size() / 1.15);
if (!fIncoming) {
InitEmailCompletion();
InitGroupCompletion();
}
// Prepare the character set selection pop-up menu (we tell the user that
// it is the Encoding menu, even though it is really the character set).
// It may appear in the first line, to the right of the From box if the
// user is reading an e-mail. It appears on the second line, to the right
// of the e-mail account menu, if the user is composing a message. It lets
// the user quickly select a character set different from the application
// wide default one, and also shows them which character set is active. If
// you are reading a message, you also see an item that says "Automatic"
// for automatic decoding character set choice. It can slide around as the
// window is resized when viewing a message, but not when composing
// (because the adjacent pop-up menu can't resize dynamically due to a BeOS
// bug).
float widestCharacterSet = 0;
bool markedCharSet = false;
BMenuItem* item;
fEncodingMenu = new BPopUpMenu(B_EMPTY_STRING);
BCharacterSetRoster roster;
BCharacterSet charset;
while (roster.GetNextCharacterSet(&charset) == B_OK) {
BString name(charset.GetPrintName());
const char* mime = charset.GetMIMEName();
if (mime)
name << " (" << mime << ")";
uint32 convertID;
if (mime == NULL || strcasecmp(mime, "UTF-8") != 0)
convertID = charset.GetConversionID();
else
convertID = B_MAIL_UTF8_CONVERSION;
msg = new BMessage(kMsgEncoding);
msg->AddInt32("charset", convertID);
fEncodingMenu->AddItem(item = new BMenuItem(name.String(), msg));
if (convertID == fCharacterSetUserSees && !markedCharSet) {
item->SetMarked(true);
markedCharSet = true;
}
if (StringWidth(name.String()) > widestCharacterSet)
widestCharacterSet = StringWidth(name.String());
}
msg = new BMessage(kMsgEncoding);
msg->AddInt32("charset", B_MAIL_US_ASCII_CONVERSION);
fEncodingMenu->AddItem(item = new BMenuItem("US-ASCII", msg));
if (fCharacterSetUserSees == B_MAIL_US_ASCII_CONVERSION && !markedCharSet) {
item->SetMarked(true);
markedCharSet = true;
}
if (!resending && fIncoming) {
// reading a message, display the Automatic item
//.........这里部分代码省略.........