wxMenuItem::GetLabelFromText() added/documented, bug in wxMenu::FindItem() fixed
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5339 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
ba2d860554
commit
3b59cdbfaf
@ -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}
|
||||
|
||||
|
@ -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 \
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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() { }
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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() )
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user