本文整理汇总了C++中BMenuItem类的典型用法代码示例。如果您正苦于以下问题:C++ BMenuItem类的具体用法?C++ BMenuItem怎么用?C++ BMenuItem使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BMenuItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BPopUpMenu
BPopUpMenu*
TPrefsWindow::_BuildEncodingMenu(uint32 encoding)
{
BMenuItem* item;
BMessage* msg;
BPopUpMenu* menu;
menu = new BPopUpMenu("");
BCharacterSetRoster roster;
BCharacterSet charset;
while (roster.GetNextCharacterSet(&charset) == B_NO_ERROR) {
BString name(charset.GetPrintName());
const char* mime = charset.GetMIMEName();
if (mime)
name << " (" << mime << ")";
msg = new BMessage(P_ENC);
uint32 convert_id;
if ((mime == 0) || (strcasecmp(mime, "UTF-8") != 0))
convert_id = charset.GetConversionID();
else
convert_id = B_MAIL_UTF8_CONVERSION;
msg->AddInt32("encoding", convert_id);
menu->AddItem(item = new BMenuItem(name.String(), msg));
if (convert_id == encoding)
item->SetMarked(true);
}
msg = new BMessage(P_ENC);
msg->AddInt32("encoding", B_MAIL_US_ASCII_CONVERSION);
menu->AddItem(item = new BMenuItem("US-ASCII", msg));
if (encoding == B_MAIL_US_ASCII_CONVERSION)
item->SetMarked(true);
return menu;
}
示例2: directory
void
BNavMenu::DoneBuildingItemList()
{
// add sorted items to menu
if (TrackerSettings().SortFolderNamesFirst())
fItemList->SortItems(CompareFolderNamesFirstOne);
else
fItemList->SortItems(CompareOne);
// if the parent link should be shown, it will be the first
// entry in the menu - but don't add the item if we're already
// at the file system's root
if (fFlags & kShowParent) {
BDirectory directory(&fNavDir);
BEntry entry(&fNavDir);
if (!directory.IsRootDirectory()
&& entry.GetParent(&entry) == B_OK) {
Model model(&entry, true);
BLooper *looper;
AddNavParentDir(&model,fMessage.what,fMessenger.Target(&looper));
}
}
int32 count = fItemList->CountItems();
for (int32 index = 0; index < count; index++)
AddItem(fItemList->ItemAt(index));
fItemList->MakeEmpty();
if (!count) {
BMenuItem *item = new BMenuItem("Empty Folder", 0);
item->SetEnabled(false);
AddItem(item);
}
SetTargetForItems(fMessenger);
}
示例3: SettingsView
SpaceBarSettingsView::SpaceBarSettingsView(BRect rect)
: SettingsView(rect, "SpaceBarSettingsView")
{
rect.OffsetTo(B_ORIGIN);
fSpaceBarShowCheckBox = new BCheckBox(rect, "", "Show space bars on volumes",
new BMessage(kUpdateVolumeSpaceBar));
fSpaceBarShowCheckBox->ResizeToPreferred();
AddChild(fSpaceBarShowCheckBox);
rect = fSpaceBarShowCheckBox->Frame();
rect.OffsetBy(0, fSpaceBarShowCheckBox->Bounds().Height() + kItemExtraSpacing);
BPopUpMenu *menu = new BPopUpMenu(B_EMPTY_STRING);
menu->SetFont(be_plain_font);
BMenuItem *item;
menu->AddItem(item = new BMenuItem("Used space color", new BMessage(kSpaceBarSwitchColor)));
item->SetMarked(true);
fCurrentColor = 0;
menu->AddItem(new BMenuItem("Free space color", new BMessage(kSpaceBarSwitchColor)));
menu->AddItem(new BMenuItem("Warning space color", new BMessage(kSpaceBarSwitchColor)));
BBox *box = new BBox(rect);
box->SetLabel(fColorPicker = new BMenuField(rect, NULL, NULL, menu));
AddChild(box);
fColorControl = new BColorControl(BPoint(8, fColorPicker->Bounds().Height()
+ 8 + kItemExtraSpacing),
B_CELLS_16x16, 1, "SpaceColorControl", new BMessage(kSpaceBarColorChanged));
fColorControl->SetValue(TrackerSettings().UsedSpaceColor());
fColorControl->ResizeToPreferred();
box->AddChild(fColorControl);
box->ResizeTo(fColorControl->Bounds().Width() + 16,
fColorControl->Frame().bottom + 8);
}
示例4: SetTarget
void
TDeskbarMenu::ResetTargets()
{
// This method does not recurse into submenus
// and does not affect menu items in submenus.
// (e.g. "Restart System" and "Power Off")
BNavMenu::ResetTargets();
// if we are dragging, set the target to whatever was set
// else set it to the default (Tracker)
if (!fBarView->Dragging())
SetTarget(DefaultTarget());
// now set the target for the menuitems to the currently
// set target, which may or may not be tracker
SetTargetForItems(Target());
for (int32 i = 0; ; i++) {
BMenuItem* item = ItemAt(i);
if (item == NULL)
break;
if (item->Message()) {
switch (item->Message()->what) {
case kFindButton:
item->SetTarget(BMessenger(kTrackerSignature));
break;
case kShowSplash:
case kToggleDraggers:
case kConfigShow:
case kAlwaysTop:
case kExpandNewTeams:
case kHideLabels:
case kResizeTeamIcons:
case kSortRunningApps:
case kTrackerFirst:
case kRebootSystem:
case kSuspendSystem:
case kShutdownSystem:
item->SetTarget(be_app);
break;
case kShowHideTime:
case kShowSeconds:
case kShowDayOfWeek:
item->SetTarget(fBarView->fReplicantTray);
break;
}
}
}
}
示例5: BMenuItem
void TeamListView::ItemsToPopUpPriorityMenu()
{
BMenuField *Priority = (BMenuField *)slayer->mainWindow->FindView("MainPriorityField");
BMenu *menu = Priority->Menu();
BMenuItem *add;
int32 i;
for (i = 2; (add = menu->ItemAt(i)); i++) {
BMenuItem *newItem;
if (add->Label() && add->Label()[0])
newItem = new BMenuItem(add->Label(), new BMessage(
add->Command()));
else
newItem = new BSeparatorItem();
newItem->SetTarget(slayer->mainWindow);
priorityMenu->AddItem(newItem);
}
// priorityMenu->AddItem(add);
}
示例6: _DeselectOldItems
void
ControlView::_UpdateAndSendFamily(const BMessage* message)
{
_DeselectOldItems();
font_family family;
font_style style;
if (message->FindString("_family", (const char **)&family) == B_OK) {
char* name;
type_code typeFound = 0;
int32 countFound = 0;
if (message->GetInfo(B_ANY_TYPE, 0, &name, &typeFound,
&countFound) == B_OK) {
if (typeFound == B_STRING_TYPE) {
BString string;
if (message->FindString(name, 0, &string) == B_OK)
printf("Family: %s\n", string.String());
}
}
BMenuItem* markedItem = fFontFamilyMenu->FindItem(family);
if (!markedItem)
return;
markedItem->SetMarked(true);
get_font_style(family, 0, &style);
BString string;
string << family << " " << style;
if (fFontMenuField)
fFontMenuField->MenuItem()->SetLabel(string.String());
BMenu* submenu = markedItem->Submenu();
if (submenu) {
BMenuItem* styleItem = submenu->FindItem(style);
if (styleItem && !styleItem->IsMarked())
styleItem->SetMarked(true);
}
BMessage fontMsg(FONTFAMILY_CHANGED_MSG);
if (fontMsg.AddMessage("_fontMessage", message) == B_OK)
fMessenger->SendMessage(&fontMsg);
}
}
示例7: BPopUpMenu
void SeqToolBarView::ShowPropertyMenu(const AmTool* tool, BPoint where)
{
BPopUpMenu* menu = new BPopUpMenu("properties menu");
if (!menu) return;
BMessage* msg = new BMessage(PROPERTIES_MSG);
if (msg) {
msg->AddString("tool_key", tool->Key() );
BMenuItem* item = new BMenuItem("Properties", msg);
if (item) {
item->SetTarget(this);
menu->AddItem(item);
}
}
msg = new BMessage(EDIT_MSG);
if (msg) {
msg->AddString("tool_key", tool->Key() );
msg->AddString("path", tool->LocalFilePath() );
BMenuItem* item = new BMenuItem("Edit", msg);
if (item) {
item->SetTarget(this);
if (tool->IsReadOnly() ) item->SetEnabled(false);
menu->AddItem(item);
}
}
menu->AddSeparatorItem();
msg = new BMessage(REMOVE_FROM_TOOL_BAR_MSG);
if (msg) {
msg->AddString("tool_key", tool->Key() );
msg->AddPointer("tool_id", tool->Id() );
BMenuItem* item = new BMenuItem("Remove From Tool Bar", msg);
if (item) {
item->SetTarget(this);
menu->AddItem(item);
}
}
menu->SetAsyncAutoDestruct(true);
where = ConvertToScreen(where);
BRect sticky(where.x-5, where.y-5, where.x+5, where.y+5);
menu->Go(where, true, false, sticky, true);
}
示例8:
void
AddPrinterDialog::_HandleChangedTransport(BMessage *msg)
{
BString name;
if (msg->FindString("name", &name) != B_OK) {
name = "";
}
fTransportText = name;
BString path;
if (msg->FindString("path", &path) == B_OK) {
// transport path selected
fTransportPathText = path;
// mark sub menu
void* pointer;
if (msg->FindPointer("source", &pointer) == B_OK) {
BMenuItem* item = (BMenuItem*)pointer;
// Update printer name with Transport Path if not filled in
if (strlen(fName->Text()) == 0)
fName->SetText(item->Label());
BMenu* menu = item->Menu();
int32 index = fTransport->IndexOf(menu);
item = fTransport->ItemAt(index);
if (item != NULL)
item->SetMarked(true);
}
} else {
// transport selected
fTransportPathText = "";
// remove mark from item in sub menu of transport sub menu
for (int32 i = fTransport->CountItems() - 1; i >= 0; i --) {
BMenu* menu = fTransport->SubmenuAt(i);
if (menu != NULL) {
BMenuItem* item = menu->FindMarked();
if (item != NULL)
item->SetMarked(false);
}
}
}
_Update();
}
示例9: ColumnListView
TeamListView::TeamListView(BRect frame, const char *name, CLVContainerView **s)
: ColumnListView(frame, s, name, B_FOLLOW_ALL_SIDES, B_WILL_DRAW|B_NAVIGABLE|B_FRAME_EVENTS,
B_MULTIPLE_SELECTION_LIST, true, true, true, false, B_FANCY_BORDER)
{
// add Columns...
AddColumn(new CLVColumn(NULL, 20.0, CLV_EXPANDER|CLV_LOCK_AT_BEGINNING|CLV_NOT_MOVABLE));
AddColumn(new CLVColumn(NULL, 20.0, CLV_LOCK_AT_BEGINNING|CLV_NOT_RESIZABLE|
CLV_NOT_MOVABLE|CLV_MERGE_WITH_RIGHT));
AddColumn(new CLVColumn("Name", 100.0, CLV_LOCK_AT_BEGINNING|CLV_NOT_MOVABLE));
AddColumn(new CLVColumn("Id", 40.0));
AddColumn(new CLVColumn("Priority", 50.0));
AddColumn(new CLVColumn("State", 60.0));
AddColumn(new CLVColumn("Memory", 60.0));
AddColumn(new CLVColumn("CPU", 60.0));
SetInvocationMessage(new BMessage(TEAM_INV));
// create the PopUpMenu
BMenuItem *inv;
operationMenu = new BPopUpMenu("operationMenu", false, false);
operationMenu->AddItem((inv = new BMenuItem("Kill",
new BMessage(IE_MAINWINDOW_MAINKILL))));
inv->SetTarget(slayer->mainWindow);
operationMenu->AddItem((inv = new BMenuItem("Suspend",
new BMessage(IE_MAINWINDOW_MAINSUSPEND))));
inv->SetTarget(slayer->mainWindow);
operationMenu->AddItem((inv = new BMenuItem("Resume",
new BMessage(IE_MAINWINDOW_MAINRESUME))));
inv->SetTarget(slayer->mainWindow);
operationMenu->AddSeparatorItem();
priorityMenu = new BMenu("PriorityMenu");
BMenuItem *pr = new BMenuItem(priorityMenu); //, new BMessage('tmpj'));
pr->SetLabel("Set priority");
operationMenu->AddItem(pr);
ItemsToPopUpPriorityMenu();
// MakeFocus(true);
// = new BMenu("Set priority");
// operationMenu->AddItem(setPriorityMenu);
// operationMenu->AddSeparator
}
示例10:
/*! Marks the menu items corresponding to the dead key state of the current
key map.
*/
void
KeymapWindow::_UpdateDeadKeyMenu()
{
BString trigger;
fCurrentMap.GetDeadKeyTrigger(kDeadKeyAcute, trigger);
if (!trigger.Length())
trigger = kDeadKeyTriggerNone;
BMenuItem* menuItem = fAcuteMenu->FindItem(trigger.String());
if (menuItem)
menuItem->SetMarked(true);
fCurrentMap.GetDeadKeyTrigger(kDeadKeyCircumflex, trigger);
if (!trigger.Length())
trigger = kDeadKeyTriggerNone;
menuItem = fCircumflexMenu->FindItem(trigger.String());
if (menuItem)
menuItem->SetMarked(true);
fCurrentMap.GetDeadKeyTrigger(kDeadKeyDiaeresis, trigger);
if (!trigger.Length())
trigger = kDeadKeyTriggerNone;
menuItem = fDiaeresisMenu->FindItem(trigger.String());
if (menuItem)
menuItem->SetMarked(true);
fCurrentMap.GetDeadKeyTrigger(kDeadKeyGrave, trigger);
if (!trigger.Length())
trigger = kDeadKeyTriggerNone;
menuItem = fGraveMenu->FindItem(trigger.String());
if (menuItem)
menuItem->SetMarked(true);
fCurrentMap.GetDeadKeyTrigger(kDeadKeyTilde, trigger);
if (!trigger.Length())
trigger = kDeadKeyTriggerNone;
menuItem = fTildeMenu->FindItem(trigger.String());
if (menuItem)
menuItem->SetMarked(true);
}
示例11: ConvertFromScreen
void MainView::showPopUp(const BPoint& win_point)
{
BMenuItem *item;
BPoint point = ConvertFromScreen(win_point);
if(menu != NULL) {
delete menu;
}
menu = new BPopUpMenu("menu", false);
BMessage *msg = new BMessage(MSG_ADD_GUIDE);
msg->AddBool("orientation", true);
msg->AddInt32("point", point.y);
item = new BMenuItem("Add Horizontal Guide", msg);
item->SetTarget(this);
menu->AddItem(item);
msg = new BMessage(MSG_ADD_GUIDE);
msg->AddBool("orientation", false);
msg->AddInt32("point", point.x);
item = new BMenuItem("Add Vertical Guide", msg);
item->SetTarget(this);
menu->AddItem(item);
msg = new BMessage(MSG_MAIN_VIEW_SHOW_GUIDES);
item = new BMenuItem("Show Guides", msg);
item->SetTarget(this);
menu->AddItem(item);
msg = new BMessage(MSG_MAIN_VIEW_HIDE_GUIDES);
item = new BMenuItem("Hide Guides", msg);
item->SetTarget(this);
menu->AddItem(item);
item = new BMenuItem("Edit Guides", new BMessage(MSG_SHOW_GUIDES));
item->SetTarget(Window());
menu->AddItem(item);
menu->Go(win_point, true);
}
示例12: Looper
void CInfoDialog::UpdateFields()
{
BMessage *msg = Looper()->CurrentMessage();
const char *ff, *fs;
if (msg->FindString("family", &ff) == B_NO_ERROR &&
msg->FindString("style", &fs) == B_NO_ERROR)
{
BMenuItem *item;
item = fMenu->FindMarked();
if (item)
{
item = item->Submenu()->FindMarked();
if (item) item->SetMarked(false);
fMenu->FindMarked()->SetMarked(false);
}
item = fMenu->FindItem(ff);
if (item)
{
item->SetMarked(true);
item = item->Submenu()->FindItem(fs);
if (item) item->SetMarked(true);
}
}
if (strcmp(fTypes->FindMarked()->Label(), "undefined") == 0)
{
MWarningAlert a("Please choose a real mime type");
a.Go();
}
SetEnabled("wrapfixedto", IsOn("wrapfixed"));
SetEnabled("ok", true);
SetEnabled("cancel", true);
} /* CInfoDialog::UpdateFields */
示例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: SetTitle
void TCueSheetWindow::Save(BMessage* message)
{
status_t myErr;
entry_ref theRef;
char* theString = NULL;
// Get directory to save data to
message->FindRef("directory", &theRef);
// Get name of file to be saved as
message->FindString("name", (const char**)&theString);
// Set window title to new filename
SetTitle(theString);
// Create a BDirectory object
BDirectory saveDir(&theRef);
// Now create the file. Create new file if fFile is unitialized.
if (fFile)
delete fFile;
fFile = new BFile();
myErr = saveDir.CreateFile(theString, fFile, false);
if (myErr != B_OK)
return;
// Write out file header
//WriteHeader(fFile);
BMessage archive;
// Archive CueSheetWindow and write to file
BMessage cueSheetArchive;
Archive(&cueSheetArchive, true);
// Flatten and write out to file
ssize_t numBytes;
cueSheetArchive.Flatten(fFile, &numBytes);
// Set file type
BNodeInfo info(fFile);
if ( info.InitCheck() )
return;
myErr = info.SetType("application/x-mediapede-cuesheet");
// Set icons
BBitmap* smallIcon = GetMICNFromResource("application/x-mediapede-cuesheet");
info.SetIcon( smallIcon, B_MINI_ICON);
BBitmap* largeIcon = GetICONFromResource("application/x-mediapede-cuesheet");
info.SetIcon( largeIcon, B_LARGE_ICON);
delete smallIcon;
delete largeIcon;
// Update our entry in the Windows menu to reflect possible new filename
BMenuItem* theItem = fAppMenu->GetWindowsMenu()->FindItem( Title());
if (theItem)
theItem->SetLabel(theString);
// We aren't dirty now
fCueSheetView->SetDirty(false);
}
示例15: sizeof
void TCueSheetWindow::AdjustWindowsMenu()
{
// Set up string buffers
bool retVal;
char* menuStr = (char*)malloc( sizeof(char) * 256);
// Get application
MuseumApp* theApp = static_cast<MuseumApp*>(be_app);
BMenu* theMenu = fAppMenu->GetWindowsMenu();
if (theMenu) {
// Stage Item
BMenuItem* stageItem = theMenu->FindItem(WINDOWS_STAGE_MSG);
if (stageItem) {
TStageWindow* stage = fStageWindow;
if (stage) {
stage->Lock();
if (stage->IsHidden())
retVal = GetString("WindowsMenuStrings", kWindowsShowStageItem, menuStr);
else
retVal = GetString("WindowsMenuStrings", kWindowsHideStageItem, menuStr);
stage->Unlock();
stageItem->SetLabel(menuStr);
} else {
retVal = GetString("WindowsMenuStrings", kWindowsShowStageItem, menuStr);
stageItem->SetLabel(menuStr);
}
}
// Browser Item
BMenuItem* browserItem = theMenu->FindItem(WINDOWS_BROWSER_MSG);
if (stageItem) {
TBrowserWindow* browser = theApp->GetBrowser();
if (browser) {
browser->Lock();
if (browser->IsHidden())
retVal = GetString("WindowsMenuStrings", kWindowsShowBrowserItem, menuStr);
else
retVal = GetString("WindowsMenuStrings", kWindowsHideBrowserItem, menuStr);
browser->Unlock();
browserItem->SetLabel(menuStr);
} else {
retVal = GetString("WindowsMenuStrings", kWindowsShowBrowserItem, menuStr);
browserItem->SetLabel(menuStr);
}
}
// Transport Item
BMenuItem* transportItem = theMenu->FindItem(WINDOWS_TRANSPORT_MSG);
if (transportItem) {
TTransportPalette* transport = theApp->GetTransport();
if (transport) {
transport->Lock();
if (transport->IsHidden())
retVal = GetString("WindowsMenuStrings", kWindowsShowTransportItem, menuStr);
else
retVal = GetString("WindowsMenuStrings", kWindowsHideTransportItem, menuStr);
transport->Unlock();
transportItem->SetLabel(menuStr);
} else {
retVal = GetString("WindowsMenuStrings", kWindowsShowTransportItem, menuStr);
transportItem->SetLabel(menuStr);
}
}
// Locator Item
BMenuItem* counterItem = theMenu->FindItem(WINDOWS_COUNTER_MSG);
if (counterItem) {
TTimePalette* time = theApp->GetTimePalette();
if (time) {
time->Lock();
if (time->IsHidden())
retVal = GetString("WindowsMenuStrings", kWindowsShowLocatorItem, menuStr);
else
retVal = GetString("WindowsMenuStrings", kWindowsHideLocatorItem, menuStr);
time->Unlock();
counterItem->SetLabel(menuStr);
} else {
retVal = GetString("WindowsMenuStrings", kWindowsShowLocatorItem, menuStr);
counterItem->SetLabel(menuStr);
}
}
// Media Cue Item
BMenuItem* mediaItem = theMenu->FindItem(WINDOWS_MEDIA_MSG);
if (mediaItem) {
TMediaCuePalette* mediaPalette = theApp->GetMediaPalette();
if (mediaPalette) {
mediaPalette->Lock();
if (mediaPalette->IsHidden())
retVal = GetString("WindowsMenuStrings", kWindowsShowMediaItem, menuStr);
else
retVal = GetString("WindowsMenuStrings", kWindowsHideMediaItem, menuStr);
mediaPalette->Unlock();
//.........这里部分代码省略.........