Menu label consistency changes
authorJulian Smart <julian@anthemion.co.uk>
Sat, 11 Aug 2007 17:54:59 +0000 (17:54 +0000)
committerJulian Smart <julian@anthemion.co.uk>
Sat, 11 Aug 2007 17:54:59 +0000 (17:54 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@48023 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

39 files changed:
include/wx/cocoa/menu.h
include/wx/cocoa/menuitem.h
include/wx/gtk/menu.h
include/wx/gtk/menuitem.h
include/wx/gtk1/menu.h
include/wx/gtk1/menuitem.h
include/wx/mac/carbon/menu.h
include/wx/mac/carbon/menuitem.h
include/wx/menu.h
include/wx/menuitem.h
include/wx/motif/menu.h
include/wx/motif/menuitem.h
include/wx/msw/menu.h
include/wx/msw/menuitem.h
include/wx/os2/menu.h
include/wx/os2/menuitem.h
include/wx/palmos/menu.h
include/wx/palmos/menuitem.h
include/wx/univ/menu.h
include/wx/univ/menuitem.h
samples/menu/menu.cpp
src/cocoa/menu.mm
src/cocoa/menuitem.mm
src/common/menucmn.cpp
src/common/utilscmn.cpp
src/gtk/menu.cpp
src/gtk1/menu.cpp
src/mac/carbon/menu.cpp
src/mac/carbon/menuitem.cpp
src/motif/menu.cpp
src/motif/menuitem.cpp
src/msw/frame.cpp
src/msw/menu.cpp
src/msw/menuitem.cpp
src/os2/menu.cpp
src/os2/menuitem.cpp
src/palmos/menu.cpp
src/palmos/menuitem.cpp
src/univ/menu.cpp

index 479afe083b396222f1e104285ddb49b1da41d2b5..a2f4fc75bf10f121bff742f6b1219c323f90b9b2 100644 (file)
@@ -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();
index d5ba585ac620a5422cd0fbf56d39c52d402ddaf9..f0e7d137d1a1341841ca1332a5021003ba62bbdf 100644 (file)
@@ -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);
index ba4c245a9d8c1480f284bf0a45a72a9d88492b6a..eda3f5a5b16c6f67654afc84d5280afd4c5eb12f 100644 (file)
@@ -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;
index 7ac723e239f6ab9899bb6898ff9fc8479689389a..4133cc5e834f7804e7fb55940c0fa729fe613837 100644 (file)
@@ -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__
index f2aef5abb501149e01f75ae202e8e215d95ec9c1..32136bdd096e18c12f292e3a5c994f93d7a72051 100644 (file)
@@ -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 );
index 565cb5620d55f2fbd192b4643b5988461ee96245..827cf6e780195e9ba66677f5d1afba51bbe92d78 100644 (file)
@@ -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__
index 5fda6b8f6a1529f616f01207e0cfded6f6d175d2..634ee2fe87be341b618a7c684532e2a9b7f7b875 100644 (file)
@@ -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 )
index 7f89ee9420701270336942b5bf73e660ce7ce1ce..a5b087cb5aaea22aed6f3bc07091bbd5551666f2 100644 (file)
@@ -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);
index 852b6eac201d4e5c35e5285030d3654e8cc70630..0de4fb3eef4576bf60ca1d3d680fa72e1e255d06 100644 (file)
@@ -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
 // ----------------------------------------------------------------------------
index bc9d0bee0f254ef2d85b2394dce8cbf72a17aca2..75b2dcff3d7a44c40b88f52f968d3ce817e1e859 100644 (file)
@@ -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
 
 // ----------------------------------------------------------------------------
index 22ed6b55a0185204957803d8c54ae5030ea9332f..a48c219af04a68b37b6e250f6ae108bde42ba8d3 100644 (file)
@@ -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
     // -------------------------------
