本文整理汇总了C++中BPopUpMenu::SetLabelFromMarked方法的典型用法代码示例。如果您正苦于以下问题:C++ BPopUpMenu::SetLabelFromMarked方法的具体用法?C++ BPopUpMenu::SetLabelFromMarked怎么用?C++ BPopUpMenu::SetLabelFromMarked使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BPopUpMenu
的用法示例。
在下文中一共展示了BPopUpMenu::SetLabelFromMarked方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateMonthsMenu
/*!
* \brief Internal function that creates a menu with month names.
* \param[in] listOfMonths List of months for a given year.
* \returns The created BMenu.
* \remarks Deletion and deallocation of the created menu is in
* responcibility of the caller.
*/
BPopUpMenu* CalendarControl::CreateMonthsMenu( map<int, DoubleNames> &listOfMonths )
{
BMessage* message = NULL;
BMenuItem* item = NULL;
BString monthName;
BPopUpMenu* toReturn = new BPopUpMenu("Months list");
if (!toReturn) {
/* Panic! */
fLastError = B_NO_MEMORY;
return NULL;
}
toReturn->SetLabelFromMarked(true);
toReturn->SetRadioMode(true);
BFont font(be_plain_font);
toReturn->SetFont(&font, B_FONT_FAMILY_AND_STYLE);
int limit = listOfMonths.size();
for (int i = 1; i <= limit; ++i ) {
message = new BMessage( kMonthChanged );
if ( !message ) {
/* Panic! */
fLastError = B_NO_MEMORY;
return NULL;
}
if ( B_OK != message->AddInt8( "Month", ( int8 )i ) ) { //< Number of selected month in the year
// Panic!
exit(5);
}
monthName = listOfMonths[ i ].longName;
item = new BMenuItem( monthName.String(), message );
if (!item) {
/* Panic! */
fLastError = B_NO_MEMORY;
return NULL;
}
if ( i == this->fRepresentedTime.tm_mon )
{
item->SetMarked(true);
}
toReturn->AddItem(item);
}
UpdateTargets( toReturn );
return toReturn;
}
示例2: CreateYearsMenu
/*!
* \brief
* \param[in] year The current year
* \returns The created BMenu.
* \remarks It's up to the caller to delete this menu!
*/
BPopUpMenu* CalendarControl::CreateYearsMenu( int yearIn )
{
BPopUpMenu* toReturn = new BPopUpMenu("Years list");
BMessage* message = NULL;
BMenuItem* item = NULL;
BString yearName;
if (!toReturn) {
/* Panic! */
fLastError = B_NO_MEMORY;
return NULL;
}
toReturn->SetLabelFromMarked(true);
toReturn->SetRadioMode(true);
for ( int i = yearIn - YEARS_UP_AND_DOWN;
i <= yearIn + YEARS_UP_AND_DOWN;
++i )
{
message = new BMessage( kYearChanged );
if ( !message )
{
/* Panic! */
fLastError = B_NO_MEMORY;
return NULL;
}
if ( B_OK != message->AddInt32( "Year", i ) )
{
exit(5);
}
yearName.Truncate( 0 );
yearName << i;
item = new BMenuItem( yearName.String(), message );
if ( !item ) {
/* Panic! */
fLastError = B_NO_MEMORY;
return NULL;
}
item->SetTarget( this );
if ( i == yearIn ) {
item->SetMarked( true );
}
toReturn->AddItem( item );
}
UpdateTargets( toReturn );
return toReturn;
} // <-- end of function CalendarControl::CreateYearsMenu