X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/7d5b794ce4c4b835dff3192b361fd3cd3f9f16a8..8fdbcf4de8eeff67ccfaf3deec833d203f112629:/src/common/framecmn.cpp?ds=sidebyside diff --git a/src/common/framecmn.cpp b/src/common/framecmn.cpp index b303b53a36..be0234a6c7 100644 --- a/src/common/framecmn.cpp +++ b/src/common/framecmn.cpp @@ -26,6 +26,7 @@ #include "wx/frame.h" #ifndef WX_PRECOMP + #include "wx/app.h" #include "wx/menu.h" #include "wx/menuitem.h" #include "wx/dcclient.h" @@ -40,16 +41,34 @@ extern WXDLLEXPORT_DATA(const char) wxStatusLineNameStr[] = "status_line"; // event table // ---------------------------------------------------------------------------- -#if wxUSE_MENUS && wxUSE_STATUSBAR +#if wxUSE_MENUS +#if wxUSE_STATUSBAR BEGIN_EVENT_TABLE(wxFrameBase, wxTopLevelWindow) EVT_MENU_OPEN(wxFrameBase::OnMenuOpen) EVT_MENU_CLOSE(wxFrameBase::OnMenuClose) EVT_MENU_HIGHLIGHT_ALL(wxFrameBase::OnMenuHighlight) END_EVENT_TABLE() +#endif // wxUSE_STATUSBAR -#endif // wxUSE_MENUS && wxUSE_STATUSBAR +/* static */ +bool wxFrameBase::ShouldUpdateMenuFromIdle() +{ + // Usually this is determined at compile time and is determined by whether + // the platform supports wxEVT_MENU_OPEN, however in wxGTK we need to also + // check if we're using the global menu bar as we don't get EVT_MENU_OPEN + // for it and need to fall back to idle time updating even if normally + // wxUSE_IDLEMENUUPDATES is set to 0 for wxGTK. +#ifdef __WXGTK20__ + if ( wxApp::GTKIsUsingGlobalMenu() ) + return true; +#endif // !__WXGTK__ + + return wxUSE_IDLEMENUUPDATES != 0; +} + +#endif // wxUSE_MENUS // ============================================================================ // implementation @@ -112,7 +131,7 @@ wxEND_FLAGS( wxFrameStyle ) wxIMPLEMENT_DYNAMIC_CLASS_XTI(wxFrame, wxTopLevelWindow, "wx/frame.h") wxBEGIN_PROPERTIES_TABLE(wxFrame) -wxEVENT_PROPERTY( Menu, wxEVT_COMMAND_MENU_SELECTED, wxCommandEvent) +wxEVENT_PROPERTY( Menu, wxEVT_MENU, wxCommandEvent) wxPROPERTY( Title,wxString, SetTitle, GetTitle, wxString(), 0 /*flags*/, \ wxT("Helpstring"), wxT("group")) @@ -300,9 +319,7 @@ void wxFrameBase::UpdateWindowUI(long flags) // If coming from an idle event, we only want to update the menus if // we're in the wxUSE_IDLEMENUUPDATES configuration, otherwise they // will be update when the menu is opened later -#if !wxUSE_IDLEMENUUPDATES - if ( !(flags & wxUPDATE_UI_FROMIDLE) ) -#endif // wxUSE_IDLEMENUUPDATES + if ( !(flags & wxUPDATE_UI_FROMIDLE) || ShouldUpdateMenuFromIdle() ) DoMenuUpdates(); } #endif // wxUSE_MENUS @@ -323,12 +340,11 @@ void wxFrameBase::OnMenuHighlight(wxMenuEvent& event) void wxFrameBase::OnMenuOpen(wxMenuEvent& event) { -#if wxUSE_IDLEMENUUPDATES - wxUnusedVar(event); -#else // !wxUSE_IDLEMENUUPDATES - // as we didn't update the menus from idle time, do it now - DoMenuUpdates(event.GetMenu()); -#endif // wxUSE_IDLEMENUUPDATES/!wxUSE_IDLEMENUUPDATES + if ( !ShouldUpdateMenuFromIdle() ) + { + // as we didn't update the menus from idle time, do it now + DoMenuUpdates(event.GetMenu()); + } } void wxFrameBase::OnMenuClose(wxMenuEvent& WXUNUSED(event)) @@ -343,8 +359,8 @@ void wxFrameBase::OnInternalIdle() { wxTopLevelWindow::OnInternalIdle(); -#if wxUSE_MENUS && wxUSE_IDLEMENUUPDATES - if (wxUpdateUIEvent::CanUpdate(this)) +#if wxUSE_MENUS + if ( ShouldUpdateMenuFromIdle() && wxUpdateUIEvent::CanUpdate(this) ) DoMenuUpdates(); #endif } @@ -546,7 +562,7 @@ wxToolBar* wxFrameBase::CreateToolBar(long style, // a) this allows us to have different defaults for different // platforms (even if we don't have them right now) // b) we don't need to include wx/toolbar.h in the header then - style = wxBORDER_NONE | wxTB_HORIZONTAL | wxTB_FLAT; + style = wxTB_DEFAULT_STYLE; } SetToolBar(OnCreateToolBar(style, id, name));