+// ----------------------------------------------------------------------------
+// wxMenu invoking window handling
+// ----------------------------------------------------------------------------
+
+void wxMenuBase::SetInvokingWindow(wxWindow *win)
+{
+ wxASSERT_MSG( !GetParent(),
+ "should only be called for top level popup menus" );
+ wxASSERT_MSG( !IsAttached(),
+ "menus attached to menu bar can't have invoking window" );
+
+ m_invokingWindow = win;
+}
+
+wxWindow *wxMenuBase::GetInvokingWindow() const
+{
+ // only the popup menu itself has a non-NULL invoking window so recurse
+ // upwards until we find it
+ const wxMenuBase *menu = this;
+ while ( menu->GetParent() )
+ {
+ menu = menu->GetParent();
+ }
+
+ // menu is a top level menu here
+ return menu->m_invokingWindow;
+}
+