void SubsTextEditCtrl::AddSpellCheckerEntries(wxMenu &menu) { if (currentWord.empty()) return; sugs = spellchecker->GetSuggestions(currentWord); if (spellchecker->CheckWord(currentWord)) { if (sugs.empty()) menu.Append(EDIT_MENU_SUGGESTION,_("No spell checker suggestions"))->Enable(false); else { wxMenu *subMenu = new wxMenu; for (size_t i = 0; i < sugs.size(); ++i) subMenu->Append(EDIT_MENU_SUGGESTIONS+i, to_wx(sugs[i])); menu.Append(-1, wxString::Format(_("Spell checker suggestions for \"%s\""), to_wx(currentWord)), subMenu); } } else { if (sugs.empty()) menu.Append(EDIT_MENU_SUGGESTION,_("No correction suggestions"))->Enable(false); for (size_t i = 0; i < sugs.size(); ++i) menu.Append(EDIT_MENU_SUGGESTIONS+i, to_wx(sugs[i])); // Append "add word" menu.Append(EDIT_MENU_ADD_TO_DICT, wxString::Format(_("Add \"%s\" to dictionary"), to_wx(currentWord)))->Enable(spellchecker->CanAddWord(currentWord)); } }
void CompilerMessages::AppendAdditionalMenuItems(wxMenu &menu) { menu.Append(idMenuFit, _("Fit text"), _("Makes the whole text visible")); menu.AppendCheckItem(idMenuAutoFit, _("Fit automatically"), _("Automatically makes the whole text visible during compilation")); menu.Check(idMenuAutoFit, m_autoFit); }
void RightPopupMenu::CreateCommonMenu(wxMenu& menu) { if (m_edited_sprs.empty()) { return; } m_parent->Bind(wxEVT_COMMAND_MENU_SELECTED, &EditPanelImpl::OnRightPopupMenu, m_stage, MENU_UP_LAYER); menu.Append(MENU_UP_LAYER, "ÉÏÒÆÒ»²ã"); m_parent->Bind(wxEVT_COMMAND_MENU_SELECTED, &EditPanelImpl::OnRightPopupMenu, m_stage, MENU_DOWN_LAYER); menu.Append(MENU_DOWN_LAYER, "ÏÂÒÆÒ»²ã"); m_parent->Bind(wxEVT_COMMAND_MENU_SELECTED, &EditPanelImpl::OnRightPopupMenu, m_stage, MENU_UP_MOST); menu.Append(MENU_UP_MOST, "ÒƵ½¶¥"); m_parent->Bind(wxEVT_COMMAND_MENU_SELECTED, &EditPanelImpl::OnRightPopupMenu, m_stage, MENU_DOWN_MOST); menu.Append(MENU_DOWN_MOST, "ÒƵ½µ×"); menu.AppendSeparator(); m_parent->Bind(wxEVT_COMMAND_MENU_SELECTED, &EditPanelImpl::OnRightPopupMenu, m_stage, MENU_HORI_MIRROR); menu.Append(MENU_HORI_MIRROR, "ˮƽ¾µÏñ"); m_parent->Bind(wxEVT_COMMAND_MENU_SELECTED, &EditPanelImpl::OnRightPopupMenu, m_stage, MENU_VERT_MIRROR); menu.Append(MENU_VERT_MIRROR, "ÊúÖ±¾µÏñ"); menu.AppendSeparator(); if (m_edited_sprs.size() == 1) { m_parent->Bind(wxEVT_COMMAND_MENU_SELECTED, &EditPanelImpl::OnRightPopupMenu, m_stage, MENU_SELECT_SAME); menu.Append(MENU_SELECT_SAME, "Ñ¡ÔñÏàͬ"); menu.AppendSeparator(); } }
//Hack to allow use (events) of wxmenu inside a tool like simpletexttool void hdDrawingView::connectPopUpMenu(wxMenu &mnu) { // Connect the main menu mnu.Connect(wxEVT_COMMAND_MENU_SELECTED, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) &hdDrawingView::OnGenericPopupClick, NULL, this); // Connect all submenus wxMenuItem *item; wxMenuItemList list = mnu.GetMenuItems(); for (unsigned int index = 0; index < list.GetCount(); index++) { wxMenuItemList::compatibility_iterator node = list.Item(index); item = (wxMenuItem *) node->GetData(); if (item->IsSubMenu()) { wxMenu *submenu = item->GetSubMenu(); submenu->Connect(wxEVT_COMMAND_MENU_SELECTED, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) &hdDrawingView::OnGenericPopupClick, NULL, this); } } }
void showPopupMenu( wxMenu& menu ) override { if( m_grid->GetGridCursorCol() == COL_OPTIONS ) { menu.Append( MYID_OPTIONS_EDITOR, _( "Options Editor..." ), _( "Edit options" ) ); menu.AppendSeparator(); } GRID_TRICKS::showPopupMenu( menu ); }
void wxHeaderCtrlBase::AddColumnsItems(wxMenu& menu, int idColumnsBase) { const unsigned count = GetColumnCount(); for ( unsigned n = 0; n < count; n++ ) { const wxHeaderColumn& col = GetColumn(n); menu.AppendCheckItem(idColumnsBase + n, col.GetTitle()); if ( col.IsShown() ) menu.Check(n, true); } }
void ddColumnOptionIcon::createMenu(wxMenu &mnu) { wxMenuItem *item; item = mnu.AppendCheckItem(MNU_COLNULL, _("NULL")); item->Check(colOption == null); item->Enable(!getOwnerColumn()->isGeneratedForeignKey()); item = mnu.AppendCheckItem(MNU_COLNOTNULL, _("Not NULL")); item->Check(colOption == notnull); item->Enable(!getOwnerColumn()->isGeneratedForeignKey()); }
bool LocationView::MouseRightDown(const Point2D& mousePt, wxMenu& popupMenu) { if(IsClicked(mousePt)) { if(popupMenu.GetMenuItems().size() == 0) { popupMenu.Append(ID_POPUP_MNU_PROPERTIES, wxT("Properties")); } return true; } return false; }
void RightPopupMenu::CreateDebugMenu(wxMenu& menu) { if (m_edited_sprs.empty()) { return; } #ifdef _DEBUG m_parent->Bind(wxEVT_COMMAND_MENU_SELECTED, &EditPanelImpl::OnRightPopupMenu, m_stage, MENU_INSERT_TO_DTEX); menu.Append(MENU_INSERT_TO_DTEX, "Insert To DTex"); m_parent->Bind(wxEVT_COMMAND_MENU_SELECTED, &EditPanelImpl::OnRightPopupMenu, m_stage, MENU_REMOVE_FROM_DTEX); menu.Append(MENU_REMOVE_FROM_DTEX, "Remove From DTex"); menu.AppendSeparator(); #endif }
void RightPopupMenu::CreateSelectMenu(wxMenu& menu) { if (m_selected_sprs.size() <= 1) { return; } int sz = std::min(MENU_MULTI_SELECTED_END - MENU_MULTI_SELECTED + 1, (int)m_selected_sprs.size()); for (int i = 0; i < sz; ++i) { auto spr = m_selected_sprs[i]; m_parent->Bind(wxEVT_COMMAND_MENU_SELECTED, &EditPanelImpl::OnRightPopupMenu, m_stage, MENU_MULTI_SELECTED + i); auto name = FileHelper::GetFilename(std::dynamic_pointer_cast<ee::Symbol>(spr->GetSymbol())->GetFilepath()); menu.Append(MENU_MULTI_SELECTED + i, name.c_str()); } menu.AppendSeparator(); }
void SubsTextEditCtrl::AddThesaurusEntries(wxMenu &menu) { if (currentWord.empty()) return; if (!thesaurus) thesaurus.reset(new Thesaurus); std::vector<Thesaurus::Entry> results; thesaurus->Lookup(currentWord, &results); thesSugs.clear(); if (results.size()) { wxMenu *thesMenu = new wxMenu; int curThesEntry = 0; for (auto const& result : results) { // Single word, insert directly if (result.second.size() == 1) { thesMenu->Append(EDIT_MENU_THESAURUS_SUGS+curThesEntry, to_wx(result.first)); thesSugs.push_back(result.first); ++curThesEntry; } // Multiple, create submenu else { wxMenu *subMenu = new wxMenu; for (auto const& sug : result.second) { subMenu->Append(EDIT_MENU_THESAURUS_SUGS+curThesEntry, to_wx(sug)); thesSugs.push_back(sug); ++curThesEntry; } thesMenu->Append(-1, to_wx(result.first), subMenu); } } menu.Append(-1, wxString::Format(_("Thesaurus suggestions for \"%s\""), to_wx(currentWord)), thesMenu); } else menu.Append(EDIT_MENU_THESAURUS,_("No thesaurus suggestions"))->Enable(false); // Append language list menu.Append(-1,_("Thesaurus language"), GetLanguagesMenu( EDIT_MENU_THES_LANGS, to_wx(OPT_GET("Tool/Thesaurus/Language")->GetString()), to_wx(thesaurus->GetLanguageList()))); menu.AppendSeparator(); }
void CommandProcessorBase::DoPopulateUnRedoMenu(wxMenu& menu, bool undoing) { wxString prefix(undoing ? _("Undo ") : _("Redo ")); int id = FIRST_MENU_ID; int count = 0; if (undoing) { if (GetCommands().size() > 0) { for (CLCommand::Vec_t::const_reverse_iterator iter = GetCommands().rbegin() + GetNextUndoCommand(); iter != GetCommands().rend(); ++iter) { CLCommand::Ptr_t command = *iter; if (command) { wxString label; if (!command->GetUserLabel().empty()) { if (command->GetName().Contains(":")) { label = command->GetName().BeforeFirst(':') + ": "; } label << command->GetUserLabel(); } else { if (command == GetOpenCommand()) { label = GetBestLabel(command); // If the command's still open, there won't otherwise be a name string } else { label = command->GetName(); } } menu.Append(id++, wxString::Format("%i ", ++count) + prefix + label); } } } } else { for (CLCommand::Vec_t::const_iterator iter = GetCommands().begin() + GetCurrentCommand() + 1; iter != GetCommands().end(); ++iter) { CLCommand::Ptr_t command = *iter; if (command) { wxString label; if (!command->GetUserLabel().empty()) { if (command->GetName().Contains(":")) { label = command->GetName().BeforeFirst(':') + ": "; } label << command->GetUserLabel(); } else { label = command->GetName(); } menu.Append(id++, wxString::Format("%i ", ++count) + prefix + label); } } } }
void DebuggerMenuHandler::BuildContextMenu(wxMenu &menu, const wxString& word_at_caret, bool is_running) { cbDebuggerPlugin *plugin = Manager::Get()->GetDebuggerManager()->GetActiveDebugger(); if (!plugin) return; int item = 0; // Insert Run to Cursor if (plugin->SupportsFeature(cbDebuggerFeature::RunToCursor)) menu.Insert(item++, idMenuRunToCursor, _("Run to cursor")); if (is_running) { if (plugin->SupportsFeature(cbDebuggerFeature::SetNextStatement)) menu.Insert(item++, idMenuSetNextStatement, _("Set next statement")); if (item > 0) menu.InsertSeparator(item++); if (!word_at_caret.empty()) { if (plugin->SupportsFeature(cbDebuggerFeature::Watches)) menu.Insert(item++, idMenuDebuggerAddWatch, wxString::Format(_("Watch '%s'"), word_at_caret.c_str())); // data breakpoint if (plugin->SupportsFeature(cbDebuggerFeature::Breakpoints)) { menu.Insert(item++, idMenuAddDataBreakpoint, wxString::Format(_("Add data breakpoint for '%s'"), word_at_caret.c_str())); } } } // Insert toggle breakpoint if (plugin->SupportsFeature(cbDebuggerFeature::Breakpoints)) menu.Insert(item++, idMenuToggleBreakpoint, _("Toggle breakpoint")); if (item > 0) menu.InsertSeparator(item++); }
void DebuggerMenuHandler::AppendWindowMenuItems(wxMenu &menu) { std::map<wxString, long> sortedNames; for (WindowMenuItemsMap::iterator it = m_windowMenuItems.begin(); it != m_windowMenuItems.end(); ++it) sortedNames[it->second.name] = it->first; for (std::map<wxString, long>::iterator it = sortedNames.begin(); it != sortedNames.end(); ++it) menu.AppendCheckItem(it->second, it->first, m_windowMenuItems[it->second].help); }
void SetMenu( wxMenu* menu, const OS_string& items, EnabledCallback enabledCallback = NULL ) { // protect the MRU so that it is only tied to one menu HELIUM_ASSERT( m_Menu == NULL || m_Menu == menu ); m_Menu = menu; m_MenuItemIDToString.clear(); // Clear out the old menu items while ( m_Menu->GetMenuItemCount() > 0 ) { m_Menu->Delete( *( m_Menu->GetMenuItems().begin() ) ); } // Build a new list of menu items from the MRU OS_string::ReverseIterator mruItr = items.ReverseBegin(); OS_string::ReverseIterator mruEnd = items.ReverseEnd(); for ( ; mruItr != mruEnd; ++mruItr ) { const tstring& item = *mruItr; wxMenuItem* menuItem = menu->Append( wxID_ANY, item.c_str() ); bool enabled = true; if ( enabledCallback ) { enabled = (*enabledCallback)( item ); } if ( enabled ) { Connect( menuItem->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MenuMRUEvtHandler::OnMRUMenuItem ), NULL, this ); } else { menuItem->SetItemLabel( ( item + TXT( " (missing)" ) ).c_str() ); menuItem->Enable( false ); } m_MenuItemIDToString.insert( M_MenuItemIDToString::value_type( menuItem->GetId(), item ) ); } }
void wxcEditManager::DoPopulateUnRedoMenu(wxMenu& menu, bool undoing) { wxString prefix(undoing ? _("Undo ") : _("Redo ")); int id = FIRST_MENU_ID; int count = 0; if(undoing) { if(m_undoList.size() > 0) { for(State::List_t::const_reverse_iterator iter = m_undoList.rbegin(); iter != m_undoList.rend(); ++iter) { State::Ptr_t command = *iter; if(command) { menu.Append(id++, wxString::Format("%i ", ++count) + prefix + command->label); } } } } else { for(State::List_t::const_reverse_iterator iter = m_redoList.rbegin(); iter != m_redoList.rend(); ++iter) { State::Ptr_t command = *iter; if(command) { menu.Append(id++, wxString::Format("%i ", ++count) + prefix + command->label); } } } }
void PCB_LAYER_WIDGET::AddRightClickMenuItems( wxMenu& menu ) { // menu text is capitalized: // http://library.gnome.org/devel/hig-book/2.20/design-text-labels.html.en#layout-capitalization AddMenuItem( &menu, ID_SHOW_ALL_COPPER_LAYERS, _( "Show All Copper Layers" ), KiBitmap( select_layer_pair_xpm ) ); AddMenuItem( &menu, ID_SHOW_NO_COPPER_LAYERS_BUT_ACTIVE, _( "Hide All Copper Layers But Active" ), KiBitmap( select_w_layer_xpm ) ); AddMenuItem( &menu, ID_ALWAYS_SHOW_NO_COPPER_LAYERS_BUT_ACTIVE, _( "Always Hide All Copper Layers But Active" ), KiBitmap( select_w_layer_xpm ) ); AddMenuItem( &menu, ID_SHOW_NO_COPPER_LAYERS, _( "Hide All Copper Layers" ), KiBitmap( show_no_copper_layers_xpm ) ); menu.AppendSeparator(); AddMenuItem( &menu, ID_SHOW_ALL_NON_COPPER, _( "Show All Non Copper Layers" ), KiBitmap( select_w_layer_xpm ) ); AddMenuItem( &menu, ID_HIDE_ALL_NON_COPPER, _( "Hide All Non Copper Layers" ), KiBitmap( show_no_copper_layers_xpm ) ); menu.AppendSeparator(); AddMenuItem( &menu, ID_SHOW_NO_LAYERS, _( "Hide All Layers" ), KiBitmap( show_no_layers_xpm ) ); AddMenuItem( &menu, ID_SHOW_ALL_LAYERS, _( "Show All Layers" ), KiBitmap( show_all_layers_xpm ) ); menu.AppendSeparator(); AddMenuItem( &menu, ID_SHOW_ALL_FRONT, _( "Show All Front Layers" ), KiBitmap( show_no_layers_xpm ) ); AddMenuItem( &menu, ID_SHOW_ALL_BACK, _( "Show All Back Layers" ), KiBitmap( show_all_layers_xpm ) ); }
void Scrubber::PopulateMenu(wxMenu &menu) { int id = CMD_ID; auto cm = mProject->GetCommandManager(); const MenuItem *checkedItem = HasStartedScrubbing() ? &FindMenuItem(mSmoothScrollingScrub, mAlwaysSeeking) : nullptr; for (const auto &item : menuItems) { if (cm->GetEnabled(item.name)) { #ifdef CHECKABLE_SCRUB_MENU_ITEMS menu.AppendCheckItem(id, item.label); if(&item == checkedItem) menu.FindItem(id)->Check(); #else menu.Append(id, item.label); #endif } ++id; } }
void SubsTextEditCtrl::AddSpellCheckerEntries(wxMenu &menu) { if (currentWord.empty()) return; if (spellchecker->CanRemoveWord(currentWord)) menu.Append(EDIT_MENU_REMOVE_FROM_DICT, fmt_tl("Remove \"%s\" from dictionary", currentWord)); sugs = spellchecker->GetSuggestions(currentWord); if (spellchecker->CheckWord(currentWord)) { if (sugs.empty()) menu.Append(EDIT_MENU_SUGGESTION,_("No spell checker suggestions"))->Enable(false); else { auto subMenu = new wxMenu; for (size_t i = 0; i < sugs.size(); ++i) subMenu->Append(EDIT_MENU_SUGGESTIONS+i, to_wx(sugs[i])); menu.Append(-1, fmt_tl("Spell checker suggestions for \"%s\"", currentWord), subMenu); } } else { if (sugs.empty()) menu.Append(EDIT_MENU_SUGGESTION,_("No correction suggestions"))->Enable(false); for (size_t i = 0; i < sugs.size(); ++i) menu.Append(EDIT_MENU_SUGGESTIONS+i, to_wx(sugs[i])); // Append "add word" menu.Append(EDIT_MENU_ADD_TO_DICT, fmt_tl("Add \"%s\" to dictionary", currentWord))->Enable(spellchecker->CanAddWord(currentWord)); } }
//----------------------------------------------------------------------------- // wxDockTaskBarIcon::PopupMenu // // 2.4 and wxPython method that "pops of the menu in the taskbar". // // In reality because of the way the dock menu works in carbon // we just save the menu, and if the user didn't override CreatePopupMenu // return the menu passed here, thus sort of getting the same effect. //----------------------------------------------------------------------------- bool wxDockTaskBarIcon::PopupMenu(wxMenu *menu) { wxASSERT(menu != NULL); delete m_pMenu; // start copy of menu m_pMenu = wxDeepCopyMenu(menu); // finish up m_pMenu->SetInvokingWindow(m_menuEventWindow); return true; }
void RebrandingHelper::ApplyBranding(wxMenu & menu, wxString scope) { size_t separatorIndex = 0; wxMenuItemList & itemsList = menu.GetMenuItems(); for(auto itemIt = itemsList.begin(); itemIt != itemsList.end();++itemIt) { wxMenuItem * item = *itemIt; if (!item) continue; wxString name = menu.GetLabelText(item->GetId()); if (item->GetId() == wxID_SEPARATOR) { name = "Separator_"; name << separatorIndex; separatorIndex++; } wxString itemScope = scope + "." + name; if (ShouldDelete(itemScope)) menu.Destroy(item); else if (ShouldRename(itemScope)) item->SetItemLabel(GetNewName(itemScope)); } }
void DebuggerMenuHandler::BuildContextMenu(wxMenu &menu, const wxString& word_at_caret, bool is_running) { cbDebuggerPlugin *plugin = Manager::Get()->GetDebuggerManager()->GetActiveDebugger(); if (!plugin) return; PluginManager *pluginManager = Manager::Get()->GetPluginManager(); int initialItem; if (is_running) { // we want debugger menu items to be at the top when debugging initialItem = pluginManager->GetFindMenuItemFirst(); } else initialItem = pluginManager->GetFindMenuItemFirst() + pluginManager->GetFindMenuItemCount(); int item = initialItem; // Insert Run to Cursor if (plugin->SupportsFeature(cbDebuggerFeature::RunToCursor)) menu.Insert(item++, idMenuRunToCursor, _("Run to cursor")); if (is_running) { if (plugin->SupportsFeature(cbDebuggerFeature::SetNextStatement)) menu.Insert(item++, idMenuSetNextStatement, _("Set next statement")); if (item > 0) menu.InsertSeparator(item++); if (!word_at_caret.empty()) { if (plugin->SupportsFeature(cbDebuggerFeature::Watches)) menu.Insert(item++, idMenuDebuggerAddWatch, wxString::Format(_("Watch '%s'"), word_at_caret.c_str())); // data breakpoint if (plugin->SupportsFeature(cbDebuggerFeature::Breakpoints)) { menu.Insert(item++, idMenuAddDataBreakpoint, wxString::Format(_("Add data breakpoint for '%s'"), word_at_caret.c_str())); } } } // Insert toggle breakpoint if (plugin->SupportsFeature(cbDebuggerFeature::Breakpoints)) menu.Insert(item++, idMenuToggleBreakpoint, _("Toggle breakpoint")); if (item > 0) menu.InsertSeparator(item++); if (is_running) pluginManager->RegisterFindMenuItems(true, item - initialItem); }
//----------------------------------------------------------------------------- // wxDockTaskBarIcon::DoCreatePopupMenu // // Helper function that handles a request from the dock event handler // to get the menu for the dock //----------------------------------------------------------------------------- wxMenu * wxDockTaskBarIcon::DoCreatePopupMenu() { // get the menu from the parent wxMenu* theNewMenu = CreatePopupMenu(); if (theNewMenu) { delete m_pMenu; m_pMenu = theNewMenu; m_pMenu->SetInvokingWindow(m_menuEventWindow); } // the return here can be one of three things // (in order of priority): // 1) User passed a menu from CreatePopupMenu override // 2) menu sent to and copied from PopupMenu // 3) If neither (1) or (2), then NULL // return m_pMenu; }
void hdDrawingView::createViewMenu(wxMenu &mnu) { wxMenuItem *item; item = mnu.AppendCheckItem(1000, _("Sample Item")); item->Check(true); }
/** * Invoked when user selects the "Menu" item */ void WebFrame::OnToolsClicked(wxCommandEvent& WXUNUSED(evt)) { if(m_browser->GetCurrentURL() == "") return; m_tools_tiny->Check(false); m_tools_small->Check(false); m_tools_medium->Check(false); m_tools_large->Check(false); m_tools_largest->Check(false); wxWebViewZoom zoom = m_browser->GetZoom(); switch (zoom) { case wxWEBVIEW_ZOOM_TINY: m_tools_tiny->Check(); break; case wxWEBVIEW_ZOOM_SMALL: m_tools_small->Check(); break; case wxWEBVIEW_ZOOM_MEDIUM: m_tools_medium->Check(); break; case wxWEBVIEW_ZOOM_LARGE: m_tools_large->Check(); break; case wxWEBVIEW_ZOOM_LARGEST: m_tools_largest->Check(); break; } m_edit_cut->Enable(m_browser->CanCut()); m_edit_copy->Enable(m_browser->CanCopy()); m_edit_paste->Enable(m_browser->CanPaste()); m_edit_undo->Enable(m_browser->CanUndo()); m_edit_redo->Enable(m_browser->CanRedo()); m_selection_clear->Enable(m_browser->HasSelection()); m_selection_delete->Enable(m_browser->HasSelection()); m_context_menu->Check(m_browser->IsContextMenuEnabled()); //Firstly we clear the existing menu items, then we add the current ones wxMenuHistoryMap::const_iterator it; for( it = m_histMenuItems.begin(); it != m_histMenuItems.end(); ++it ) { m_tools_history_menu->Destroy(it->first); } m_histMenuItems.clear(); wxVector<wxSharedPtr<wxWebViewHistoryItem> > back = m_browser->GetBackwardHistory(); wxVector<wxSharedPtr<wxWebViewHistoryItem> > forward = m_browser->GetForwardHistory(); wxMenuItem* item; unsigned int i; for(i = 0; i < back.size(); i++) { item = m_tools_history_menu->AppendRadioItem(wxID_ANY, back[i]->GetTitle()); m_histMenuItems[item->GetId()] = back[i]; Connect(item->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(WebFrame::OnHistory), NULL, this ); } wxString title = m_browser->GetCurrentTitle(); if ( title.empty() ) title = "(untitled)"; item = m_tools_history_menu->AppendRadioItem(wxID_ANY, title); item->Check(); //No need to connect the current item m_histMenuItems[item->GetId()] = wxSharedPtr<wxWebViewHistoryItem>(new wxWebViewHistoryItem(m_browser->GetCurrentURL(), m_browser->GetCurrentTitle())); for(i = 0; i < forward.size(); i++) { item = m_tools_history_menu->AppendRadioItem(wxID_ANY, forward[i]->GetTitle()); m_histMenuItems[item->GetId()] = forward[i]; Connect(item->GetId(), wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler(WebFrame::OnHistory), NULL, this ); } wxPoint position = ScreenToClient( wxGetMousePosition() ); PopupMenu(m_tools_menu, position.x, position.y); }
//Hack to allow use (events) of wxmenu inside a tool like simpletexttool void ddDrawingView::setTextPopUpList(wxArrayString &strings, wxMenu &mnu) { //DD-TODO: choose a better id for event mnu.Disconnect(wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)(wxEventFunction) (wxCommandEventFunction) &ddDrawingView::OnTextPopupClick,NULL,this); int sz = strings.size(); //to avoid warning wxMenuItem *item = NULL; wxMenu *submenu = NULL; bool isSubItem; bool subItemsDisable=false; for(int i=0 ; i < sz ; i++){ //DD-TODO: only create options for what I need, this can be improved later //String "--submenu##menu item**sub menu title" and "--subitem--" create and add items to last created submenu isSubItem=false; item=NULL; if(strings[i].Contains(wxT("--submenu"))) { if(strings[i].Contains(wxT("--disable"))) subItemsDisable=true; else subItemsDisable=false; submenu = new wxMenu(strings[i].SubString(strings[i].find(wxT("**"))+2,strings[i].length())); mnu.AppendSubMenu(submenu,strings[i].SubString(strings[i].find(wxT("##"))+2,strings[i].find(wxT("**"))-1)); } else if(strings[i].Contains(wxT("--subitem"))) { isSubItem=true; if(submenu) { if(strings[i].Contains(wxT("--checked"))) { item=submenu->AppendCheckItem(i,strings[i].SubString(strings[i].find(wxT("**"))+2,strings[i].length())); } else { item=submenu->Append(i,strings[i].SubString(strings[i].find(wxT("**"))+2,strings[i].length())); } } else { wxMessageDialog *error = new wxMessageDialog(NULL, wxT("Error setting text popup strings list"), wxT("Error!"), wxOK | wxICON_ERROR); error->ShowModal(); delete error; } } else if(strings[i].Contains(wxT("--separator--"))) { mnu.AppendSeparator(); } else if(strings[i].Contains(wxT("--checked"))) { item = mnu.AppendCheckItem(i, strings[i].SubString(strings[i].find(wxT("**"))+2,strings[i].length())); } else if(strings[i].Contains(wxT("**"))) { item = mnu.Append(i, strings[i].SubString(strings[i].find(wxT("**"))+2,strings[i].length())); } else { item = mnu.Append(i, strings[i]); } if(item && strings[i].Contains(wxT("--checked"))) { item->Check(true); } if( item && ( strings[i].Contains(wxT("--disable")) || (submenu && isSubItem && subItemsDisable) ) ) { item->Enable(false); } } //DD-TODO: create a better version of this hack mnu.Connect(wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)(wxEventFunction) (wxCommandEventFunction) &ddDrawingView::OnTextPopupClick,NULL,this); }
void ddTextTableItemFigure::createMenu(wxMenu &mnu) { wxMenu *submenu; wxMenuItem *item; mnu.Append(MNU_DDADDCOLUMN, _("Add a column...")); item = mnu.Append(MNU_DELCOLUMN, _("Delete the selected column...")); if(getOwnerColumn()->isGeneratedForeignKey()) item->Enable(false); mnu.Append(MNU_RENAMECOLUMN, _("Rename the selected column...")); if(getOwnerColumn()->isGeneratedForeignKey() && !getOwnerColumn()->isFkNameGenerated()) mnu.Append(MNU_AUTONAMCOLUMN, _("Activate fk auto-naming...")); mnu.AppendSeparator(); item = mnu.AppendCheckItem(MNU_NOTNULL, _("Not NULL constraint")); if(getOwnerColumn()->isNotNull()) item->Check(true); if(getOwnerColumn()->isGeneratedForeignKey()) item->Enable(false); mnu.AppendSeparator(); item = mnu.AppendCheckItem(MNU_PKEY, _("Primary Key")); if(getOwnerColumn()->isPrimaryKey()) item->Check(true); if(getOwnerColumn()->isGeneratedForeignKey()) item->Enable(false); item = mnu.AppendCheckItem(MNU_UKEY, _("Unique Key")); if(getOwnerColumn()->isUniqueKey()) item->Check(true); mnu.AppendSeparator(); submenu = new wxMenu(); item = mnu.AppendSubMenu(submenu, _("Column datatype")); if(getOwnerColumn()->isGeneratedForeignKey()) item->Enable(false); item = submenu->AppendCheckItem(MNU_TYPESERIAL, _("serial")); item->Check(columnType == dt_bigint); item = submenu->AppendCheckItem(MNU_TYPEBOOLEAN, _("boolean")); item->Check(columnType == dt_boolean); item = submenu->AppendCheckItem(MNU_TYPEINTEGER, _("integer")); item->Check(columnType == dt_integer); item = submenu->AppendCheckItem(MNU_TYPEMONEY, _("money")); item->Check(columnType == dt_money); item = submenu->AppendCheckItem(MNU_TYPEVARCHAR, _("varchar(n)")); item->Check(columnType == dt_varchar); item = submenu->Append(MNU_TYPEOTHER, _("Choose another datatype...")); mnu.AppendSeparator(); mnu.Append(MNU_TYPEPKEY_CONSTRAINTNAME, _("Primary Key Constraint name...")); mnu.Append(MNU_TYPEUKEY_CONSTRAINTNAME, _("Unique Key Constraint name...")); mnu.AppendSeparator(); mnu.Append(MNU_DELTABLE, _("Delete table...")); };
void AudioKaraoke::AddMenuItem(wxMenu &menu, std::string const& tag, wxString const& help, std::string const& selected) { wxMenuItem *item = menu.AppendCheckItem(-1, to_wx(tag), help); menu.Bind(wxEVT_COMMAND_MENU_SELECTED, std::bind(&AudioKaraoke::SetTagType, this, tag), item->GetId()); item->Check(tag == selected); }