本文整理汇总了C++中BLayoutItem::SetExplicitMinSize方法的典型用法代码示例。如果您正苦于以下问题:C++ BLayoutItem::SetExplicitMinSize方法的具体用法?C++ BLayoutItem::SetExplicitMinSize怎么用?C++ BLayoutItem::SetExplicitMinSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BLayoutItem
的用法示例。
在下文中一共展示了BLayoutItem::SetExplicitMinSize方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BMessage
void
BreakpointEditWindow::_Init()
{
fConditionInput = new BTextControl(NULL, NULL, NULL);
BLayoutItem* textLayoutItem = fConditionInput->CreateTextViewLayoutItem();
textLayoutItem->SetExplicitMinSize(BSize(200.0, B_SIZE_UNSET));
BLayoutBuilder::Group<>(this, B_VERTICAL)
.SetInsets(B_USE_DEFAULT_SPACING)
.Add((fAlwaysRadio = new BRadioButton("Break always",
new BMessage(MSG_SET_BREAK_ALWAYS))))
.AddGroup(B_HORIZONTAL)
.Add((fConditionRadio = new BRadioButton("Break on condition: ",
new BMessage(MSG_SET_BREAK_ON_CONDITION))))
.Add(textLayoutItem)
.End()
.AddGroup(B_HORIZONTAL)
.AddGlue()
.Add((fSaveButton = new BButton("Save",
new BMessage(MSG_SAVE_BREAKPOINT_SETTINGS))))
.Add((fCancelButton = new BButton("Cancel",
new BMessage(B_CANCEL))))
.End()
.End();
AutoLocker< ::Team> teamLocker(fTeam);
if (fTargetBreakpoint->HasCondition()) {
fConditionRadio->SetValue(B_CONTROL_ON);
fConditionInput->SetText(fTargetBreakpoint->Condition());
} else {
fAlwaysRadio->SetValue(B_CONTROL_ON);
fConditionInput->SetEnabled(false);
}
}
示例2: BMessage
NamePanel::NamePanel(const char* label, const char* text, BWindow* window,
BHandler* target, BMessage* message, const BSize& size)
:
Panel(BRect(B_ORIGIN, size), B_TRANSLATE("Name Panel"),
B_MODAL_WINDOW_LOOK, B_MODAL_SUBSET_WINDOW_FEEL,
B_ASYNCHRONOUS_CONTROLS | B_NOT_V_RESIZABLE
| B_AUTO_UPDATE_SIZE_LIMITS),
fWindow(window),
fTarget(target),
fMessage(message)
{
BButton* defaultButton = new BButton(B_TRANSLATE("OK"),
new BMessage(MSG_PANEL_OK));
BButton* cancelButton = new BButton(B_TRANSLATE("Cancel"),
new BMessage(MSG_PANEL_CANCEL));
fNameTC = new BTextControl(label, text, NULL);
BLayoutItem* inputItem = fNameTC->CreateTextViewLayoutItem();
inputItem->SetExplicitMinSize(
BSize(fNameTC->StringWidth("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"),
B_SIZE_UNSET));
BLayoutBuilder::Group<>(this, B_VERTICAL, 10)
.AddGlue()
// controls
.AddGroup(B_HORIZONTAL, 5)
.AddStrut(5)
// text control
.Add(fNameTC->CreateLabelLayoutItem())
.Add(inputItem)
.AddStrut(5)
.End()
.AddGlue()
// buttons
.AddGroup(B_HORIZONTAL, 5)
.AddGlue()
.Add(cancelButton)
.Add(defaultButton)
.AddStrut(5)
.End()
.AddGlue();
SetDefaultButton(defaultButton);
fNameTC->MakeFocus(true);
if (fWindow && fWindow->Lock()) {
fSavedTargetWindowFeel = fWindow->Feel();
if (fSavedTargetWindowFeel != B_NORMAL_WINDOW_FEEL)
fWindow->SetFeel(B_NORMAL_WINDOW_FEEL);
fWindow->Unlock();
}
AddToSubset(fWindow);
}
示例3: streamNodeSource
void
TFilePanel::RestoreState()
{
BNode defaultingNode;
if (DefaultStateSourceNode(kDefaultFilePanelTemplate, &defaultingNode,
false)) {
AttributeStreamFileNode streamNodeSource(&defaultingNode);
RestoreWindowState(&streamNodeSource);
PoseView()->Init(&streamNodeSource);
} else {
RestoreWindowState(NULL);
PoseView()->Init(NULL);
}
// Finish UI creation now that the PoseView is initialized
BLayoutItem* item
= fBorderedView->GroupLayout()->AddView(0, fPoseView->TitleView());
BSize minSize = item->MinSize();
BSize maxSize = item->MaxSize();
item->SetExplicitMinSize(BSize(minSize.Width(), kTitleViewHeight));
item->SetExplicitMaxSize(BSize(maxSize.Width(), kTitleViewHeight));
BRect rect(fBorderedView->Frame());
rect.right = rect.left + kCountViewWidth;
rect.top = rect.bottom + 1;
rect.bottom = rect.top + PoseView()->HScrollBar()->Bounds().Height() - 1;
PoseView()->CountView()->MoveTo(rect.LeftTop());
PoseView()->CountView()->ResizeTo(rect.Size());
PoseView()->CountView()->SetResizingMode(B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
fBackView->AddChild(PoseView()->CountView(), fBorderedView);
PoseView()->HScrollBar()->MoveBy(kCountViewWidth + 1, 0);
PoseView()->HScrollBar()->ResizeBy(-kCountViewWidth - 1, 0);
// The Be Book states that the BTitleView will have a name of "TitleView",
// and so some apps will try to grab it by that name and move it around.
// They don't need to, because resizing "PoseView" (really the BorderedView)
// will resize the BTitleView as well. So just create a dummy view here
// so that they don't get NULL when trying to find the view.
BView* dummyTitleView = new BView(BRect(), "TitleView", B_FOLLOW_NONE, 0);
fBackView->AddChild(dummyTitleView);
dummyTitleView->Hide();
}
示例4: font
void
PackageView::_InitView()
{
SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
float fontHeight = be_plain_font->Size();
rgb_color textColor = ui_color(B_PANEL_TEXT_COLOR);
BTextView* packageDescriptionView = new DescriptionTextView(
"package description", fontHeight * 13);
packageDescriptionView->SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
packageDescriptionView->SetText(fInfo.GetDescription());
packageDescriptionView->MakeEditable(false);
packageDescriptionView->MakeSelectable(false);
packageDescriptionView->SetFontAndColor(be_plain_font, B_FONT_ALL,
&textColor);
BScrollView* descriptionScrollView = new BScrollView(
"package description scroll view", packageDescriptionView,
0, false, true, B_NO_BORDER);
// Install type menu field
fInstallTypes = new BPopUpMenu(B_TRANSLATE("none"));
BMenuField* installType = new BMenuField("install_type",
B_TRANSLATE("Installation type:"), fInstallTypes);
// Install type description text view
fInstallTypeDescriptionView = new DescriptionTextView(
"install type description", fontHeight * 4);
fInstallTypeDescriptionView->MakeEditable(false);
fInstallTypeDescriptionView->MakeSelectable(false);
fInstallTypeDescriptionView->SetInsets(8, 0, 0, 0);
// Left inset needs to match BMenuField text offset
fInstallTypeDescriptionView->SetText(
B_TRANSLATE("No installation type selected"));
fInstallTypeDescriptionView->SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
BFont font(be_plain_font);
font.SetSize(ceilf(font.Size() * 0.85));
fInstallTypeDescriptionView->SetFontAndColor(&font, B_FONT_ALL,
&textColor);
BScrollView* installTypeScrollView = new BScrollView(
"install type description scroll view", fInstallTypeDescriptionView,
0, false, true, B_NO_BORDER);
// Destination menu field
fDestination = new BPopUpMenu(B_TRANSLATE("none"));
fDestField = new BMenuField("install_to", B_TRANSLATE("Install to:"),
fDestination);
fBeginButton = new BButton("begin_button", B_TRANSLATE("Begin"),
new BMessage(P_MSG_INSTALL));
BLayoutItem* typeLabelItem = installType->CreateLabelLayoutItem();
BLayoutItem* typeMenuItem = installType->CreateMenuBarLayoutItem();
BLayoutItem* destFieldLabelItem = fDestField->CreateLabelLayoutItem();
BLayoutItem* destFieldMenuItem = fDestField->CreateMenuBarLayoutItem();
float forcedMinWidth = be_plain_font->StringWidth("XXX") * 5;
destFieldMenuItem->SetExplicitMinSize(BSize(forcedMinWidth, B_SIZE_UNSET));
typeMenuItem->SetExplicitMinSize(BSize(forcedMinWidth, B_SIZE_UNSET));
BAlignment labelAlignment(B_ALIGN_RIGHT, B_ALIGN_VERTICAL_UNSET);
typeLabelItem->SetExplicitAlignment(labelAlignment);
destFieldLabelItem->SetExplicitAlignment(labelAlignment);
// Build the layout
BLayoutBuilder::Group<>(this, B_VERTICAL)
.Add(descriptionScrollView)
.AddGrid(B_USE_SMALL_SPACING, B_USE_DEFAULT_SPACING)
.Add(typeLabelItem, 0, 0)
.Add(typeMenuItem, 1, 0)
.Add(installTypeScrollView, 1, 1)
.Add(destFieldLabelItem, 0, 2)
.Add(destFieldMenuItem, 1, 2)
.End()
.AddGroup(B_HORIZONTAL)
.AddGlue()
.Add(fBeginButton)
.End()
.SetInsets(B_USE_DEFAULT_SPACING)
;
fBeginButton->MakeDefault(true);
}
示例5: BMessage
KeyRequestView()
:
BView("KeyRequestView", B_WILL_DRAW),
fPassword(NULL)
{
SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
BGroupLayout* rootLayout = new(std::nothrow) BGroupLayout(B_VERTICAL);
if (rootLayout == NULL)
return;
SetLayout(rootLayout);
BGridView* controls = new(std::nothrow) BGridView();
if (controls == NULL)
return;
BGridLayout* layout = controls->GridLayout();
float inset = ceilf(be_plain_font->Size() * 0.7);
rootLayout->SetInsets(inset, inset, inset, inset);
rootLayout->SetSpacing(inset);
layout->SetSpacing(inset, inset);
BStringView* label = new(std::nothrow) BStringView("keyringLabel",
B_TRANSLATE("Keyring:"));
if (label == NULL)
return;
int32 row = 0;
layout->AddView(label, 0, row);
fKeyringName = new(std::nothrow) BStringView("keyringName", "");
if (fKeyringName == NULL)
return;
layout->AddView(fKeyringName, 1, row++);
fPassword = new(std::nothrow) BTextControl(B_TRANSLATE("Password:"), "", NULL);
if (fPassword == NULL)
return;
BLayoutItem* layoutItem = fPassword->CreateTextViewLayoutItem();
layoutItem->SetExplicitMinSize(BSize(fPassword->StringWidth(
"0123456789012345678901234567890123456789") + inset,
B_SIZE_UNSET));
layout->AddItem(fPassword->CreateLabelLayoutItem(), 0, row);
layout->AddItem(layoutItem, 1, row++);
BGroupView* buttons = new(std::nothrow) BGroupView(B_HORIZONTAL);
if (buttons == NULL)
return;
fCancelButton = new(std::nothrow) BButton(B_TRANSLATE("Cancel"),
new BMessage(kMessageCancel));
buttons->GroupLayout()->AddView(fCancelButton);
buttons->GroupLayout()->AddItem(BSpaceLayoutItem::CreateGlue());
fUnlockButton = new(std::nothrow) BButton(B_TRANSLATE("Unlock"),
new BMessage(kMessageUnlock));
buttons->GroupLayout()->AddView(fUnlockButton);
BTextView* message = new(std::nothrow) BTextView("message");
message->SetText(B_TRANSLATE("An application wants to access the "
"keyring below, but it is locked with a passphrase. Please enter "
"the passphrase to unlock the keyring.\n"
"If you unlock the keyring, it stays unlocked until the system is "
"shut down or the keyring is manually locked again.\n"
"If you cancel this dialog the keyring will remain locked."));
message->SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
rgb_color textColor = ui_color(B_PANEL_TEXT_COLOR);
message->SetFontAndColor(be_plain_font, B_FONT_ALL, &textColor);
message->MakeEditable(false);
message->MakeSelectable(false);
message->SetWordWrap(true);
rootLayout->AddView(message);
rootLayout->AddView(controls);
rootLayout->AddView(buttons);
}
示例6: BMessage
ModifierKeysWindow::ModifierKeysWindow()
:
BWindow(BRect(0, 0, 360, 220), B_TRANSLATE("Modifier keys"),
B_FLOATING_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE
| B_AUTO_UPDATE_SIZE_LIMITS)
{
get_key_map(&fCurrentMap, &fCurrentBuffer);
get_key_map(&fSavedMap, &fSavedBuffer);
BStringView* keyRole = new BStringView("key role",
B_TRANSLATE_COMMENT("Role", "As in the role of a modifier key"));
keyRole->SetAlignment(B_ALIGN_RIGHT);
keyRole->SetFont(be_bold_font);
BStringView* keyLabel = new BStringView("key label",
B_TRANSLATE_COMMENT("Key", "As in a computer keyboard key"));
keyLabel->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));
keyLabel->SetFont(be_bold_font);
BMenuField* shiftMenuField = _CreateShiftMenuField();
shiftMenuField->SetAlignment(B_ALIGN_RIGHT);
BMenuField* controlMenuField = _CreateControlMenuField();
controlMenuField->SetAlignment(B_ALIGN_RIGHT);
BMenuField* optionMenuField = _CreateOptionMenuField();
optionMenuField->SetAlignment(B_ALIGN_RIGHT);
BMenuField* commandMenuField = _CreateCommandMenuField();
commandMenuField->SetAlignment(B_ALIGN_RIGHT);
fShiftConflictView = new ConflictView("shift warning view");
fShiftConflictView->SetExplicitMaxSize(BSize(15, 15));
fControlConflictView = new ConflictView("control warning view");
fControlConflictView->SetExplicitMaxSize(BSize(15, 15));
fOptionConflictView = new ConflictView("option warning view");
fOptionConflictView->SetExplicitMaxSize(BSize(15, 15));
fCommandConflictView = new ConflictView("command warning view");
fCommandConflictView->SetExplicitMaxSize(BSize(15, 15));
fCancelButton = new BButton("cancelButton", B_TRANSLATE("Cancel"),
new BMessage(B_QUIT_REQUESTED));
fRevertButton = new BButton("revertButton", B_TRANSLATE("Revert"),
new BMessage(kMsgRevertModifiers));
fRevertButton->SetEnabled(false);
fOkButton = new BButton("okButton", B_TRANSLATE("Set modifier keys"),
new BMessage(kMsgApplyModifiers));
fOkButton->MakeDefault(true);
// Build the layout
SetLayout(new BGroupLayout(B_VERTICAL));
float forcedMinWidth = be_plain_font->StringWidth("XXX") * 4;
keyRole->SetExplicitMinSize(BSize(forcedMinWidth, B_SIZE_UNSET));
BLayoutItem* shiftLabel = shiftMenuField->CreateLabelLayoutItem();
shiftLabel->SetExplicitMinSize(BSize(forcedMinWidth, B_SIZE_UNSET));
BLayoutItem* controlLabel = controlMenuField->CreateLabelLayoutItem();
controlLabel->SetExplicitMinSize(BSize(forcedMinWidth, B_SIZE_UNSET));
BLayoutItem* optionLabel = optionMenuField->CreateLabelLayoutItem();
optionLabel->SetExplicitMinSize(BSize(forcedMinWidth, B_SIZE_UNSET));
BLayoutItem* commandLabel = commandMenuField->CreateLabelLayoutItem();
commandLabel->SetExplicitMinSize(BSize(forcedMinWidth, B_SIZE_UNSET));
AddChild(BLayoutBuilder::Group<>(B_VERTICAL, B_USE_SMALL_SPACING)
.AddGroup(B_HORIZONTAL)
.Add(keyRole)
.Add(keyLabel)
.End()
.AddGroup(B_HORIZONTAL)
.Add(shiftLabel)
.Add(shiftMenuField->CreateMenuBarLayoutItem())
.Add(fShiftConflictView)
.End()
.AddGroup(B_HORIZONTAL)
.Add(controlLabel)
.Add(controlMenuField->CreateMenuBarLayoutItem())
.Add(fControlConflictView)
.End()
.AddGroup(B_HORIZONTAL)
.Add(optionLabel)
.Add(optionMenuField->CreateMenuBarLayoutItem())
.Add(fOptionConflictView)
.End()
.AddGroup(B_HORIZONTAL)
.Add(commandLabel)
.Add(commandMenuField->CreateMenuBarLayoutItem())
.Add(fCommandConflictView)
.End()
.AddGlue()
.AddGroup(B_HORIZONTAL)
.Add(fCancelButton)
.AddGlue()
.Add(fRevertButton)
.Add(fOkButton)
//.........这里部分代码省略.........
示例7: boldFont
//.........这里部分代码省略.........
*----------------------------------------------------------------*/
BRect tempRect( BPoint( 0, 0 ), size );
tempRect.right -= B_V_SCROLL_BAR_WIDTH;
fNoteText = new BTextView( tempRect,
"Notification text container",
tempRect.InsetByCopy( 1, 1 ),
B_FOLLOW_ALL_SIDES,
B_WILL_DRAW );
if ( !fNoteText ) {
/* Panic! */
fLastError = B_NO_MEMORY;
return;
}
fNoteText->MakeEditable( false );
fNoteText->SetText( tempString.String() );
/*-----------------------------------------------------------------
* Scroll view to scroll the notification text
*----------------------------------------------------------------*/
fTextScroller = new BScrollView( "Notification text scroller",
fNoteText,
B_FOLLOW_ALL_SIDES,
0,
false,
true );
if ( !fTextScroller ) {
/* Panic! */
fLastError = B_NO_MEMORY;
return;
}
layoutItem = gridLayout->AddView( fTextScroller, 0, nextLineInLayout++, numberOfColumnsInLayout, 1 );
if ( layoutItem ) {
// layoutItem->SetExplicitMaxSize( size );
layoutItem->SetExplicitMinSize( size );
layoutItem->SetExplicitPreferredSize( size );
layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_USE_FULL_WIDTH, B_ALIGN_USE_FULL_HEIGHT ) );
}
} // <-- end of adding information about the notification
/*================================================================
* If user wanted to play a sound file, notify him about it.
*================================================================*/
if ( fData->GetSound( &path ) )
{
/*-----------------------------------------------------------------
* Line of explanation
*----------------------------------------------------------------*/
exp = new BStringView( BRect( 0, 0, 1, 1 ),
"Sound file explanation",
"You wanted to play the file:",
B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP );
if ( !exp ) {
/* Panic! */
fLastError = B_NO_MEMORY;
return;
}
exp->ResizeToPreferred();
layoutItem = gridLayout->AddView( exp, 0, nextLineInLayout++, numberOfColumnsInLayout, 1 );
if ( layoutItem ) {
layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_CENTER, B_ALIGN_MIDDLE ) );
}
/*-----------------------------------------------------------------
* Display sound file name
*----------------------------------------------------------------*/
示例8: r
/*! \brief Constructor of CategoryPreferencesView
* \details It's a descendant of BView.
* \param[in] frame The frame rectangle of the view.
*/
CategoryPreferencesView::CategoryPreferencesView( BRect frame )
:
BView( frame,
"Category Preferences",
B_FOLLOW_ALL_SIDES,
B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE )
{
BLayoutItem* layoutItem = NULL;
BMessage* toSend = NULL;
menuField = NULL;
this->SetViewColor( ui_color( B_PANEL_BACKGROUND_COLOR ) );
/*! \note Layout of the view
* The view has a grid layout. It's arranged in the following way:
* 1) Left column - list of Categories (CategoryList) that
* contains all categories currently available.
* 2) Right column - three buttons, from top to bottom:
* 2a) Edit currently selected category - guess what it's doing
* 2b) Add a new category
* 2c) Merge a current directory into another one + menu with
* all categories. The category selected in the list is disabled.
* \note Restrictions:
* a) The list of categories is scrolled.
* b) If no category is selected, then
* i) "Edit" button is disabled
* ii) "Merge to" field is disabled
*
*/
BGridLayout* gridLayout = new BGridLayout();
if ( !gridLayout )
{
/* Panic! */
exit( 1 );
}
// Margins from the sides of the view and spacing between the elements
gridLayout->SetInsets( 5, 5, 5, 5 );
gridLayout->SetHorizontalSpacing( 10 );
gridLayout->SetVerticalSpacing( 10 );
this->SetLayout( gridLayout );
gridLayout->SetExplicitAlignment( BAlignment( B_ALIGN_USE_FULL_WIDTH, B_ALIGN_USE_FULL_HEIGHT ) );
gridLayout->SetExplicitMinSize( BSize( (this->Bounds()).Width(), (this->Bounds()).Height() ) );
BRect rect = gridLayout->Frame();
printf ( "The frame is %d pixels wide and %d pixels high.\n",
(int )rect.Width(),
(int )rect.Height() );
/* Creating the CategoryListView with its scroller */
BRect r( this->Bounds() );
r.InsetBySelf( 5, 10 ); // Margins near the border of the view
r.right = (int)(r.right / 2) - B_V_SCROLL_BAR_WIDTH;
r.bottom -= 0;
listView = new CategoryListView( r, "List View" );
if ( ! listView ) {
/* Panic! */
exit( 1 );
}
BLooper* looper = this->Looper();
if ( looper && looper->LockLooper() )
{
looper->AddHandler( ( BHandler* )this );
looper->UnlockLooper();
}
scroller = new BScrollView( "Scroller",
listView,
B_FOLLOW_LEFT | B_FOLLOW_TOP,
0, // Flags
true,
true );
if ( !scroller )
{
/* Panic! */
exit( 1 );
}
layoutItem = gridLayout->AddView( scroller, 0, 0, 1, 3 );
if ( !layoutItem ) {
/* Panic! */
exit( 1 );
}
layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_LEFT,
B_ALIGN_USE_FULL_HEIGHT ) );
toSend = new BMessage( kCategoryInvoked );
if ( !toSend )
{
/* Panic! */
exit( 1 );
}
listView->SetInvocationMessage( toSend );
toSend = new BMessage( kCategorySelected );
if ( !toSend )
{
//.........这里部分代码省略.........