diff --git a/include/wx/frame.h b/include/wx/frame.h index 3a3c0354a3..6f5ca2de91 100644 --- a/include/wx/frame.h +++ b/include/wx/frame.h @@ -192,6 +192,10 @@ protected: // something changes virtual void PositionStatusBar() { } + // show the help string for this menu item in the given status bar: the + // status bar pointer can be NULL; return TRUE if help was shown + bool ShowMenuHelp(wxStatusBar *statbar, int id); + wxStatusBar *m_frameStatusBar; #endif // wxUSE_STATUSBAR diff --git a/include/wx/gtk/mdi.h b/include/wx/gtk/mdi.h index e8f87df94d..62d5cae314 100644 --- a/include/wx/gtk/mdi.h +++ b/include/wx/gtk/mdi.h @@ -152,9 +152,10 @@ public: virtual bool IsTopLevel() const { return FALSE; } - void OnActivate( wxActivateEvent &event ); + void OnActivate( wxActivateEvent& event ); + void OnMenuHighlight( wxMenuEvent& event ); - // implementation + // implementation wxMenuBar *m_menuBar; GtkNotebookPage *m_page; diff --git a/include/wx/gtk1/mdi.h b/include/wx/gtk1/mdi.h index e8f87df94d..62d5cae314 100644 --- a/include/wx/gtk1/mdi.h +++ b/include/wx/gtk1/mdi.h @@ -152,9 +152,10 @@ public: virtual bool IsTopLevel() const { return FALSE; } - void OnActivate( wxActivateEvent &event ); + void OnActivate( wxActivateEvent& event ); + void OnMenuHighlight( wxMenuEvent& event ); - // implementation + // implementation wxMenuBar *m_menuBar; GtkNotebookPage *m_page; diff --git a/src/common/framecmn.cpp b/src/common/framecmn.cpp index ef3ab1defc..3d94d675e1 100644 --- a/src/common/framecmn.cpp +++ b/src/common/framecmn.cpp @@ -284,29 +284,7 @@ void wxFrameBase::OnCloseWindow(wxCloseEvent& WXUNUSED(event)) void wxFrameBase::OnMenuHighlight(wxMenuEvent& event) { #if wxUSE_STATUSBAR - if ( GetStatusBar() ) - { - // if no help string found, we will clear the status bar text - wxString helpString; - - int menuId = event.GetMenuId(); - if ( menuId != wxID_SEPARATOR && menuId != -2 /* wxID_TITLE */ ) - { - wxMenuBar *menuBar = GetMenuBar(); - if ( menuBar ) - { - // it's ok if we don't find the item because it might belong - // to the popup menu - wxMenuItem *item = menuBar->FindItem(menuId); - if ( item ) - helpString = item->GetHelp(); - } - } - - // set status text even if the string is empty - this will at least - // remove the string from the item which was previously selected - SetStatusText(helpString); - } + (void)ShowMenuHelp(GetStatusBar(), event.GetMenuId()); #endif // wxUSE_STATUSBAR } @@ -372,6 +350,34 @@ void wxFrameBase::SetStatusWidths(int n, const int widths_field[] ) PositionStatusBar(); } +bool wxFrameBase::ShowMenuHelp(wxStatusBar *statbar, int menuId) +{ + if ( !statbar ) + return FALSE; + + // if no help string found, we will clear the status bar text + wxString helpString; + + if ( menuId != wxID_SEPARATOR && menuId != -2 /* wxID_TITLE */ ) + { + wxMenuBar *menuBar = GetMenuBar(); + if ( menuBar ) + { + // it's ok if we don't find the item because it might belong + // to the popup menu + wxMenuItem *item = menuBar->FindItem(menuId); + if ( item ) + helpString = item->GetHelp(); + } + } + + // set status text even if the string is empty - this will at least + // remove the string from the item which was previously selected + statbar->SetStatusText(helpString); + + return !helpString.IsEmpty(); +} + #endif // wxUSE_STATUSBAR // ---------------------------------------------------------------------------- diff --git a/src/gtk/mdi.cpp b/src/gtk/mdi.cpp index c3556b7db2..47447fa95f 100644 --- a/src/gtk/mdi.cpp +++ b/src/gtk/mdi.cpp @@ -303,6 +303,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxMDIChildFrame,wxFrame) BEGIN_EVENT_TABLE(wxMDIChildFrame, wxFrame) EVT_ACTIVATE(wxMDIChildFrame::OnActivate) + EVT_MENU_HIGHLIGHT_ALL(wxMDIChildFrame::OnMenuHighlight) END_EVENT_TABLE() wxMDIChildFrame::wxMDIChildFrame() @@ -388,10 +389,23 @@ void wxMDIChildFrame::Activate() #endif } -void wxMDIChildFrame::OnActivate( wxActivateEvent &WXUNUSED(event) ) +void wxMDIChildFrame::OnActivate( wxActivateEvent& WXUNUSED(event) ) { } +void wxMDIChildFrame::OnMenuHighlight( wxMenuEvent& event ) +{ +#if wxUSE_STATUSBAR + wxMDIParentFrame *mdi_frame = (wxMDIParentFrame*)m_parent->GetParent(); + if ( !ShowMenuHelp(mdi_frame->GetStatusBar(), event.GetMenuId()) ) + { + // we don't have any help text for this item, but may be the MDI frame + // does? + mdi_frame->OnMenuHighlight(event); + } +#endif // wxUSE_STATUSBAR +} + //----------------------------------------------------------------------------- // "size_allocate" //----------------------------------------------------------------------------- diff --git a/src/gtk1/mdi.cpp b/src/gtk1/mdi.cpp index c3556b7db2..47447fa95f 100644 --- a/src/gtk1/mdi.cpp +++ b/src/gtk1/mdi.cpp @@ -303,6 +303,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxMDIChildFrame,wxFrame) BEGIN_EVENT_TABLE(wxMDIChildFrame, wxFrame) EVT_ACTIVATE(wxMDIChildFrame::OnActivate) + EVT_MENU_HIGHLIGHT_ALL(wxMDIChildFrame::OnMenuHighlight) END_EVENT_TABLE() wxMDIChildFrame::wxMDIChildFrame() @@ -388,10 +389,23 @@ void wxMDIChildFrame::Activate() #endif } -void wxMDIChildFrame::OnActivate( wxActivateEvent &WXUNUSED(event) ) +void wxMDIChildFrame::OnActivate( wxActivateEvent& WXUNUSED(event) ) { } +void wxMDIChildFrame::OnMenuHighlight( wxMenuEvent& event ) +{ +#if wxUSE_STATUSBAR + wxMDIParentFrame *mdi_frame = (wxMDIParentFrame*)m_parent->GetParent(); + if ( !ShowMenuHelp(mdi_frame->GetStatusBar(), event.GetMenuId()) ) + { + // we don't have any help text for this item, but may be the MDI frame + // does? + mdi_frame->OnMenuHighlight(event); + } +#endif // wxUSE_STATUSBAR +} + //----------------------------------------------------------------------------- // "size_allocate" //-----------------------------------------------------------------------------