Change storage of window menu label translation
Use member variable instead of global variable
This commit is contained in:
@@ -85,6 +85,12 @@ public:
|
||||
virtual void RemoveMDIChild(wxMDIChildFrame *child);
|
||||
#endif // wxUSE_MENUS
|
||||
|
||||
// called by AddWindowMenu to remember the translation of the window menu label
|
||||
void SetWindowMenuLabelTranslated();
|
||||
|
||||
// called by AddWindowMenu and RemoveWindowMenu to get the last used translation of the window menu label
|
||||
const wxString GetWindowMenuLabelTranslated() const;
|
||||
|
||||
// handlers
|
||||
// --------
|
||||
|
||||
@@ -150,6 +156,9 @@ private:
|
||||
// it was "handled", see OnActivate() and HandleActivate()
|
||||
bool m_activationNotHandled;
|
||||
|
||||
// holds the current translation for the window menu label
|
||||
wxString m_windowMenuLabelTranslated;
|
||||
|
||||
|
||||
friend class WXDLLIMPEXP_FWD_CORE wxMDIChildFrame;
|
||||
|
||||
|
@@ -77,7 +77,6 @@ const int wxID_MDI_MORE_WINDOWS = wxLAST_MDI_CHILD + 1;
|
||||
|
||||
// The MDI "Window" menu label
|
||||
const char *WINDOW_MENU_LABEL = gettext_noop("&Window");
|
||||
wxString WINDOW_MENU_LABEL_TRANSLATED;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// private functions
|
||||
@@ -89,10 +88,10 @@ void MDISetMenu(wxWindow *win, HMENU hmenuFrame, HMENU hmenuWindow);
|
||||
|
||||
// insert the window menu (subMenu) into menu just before "Help" submenu or at
|
||||
// the very end if not found
|
||||
void MDIInsertWindowMenu(wxWindow *win, WXHMENU hMenu, HMENU subMenu);
|
||||
void MDIInsertWindowMenu(wxWindow *win, WXHMENU hMenu, HMENU subMenu, const wxString& windowMenuLabelTranslated);
|
||||
|
||||
// Remove the window menu
|
||||
void MDIRemoveWindowMenu(wxWindow *win, WXHMENU hMenu);
|
||||
void MDIRemoveWindowMenu(wxWindow *win, WXHMENU hMenu, const wxString& windowMenuLabelTranslated);
|
||||
|
||||
// unpack the parameters of WM_MDIACTIVATE message
|
||||
void UnpackMDIActivate(WXWPARAM wParam, WXLPARAM lParam,
|
||||
@@ -278,6 +277,16 @@ int wxMDIParentFrame::GetChildFramesCount() const
|
||||
return count;
|
||||
}
|
||||
|
||||
void wxMDIParentFrame::SetWindowMenuLabelTranslated()
|
||||
{
|
||||
m_windowMenuLabelTranslated = wxGetTranslation(WINDOW_MENU_LABEL);
|
||||
}
|
||||
|
||||
const wxString wxMDIParentFrame::GetWindowMenuLabelTranslated() const
|
||||
{
|
||||
return m_windowMenuLabelTranslated;
|
||||
}
|
||||
|
||||
#if wxUSE_MENUS
|
||||
|
||||
void wxMDIParentFrame::AddMDIChild(wxMDIChildFrame * WXUNUSED(child))
|
||||
@@ -335,7 +344,8 @@ void wxMDIParentFrame::AddWindowMenu()
|
||||
// attach it to the menu bar.
|
||||
m_windowMenu->Attach(GetMenuBar());
|
||||
|
||||
MDIInsertWindowMenu(GetClientWindow(), m_hMenu, GetMDIWindowMenu(this));
|
||||
SetWindowMenuLabelTranslated();
|
||||
MDIInsertWindowMenu(GetClientWindow(), m_hMenu, GetMDIWindowMenu(this), GetWindowMenuLabelTranslated());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -343,7 +353,7 @@ void wxMDIParentFrame::RemoveWindowMenu()
|
||||
{
|
||||
if ( m_windowMenu )
|
||||
{
|
||||
MDIRemoveWindowMenu(GetClientWindow(), m_hMenu);
|
||||
MDIRemoveWindowMenu(GetClientWindow(), m_hMenu, GetWindowMenuLabelTranslated());
|
||||
|
||||
m_windowMenu->Detach();
|
||||
}
|
||||
@@ -927,7 +937,7 @@ wxMDIChildFrame::~wxMDIChildFrame()
|
||||
|
||||
DestroyChildren();
|
||||
|
||||
MDIRemoveWindowMenu(NULL, m_hMenu);
|
||||
MDIRemoveWindowMenu(NULL, m_hMenu, parent->GetWindowMenuLabelTranslated());
|
||||
|
||||
// MDIRemoveWindowMenu() doesn't update the MDI menu when called with NULL
|
||||
// window, so do it ourselves.
|
||||
@@ -1048,12 +1058,14 @@ void wxMDIChildFrame::InternalSetMenuBar()
|
||||
wxMDIParentFrame * const parent = GetMDIParent();
|
||||
|
||||
MDIInsertWindowMenu(parent->GetClientWindow(),
|
||||
m_hMenu, GetMDIWindowMenu(parent));
|
||||
m_hMenu, GetMDIWindowMenu(parent), parent->GetWindowMenuLabelTranslated());
|
||||
}
|
||||
|
||||
void wxMDIChildFrame::DetachMenuBar()
|
||||
{
|
||||
MDIRemoveWindowMenu(NULL, m_hMenu);
|
||||
wxMDIParentFrame * const parent = GetMDIParent();
|
||||
|
||||
MDIRemoveWindowMenu(NULL, m_hMenu, parent->GetWindowMenuLabelTranslated());
|
||||
wxFrame::DetachMenuBar();
|
||||
}
|
||||
|
||||
@@ -1553,7 +1565,7 @@ private:
|
||||
wxDECLARE_NO_COPY_CLASS(MenuIterator);
|
||||
};
|
||||
|
||||
void MDIInsertWindowMenu(wxWindow *win, WXHMENU hMenu, HMENU menuWin)
|
||||
void MDIInsertWindowMenu(wxWindow *win, WXHMENU hMenu, HMENU menuWin, const wxString& windowMenuLabelTranslated)
|
||||
{
|
||||
HMENU hmenu = (HMENU)hMenu;
|
||||
|
||||
@@ -1563,7 +1575,6 @@ void MDIInsertWindowMenu(wxWindow *win, WXHMENU hMenu, HMENU menuWin)
|
||||
bool inserted = false;
|
||||
wxString buf;
|
||||
MenuIterator it(hmenu);
|
||||
WINDOW_MENU_LABEL_TRANSLATED = wxGetTranslation(WINDOW_MENU_LABEL);
|
||||
while ( it.GetNext(buf) )
|
||||
{
|
||||
const wxString label = wxStripMenuCodes(buf);
|
||||
@@ -1573,7 +1584,7 @@ void MDIInsertWindowMenu(wxWindow *win, WXHMENU hMenu, HMENU menuWin)
|
||||
::InsertMenu(hmenu, it.GetPos(),
|
||||
MF_BYPOSITION | MF_POPUP | MF_STRING,
|
||||
(UINT_PTR)menuWin,
|
||||
WINDOW_MENU_LABEL_TRANSLATED.t_str());
|
||||
windowMenuLabelTranslated.t_str());
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1582,14 +1593,14 @@ void MDIInsertWindowMenu(wxWindow *win, WXHMENU hMenu, HMENU menuWin)
|
||||
{
|
||||
::AppendMenu(hmenu, MF_POPUP,
|
||||
(UINT_PTR)menuWin,
|
||||
WINDOW_MENU_LABEL_TRANSLATED.t_str());
|
||||
windowMenuLabelTranslated.t_str());
|
||||
}
|
||||
}
|
||||
|
||||
MDISetMenu(win, hmenu, menuWin);
|
||||
}
|
||||
|
||||
void MDIRemoveWindowMenu(wxWindow *win, WXHMENU hMenu)
|
||||
void MDIRemoveWindowMenu(wxWindow *win, WXHMENU hMenu, const wxString& windowMenuLabelTranslated)
|
||||
{
|
||||
HMENU hmenu = (HMENU)hMenu;
|
||||
|
||||
@@ -1599,7 +1610,7 @@ void MDIRemoveWindowMenu(wxWindow *win, WXHMENU hMenu)
|
||||
MenuIterator it(hmenu);
|
||||
while ( it.GetNext(buf) )
|
||||
{
|
||||
if ( wxStrcmp(buf, WINDOW_MENU_LABEL_TRANSLATED) == 0 )
|
||||
if ( wxStrcmp(buf, windowMenuLabelTranslated) == 0 )
|
||||
{
|
||||
if ( !::RemoveMenu(hmenu, it.GetPos(), MF_BYPOSITION) )
|
||||
{
|
||||
|
Reference in New Issue
Block a user