diff --git a/include/wx/cocoa/menu.h b/include/wx/cocoa/menu.h index 479afe083b..a2f4fc75bf 100644 --- a/include/wx/cocoa/menu.h +++ b/include/wx/cocoa/menu.h @@ -4,7 +4,7 @@ // Author: David Elliott // Modified by: // Created: 2002/12/09 -// RCS-ID: $Id: +// RCS-ID: $Id: // Copyright: (c) 2002 David Elliott // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -102,8 +102,8 @@ public: virtual void EnableTop(size_t pos, bool enable); virtual bool IsEnabledTop(size_t pos) const; - virtual void SetLabelTop(size_t pos, const wxString& label); - virtual wxString GetLabelTop(size_t pos) const; + virtual void SetMenuLabel(size_t pos, const wxString& label); + virtual wxString GetMenuLabel(size_t pos) const; virtual void Attach(wxFrame *frame); virtual void Detach(); diff --git a/include/wx/cocoa/menuitem.h b/include/wx/cocoa/menuitem.h index d5ba585ac6..f0e7d137d1 100644 --- a/include/wx/cocoa/menuitem.h +++ b/include/wx/cocoa/menuitem.h @@ -4,7 +4,7 @@ // Author: David Elliott // Modified by: // Created: 2002/12/13 -// RCS-ID: $Id: +// RCS-ID: $Id: // Copyright: (c) 2002 David Elliott // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -63,7 +63,7 @@ protected: // ------------------------------------------------------------------------ public: // override base class virtuals to update the item appearance on screen - virtual void SetText(const wxString& text); + virtual void SetItemLabel(const wxString& text); virtual void SetCheckable(bool checkable); virtual void Enable(bool enable = TRUE); diff --git a/include/wx/gtk/menu.h b/include/wx/gtk/menu.h index ba4c245a9d..eda3f5a5b1 100644 --- a/include/wx/gtk/menu.h +++ b/include/wx/gtk/menu.h @@ -34,8 +34,8 @@ public: virtual wxMenuItem* FindItem( int id, wxMenu **menu = NULL ) const; virtual void EnableTop( size_t pos, bool flag ); - virtual void SetLabelTop( size_t pos, const wxString& label ); - virtual wxString GetLabelTop( size_t pos ) const; + virtual void SetMenuLabel( size_t pos, const wxString& label ); + virtual wxString GetMenuLabel( size_t pos ) const; void SetLayoutDirection(wxLayoutDirection dir); wxLayoutDirection GetLayoutDirection() const; diff --git a/include/wx/gtk/menuitem.h b/include/wx/gtk/menuitem.h index 7ac723e239..4133cc5e83 100644 --- a/include/wx/gtk/menuitem.h +++ b/include/wx/gtk/menuitem.h @@ -28,7 +28,8 @@ public: virtual ~wxMenuItem(); // implement base class virtuals - virtual void SetText( const wxString& str ); + virtual void SetItemLabel( const wxString& str ); + virtual wxString GetItemLabel() const; virtual void Enable( bool enable = TRUE ); virtual void Check( bool check = TRUE ); virtual bool IsChecked() const; @@ -77,6 +78,5 @@ private: DECLARE_DYNAMIC_CLASS(wxMenuItem) }; - #endif //__GTKMENUITEMH__ diff --git a/include/wx/gtk1/menu.h b/include/wx/gtk1/menu.h index f2aef5abb5..32136bdd09 100644 --- a/include/wx/gtk1/menu.h +++ b/include/wx/gtk1/menu.h @@ -34,8 +34,8 @@ public: virtual wxMenuItem* FindItem( int id, wxMenu **menu = NULL ) const; virtual void EnableTop( size_t pos, bool flag ); - virtual void SetLabelTop( size_t pos, const wxString& label ); - virtual wxString GetLabelTop( size_t pos ) const; + virtual void SetMenuLabel( size_t pos, const wxString& label ); + virtual wxString GetMenuLabel( size_t pos ) const; // implementation only from now on void SetInvokingWindow( wxWindow *win ); diff --git a/include/wx/gtk1/menuitem.h b/include/wx/gtk1/menuitem.h index 565cb5620d..827cf6e780 100644 --- a/include/wx/gtk1/menuitem.h +++ b/include/wx/gtk1/menuitem.h @@ -28,7 +28,8 @@ public: virtual ~wxMenuItem(); // implement base class virtuals - virtual void SetText( const wxString& str ); + virtual void SetItemLabel( const wxString& str ); + virtual wxString GetItemLabel() const; virtual void Enable( bool enable = TRUE ); virtual void Check( bool check = TRUE ); virtual bool IsChecked() const; @@ -73,6 +74,5 @@ private: DECLARE_DYNAMIC_CLASS(wxMenuItem) }; - #endif //__GTKMENUITEMH__ diff --git a/include/wx/mac/carbon/menu.h b/include/wx/mac/carbon/menu.h index 5fda6b8f6a..634ee2fe87 100644 --- a/include/wx/mac/carbon/menu.h +++ b/include/wx/mac/carbon/menu.h @@ -43,7 +43,7 @@ public: // implementation only from now on // ------------------------------- - int MacGetIndexFromId( int id ) ; + int MacGetIndexFromId( int id ) ; int MacGetIndexFromItem( wxMenuItem *pItem ) ; void MacEnableMenu( bool bDoEnable ) ; // MacOS needs to know about submenus somewhere within this menu @@ -119,8 +119,8 @@ public: virtual wxMenuItem* FindItem( int id, wxMenu **menu = NULL ) const; virtual void EnableTop( size_t pos, bool flag ); - virtual void SetLabelTop( size_t pos, const wxString& label ); - virtual wxString GetLabelTop( size_t pos ) const; + virtual void SetMenuLabel( size_t pos, const wxString& label ); + virtual wxString GetMenuLabel( size_t pos ) const; virtual bool Enable( bool enable = TRUE ); // for virtual function hiding virtual void Enable( int itemid, bool enable ) diff --git a/include/wx/mac/carbon/menuitem.h b/include/wx/mac/carbon/menuitem.h index 7f89ee9420..a5b087cb5a 100644 --- a/include/wx/mac/carbon/menuitem.h +++ b/include/wx/mac/carbon/menuitem.h @@ -35,7 +35,7 @@ public: virtual ~wxMenuItem(); // override base class virtuals - virtual void SetText(const wxString& strName); + virtual void SetItemLabel(const wxString& strName); virtual void Enable(bool bDoEnable = true); virtual void Check(bool bDoCheck = true); diff --git a/include/wx/menu.h b/include/wx/menu.h index 852b6eac20..0de4fb3eef 100644 --- a/include/wx/menu.h +++ b/include/wx/menu.h @@ -237,6 +237,9 @@ public: void SetLabel(int itemid, const wxString& label); wxString GetLabel(int itemid) const; + // Returns the stripped label + wxString GetLabelText(int itemid) const { return wxMenuItem::GetLabelText(GetLabel(itemid)); } + virtual void SetHelpString(int itemid, const wxString& helpString); virtual wxString GetHelpString(int itemid) const; @@ -424,8 +427,11 @@ public: virtual bool IsEnabledTop(size_t WXUNUSED(pos)) const { return true; } // get or change the label of the menu at given position - virtual void SetLabelTop(size_t pos, const wxString& label) = 0; - virtual wxString GetLabelTop(size_t pos) const = 0; + virtual void SetMenuLabel(size_t pos, const wxString& label) = 0; + virtual wxString GetMenuLabel(size_t pos) const = 0; + + // get the stripped label of the menu at given position + virtual wxString GetMenuLabelText(size_t pos) const { return wxMenuItem::GetLabelText(GetMenuLabel(pos)); } // item search // ----------- @@ -490,6 +496,12 @@ public: virtual bool CanBeOutsideClientArea() const { return true; } +#if WXWIN_COMPATIBILITY_2_8 + // get or change the label of the menu at given position + wxDEPRECATED( void SetLabelTop(size_t pos, const wxString& label) ); + wxDEPRECATED( wxString GetLabelTop(size_t pos) const ); +#endif + protected: // the list of all our menus wxMenuList m_menus; @@ -500,6 +512,19 @@ protected: DECLARE_NO_COPY_CLASS(wxMenuBarBase) }; +#if WXWIN_COMPATIBILITY_2_8 +// get or change the label of the menu at given position +void wxMenuBarBase::SetLabelTop(size_t pos, const wxString& label) +{ + SetMenuLabel(pos, label); +} + +wxString wxMenuBarBase::GetLabelTop(size_t pos) const +{ + return GetMenuLabel(pos); +} +#endif + // ---------------------------------------------------------------------------- // include the real class declaration // ---------------------------------------------------------------------------- diff --git a/include/wx/menuitem.h b/include/wx/menuitem.h index bc9d0bee0f..75b2dcff3d 100644 --- a/include/wx/menuitem.h +++ b/include/wx/menuitem.h @@ -60,16 +60,23 @@ public: // the item's text (or name) // - // NB: the item's text includes the accelerators and mnemonics info (if + // NB: the item's label includes the accelerators and mnemonics info (if // any), i.e. it may contain '&' or '_' or "\t..." and thus is - // different from the item's label which only contains the text shown - // in the menu - virtual void SetText(const wxString& str); - wxString GetLabel() const { return GetLabelFromText(m_text); } - const wxString& GetText() const { return m_text; } + // different from the item's text which only contains the text shown + // in the menu. This used to be called SetText. + virtual void SetItemLabel(const wxString& str); - // get the label from text (implemented in platform-specific code) - static wxString GetLabelFromText(const wxString& text); + // return the item label including any mnemonics and accelerators. + // This used to be called GetText. + virtual wxString GetItemLabel() const { return m_text; } + + // return just the text of the item label, without any mnemonics + // This used to be called GetLabel. + virtual wxString GetItemLabelText() const { return GetLabelText(m_text); } + + // return just the text part of the given label (implemented in platform-specific code) + // This used to be called GetLabelFromText. + static wxString GetLabelText(const wxString& label); // what kind of menu item we are wxItemKind GetKind() const { return m_kind; } @@ -111,7 +118,19 @@ public: #if WXWIN_COMPATIBILITY_2_8 // compatibility only, use new functions in the new code wxDEPRECATED( void SetName(const wxString& str) ); - wxDEPRECATED( const wxString& GetName() const ); + wxDEPRECATED( wxString GetName() const ); + + // Now use GetItemLabelText + wxDEPRECATED( wxString GetLabel() const ) ; + + // Now use GetItemLabel + wxDEPRECATED( const wxString& GetText() const ); + + // Now use GetLabelText to strip the accelerators + wxDEPRECATED( static wxString GetLabelFromText(const wxString& text) ); + + // Now use SetItemLabel + wxDEPRECATED( virtual void SetText(const wxString& str) ); #endif // WXWIN_COMPATIBILITY_2_8 static wxMenuItem *New(wxMenu *parentMenu, @@ -152,9 +171,13 @@ private: #if WXWIN_COMPATIBILITY_2_8 inline void wxMenuItemBase::SetName(const wxString &str) - { SetText(str); } -inline const wxString& wxMenuItemBase::GetName() const - { return GetText(); } + { SetItemLabel(str); } +inline wxString wxMenuItemBase::GetName() const + { return GetItemLabel(); } +inline wxString wxMenuItemBase::GetLabel() const + { return GetLabelFromText(m_text); } +inline const wxString& wxMenuItemBase::GetText() const { return m_text; } +inline void wxMenuItemBase::SetText(const wxString& text) { SetItemLabel(text); } #endif // WXWIN_COMPATIBILITY_2_8 // ---------------------------------------------------------------------------- diff --git a/include/wx/motif/menu.h b/include/wx/motif/menu.h index 22ed6b55a0..a48c219af0 100644 --- a/include/wx/motif/menu.h +++ b/include/wx/motif/menu.h @@ -130,8 +130,8 @@ public: virtual wxMenuItem* FindItem( int id, wxMenu **menu = NULL ) const; virtual void EnableTop( size_t pos, bool flag ); - virtual void SetLabelTop( size_t pos, const wxString& label ); - virtual wxString GetLabelTop( size_t pos ) const; + virtual void SetMenuLabel( size_t pos, const wxString& label ); + virtual wxString GetMenuLabel( size_t pos ) const; // implementation only from now on // ------------------------------- diff --git a/include/wx/motif/menuitem.h b/include/wx/motif/menuitem.h index 7df8dd2e4e..e8b114573a 100644 --- a/include/wx/motif/menuitem.h +++ b/include/wx/motif/menuitem.h @@ -33,7 +33,7 @@ public: virtual ~wxMenuItem(); // accessors (some more are inherited from wxOwnerDrawn or are below) - virtual void SetText(const wxString& label); + virtual void SetItemLabel(const wxString& label); virtual void Enable(bool enable = true); virtual void Check(bool check = true); // included SetBitmap and GetBitmap as copied from the GTK include file diff --git a/include/wx/msw/menu.h b/include/wx/msw/menu.h index fde7364053..18ab994c8f 100644 --- a/include/wx/msw/menu.h +++ b/include/wx/msw/menu.h @@ -163,8 +163,8 @@ public: virtual wxMenu *Remove(size_t pos); virtual void EnableTop( size_t pos, bool flag ); - virtual void SetLabelTop( size_t pos, const wxString& label ); - virtual wxString GetLabelTop( size_t pos ) const; + virtual void SetMenuLabel( size_t pos, const wxString& label ); + virtual wxString GetMenuLabel( size_t pos ) const; // implementation from now on WXHMENU Create(); diff --git a/include/wx/msw/menuitem.h b/include/wx/msw/menuitem.h index 3b9d7875d3..6c6f5885a3 100644 --- a/include/wx/msw/menuitem.h +++ b/include/wx/msw/menuitem.h @@ -40,7 +40,7 @@ public: virtual ~wxMenuItem(); // override base class virtuals - virtual void SetText(const wxString& strName); + virtual void SetItemLabel(const wxString& strName); virtual void SetCheckable(bool checkable); virtual void Enable(bool bDoEnable = true); diff --git a/include/wx/os2/menu.h b/include/wx/os2/menu.h index f7edd51be0..a4c380faa8 100644 --- a/include/wx/os2/menu.h +++ b/include/wx/os2/menu.h @@ -226,10 +226,10 @@ public: virtual void EnableTop( size_t nPos ,bool bFlag ); - virtual void SetLabelTop( size_t nPos + virtual void SetMenuLabel( size_t nPos ,const wxString& rLabel ); - virtual wxString GetLabelTop(size_t nPos) const; + virtual wxString GetMenuLabel(size_t nPos) const; // // Implementation from now on diff --git a/include/wx/os2/menuitem.h b/include/wx/os2/menuitem.h index 1e9d1d89b8..350f850848 100644 --- a/include/wx/os2/menuitem.h +++ b/include/wx/os2/menuitem.h @@ -64,7 +64,7 @@ public: // // Override base class virtuals // - virtual void SetText(const wxString& rStrName); + virtual void SetItemLabel(const wxString& rStrName); virtual void SetCheckable(bool bCheckable); virtual void Enable(bool bDoEnable = true); diff --git a/include/wx/palmos/menu.h b/include/wx/palmos/menu.h index 4980b4523c..6859d70bbb 100644 --- a/include/wx/palmos/menu.h +++ b/include/wx/palmos/menu.h @@ -144,8 +144,8 @@ public: virtual wxMenu *Remove(size_t pos); virtual void EnableTop( size_t pos, bool flag ); - virtual void SetLabelTop( size_t pos, const wxString& label ); - virtual wxString GetLabelTop( size_t pos ) const; + virtual void SetMenuLabel( size_t pos, const wxString& label ); + virtual wxString GetMenuLabel( size_t pos ) const; // implementation from now on WXHMENU Create(); diff --git a/include/wx/palmos/menuitem.h b/include/wx/palmos/menuitem.h index 9954fd3827..df01b0092f 100644 --- a/include/wx/palmos/menuitem.h +++ b/include/wx/palmos/menuitem.h @@ -40,7 +40,7 @@ public: virtual ~wxMenuItem(); // override base class virtuals - virtual void SetText(const wxString& strName); + virtual void SetItemLabel(const wxString& strName); virtual void SetCheckable(bool checkable); virtual void Enable(bool bDoEnable = TRUE); diff --git a/include/wx/univ/menu.h b/include/wx/univ/menu.h index 591df3bd66..6515c41b36 100644 --- a/include/wx/univ/menu.h +++ b/include/wx/univ/menu.h @@ -155,8 +155,8 @@ public: virtual void EnableTop(size_t pos, bool enable); virtual bool IsEnabledTop(size_t pos) const; - virtual void SetLabelTop(size_t pos, const wxString& label); - virtual wxString GetLabelTop(size_t pos) const; + virtual void SetMenuLabel(size_t pos, const wxString& label); + virtual wxString GetMenuLabel(size_t pos) const; virtual void Attach(wxFrame *frame); virtual void Detach(); diff --git a/include/wx/univ/menuitem.h b/include/wx/univ/menuitem.h index da63e3afa0..3601bd5fc8 100644 --- a/include/wx/univ/menuitem.h +++ b/include/wx/univ/menuitem.h @@ -29,7 +29,7 @@ public: virtual ~wxMenuItem(); // override base class virtuals to update the item appearance on screen - virtual void SetText(const wxString& text); + virtual void SetItemLabel(const wxString& text); virtual void SetCheckable(bool checkable); virtual void Enable(bool enable = true); @@ -94,7 +94,7 @@ protected: // the bitmaps (may be invalid, then they're not used) wxBitmap m_bmpChecked, m_bmpUnchecked, - m_bmpDisabled; + m_bmpDisabled; // the positions of the first and last items of the radio group this item // belongs to or -1: start is the radio group start and is valid for all diff --git a/samples/menu/menu.cpp b/samples/menu/menu.cpp index 4a11c52c36..a9f4b67837 100644 --- a/samples/menu/menu.cpp +++ b/samples/menu/menu.cpp @@ -719,7 +719,7 @@ void MyFrame::OnGetLabelMenu(wxCommandEvent& WXUNUSED(event)) wxCHECK_RET( count, _T("no last menu?") ); wxLogMessage(_T("The label of the last menu item is '%s'"), - mbar->GetLabelTop(count - 1).c_str()); + mbar->GetMenuLabel(count - 1).c_str()); } #if wxUSE_TEXTDLG @@ -734,13 +734,13 @@ void MyFrame::OnSetLabelMenu(wxCommandEvent& WXUNUSED(event)) ( _T("Enter new label: "), _T("Change last menu text"), - mbar->GetLabelTop(count - 1), + mbar->GetMenuLabel(count - 1), this ); if ( !label.empty() ) { - mbar->SetLabelTop(count - 1, label); + mbar->SetMenuLabel(count - 1, label); } } @@ -874,14 +874,14 @@ void MyFrame::OnSetLabelMenuItem(wxCommandEvent& WXUNUSED(event)) ( _T("Enter new label: "), _T("Change last menu item text"), - item->GetLabel(), + item->GetItemLabel(), this ); label.Replace( _T("\\t"), _T("\t") ); if ( !label.empty() ) { - item->SetText(label); + item->SetItemLabel(label); } } } diff --git a/src/cocoa/menu.mm b/src/cocoa/menu.mm index 55e0f3035b..df0e8612aa 100644 --- a/src/cocoa/menu.mm +++ b/src/cocoa/menu.mm @@ -215,11 +215,11 @@ bool wxMenuBar::IsEnabledTop(size_t pos) const return false; } -void wxMenuBar::SetLabelTop(size_t pos, const wxString& label) +void wxMenuBar::SetMenuLabel(size_t pos, const wxString& label) { } -wxString wxMenuBar::GetLabelTop(size_t pos) const +wxString wxMenuBar::GetMenuLabel(size_t pos) const { wxMenu *menu = GetMenu(pos); int itemindex = [m_cocoaNSMenu indexOfItemWithSubmenu:menu->GetNSMenu()]; diff --git a/src/cocoa/menuitem.mm b/src/cocoa/menuitem.mm index e87f6b2aa6..81ccdd73a3 100644 --- a/src/cocoa/menuitem.mm +++ b/src/cocoa/menuitem.mm @@ -98,7 +98,7 @@ wxMenuItem *wxMenuItemBase::New(wxMenu *parentMenu, } /* static */ -wxString wxMenuItemBase::GetLabelFromText(const wxString& text) +wxString wxMenuItemBase::GetLabelText(const wxString& text) { return wxStripMenuCodes(text); } @@ -281,9 +281,9 @@ void wxMenuItem::Check(bool check) } } -void wxMenuItem::SetText(const wxString& label) +void wxMenuItem::SetItemLabel(const wxString& label) { - wxMenuItemBase::SetText(label); + wxMenuItemBase::SetItemLabel(label); wxCHECK_RET(m_kind != wxITEM_SEPARATOR, wxT("Separator items do not have titles.")); [m_cocoaNSMenuItem setTitle: wxNSStringWithWxString(wxStripMenuCodes(label))]; CocoaSetKeyEquivalent(); diff --git a/src/common/menucmn.cpp b/src/common/menucmn.cpp index 2b65f80845..0c85d548ba 100644 --- a/src/common/menucmn.cpp +++ b/src/common/menucmn.cpp @@ -71,7 +71,7 @@ wxMenuItemBase::wxMenuItemBase(wxMenu *parentMenu, if (m_id == wxID_SEPARATOR) m_kind = wxITEM_SEPARATOR; - SetText(text); + SetItemLabel(text); SetHelp(help); } @@ -84,7 +84,7 @@ wxMenuItemBase::~wxMenuItemBase() wxAcceleratorEntry *wxMenuItemBase::GetAccel() const { - return wxAcceleratorEntry::Create(GetText()); + return wxAcceleratorEntry::Create(GetItemLabel()); } void wxMenuItemBase::SetAccel(wxAcceleratorEntry *accel) @@ -96,12 +96,12 @@ void wxMenuItemBase::SetAccel(wxAcceleratorEntry *accel) text += accel->ToString(); } - SetText(text); + SetItemLabel(text); } #endif // wxUSE_ACCEL -void wxMenuItemBase::SetText(const wxString& str) +void wxMenuItemBase::SetItemLabel(const wxString& str) { m_text = str; @@ -125,6 +125,13 @@ void wxMenuItemBase::SetHelp(const wxString& str) } } +#if WXWIN_COMPATIBILITY_2_8 +wxString wxMenuItemBase::GetLabelFromText(const wxString& text) +{ + return GetLabelText(text); +} +#endif + bool wxMenuBase::ms_locked = true; // ---------------------------------------------------------------------------- @@ -283,7 +290,7 @@ bool wxMenuBase::DoDestroy(wxMenuItem *item) // Finds the item id matching the given string, wxNOT_FOUND if not found. int wxMenuBase::FindItem(const wxString& text) const { - wxString label = wxMenuItem::GetLabelFromText(text); + wxString label = wxMenuItem::GetLabelText(text); for ( wxMenuItemList::compatibility_iterator node = m_items.GetFirst(); node; node = node->GetNext() ) @@ -545,7 +552,7 @@ void wxMenuBase::SetLabel( int id, const wxString &label ) wxCHECK_RET( item, wxT("wxMenu::SetLabel: no such item") ); - item->SetText(label); + item->SetItemLabel(label); } wxString wxMenuBase::GetLabel( int id ) const @@ -554,7 +561,7 @@ wxString wxMenuBase::GetLabel( int id ) const wxCHECK_MSG( item, wxEmptyString, wxT("wxMenu::GetLabel: no such item") ); - return item->GetText(); + return item->GetItemLabel(); } void wxMenuBase::SetHelpString( int id, const wxString& helpString ) @@ -665,14 +672,14 @@ wxMenu *wxMenuBarBase::Remove(size_t pos) int wxMenuBarBase::FindMenu(const wxString& title) const { - wxString label = wxMenuItem::GetLabelFromText(title); + wxString label = wxMenuItem::GetLabelText(title); size_t count = GetMenuCount(); for ( size_t i = 0; i < count; i++ ) { - wxString title2 = GetLabelTop(i); + wxString title2 = GetMenuLabel(i); if ( (title2 == title) || - (wxMenuItem::GetLabelFromText(title2) == label) ) + (wxMenuItem::GetLabelText(title2) == label) ) { // found return (int)i; @@ -723,13 +730,13 @@ wxMenuItem *wxMenuBarBase::FindItem(int id, wxMenu **menu) const int wxMenuBarBase::FindMenuItem(const wxString& menu, const wxString& item) const { - wxString label = wxMenuItem::GetLabelFromText(menu); + wxString label = wxMenuItem::GetLabelText(menu); int i = 0; wxMenuList::compatibility_iterator node; for ( node = m_menus.GetFirst(); node; node = node->GetNext(), i++ ) { - if ( label == wxMenuItem::GetLabelFromText(GetLabelTop(i)) ) + if ( label == wxMenuItem::GetLabelText(GetMenuLabel(i)) ) return node->GetData()->FindItem(item); } @@ -783,7 +790,7 @@ void wxMenuBarBase::SetLabel(int id, const wxString& label) wxCHECK_RET( item, wxT("wxMenuBar::SetLabel(): no such item") ); - item->SetText(label); + item->SetItemLabel(label); } wxString wxMenuBarBase::GetLabel(int id) const @@ -793,7 +800,7 @@ wxString wxMenuBarBase::GetLabel(int id) const wxCHECK_MSG( item, wxEmptyString, wxT("wxMenuBar::GetLabel(): no such item") ); - return item->GetText(); + return item->GetItemLabel(); } void wxMenuBarBase::SetHelpString(int id, const wxString& helpString) diff --git a/src/common/utilscmn.cpp b/src/common/utilscmn.cpp index 96b8727593..2183825135 100644 --- a/src/common/utilscmn.cpp +++ b/src/common/utilscmn.cpp @@ -1153,7 +1153,7 @@ bool wxLaunchDefaultBrowser(const wxString& urlOrig, int flags) wxChar *wxStripMenuCodes(const wxChar *in, wxChar *out) { #if wxUSE_MENUS - wxString s = wxMenuItem::GetLabelFromText(in); + wxString s = wxMenuItem::GetLabelText(in); #else wxString str(in); wxString s = wxStripMenuCodes(str); diff --git a/src/gtk/menu.cpp b/src/gtk/menu.cpp index 97d926f92f..51fa71566c 100644 --- a/src/gtk/menu.cpp +++ b/src/gtk/menu.cpp @@ -90,6 +90,40 @@ static wxString wxReplaceUnderscore( const wxString& title ) return str; } +static wxString wxConvertFromGTKToWXLabel(const wxString& gtkLabel) +{ + wxString label; + for ( const wxChar *pc = gtkLabel.c_str(); *pc; pc++ ) + { + // '_' is the escape character for GTK+. + + if ( *pc == wxT('_') && *(pc+1) == wxT('_')) + { + // An underscore was escaped. + label += wxT('_'); + pc++; + } + else if ( *pc == wxT('_') ) + { + // Convert GTK+ hotkey symbol to wxWidgets/Windows standard + label += wxT('&'); + } + else if ( *pc == wxT('&') ) + { + // Double the ampersand to escape it as far as wxWidgets is concerned + label += wxT("&&"); + } + else + { + // don't remove ampersands '&' since if we have them in the menu title + // it means that they were doubled to indicate "&" instead of accelerator + label += *pc; + } + } + + return label; +} + //----------------------------------------------------------------------------- // activate message from GTK //----------------------------------------------------------------------------- @@ -419,7 +453,7 @@ wxMenu *wxMenuBar::Remove(size_t pos) static int FindMenuItemRecursive( const wxMenu *menu, const wxString &menuString, const wxString &itemString ) { - if (wxMenuItem::GetLabelFromText(menu->GetTitle()) == wxMenuItem::GetLabelFromText(menuString)) + if (wxMenuItem::GetLabelText(wxConvertFromGTKToWXLabel(menu->GetTitle())) == wxMenuItem::GetLabelText(menuString)) { int res = menu->FindItem( itemString ); if (res != wxNOT_FOUND) @@ -504,7 +538,7 @@ void wxMenuBar::EnableTop( size_t pos, bool flag ) gtk_widget_set_sensitive( menu->m_owner, flag ); } -wxString wxMenuBar::GetLabelTop( size_t pos ) const +wxString wxMenuBar::GetMenuLabel( size_t pos ) const { wxMenuList::compatibility_iterator node = m_menus.Item( pos ); @@ -512,26 +546,10 @@ wxString wxMenuBar::GetLabelTop( size_t pos ) const wxMenu* menu = node->GetData(); - wxString label; - wxString text( menu->GetTitle() ); - for ( const wxChar *pc = text.c_str(); *pc; pc++ ) - { - if ( *pc == wxT('_') ) - { - // '_' is the escape character for GTK+ - continue; - } - - // don't remove ampersands '&' since if we have them in the menu title - // it means that they were doubled to indicate "&" instead of accelerator - - label += *pc; - } - - return label; + return wxConvertFromGTKToWXLabel(menu->GetTitle()); } -void wxMenuBar::SetLabelTop( size_t pos, const wxString& label ) +void wxMenuBar::SetMenuLabel( size_t pos, const wxString& label ) { wxMenuList::compatibility_iterator node = m_menus.Item( pos ); @@ -728,8 +746,19 @@ wxMenuItem::~wxMenuItem() // return the menu item text without any menu accels /* static */ -wxString wxMenuItemBase::GetLabelFromText(const wxString& text) + +// TODO: this is now wrong, because it will be used by public APIs +// to convert from label-with-wxWidgets-hotkeys to plain text, +// and this function converts from GTK+ hotkeys to plain text. + +wxString wxMenuItemBase::GetLabelText(const wxString& text) { + // The argument to this function will now always be in wxWidgets standard label + // format, not GTK+ format, so we do what the other ports do. + + return wxStripMenuCodes(text); + +#if 0 wxString label; for ( const wxChar *pc = text.c_str(); *pc; pc++ ) @@ -763,12 +792,18 @@ wxString wxMenuItemBase::GetLabelFromText(const wxString& text) label += *pc; } - // wxPrintf( wxT("GetLabelFromText(): text %s label %s\n"), text.c_str(), label.c_str() ); + // wxPrintf( wxT("GetLabelText(): text %s label %s\n"), text.c_str(), label.c_str() ); return label; +#endif } -void wxMenuItem::SetText( const wxString& str ) +wxString wxMenuItem::GetItemLabel() const +{ + return wxConvertFromGTKToWXLabel(m_text); +} + +void wxMenuItem::SetItemLabel( const wxString& str ) { // cache some data which must be used later bool isstock = wxIsStockID(GetId()); @@ -863,7 +898,7 @@ void wxMenuItem::SetText( const wxString& str ) } // NOTE: this function is different from the similar functions GTKProcessMnemonics() -// implemented in control.cpp and from wxMenuItemBase::GetLabelFromText... +// implemented in control.cpp and from wxMenuItemBase::GetLabelText... // so there's no real code duplication wxString wxMenuItem::GTKProcessMenuItemLabel(const wxString& str, wxString *hotKey) { @@ -1022,7 +1057,7 @@ wxMenu::~wxMenu() // see wxMenu::Init gtk_widget_unref( m_menu ); g_object_unref( m_accel ); - + // if the menu is inserted in another menu at this time, there was // one more reference to it: if ( m_owner ) @@ -1047,7 +1082,7 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem, int pos) GtkWidget *menuItem; // cache some data used later - wxString text = mitem->GetText(); + wxString text = mitem->GetItemLabel(); int id = mitem->GetId(); bool isstock = wxIsStockID(id); const char *stockid = NULL; @@ -1113,7 +1148,7 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem, int pos) } else // a normal item { - // NB: 'text' variable has "_" instead of "&" after mitem->SetText() + // NB: 'text' variable has "_" instead of "&" after mitem->SetItemLabel() // so don't use it switch ( mitem->GetKind() ) @@ -1161,7 +1196,7 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem, int pos) GdkModifierType accel_mods; wxCharBuffer buf = wxGTK_CONV_SYS( GetGtkHotKey(*mitem) ); - // wxPrintf( wxT("item: %s hotkey %s\n"), mitem->GetText().c_str(), GetGtkHotKey(*mitem).c_str() ); + // wxPrintf( wxT("item: %s hotkey %s\n"), mitem->GetItemLabel().c_str(), GetGtkHotKey(*mitem).c_str() ); if (buf[(size_t)0] != '\0') { gtk_accelerator_parse( (const char*) buf, &accel_key, &accel_mods); diff --git a/src/gtk1/menu.cpp b/src/gtk1/menu.cpp index ea47b894ec..28436b7484 100644 --- a/src/gtk1/menu.cpp +++ b/src/gtk1/menu.cpp @@ -91,6 +91,41 @@ static wxString wxReplaceUnderscore( const wxString& title ) return str; } +static wxString wxConvertFromGTKToWXLabel(const wxString& gtkLabel) +{ + wxString label; + for ( const wxChar *pc = gtkLabel.c_str(); *pc; pc++ ) + { + // '_' is the escape character for GTK+. + + if ( *pc == wxT('_') && *(pc+1) == wxT('_')) + { + // An underscore was escaped. + label += wxT('_'); + pc++; + } + else if ( *pc == wxT('_') ) + { + // Convert GTK+ hotkey symbol to wxWidgets/Windows standard + label += wxT('&'); + } + else if ( *pc == wxT('&') ) + { + // Double the ampersand to escape it as far as wxWidgets is concerned + label += wxT("&&"); + } + else + { + // don't remove ampersands '&' since if we have them in the menu title + // it means that they were doubled to indicate "&" instead of accelerator + label += *pc; + } + } + + return label; +} + + //----------------------------------------------------------------------------- // activate message from GTK //----------------------------------------------------------------------------- @@ -408,7 +443,7 @@ wxMenu *wxMenuBar::Remove(size_t pos) static int FindMenuItemRecursive( const wxMenu *menu, const wxString &menuString, const wxString &itemString ) { - if (wxMenuItem::GetLabelFromText(menu->GetTitle()) == wxMenuItem::GetLabelFromText(menuString)) + if (wxMenuItem::GetLabelText(wxConvertFromGTKToWXLabel(menu->GetTitle())) == wxMenuItem::GetLabelText(menuString)) { int res = menu->FindItem( itemString ); if (res != wxNOT_FOUND) @@ -493,7 +528,7 @@ void wxMenuBar::EnableTop( size_t pos, bool flag ) gtk_widget_set_sensitive( menu->m_owner, flag ); } -wxString wxMenuBar::GetLabelTop( size_t pos ) const +wxString wxMenuBar::GetMenuLabel( size_t pos ) const { wxMenuList::compatibility_iterator node = m_menus.Item( pos ); @@ -501,26 +536,10 @@ wxString wxMenuBar::GetLabelTop( size_t pos ) const wxMenu* menu = node->GetData(); - wxString label; - wxString text( menu->GetTitle() ); - for ( const wxChar *pc = text.c_str(); *pc; pc++ ) - { - if ( *pc == wxT('_') ) - { - // '_' is the escape character for GTK+ - continue; - } - - // don't remove ampersands '&' since if we have them in the menu title - // it means that they were doubled to indicate "&" instead of accelerator - - label += *pc; - } - - return label; + return wxConvertFromGTKToWXLabel(menu->GetTitle()); } -void wxMenuBar::SetLabelTop( size_t pos, const wxString& label ) +void wxMenuBar::SetMenuLabel( size_t pos, const wxString& label ) { wxMenuList::compatibility_iterator node = m_menus.Item( pos ); @@ -734,8 +753,14 @@ wxMenuItem::~wxMenuItem() // return the menu item text without any menu accels /* static */ -wxString wxMenuItemBase::GetLabelFromText(const wxString& text) +wxString wxMenuItemBase::GetLabelText(const wxString& text) { + // The argument to this function will now always be in wxWidgets standard label + // format, not GTK+ format, so we do what the other ports do. + + return wxStripMenuCodes(text); + +#if 0 wxString label; for ( const wxChar *pc = text.c_str(); *pc; pc++ ) @@ -761,12 +786,18 @@ wxString wxMenuItemBase::GetLabelFromText(const wxString& text) label += *pc; } - // wxPrintf( wxT("GetLabelFromText(): text %s label %s\n"), text.c_str(), label.c_str() ); + // wxPrintf( wxT("GetLabelText(): text %s label %s\n"), text.c_str(), label.c_str() ); return label; +#endif } -void wxMenuItem::SetText( const wxString& string ) +wxString wxMenuItem::GetItemLabel() const +{ + return wxConvertFromGTKToWXLabel(m_text); +} + +void wxMenuItem::SetItemLabel( const wxString& string ) { wxString str = string; if ( str.empty() && !IsSeparator() ) @@ -996,7 +1027,7 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem, int pos) } else if (mitem->GetBitmap().Ok()) { - text = mitem->GetText(); + text = mitem->GetItemLabel(); const wxBitmap *bitmap = &mitem->GetBitmap(); // TODO @@ -1008,8 +1039,8 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem, int pos) } else // a normal item { - // text has "_" instead of "&" after mitem->SetText() so don't use it - text = mitem->GetText() ; + // text has "_" instead of "&" after mitem->SetItemLabel() so don't use it + text = mitem->GetItemLabel() ; switch ( mitem->GetKind() ) { @@ -1062,7 +1093,7 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem, int pos) GdkModifierType accel_mods; wxCharBuffer buf = wxGTK_CONV( GetGtkHotKey(*mitem) ); - // wxPrintf( wxT("item: %s hotkey %s\n"), mitem->GetText().c_str(), GetGtkHotKey(*mitem).c_str() ); + // wxPrintf( wxT("item: %s hotkey %s\n"), mitem->GetItemLabel().c_str(), GetGtkHotKey(*mitem).c_str() ); gtk_accelerator_parse( (const char*) buf, &accel_key, &accel_mods); if (accel_key != 0) { diff --git a/src/mac/carbon/menu.cpp b/src/mac/carbon/menu.cpp index b790e19ccf..a4d7e57fb3 100644 --- a/src/mac/carbon/menu.cpp +++ b/src/mac/carbon/menu.cpp @@ -852,7 +852,7 @@ bool wxMenuBar::Enable(bool enable) return true; } -void wxMenuBar::SetLabelTop(size_t pos, const wxString& label) +void wxMenuBar::SetMenuLabel(size_t pos, const wxString& label) { wxCHECK_RET( pos < GetMenuCount(), wxT("invalid menu index") ); @@ -870,10 +870,10 @@ void wxMenuBar::SetLabelTop(size_t pos, const wxString& label) } } -wxString wxMenuBar::GetLabelTop(size_t pos) const +wxString wxMenuBar::GetMenuLabel(size_t pos) const { wxCHECK_MSG( pos < GetMenuCount(), wxEmptyString, - wxT("invalid menu index in wxMenuBar::GetLabelTop") ); + wxT("invalid menu index in wxMenuBar::GetMenuLabel") ); return m_titles[pos]; } diff --git a/src/mac/carbon/menuitem.cpp b/src/mac/carbon/menuitem.cpp index 7d6dc48db1..0d8d3d589c 100644 --- a/src/mac/carbon/menuitem.cpp +++ b/src/mac/carbon/menuitem.cpp @@ -233,13 +233,13 @@ void wxMenuItem::Check(bool bDoCheck) } } -void wxMenuItem::SetText(const wxString& text) +void wxMenuItem::SetItemLabel(const wxString& text) { // don't do anything if label didn't change if ( m_text == text ) return; - wxMenuItemBase::SetText(text); + wxMenuItemBase::SetItemLabel(text); UpdateItemText() ; } @@ -273,7 +273,7 @@ void wxMenuItem::SetRadioGroupEnd(int end) // ---------------------------------------------------------------------------- /* static */ -wxString wxMenuItemBase::GetLabelFromText(const wxString& text) +wxString wxMenuItemBase::GetLabelText(const wxString& text) { return wxStripMenuCodes(text); } diff --git a/src/motif/menu.cpp b/src/motif/menu.cpp index 00637cc3b8..be5776e4c0 100644 --- a/src/motif/menu.cpp +++ b/src/motif/menu.cpp @@ -221,7 +221,7 @@ void wxMenuBar::EnableTop(size_t WXUNUSED(pos), bool WXUNUSED(flag)) // wxLogWarning("wxMenuBar::EnableTop not yet implemented."); } -void wxMenuBar::SetLabelTop(size_t pos, const wxString& label) +void wxMenuBar::SetMenuLabel(size_t pos, const wxString& label) { wxMenu *menu = GetMenu(pos); if ( !menu ) @@ -236,26 +236,14 @@ void wxMenuBar::SetLabelTop(size_t pos, const wxString& label) XmNlabelString, label_str(), NULL); } + m_titles[i] = label; } -wxString wxMenuBar::GetLabelTop(size_t pos) const +wxString wxMenuBar::GetMenuLabel(size_t pos) const { - wxMenu *menu = GetMenu(pos); - if ( menu ) - { - Widget w = (Widget)menu->GetButtonWidget(); - if (w) - { - XmString text; - XtVaGetValues(w, - XmNlabelString, &text, - NULL); - - return wxXmStringToString( text ); - } - } - - return wxEmptyString; + wxCHECK_MSG( pos < GetMenuCount(), wxEmptyString, + wxT("invalid menu index in wxMenuBar::GetMenuLabel") ); + return m_titles[pos]; } bool wxMenuBar::Append(wxMenu * menu, const wxString& title) diff --git a/src/motif/menuitem.cpp b/src/motif/menuitem.cpp index 2b57e57d6a..6ac3fba445 100644 --- a/src/motif/menuitem.cpp +++ b/src/motif/menuitem.cpp @@ -137,7 +137,7 @@ void wxMenuItem::Check(bool bDoCheck) } /* static */ -wxString wxMenuItemBase::GetLabelFromText(const wxString& text) +wxString wxMenuItemBase::GetLabelText(const wxString& text) { return wxStripMenuCodes(text); } @@ -308,7 +308,7 @@ void wxMenuItem::DestroyItem(bool full) } } -void wxMenuItem::SetText(const wxString& label) +void wxMenuItem::SetItemLabel(const wxString& label) { char mnem = wxFindMnemonic (label); wxString label2 = wxStripMenuCodes(label); diff --git a/src/msw/frame.cpp b/src/msw/frame.cpp index 2701eb8ad2..cbd908ce5a 100644 --- a/src/msw/frame.cpp +++ b/src/msw/frame.cpp @@ -398,7 +398,7 @@ void wxFrame::AttachMenuBar(wxMenuBar *menubar) if( menubar->GetMenuCount() == 1 ) { autoMenu = wxTopLevelWindowMSW::ButtonMenu::DuplicateMenu(menubar->GetMenu(0)); - SetRightMenu(wxID_ANY, menubar->GetLabelTop(0), autoMenu); + SetRightMenu(wxID_ANY, menubar->GetMenuLabel(0), autoMenu); } else { @@ -407,7 +407,7 @@ void wxFrame::AttachMenuBar(wxMenuBar *menubar) for( size_t n = 0; n < menubar->GetMenuCount(); n++ ) { wxMenu *item = menubar->GetMenu(n); - wxString label = menubar->GetLabelTop(n); + wxString label = menubar->GetMenuLabel(n); wxMenu *new_item = wxTopLevelWindowMSW::ButtonMenu::DuplicateMenu(item); autoMenu->Append(wxID_ANY, label, new_item); } diff --git a/src/msw/menu.cpp b/src/msw/menu.cpp index f883a23128..915992cf08 100644 --- a/src/msw/menu.cpp +++ b/src/msw/menu.cpp @@ -227,7 +227,7 @@ const wxMenuInfoList& wxMenuBar::GetMenuInfos() const for( size_t i = 0 ; i < GetMenuCount() ; ++i ) { wxMenuInfo* info = new wxMenuInfo() ; - info->Create( const_cast(this)->GetMenu(i) , GetLabelTop(i) ) ; + info->Create( const_cast(this)->GetMenu(i) , GetMenuLabel(i) ) ; list->Append( info ) ; } return m_menuInfos ; @@ -331,7 +331,7 @@ void wxMenu::UpdateAccel(wxMenuItem *item) } // find the (new) accel for this item - wxAcceleratorEntry *accel = wxAcceleratorEntry::Create(item->GetText()); + wxAcceleratorEntry *accel = wxAcceleratorEntry::Create(item->GetItemLabel()); if ( accel ) accel->m_command = item->GetId(); @@ -404,7 +404,7 @@ bool wxMenu::DoInsertOrAppend(wxMenuItem *pItem, size_t pos) // prepare to insert the item in the menu - wxString itemText = pItem->GetText(); + wxString itemText = pItem->GetItemLabel(); LPCTSTR pData = NULL; if ( pos == (size_t)-1 ) { @@ -545,7 +545,7 @@ bool wxMenu::DoInsertOrAppend(wxMenuItem *pItem, size_t pos) flags |= MF_STRING; #ifdef __WXWINCE__ - itemText = wxMenuItem::GetLabelFromText(itemText); + itemText = wxMenuItem::GetLabelText(itemText); #endif pData = (wxChar*)itemText.wx_str(); @@ -949,7 +949,7 @@ WXHMENU wxMenuBar::Create() { HMENU hPopupMenu = (HMENU) GetMenu(i)->GetHMenu(); tbButton.dwData = (DWORD)hPopupMenu; - wxString label = wxStripMenuCodes(GetLabelTop(i)); + wxString label = wxStripMenuCodes(GetMenuLabel(i)); tbButton.iString = (int) label.wx_str(); tbButton.idCommand = NewControlId(); @@ -1036,7 +1036,7 @@ void wxMenuBar::EnableTop(size_t pos, bool enable) Refresh(); } -void wxMenuBar::SetLabelTop(size_t pos, const wxString& label) +void wxMenuBar::SetMenuLabel(size_t pos, const wxString& label) { wxCHECK_RET( pos < GetMenuCount(), wxT("invalid menu index") ); @@ -1094,12 +1094,12 @@ void wxMenuBar::SetLabelTop(size_t pos, const wxString& label) Refresh(); } -wxString wxMenuBar::GetLabelTop(size_t pos) const +wxString wxMenuBar::GetMenuLabel(size_t pos) const { wxCHECK_MSG( pos < GetMenuCount(), wxEmptyString, - wxT("invalid menu index in wxMenuBar::GetLabelTop") ); + wxT("invalid menu index in wxMenuBar::GetMenuLabel") ); - return wxMenuItem::GetLabelFromText(m_titles[pos]); + return m_titles[pos]; } // --------------------------------------------------------------------------- diff --git a/src/msw/menuitem.cpp b/src/msw/menuitem.cpp index 91a7d41211..2398a129a5 100644 --- a/src/msw/menuitem.cpp +++ b/src/msw/menuitem.cpp @@ -207,7 +207,7 @@ bool wxMenuItem::IsChecked() const } /* static */ -wxString wxMenuItemBase::GetLabelFromText(const wxString& text) +wxString wxMenuItemBase::GetLabelText(const wxString& text) { return wxStripMenuCodes(text); } @@ -337,7 +337,7 @@ void wxMenuItem::Check(bool check) wxMenuItemBase::Check(check); } -void wxMenuItem::SetText(const wxString& txt) +void wxMenuItem::SetItemLabel(const wxString& txt) { wxString text = txt; @@ -346,7 +346,7 @@ void wxMenuItem::SetText(const wxString& txt) return; // wxMenuItemBase will do stock ID checks - wxMenuItemBase::SetText(text); + wxMenuItemBase::SetItemLabel(text); // m_text could now be different from 'text' if we are a stock menu item, // so use only m_text below diff --git a/src/os2/menu.cpp b/src/os2/menu.cpp index 7f693d4d2d..573611a005 100644 --- a/src/os2/menu.cpp +++ b/src/os2/menu.cpp @@ -847,7 +847,7 @@ void wxMenuBar::EnableTop( Refresh(); } // end of wxMenuBar::EnableTop -void wxMenuBar::SetLabelTop( +void wxMenuBar::SetMenuLabel( size_t nPos , const wxString& rLabel ) @@ -884,16 +884,16 @@ void wxMenuBar::SetLabelTop( wxLogLastError(wxT("ModifyMenu")); } Refresh(); -} // end of wxMenuBar::SetLabelTop +} // end of wxMenuBar::SetMenuLabel -wxString wxMenuBar::GetLabelTop( +wxString wxMenuBar::GetMenuLabel( size_t nPos ) const { wxCHECK_MSG( nPos < GetMenuCount(), wxEmptyString, - wxT("invalid menu index in wxMenuBar::GetLabelTop") ); + wxT("invalid menu index in wxMenuBar::GetMenuLabel") ); return m_titles[nPos]; -} // end of wxMenuBar::GetLabelTop +} // end of wxMenuBar::GetMenuLabel // --------------------------------------------------------------------------- // wxMenuBar construction diff --git a/src/os2/menuitem.cpp b/src/os2/menuitem.cpp index 921cfd2cbe..193a679348 100644 --- a/src/os2/menuitem.cpp +++ b/src/os2/menuitem.cpp @@ -180,7 +180,7 @@ bool wxMenuItem::IsChecked() const return (uFlag & MIA_CHECKED) == MIA_CHECKED ; } // end of wxMenuItem::IsChecked -wxString wxMenuItemBase::GetLabelFromText( +wxString wxMenuItemBase::GetLabelText( const wxString& rsText ) { @@ -199,7 +199,7 @@ wxString wxMenuItemBase::GetLabelFromText( sLabel += *zPc; } return sLabel; -} // end of wxMenuItemBase::GetLabelFromText +} // end of wxMenuItemBase::GetLabelText // // Radio group stuff @@ -363,7 +363,7 @@ void wxMenuItem::Check( wxMenuItemBase::Check(bCheck); } // end of wxMenuItem::Check -void wxMenuItem::SetText( const wxString& rText ) +void wxMenuItem::SetItemLabel( const wxString& rText ) { // // Don't do anything if label didn't change @@ -374,7 +374,7 @@ void wxMenuItem::SetText( const wxString& rText ) return; // wxMenuItemBase will do stock ID checks - wxMenuItemBase::SetText(sText); + wxMenuItemBase::SetItemLabel(sText); // m_text could now be different from 'text' if we are a stock menu item, // so use only m_text below diff --git a/src/palmos/menu.cpp b/src/palmos/menu.cpp index 7274757921..05adc26c67 100644 --- a/src/palmos/menu.cpp +++ b/src/palmos/menu.cpp @@ -152,7 +152,7 @@ const wxMenuInfoList& wxMenuBar::GetMenuInfos() const for( size_t i = 0 ; i < GetMenuCount() ; ++i ) { wxMenuInfo* info = new wxMenuInfo() ; - info->Create( const_cast(this)->GetMenu(i) , GetLabelTop(i) ) ; + info->Create( const_cast(this)->GetMenu(i) , GetMenuLabel(i) ) ; list->Append( info ) ; } return m_menuInfos ; @@ -372,11 +372,11 @@ void wxMenuBar::EnableTop(size_t pos, bool enable) // Palm OS does not have support for grayed or disabled items } -void wxMenuBar::SetLabelTop(size_t pos, const wxString& label) +void wxMenuBar::SetMenuLabel(size_t pos, const wxString& label) { wxCHECK_RET( pos < GetMenuCount(), wxT("invalid menu index") ); - m_titles[pos]=wxStripMenuCodes(label); + m_titles[pos] = label; if ( !IsAttached() ) { @@ -387,12 +387,12 @@ void wxMenuBar::SetLabelTop(size_t pos, const wxString& label) Refresh(); } -wxString wxMenuBar::GetLabelTop(size_t pos) const +wxString wxMenuBar::GetMenuLabel(size_t pos) const { wxCHECK_MSG( pos < GetMenuCount(), wxEmptyString, - wxT("invalid menu index in wxMenuBar::GetLabelTop") ); + wxT("invalid menu index in wxMenuBar::GetMenuLabel") ); - return wxMenuItem::GetLabelFromText(m_titles[pos]); + return m_titles[pos]; } // --------------------------------------------------------------------------- @@ -405,7 +405,7 @@ wxMenu *wxMenuBar::Replace(size_t pos, wxMenu *menu, const wxString& title) if ( !menuOld ) return NULL; - m_titles[pos]=wxStripMenuCodes(title); + m_titles[pos] = title; if ( IsAttached() ) { @@ -421,7 +421,7 @@ bool wxMenuBar::Insert(size_t pos, wxMenu *menu, const wxString& title) if ( !wxMenuBarBase::Insert(pos, menu, title) ) return false; - m_titles.Insert(wxStripMenuCodes(title), pos); + m_titles.Insert(title, pos); if ( IsAttached() ) { @@ -437,7 +437,7 @@ bool wxMenuBar::Append(wxMenu *menu, const wxString& title) if ( !wxMenuBarBase::Append(menu, title) ) return false; - m_titles.Add(wxStripMenuCodes(title)); + m_titles.Add(title); if(IsAttached()) { diff --git a/src/palmos/menuitem.cpp b/src/palmos/menuitem.cpp index 23d967875c..a491c36a86 100644 --- a/src/palmos/menuitem.cpp +++ b/src/palmos/menuitem.cpp @@ -159,7 +159,7 @@ bool wxMenuItem::IsChecked() const } /* static */ -wxString wxMenuItemBase::GetLabelFromText(const wxString& text) +wxString wxMenuItemBase::GetLabelText(const wxString& text) { return wxStripMenuCodes(text); } @@ -190,7 +190,7 @@ void wxMenuItem::Check(bool check) { } -void wxMenuItem::SetText(const wxString& text) +void wxMenuItem::SetItemLabel(const wxString& text) { } diff --git a/src/univ/menu.cpp b/src/univ/menu.cpp index 2d3fa88a55..4db54a095a 100644 --- a/src/univ/menu.cpp +++ b/src/univ/menu.cpp @@ -1516,7 +1516,7 @@ wxMenuItem *wxMenuItemBase::New(wxMenu *parentMenu, } /* static */ -wxString wxMenuItemBase::GetLabelFromText(const wxString& text) +wxString wxMenuItemBase::GetLabelText(const wxString& text) { return wxStripMenuCodes(text); } @@ -1538,13 +1538,13 @@ void wxMenuItem::UpdateAccelInfo() m_strAccel = m_text.AfterFirst(_T('\t')); } -void wxMenuItem::SetText(const wxString& text) +void wxMenuItem::SetItemLabel(const wxString& text) { if ( text != m_text ) { // first call the base class version to change m_text // (and also check if we don't have a stock menu item) - wxMenuItemBase::SetText(text); + wxMenuItemBase::SetItemLabel(text); UpdateAccelInfo(); @@ -1820,9 +1820,9 @@ bool wxMenuBar::IsEnabledTop(size_t pos) const return m_menuInfos[pos].IsEnabled(); } -void wxMenuBar::SetLabelTop(size_t pos, const wxString& label) +void wxMenuBar::SetMenuLabel(size_t pos, const wxString& label) { - wxCHECK_RET( pos < GetCount(), _T("invalid index in EnableTop") ); + wxCHECK_RET( pos < GetCount(), _T("invalid index in SetMenuLabel") ); if ( label != m_menuInfos[pos].GetLabel() ) { @@ -1833,9 +1833,9 @@ void wxMenuBar::SetLabelTop(size_t pos, const wxString& label) //else: nothing to do } -wxString wxMenuBar::GetLabelTop(size_t pos) const +wxString wxMenuBar::GetMenuLabel(size_t pos) const { - wxCHECK_MSG( pos < GetCount(), wxEmptyString, _T("invalid index in GetLabelTop") ); + wxCHECK_MSG( pos < GetCount(), wxEmptyString, _T("invalid index in GetMenuLabel") ); return m_menuInfos[pos].GetLabel(); } @@ -1960,7 +1960,7 @@ wxSize wxMenuBar::DoGetBestClientSize() const { wxClientDC dc(wxConstCast(this, wxMenuBar)); dc.SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT)); - dc.GetTextExtent(GetLabelTop(0), &size.x, &size.y); + dc.GetTextExtent(GetMenuLabel(0), &size.x, &size.y); // adjust for the renderer we use size = GetRenderer()->GetMenuBarItemSize(size);