]> git.saurik.com Git - wxWidgets.git/commitdiff
wxMenuItem::GetLabelFromText() added/documented, bug in wxMenu::FindItem() fixed
authorVadim Zeitlin <vadim@wxwidgets.org>
Tue, 11 Jan 2000 13:58:41 +0000 (13:58 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Tue, 11 Jan 2000 13:58:41 +0000 (13:58 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5339 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

12 files changed:
docs/latex/wx/menuitem.tex
include/wx/app.h
include/wx/gtk/menuitem.h
include/wx/gtk1/menuitem.h
include/wx/menuitem.h
include/wx/motif/menuitem.h
include/wx/msw/menuitem.h
src/common/menucmn.cpp
src/gtk/menu.cpp
src/gtk1/menu.cpp
src/motif/menuitem.cpp
src/msw/menuitem.cpp

index 0d46f86854c264555514f0936095dcfb83e788ff..f224111716eaf4bb9b61a0bd01702a4e03b75304 100644 (file)
@@ -104,7 +104,26 @@ characaters it might contain.
 
 \wxheading{See also}
 
-\helpref{GetText}{wxmenuitemgettext}
+\helpref{GetText}{wxmenuitemgettext},
+\helpref{GetLabelFromText}{wxmenuitemgetlabelfromtext}
+
+\membersection{wxMenuItem::GetLabelFromText}\label{wxmenuitemgetlabelfromtext}
+
+\func{static wxString}{GetLabelFromText}{\param{const wxString\& }{text}}
+
+Strips all accelerator characeters and mnemonics from the given {\it text}.
+For example,
+
+\begin{verbatim}
+wxMenuItem::GetLabelFromText("&Hello\tCtrl-H");
+\end{verbatim}
+
+will return just {\tt "Hello"}.
+
+\wxheading{See also}
+
+\helpref{GetText}{wxmenuitemgettext},
+\helpref{GetLabel}{wxmenuitemgetlabel}
 
 \membersection{wxMenuItem::GetMarginWidth}\label{wxmenuitemgetmarginwidth}
 
@@ -131,7 +150,8 @@ wxMenuItem constructor, i.e. with any accelerator characters it may contain.
 
 \wxheading{See also}
 
-\helpref{GetLabel}{wxmenuitemgetlabel}
+\helpref{GetLabel}{wxmenuitemgetlabel},
+\helpref{GetLabelFromText}{wxmenuitemgetlabelfromtext}
 
 \membersection{wxMenuItem::GetSubMenu}\label{wxmenuitemgetsubmenu}
 
index 559fdebc4f59e468c53746cb0349fe90ab8756af..7d408278bbf3a046f13cb6fa3474461b18e9dcd4 100644 (file)
@@ -369,11 +369,7 @@ public:
 #elif defined(__WXMSW__) && defined(WXUSINGDLL)
     // NT defines APIENTRY, 3.x not
     #if !defined(WXAPIENTRY)
-        #ifdef __WATCOMC__
-            #define WXAPIENTRY PASCAL
-        #else
-            #define WXAPIENTRY FAR PASCAL
-        #endif
+        #define WXAPIENTRY FAR wxSTDCALL
     #endif
 
     #define IMPLEMENT_WXWIN_MAIN \
index ba846a4b9c43f1940541494c3f24458c21bff95d..54d91d04f1b79ab38fe1f2672c48abc00a9875dc 100644 (file)
@@ -31,7 +31,6 @@ public:
 
     // implement base class virtuals
     virtual void SetText( const wxString& str );
-    virtual wxString GetLabel() const;
     virtual void Enable( bool enable = TRUE );
     virtual void Check( bool check = TRUE );
     virtual bool IsChecked() const;
index ba846a4b9c43f1940541494c3f24458c21bff95d..54d91d04f1b79ab38fe1f2672c48abc00a9875dc 100644 (file)
@@ -31,7 +31,6 @@ public:
 
     // implement base class virtuals
     virtual void SetText( const wxString& str );
-    virtual wxString GetLabel() const;
     virtual void Enable( bool enable = TRUE );
     virtual void Check( bool check = TRUE );
     virtual bool IsChecked() const;
index b80497652208d9d3559f3d1212205120c690fa8a..20f143ed225d02cfd17a37e8fd659d99d711f435 100644 (file)
@@ -34,7 +34,6 @@ class WXDLLEXPORT wxMenu;
 class WXDLLEXPORT wxMenuItemBase : public wxObject
 {
 public:
-
     // creation
     static wxMenuItem *New(wxMenu *parentMenu = (wxMenu *)NULL,
                            int id = wxID_SEPARATOR,
@@ -61,9 +60,12 @@ public:
     //     different from the item's label which only contains the text shown
     //     in the menu
     virtual void SetText(const wxString& str) { m_text = str; }
-    virtual wxString GetLabel() const { return m_text; }
+    wxString GetLabel() const { return GetLabelFromText(m_text); }
     const wxString& GetText() const { return m_text; }
 
+    // get the label from text (implemented in platform-specific code)
+    static wxString GetLabelFromText(const wxString& text);
+
     // what kind of menu item we are
     virtual void SetCheckable(bool checkable) { m_isCheckable = checkable; }
     bool IsCheckable() const { return m_isCheckable; }
@@ -107,9 +109,8 @@ protected:
     bool          m_isChecked;      // is checked?
     bool          m_isEnabled;      // is enabled?
 
-    // some compilers need a default constructor here, do not use
-    wxMenuItemBase() 
-        { }
+    // some compilers need a default constructor here, do not remove
+    wxMenuItemBase() { }
 };
 
 // ----------------------------------------------------------------------------
index 4822d8013c36d1fc1afd63cd8014ed1aa3d7772c..d2c865aa66c2d5869041104224155369d73ff155 100644 (file)
@@ -2,7 +2,7 @@
 // Name:        menuitem.h
 // Purpose:     wxMenuItem class
 // Author:      Vadim Zeitlin
-// Modified by: 
+// Modified by:
 // Created:     11.11.97
 // RCS-ID:      $Id$
 // Copyright:   (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
@@ -36,7 +36,6 @@ public:
 
     // accessors (some more are inherited from wxOwnerDrawn or are below)
     virtual void SetText(const wxString& label);
-    virtual wxString GetLabel() const;
     virtual void Enable(bool enable = TRUE);
     virtual void Check(bool check = TRUE);
 
index df414512df7b430b72e3bf3dc9be2752a920943b..1be7c53921ee2999ed88a4b83ef1629730042a87 100644 (file)
@@ -45,7 +45,6 @@ public:
 
     // override base class virtuals
     virtual void SetText(const wxString& strName);
-    virtual wxString GetLabel() const;
     virtual void SetCheckable(bool checkable);
 
     virtual void Enable(bool bDoEnable = TRUE);
index 74818ae0a9cf99ed226d2e72146a75b0727f9635..9f16ca8512689404c87394eae0fc8efa143ea81b 100644 (file)
@@ -252,7 +252,7 @@ bool wxMenuBase::DoDestroy(wxMenuItem *item)
 // Finds the item id matching the given string, -1 if not found.
 int wxMenuBase::FindItem(const wxString& text) const
 {
-    wxString label = wxMenuItem(NULL, wxID_SEPARATOR, text).GetLabel();
+    wxString label = wxMenuItem::GetLabelFromText(text);
     for ( wxMenuItemList::Node *node = m_items.GetFirst();
           node;
           node = node->GetNext() )
index 47ac10d93f9ab58fc6276b86de624b85eac0d87f..daff7c92be69433d65cd5e75d86d55112f25b8f9 100644 (file)
@@ -625,11 +625,12 @@ wxMenuItem::~wxMenuItem()
 }
 
 // return the menu item text without any menu accels
-wxString wxMenuItem::GetLabel() const
+/* static */
+wxString wxMenuItemBase::GetLabelFromText(const wxString& text)
 {
     wxString label;
 #if (GTK_MINOR_VERSION > 0)
-    for ( const wxChar *pc = m_text.c_str(); *pc; pc++ )
+    for ( const wxChar *pc = text.c_str(); *pc; pc++ )
     {
         if ( *pc == wxT('_') )
         {
@@ -640,7 +641,7 @@ wxString wxMenuItem::GetLabel() const
         label += *pc;
     }
 #else // GTK+ 1.0
-    label = m_text;
+    label = text;
 #endif // GTK+ 1.2/1.0
 
     return label;
index 47ac10d93f9ab58fc6276b86de624b85eac0d87f..daff7c92be69433d65cd5e75d86d55112f25b8f9 100644 (file)
@@ -625,11 +625,12 @@ wxMenuItem::~wxMenuItem()
 }
 
 // return the menu item text without any menu accels
-wxString wxMenuItem::GetLabel() const
+/* static */
+wxString wxMenuItemBase::GetLabelFromText(const wxString& text)
 {
     wxString label;
 #if (GTK_MINOR_VERSION > 0)
-    for ( const wxChar *pc = m_text.c_str(); *pc; pc++ )
+    for ( const wxChar *pc = text.c_str(); *pc; pc++ )
     {
         if ( *pc == wxT('_') )
         {
@@ -640,7 +641,7 @@ wxString wxMenuItem::GetLabel() const
         label += *pc;
     }
 #else // GTK+ 1.0
-    label = m_text;
+    label = text;
 #endif // GTK+ 1.2/1.0
 
     return label;
index deaad78a6fc565fdc6e90d9b7e93cbdd3593e85f..e07a652c5888336c74c344d2ca4b19d0d9da7e22 100644 (file)
@@ -154,12 +154,12 @@ void wxMenuItem::Check(bool bDoCheck)
     }
 }
 
-wxString wxMenuItem::GetLabel() const
+/* static */
+wxString wxMenuItemBase::GetLabelFromText(const wxString& text)
 {
     return wxStripMenuCodes(m_text);
 }
 
-
 // ----------------------------------------------------------------------------
 // wxMenuItemBase
 // ----------------------------------------------------------------------------
index 9b6dbe9b52d18e3d126a1a222d0dc3488229728e..1c0fa7137aa91451c64b2d4db0181094de9d63da 100644 (file)
@@ -141,7 +141,8 @@ bool wxMenuItem::IsChecked() const
     return (flag & MF_CHECKED) != 0;
 }
 
-wxString wxMenuItem::GetLabel() const
+/* static */
+wxString wxMenuItemBase::GetLabelFromText(const wxString& text)
 {
     return wxStripMenuCodes(m_text);
 }