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:
parent
49f6370890
commit
68ee7ffa2a
@ -23,7 +23,9 @@ extern WXDLLIMPEXP_DATA_CORE(const char) wxStatusLineNameStr[];
|
|||||||
extern WXDLLIMPEXP_DATA_CORE(const char) wxToolBarNameStr[];
|
extern WXDLLIMPEXP_DATA_CORE(const char) wxToolBarNameStr[];
|
||||||
|
|
||||||
class WXDLLIMPEXP_FWD_CORE wxFrame;
|
class WXDLLIMPEXP_FWD_CORE wxFrame;
|
||||||
|
#if wxUSE_MENUBAR
|
||||||
class WXDLLIMPEXP_FWD_CORE wxMenuBar;
|
class WXDLLIMPEXP_FWD_CORE wxMenuBar;
|
||||||
|
#endif
|
||||||
class WXDLLIMPEXP_FWD_CORE wxMenuItem;
|
class WXDLLIMPEXP_FWD_CORE wxMenuItem;
|
||||||
class WXDLLIMPEXP_FWD_CORE wxStatusBar;
|
class WXDLLIMPEXP_FWD_CORE wxStatusBar;
|
||||||
class WXDLLIMPEXP_FWD_CORE wxToolBar;
|
class WXDLLIMPEXP_FWD_CORE wxToolBar;
|
||||||
@ -78,6 +80,7 @@ public:
|
|||||||
// ------------------
|
// ------------------
|
||||||
|
|
||||||
#if wxUSE_MENUS
|
#if wxUSE_MENUS
|
||||||
|
#if wxUSE_MENUBAR
|
||||||
virtual void SetMenuBar(wxMenuBar *menubar);
|
virtual void SetMenuBar(wxMenuBar *menubar);
|
||||||
virtual wxMenuBar *GetMenuBar() const { return m_frameMenuBar; }
|
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
|
// and exists mainly in order to be overridden in the MDI parent frame
|
||||||
// which also looks at its active child menu bar
|
// which also looks at its active child menu bar
|
||||||
virtual wxMenuItem *FindItemInMenuBar(int menuId) const;
|
virtual wxMenuItem *FindItemInMenuBar(int menuId) const;
|
||||||
|
#endif
|
||||||
// generate menu command corresponding to the given menu item
|
// generate menu command corresponding to the given menu item
|
||||||
//
|
//
|
||||||
// returns true if processed
|
// returns true if processed
|
||||||
@ -192,7 +195,7 @@ protected:
|
|||||||
// test whether this window makes part of the frame
|
// test whether this window makes part of the frame
|
||||||
virtual bool IsOneOfBars(const wxWindow *win) const wxOVERRIDE;
|
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
|
// override to update menu bar position when the frame size changes
|
||||||
virtual void PositionMenuBar() { }
|
virtual void PositionMenuBar() { }
|
||||||
|
|
||||||
@ -203,13 +206,15 @@ protected:
|
|||||||
// override to do something special when the menu bar is attached to the
|
// override to do something special when the menu bar is attached to the
|
||||||
// frame
|
// frame
|
||||||
virtual void AttachMenuBar(wxMenuBar *menubar);
|
virtual void AttachMenuBar(wxMenuBar *menubar);
|
||||||
|
#endif // wxUSE_MENUBAR
|
||||||
|
|
||||||
// Return true if we should update the menu item state from idle event
|
// 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.
|
// handler or false if we should delay it until the menu is opened.
|
||||||
static bool ShouldUpdateMenuFromIdle();
|
static bool ShouldUpdateMenuFromIdle();
|
||||||
|
|
||||||
|
#if wxUSE_MENUBAR
|
||||||
wxMenuBar *m_frameMenuBar;
|
wxMenuBar *m_frameMenuBar;
|
||||||
#endif // wxUSE_MENUS
|
#endif // wxUSE_MENUBAR
|
||||||
|
|
||||||
#if wxUSE_STATUSBAR && (wxUSE_MENUS || wxUSE_TOOLBAR)
|
#if wxUSE_STATUSBAR && (wxUSE_MENUS || wxUSE_TOOLBAR)
|
||||||
// the saved status bar text overwritten by DoGiveHelp()
|
// the saved status bar text overwritten by DoGiveHelp()
|
||||||
|
@ -282,6 +282,7 @@ public:
|
|||||||
// handler to use for these events, but this should never be needed.
|
// handler to use for these events, but this should never be needed.
|
||||||
void UpdateUI(wxEvtHandler* source = NULL);
|
void UpdateUI(wxEvtHandler* source = NULL);
|
||||||
|
|
||||||
|
#if wxUSE_MENUBAR
|
||||||
// get the menu bar this menu is attached to (may be NULL, always NULL for
|
// 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.
|
// popup menus). Traverse up the menu hierarchy to find it.
|
||||||
wxMenuBar *GetMenuBar() const;
|
wxMenuBar *GetMenuBar() const;
|
||||||
@ -292,6 +293,7 @@ public:
|
|||||||
|
|
||||||
// is the menu attached to a menu bar (or is it a popup one)?
|
// is the menu attached to a menu bar (or is it a popup one)?
|
||||||
bool IsAttached() const { return GetMenuBar() != NULL; }
|
bool IsAttached() const { return GetMenuBar() != NULL; }
|
||||||
|
#endif
|
||||||
|
|
||||||
// set/get the parent of this menu
|
// set/get the parent of this menu
|
||||||
void SetParent(wxMenu *parent) { m_menuParent = parent; }
|
void SetParent(wxMenu *parent) { m_menuParent = parent; }
|
||||||
@ -443,6 +445,8 @@ WX_DECLARE_EXPORTED_LIST(wxMenuInfoHelper, wxMenuInfoHelperList );
|
|||||||
// wxMenuBar
|
// wxMenuBar
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#if wxUSE_MENUBAR
|
||||||
|
|
||||||
class WXDLLIMPEXP_CORE wxMenuBarBase : public wxWindow
|
class WXDLLIMPEXP_CORE wxMenuBarBase : public wxWindow
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -584,6 +588,7 @@ protected:
|
|||||||
|
|
||||||
wxDECLARE_NO_COPY_CLASS(wxMenuBarBase);
|
wxDECLARE_NO_COPY_CLASS(wxMenuBarBase);
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// include the real class declaration
|
// include the real class declaration
|
||||||
|
@ -90,7 +90,7 @@ protected:
|
|||||||
virtual void DoGetClientSize(int *width, int *height) const wxOVERRIDE;
|
virtual void DoGetClientSize(int *width, int *height) const wxOVERRIDE;
|
||||||
virtual void DoSetClientSize(int width, int height) wxOVERRIDE;
|
virtual void DoSetClientSize(int width, int height) wxOVERRIDE;
|
||||||
|
|
||||||
#if wxUSE_MENUS
|
#if wxUSE_MENUBAR
|
||||||
virtual void DetachMenuBar() wxOVERRIDE;
|
virtual void DetachMenuBar() wxOVERRIDE;
|
||||||
virtual void AttachMenuBar(wxMenuBar *menubar) wxOVERRIDE;
|
virtual void AttachMenuBar(wxMenuBar *menubar) wxOVERRIDE;
|
||||||
#endif
|
#endif
|
||||||
|
@ -255,7 +255,12 @@
|
|||||||
|
|
||||||
#if wxUSE_MENUS
|
#if wxUSE_MENUS
|
||||||
#undef 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
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -102,7 +102,7 @@ private:
|
|||||||
wxDECLARE_DYNAMIC_CLASS(wxMenu);
|
wxDECLARE_DYNAMIC_CLASS(wxMenu);
|
||||||
};
|
};
|
||||||
|
|
||||||
#if wxOSX_USE_COCOA_OR_CARBON
|
#if wxUSE_MENUBAR
|
||||||
|
|
||||||
// the iphone only has popup-menus
|
// the iphone only has popup-menus
|
||||||
|
|
||||||
|
@ -148,7 +148,7 @@ wxCONSTRUCTOR_6( wxFrame, wxWindow*, Parent, wxWindowID, Id, wxString, Title, \
|
|||||||
|
|
||||||
wxFrameBase::wxFrameBase()
|
wxFrameBase::wxFrameBase()
|
||||||
{
|
{
|
||||||
#if wxUSE_MENUS
|
#if wxUSE_MENUBAR
|
||||||
m_frameMenuBar = NULL;
|
m_frameMenuBar = NULL;
|
||||||
#endif // wxUSE_MENUS
|
#endif // wxUSE_MENUS
|
||||||
|
|
||||||
@ -183,7 +183,7 @@ wxFrame *wxFrameBase::New(wxWindow *parent,
|
|||||||
|
|
||||||
void wxFrameBase::DeleteAllBars()
|
void wxFrameBase::DeleteAllBars()
|
||||||
{
|
{
|
||||||
#if wxUSE_MENUS
|
#if wxUSE_MENUBAR
|
||||||
wxDELETE(m_frameMenuBar);
|
wxDELETE(m_frameMenuBar);
|
||||||
#endif // wxUSE_MENUS
|
#endif // wxUSE_MENUS
|
||||||
|
|
||||||
@ -198,7 +198,7 @@ void wxFrameBase::DeleteAllBars()
|
|||||||
|
|
||||||
bool wxFrameBase::IsOneOfBars(const wxWindow *win) const
|
bool wxFrameBase::IsOneOfBars(const wxWindow *win) const
|
||||||
{
|
{
|
||||||
#if wxUSE_MENUS
|
#if wxUSE_MENUBAR
|
||||||
if ( win == GetMenuBar() )
|
if ( win == GetMenuBar() )
|
||||||
return true;
|
return true;
|
||||||
#endif // wxUSE_MENUS
|
#endif // wxUSE_MENUS
|
||||||
@ -258,11 +258,15 @@ wxPoint wxFrameBase::GetClientAreaOrigin() const
|
|||||||
|
|
||||||
bool wxFrameBase::ProcessCommand(int id)
|
bool wxFrameBase::ProcessCommand(int id)
|
||||||
{
|
{
|
||||||
|
#if wxUSE_MENUBAR
|
||||||
wxMenuItem* const item = FindItemInMenuBar(id);
|
wxMenuItem* const item = FindItemInMenuBar(id);
|
||||||
if ( !item )
|
if ( !item )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return ProcessCommand(item);
|
return ProcessCommand(item);
|
||||||
|
#else
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxFrameBase::ProcessCommand(wxMenuItem *item)
|
bool wxFrameBase::ProcessCommand(wxMenuItem *item)
|
||||||
@ -308,7 +312,7 @@ void wxFrameBase::UpdateWindowUI(long flags)
|
|||||||
GetToolBar()->UpdateWindowUI(flags);
|
GetToolBar()->UpdateWindowUI(flags);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if wxUSE_MENUS
|
#if wxUSE_MENUBAR
|
||||||
if (GetMenuBar())
|
if (GetMenuBar())
|
||||||
{
|
{
|
||||||
// If coming from an idle event, we only want to update the menus if
|
// If coming from an idle event, we only want to update the menus if
|
||||||
@ -635,14 +639,18 @@ void wxFrameBase::DoMenuUpdates(wxMenu* menu)
|
|||||||
{
|
{
|
||||||
menu->UpdateUI();
|
menu->UpdateUI();
|
||||||
}
|
}
|
||||||
|
#if wxUSE_MENUBAR
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
wxMenuBar* bar = GetMenuBar();
|
wxMenuBar* bar = GetMenuBar();
|
||||||
if (bar != NULL)
|
if (bar != NULL)
|
||||||
bar->UpdateMenus();
|
bar->UpdateMenus();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if wxUSE_MENUBAR
|
||||||
|
|
||||||
void wxFrameBase::DetachMenuBar()
|
void wxFrameBase::DetachMenuBar()
|
||||||
{
|
{
|
||||||
if ( m_frameMenuBar )
|
if ( m_frameMenuBar )
|
||||||
@ -681,4 +689,6 @@ wxMenuItem *wxFrameBase::FindItemInMenuBar(int menuId) const
|
|||||||
return menuBar ? menuBar->FindItem(menuId) : NULL;
|
return menuBar ? menuBar->FindItem(menuId) : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // wxUSE_MENUBAR
|
||||||
|
|
||||||
#endif // wxUSE_MENUS
|
#endif // wxUSE_MENUS
|
||||||
|
@ -101,9 +101,10 @@ bool wxMenuBarStreamingCallback( const wxObject *WXUNUSED(object), wxObjectWrite
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if wxUSE_MENUBAR
|
||||||
wxIMPLEMENT_DYNAMIC_CLASS_XTI_CALLBACK(wxMenuBar, wxWindow, "wx/menu.h", \
|
wxIMPLEMENT_DYNAMIC_CLASS_XTI_CALLBACK(wxMenuBar, wxWindow, "wx/menu.h", \
|
||||||
wxMenuBarStreamingCallback)
|
wxMenuBarStreamingCallback)
|
||||||
|
#endif
|
||||||
|
|
||||||
#if wxUSE_EXTENDED_RTTI
|
#if wxUSE_EXTENDED_RTTI
|
||||||
WX_DEFINE_LIST( wxMenuInfoHelperList )
|
WX_DEFINE_LIST( wxMenuInfoHelperList )
|
||||||
@ -445,8 +446,10 @@ wxMenuItem *wxMenuBase::DoRemove(wxMenuItem *item)
|
|||||||
if ( submenu )
|
if ( submenu )
|
||||||
{
|
{
|
||||||
submenu->SetParent(NULL);
|
submenu->SetParent(NULL);
|
||||||
|
#if wxUSE_MENUBAR
|
||||||
if ( submenu->IsAttached() )
|
if ( submenu->IsAttached() )
|
||||||
submenu->Detach();
|
submenu->Detach();
|
||||||
|
#endif // wxUSE_MENUBAR
|
||||||
}
|
}
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
@ -648,7 +651,11 @@ bool wxMenuBase::DoProcessEvent(wxMenuBase* menu, wxEvent& event, wxWindow* win)
|
|||||||
{
|
{
|
||||||
event.SetEventObject(menu);
|
event.SetEventObject(menu);
|
||||||
|
|
||||||
|
#if wxUSE_MENUBAR
|
||||||
wxMenuBar* const mb = menu ? menu->GetMenuBar() : NULL;
|
wxMenuBar* const mb = menu ? menu->GetMenuBar() : NULL;
|
||||||
|
#else
|
||||||
|
bool mb = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
// Process event in the menu itself and all its parent menus, if it's a
|
// Process event in the menu itself and all its parent menus, if it's a
|
||||||
// submenu, first.
|
// submenu, first.
|
||||||
@ -669,6 +676,7 @@ bool wxMenuBase::DoProcessEvent(wxMenuBase* menu, wxEvent& event, wxWindow* win)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if wxUSE_MENUBAR
|
||||||
// If this menu is part of the menu bar, try the event there.
|
// If this menu is part of the menu bar, try the event there.
|
||||||
if ( mb )
|
if ( mb )
|
||||||
{
|
{
|
||||||
@ -681,6 +689,7 @@ bool wxMenuBase::DoProcessEvent(wxMenuBase* menu, wxEvent& event, wxWindow* win)
|
|||||||
if ( event.ShouldPropagate() )
|
if ( event.ShouldPropagate() )
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
#endif // wxUSE_MENUBAR
|
||||||
|
|
||||||
// Try the window the menu was popped up from.
|
// Try the window the menu was popped up from.
|
||||||
if ( win )
|
if ( win )
|
||||||
@ -712,6 +721,7 @@ wxMenuBase::ProcessMenuEvent(wxMenu* menu, wxMenuEvent& event, wxWindow* win)
|
|||||||
// wxMenu attaching/detaching to/from menu bar
|
// wxMenu attaching/detaching to/from menu bar
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#if wxUSE_MENUBAR
|
||||||
wxMenuBar* wxMenuBase::GetMenuBar() const
|
wxMenuBar* wxMenuBase::GetMenuBar() const
|
||||||
{
|
{
|
||||||
if(GetParent())
|
if(GetParent())
|
||||||
@ -737,6 +747,7 @@ void wxMenuBase::Detach()
|
|||||||
|
|
||||||
m_menuBar = NULL;
|
m_menuBar = NULL;
|
||||||
}
|
}
|
||||||
|
#endif // wxUSE_MENUBAR
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// wxMenu invoking window handling
|
// wxMenu invoking window handling
|
||||||
@ -746,9 +757,10 @@ void wxMenuBase::SetInvokingWindow(wxWindow *win)
|
|||||||
{
|
{
|
||||||
wxASSERT_MSG( !GetParent(),
|
wxASSERT_MSG( !GetParent(),
|
||||||
"should only be called for top level popup menus" );
|
"should only be called for top level popup menus" );
|
||||||
|
#if wxUSE_MENUBAR
|
||||||
wxASSERT_MSG( !IsAttached(),
|
wxASSERT_MSG( !IsAttached(),
|
||||||
"menus attached to menu bar can't have invoking window" );
|
"menus attached to menu bar can't have invoking window" );
|
||||||
|
#endif
|
||||||
m_invokingWindow = win;
|
m_invokingWindow = win;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -762,8 +774,12 @@ wxWindow *wxMenuBase::GetWindow() const
|
|||||||
menu = menu->GetParent();
|
menu = menu->GetParent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if wxUSE_MENUBAR
|
||||||
return menu->GetMenuBar() ? menu->GetMenuBar()->GetFrame()
|
return menu->GetMenuBar() ? menu->GetMenuBar()->GetFrame()
|
||||||
: menu->GetInvokingWindow();
|
: menu->GetInvokingWindow();
|
||||||
|
#else
|
||||||
|
return menu->GetInvokingWindow();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@ -842,6 +858,8 @@ wxString wxMenuBase::GetHelpString( int itemid ) const
|
|||||||
return item->GetHelp();
|
return item->GetHelp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if wxUSE_MENUBAR
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// wxMenuBarBase ctor and dtor
|
// wxMenuBarBase ctor and dtor
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@ -1110,4 +1128,6 @@ wxString wxMenuBarBase::GetLabelTop(size_t pos) const
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif // wxUSE_MENUBAR
|
||||||
|
|
||||||
#endif // wxUSE_MENUS
|
#endif // wxUSE_MENUS
|
||||||
|
@ -1261,15 +1261,15 @@ wxFindMenuItemId(wxFrame *frame,
|
|||||||
const wxString& menuString,
|
const wxString& menuString,
|
||||||
const wxString& itemString)
|
const wxString& itemString)
|
||||||
{
|
{
|
||||||
#if wxUSE_MENUS
|
#if wxUSE_MENUBAR
|
||||||
wxMenuBar *menuBar = frame->GetMenuBar ();
|
wxMenuBar *menuBar = frame->GetMenuBar ();
|
||||||
if ( menuBar )
|
if ( menuBar )
|
||||||
return menuBar->FindMenuItem (menuString, itemString);
|
return menuBar->FindMenuItem (menuString, itemString);
|
||||||
#else // !wxUSE_MENUS
|
#else // !wxUSE_MENUBAR
|
||||||
wxUnusedVar(frame);
|
wxUnusedVar(frame);
|
||||||
wxUnusedVar(menuString);
|
wxUnusedVar(menuString);
|
||||||
wxUnusedVar(itemString);
|
wxUnusedVar(itemString);
|
||||||
#endif // wxUSE_MENUS/!wxUSE_MENUS
|
#endif // wxUSE_MENUBAR/!wxUSE_MENUBAR
|
||||||
|
|
||||||
return wxNOT_FOUND;
|
return wxNOT_FOUND;
|
||||||
}
|
}
|
||||||
|
@ -412,7 +412,7 @@ void wxApp::OnIdle(wxIdleEvent& WXUNUSED(event))
|
|||||||
// either events to the threads other than main or events posted with
|
// either events to the threads other than main or events posted with
|
||||||
// wxPostEvent() functions
|
// wxPostEvent() functions
|
||||||
#ifndef __WXUNIVERSAL__
|
#ifndef __WXUNIVERSAL__
|
||||||
#if wxUSE_MENUS
|
#if wxUSE_MENUBAR
|
||||||
if (!wxMenuBar::MacGetInstalledMenuBar() && wxMenuBar::MacGetCommonMenuBar())
|
if (!wxMenuBar::MacGetInstalledMenuBar() && wxMenuBar::MacGetCommonMenuBar())
|
||||||
wxMenuBar::MacGetCommonMenuBar()->MacInstallMenuBar();
|
wxMenuBar::MacGetCommonMenuBar()->MacInstallMenuBar();
|
||||||
#endif
|
#endif
|
||||||
|
@ -84,7 +84,7 @@ bool wxFrame::Enable(bool enable)
|
|||||||
if ( !wxWindow::Enable(enable) )
|
if ( !wxWindow::Enable(enable) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
#if wxUSE_MENUS
|
#if wxUSE_MENUBAR
|
||||||
// we should always enable/disable the menubar, even if we are not current, otherwise
|
// we should always enable/disable the menubar, even if we are not current, otherwise
|
||||||
// we might miss some state change later (happened eg in the docview sample after PrintPreview)
|
// we might miss some state change later (happened eg in the docview sample after PrintPreview)
|
||||||
if ( m_frameMenuBar /*&& m_frameMenuBar == wxMenuBar::MacGetInstalledMenuBar()*/)
|
if ( m_frameMenuBar /*&& m_frameMenuBar == wxMenuBar::MacGetInstalledMenuBar()*/)
|
||||||
@ -156,7 +156,7 @@ void wxFrame::OnActivate(wxActivateEvent& event)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#if wxUSE_MENUS
|
#if wxUSE_MENUBAR
|
||||||
if (m_frameMenuBar != NULL)
|
if (m_frameMenuBar != NULL)
|
||||||
{
|
{
|
||||||
m_frameMenuBar->MacInstallMenuBar();
|
m_frameMenuBar->MacInstallMenuBar();
|
||||||
@ -180,7 +180,7 @@ void wxFrame::OnActivate(wxActivateEvent& event)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if wxUSE_MENUS
|
#if wxUSE_MENUBAR
|
||||||
void wxFrame::DetachMenuBar()
|
void wxFrame::DetachMenuBar()
|
||||||
{
|
{
|
||||||
wxFrameBase::DetachMenuBar();
|
wxFrameBase::DetachMenuBar();
|
||||||
@ -210,7 +210,7 @@ void wxFrame::AttachMenuBar( wxMenuBar *menuBar )
|
|||||||
m_frameMenuBar->MacInstallMenuBar();
|
m_frameMenuBar->MacInstallMenuBar();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif // wxUSE_MENUBAR
|
||||||
|
|
||||||
void wxFrame::DoGetClientSize(int *x, int *y) const
|
void wxFrame::DoGetClientSize(int *x, int *y) const
|
||||||
{
|
{
|
||||||
@ -391,7 +391,7 @@ bool wxFrame::Show(bool show)
|
|||||||
{
|
{
|
||||||
if ( !show )
|
if ( !show )
|
||||||
{
|
{
|
||||||
#if wxUSE_MENUS
|
#if wxUSE_MENUBAR
|
||||||
if (m_frameMenuBar != NULL)
|
if (m_frameMenuBar != NULL)
|
||||||
{
|
{
|
||||||
m_frameMenuBar->MacUninstallMenuBar();
|
m_frameMenuBar->MacUninstallMenuBar();
|
||||||
|
@ -66,13 +66,14 @@ void wxMenu::Init()
|
|||||||
|
|
||||||
m_peer = wxMenuImpl::Create( this, wxStripMenuCodes(m_title, wxStrip_Menu) );
|
m_peer = wxMenuImpl::Create( this, wxStripMenuCodes(m_title, wxStrip_Menu) );
|
||||||
|
|
||||||
|
#if wxOSX_USE_COCOA
|
||||||
// if we have a title, insert it in the beginning of the menu
|
// under macOS there is no built-in title, so if we have a title, insert it in the beginning of the menu
|
||||||
if ( !m_title.empty() )
|
if ( !m_title.empty() )
|
||||||
{
|
{
|
||||||
Append(idMenuTitle, m_title) ;
|
Append(idMenuTitle, m_title) ;
|
||||||
AppendSeparator() ;
|
AppendSeparator() ;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
wxMenu::~wxMenu()
|
wxMenu::~wxMenu()
|
||||||
@ -151,9 +152,11 @@ bool wxMenu::DoInsertOrAppend(wxMenuItem *item, size_t pos)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if wxUSE_MENUBAR
|
||||||
// if we're already attached to the menubar, we must update it
|
// if we're already attached to the menubar, we must update it
|
||||||
if ( IsAttached() && GetMenuBar()->IsAttached() )
|
if ( IsAttached() && GetMenuBar()->IsAttached() )
|
||||||
GetMenuBar()->Refresh();
|
GetMenuBar()->Refresh();
|
||||||
|
#endif // wxUSE_MENUBAR
|
||||||
|
|
||||||
if ( check )
|
if ( check )
|
||||||
item->Check(true);
|
item->Check(true);
|
||||||
@ -400,6 +403,8 @@ void wxMenu::HandleMenuClosed()
|
|||||||
DoHandleMenuOpenedOrClosed(wxEVT_MENU_CLOSE);
|
DoHandleMenuOpenedOrClosed(wxEVT_MENU_CLOSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if wxUSE_MENUBAR
|
||||||
|
|
||||||
// Menu Bar
|
// Menu Bar
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -707,5 +712,6 @@ void wxMenuBar::DoGetClientSize(int *width, int *height) const
|
|||||||
DoGetSize(width, height);
|
DoGetSize(width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // wxUSE_MENUBAR
|
||||||
|
|
||||||
#endif // wxUSE_MENUS
|
#endif // wxUSE_MENUS
|
||||||
|
@ -47,12 +47,14 @@ wxObject *wxMenuXmlHandler::DoCreateResource()
|
|||||||
CreateChildren(menu, true/*only this handler*/);
|
CreateChildren(menu, true/*only this handler*/);
|
||||||
m_insideMenu = oldins;
|
m_insideMenu = oldins;
|
||||||
|
|
||||||
|
#if wxUSE_MENUBAR
|
||||||
wxMenuBar *p_bar = wxDynamicCast(m_parent, wxMenuBar);
|
wxMenuBar *p_bar = wxDynamicCast(m_parent, wxMenuBar);
|
||||||
if (p_bar)
|
if (p_bar)
|
||||||
{
|
{
|
||||||
p_bar->Append(menu, title);
|
p_bar->Append(menu, title);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
#endif // wxUSE_MENUBAR
|
||||||
{
|
{
|
||||||
wxMenu *p_menu = wxDynamicCast(m_parent, wxMenu);
|
wxMenu *p_menu = wxDynamicCast(m_parent, wxMenu);
|
||||||
if (p_menu)
|
if (p_menu)
|
||||||
@ -145,6 +147,8 @@ bool wxMenuXmlHandler::CanHandle(wxXmlNode *node)
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if wxUSE_MENUBAR
|
||||||
|
|
||||||
wxIMPLEMENT_DYNAMIC_CLASS(wxMenuBarXmlHandler, wxXmlResourceHandler);
|
wxIMPLEMENT_DYNAMIC_CLASS(wxMenuBarXmlHandler, wxXmlResourceHandler);
|
||||||
|
|
||||||
wxMenuBarXmlHandler::wxMenuBarXmlHandler() : wxXmlResourceHandler()
|
wxMenuBarXmlHandler::wxMenuBarXmlHandler() : wxXmlResourceHandler()
|
||||||
@ -184,4 +188,6 @@ bool wxMenuBarXmlHandler::CanHandle(wxXmlNode *node)
|
|||||||
return IsOfClass(node, wxT("wxMenuBar"));
|
return IsOfClass(node, wxT("wxMenuBar"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // wxUSE_MENUBAR
|
||||||
|
|
||||||
#endif // wxUSE_XRC && wxUSE_MENUS
|
#endif // wxUSE_XRC && wxUSE_MENUS
|
||||||
|
@ -140,8 +140,10 @@ void wxXmlResource::InitAllHandlers()
|
|||||||
#endif
|
#endif
|
||||||
#if wxUSE_MENUS
|
#if wxUSE_MENUS
|
||||||
AddHandler(new wxMenuXmlHandler);
|
AddHandler(new wxMenuXmlHandler);
|
||||||
|
#if wxUSE_MENUBAR
|
||||||
AddHandler(new wxMenuBarXmlHandler);
|
AddHandler(new wxMenuBarXmlHandler);
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
#if wxUSE_NOTEBOOK
|
#if wxUSE_NOTEBOOK
|
||||||
AddHandler(new wxNotebookXmlHandler);
|
AddHandler(new wxNotebookXmlHandler);
|
||||||
#endif
|
#endif
|
||||||
|
@ -436,10 +436,11 @@ wxMenu* CreateTestMenu(wxFrame* frame)
|
|||||||
{
|
{
|
||||||
wxMenu* const menu = new wxMenu;
|
wxMenu* const menu = new wxMenu;
|
||||||
menu->Append(wxID_APPLY);
|
menu->Append(wxID_APPLY);
|
||||||
|
#if wxUSE_MENUBAR
|
||||||
wxMenuBar* const mb = new wxMenuBar;
|
wxMenuBar* const mb = new wxMenuBar;
|
||||||
mb->Append(menu, "&Menu");
|
mb->Append(menu, "&Menu");
|
||||||
frame->SetMenuBar(mb);
|
frame->SetMenuBar(mb);
|
||||||
|
#endif
|
||||||
return menu;
|
return menu;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -464,10 +465,11 @@ void EventPropagationTestCase::MenuEvent()
|
|||||||
|
|
||||||
// Create a minimal menu bar.
|
// Create a minimal menu bar.
|
||||||
wxMenu* const menu = CreateTestMenu(frame);
|
wxMenu* const menu = CreateTestMenu(frame);
|
||||||
|
#if wxUSE_MENUBAR
|
||||||
wxMenuBar* const mb = menu->GetMenuBar();
|
wxMenuBar* const mb = menu->GetMenuBar();
|
||||||
wxScopedPtr<wxMenuBar> ensureMenuBarDestruction(mb);
|
wxScopedPtr<wxMenuBar> ensureMenuBarDestruction(mb);
|
||||||
wxON_BLOCK_EXIT_OBJ1( *frame, wxFrame::SetMenuBar, (wxMenuBar*)NULL );
|
wxON_BLOCK_EXIT_OBJ1( *frame, wxFrame::SetMenuBar, (wxMenuBar*)NULL );
|
||||||
|
#endif
|
||||||
// Check that wxApp gets the event exactly once.
|
// Check that wxApp gets the event exactly once.
|
||||||
ASSERT_MENU_EVENT_RESULT( menu, "aA" );
|
ASSERT_MENU_EVENT_RESULT( menu, "aA" );
|
||||||
|
|
||||||
@ -491,13 +493,14 @@ void EventPropagationTestCase::MenuEvent()
|
|||||||
wxEvtHandler::SetNextHandler, (wxEvtHandler*)NULL );
|
wxEvtHandler::SetNextHandler, (wxEvtHandler*)NULL );
|
||||||
ASSERT_MENU_EVENT_RESULT_FOR( wxID_ABOUT, submenu, "aosomA" );
|
ASSERT_MENU_EVENT_RESULT_FOR( wxID_ABOUT, submenu, "aosomA" );
|
||||||
|
|
||||||
|
#if wxUSE_MENUBAR
|
||||||
// Test that the event handler associated with the menu bar gets the event.
|
// Test that the event handler associated with the menu bar gets the event.
|
||||||
TestMenuEvtHandler hb('b'); // 'b' for "menu Bar"
|
TestMenuEvtHandler hb('b'); // 'b' for "menu Bar"
|
||||||
mb->PushEventHandler(&hb);
|
mb->PushEventHandler(&hb);
|
||||||
wxON_BLOCK_EXIT_OBJ1( *mb, wxWindow::PopEventHandler, false );
|
wxON_BLOCK_EXIT_OBJ1( *mb, wxWindow::PopEventHandler, false );
|
||||||
|
|
||||||
ASSERT_MENU_EVENT_RESULT( menu, "aomobA" );
|
ASSERT_MENU_EVENT_RESULT( menu, "aomobA" );
|
||||||
|
#endif
|
||||||
|
|
||||||
// Also test that the window to which the menu belongs gets the event.
|
// Also test that the window to which the menu belongs gets the event.
|
||||||
TestMenuEvtHandler hw('w'); // 'w' for "Window"
|
TestMenuEvtHandler hw('w'); // 'w' for "Window"
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
#include "testprec.h"
|
#include "testprec.h"
|
||||||
|
|
||||||
#if wxUSE_MENUS
|
#if wxUSE_MENUBAR
|
||||||
|
|
||||||
#ifdef __BORLANDC__
|
#ifdef __BORLANDC__
|
||||||
#pragma hdrstop
|
#pragma hdrstop
|
||||||
|
Loading…
Reference in New Issue
Block a user