void OnTestCheck(wxCommandEvent& event);
void OnTestRadio(wxCommandEvent& event);
-#ifdef __WXMSW__
+ void OnUpdateSubMenuNormal(wxUpdateUIEvent& event);
+ void OnUpdateSubMenuCheck(wxUpdateUIEvent& event);
+ void OnUpdateSubMenuRadio(wxUpdateUIEvent& event);
+
+#if defined( __WXMSW__ ) || defined( __WXMAC__ )
void OnContextMenu(wxContextMenuEvent& event)
{ ShowContextMenu(ScreenToClient(event.GetPosition())); }
#else
Menu_Test_Radio2,
Menu_Test_Radio3,
+ Menu_SubMenu = 450,
+ Menu_SubMenu_Normal,
+ Menu_SubMenu_Check,
+ Menu_SubMenu_Radio1,
+ Menu_SubMenu_Radio2,
+ Menu_SubMenu_Radio3,
+
Menu_Dummy_First = 500,
Menu_Dummy_Second,
Menu_Dummy_Third,
EVT_MENU(Menu_Test_Radio2, MyFrame::OnTestRadio)
EVT_MENU(Menu_Test_Radio3, MyFrame::OnTestRadio)
+ EVT_UPDATE_UI(Menu_SubMenu_Normal, MyFrame::OnUpdateSubMenuNormal)
+ EVT_UPDATE_UI(Menu_SubMenu_Check, MyFrame::OnUpdateSubMenuCheck)
+ EVT_UPDATE_UI(Menu_SubMenu_Radio1, MyFrame::OnUpdateSubMenuRadio)
+ EVT_UPDATE_UI(Menu_SubMenu_Radio2, MyFrame::OnUpdateSubMenuRadio)
+ EVT_UPDATE_UI(Menu_SubMenu_Radio3, MyFrame::OnUpdateSubMenuRadio)
+
EVT_MENU_RANGE(Menu_Dummy_First, Menu_Dummy_Last, MyFrame::OnDummy)
EVT_UPDATE_UI(Menu_Menu_Check, MyFrame::OnUpdateCheckMenuItemUI)
-#ifdef __WXMSW__
+#if defined( __WXMSW__ ) || defined( __WXMAC__ )
EVT_CONTEXT_MENU(MyFrame::OnContextMenu)
#else
EVT_RIGHT_UP(MyFrame::OnRightUp)
menubarMenu->Append(Menu_MenuBar_FindMenu, _T("&Find menu from label\tCtrl-F"),
_T("Find a menu by searching for its label"));
+ wxMenu* subMenu = new wxMenu;
+ subMenu->Append(Menu_SubMenu_Normal, _T("&Normal submenu item"), _T("Disabled submenu item"));
+ subMenu->AppendCheckItem(Menu_SubMenu_Check, _T("&Unchecked submenu item"), _T("Unchecked submenu item"));
+ subMenu->AppendRadioItem(Menu_SubMenu_Radio1, _T("&Radio item 1"), _T("Radio item"));
+ subMenu->AppendRadioItem(Menu_SubMenu_Radio2, _T("&Radio item 2"), _T("Radio item"));
+ subMenu->AppendRadioItem(Menu_SubMenu_Radio3, _T("&Radio item 3"), _T("Radio item"));
+
+ menubarMenu->Append(Menu_SubMenu, _T("Submenu"), subMenu);
+
wxMenu *menuMenu = new wxMenu;
menuMenu->Append(Menu_Menu_Append, _T("&Append menu item\tAlt-A"),
_T("Append a menu item to the last menu"));
wxMenuBar *menubar = GetMenuBar();
wxMenu *menu = menubar->GetMenu(menubar->GetMenuCount() - 1);
- wxMenuItemList::Node *node = menu->GetMenuItems().GetLast();
+ wxMenuItemList::compatibility_iterator node = menu->GetMenuItems().GetLast();
if ( !node )
{
wxLogWarning(wxT("No last item in the last menu!"));
(
_T("Enter label to search for: "),
_T("Find menu"),
- "",
+ _T(""),
this
);
{
wxMenuBar *menubar = GetMenuBar();
- wxMenu *menu = menubar->GetMenu(menubar->GetMenuCount() - 1);
+ wxMenu *menu = menubar->GetMenu(menubar->GetMenuCount() - 2);
menu->Append(Menu_Dummy_Last, _T("&Dummy sub menu"),
CreateDummyMenu(NULL), _T("Dummy sub menu help"));
(
_T("Enter label to search for: "),
_T("Find menu item"),
- "",
+ _T(""),
this
);
}
else
{
- wxLogMessage(wxT("Menu item %d in menu %d has label '%s'"),
- index, menuindex, label.c_str());
+ wxLogMessage(wxT("Menu item %d in menu %lu has label '%s'"),
+ index, (unsigned long)menuindex, label.c_str());
}
}
}
menu.Append(Menu_Popup_Submenu, _T("&Submenu"), CreateDummyMenu(NULL));
menu.Append(Menu_Popup_ToBeDeleted, _T("To be &deleted"));
menu.Append(Menu_Popup_ToBeChecked, _T("To be &checked"), _T(""), TRUE);
- menu.Append(Menu_Popup_ToBeGreyed, _T("To be &greyed"));
+ menu.Append(Menu_Popup_ToBeGreyed, _T("To be &greyed"),
+ _T("This menu item should be initially greyed out"));
menu.AppendSeparator();
menu.Append(Menu_File_Quit, _T("E&xit"));
event.IsPopup() ? _T("popup ") : _T(""), what);
}
+void MyFrame::OnUpdateSubMenuNormal(wxUpdateUIEvent& event)
+{
+ event.Enable(FALSE);
+}
+
+void MyFrame::OnUpdateSubMenuCheck(wxUpdateUIEvent& event)
+{
+ event.Enable(TRUE);
+ event.Check(TRUE);
+}
+
+void MyFrame::OnUpdateSubMenuRadio(wxUpdateUIEvent& event)
+{
+ int which = (event.GetId() - Menu_SubMenu_Radio1 + 1);
+ if (which == 2)
+ event.Check(TRUE);
+ else
+ event.Check(FALSE);
+}
+
void MyFrame::OnSize(wxSizeEvent& event)
{
if ( !m_textctrl )