// implementation
// ============================================================================
-#include "wx/listimpl.cpp"
-
-#if wxUSE_EXTENDED_RTTI
-
-WX_DEFINE_FLAGS( wxMenuStyle )
-
-wxBEGIN_FLAGS( wxMenuStyle )
- wxFLAGS_MEMBER(wxMENU_TEAROFF)
-wxEND_FLAGS( wxMenuStyle )
-
-IMPLEMENT_DYNAMIC_CLASS_XTI(wxMenu, wxEvtHandler,"wx/menu.h")
-
-wxCOLLECTION_TYPE_INFO( wxMenuItem * , wxMenuItemList ) ;
-
-template<> void wxCollectionToVariantArray( wxMenuItemList const &theList, wxxVariantArray &value)
-{
- wxListCollectionToVariantArray<wxMenuItemList::compatibility_iterator>( theList , value ) ;
-}
-
-wxBEGIN_PROPERTIES_TABLE(wxMenu)
- wxEVENT_PROPERTY( Select , wxEVT_COMMAND_MENU_SELECTED , wxCommandEvent)
- wxPROPERTY( Title, wxString , SetTitle, GetTitle, wxString(), 0 /*flags*/ , wxT("Helpstring") , wxT("group") )
- wxREADONLY_PROPERTY_FLAGS( MenuStyle , wxMenuStyle , long , GetStyle , EMPTY_MACROVALUE , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style
- wxPROPERTY_COLLECTION( MenuItems , wxMenuItemList , wxMenuItem* , Append , GetMenuItems , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
-wxEND_PROPERTIES_TABLE()
-
-wxBEGIN_HANDLERS_TABLE(wxMenu)
-wxEND_HANDLERS_TABLE()
-
-wxDIRECT_CONSTRUCTOR_2( wxMenu , wxString , Title , long , MenuStyle )
-
-WX_DEFINE_FLAGS( wxMenuBarStyle )
-
-wxBEGIN_FLAGS( wxMenuBarStyle )
- wxFLAGS_MEMBER(wxMB_DOCKABLE)
-wxEND_FLAGS( wxMenuBarStyle )
-
-// the negative id would lead the window (its superclass !) to vetoe streaming out otherwise
-bool wxMenuBarStreamingCallback( const wxObject *WXUNUSED(object), wxWriter * , wxPersister * , wxxVariantArray & )
-{
- return true ;
-}
-
-IMPLEMENT_DYNAMIC_CLASS_XTI_CALLBACK(wxMenuBar, wxWindow ,"wx/menu.h",wxMenuBarStreamingCallback)
-
-IMPLEMENT_DYNAMIC_CLASS_XTI(wxMenuInfo, wxObject , "wx/menu.h" )
-
-wxBEGIN_HANDLERS_TABLE(wxMenuBar)
-wxEND_HANDLERS_TABLE()
-
-wxCONSTRUCTOR_DUMMY( wxMenuBar )
-
-#else
-IMPLEMENT_DYNAMIC_CLASS(wxMenu, wxEvtHandler)
-IMPLEMENT_DYNAMIC_CLASS(wxMenuBar, wxWindow)
-#endif
-
// ---------------------------------------------------------------------------
// wxMenu construction, adding and removing menu items
// ---------------------------------------------------------------------------
pos = GetMenuItemCount() - 1;
}
- // adjust position to account for the title, if any
- if ( !m_title.empty() )
+ // adjust position to account for the title of a popup menu, if any
+ if ( !GetMenuBar() && !m_title.empty() )
pos += 2; // for the title itself and its separator
BOOL ok = false;
return true;
}
+// get the menu with given handle (recursively)
+wxMenu* wxMenu::MSWGetMenu(WXHMENU hMenu)
+{
+ // check self
+ if ( GetHMenu() == hMenu )
+ return this;
+
+ // recursively query submenus
+ for ( size_t n = 0 ; n < GetMenuItemCount(); ++n )
+ {
+ wxMenuItem* item = FindItemByPosition(n);
+ wxMenu* submenu = item->GetSubMenu();
+ if ( submenu )
+ {
+ submenu = submenu->MSWGetMenu(hMenu);
+ if (submenu)
+ return submenu;
+ }
+ }
+
+ // unknown hMenu
+ return NULL;
+}
+
// ---------------------------------------------------------------------------
// Menu Bar
// ---------------------------------------------------------------------------
wxMenuBarBase::Detach();
}
+// get the menu with given handle (recursively)
+wxMenu* wxMenuBar::MSWGetMenu(WXHMENU hMenu)
+{
+ wxCHECK_MSG( GetHMenu() != hMenu, NULL,
+ wxT("wxMenuBar::MSWGetMenu(): menu handle is wxMenuBar, not wxMenu") );
+
+ // query all menus
+ for ( size_t n = 0 ; n < GetMenuCount(); ++n )
+ {
+ wxMenu* menu = GetMenu(n)->MSWGetMenu(hMenu);
+ if ( menu )
+ return menu;
+ }
+
+ // unknown hMenu
+ return NULL;
+}
+
#endif // wxUSE_MENUS