本文整理汇总了C++中BGridLayout::SetColumnWeight方法的典型用法代码示例。如果您正苦于以下问题:C++ BGridLayout::SetColumnWeight方法的具体用法?C++ BGridLayout::SetColumnWeight怎么用?C++ BGridLayout::SetColumnWeight使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BGridLayout
的用法示例。
在下文中一共展示了BGridLayout::SetColumnWeight方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: r
//.........这里部分代码省略.........
layoutItem->SetExplicitMinSize( BSize( ( B_V_SCROLL_BAR_WIDTH * 2 ), r.Height() ) );
gridLayout->SetMaxColumnWidth( 0, r.Width()-70 );
gridLayout->SetMaxColumnWidth( 1, r.Width()-66 );
// Add categories to the list
PopulateCategoriesView();
/* Creating the buttons */
// Add new category button
toSend = new BMessage( kAddNewCategory );
addButton = new BButton( BRect( 0, 0, 1, 1),
"Add category",
"Add category",
toSend,
B_FOLLOW_H_CENTER | B_FOLLOW_V_CENTER );
if ( !toSend || !addButton ) {
/* Panic! */
exit( 1 );
}
addButton->ResizeToPreferred();
addButton->SetTarget( this );
layoutItem = gridLayout->AddView( addButton, 1, 0, 1, 1 );
layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_HORIZONTAL_CENTER, B_ALIGN_VERTICAL_CENTER ) );
// Edit old category button
toSend = new BMessage( kCategoryInvoked );
editButton = new BButton( BRect( 0, 0, 1, 1),
"Edit category",
"Edit category",
toSend,
B_FOLLOW_H_CENTER | B_FOLLOW_V_CENTER );
if ( !toSend || !editButton ) {
/* Panic! */
exit( 1 );
}
editButton->ResizeToPreferred();
editButton->SetTarget( this );
layoutItem = gridLayout->AddView( editButton, 1, 1, 1, 1 );
layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_HORIZONTAL_CENTER, B_ALIGN_VERTICAL_CENTER ) );
// Edit category button is disabled by default;
// it's enabled when user chooses a category in the list.
editButton->SetEnabled( false );
/* Creating the menu of merging a category */
// Create a label
BGroupLayout* groupLayout = new BGroupLayout( B_VERTICAL );
if ( !groupLayout )
{
/* Panic! */
exit( 1 );
}
gridLayout->AddItem( groupLayout, 1, 2, 1, 1 );
groupLayout->SetExplicitAlignment( BAlignment( B_ALIGN_LEFT, B_ALIGN_TOP ) );
mergeToLabel = new BStringView( BRect( 0, 0, 1, 1 ),
"Merge to label",
"Merge selected category into:" );
if ( !mergeToLabel ) {
/* Panic! */
exit( 1 );
}
mergeToLabel->ResizeToPreferred();
layoutItem = groupLayout->AddView( mergeToLabel );
layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_LEFT, B_ALIGN_TOP ) );
// Create the menu
BMessage templateMessage( kMergeIntoCategory );
listMenu = new CategoryMenu( "Select category to merge to:", true, &templateMessage );
if ( !listMenu )
{
/* Panic! */
exit( 1 );
}
menuField = new BMenuField( mergeToLabel->Bounds(),
"Merge to field",
NULL,
listMenu );
if ( !menuField ) {
/* Panic! */
exit( 1 );
}
menuField->SetDivider( 0 );
// Just like the "Edit" button above, the menu is initially disabled.
menuField->SetEnabled( false );
layoutItem = groupLayout->AddView( menuField );
layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_USE_FULL_WIDTH, B_ALIGN_TOP ) );
for ( int index = 0; index < gridLayout->CountColumns(); ++index )
{
gridLayout->SetColumnWeight( index, 1 );
}
for ( int index = 0; index < gridLayout->CountRows(); ++index )
{
gridLayout->SetRowWeight( index, 1 );
}
gridLayout->InvalidateLayout();
} // <-- end of constructor of CategoryPreferencesView
示例2: size
//.........这里部分代码省略.........
/* Panic! */
fLastError = B_NO_MEMORY;
return;
}
fCalendarModuleLabel = new BStringView( BRect( 0, 0, 1, 1 ),
"label for the calendar module selector",
"Calendar:" );
if ( !fCalendarModuleLabel ) {
/* Panic! */
fLastError = B_NO_MEMORY;
return;
}
fCalendarModuleLabel->ResizeToPreferred();
fCalendarsMenu = CreateMenuOfCalendarModules();
if ( !fCalendarsMenu ) {
/* Panic! */
fLastError = B_NO_MEMORY;
return;
}
fCalendarModuleSelector = new BMenuField( BRect( 0, 0, 1, 1 ),
"calendar module selector",
NULL, // Label is created separately
fCalendarsMenu );
if ( !fCalendarModuleSelector ) {
/* Panic! */
fLastError = B_NO_MEMORY;
return;
}
fCalendarModuleSelector->ResizeToPreferred();
// Create the menu
CreateMenu();
BRect stringViewFrame = fLabel->Frame();
BPoint topLeftCorner = stringViewFrame.RightTop();
BSize size( BUTTON_WIDTH, stringViewFrame.Height() + SPACING );
fMenuBar = new BMenuBar( BRect(topLeftCorner, size),
"menuBar",
B_FOLLOW_RIGHT | B_FOLLOW_TOP,
B_ITEMS_IN_ROW,
false);
if (! fMenuBar) {
// Panic!
fLastError = B_NO_MEMORY;
return;
}
fMenuBar->SetBorder( B_BORDER_EACH_ITEM );
fMenuBar->AddItem( fDateSelector );
// Update the selected date label to currently selected moment of time
UpdateText();
// Initializing the layout
BGridLayout* lay = new BGridLayout( );
if (!lay) {
// Panic!
fLastError = B_NO_MEMORY;
return;
}
lay->SetInsets(0, 5, 0, 0);
lay->SetSpacing( 10, 5 );
lay->SetExplicitAlignment( BAlignment( B_ALIGN_USE_FULL_WIDTH, B_ALIGN_MIDDLE ) );
this->SetLayout(lay);
BLayoutItem* layoutItem;
layoutItem = lay->AddView( fLabel, 0, 0 );
layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_LEFT, B_ALIGN_TOP ) );
layoutItem = lay->AddView( fDateLabel, 1, 0 );
layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_USE_FULL_WIDTH, B_ALIGN_TOP ) );
layoutItem = lay->AddView( fMenuBar, 2, 0 );
layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_RIGHT, B_ALIGN_TOP ) );
layoutItem->SetExplicitMaxSize( size );
layoutItem = lay->AddView( fCalendarModuleLabel, 0, 1 );
layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_LEFT, B_ALIGN_MIDDLE ) );
layoutItem = lay->AddView( fCalendarModuleSelector, 1, 1 );
layoutItem->SetExplicitAlignment( BAlignment( B_ALIGN_USE_FULL_WIDTH, B_ALIGN_TOP ) );
lay->SetColumnWeight( 0, 0 );
lay->SetColumnWeight( 1, 1000 );
lay->SetColumnWeight( 2, 0 );
lay->SetMaxColumnWidth( 2, BUTTON_WIDTH );
this->InvalidateLayout();
this->Relayout();
this->Invalidate();
fLastError = B_OK;
}