本文整理汇总了C++中BMenu::SetLabelFromMarked方法的典型用法代码示例。如果您正苦于以下问题:C++ BMenu::SetLabelFromMarked方法的具体用法?C++ BMenu::SetLabelFromMarked怎么用?C++ BMenu::SetLabelFromMarked使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BMenu
的用法示例。
在下文中一共展示了BMenu::SetLabelFromMarked方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BMenu
Window::Window()
:
BWindow(BRect(100, 100, 620, 200), "Alert-Test", B_TITLED_WINDOW,
B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS)
{
BMenu* sizeMenu = new BMenu("Button size");
sizeMenu->SetLabelFromMarked(true);
sizeMenu->SetRadioMode(true);
sizeMenu->AddItem(new BMenuItem("As usual", NULL));
sizeMenu->AddItem(new BMenuItem("From widest", NULL));
sizeMenu->AddItem(new BMenuItem("From label", NULL));
sizeMenu->ItemAt(0)->SetMarked(true);
fSizeField = new BMenuField("Button size", sizeMenu);
BMenu* typeMenu = new BMenu("Alert type");
typeMenu->SetLabelFromMarked(true);
typeMenu->SetRadioMode(true);
typeMenu->AddItem(new BMenuItem("Empty", NULL));
typeMenu->AddItem(new BMenuItem("Info", NULL));
typeMenu->AddItem(new BMenuItem("Idea", NULL));
typeMenu->AddItem(new BMenuItem("Warning", NULL));
typeMenu->AddItem(new BMenuItem("Stop", NULL));
typeMenu->ItemAt(0)->SetMarked(true);
fTypeField = new BMenuField("Alert type", typeMenu);
BMenu* spacingMenu = new BMenu("Button spacing");
spacingMenu->SetLabelFromMarked(true);
spacingMenu->SetRadioMode(true);
spacingMenu->AddItem(new BMenuItem("Even", NULL));
spacingMenu->AddItem(new BMenuItem("Offset", NULL));
spacingMenu->ItemAt(0)->SetMarked(true);
fSpacingField = new BMenuField("Button spacing", spacingMenu);
fCountSlider = new BSlider("count", "Button count", NULL, 1, 3,
B_HORIZONTAL);
fCountSlider->SetValue(3);
fCountSlider->SetLimitLabels("1", "3");
fCountSlider->SetHashMarkCount(3);
fCountSlider->SetHashMarks(B_HASH_MARKS_BOTTOM);
fLastStringView = new BStringView("last pressed", "");
fLastStringView->SetAlignment(B_ALIGN_CENTER);
BButton* button = new BButton("Show alert", new BMessage(kMsgShowAlert));
BLayoutBuilder::Group<>(this, B_VERTICAL)
.Add(fSizeField)
.Add(fTypeField)
.Add(fSpacingField)
.Add(fCountSlider)
.AddGlue()
.Add(fLastStringView)
.Add(button)
.SetInsets(B_USE_DEFAULT_SPACING);
CenterOnScreen();
SetFlags(Flags() | B_CLOSE_ON_ESCAPE);
}
示例2: Bounds
/***********************************************************
* InitGUI
***********************************************************/
void
HCriteriaView::InitGUI()
{
BRect rect = Bounds();
rect.left += 5;
rect.top += 2;
rect.right = rect.left + 80;
BMenu *menu = new BMenu("menu");
menu->AddItem(new BMenuItem(_("Subject"),NULL));
menu->AddItem(new BMenuItem(_("To"),NULL));
menu->AddItem(new BMenuItem(_("From"),NULL));
menu->AddItem(new BMenuItem(_("Cc"),NULL));
menu->AddItem(new BMenuItem(_("Reply-To"),NULL));
menu->AddItem(new BMenuItem(_("Account"),NULL));
menu->ItemAt(0)->SetMarked(true);
menu->SetRadioMode(true);
menu->SetLabelFromMarked(true);
fAttrMenu = new BMenuField(rect,"attr","",menu);
fAttrMenu->SetDivider(0);
AddChild(fAttrMenu);
rect.OffsetBy(80,0);
menu = new BMenu("menu");
menu->AddItem(new BMenuItem(_("contains"),NULL));
menu->AddItem(new BMenuItem(_("is"),NULL));
menu->AddItem(new BMenuItem(_("begin with"),NULL));
menu->AddItem(new BMenuItem(_("end with"),NULL));
menu->ItemAt(0)->SetMarked(true);
menu->SetRadioMode(true);
menu->SetLabelFromMarked(true);
fOpMenu = new BMenuField(rect,"op","",menu);
fOpMenu->SetDivider(0);
AddChild(fOpMenu);
rect.OffsetBy(80,2);
rect.right= Bounds().right - 70;
fValue = new BTextControl(rect,"value","","",NULL);
fValue->SetDivider(0);
AddChild(fValue);
rect.right = Bounds().right - 5;
rect.left = Bounds().right - 65;
menu = new BMenu("operator");
menu->AddItem(new BMenuItem(_("and"),NULL));
menu->AddItem(new BMenuItem(_("or"),NULL));
menu->ItemAt(0)->SetMarked(true);
menu->SetRadioMode(true);
menu->SetLabelFromMarked(true);
fOp2Menu= new BMenuField(rect,"op2","",menu);
fOp2Menu->SetDivider(0);
AddChild(fOp2Menu);
}
示例3: FTSetFont
// ----------------------------------------------------------------------- RHTML_Preferences_Win - FTSetFont -
void RHTMLPreferencesWin::FTSetFont(const char *font,const char *style ="")
{
fFTFontsBox->RemoveChild(fFTDFStyle);
font_family fFamily;
font_style fStyle;
BMenu *fSMenu;
strcpy(fFamily,font);
int32 styleNum = count_font_styles(fFamily);
if (style!="")
{
fSMenu = new BMenu(fOptions->GetLocaleString("Preferences_Window_FileTypes",style));
} else
if (styleNum>0)
{
get_font_style(fFamily, 0, &fStyle);
fSMenu = new BMenu(fOptions->GetLocaleString("Preferences_Window_FileTypes",fStyle));
} else fSMenu = new BMenu("");
fSMenu->SetRadioMode(false);
fSMenu->SetLabelFromMarked(true);
for (int32 ii = 0; ii < styleNum; ii++)
{
get_font_style(fFamily, ii, &fStyle);
BMessage* msg = new BMessage('FTFS');
msg->AddString("font_style", fStyle);
fSMenu->AddItem(new BMenuItem(fOptions->GetLocaleString("Preferences_Window_FileTypes",fStyle),msg));
}
fFTDFStyle= new BMenuField(BRect(10,45,180,75),"Font Style",fOptions->GetLocaleString("Preferences_Window_FileTypes","Style"),fSMenu);
fFTDFStyle->SetDivider(60);
fFTFontsBox->AddChild(fFTDFStyle);
}
示例4: r
S9xRefreshWindow::S9xRefreshWindow(BRect rect, BWindow *parent, uint32 closemsg)
: BWindow(rect, "FullScreen - Refresh Rate", B_FLOATING_WINDOW, B_NOT_ZOOMABLE | B_NOT_RESIZABLE),
fWindow(parent),
fS9xMsg(closemsg)
{
display_mode *modes;
uint32 mode_count;
if(BScreen().GetModeList(&modes, &mode_count) == B_NO_ERROR) {
BMenu *menu = new BMenu("menu");
for(unsigned int i = 0; i < mode_count; i++) {
// if((modes[i].virtual_width == 640) && (modes[i].space == B_RGB16)) {
BMessage *msg = new BMessage(ID_REFRESH);
msg->AddPointer("refr_rate", (void *)&modes[i]);
BString item_name;
item_name << (modes[i].timing.pixel_clock * 1000)
/ (modes[i].timing.h_total * modes[i].timing.v_total) << " Hz";
menu->AddItem(new BMenuItem(item_name.String(), msg));
// }
}
BRect r(20, 20, 200, 60);
BMenuField *field = new BMenuField(r, "field", "Refresh Rate:", menu);
AddChild(field);
menu->SetLabelFromMarked(true);
menu->ItemAt(0)->SetMarked(true);
menu->SetTargetForItems(fWindow);
}
Show();
}
示例5: new_menu
static BMenu* new_menu()
{
BMenu* m = new BMenu("program menu");
if( !m ) return 0;
m->SetLabelFromMarked( true );
return m;
}
示例6: new_bank_menu
static BMenu* new_bank_menu()
{
BMenu* m = new BMenu("bank menu");
if( !m ) return 0;
m->SetLabelFromMarked( true );
return m;
}
示例7: BMenu
/*! \brief Creates list of all Calendar Modules in the system.
* \attention It is assumed that \c global_ListOfCalendarModules is set up
* before constructing this control.
*/
BMenu* CalendarControl::CreateMenuOfCalendarModules()
{
BMenu* toReturn = new BMenu( "Calendar Modules" , B_ITEMS_IN_COLUMN );
if ( !toReturn ) { return NULL; }
toReturn->SetRadioMode( true );
toReturn->SetLabelFromMarked( true );
BMenuItem* item;
BMessage* toSend;
BString tempNameOfModule;
CalendarModule* module;
// Fill the menu
for ( int i = 0; i < NUMBER_OF_CALENDAR_MODULES; ++i ) {
module = ( CalendarModule* )global_ListOfCalendarModules.ItemAt( i );
if ( !module ) { continue; }
tempNameOfModule.SetTo( module->Identify() );
toSend = new BMessage( kCalendarModuleChosen );
if ( !toSend ) { continue; }
toSend->AddString( "Name of calendar module", tempNameOfModule );
item = new BMenuItem( tempNameOfModule.String(), toSend );
if ( !item ) { continue; }
toReturn->AddItem( item );
if ( tempNameOfModule == fRepresentedTime.GetCalendarModule() ) {
item->SetMarked( true );
}
}
return toReturn;
} // <-- end of function CalendarControl::CreateMenuOfCalendarModules
示例8: BMessage
void
HWindow::_InitGUI()
{
fEventList = new HEventList();
fEventList->SetType(BMediaFiles::B_SOUNDS);
fEventList->SetSelectionMode(B_SINGLE_SELECTION_LIST);
BMenu* menu = new BMenu("file");
menu->SetRadioMode(true);
menu->SetLabelFromMarked(true);
menu->AddSeparatorItem();
menu->AddItem(new BMenuItem(B_TRANSLATE("<none>"),
new BMessage(M_NONE_MESSAGE)));
menu->AddItem(new BMenuItem(B_TRANSLATE("Other" B_UTF8_ELLIPSIS),
new BMessage(M_OTHER_MESSAGE)));
BString label(B_TRANSLATE("Sound file:"));
BMenuField* menuField = new BMenuField("filemenu", label, menu);
menuField->SetDivider(menuField->StringWidth(label) + 10);
BSize buttonsSize(be_plain_font->Size() * 2.5, be_plain_font->Size() * 2.5);
BButton* stopbutton = new BButton("stop", "\xE2\x96\xA0",
new BMessage(M_STOP_MESSAGE));
stopbutton->SetEnabled(false);
stopbutton->SetExplicitSize(buttonsSize);
// We need at least one view to trigger B_PULSE_NEEDED events which we will
// intercept in DispatchMessage to trigger the buttons enabling or disabling.
stopbutton->SetFlags(stopbutton->Flags() | B_PULSE_NEEDED);
BButton* playbutton = new BButton("play", "\xE2\x96\xB6",
new BMessage(M_PLAY_MESSAGE));
playbutton->SetEnabled(false);
playbutton->SetExplicitSize(buttonsSize);
BLayoutBuilder::Group<>(this, B_VERTICAL)
.SetInsets(B_USE_WINDOW_SPACING)
.Add(fEventList)
.AddGroup(B_HORIZONTAL)
.Add(menuField)
.AddGroup(B_HORIZONTAL, 0)
.Add(playbutton)
.Add(stopbutton)
.End()
.End();
// setup file menu
_SetupMenuField();
BMenuItem* noneItem = menu->FindItem(B_TRANSLATE("<none>"));
if (noneItem != NULL)
noneItem->SetMarked(true);
_UpdateZoomLimits();
}
示例9: new_device_control
static BMenuField* new_device_control(BRect f)
{
BMenu* menu = new BMenu("device_menu");
if (!menu) return NULL;
menu->SetLabelFromMarked(true);
menu->SetRadioMode(true);
add_device_menu_items(menu);
BMenuField* field = new BMenuField(f, "device_field", "Device:", menu, B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
if (!field) {
delete menu;
return NULL;
}
return field;
}
示例10: FTHSetFSize
// --------------------------------------------------------------------- RHTML_Preferences_Win - FTHSetFSize -
void RHTMLPreferencesWin::FTHSetFSize(uint FontColor)
{
fFTHFontBox->RemoveChild(fFTHStyle);
font_family fFamily;
font_style fStyle;
BMessage *msg;
// - Style
BMenu *fStyleMenu;
fOptions->DefaultFont->GetFamilyAndStyle(&fFamily,&fStyle);
int32 styleNum = count_font_styles(fFamily);
if (fOptions->FileTypes[fFTHFileTypes]->Font[FontColor]->Style.ICompare("Default style")==0)
{
fStyleMenu = new BMenu(fOptions->GetLocaleString("Preferences_Window_FileTypes","Default style"));
} else
fStyleMenu = new BMenu(fOptions->GetLocaleString("Preferences_Window_FileTypes",fOptions->FileTypes[fFTHFileTypes]->Font[FontColor]->Style.String()));
fStyleMenu->SetRadioMode(false);
fStyleMenu->SetLabelFromMarked(true);
msg = new BMessage(R_FTH_Style_MSG);
msg->AddString("font_style","Default style");
fStyleMenu->AddItem(new BMenuItem(fOptions->GetLocaleString("Preferences_Window_FileTypes","Default style"),msg));
for (int32 ii = 0; ii < styleNum; ii++)
{
get_font_style(fFamily, ii, &fStyle);
msg = new BMessage(R_FTH_Style_MSG);
msg->AddString("font_style", fStyle);
fStyleMenu->AddItem(new BMenuItem(fOptions->GetLocaleString("Preferences_Window_FileTypes",fStyle),msg));
}
fFTHStyle= new BMenuField(BRect(10,15,210,40),"Style",fOptions->GetLocaleString("Preferences_Window_FileTypes","Style"),fStyleMenu);
fFTHStyle->SetDivider(80);
fFTHFontBox->AddChild(fFTHStyle);
// - Color
rgb_color rgb;
rgb.alpha=fOptions->FileTypes[fFTHFileTypes]->Color[FontColor]->alpha;
rgb.red=fOptions->FileTypes[fFTHFileTypes]->Color[FontColor]->red;
rgb.green=fOptions->FileTypes[fFTHFileTypes]->Color[FontColor]->green;
rgb.blue=fOptions->FileTypes[fFTHFileTypes]->Color[FontColor]->blue;
fFTHCC->SetValue(rgb);
}
示例11: inherited
/*******************************************************
* ARP-FONT-CONTROL
*******************************************************/
ArpFontControl::ArpFontControl( BRect frame,
const char* name,
const BString16* label,
uint32 message,
float divider)
: inherited(frame, name, 0, new BMessage(message),
B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP, B_WILL_DRAW),
mFontCtrl(0), mSizeCtrl(0), mMsgWhat(message)
{
if (label) {
if (divider <= 0) divider = StringWidth(label);
BRect f(0, 0, divider, frame.Height());
BStringView* sv = new BStringView(f, "sv", label);
if (sv) AddChild(sv);
}
float sizeW = StringWidth("000") + 5;
float sizeL = frame.Width() - sizeW;
BRect f(divider + 1, 0, sizeL - 1, frame.Height());
mFontCtrl = new BMenuField(f, "fonts", 0, new BMenu("font"), true,
B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
if (!mFontCtrl) return;
mFontCtrl->SetDivider(0);
BMenu* m = mFontCtrl->Menu();
if (m) {
m->SetLabelFromMarked(true);
_ArpFontControlFamilies families(m);
families.ForEach();
}
AddChild(mFontCtrl);
float iH = float(Prefs().GetInt32(ARP_INTCTRL_Y));
float iT = 0, iB = frame.Height();
if (iH < frame.Height()) {
iT = (frame.Height() - iH) / 2;
iB = iT + iH;
}
f.Set(sizeL, iT, sizeL + sizeW, iB);
mSizeCtrl = new ArpIntControl( f, "size", 0, new BMessage(SIZE_IMSG),
B_FOLLOW_RIGHT | B_FOLLOW_TOP);
if (mSizeCtrl) {
mSizeCtrl->SetLimits(1, 512);
AddChild(mSizeCtrl);
}
}
示例12: BMenu
/*static*/ BMenu*
AppearancePrefView::_MakeFontSizeMenu(const char* label, uint32 command,
const char* family, const char* style, const char* size)
{
BMenu* menu = new BMenu(label);
menu->SetRadioMode(true);
menu->SetLabelFromMarked(false);
int32 sizes[] = {
8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 28, 32, 36, 0
};
bool found = false;
for (uint32 i = 0; sizes[i]; i++) {
BString fontSize;
fontSize << sizes[i];
BMessage* message = new BMessage(command);
message->AddString("font_family", family);
message->AddString("font_style", style);
message->AddString("font_size", fontSize.String());
BMenuItem* item = new BMenuItem(fontSize.String(), message);
menu->AddItem(item);
if (sizes[i] == atoi(size)) {
item->SetMarked(true);
found = true;
}
}
if (!found) {
for (uint32 i = 0; sizes[i]; i++) {
if (sizes[i] > atoi(size)) {
BMessage* message = new BMessage(command);
message->AddString("font_family", family);
message->AddString("font_style", style);
message->AddString("font_size", size);
BMenuItem* item = new BMenuItem(size, message);
item->SetMarked(true);
menu->AddItem(item, i);
break;
}
}
}
return menu;
}
示例13: BMessage
OpenGLView::OpenGLView()
:
BGroupView("OpenGLView", B_VERTICAL)
{
BGLView* glView = new BGLView(BRect(0, 0, 1, 1), "gl info", B_FOLLOW_NONE, 0,
BGL_RGB | BGL_DOUBLE);
glView->Hide();
AddChild(glView);
glView->LockGL();
BMenu* menu = new BMenu(B_TRANSLATE("Automatic"));
menu->SetRadioMode(true);
menu->SetLabelFromMarked(true);
menu->AddItem(new BMenuItem(B_TRANSLATE("Automatic"),
new BMessage(MENU_AUTO_MESSAGE)));
menu->AddSeparatorItem();
menu->AddItem(new BMenuItem(B_TRANSLATE("Software Rasterizer"),
new BMessage(MENU_SWRAST_MESSAGE)));
menu->AddItem(new BMenuItem(B_TRANSLATE("Gallium Software Pipe"),
new BMessage(MENU_SWPIPE_MESSAGE)));
menu->AddItem(new BMenuItem(B_TRANSLATE("Gallium LLVM Pipe"),
new BMessage(MENU_SWLLVM_MESSAGE)));
BMenuField* menuField = new BMenuField("renderer",
B_TRANSLATE("3D Rendering Engine:"), menu);
// TODO: Set current Renderer
menuField->SetEnabled(false);
BTabView *tabView = new BTabView("tab view", B_WIDTH_FROM_LABEL);
tabView->AddTab(new InfoView());
tabView->AddTab(new CapabilitiesView());
tabView->AddTab(new ExtensionsView());
glView->UnlockGL();
GroupLayout()->SetSpacing(0);
BLayoutBuilder::Group<>(this)
.SetInsets(B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING,
B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING)
.Add(menuField)
.AddGroup(B_HORIZONTAL)
.Add(tabView)
.SetInsets(0, B_USE_DEFAULT_SPACING, 0, 0);
}
示例14: new_color_field
static BMenuField* new_color_field(BRect f)
{
BMenu* menu = new BMenu("colors_menu");
if (!menu) return NULL;
BMenuItem* item = new BMenuItem(BACKGROUND_STR, new BMessage(BACKGROUND_C_MSG));
if (item) menu->AddItem(item);
item = new BMenuItem(FOREGROUND_STR, new BMessage(FOREGROUND_C_MSG));
if (item) menu->AddItem(item);
item = menu->ItemAt(0);
if (item) item->SetMarked(true);
menu->SetLabelFromMarked(true);
menu->SetRadioMode(true);
BMenuField* field = new BMenuField(f, "colors_field", "Color:", menu, B_FOLLOW_LEFT | B_FOLLOW_TOP);
if (!field) {
delete menu;
return NULL;
}
return field;
}
示例15: FTHSetFT
// ------------------------------------------------------------------------ RHTML_Preferences_Win - FTHSetFT -
void RHTMLPreferencesWin::FTHSetFT(uint FileType)
{
fFTHFTBox->RemoveChild(fFTHFC);
BMenu *fFCMenu = new BMenu(fOptions->GetLocaleString("FileTypes_FontColorName",fOptions->FileTypes[FileType]->FCName[0]->String()));
fFCMenu->SetLabelFromMarked(true);
fFCMenu->SetRadioMode(true);
for (int32 i=0;i<(int32)fOptions->FileTypes[FileType]->FontColorDb;i++)
{
BMessage* msg = new BMessage('FTHT');
msg->AddInt32("FontColor",i);
BMenuItem *item;
fFCMenu->AddItem(item=new BMenuItem(fOptions->GetLocaleString("FileTypes_FontColorName",fOptions->FileTypes[FileType]->FCName[i]->String()),msg));
item->SetTarget(this);
}
fFTHFC= new BMenuField(BRect(10,40,210,65),"FileTypesMenu",fOptions->GetLocaleString("Preferences_Window_FileTypes","Element"),fFCMenu);
fFTHFC->SetDivider(100);
fFTHFTBox->AddChild(fFTHFC);
FTHSetFSize(0);
}