本文整理汇总了C++中BButton::ResizeTo方法的典型用法代码示例。如果您正苦于以下问题:C++ BButton::ResizeTo方法的具体用法?C++ BButton::ResizeTo怎么用?C++ BButton::ResizeTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BButton
的用法示例。
在下文中一共展示了BButton::ResizeTo方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BMessage
BButton*
BAlert::_CreateButton(int32 which, const char* label)
{
BMessage* message = new BMessage(kAlertButtonMsg);
if (message == NULL)
return NULL;
message->AddInt32("which", which);
BRect rect;
rect.top = Bounds().bottom - kBottomOffset;
rect.bottom = rect.top;
char name[32];
snprintf(name, sizeof(name), "_b%ld_", which);
BButton* button = new(std::nothrow) BButton(rect, name, label, message,
B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
if (button == NULL)
return NULL;
float width, height;
button->GetPreferredSize(&width, &height);
if (fButtonWidth == B_WIDTH_AS_USUAL) {
float fontFactor = be_plain_font->Size() / 11.0f;
width = max_c(width, kButtonUsualWidth * fontFactor);
}
button->ResizeTo(width, height);
button->MoveBy(0.0f, -height);
return button;
}
示例2: rect
//.........这里部分代码省略.........
B_TRANSLATE("Only when dial-up is connected"), NULL);
box->AddChild(fPPPActiveCheckBox);
rect.OffsetBy(0,height + 9);
rect.bottom -= 2;
fPPPActiveSendCheckBox = new BCheckBox(rect, "ppp activesend",
B_TRANSLATE("Schedule outgoing mail when dial-up is disconnected"),
NULL);
box->AddChild(fPPPActiveSendCheckBox);
// Miscellaneous settings box
rect = box->Frame();
rect.bottom = rect.top + 3 * height + 30;
box = new BBox(rect);
box->SetLabel(B_TRANSLATE("Miscellaneous"));
view->AddChild(box);
BPopUpMenu *statusPopUp = new BPopUpMenu(B_EMPTY_STRING);
const char *statusModes[] = {
B_TRANSLATE("Never"),
B_TRANSLATE("While sending"),
B_TRANSLATE("While sending and receiving"),
B_TRANSLATE("Always")
};
BMessage *msg;
for (int32 i = 0; i < 4; i++) {
statusPopUp->AddItem(item = new BMenuItem(statusModes[i],
msg = new BMessage(kMsgShowStatusWindowChanged)));
msg->AddInt32("ShowStatusWindow", i);
if (i == 0)
item->SetMarked(true);
}
rect = box->Bounds().InsetByCopy(8,8);
rect.top += 7;
rect.bottom = rect.top + height + 5;
labelWidth
= (int32)view->StringWidth(
B_TRANSLATE("Show connection status window:")) + 8;
fStatusModeField = new BMenuField(rect, "show status",
B_TRANSLATE("Show connection status window:"), statusPopUp);
fStatusModeField->SetDivider(labelWidth);
box->AddChild(fStatusModeField);
rect = fStatusModeField->Frame();;
rect.OffsetBy(0, rect.Height() + 10);
BButton *button = new BButton(rect, B_EMPTY_STRING,
B_TRANSLATE("Edit mailbox menu…"),
msg = new BMessage(B_REFS_RECEIVED));
button->ResizeToPreferred();
box->AddChild(button);
button->SetTarget(BMessenger("application/x-vnd.Be-TRAK"));
BPath path;
find_directory(B_USER_SETTINGS_DIRECTORY, &path);
path.Append("Mail/Menu Links");
BEntry entry(path.Path());
if (entry.InitCheck() == B_OK && entry.Exists()) {
entry_ref ref;
entry.GetRef(&ref);
msg->AddRef("refs", &ref);
}
else
button->SetEnabled(false);
rect = button->Frame();
rect.OffsetBy(rect.Width() + 30,0);
fAutoStartCheckBox = new BCheckBox(rect, "start daemon",
B_TRANSLATE("Start mail services on startup"), NULL);
fAutoStartCheckBox->ResizeToPreferred();
box->AddChild(fAutoStartCheckBox);
// save/revert buttons
top->AddChild(tabView);
rect = tabView->Frame();
rect.top = rect.bottom + 5;
rect.bottom = rect.top + height + 5;
BButton *saveButton = new BButton(rect, "apply", B_TRANSLATE("Apply"),
new BMessage(kMsgSaveSettings));
float w,h;
saveButton->GetPreferredSize(&w, &h);
saveButton->ResizeTo(w, h);
saveButton->MoveTo(rect.right - w, rect.top);
top->AddChild(saveButton);
BButton *revertButton = new BButton(rect, "revert", B_TRANSLATE("Revert"),
new BMessage(kMsgRevertSettings));
revertButton->GetPreferredSize(&w, &h);
revertButton->ResizeTo(w,h);
revertButton->MoveTo(saveButton->Frame().left - 25 - w, rect.top);
top->AddChild(revertButton);
LoadSettings();
// this will also move our window to the stored position
fAccountsListView->SetSelectionMessage(new BMessage(kMsgAccountSelected));
fAccountsListView->MakeFocus(true);
}
示例3: rect
//.........这里部分代码省略.........
fStatusLookField = new BMenuField(rect,"status look",
MDR_DIALECT_CHOICE ("Window Look:","ウィンドウ外観:"),lookPopUp);
fStatusLookField->SetDivider(labelWidth);
box->AddChild(fStatusLookField);
BPopUpMenu *workspacesPopUp = new BPopUpMenu(B_EMPTY_STRING);
workspacesPopUp->AddItem(item = new BMenuItem(
MDR_DIALECT_CHOICE ("Current Workspace","使用中ワークスペース"),
msg = new BMessage(kMsgStatusWorkspaceChanged)));
msg->AddInt32("StatusWindowWorkSpace", 0);
workspacesPopUp->AddItem(item = new BMenuItem(
MDR_DIALECT_CHOICE ("All Workspaces","全てのワークスペース"),
msg = new BMessage(kMsgStatusWorkspaceChanged)));
msg->AddInt32("StatusWindowWorkSpace", -1);
rect.OffsetBy(0,height + 6);
fStatusWorkspaceField = new BMenuField(rect,"status workspace",
MDR_DIALECT_CHOICE ("Window visible on:","表示場所:"),workspacesPopUp);
fStatusWorkspaceField->SetDivider(labelWidth);
box->AddChild(fStatusWorkspaceField);
rect = box->Frame(); rect.bottom = rect.top + 3*height + 13;
box = new BBox(rect);
box->SetLabel(MDR_DIALECT_CHOICE ("Deskbar Icon","デスクバーアイコンリンク"));
view->AddChild(box);
rect = box->Bounds().InsetByCopy(8,8);
rect.top += 7; rect.bottom = rect.top + height + 5;
BStringView *stringView = new BStringView(rect,B_EMPTY_STRING, MDR_DIALECT_CHOICE (
"The menu links are links to folders in a real folder like the Be menu.",
"デスクバーで表示する項目の設定"));
box->AddChild(stringView);
stringView->SetAlignment(B_ALIGN_CENTER);
stringView->ResizeToPreferred();
// BStringView::ResizeToPreferred() changes the width, so that the
// alignment has no effect anymore
stringView->ResizeTo(rect.Width(), stringView->Bounds().Height());
rect.left += 100; rect.right -= 100;
rect.OffsetBy(0,height + 1);
BButton *button = new BButton(rect,B_EMPTY_STRING,
MDR_DIALECT_CHOICE ("Configure Menu Links","メニューリンクの設定"),
msg = new BMessage(B_REFS_RECEIVED));
box->AddChild(button);
button->SetTarget(BMessenger("application/x-vnd.Be-TRAK"));
BPath path;
find_directory(B_USER_SETTINGS_DIRECTORY, &path);
path.Append("Mail/Menu Links");
BEntry entry(path.Path());
if (entry.InitCheck() == B_OK && entry.Exists()) {
entry_ref ref;
entry.GetRef(&ref);
msg->AddRef("refs", &ref);
}
else
button->SetEnabled(false);
rect = box->Frame(); rect.bottom = rect.top + 2*height + 6;
box = new BBox(rect);
box->SetLabel(MDR_DIALECT_CHOICE ("Misc.","その他の設定"));
view->AddChild(box);
rect = box->Bounds().InsetByCopy(8,8);
rect.top += 7; rect.bottom = rect.top + height + 5;
fAutoStartCheckBox = new BCheckBox(rect,"start daemon",
示例4:
//calculate the view positions of all the MatrixLayoutItems
//on the items list with offsets based upon matrixLeft
//and matrixTop
void
LayoutMatrix :: Calc( const float paramMatrixLeft,
const float paramMatrixTop,
sem_id paramSemID)
{
int32 numItems = mpItemsList->CountItems();
if (!numItems) return;
if (acquire_sem(paramSemID) != B_NO_ERROR)
{
warning(myPrefs->FailAqSem);
return;
}
bool hasPopUpMenu = false;
TextItem * scratchTextItem;
for ( int i = 0;
i < numItems;
i++)
{
((LayoutMatrixItem *)(mpItemsList->ItemAt(i)))->Calc();
}
float widest = 0;
float tallest = 0;
int32 index = 0;
for ( int i = 0;
i < numItems;
i++)
{
LayoutMatrixItem * lmi = (LayoutMatrixItem *)mpItemsList->ItemAt(index++);
if (lmi->mfWidthPref > widest)
{
widest = lmi->mfWidthPref;
}
if (lmi->mfHeightPref > tallest)
{
tallest = lmi->mfHeightPref;
}
}
if (mui32Flags & SAMESIZE)
{//SAMESIZE makes all items the same size as the largest
index = 0;
//Resize all items to match largest:
for ( uint32 i = 0;
i < mui32Rows;
i++)
{
for ( uint32 j = 0;
j < mui32Columns;
j++)
{
LayoutMatrixItem * lmi = (LayoutMatrixItem *)mpItemsList->ItemAt(index++);
switch (lmi->mui32Kind)
{
case KIND_MYSPACER:
{
MySpacer * scratchMySpacer = (MySpacer *)lmi->mpItem;
if (scratchMySpacer->mbSAMEFromWidest)
{
scratchMySpacer->ResizeTo(widest, tallest);
}
}
break;
case KIND_MYBUTTON:
{
BButton * scratchMyButton = (BButton *)lmi->mpItem;
scratchMyButton->ResizeTo(widest, tallest);
}
break;
case KIND_MYSLIDER:
{
BSlider * scratchMySlider = (BSlider *)lmi->mpItem;
scratchMySlider->ResizeTo(widest, tallest);
}
break;
case KIND_STRINGDRAWER:
{
BStringView * scratchMyStringView = (BStringView *)lmi->mpItem;
scratchMyStringView->ResizeTo(widest, tallest);
}
break;
case KIND_MYCHECKBOX:
{
BCheckBox * scratchMyCheckBox = (BCheckBox *)lmi->mpItem;
scratchMyCheckBox->ResizeTo(widest, tallest);
}
break;
case KIND_MYPICTUREBUTTON:
{
BPictureButton * scratchMyPictureButton = (BPictureButton *)lmi->mpItem;
scratchMyPictureButton->ResizeTo(widest, tallest);
}
break;
case KIND_MYCOLORCONTROL:
{
BColorControl * scratchMyColorControl = (BColorControl *)lmi->mpItem;
scratchMyColorControl->ResizeTo(widest, tallest);
}
break;
//.........这里部分代码省略.........
示例5: 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 ;
//.........这里部分代码省略.........