Add wxUSE_MENUBAR build option, off by default in wxiOS

Allow building without wxMenuBar (but with wxMenu), as this class
doesn't exist and can't be reasonably implemented under iOS (but
wxMenu can and should be, as it's widely used in iOS 14 UI).
This commit is contained in:
Stefan Csomor
2020-07-14 17:58:15 +02:00
committed by Vadim Zeitlin
parent 49f6370890
commit 68ee7ffa2a
15 changed files with 89 additions and 27 deletions

View File

@@ -23,7 +23,9 @@ extern WXDLLIMPEXP_DATA_CORE(const char) wxStatusLineNameStr[];
extern WXDLLIMPEXP_DATA_CORE(const char) wxToolBarNameStr[];
class WXDLLIMPEXP_FWD_CORE wxFrame;
#if wxUSE_MENUBAR
class WXDLLIMPEXP_FWD_CORE wxMenuBar;
#endif
class WXDLLIMPEXP_FWD_CORE wxMenuItem;
class WXDLLIMPEXP_FWD_CORE wxStatusBar;
class WXDLLIMPEXP_FWD_CORE wxToolBar;
@@ -78,6 +80,7 @@ public:
// ------------------
#if wxUSE_MENUS
#if wxUSE_MENUBAR
virtual void SetMenuBar(wxMenuBar *menubar);
virtual wxMenuBar *GetMenuBar() const { return m_frameMenuBar; }
@@ -85,7 +88,7 @@ public:
// and exists mainly in order to be overridden in the MDI parent frame
// which also looks at its active child menu bar
virtual wxMenuItem *FindItemInMenuBar(int menuId) const;
#endif
// generate menu command corresponding to the given menu item
//
// returns true if processed
@@ -192,7 +195,7 @@ protected:
// test whether this window makes part of the frame
virtual bool IsOneOfBars(const wxWindow *win) const wxOVERRIDE;
#if wxUSE_MENUS
#if wxUSE_MENUBAR
// override to update menu bar position when the frame size changes
virtual void PositionMenuBar() { }
@@ -203,13 +206,15 @@ protected:
// override to do something special when the menu bar is attached to the
// frame
virtual void AttachMenuBar(wxMenuBar *menubar);
#endif // wxUSE_MENUBAR
// Return true if we should update the menu item state from idle event
// handler or false if we should delay it until the menu is opened.
static bool ShouldUpdateMenuFromIdle();
#if wxUSE_MENUBAR
wxMenuBar *m_frameMenuBar;
#endif // wxUSE_MENUS
#endif // wxUSE_MENUBAR
#if wxUSE_STATUSBAR && (wxUSE_MENUS || wxUSE_TOOLBAR)
// the saved status bar text overwritten by DoGiveHelp()

View File

@@ -282,6 +282,7 @@ public:
// handler to use for these events, but this should never be needed.
void UpdateUI(wxEvtHandler* source = NULL);
#if wxUSE_MENUBAR
// get the menu bar this menu is attached to (may be NULL, always NULL for
// popup menus). Traverse up the menu hierarchy to find it.
wxMenuBar *GetMenuBar() const;
@@ -292,6 +293,7 @@ public:
// is the menu attached to a menu bar (or is it a popup one)?
bool IsAttached() const { return GetMenuBar() != NULL; }
#endif
// set/get the parent of this menu
void SetParent(wxMenu *parent) { m_menuParent = parent; }
@@ -443,6 +445,8 @@ WX_DECLARE_EXPORTED_LIST(wxMenuInfoHelper, wxMenuInfoHelperList );
// wxMenuBar
// ----------------------------------------------------------------------------
#if wxUSE_MENUBAR
class WXDLLIMPEXP_CORE wxMenuBarBase : public wxWindow
{
public:
@@ -584,6 +588,7 @@ protected:
wxDECLARE_NO_COPY_CLASS(wxMenuBarBase);
};
#endif
// ----------------------------------------------------------------------------
// include the real class declaration

View File

@@ -90,7 +90,7 @@ protected:
virtual void DoGetClientSize(int *width, int *height) const wxOVERRIDE;
virtual void DoSetClientSize(int width, int height) wxOVERRIDE;
#if wxUSE_MENUS
#if wxUSE_MENUBAR
virtual void DetachMenuBar() wxOVERRIDE;
virtual void AttachMenuBar(wxMenuBar *menubar) wxOVERRIDE;
#endif

View File

@@ -255,7 +255,12 @@
#if wxUSE_MENUS
#undef wxUSE_MENUS
#define wxUSE_MENUS 0
#define wxUSE_MENUS 1
#endif
#if wxUSE_MENUBAR
#undef wxUSE_MENUBAR
#define wxUSE_MENUBAR 0
#endif
/*

View File

@@ -102,7 +102,7 @@ private:
wxDECLARE_DYNAMIC_CLASS(wxMenu);
};
#if wxOSX_USE_COCOA_OR_CARBON
#if wxUSE_MENUBAR
// the iphone only has popup-menus