wxPROPERTY_FLAGS( WindowStyle, wxFrameStyle, long, SetWindowStyleFlag, \
GetWindowStyleFlag, wxEMPTY_PARAMETER_VALUE, 0 /*flags*/, \
wxT("Helpstring"), wxT("group")) // style
+#if wxUSE_MENUS
wxPROPERTY( MenuBar, wxMenuBar *, SetMenuBar, GetMenuBar, wxEMPTY_PARAMETER_VALUE, \
0 /*flags*/, wxT("Helpstring"), wxT("group"))
+#endif
wxEND_PROPERTIES_TABLE()
wxEMPTY_HANDLERS_TABLE(wxFrame)
bool wxFrameBase::ProcessCommand(int id)
{
- wxMenuBar *bar = GetMenuBar();
- if ( !bar )
- return false;
-
- wxMenuItem *item = bar->FindItem(id);
+ wxMenuItem* const item = FindItemInMenuBar(id);
if ( !item )
return false;
bool wxFrameBase::ProcessCommand(wxMenuItem *item)
{
- wxCommandEvent commandEvent(wxEVT_COMMAND_MENU_SELECTED, item->GetId());
- commandEvent.SetEventObject(this);
+ wxCHECK_MSG( item, false, wxS("Menu item can't be NULL") );
if (!item->IsEnabled())
return true;
if ((item->GetKind() == wxITEM_RADIO) && item->IsChecked() )
return true;
+ int checked;
if (item->IsCheckable())
{
item->Toggle();
// use the new value
- commandEvent.SetInt(item->IsChecked());
+ checked = item->IsChecked();
}
+ else // Uncheckable item.
+ {
+ checked = -1;
+ }
+
+ wxMenu* const menu = item->GetMenu();
+ wxCHECK_MSG( menu, false, wxS("Menu item should be attached to a menu") );
- return HandleWindowEvent(commandEvent);
+ return menu->SendEvent(item->GetId(), checked);
}
#endif // wxUSE_MENUS