本文整理汇总了C++中BView::ResizeToPreferred方法的典型用法代码示例。如果您正苦于以下问题:C++ BView::ResizeToPreferred方法的具体用法?C++ BView::ResizeToPreferred怎么用?C++ BView::ResizeToPreferred使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BView
的用法示例。
在下文中一共展示了BView::ResizeToPreferred方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CSelectTeamWindowView
CSelectTeamWindow::CSelectTeamWindow() :
CSingletonWindow(
BRect(0,0,10,10),
B_TRANSLATE("Select Team"),
B_TITLED_WINDOW,
B_NOT_ZOOMABLE | B_NOT_MINIMIZABLE | B_NOT_RESIZABLE | B_ASYNCHRONOUS_CONTROLS,
B_CURRENT_WORKSPACE)
{
static const float windowWidth = 200;
float windowHeight;
BView *view = new CSelectTeamWindowView(BRect(0, 0, windowWidth, 10));
view->GetPreferredSize(NULL, &windowHeight);
view->ResizeToPreferred();
BRect screenRect = BScreen(this).Frame();
// center window
float wx = (screenRect.Width()-windowWidth)/2;
float wy = (screenRect.Height()-windowHeight)/2;
MoveTo(wx, wy);
ResizeTo(windowWidth, windowHeight);
AddChild(view);
Show();
}
示例2: 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);
}
}
示例3: rect
Window::Window()
: BWindow(BRect(100, 100, 520, 430), "CheckBox-Test",
B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS)
{
BRect rect(20, 10, 200, 30);
BStringView *stringView = new BStringView(rect, NULL, "Be's BCheckBox");
stringView->SetFont(be_bold_font);
AddChild(stringView);
rect.OffsetBy(0, 40);
BView *checkBox = new BCheckBox(rect, NULL, "Test 1", NULL);
AddChild(checkBox);
rect.OffsetBy(0, 60);
BView *view = new BView(rect.InsetByCopy(-15, -15), NULL, B_FOLLOW_NONE, B_WILL_DRAW);
view->SetViewColor(240, 180, 20);
AddChild(view);
checkBox = new BCheckBox(rect.OffsetToCopy(15, 15), NULL, "Test 2", NULL);
view->AddChild(checkBox);
checkBox->SetViewColor(220, 170, 20);
rect.OffsetBy(0, 60);
BBox *box = new BBox(rect.InsetByCopy(-15, -15), NULL);
AddChild(box);
checkBox = new BCheckBox(rect.OffsetToCopy(15, 15), NULL, "Test 3", NULL);
checkBox->SetViewColor(220, 170, 20);
// is ignored...
box->AddChild(checkBox);
rect.OffsetBy(0, 60);
view = new DividedBackgroundView(rect.InsetByCopy(-15, -15));
AddChild(view);
checkBox = new BCheckBox(rect.OffsetToCopy(15, 15), NULL, "Test 4", NULL);
view->AddChild(checkBox);
rect.OffsetBy(0, 60);
view = new DividedBackgroundView(rect.InsetByCopy(-15, -15));
AddChild(view);
checkBox = new BCheckBox(rect.OffsetToCopy(15, 15), NULL, "Test 5", NULL);
checkBox->ResizeToPreferred();
view->AddChild(checkBox);
// Antares's BCheckBox
rect.Set(240, 10, 400, 30);
stringView = new BStringView(rect, NULL, "Antares's BCheckBox");
stringView->SetFont(be_bold_font);
AddChild(stringView);
rect.OffsetBy(0, 40);
checkBox = new HCheckBox(rect, NULL, "Test 1", NULL);
AddChild(checkBox);
rect.OffsetBy(0, 60);
view = new BView(rect.InsetByCopy(-15, -15), NULL, B_FOLLOW_NONE, B_WILL_DRAW);
view->SetViewColor(240, 180, 20);
AddChild(view);
checkBox = new HCheckBox(rect.OffsetToCopy(15, 15), NULL, "Test 2", NULL);
view->AddChild(checkBox);
checkBox->SetViewColor(220, 170, 20);
rect.OffsetBy(0, 60);
box = new BBox(rect.InsetByCopy(-15, -15), NULL);
AddChild(box);
checkBox = new HCheckBox(rect.OffsetToCopy(15, 15), NULL, "Test 3", NULL);
checkBox->SetViewColor(220, 170, 20);
// is ignored...
box->AddChild(checkBox);
rect.OffsetBy(0, 60);
view = new DividedBackgroundView(rect.InsetByCopy(-15, -15));
AddChild(view);
checkBox = new HCheckBox(rect.OffsetToCopy(15, 15), NULL, "Test 4", NULL);
view->AddChild(checkBox);
rect.OffsetBy(0, 60);
view = new DividedBackgroundView(rect.InsetByCopy(-15, -15));
AddChild(view);
checkBox = new HCheckBox(rect.OffsetToCopy(15, 15), NULL, "Test 5", NULL);
checkBox->ResizeToPreferred();
view->AddChild(checkBox);
}