本文整理汇总了C++中BMenu类的典型用法代码示例。如果您正苦于以下问题:C++ BMenu类的具体用法?C++ BMenu怎么用?C++ BMenu使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BMenu类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: switch
void
TemplateWindow::MessageReceived(BMessage* message)
{
switch (message->what) {
case M_NAME_CHANGED:
case M_TARGET_CHANGED:
{
if (fNameBox->Text() && strlen(fNameBox->Text()) > 0 &&
fTargetBox->Text() && strlen(fTargetBox->Text()) > 0)
fCreateProjectButton->SetEnabled(true);
else
fCreateProjectButton->SetEnabled(false);
break;
}
case M_CREATE_PROJECT:
{
BMenu* menu = fTemplateField->Menu();
BMenuItem* item = menu->FindMarked();
if (item == NULL)
break;
int32 selection = menu->IndexOf(item);
ProjectTemplate* ptemp = fTempList.TemplateAt(selection);
BMessage projectMessage(M_CREATE_PROJECT), reply;
projectMessage.AddString("name", fNameBox->Text());
projectMessage.AddString("target", fTargetBox->Text());
projectMessage.AddInt32("type", ptemp->TargetType());
projectMessage.AddString("path", fPathBox->Path());
projectMessage.AddString("template", ptemp->GetRef().name);
projectMessage.AddString("pldfile", ptemp->ProjectFileName());
BMenu* scmMenu = fSCMChooser->Menu();
int32 scm = scmMenu->IndexOf(scmMenu->FindMarked());
projectMessage.AddInt32("scmtype",scm);
if (!ptemp->ProjectFileName()) {
for (int32 i = 0; i < ptemp->CountFiles(); i++)
projectMessage.AddRef("refs", ptemp->FileAt(i));
for (int32 i = 0; i < ptemp->CountLibs(); i++)
projectMessage.AddRef("libs", ptemp->LibAt(i));
}
if (!BEntry(PROJECT_PATH).Exists())
create_directory(PROJECT_PATH, 0755);
projectMessage.AddBool("createfolder", (fCreateFolder->Value() == B_CONTROL_ON));
be_app_messenger.SendMessage(&projectMessage, &reply);
PostMessage(B_QUIT_REQUESTED);
break;
}
default:
BWindow::MessageReceived(message);
}
}
示例2:
void
AppearancePrefView::AttachedToWindow()
{
fTabTitle->SetTarget(this);
fWindowTitle->SetTarget(this);
fBlinkCursor->SetTarget(this);
fWarnOnExit->SetTarget(this);
fFontField->Menu()->SetTargetForItems(this);
for (int32 i = 0; i < fFontField->Menu()->CountItems(); i++) {
BMenu* fontSizeMenu = fFontField->Menu()->SubmenuAt(i);
if (fontSizeMenu == NULL)
continue;
fontSizeMenu->SetTargetForItems(this);
}
fColorControl->SetTarget(this);
fColorField->Menu()->SetTargetForItems(this);
fColorSchemeField->Menu()->SetTargetForItems(this);
_SetCurrentColorScheme();
}
示例3: snprintf
void
AppearancePrefView::_MarkSelectedFont(const char* family, const char* style,
const char* size)
{
char fontMenuLabel[134];
snprintf(fontMenuLabel, sizeof(fontMenuLabel), "%s - %s", family, style);
// mark the selected font
BMenuItem* selectedFont = fFontField->Menu()->FindItem(fontMenuLabel);
if (selectedFont != NULL)
selectedFont->SetMarked(true);
// mark the selected font size on all font menus
for (int32 i = 0; i < fFontField->Menu()->CountItems(); i++) {
BMenu* fontSizeMenu = fFontField->Menu()->SubmenuAt(i);
if (fontSizeMenu == NULL)
continue;
BMenuItem* item = fontSizeMenu->FindItem(size);
if (item != NULL)
item->SetMarked(true);
}
}
示例4: switch
void
PPPoEView::MessageReceived(BMessage *message)
{
switch(message->what) {
case kMsgSelectInterface: {
BMenuItem *item = fInterface->Menu()->FindMarked();
if(item)
fInterfaceName = item->Label();
} break;
case kMsgSelectOther:
(new TextRequestDialog("InterfaceName", NULL, kRequestInterfaceName,
fInterfaceName.String()))->Go(new BInvoker(
new BMessage(kMsgFinishSelectOther), this));
break;
case kMsgFinishSelectOther: {
int32 which;
message->FindInt32("which", &which);
const char *name = message->FindString("text");
BMenu *menu = fInterface->Menu();
BMenuItem *item;
if(which != 1 || !name || strlen(name) == 0) {
item = menu->FindItem(fInterfaceName.String());
if(item && menu->IndexOf(item) <= menu->CountItems() - 2)
item->SetMarked(true);
else
fOtherInterface->SetMarked(true);
return;
}
fInterfaceName = name;
item = menu->FindItem(fInterfaceName.String());
if(item && menu->IndexOf(item) <= menu->CountItems() - 2) {
item->SetMarked(true);
return;
}
BString label(kLabelOtherInterface);
label << " " << name;
fOtherInterface->SetLabel(label.String());
fOtherInterface->SetMarked(true);
// XXX: this is needed to tell the owning menu to update its label
} break;
default:
BView::MessageReceived(message);
}
}
示例5: BMenu
void
MainWindow::_BuildMenu(BMenuBar* menuBar)
{
BMenu* menu = new BMenu(B_TRANSLATE("Tools"));
menu->AddItem(new BMenuItem(B_TRANSLATE("Refresh depots"),
new BMessage(MSG_REFRESH_DEPOTS)));
menuBar->AddItem(menu);
menu = new BMenu(B_TRANSLATE("Show"));
fShowFeaturedPackagesItem = new BMenuItem(
B_TRANSLATE("Only featured packages"),
new BMessage(MSG_SHOW_FEATURED_PACKAGES));
menu->AddItem(fShowFeaturedPackagesItem);
menu->AddSeparatorItem();
fShowAvailablePackagesItem = new BMenuItem(
B_TRANSLATE("Available packages"),
new BMessage(MSG_SHOW_AVAILABLE_PACKAGES));
menu->AddItem(fShowAvailablePackagesItem);
fShowInstalledPackagesItem = new BMenuItem(
B_TRANSLATE("Installed packages"),
new BMessage(MSG_SHOW_INSTALLED_PACKAGES));
menu->AddItem(fShowInstalledPackagesItem);
menu->AddSeparatorItem();
fShowDevelopPackagesItem = new BMenuItem(
B_TRANSLATE("Develop packages"),
new BMessage(MSG_SHOW_DEVELOP_PACKAGES));
menu->AddItem(fShowDevelopPackagesItem);
fShowSourcePackagesItem = new BMenuItem(
B_TRANSLATE("Source packages"),
new BMessage(MSG_SHOW_SOURCE_PACKAGES));
menu->AddItem(fShowSourcePackagesItem);
menuBar->AddItem(menu);
}
示例6: KeyMenuBar
void SeqStudioWindow::MenusBeginning()
{
inherited::MenusBeginning();
BMenuBar* bar = KeyMenuBar();
if (!bar) return;
BColumnListView* table = dynamic_cast<BColumnListView*>( FindView(ENDPOINT_LIST_STR) );
if (!table) return;
if (mDeviceCtrl && mDeviceCtrl->Menu() ) add_device_menu_items(mDeviceCtrl->Menu() );
// MIDI Port menu
if (mPortMenu) {
bool deleteEnabled = false;
_EndpointRow* r = dynamic_cast<_EndpointRow*>(table->CurrentSelection() );
if (r && !r->mIsValid && r->mEndpoint.channel < 0) deleteEnabled = true;
BMenuItem* deleteItem = mPortMenu->FindItem(DELETE_STR);
if (deleteItem && deleteItem->IsEnabled() != deleteEnabled) deleteItem->SetEnabled(deleteEnabled);
}
// Attributes menu
BMenu* menu;
BMenuItem* item;
if ( (menu = bar->SubmenuAt(ATTRIBUTES_MENU_INDEX)) != NULL) {
for (int32 k = 0; (item = menu->ItemAt(k)) != NULL; k++) {
const char* n;
if (item->Message() && item->Message()->FindString(COLUMN_NAME_STR, &n) == B_OK) {
BColumn* col = column_named(n, table);
if (col && col->IsVisible() ) {
if (!item->IsMarked() ) item->SetMarked(true);
} else {
if (item->IsMarked() ) item->SetMarked(false);
}
}
}
}
}
示例7: BMessage
// PopulateMenu
void
FontValueView::_PolulateMenu(BMenu* menu, BHandler* target,
const char* markedFamily,
const char* markedStyle)
{
if (!menu)
return;
FontManager* manager = FontManager::Default();
if (!manager->Lock())
return;
BMenu* fontMenu = NULL;
font_family family;
font_style style;
int32 count = manager->CountFontFiles();
for (int32 i = 0; i < count; i++) {
if (!manager->GetFontAt(i, family, style))
break;
BMessage* message = new BMessage(MSG_FONT_CHANGED);
message->AddString("font family", family);
message->AddString("font style", style);
FontMenuItem* item = new FontMenuItem(style, family, style,
message);
item->SetTarget(target);
bool markStyle = false;
if (!fontMenu
|| (fontMenu->Name()
&& strcmp(fontMenu->Name(), family) != 0)) {
// create new entry
fontMenu = new BMenu(family);
fontMenu->AddItem(item);
menu->AddItem(fontMenu);
// mark the menu if necessary
if (markedFamily && strcmp(markedFamily, family) == 0) {
if (BMenuItem* superItem = fontMenu->Superitem())
superItem->SetMarked(true);
markStyle = true;
}
} else {
// reuse old entry
fontMenu->AddItem(item);
}
// mark the item if necessary
if (markStyle && markedStyle && strcmp(markedStyle, style) == 0)
item->SetMarked(true);
}
manager->Unlock();
}
示例8: new_rhythm_menu_field
static ArpMenuField* new_rhythm_menu_field()
{
BMenu* menu = new BMenu("motion_menu");
if (!menu) return NULL;
BString label, key;
for (uint32 k = 0; AmGlobals().GetMotionInfo(k, label, key) == B_OK; k++) {
BMessage* msg = new BMessage(MOTION_MSG);
if (msg) {
msg->AddString(MOTION_KEY_STR, key);
BMenuItem* item = new BMenuItem(label.String(), msg);
if (!item) delete msg;
else menu->AddItem(item);
}
}
// menu->SetLabelFromMarked(true);
// menu->SetRadioMode(true);
ArpMenuField* field = new ArpMenuField("rhythm_field", "Motion:", menu);
if (!field) {
delete menu;
return NULL;
}
return field;
}
示例9: BMessage
BMenuItem* SplitWindow::MakeCatMenu(Cat* cat)
{
BMenuItem* mi;
BMessage* msgs = new BMessage(CatPopUpMSG);
msgs->AddString("text", cat->Name().c_str());
msgs->AddInt8("num", catnum);
cas* childcats = cat->SetOfChildren();
if (childcats->empty())
{
mi = new BMenuItem(cat->LeafName().c_str(), msgs);
}
else
{
BMenu* m = new BMenu(cat->LeafName().c_str());
mi = new BMenuItem(m, msgs);
for (cas::iterator ci = childcats->begin(); ci != childcats->end(); ci++)
{
m->AddItem(MakeCatMenu(*ci));
}
}
return mi;
}
示例10: ReadPreferences
void
Renamer_Remove::AttachedToWindow()
{
BMessage msg;
ReadPreferences("ren_remove", msg);
BString string = "";
int32 integer = 0;
bool boolean = 0;
if (msg.FindInt32("pos1", &integer) == B_OK)
fPosition1->SetValue(integer);
if (msg.FindInt32("pos2", &integer) == B_OK)
fPosition2->SetValue(integer);
if (msg.FindBool("direction1", &boolean) == B_OK) {
BMenu* menu = fDirection1->Menu();
for (int i = 0; i < 2; ++i)
menu->ItemAt(i)->SetMarked(i == (int)boolean);
}
if (msg.FindBool("direction2", &boolean) == B_OK) {
BMenu* menu = fDirection2->Menu();
for (int i = 0; i < 2; ++i)
menu->ItemAt(i)->SetMarked(i == (int)boolean);
}
}
示例11: BGroupView
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);
}
示例12: BMenuBar
BMenuBar*
KeymapWindow::_CreateMenu()
{
BMenuBar* menuBar = new BMenuBar(Bounds(), "menubar");
// Create the File menu
BMenu* menu = new BMenu(B_TRANSLATE("File"));
menu->AddItem(new BMenuItem(B_TRANSLATE("Open" B_UTF8_ELLIPSIS),
new BMessage(kMsgMenuFileOpen), 'O'));
menu->AddItem(new BMenuItem(B_TRANSLATE("Save as" B_UTF8_ELLIPSIS),
new BMessage(kMsgMenuFileSaveAs)));
menu->AddSeparatorItem();
menu->AddItem(new BMenuItem(
B_TRANSLATE("Set modifier keys" B_UTF8_ELLIPSIS),
new BMessage(kMsgShowModifierKeysWindow)));
menu->AddSeparatorItem();
menu->AddItem(new BMenuItem(B_TRANSLATE("Quit"),
new BMessage(B_QUIT_REQUESTED), 'Q'));
menuBar->AddItem(menu);
// Create keyboard layout menu
fLayoutMenu = new BMenu(B_TRANSLATE("Layout"));
_AddKeyboardLayouts(fLayoutMenu);
menuBar->AddItem(fLayoutMenu);
// Create the Font menu
fFontMenu = new BMenu(B_TRANSLATE("Font"));
fFontMenu->SetRadioMode(true);
int32 numFamilies = count_font_families();
font_family family, currentFamily;
font_style currentStyle;
uint32 flags;
be_plain_font->GetFamilyAndStyle(¤tFamily, ¤tStyle);
for (int32 i = 0; i < numFamilies; i++) {
if (get_font_family(i, &family, &flags) == B_OK) {
BMenuItem *item =
new BMenuItem(family, new BMessage(kMsgMenuFontChanged));
fFontMenu->AddItem(item);
if (!strcmp(family, currentFamily))
item->SetMarked(true);
}
}
menuBar->AddItem(fFontMenu);
return menuBar;
}
示例13: AdjustEditMenu
void TCueSheetWindow::AdjustEditMenu()
{
BMenu* theMenu = fAppMenu->GetEditMenu();
if (theMenu) {
// Undo Item
BMenuItem* undoItem = theMenu->FindItem(EDIT_UNDO_MSG);
if (undoItem) {
if (fUndoEngine->CanUndo())
undoItem->SetEnabled(true);
else
undoItem->SetEnabled(false);
}
// Cut
// Enable if any items are selected
BMenuItem* cutItem = theMenu->FindItem(EDIT_CUT_MSG);
if (cutItem)
cutItem->SetEnabled( fCueSheetView->ItemsSelected() );
// Copy
// Enable if any items are selected
BMenuItem* copyItem = theMenu->FindItem(EDIT_COPY_MSG);
if (copyItem)
copyItem->SetEnabled( fCueSheetView->ItemsSelected() );
// Paste
// Enable if there is anything on the clipboard
BMenuItem* pasteItem = theMenu->FindItem(EDIT_PASTE_MSG);
if (pasteItem)
pasteItem->SetEnabled( static_cast<MuseumApp*>(be_app)->fClipboard->HasData() );
// Clear
BMenuItem* clearItem = theMenu->FindItem(EDIT_CLEAR_MSG);
if (clearItem)
clearItem->SetEnabled( fCueSheetView->ItemsSelected() );
// Select All
// Enable if there is anything to be selected
BMenuItem* selectAllItem = theMenu->FindItem(EDIT_SELECTALL_MSG);
if (selectAllItem) {
// Enable this item if there are any cues to be selected
selectAllItem->SetEnabled( fCueSheetView->HasCues() );
}
}
}
示例14: Menu
void BitmapMenuItem::Draw(void)
{
BMenu* menu = Menu();
if (menu) {
BRect itemFrame = Frame();
BRect bitmapFrame = itemFrame;
bitmapFrame.InsetBy(2, 2); // account for 2-pixel margin
menu->SetDrawingMode(B_OP_COPY);
menu->SetHighColor(BKG_GREY);
menu->FillRect(itemFrame);
menu->DrawBitmap(&m_bitmap, bitmapFrame);
if (IsSelected()) {
// a nonstandard but simple way to draw highlights
menu->SetDrawingMode(B_OP_INVERT);
menu->SetHighColor(0,0,0);
menu->FillRect(itemFrame);
}
}
}
示例15: Menu
void
BSeparatorItem::Draw()
{
BMenu *menu = Menu();
if (menu == NULL)
return;
BRect bounds = Frame();
rgb_color oldColor = menu->HighColor();
rgb_color lowColor = menu->LowColor();
const float startTop = bounds.top + (floor(bounds.Height())) / 2;
menu->SetHighColor(tint_color(lowColor, B_DARKEN_1_TINT));
menu->StrokeLine(BPoint(bounds.left + 1.0f, startTop),
BPoint(bounds.right - 1.0f, startTop));
menu->SetHighColor(tint_color(lowColor, B_LIGHTEN_2_TINT));
menu->StrokeLine(BPoint(bounds.left + 1.0f, startTop + 1.0f),
BPoint(bounds.right - 1.0f, startTop + 1.0f));
menu->SetHighColor(oldColor);
}