Slightly simplify the previous commits

Remove SetWindowMenuLabelTranslated() which was only called once and so
didn't seem to be worth having. Also get rid of WINDOW_MENU_LABEL for
the same reason: it was used only once and imposed the use of
gettext_noop() which is not needed any longer.

Rename GetWindowMenuLabelTranslated() to have a MSW prefix in order to
indicate that it's a private MSW function and not part of the public wx
API.

Also renamed "Translated" to "Current" to (hopefully) more clearly
indicate why do we need to keep this variable.
This commit is contained in:
Vadim Zeitlin
2018-09-18 00:13:35 +02:00
parent 9a9176a1be
commit 2ee322b667
2 changed files with 20 additions and 26 deletions

View File

@@ -85,11 +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;
// Retrieve the current window menu label: it can be different from
// "Window" when using non-English translations and can also be different
// from wxGetTranslation("Window") if the locale has changed since the
// "Window" menu was added.
const wxString& MSWGetCurrentWindowMenuLabel() const
{ return m_currentWindowMenuLabel; }
// handlers
// --------
@@ -157,7 +158,7 @@ private:
bool m_activationNotHandled;
// holds the current translation for the window menu label
wxString m_windowMenuLabelTranslated;
wxString m_currentWindowMenuLabel;
friend class WXDLLIMPEXP_FWD_CORE wxMDIChildFrame;

View File

@@ -75,9 +75,6 @@ const int wxLAST_MDI_CHILD = wxFIRST_MDI_CHILD + 8;
// child.
const int wxID_MDI_MORE_WINDOWS = wxLAST_MDI_CHILD + 1;
// The MDI "Window" menu label
const char *WINDOW_MENU_LABEL = gettext_noop("&Window");
// ---------------------------------------------------------------------------
// private functions
// ---------------------------------------------------------------------------
@@ -277,16 +274,6 @@ 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))
@@ -344,8 +331,12 @@ void wxMDIParentFrame::AddWindowMenu()
// attach it to the menu bar.
m_windowMenu->Attach(GetMenuBar());
SetWindowMenuLabelTranslated();
MDIInsertWindowMenu(GetClientWindow(), m_hMenu, GetMDIWindowMenu(this), GetWindowMenuLabelTranslated());
// Store the current translation, we can't use _("Window") later in
// case the locale changes.
m_currentWindowMenuLabel = _("&Window");
MDIInsertWindowMenu(GetClientWindow(), m_hMenu, GetMDIWindowMenu(this),
m_currentWindowMenuLabel);
}
}
@@ -353,7 +344,8 @@ void wxMDIParentFrame::RemoveWindowMenu()
{
if ( m_windowMenu )
{
MDIRemoveWindowMenu(GetClientWindow(), m_hMenu, GetWindowMenuLabelTranslated());
MDIRemoveWindowMenu(GetClientWindow(), m_hMenu,
m_currentWindowMenuLabel);
m_windowMenu->Detach();
}
@@ -937,7 +929,7 @@ wxMDIChildFrame::~wxMDIChildFrame()
DestroyChildren();
MDIRemoveWindowMenu(NULL, m_hMenu, parent->GetWindowMenuLabelTranslated());
MDIRemoveWindowMenu(NULL, m_hMenu, parent->MSWGetCurrentWindowMenuLabel());
// MDIRemoveWindowMenu() doesn't update the MDI menu when called with NULL
// window, so do it ourselves.
@@ -1058,14 +1050,15 @@ void wxMDIChildFrame::InternalSetMenuBar()
wxMDIParentFrame * const parent = GetMDIParent();
MDIInsertWindowMenu(parent->GetClientWindow(),
m_hMenu, GetMDIWindowMenu(parent), parent->GetWindowMenuLabelTranslated());
m_hMenu, GetMDIWindowMenu(parent),
parent->MSWGetCurrentWindowMenuLabel());
}
void wxMDIChildFrame::DetachMenuBar()
{
wxMDIParentFrame * const parent = GetMDIParent();
MDIRemoveWindowMenu(NULL, m_hMenu, parent->GetWindowMenuLabelTranslated());
MDIRemoveWindowMenu(NULL, m_hMenu, parent->MSWGetCurrentWindowMenuLabel());
wxFrame::DetachMenuBar();
}