fix for menu helpstring in the status bar for MDI child frames

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_2_BRANCH@7158 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2000-04-13 18:03:34 +00:00
parent cbb5561c49
commit 99f55f5c26
6 changed files with 69 additions and 29 deletions

View File

@@ -192,6 +192,10 @@ protected:
// something changes // something changes
virtual void PositionStatusBar() { } 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; wxStatusBar *m_frameStatusBar;
#endif // wxUSE_STATUSBAR #endif // wxUSE_STATUSBAR

View File

@@ -152,9 +152,10 @@ public:
virtual bool IsTopLevel() const { return FALSE; } virtual bool IsTopLevel() const { return FALSE; }
void OnActivate( wxActivateEvent &event ); void OnActivate( wxActivateEvent& event );
void OnMenuHighlight( wxMenuEvent& event );
// implementation // implementation
wxMenuBar *m_menuBar; wxMenuBar *m_menuBar;
GtkNotebookPage *m_page; GtkNotebookPage *m_page;

View File

@@ -152,9 +152,10 @@ public:
virtual bool IsTopLevel() const { return FALSE; } virtual bool IsTopLevel() const { return FALSE; }
void OnActivate( wxActivateEvent &event ); void OnActivate( wxActivateEvent& event );
void OnMenuHighlight( wxMenuEvent& event );
// implementation // implementation
wxMenuBar *m_menuBar; wxMenuBar *m_menuBar;
GtkNotebookPage *m_page; GtkNotebookPage *m_page;

View File

@@ -284,29 +284,7 @@ void wxFrameBase::OnCloseWindow(wxCloseEvent& WXUNUSED(event))
void wxFrameBase::OnMenuHighlight(wxMenuEvent& event) void wxFrameBase::OnMenuHighlight(wxMenuEvent& event)
{ {
#if wxUSE_STATUSBAR #if wxUSE_STATUSBAR
if ( GetStatusBar() ) (void)ShowMenuHelp(GetStatusBar(), event.GetMenuId());
{
// 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);
}
#endif // wxUSE_STATUSBAR #endif // wxUSE_STATUSBAR
} }
@@ -372,6 +350,34 @@ void wxFrameBase::SetStatusWidths(int n, const int widths_field[] )
PositionStatusBar(); 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 #endif // wxUSE_STATUSBAR
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@@ -303,6 +303,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxMDIChildFrame,wxFrame)
BEGIN_EVENT_TABLE(wxMDIChildFrame, wxFrame) BEGIN_EVENT_TABLE(wxMDIChildFrame, wxFrame)
EVT_ACTIVATE(wxMDIChildFrame::OnActivate) EVT_ACTIVATE(wxMDIChildFrame::OnActivate)
EVT_MENU_HIGHLIGHT_ALL(wxMDIChildFrame::OnMenuHighlight)
END_EVENT_TABLE() END_EVENT_TABLE()
wxMDIChildFrame::wxMDIChildFrame() wxMDIChildFrame::wxMDIChildFrame()
@@ -388,10 +389,23 @@ void wxMDIChildFrame::Activate()
#endif #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" // "size_allocate"
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------

View File

@@ -303,6 +303,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxMDIChildFrame,wxFrame)
BEGIN_EVENT_TABLE(wxMDIChildFrame, wxFrame) BEGIN_EVENT_TABLE(wxMDIChildFrame, wxFrame)
EVT_ACTIVATE(wxMDIChildFrame::OnActivate) EVT_ACTIVATE(wxMDIChildFrame::OnActivate)
EVT_MENU_HIGHLIGHT_ALL(wxMDIChildFrame::OnMenuHighlight)
END_EVENT_TABLE() END_EVENT_TABLE()
wxMDIChildFrame::wxMDIChildFrame() wxMDIChildFrame::wxMDIChildFrame()
@@ -388,10 +389,23 @@ void wxMDIChildFrame::Activate()
#endif #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" // "size_allocate"
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------