本文整理汇总了C++中BGridLayout::SetVerticalSpacing方法的典型用法代码示例。如果您正苦于以下问题:C++ BGridLayout::SetVerticalSpacing方法的具体用法?C++ BGridLayout::SetVerticalSpacing怎么用?C++ BGridLayout::SetVerticalSpacing使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BGridLayout
的用法示例。
在下文中一共展示了BGridLayout::SetVerticalSpacing方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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 )
{
//.........这里部分代码省略.........
示例2: DebuggerPrintout
/*!
* \brief Create box for selection of the weekend days
* \note Additionally, select the color for weekends and weekdays
* \param[in] frame Enclosing rectangle.
* \param[in] id Reference to name of the selected Calendar module.
* \returns Pointer to all-set-up BBox. Or NULL in case of error.
*/
BBox* CalendarModulePreferencesView::CreateWeekendSelectionBox( BRect frame,
const BString &id )
{
/*! \par Notes on implementation:
* It's not all that straightforward - to create this selection box.
* The problem is that number of days in week is dependent on the
* Calendar Module, therefore the frame rectangle must be divided
* properly. We should take into account the possibility that there's
* not enough place for all days in the submitted frame.
*
* \par
* The solution will be as follows:
* Let number of days in week be N. I create two columns and
* several rows (the number depends on N). Days in week will be
* proceeded in the order <em>as Calendar Module supplies them</em>.
* The days occupy both columns, and are located in rows
* [0, (ceiling of (N/2)) ). Days returned from CalendarModule are
* placed as follows: days from 0 to (ceiling of (N/2)-1) in the left
* column, days from (ceiling of (N/2)-1) to (N-1) in right column.
*
* \par
* There will be an empty cell in the right column, if number
* of days in week is odd, (which is usually the case).
*/
frame.InsetBySelf( 5, 0 );
BMessage* toSend = NULL;
BCheckBox* dayCheckBox = NULL;
BString tempString;
BLayoutItem* layoutItem = NULL;
CalendarModulePreferences* prefs = NULL;
CalendarModule* calModule = NULL;
int height = 0; //!< this is used to resize the BBox to proper size
calModule = utl_FindCalendarModule( id );
if ( calModule == NULL ) {
/* Error */
utl_Deb = new DebuggerPrintout( "Did not succeed to find the calendar module." );
return NULL;
}
// Get the data on days of week
uint32 daysInWeek = ( uint32 )( calModule->GetDaysInWeek() );
map<uint32, DoubleNames> weekdayNames = calModule->GetWeekdayNames();
/* Obtain the current Calendar Module preferences */
prefs = pref_GetPreferencesForCalendarModule( id );
if ( !prefs ) {
utl_Deb = new DebuggerPrintout( "Did not succeed to find the preferences for the calendar module." );
return NULL;
}
// At this point, "pref" points to current preferences of this calendar module.
BList* weekends = prefs->GetWeekends(); // Get info on currently selected weekends
// Prepare the item to be returned
BBox* enclosingBox = new BBox( frame, "Weekend selector" );
if ( !enclosingBox )
{
/* Panic! */
exit(1);
}
enclosingBox->SetLabel( "Select the non-working days (weekends)" );
// Prepare the layout to be used
BGridLayout* layout = new BGridLayout();
if ( !layout)
{
/* Panic! */
exit(1);
}
enclosingBox->SetLayout( layout );
layout->SetInsets( 10, 15, 10, 5 );
layout->SetVerticalSpacing( 1 );
/* indexX is 0 for left column or 1 for right column.
* indexY is 0 for topmost row, 1 for second from top row, etc.
* Max value for indexY = (ceiling of (N/2)).
*/
int indexX = 0, indexY = 0;
for (uint32 day = prefs->GetFirstDayOfWeek(), i = 0; i < ( uint32 )daysInWeek; ++i )
{
/* Creating the message to be sent */
toSend = new BMessage( kCalendarModuleWeekendDaySelected );
if ( !toSend )
{
/* Panic! */
exit(1);
}
toSend->AddInt32( "Weekday const", day );
toSend->AddString( "Calendar module", id );
//.........这里部分代码省略.........