index 7df8dd2e4e1cc9fcb1389aaa9b205a3ed3807285..e8b114573a66bcfaf1a3e764336aa57f25112d49 100644 (file)
@@ -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
index fde736405352f96b9bb30886639bffbfad1b6cff..18ab994c8f325c691d6c9eb67244001d8a9c5631 100644 (file)
@@ -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();
index 3b9d7875d3855259e55599614864992916a80646..6c6f5885a392d602ad72ab3bb6b9388114223a26 100644 (file)
@@ -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);
index f7edd51be05fd2732d7d12b2bc2acf9337721b94..a4c380faa89fba6574c9601d786f1b4765c65972 100644 (file)
@@ -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
index 1e9d1d89b8bbc1fe2ecb1a8317ad5fb59cc24583..350f8508487f6e10e7314b082acc26cf2fe1f853 100644 (file)
@@ -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);
index 4980b4523cfe6bf7ad8897aba13df5d4fdc7072b..6859d70bbb7bc3ea7504f8fd769ce8ee39846d31 100644 (file)
@@ -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();
index 9954fd3827104116f44d41f961a8391b9f49a970..df01b0092f096c13fa206291c4cb1a9ec3fd5b95 100644 (file)
@@ -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);
index 591df3bd664f053e088d836272eed7c89221e558..6515c41b36631cf77cb3ef9ad61a861b459693ff 100644 (file)
@@ -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();
index da63e3afa0712917fbd2c079e945b93bddc06935..3601bd5fc8ba9b2522e0e3c2ab3711bdc55ec550 100644 (file)
@@ -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
index 4a11c52c36c891068658b9605708f880c9665b7b..a9f4b678373894e3e352843fc2c4c7b970359553 100644 (file)
@@ -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);
         }
     }
 }
index 55e0f3035b114a4dcfac97a530005ae091435712..df0e8612aaedd63ac28c00d9e840765d2d13758f 100644 (file)
@@ -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()];
index e87f6b2aa65cb3fc7fb4f58b94d1d33536352234..81ccdd73a33da719da6534969a37d2ebbadcafd4 100644 (file)
@@ -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();
index 2b65f80845f0bf2a7d25c7483c6bcaf87bf7274c..0c85d548ba9230d618f4317c6ee54388d8d82565 100644 (file)
@@ -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)
index 96b872759342db6c5defab8a45f83ab20f82f7a2..2183825135b782f0c0c035dfcc387e4141518aa2 100644 (file)
@@ -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);
index 97d926f92fbf892fab79a108581c38085c1c77ae..51fa71566cbdfef088f762cfe4b8035b8126d833 100644 (file)
@@ -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);
index ea47b894ec325784450d37b418945ff0d288c126..28436b74844c8689fdebe443e855d947972d742f 100644 (file)
@@ -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
+}
+
+wxString wxMenuItem::GetItemLabel() const
+{
+    return wxConvertFromGTKToWXLabel(m_text);
 }
 
-void wxMenuItem::SetText( const wxString& string )
+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)
     {
index b790e19ccf79caf11302c1294e3bcf7a54a0f53b..a4d7e57fb32da04eb668ab6fe197139d07df9800 100644 (file)
@@ -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];
 }
index 7d6dc48db145f7b975843372a59c170418ac2c0e..0d8d3d589cf7e25c588086909bd1da66544cca35 100644 (file)
@@ -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);
 }
index 00637cc3b87e0f43b673eda95710444da19227c6..be5776e4c086d7ae8bfa4216ea6d0b2951c61293 100644 (file)
@@ -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)
index 2b57e57d6accc64011b89a9b28b69c92c11c87b7..6ac3fba445b1b0886860db55110329341a11a495 100644 (file)
@@ -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);
index 2701eb8ad2c406af685f66c4b6ce854f000c5d8e..cbd908ce5ac7ef3583fb3f82b074f21bd6a5d4c9 100644 (file)
@@ -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);
         }
index f883a23128e251a1baa73add1f2561a34bd23595..915992cf0845e7dd96924aa0eae6b70a231b560d 100644 (file)
@@ -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<wxMenuBar*>(this)->GetMenu(i) , GetLabelTop(i) ) ;
+        info->Create( const_cast<wxMenuBar*>(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];
 }
 
 // ---------------------------------------------------------------------------
index 91a7d4121187c8bb983542179f7581bf587d92ce..2398a129a55c4251a7cd43c79f4629a01cc43444 100644 (file)
@@ -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
index 7f693d4d2ddc4278ab2443a83216f46e4d1597ce..573611a005b335685371b795af6f83bd445215b6 100644 (file)
@@ -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
index 921cfd2cbe4c633f6ce423185c3427aabb62b286..193a679348df0e0fa44aff4b27ff0dff7e314989 100644 (file)
@@ -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
index 727475792103bc3166e0ba14cd60a897758a9725..05adc26c67874fa509963a5eb0fe70be175493d7 100644 (file)
@@ -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<wxMenuBar*>(this)->GetMenu(i) , GetLabelTop(i) ) ;
+        info->Create( const_cast<wxMenuBar*>(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())
     {
index 23d967875c4147fb936a43f128bb35bc77274c90..a491c36a86a0c9b63345714142255c8098d56a9c 100644 (file)
@@ -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)
 {
 }
 
index 2d3fa88a55101453f890433e4a03cf8a24a7f44f..4db54a095a407df3af59443708b704a81e261a19 100644 (file)
@@ -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);