+bool wxMenuBase::SendEvent(int id, int checked)
+{
+ wxCommandEvent event(wxEVT_COMMAND_MENU_SELECTED, id);
+ event.SetEventObject(this);
+ event.SetInt(checked);
+
+ bool processed = false;
+
+ // Try the menu's event handler
+ // if ( !processed )
+ {
+ wxEvtHandler *handler = GetEventHandler();
+ if ( handler )
+ processed = handler->ProcessEvent(event);
+ }
+
+ // Try the window the menu was popped up from (and up through the
+ // hierarchy)
+ if ( !processed )
+ {
+ const wxMenuBase *menu = this;
+ while ( menu )
+ {
+ wxWindow *win = menu->GetInvokingWindow();
+ if ( win )
+ {
+ processed = win->GetEventHandler()->ProcessEvent(event);
+ break;
+ }
+
+ menu = menu->GetParent();
+ }
+ }
+
+ return processed;
+}
+
+// ----------------------------------------------------------------------------
+// wxMenu attaching/detaching to/from menu bar
+// ----------------------------------------------------------------------------
+
+wxMenuBar* wxMenuBase::GetMenuBar() const
+{
+ if(GetParent())
+ return GetParent()->GetMenuBar();
+ return m_menuBar;
+}
+
+void wxMenuBase::Attach(wxMenuBarBase *menubar)
+{
+ // use Detach() instead!
+ wxASSERT_MSG( menubar, _T("menu can't be attached to NULL menubar") );
+
+ // use IsAttached() to prevent this from happening
+ wxASSERT_MSG( !m_menuBar, _T("attaching menu twice?") );
+
+ m_menuBar = (wxMenuBar *)menubar;
+}
+
+void wxMenuBase::Detach()
+{
+ // use IsAttached() to prevent this from happening
+ wxASSERT_MSG( m_menuBar, _T("detaching unattached menu?") );
+
+ m_menuBar = NULL;
+}
+