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:
@@ -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
|
||||
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
|
@@ -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
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@@ -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"
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@@ -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"
|
||||
//-----------------------------------------------------------------------------
|
||||
|
Reference in New Issue
Block a user