本文整理汇总了C++中BMenuItem::SetEnabled方法的典型用法代码示例。如果您正苦于以下问题:C++ BMenuItem::SetEnabled方法的具体用法?C++ BMenuItem::SetEnabled怎么用?C++ BMenuItem::SetEnabled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BMenuItem
的用法示例。
在下文中一共展示了BMenuItem::SetEnabled方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MakeCatMenu
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;
}
示例2: AdjustFileMenu
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);
}
}
}
示例3: mouseRect
// 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;
}
示例4: BMessage
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);
}
示例5:
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());
}
示例6:
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);
}
示例7: BMessage
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);
}
示例8: BMenuBar
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);
}
示例9:
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();
}
示例10: BPopUpMenu
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;
}
示例11: BMessage
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);
}
}
示例12: RedoCatPopUp
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));
}
}
}
示例13: createMenuItem
/// 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;
}
示例14: BMessage
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());
}
示例15: NewChangeViewItem
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;
}