BMenuItem* CheckView::MakeCatMenu(Cat* cat, bool enabled = true) { BMenuItem* mi; BMessage* msgs = new BMessage(CheckPopCatMSG); msgs->AddString("text", cat->Name().c_str()); cas* childcats = cat->SetOfChildren(); if (childcats->empty()) { mi = new BMenuItem(cat->LeafName().c_str(), msgs); mi->SetEnabled(enabled); } else { BMenu* m = new BMenu(cat->LeafName().c_str()); mi = new BMenuItem(m, msgs); mi->SetEnabled(enabled); for (cas::iterator ci = childcats->begin(); ci != childcats->end(); ci++) { m->AddItem(MakeCatMenu(*ci)); } } return mi; }
void TCueSheetWindow::AdjustFileMenu() { BMenu* theMenu = fAppMenu->GetFileMenu(); if (theMenu) { // Save item BMenuItem* saveItem = theMenu->FindItem(FILE_SAVE_MSG); if (saveItem) { if (fCueSheetView->IsDirty()) saveItem->SetEnabled(true); else saveItem->SetEnabled(false); } // Revert item BMenuItem* revertItem = theMenu->FindItem(FILE_REVERT_MSG); if (saveItem) { if (fCueSheetView->IsDirty()) revertItem->SetEnabled(true); else revertItem->SetEnabled(false); } } }
// ShowContextMenu bool PathManipulator::ShowContextMenu(BPoint where) { // Change the selection to the current point if it isn't currently // selected. This could will only be chosen if the user right-clicked // a path point directly. if (fCurrentPathPoint >= 0 && !fSelection->Contains(fCurrentPathPoint)) { fSelection->MakeEmpty(); _UpdateSelection(); *fOldSelection = *fSelection; _Select(fCurrentPathPoint, false); } BPopUpMenu* menu = new BPopUpMenu("context menu", false, false); BMessage* message; BMenuItem* item; bool hasSelection = fSelection->CountItems() > 0; if (fCurrentPathPoint < 0) { message = new BMessage(B_SELECT_ALL); item = new BMenuItem("Select All", message, 'A'); menu->AddItem(item); menu->AddSeparatorItem(); } message = new BMessage(MSG_TRANSFORM); item = new BMenuItem("Transform", message, 'T'); item->SetEnabled(hasSelection); menu->AddItem(item); message = new BMessage(MSG_SPLIT_POINTS); item = new BMenuItem("Split", message); item->SetEnabled(hasSelection); menu->AddItem(item); message = new BMessage(MSG_FLIP_POINTS); item = new BMenuItem("Flip", message); item->SetEnabled(hasSelection); menu->AddItem(item); message = new BMessage(MSG_REMOVE_POINTS); item = new BMenuItem("Remove", message); item->SetEnabled(hasSelection); menu->AddItem(item); // go menu->SetTargetForItems(fCanvasView); menu->SetAsyncAutoDestruct(true); menu->SetFont(be_plain_font); where = fCanvasView->ConvertToScreen(where); BRect mouseRect(where, where); mouseRect.InsetBy(-10.0, -10.0); where += BPoint(5.0, 5.0); menu->Go(where, true, false, mouseRect, true); return true; }
void URLInputGroup::URLTextView::MouseDown(BPoint where) { bool wasFocus = IsFocus(); if (!wasFocus) MakeFocus(true); int32 buttons; if (Window()->CurrentMessage()->FindInt32("buttons", &buttons) != B_OK) buttons = B_PRIMARY_MOUSE_BUTTON; if ((buttons & B_SECONDARY_MOUSE_BUTTON) != 0) { // Display context menu int32 selectionStart; int32 selectionEnd; GetSelection(&selectionStart, &selectionEnd); bool canCutOrCopy = selectionEnd > selectionStart; bool canPaste = false; if (be_clipboard->Lock()) { if (BMessage* data = be_clipboard->Data()) canPaste = data->HasData("text/plain", B_MIME_TYPE); be_clipboard->Unlock(); } BMenuItem* cutItem = new BMenuItem(B_TRANSLATE("Cut"), new BMessage(B_CUT)); BMenuItem* copyItem = new BMenuItem(B_TRANSLATE("Copy"), new BMessage(B_COPY)); BMenuItem* pasteItem = new BMenuItem(B_TRANSLATE("Paste"), new BMessage(B_PASTE)); BMenuItem* clearItem = new BMenuItem(B_TRANSLATE("Clear"), new BMessage(MSG_CLEAR)); cutItem->SetEnabled(canCutOrCopy); copyItem->SetEnabled(canCutOrCopy); pasteItem->SetEnabled(canPaste); clearItem->SetEnabled(strlen(Text()) > 0); BPopUpMenu* menu = new BPopUpMenu("url context"); menu->AddItem(cutItem); menu->AddItem(copyItem); menu->AddItem(pasteItem); menu->AddItem(clearItem); menu->SetTargetForItems(this); menu->Go(ConvertToScreen(where), true, true, true); return; } // Only pass through to base class if we already have focus. if (!wasFocus) return; BTextView::MouseDown(where); }
void VideoWindow::ToggleMenuOnOff() { BMenuItem* item = fMenu->FindItem(msg_video); item->SetEnabled(!item->IsEnabled()); item = fMenu->FindItem(msg_start); item->SetEnabled(!item->IsEnabled()); item = fMenu->FindItem(msg_stop); item->SetEnabled(!item->IsEnabled()); }
void FindWindow::EnableReplace(bool value) { fReplaceButton->SetEnabled(value); fReplaceAllButton->SetEnabled(value); BMenuItem *item = fMenuBar->FindItem(B_TRANSLATE("Replace")); if (item) item->SetEnabled(value); item = fMenuBar->FindItem(B_TRANSLATE("Replace all")); if (item) item->SetEnabled(value); }
void CronoView::_BuildMenu() { // Menu bar fMenuBar = new BMenuBar("MenuBar"); fFileMenu = new BMenu("Metronome"); fFileMenu->AddItem(new BMenuItem("Quit", new BMessage(MSG_CLOSE), 'Q')); fFileMenu->AddItem(new BSeparatorItem); fFileMenu->AddItem(new BMenuItem("Start", new BMessage(MSG_START), 'G')); fFileMenu->AddItem(new BMenuItem("Stop", new BMessage(MSG_STOP), 'H')); fMenuBar->AddItem(fFileMenu); fEditMenu = new BMenu("Edit"); fEditMenu->AddItem(new BMenuItem("Settings", new BMessage(MSG_SETTINGS), 'S')); fEditMenu->AddItem(new BSeparatorItem); fShowMenu = new BMenu("Show"); fEditMenu->AddItem(fShowMenu); BMenuItem* item = new BMenuItem("Visual Metronome", NULL, 0); item->SetEnabled(false); fShowMenu->AddItem(item); item = new BMenuItem("Speed trainer", NULL, 0); item->SetEnabled(false); fShowMenu->AddItem(item); fAccentTableItem = new BMenuItem("Show accents table", new BMessage(MSG_ACCENT_TABLE), 0); fShowMenu->AddItem(fAccentTableItem); fMenuBar->AddItem(fEditMenu); fHelpMenu = new BMenu("Help"); fHelpMenu->AddItem(new BMenuItem("Help", new BMessage(MSG_HELP), 'H')); fHelpMenu->AddItem(new BMenuItem("Homepage", new BMessage(MSG_HOMEPAGE),'P')); fHelpMenu->AddItem(new BSeparatorItem); fHelpMenu->AddItem(new BMenuItem("About", new BMessage(MSG_ABOUT), 'A')); fMenuBar->AddItem(fHelpMenu); }
void CAssemblyWindow::AddMenuBar() { BMenu *menu, *subMenu; BMenuItem *item; BMenuBar *menuBar = new BMenuBar(Bounds(), "General"); // Create the 'File' menu CreateFileMenu(menuBar); // Create the edit menu menu = new BMenu("Edit"); menu->AddItem(new BMenuItem("Undo", new BMessage(MENU_UNDO), 'Z')); menu->AddItem(new BMenuItem("Redo", new BMessage(MENU_REDO), 'Z', B_SHIFT_KEY)); menu->AddSeparatorItem(); menu->AddItem(item = new BMenuItem("Cut", new BMessage(B_CUT), 'X')); item->SetEnabled(false); menu->AddItem(item = new BMenuItem("Copy", new BMessage(B_COPY), 'C')); item->SetEnabled(false); menu->AddItem(item = new BMenuItem("Paste", new BMessage(B_PASTE), 'V')); item->SetEnabled(false); menu->AddItem(new CQuickKeyMenuItem("Clear", new BMessage(MENU_CLEAR), B_DELETE, "Del")); menu->AddSeparatorItem(); menu->AddItem(new BMenuItem("Select All", new BMessage(B_SELECT_ALL), 'A')); menuBar->AddItem(menu); // Create the 'Play' menu menu = new BMenu("Play"); menu->AddItem(new CQuickKeyMenuItem("Pause", new BMessage(MENU_PAUSE), B_SPACE, "Space")); menu->AddSeparatorItem(); menu->AddItem(new CQuickKeyMenuItem("Start", new BMessage(MENU_PLAY), B_ENTER, "Enter")); menu->AddItem(new CQuickKeyMenuItem("Play Section", new BMessage(MENU_PLAY_SECTION ), 'p', "p")); menu->AddSeparatorItem(); menu->AddItem(new BMenuItem("Set Section", new BMessage(MENU_SET_SECTION), 'S', B_SHIFT_KEY)); menuBar->AddItem(menu); // Create the 'View' menu menu = new BMenu("View"); subMenu = new BMenu("Add Strip"); menu->AddItem(subMenu); menuBar->AddItem(menu); // Create the 'Window' menu CreateWindowMenu(menuBar); // Add the menus AddChild(menuBar); }
void MainWindow::MenusBeginning() { BRow* sel = teamView->CurrentSelection(); bool is_sel = (sel != NULL); BMenu *menu = (BMenu *)FindView("MenuBar"); BMenuItem *item = menu->FindItem(IE_MAINWINDOW_MAINKILL); if (item) item->SetEnabled(is_sel); item = menu->FindItem(IE_MAINWINDOW_MAINSUSPEND); if (item) item->SetEnabled(is_sel); item = menu->FindItem(IE_MAINWINDOW_MAINRESUME); if (item) item->SetEnabled(is_sel); priorityMenu->SetEnabled(is_sel); priorityMenu->Update(); }
BPopUpMenu* TPrefsWindow::_BuildAccountMenu(uint32 account) { BPopUpMenu* menu = new BPopUpMenu(""); BMenuItem* item; //menu->SetRadioMode(true); BList chains; if (GetOutboundMailChains(&chains) < B_OK) { menu->AddItem(item = new BMenuItem("<no account found>", NULL)); item->SetEnabled(false); return menu; } BMessage* msg; for (int32 i = 0; i < chains.CountItems(); i++) { BMailChain* chain = (BMailChain*)chains.ItemAt(i); item = new BMenuItem(chain->Name(), msg = new BMessage(P_ACCOUNT)); msg->AddInt32("id",chain->ID()); if (account == chain->ID()) item->SetMarked(true); menu->AddItem(item); delete chain; } return menu; }
void PriorityMenu::BuildMenu() { BMenuItem* item; BMessage* message; long found = false; for (long index = 0; ; index++) { PriorityRec *priority = &priorities[index]; if (priority->priority < 0) break; if (!found && fPriority < priority->priority && fPriority >= 0) { priority = &customPriority; priority->priority = fPriority; index--; } message = new BMessage(SET_PRIORITY); message->AddInt32("priority", priority->priority); BString name; const size_t size = B_OS_NAME_LENGTH * 4; snprintf(name.LockBuffer(size), size, "%s [%d]", priority->name, (int)priority->priority); name.UnlockBuffer(); item = new BMenuItem(name.String(), message); item->SetTarget(slayer->mainWindow); item->SetEnabled(fEnabled); if (fPriority == priority->priority) found = true, item->SetMarked(true); AddItem(item); } }
void CheckView::RedoCatPopUp() { EmptyMenu(catPop); if (tsf) { BMenuItem* mi = new BMenuItem("Clear Transfer", new BMessage(ClearTransferMSG)); catPop->AddItem(mi); if (!catS->empty()) catPop->AddSeparatorItem(); } else if (theSplCat) { BMenuItem* mi = new BMenuItem("Clear Split", new BMessage(ClearSplitMSG)); catPop->AddItem(mi); catPop->AddSeparatorItem(); } if (curTra && !tsf && curTra->cat) { BMessage* msg = new BMessage(CheckPopCatMSG); msg->AddString("text", curTra->cat->Name().c_str()); BMenuItem* mi = new BMenuItem(curTra->cat->Name().c_str(), msg); catPop->AddItem(mi); mi->SetEnabled(theSplCat == 0); catPop->AddSeparatorItem(); } for (cas::iterator ci = catS->begin(); ci != catS->end(); ci++) { if ((*ci)->IsRoot()) { catPop->AddItem(MakeCatMenu(*ci, theSplCat == 0 && !tsf)); } } }
/// helper function to create menu item. BMenuItem* BeSkinView::createMenuItem(SInt32 nameId, uint32 command, int8 shortcut, uint32 modifiers) { NativeStringLoader* nsl = CoveredCalcApp::GetInstance(); MBCString sourceLabel = nsl->LoadNativeString(nameId); BString label; char trigger = parseMenuItemTrigger(sourceLabel, label); BMenuItem* newItem = new BMenuItem(label.String(), new BMessage(command), shortcut, modifiers); newItem->SetTrigger(trigger); bool isEnabled = true; bool isChecked = false; SInt32 commandId = getMenuCommand(command); UInt32 itemStates = uiManager->GetCommandState(commandId); if (itemStates & UIManager::CommandState_Checked) { isChecked = true; } if (itemStates & UIManager::CommandState_Disabled) { isEnabled = false; } newItem->SetEnabled(isEnabled); newItem->SetMarked(isChecked); return newItem; }
void BVolumeWindow::AddFileMenu(BMenu *menu) { menu->AddItem(new BMenuItem(B_TRANSLATE("Find"B_UTF8_ELLIPSIS), new BMessage(kFindButton), 'F')); menu->AddSeparatorItem(); menu->AddItem(new BMenuItem(B_TRANSLATE("Open"), new BMessage(kOpenSelection), 'O')); menu->AddItem(new BMenuItem(B_TRANSLATE("Get info"), new BMessage(kGetInfo), 'I')); menu->AddItem(new BMenuItem(B_TRANSLATE("Edit name"), new BMessage(kEditItem), 'E')); BMenuItem* item = new BMenuItem(B_TRANSLATE("Unmount"), new BMessage(kUnmountVolume), 'U'); item->SetEnabled(false); menu->AddItem(item); menu->AddItem(new BMenuItem(B_TRANSLATE("Mount settings" B_UTF8_ELLIPSIS), new BMessage(kRunAutomounterSettings))); menu->AddSeparatorItem(); menu->AddItem(new BMenu(B_TRANSLATE("Add-ons"))); menu->SetTargetForItems(PoseView()); }
BMenuItem* AmTrackInfoView::NewChangeViewItem() const { AmViewFactory* factory = AmGlobals().FactoryNamed(mFactorySignature); if (!factory) return NULL; BMenu* menu = new BMenu(AM_INFO_CHANGE_VIEW_STR); if (!menu) return NULL; BMenuItem* item; BString name; for (uint32 k = 0; factory->DataNameAt(k, mViewType, name) == B_OK; k++) { BMessage* msg = new BMessage(CHANGE_INFO_MSG); if( msg && (item = new BMenuItem( name.String(), msg )) ) { msg->AddPointer(SZ_VIEW_ID, this); msg->AddString(SZ_FACTORY_SIGNATURE, mFactorySignature.String() ); msg->AddString(SZ_FACTORY_VIEW_NAME, name.String() ); item->SetTarget(this); menu->AddItem(item); if (name == mViewName) item->SetEnabled(false); } name = (const char*)NULL; } item = new BMenuItem(menu); if( !item ) { delete menu; return NULL; } menu->SetFontSize( Prefs().Size(FONT_Y) ); menu->SetFont( be_plain_font ); return item; }
void BVolumeWindow::MenusBeginning() { _inherited::MenusBeginning(); if (!fMenuBar) return; BVolume boot; BVolumeRoster().GetBootVolume(&boot); bool ejectableVolumeSelected = false; int32 count = PoseView()->SelectionList()->CountItems(); for (int32 index = 0; index < count; index++) { Model *model = PoseView()->SelectionList()->ItemAt(index)->TargetModel(); if (model->IsVolume()) { BVolume volume; volume.SetTo(model->NodeRef()->device); if (volume != boot) { ejectableVolumeSelected = true; break; } } } BMenuItem* item = fMenuBar->FindItem(kUnmountVolume); if (item) item->SetEnabled(ejectableVolumeSelected); }
void ShowImageWindow::_EnableMenuItem(BMenu *menu, uint32 what, bool enable) { BMenuItem* item = menu->FindItem(what); if (item && item->IsEnabled() != enable) item->SetEnabled(enable); }
void NetworkMenu::AttachedToWindow (void) { if (CountItems()) { BMenuItem *item (NULL); while ((item = RemoveItem((int32)0)) != NULL) delete item; } BMessage msg; BMessage *invoke (NULL); for (int32 i = 0; (msg = vision_app->GetNetwork (i)), !msg.HasBool ("error"); i++) { const char *name = msg.FindString ("name"); invoke = new BMessage (fMsgConst); invoke->AddString ("network", name); BMenuItem *item (new BMenuItem(name, invoke)); AddItem (item); if (!vision_app->CheckNetworkValid (name)) item->SetEnabled (false); } SetTargetForItems (fTarget.Target(NULL)); BMenu::AttachedToWindow(); }
BPopUpMenu* TPrefsWindow::_BuildAccountMenu(int32 account) { BPopUpMenu* menu = new BPopUpMenu(""); BMenuItem* item; //menu->SetRadioMode(true); BMailAccounts accounts; if (accounts.CountAccounts() == 0) { menu->AddItem(item = new BMenuItem(B_TRANSLATE("<no account found>"), NULL)); item->SetEnabled(false); return menu; } BMessage* msg; for (int32 i = 0; i < accounts.CountAccounts(); i++) { BMailAccountSettings* settings = accounts.AccountAt(i); item = new BMenuItem(settings->Name(), msg = new BMessage(P_ACCOUNT)); msg->AddInt32("id", settings->AccountID()); if (account == settings->AccountID()) item->SetMarked(true); menu->AddItem(item); } return menu; }
void SerialWindow::MenusBeginning() { // remove all items from the menu while(fConnectionMenu->RemoveItem(0L)); // fill it with the (updated) serial port list BSerialPort serialPort; int deviceCount = serialPort.CountDevices(); for(int i = 0; i < deviceCount; i++) { char buffer[256]; serialPort.GetDeviceName(i, buffer, 256); BMessage* message = new BMessage(kMsgOpenPort); message->AddString("port name", buffer); BMenuItem* portItem = new BMenuItem(buffer, message); portItem->SetTarget(be_app); fConnectionMenu->AddItem(portItem); } if (deviceCount > 0) { fConnectionMenu->AddSeparatorItem(); BMenuItem* disconnect = new BMenuItem("Disconnect", new BMessage(kMsgOpenPort), 'Z', B_OPTION_KEY); fConnectionMenu->AddItem(disconnect); } else { BMenuItem* noDevices = new BMenuItem("<no serial port available>", NULL); noDevices->SetEnabled(false); fConnectionMenu->AddItem(noDevices); } }
void AttributeWindow::_CheckDisplayAs() { // check display as suported types type_code currentType = _CurrentType(); BMenu* menu = fDisplayAsMenuField->Menu(); for (int32 i = menu->CountItems(); i-- > 0;) { BMenuItem* item = menu->ItemAt(i); bool supported = item == _DefaultDisplayAs(); // the default type is always supported type_code type; for (int32 j = 0; item->Message()->FindInt32("supports", j, (int32*)&type) == B_OK; j++) { if (type == currentType) { supported = true; break; } } item->SetEnabled(supported); if (item->IsMarked() && !supported) menu->ItemAt(0)->SetMarked(true); } fSpecialControl->SetEnabled(!_DefaultDisplayAs()->IsMarked()); }
BPopUpMenu* AmControlChangeInfoView::NewPropertiesMenu() const { BPopUpMenu* menu = inherited::NewPropertiesMenu(); if (!menu) return menu; mCachedControlMenu = NewControlMenu(); if (!mCachedControlMenu) return menu; BMenuItem* item; if (mCachedControlMenu->CountItems() < 1 ) { item = new _AmActiveControlItem( "<track has no output filter>", new BMessage('null') ); if (item) { item->SetEnabled( false ); mCachedControlMenu->AddItem(item); } } item = new BMenuItem(mCachedControlMenu); if (!item) { delete mCachedControlMenu; mCachedControlMenu = NULL; return menu; } menu->AddSeparatorItem(); menu->AddItem(item); return menu; }
PieView::PieView(BVolume* volume) : BView(NULL, B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE | B_SUBPIXEL_PRECISE), fWindow(NULL), fScanner(NULL), fVolume(volume), fMouseOverInfo(), fClicked(false), fDragging(false), fUpdateFileAt(false) { fMouseOverMenu = new BPopUpMenu(kEmptyStr, false, false); fMouseOverMenu->AddItem(new BMenuItem(B_TRANSLATE("Get Info"), NULL), kIdxGetInfo); fMouseOverMenu->AddItem(new BMenuItem(B_TRANSLATE("Open"), NULL), kIdxOpen); fFileUnavailableMenu = new BPopUpMenu(kEmptyStr, false, false); BMenuItem* item = new BMenuItem(B_TRANSLATE("file unavailable"), NULL); item->SetEnabled(false); fFileUnavailableMenu->AddItem(item); BFont font; GetFont(&font); font.SetSize(ceilf(font.Size() * 1.33)); font.SetFace(B_BOLD_FACE); SetFont(&font); struct font_height fh; font.GetHeight(&fh); fFontHeight = ceilf(fh.ascent) + ceilf(fh.descent) + ceilf(fh.leading); }
void IconView::MouseDown(BPoint where) { if (!IsEnabled()) return; int32 buttons = B_PRIMARY_MOUSE_BUTTON; int32 clicks = 1; if (Looper() != NULL && Looper()->CurrentMessage() != NULL) { if (Looper()->CurrentMessage()->FindInt32("buttons", &buttons) != B_OK) buttons = B_PRIMARY_MOUSE_BUTTON; if (Looper()->CurrentMessage()->FindInt32("clicks", &clicks) != B_OK) clicks = 1; } if ((buttons & B_PRIMARY_MOUSE_BUTTON) != 0 && BitmapRect().Contains(where)) { if (clicks == 2) { // double click - open Icon-O-Matic Invoke(); } else if (fIcon != NULL) { // start tracking - this icon might be dragged around fDragPoint = where; fTracking = true; SetMouseEventMask(B_POINTER_EVENTS, B_NO_POINTER_HISTORY); } } if ((buttons & B_SECONDARY_MOUSE_BUTTON) != 0) { // show context menu ConvertToScreen(&where); BPopUpMenu* menu = new BPopUpMenu("context"); menu->SetFont(be_plain_font); bool hasIcon = fHasType ? fSource == kOwnIcon : fIcon != NULL; if (hasIcon) { menu->AddItem(new BMenuItem( B_TRANSLATE("Edit icon" B_UTF8_ELLIPSIS), new BMessage(kMsgEditIcon))); } else { menu->AddItem(new BMenuItem( B_TRANSLATE("Add icon" B_UTF8_ELLIPSIS), new BMessage(kMsgAddIcon))); } BMenuItem* item = new BMenuItem( B_TRANSLATE("Remove icon"), new BMessage(kMsgRemoveIcon)); if (!hasIcon) item->SetEnabled(false); menu->AddItem(item); menu->SetTargetForItems(fTarget); menu->Go(where, true, false, true); } }
void TBeMenu::DoneBuildingItemList() { if (fItemList->CountItems() <= 0) { BMenuItem* item = new BMenuItem("<Be folder is empty>", 0); item->SetEnabled(false); AddItem(item); } else BNavMenu::DoneBuildingItemList(); }
void PDocument::ResetModified(void) { bool locked = Lock(); BMenuItem *saveItem = GetMenuItem(P_MENU_FILE_SAVE); if ((saveItem) && (entryRef != NULL)) saveItem->SetEnabled(false); modified=false; if (locked) Unlock(); }
void TDeskbarMenu::DoneBuildingItemList() { if (fItemList->CountItems() <= 0) { BMenuItem* item = new BMenuItem(B_TRANSLATE("<Deskbar folder is empty>"), 0); item->SetEnabled(false); AddItem(item); } else BNavMenu::DoneBuildingItemList(); }
BMenuItem* ShowImageWindow::_AddItemMenu(BMenu *menu, const char *label, uint32 what, const char shortcut, uint32 modifier, const BHandler *target, bool enabled) { BMenuItem* item = new BMenuItem(label, new BMessage(what), shortcut, modifier); menu->AddItem(item); item->SetTarget(target); item->SetEnabled(enabled); return item; }
void SeqManageRosterWindow::MenusBeginning() { inherited::MenusBeginning(); BMenuBar* bar = KeyMenuBar(); if (!bar) return; BColumnListView* table = dynamic_cast<BColumnListView*>( FindView(TABLE_STR) ); if (!table) return; BMenu* menu; BMenuItem* item; // Entry menu bool canEdit = false, canDuplicate = false; BString key, filePath; bool readOnly; if (GetSelectionInfo(key, filePath, &readOnly) == B_OK) { canEdit = !readOnly; canDuplicate = true; } if ( (menu = bar->SubmenuAt(ENTRY_MENU_INDEX)) != NULL) { if ( (item = menu->FindItem(EDIT_ENTRY_MSG)) != NULL) item->SetEnabled(canEdit); if ( (item = menu->FindItem(DUPLICATE_ENTRY_MSG)) != NULL) item->SetEnabled(canDuplicate); if ( (item = menu->FindItem(DELETE_ENTRY_MSG)) != NULL) item->SetEnabled(canEdit); } // Attributes menu 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); } } } } }
void TCueSheetWindow::AdjustCueMenu() { BMenu* theMenu = fAppMenu->GetCueMenu(); if (theMenu) { // Get Cue Info // Enable if any items are selected BMenuItem* cueInfoItem = theMenu->FindItem(CUESHEET_GETINFO_MSG); if (cueInfoItem) cueInfoItem->SetEnabled( fCueSheetView->ItemsSelected() ); // Default Cue Setup // Enable if any items are selected //BMenuItem *cueInfoItem = theMenu->FindItem(CUESHEET_GETINFO_MSG); //if (cueInfoItem) // cueInfoItem->SetEnabled( fCueSheetView->ItemsSelected() ); // Show Cue Contents // Enable if any items are selected BMenuItem* showContentsItem = theMenu->FindItem(CUESHEET_SHOWCONTENTS_MSG); if (showContentsItem) showContentsItem->SetEnabled( fCueSheetView->ItemsSelected() ); // Show All Cue Contents // Enable if we have cues BMenuItem* showAllContentsItem = theMenu->FindItem(CUESHEET_SHOWALLCONTENTS_MSG); if (showAllContentsItem) showAllContentsItem->SetEnabled( fCueSheetView->HasCues() ); // Hide All Cue Contents // Enable if we have cues BMenuItem* hideAllContentsItem = theMenu->FindItem(CUESHEET_HIDEALLCONTENTS_MSG); if (hideAllContentsItem) hideAllContentsItem->SetEnabled( fCueSheetView->HasCues() ); // Cue Setup // Enable if any items are selected BMenuItem* setupItem = theMenu->FindItem(CUESHEET_SETUP_MSG); if (setupItem) setupItem->SetEnabled( fCueSheetView->ItemsSelected() ); // Open Cue Editor // Enable if any items are selected BMenuItem* editItem = theMenu->FindItem(CUESHEET_EDIT_MSG); if (editItem) editItem->SetEnabled( fCueSheetView->ItemsSelected() ); // Add Keyframes // Enable if any items are selected BMenuItem* keyframeItem = theMenu->FindItem(CUESHEET_KEYFRAME_MSG); if (keyframeItem) keyframeItem->SetEnabled( fCueSheetView->ItemsSelected() ); } }