本文整理汇总了C++中BButton::MinSize方法的典型用法代码示例。如果您正苦于以下问题:C++ BButton::MinSize方法的具体用法?C++ BButton::MinSize怎么用?C++ BButton::MinSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BButton
的用法示例。
在下文中一共展示了BButton::MinSize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BMessage
BButton*
ScreenWindow::_CreateColumnRowButton(bool columns, bool plus)
{
BMessage* message = new BMessage(kMsgWorkspaceLayoutChanged);
message->AddInt32("delta_x", columns ? (plus ? 1 : -1) : 0);
message->AddInt32("delta_y", !columns ? (plus ? 1 : -1) : 0);
BButton* button = new BButton(plus ? "+" : "-", message);
button->SetFontSize(be_plain_font->Size() * 0.9);
BSize size = button->MinSize();
size.width = button->StringWidth("+") + 16;
button->SetExplicitMinSize(size);
button->SetExplicitMaxSize(size);
fWorkspacesButtons[(columns ? 0 : 2) + (plus ? 1 : 0)] = button;
return button;
}
示例2: ButtonAt
/*! Tweaks the layout according to the configuration.
*/
void
BAlert::_Prepare()
{
// Must have at least one button
if (CountButtons() == 0)
debugger("BAlerts must have at least one button.");
float fontFactor = be_plain_font->Size() / 11.0f;
if (fIconView->Bitmap() == NULL)
fIconView->SetBitmap(_CreateTypeIcon());
if (fButtonWidth == B_WIDTH_AS_USUAL) {
float usualWidth = kButtonUsualWidth * fontFactor;
for (int32 index = 0; index < CountButtons(); index++) {
BButton* button = ButtonAt(index);
if (button->MinSize().width < usualWidth)
button->SetExplicitSize(BSize(usualWidth, B_SIZE_UNSET));
}
} else if (fButtonWidth == B_WIDTH_FROM_WIDEST) {
// Get width of widest label
float maxWidth = 0;
for (int32 index = 0; index < CountButtons(); index++) {
BButton* button = ButtonAt(index);
float width;
button->GetPreferredSize(&width, NULL);
if (width > maxWidth)
maxWidth = width;
}
for (int32 index = 0; index < CountButtons(); index++) {
BButton* button = ButtonAt(index);
button->SetExplicitSize(BSize(maxWidth, B_SIZE_UNSET));
}
}
if (fButtonSpacing == B_OFFSET_SPACING && CountButtons() > 1) {
// Insert some strut
fButtonLayout->AddItem(1, BSpaceLayoutItem::CreateHorizontalStrut(
kButtonOffsetSpacing * fontFactor));
}
// Position the alert so that it is centered vertically but offset a bit
// horizontally in the parent window's frame or, if unavailable, the
// screen frame.
float minWindowWidth = (fButtonSpacing == B_OFFSET_SPACING
? kWindowOffsetMinWidth : kWindowMinWidth) * fontFactor;
GetLayout()->SetExplicitMinSize(BSize(minWindowWidth, B_SIZE_UNSET));
ResizeToPreferred();
// Return early if we've already been moved...
if (Frame().left != 0 && Frame().right != 0)
return;
// otherwise center ourselves on-top of parent window/screen
BWindow* parent = dynamic_cast<BWindow*>(BLooper::LooperForThread(
find_thread(NULL)));
const BRect frame = parent != NULL ? parent->Frame()
: BScreen(this).Frame();
MoveTo(static_cast<BWindow*>(this)->AlertPosition(frame));
// Hidden by BAlert::AlertPosition()
}