\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}
\wxheading{See also}
-\helpref{GetLabel}{wxmenuitemgetlabel}
+\helpref{GetLabel}{wxmenuitemgetlabel},
+\helpref{GetLabelFromText}{wxmenuitemgetlabelfromtext}
\membersection{wxMenuItem::GetSubMenu}\label{wxmenuitemgetsubmenu}
#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 \
// 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;
// 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;
class WXDLLEXPORT wxMenuItemBase : public wxObject
{
public:
-
// creation
static wxMenuItem *New(wxMenu *parentMenu = (wxMenu *)NULL,
int id = wxID_SEPARATOR,
// 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; }
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() { }
};
// ----------------------------------------------------------------------------
// 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>
// 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);
// 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);
// 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() )
}
// 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('_') )
{
label += *pc;
}
#else // GTK+ 1.0
- label = m_text;
+ label = text;
#endif // GTK+ 1.2/1.0
return label;
}
// 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('_') )
{
label += *pc;
}
#else // GTK+ 1.0
- label = m_text;
+ label = text;
#endif // GTK+ 1.2/1.0
return label;
}
}
-wxString wxMenuItem::GetLabel() const
+/* static */
+wxString wxMenuItemBase::GetLabelFromText(const wxString& text)
{
return wxStripMenuCodes(m_text);
}
-
// ----------------------------------------------------------------------------
// wxMenuItemBase
// ----------------------------------------------------------------------------
return (flag & MF_CHECKED) != 0;
}
-wxString wxMenuItem::GetLabel() const
+/* static */
+wxString wxMenuItemBase::GetLabelFromText(const wxString& text)
{
return wxStripMenuCodes(m_text);
}