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
#endif
void OnMenuOpen(wxMenuEvent& event)
- { LogMenuOpenOrClose(event, _T("opened")); }
+ { LogMenuOpenOrClose(event, _T("opened")); event.Skip(); }
void OnMenuClose(wxMenuEvent& event)
- { LogMenuOpenOrClose(event, _T("closed")); }
+ { LogMenuOpenOrClose(event, _T("closed")); event.Skip(); }
void OnUpdateCheckMenuItemUI(wxUpdateUIEvent& event);
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!"));
{
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"));
}
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"));
#endif // 0
}
-void MyFrame::OnTestNormal(wxCommandEvent& event)
+void MyFrame::OnTestNormal(wxCommandEvent& WXUNUSED(event))
{
wxLogMessage(_T("Normal item selected"));
}
event.IsPopup() ? _T("popup ") : _T(""), what);
}
-void MyFrame::OnSize(wxSizeEvent& event)
+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& WXUNUSED(event))
{
if ( !m_textctrl )
return;