Binary compatible API fixes for menu label retrieval with and without

mnemonics/accelerators.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@48053 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
2007-08-13 17:07:01 +00:00
parent 49ab1eb964
commit fb9c1ff9cb
38 changed files with 615 additions and 70 deletions

View File

@@ -108,6 +108,10 @@ All (GUI):
- Fixed wxXPMHandler::SaveFile for images with more than 92 colors. - Fixed wxXPMHandler::SaveFile for images with more than 92 colors.
- Fixed a crash in wxGrid on creation due to OnSize being called too soon. - Fixed a crash in wxGrid on creation due to OnSize being called too soon.
- Added XRC handler for wxPropertySheetDialog (Sander Berents). - Added XRC handler for wxPropertySheetDialog (Sander Berents).
- API consistency fixes: added wxMenuBar::SetMenuLabel, wxMenuBar::GetMenuLabel,
wxMenuBar::GetMenuLabelText, wxMenu::GetLabelText, wxMenuItem::SetItemLabel,
wxMenuItem::GetItemLabel, wxMenuItem::GetItemLabelText, wxMenuItem::GetLabelText.
Retrieval of labels with and without mnemonics/accelerators is now possible.
wxMSW: wxMSW:

View File

@@ -423,7 +423,7 @@ item was not found.
\constfunc{wxString}{GetLabel}{\param{int}{ id}} \constfunc{wxString}{GetLabel}{\param{int}{ id}}
Returns a menu item label. Returns a menu item label, including any mnemonics and accelerators.
\wxheading{Parameters} \wxheading{Parameters}
@@ -435,7 +435,26 @@ The item label, or the empty string if the item was not found.
\wxheading{See also} \wxheading{See also}
\helpref{wxMenu::SetLabel}{wxmenusetlabel} \helpref{wxMenu::GetLabelText}{wxmenugetlabeltext}, \helpref{wxMenu::SetLabel}{wxmenusetlabel}
\membersection{wxMenu::GetLabelText}\label{wxmenugetlabeltext}
\constfunc{wxString}{GetLabelText}{\param{int}{ id}}
Returns a menu item label, without any of the original mnemonics and accelerators.
\wxheading{Parameters}
\docparam{id}{The menu item identifier.}
\wxheading{Return value}
The item label, or the empty string if the item was not found.
\wxheading{See also}
\helpref{wxMenu::GetLabel}{wxmenugetlabel}, \helpref{wxMenu::SetLabel}{wxmenusetlabel}
\membersection{wxMenu::GetMenuItemCount}\label{wxmenugetmenuitemcount} \membersection{wxMenu::GetMenuItemCount}\label{wxmenugetmenuitemcount}
@@ -958,6 +977,8 @@ The menu label, or the empty string if the menu was not found.
Use only after the menubar has been associated with a frame. Use only after the menubar has been associated with a frame.
This function is deprecated in favour of \helpref{GetMenuLabel}{wxmenubargetmenulabel} and \helpref{GetMenuLabelText}{wxmenubargetmenulabeltext}.
\wxheading{See also} \wxheading{See also}
\helpref{wxMenuBar::SetLabelTop}{wxmenubarsetlabeltop} \helpref{wxMenuBar::SetLabelTop}{wxmenubarsetlabeltop}
@@ -977,6 +998,56 @@ Returns the menu at {\it menuIndex} (zero-based).
Returns the number of menus in this menubar. Returns the number of menus in this menubar.
\membersection{wxMenuBar::GetMenuLabel}\label{wxmenubargetmenulabel}
\constfunc{wxString}{GetMenuLabel}{\param{int}{ pos}}
Returns the label of a top-level menu. Note that the returned string
includes the accelerator characters that have been specified in the menu
title string during its construction.
\wxheading{Parameters}
\docparam{pos}{Position of the menu on the menu bar, starting from zero.}
\wxheading{Return value}
The menu label, or the empty string if the menu was not found.
\wxheading{Remarks}
Use only after the menubar has been associated with a frame.
\wxheading{See also}
\helpref{wxMenuBar::GetMenuLabelText}{wxmenubargetmenulabeltext}, \helpref{wxMenuBar::SetMenuLabel}{wxmenubarsetmenulabel}
\membersection{wxMenuBar::GetMenuLabelText}\label{wxmenubargetmenulabeltext}
\constfunc{wxString}{GetMenuLabelText}{\param{int}{ pos}}
Returns the label of a top-level menu. Note that the returned string does not
include any accelerator characters that may have been specified in the menu
title string during its construction.
\wxheading{Parameters}
\docparam{pos}{Position of the menu on the menu bar, starting from zero.}
\wxheading{Return value}
The menu label, or the empty string if the menu was not found.
\wxheading{Remarks}
Use only after the menubar has been associated with a frame.
\wxheading{See also}
\helpref{wxMenuBar::GetMenuLabel}{wxmenubargetmenulabel}, \helpref{wxMenuBar::SetMenuLabel}{wxmenubarsetmenulabel}
\membersection{wxMenuBar::Insert}\label{wxmenubarinsert} \membersection{wxMenuBar::Insert}\label{wxmenubarinsert}
\func{bool}{Insert}{\param{size\_t }{pos}, \param{wxMenu *}{menu}, \param{const wxString\& }{title}} \func{bool}{Insert}{\param{size\_t }{pos}, \param{wxMenu *}{menu}, \param{const wxString\& }{title}}
@@ -1133,7 +1204,30 @@ Sets the label of a top-level menu.
Use only after the menubar has been associated with a frame. Use only after the menubar has been associated with a frame.
This function has been deprecated in favour of \helpref{SetMenuLabel}{wxmenubarsetmenulabel}.
\wxheading{See also} \wxheading{See also}
\helpref{wxMenuBar::GetLabelTop}{wxmenubargetlabeltop} \helpref{wxMenuBar::GetLabelTop}{wxmenubargetlabeltop}
\membersection{wxMenuBar::SetMenuLabel}\label{wxmenubarsetmenulabel}
\func{void}{SetMenuLabel}{\param{int}{ pos}, \param{const wxString\& }{label}}
Sets the label of a top-level menu.
\wxheading{Parameters}
\docparam{pos}{The position of a menu on the menu bar, starting from zero.}
\docparam{label}{The menu label.}
\wxheading{Remarks}
Use only after the menubar has been associated with a frame.
\wxheading{See also}
\helpref{wxMenuBar::GetMenuLabel}{wxmenubargetmenulabel}, \helpref{wxMenuBar::GetMenuLabelText}{wxmenubargetmenulabeltext}

View File

@@ -148,6 +148,31 @@ Returns the help string associated with the menu item.
Returns the menu item identifier. Returns the menu item identifier.
\membersection{wxMenuItem::GetItemLabel}\label{wxmenuitemgetitemlabel}
\constfunc{wxString}{GetItemLabel}{\void}
Returns the text associated with the menu item including any accelerator
characters that were passed to the constructor or SetItemLabel.
\wxheading{See also}
\helpref{GetItemLabelText}{wxmenuitemgetitemlabeltext},
\helpref{GetLabelText}{wxmenuitemgetlabeltext}
\membersection{wxMenuItem::GetItemLabelText}\label{wxmenuitemgetitemlabeltext}
\constfunc{wxString}{GetItemLabelText}{\void}
Returns the text associated with the menu item, without any accelerator
characters.
\wxheading{See also}
\helpref{GetItemLabel}{wxmenuitemgetitemlabel},
\helpref{GetLabelText}{wxmenuitemgetlabeltext}
\membersection{wxMenuItem::GetKind}\label{wxmenuitemgetkind} \membersection{wxMenuItem::GetKind}\label{wxmenuitemgetkind}
@@ -164,12 +189,33 @@ Returns the item kind, one of {\tt wxITEM\_SEPARATOR}, {\tt wxITEM\_NORMAL},
Returns the text associated with the menu item without any accelerator Returns the text associated with the menu item without any accelerator
characters it might contain. characters it might contain.
This function is deprecated in favour of \helpref{GetItemLabelText}{wxmenuitemgetitemlabeltext}.
\wxheading{See also} \wxheading{See also}
\helpref{GetText}{wxmenuitemgettext}, \helpref{GetText}{wxmenuitemgettext},
\helpref{GetLabelFromText}{wxmenuitemgetlabelfromtext} \helpref{GetLabelFromText}{wxmenuitemgetlabelfromtext}
\membersection{wxMenuItem::GetLabelText}\label{wxmenuitemgetlabeltext}
\func{static wxString}{GetLabelText}{\param{const wxString\& }{text}}
Strips all accelerator characters 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{GetItemLabelText}{wxmenuitemgetitemlabeltext},
\helpref{GetItemLabel}{wxmenuitemgetitemlabel}
\membersection{wxMenuItem::GetLabelFromText}\label{wxmenuitemgetlabelfromtext} \membersection{wxMenuItem::GetLabelFromText}\label{wxmenuitemgetlabelfromtext}
\func{static wxString}{GetLabelFromText}{\param{const wxString\& }{text}} \func{static wxString}{GetLabelFromText}{\param{const wxString\& }{text}}
@@ -183,12 +229,13 @@ wxMenuItem::GetLabelFromText("&Hello\tCtrl-H");
will return just {\tt "Hello"}. will return just {\tt "Hello"}.
This function is deprecated; please use \helpref{wxMenuItem::GetLabelText}{wxmenuitemgetlabeltext} instead.
\wxheading{See also} \wxheading{See also}
\helpref{GetText}{wxmenuitemgettext}, \helpref{GetText}{wxmenuitemgettext},
\helpref{GetLabel}{wxmenuitemgetlabel} \helpref{GetLabel}{wxmenuitemgetlabel}
\membersection{wxMenuItem::GetMarginWidth}\label{wxmenuitemgetmarginwidth} \membersection{wxMenuItem::GetMarginWidth}\label{wxmenuitemgetmarginwidth}
\constfunc{int}{GetMarginWidth}{\void} \constfunc{int}{GetMarginWidth}{\void}
@@ -221,6 +268,8 @@ instead.
Returns the text associated with the menu item, such as it was passed to the Returns the text associated with the menu item, such as it was passed to the
wxMenuItem constructor, i.e. with any accelerator characters it may contain. wxMenuItem constructor, i.e. with any accelerator characters it may contain.
This function is deprecated in favour of \helpref{GetItemLabel}{wxmenuitemgetitemlabel}.
\wxheading{See also} \wxheading{See also}
\helpref{GetLabel}{wxmenuitemgetlabel}, \helpref{GetLabel}{wxmenuitemgetlabel},
@@ -314,6 +363,13 @@ Sets the font associated with the menu item (Windows only).
Sets the help string. Sets the help string.
\membersection{wxMenuItem::SetItemLabel}\label{wxmenuitemsetitemlabel}
\func{void}{SetItemLabel}{\param{const wxString\& }{label}}
Sets the label associated with the menu item.
\membersection{wxMenuItem::SetMarginWidth}\label{wxmenuitemsetmarginwidth} \membersection{wxMenuItem::SetMarginWidth}\label{wxmenuitemsetmarginwidth}
\constfunc{void}{SetMarginWidth}{\param{int}{ width}} \constfunc{void}{SetMarginWidth}{\param{int}{ width}}
@@ -341,6 +397,8 @@ Sets the submenu of this menu item.
Sets the text associated with the menu item. Sets the text associated with the menu item.
This function is deprecated in favour of \helpref{SetItemLabel}{wxmenuitemsetitemlabel}.
\membersection{wxMenuItem::SetTextColour}\label{wxmenuitemsettextcolour} \membersection{wxMenuItem::SetTextColour}\label{wxmenuitemsettextcolour}

View File

@@ -4,7 +4,7 @@
// Author: David Elliott // Author: David Elliott
// Modified by: // Modified by:
// Created: 2002/12/09 // Created: 2002/12/09
// RCS-ID: $Id: // RCS-ID: $Id:
// Copyright: (c) 2002 David Elliott // Copyright: (c) 2002 David Elliott
// Licence: wxWindows licence // Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@@ -183,6 +183,14 @@ private:
bool m_shouldShowMenu; bool m_shouldShowMenu;
DECLARE_DYNAMIC_CLASS(wxMenuBar) DECLARE_DYNAMIC_CLASS(wxMenuBar)
public:
#if wxABI_VERSION >= 20805
// Gets the original label at the top-level of the menubar
wxString GetMenuLabel(size_t pos) const;
#endif
}; };
#endif // _WX_COCOA_MENU_H_ #endif // _WX_COCOA_MENU_H_

View File

@@ -4,7 +4,7 @@
// Author: David Elliott // Author: David Elliott
// Modified by: // Modified by:
// Created: 2002/12/13 // Created: 2002/12/13
// RCS-ID: $Id: // RCS-ID: $Id:
// Copyright: (c) 2002 David Elliott // Copyright: (c) 2002 David Elliott
// Licence: wxWindows licence // Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@@ -94,6 +94,14 @@ protected:
private: private:
DECLARE_DYNAMIC_CLASS(wxMenuItem) DECLARE_DYNAMIC_CLASS(wxMenuItem)
public:
#if wxABI_VERSION >= 20805
// return the item label including any mnemonics and accelerators.
// This used to be called GetText.
wxString GetItemLabel() const { return GetText(); }
#endif
}; };
#endif // _WX_COCOA_MENUITEM_H_ #endif // _WX_COCOA_MENUITEM_H_

View File

@@ -57,6 +57,13 @@ private:
void Init(size_t n, wxMenu *menus[], const wxString titles[], long style); void Init(size_t n, wxMenu *menus[], const wxString titles[], long style);
DECLARE_DYNAMIC_CLASS(wxMenuBar) DECLARE_DYNAMIC_CLASS(wxMenuBar)
public:
#if wxABI_VERSION >= 20805
// Gets the original label at the top-level of the menubar
wxString GetMenuLabel(size_t pos) const;
#endif
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------

View File

@@ -75,6 +75,14 @@ private:
GtkWidget* m_labelWidget; // Label widget GtkWidget* m_labelWidget; // Label widget
DECLARE_DYNAMIC_CLASS(wxMenuItem) DECLARE_DYNAMIC_CLASS(wxMenuItem)
public:
#if wxABI_VERSION >= 20805
// return the item label including any mnemonics and accelerators.
// This used to be called GetText.
wxString GetItemLabel() const;
#endif
}; };

View File

@@ -53,6 +53,13 @@ private:
void Init(size_t n, wxMenu *menus[], const wxString titles[], long style); void Init(size_t n, wxMenu *menus[], const wxString titles[], long style);
DECLARE_DYNAMIC_CLASS(wxMenuBar) DECLARE_DYNAMIC_CLASS(wxMenuBar)
public:
#if wxABI_VERSION >= 20805
// Gets the original label at the top-level of the menubar
wxString GetMenuLabel(size_t pos) const;
#endif
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------

View File

@@ -71,6 +71,14 @@ private:
GtkWidget* m_labelWidget; // Label widget GtkWidget* m_labelWidget; // Label widget
DECLARE_DYNAMIC_CLASS(wxMenuItem) DECLARE_DYNAMIC_CLASS(wxMenuItem)
public:
#if wxABI_VERSION >= 20805
// return the item label including any mnemonics and accelerators.
// This used to be called GetText.
wxString GetItemLabel() const;
#endif
}; };

View File

@@ -43,7 +43,7 @@ public:
// implementation only from now on // implementation only from now on
// ------------------------------- // -------------------------------
int MacGetIndexFromId( int id ) ; int MacGetIndexFromId( int id ) ;
int MacGetIndexFromItem( wxMenuItem *pItem ) ; int MacGetIndexFromItem( wxMenuItem *pItem ) ;
void MacEnableMenu( bool bDoEnable ) ; void MacEnableMenu( bool bDoEnable ) ;
// MacOS needs to know about submenus somewhere within this menu // MacOS needs to know about submenus somewhere within this menu
@@ -174,6 +174,13 @@ private:
static wxMenuBar* s_macCommonMenuBar ; static wxMenuBar* s_macCommonMenuBar ;
DECLARE_DYNAMIC_CLASS(wxMenuBar) DECLARE_DYNAMIC_CLASS(wxMenuBar)
public:
#if wxABI_VERSION >= 20805
// Gets the original label at the top-level of the menubar
wxString GetMenuLabel(size_t pos) const;
#endif
}; };
#endif // _WX_MENU_H_ #endif // _WX_MENU_H_

View File

@@ -47,7 +47,7 @@ public:
void UpdateItemBitmap() ; void UpdateItemBitmap() ;
void UpdateItemText() ; void UpdateItemText() ;
void UpdateItemStatus() ; void UpdateItemStatus() ;
void DoUpdateItemBitmap( WXHMENU menu, wxUint16 index) ; void DoUpdateItemBitmap( WXHMENU menu, wxUint16 index) ;
// mark item as belonging to the given radio group // mark item as belonging to the given radio group
@@ -75,6 +75,14 @@ private:
void* m_menu ; // the appropriate menu , may also be a system menu void* m_menu ; // the appropriate menu , may also be a system menu
DECLARE_DYNAMIC_CLASS(wxMenuItem) DECLARE_DYNAMIC_CLASS(wxMenuItem)
public:
#if wxABI_VERSION >= 20805
// return the item label including any mnemonics and accelerators.
// This used to be called GetText.
wxString GetItemLabel() const { return GetText(); }
#endif
}; };
#endif //_MENUITEM_H #endif //_MENUITEM_H

View File

@@ -47,7 +47,7 @@ public:
// implementation only from now on // implementation only from now on
// ------------------------------- // -------------------------------
int MacGetIndexFromId( int id ) ; int MacGetIndexFromId( int id ) ;
int MacGetIndexFromItem( wxMenuItem *pItem ) ; int MacGetIndexFromItem( wxMenuItem *pItem ) ;
void MacEnableMenu( bool bDoEnable ) ; void MacEnableMenu( bool bDoEnable ) ;
// MacOS needs to know about submenus somewhere within this menu // MacOS needs to know about submenus somewhere within this menu
@@ -160,6 +160,13 @@ private:
static wxMenuBar* s_macCommonMenuBar ; static wxMenuBar* s_macCommonMenuBar ;
DECLARE_DYNAMIC_CLASS(wxMenuBar) DECLARE_DYNAMIC_CLASS(wxMenuBar)
public:
#if wxABI_VERSION >= 20805
// Gets the original label at the top-level of the menubar
wxString GetMenuLabel(size_t pos) const;
#endif
}; };
#endif // _WX_MENU_H_ #endif // _WX_MENU_H_

View File

@@ -72,6 +72,14 @@ private:
void* m_menu ; // the appropriate menu , may also be a system menu void* m_menu ; // the appropriate menu , may also be a system menu
DECLARE_DYNAMIC_CLASS(wxMenuItem) DECLARE_DYNAMIC_CLASS(wxMenuItem)
public:
#if wxABI_VERSION >= 20805
// return the item label including any mnemonics and accelerators.
// This used to be called GetText.
wxString GetItemLabel() const;
#endif
}; };
#endif //_MENUITEM_H #endif //_MENUITEM_H

View File

@@ -375,6 +375,14 @@ protected:
static bool ms_locked; static bool ms_locked;
DECLARE_NO_COPY_CLASS(wxMenuBase) DECLARE_NO_COPY_CLASS(wxMenuBase)
public:
#if wxABI_VERSION >= 20805
// Returns the stripped label
wxString GetLabelText(int itemid) const { return wxMenuItem::GetLabelFromText(GetLabel(itemid)); }
#endif
}; };
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -496,6 +504,21 @@ protected:
wxFrame *m_menuBarFrame; wxFrame *m_menuBarFrame;
DECLARE_NO_COPY_CLASS(wxMenuBarBase) DECLARE_NO_COPY_CLASS(wxMenuBarBase)
public:
#if wxABI_VERSION >= 20805
// Replacement for SetLabelTop
void SetMenuLabel(size_t pos, const wxString& label) { SetLabelTop(pos, label); }
// Gets the original label at the top-level of the menubar
// Implemented per port, since we can't have virtual functions in the stable branch.
// wxString GetMenuLabel(size_t pos) const;
// Get the text only, from the label at the top-level of the menubar
wxString GetMenuLabelText(size_t pos) const;
#endif
}; };
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@@ -65,6 +65,7 @@ public:
// different from the item's label which only contains the text shown // different from the item's label which only contains the text shown
// in the menu // in the menu
virtual void SetText(const wxString& str); virtual void SetText(const wxString& str);
wxString GetLabel() const { return GetLabelFromText(m_text); } wxString GetLabel() const { return GetLabelFromText(m_text); }
const wxString& GetText() const { return m_text; } const wxString& GetText() const { return m_text; }
@@ -146,6 +147,26 @@ private:
// declare them ourselves - but don't implement as they shouldn't be used // declare them ourselves - but don't implement as they shouldn't be used
wxMenuItemBase(const wxMenuItemBase& item); wxMenuItemBase(const wxMenuItemBase& item);
wxMenuItemBase& operator=(const wxMenuItemBase& item); wxMenuItemBase& operator=(const wxMenuItemBase& item);
public:
#if wxABI_VERSION >= 20805
// Sets the label. This function replaces SetText.
void SetItemLabel(const wxString& str) { SetText(str); }
// return the item label including any mnemonics and accelerators.
// This used to be called GetText.
// We can't implement this in the base class (no new virtuals in stable branch)
// wxString GetItemLabel() const;
// return just the text of the item label, without any mnemonics
// This used to be called GetLabel.
wxString GetItemLabelText() const { return GetLabelText(m_text); }
// return just the text part of the given label. In 2.9 and up, this is implemented in
// platform-specific code, but is now implemented in terms of GetLabelFromText.
static wxString GetLabelText(const wxString& label);
#endif
}; };
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@@ -170,6 +170,13 @@ public:
wxFont m_font; wxFont m_font;
DECLARE_DYNAMIC_CLASS(wxMenuBar) DECLARE_DYNAMIC_CLASS(wxMenuBar)
public:
#if wxABI_VERSION >= 20805
// Gets the original label at the top-level of the menubar
wxString GetMenuLabel(size_t pos) const;
#endif
}; };
#endif // _WX_MOTIF_MENU_H_ #endif // _WX_MOTIF_MENU_H_

View File

@@ -63,6 +63,15 @@ private:
wxBitmap m_bitmap; // Bitmap for menuitem, if any wxBitmap m_bitmap; // Bitmap for menuitem, if any
DECLARE_DYNAMIC_CLASS(wxMenuItem) DECLARE_DYNAMIC_CLASS(wxMenuItem)
public:
#if wxABI_VERSION >= 20805
// return the item label including any mnemonics and accelerators.
// This used to be called GetText.
wxString GetItemLabel() const { return GetText(); }
#endif
}; };
#endif // _WX_MOTIF_MENUITEM_H #endif // _WX_MOTIF_MENUITEM_H

View File

@@ -229,6 +229,13 @@ protected:
private: private:
DECLARE_DYNAMIC_CLASS_NO_COPY(wxMenuBar) DECLARE_DYNAMIC_CLASS_NO_COPY(wxMenuBar)
public:
#if wxABI_VERSION >= 20805
// Gets the original label at the top-level of the menubar
wxString GetMenuLabel(size_t pos) const;
#endif
}; };
#endif // _WX_MENU_H_ #endif // _WX_MENU_H_

View File

@@ -87,6 +87,14 @@ private:
bool m_isRadioGroupStart; bool m_isRadioGroupStart;
DECLARE_DYNAMIC_CLASS_NO_COPY(wxMenuItem) DECLARE_DYNAMIC_CLASS_NO_COPY(wxMenuItem)
public:
#if wxABI_VERSION >= 20805
// return the item label including any mnemonics and accelerators.
// This used to be called GetText.
wxString GetItemLabel() const { return GetText(); }
#endif
}; };
#endif //_MENUITEM_H #endif //_MENUITEM_H

View File

@@ -287,6 +287,13 @@ private:
{ wxWindow::Refresh(bErase, pRect); } { wxWindow::Refresh(bErase, pRect); }
DECLARE_DYNAMIC_CLASS(wxMenuBar) DECLARE_DYNAMIC_CLASS(wxMenuBar)
public:
#if wxABI_VERSION >= 20805
// Gets the original label at the top-level of the menubar
wxString GetMenuLabel(size_t pos) const;
#endif
}; };
#endif // _WX_MENU_H_ #endif // _WX_MENU_H_

View File

@@ -117,6 +117,15 @@ private:
bool m_bIsRadioGroupStart; bool m_bIsRadioGroupStart;
DECLARE_DYNAMIC_CLASS(wxMenuItem) DECLARE_DYNAMIC_CLASS(wxMenuItem)
public:
#if wxABI_VERSION >= 20805
// return the item label including any mnemonics and accelerators.
// This used to be called GetText.
wxString GetItemLabel() const { return GetText(); }
#endif
}; // end of CLASS wxMenuItem }; // end of CLASS wxMenuItem
#endif //_MENUITEM_H #endif //_MENUITEM_H

View File

@@ -192,6 +192,13 @@ protected:
private: private:
DECLARE_DYNAMIC_CLASS_NO_COPY(wxMenuBar) DECLARE_DYNAMIC_CLASS_NO_COPY(wxMenuBar)
public:
#if wxABI_VERSION >= 20805
// Gets the original label at the top-level of the menubar
wxString GetMenuLabel(size_t pos) const;
#endif
}; };
#endif // _WX_MENU_H_ #endif // _WX_MENU_H_

View File

@@ -82,6 +82,14 @@ private:
bool m_isRadioGroupStart; bool m_isRadioGroupStart;
DECLARE_DYNAMIC_CLASS_NO_COPY(wxMenuItem) DECLARE_DYNAMIC_CLASS_NO_COPY(wxMenuItem)
public:
#if wxABI_VERSION >= 20805
// return the item label including any mnemonics and accelerators.
// This used to be called GetText.
wxString GetItemLabel() const { return GetText(); }
#endif
}; };
#endif //_MENUITEM_H #endif //_MENUITEM_H

View File

@@ -270,6 +270,13 @@ private:
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
DECLARE_DYNAMIC_CLASS(wxMenuBar) DECLARE_DYNAMIC_CLASS(wxMenuBar)
public:
#if wxABI_VERSION >= 20805
// Gets the original label at the top-level of the menubar
wxString GetMenuLabel(size_t pos) const;
#endif
}; };
#endif // _WX_UNIV_MENU_H_ #endif // _WX_UNIV_MENU_H_

View File

@@ -94,7 +94,7 @@ protected:
// the bitmaps (may be invalid, then they're not used) // the bitmaps (may be invalid, then they're not used)
wxBitmap m_bmpChecked, wxBitmap m_bmpChecked,
m_bmpUnchecked, m_bmpUnchecked,
m_bmpDisabled; m_bmpDisabled;
// the positions of the first and last items of the radio group this item // 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 // belongs to or -1: start is the radio group start and is valid for all
@@ -121,6 +121,14 @@ protected:
private: private:
DECLARE_DYNAMIC_CLASS(wxMenuItem) DECLARE_DYNAMIC_CLASS(wxMenuItem)
public:
#if wxABI_VERSION >= 20805
// return the item label including any mnemonics and accelerators.
// This used to be called GetText.
wxString GetItemLabel() const { return GetText(); }
#endif
}; };
#endif // _WX_UNIV_MENUITEM_H_ #endif // _WX_UNIV_MENUITEM_H_

View File

@@ -227,6 +227,13 @@ wxString wxMenuBar::GetLabelTop(size_t pos) const
return wxStringWithNSString([[m_cocoaNSMenu itemAtIndex:itemindex] title]); return wxStringWithNSString([[m_cocoaNSMenu itemAtIndex:itemindex] title]);
} }
// Gets the original label at the top-level of the menubar
wxString wxMenuBar::GetMenuLabel(size_t pos) const
{
// TODO: restore the original mnemonics
return GetLabelTop(pos);
}
void wxMenuBar::Attach(wxFrame *frame) void wxMenuBar::Attach(wxFrame *frame)
{ {
wxMenuBarBase::Attach(frame); wxMenuBarBase::Attach(frame);

View File

@@ -445,6 +445,11 @@ void wxMenuItemBase::SetHelp(const wxString& str)
} }
} }
wxString wxMenuItemBase::GetLabelText(const wxString& label)
{
return GetLabelFromText(label);
}
bool wxMenuBase::ms_locked = true; bool wxMenuBase::ms_locked = true;
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -1152,4 +1157,11 @@ void wxMenuBarBase::UpdateMenus( void )
} }
} }
// Get the text only, from the label
wxString wxMenuBarBase::GetMenuLabelText(size_t pos) const
{
return wxMenuItem::GetLabelText(((wxMenuBar*)this)->GetMenuLabel(pos));
}
#endif // wxUSE_MENUS #endif // wxUSE_MENUS

View File

@@ -91,6 +91,40 @@ static wxString wxReplaceUnderscore( const wxString& title )
return str; 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 // activate message from GTK
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -425,7 +459,7 @@ wxMenu *wxMenuBar::Remove(size_t pos)
static int FindMenuItemRecursive( const wxMenu *menu, const wxString &menuString, const wxString &itemString ) static int FindMenuItemRecursive( const wxMenu *menu, const wxString &menuString, const wxString &itemString )
{ {
if (wxMenuItem::GetLabelFromText(menu->GetTitle()) == wxMenuItem::GetLabelFromText(menuString)) if (wxMenuItem::GetLabelFromText(wxConvertFromGTKToWXLabel(menu->GetTitle())) == wxMenuItem::GetLabelFromText(menuString))
{ {
int res = menu->FindItem( itemString ); int res = menu->FindItem( itemString );
if (res != wxNOT_FOUND) if (res != wxNOT_FOUND)
@@ -518,23 +552,19 @@ wxString wxMenuBar::GetLabelTop( size_t pos ) const
wxMenu* menu = node->GetData(); wxMenu* menu = node->GetData();
wxString label; return wxStripMenuCodes(wxConvertFromGTKToWXLabel(menu->GetTitle()));
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 // Gets the original label at the top-level of the menubar
// it means that they were doubled to indicate "&" instead of accelerator wxString wxMenuBar::GetMenuLabel(size_t pos) const
{
wxMenuList::compatibility_iterator node = m_menus.Item( pos );
label += *pc; wxCHECK_MSG( node, wxT("invalid"), wxT("menu not found") );
}
return label; wxMenu* menu = node->GetData();
return wxConvertFromGTKToWXLabel(menu->GetTitle());
} }
void wxMenuBar::SetLabelTop( size_t pos, const wxString& label ) void wxMenuBar::SetLabelTop( size_t pos, const wxString& label )
@@ -743,6 +773,12 @@ wxMenuItem::~wxMenuItem()
/* static */ /* static */
wxString wxMenuItemBase::GetLabelFromText(const wxString& text) wxString wxMenuItemBase::GetLabelFromText(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; wxString label;
for ( const wxChar *pc = text.c_str(); *pc; pc++ ) for ( const wxChar *pc = text.c_str(); *pc; pc++ )
@@ -779,6 +815,7 @@ wxString wxMenuItemBase::GetLabelFromText(const wxString& text)
// wxPrintf( wxT("GetLabelFromText(): text %s label %s\n"), text.c_str(), label.c_str() ); // wxPrintf( wxT("GetLabelFromText(): text %s label %s\n"), text.c_str(), label.c_str() );
return label; return label;
#endif
} }
void wxMenuItem::SetText( const wxString& str ) void wxMenuItem::SetText( const wxString& str )
@@ -986,6 +1023,14 @@ bool wxMenuItem::IsChecked() const
return ((GtkCheckMenuItem*)m_menuItem)->active != 0; return ((GtkCheckMenuItem*)m_menuItem)->active != 0;
} }
wxString wxMenuItem::GetItemLabel() const
{
wxString label = wxConvertFromGTKToWXLabel(m_text);
if (!m_hotKey.IsEmpty())
label = label + wxT("\t") + m_hotKey;
return label;
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// wxMenu // wxMenu
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------

View File

@@ -91,6 +91,40 @@ static wxString wxReplaceUnderscore( const wxString& title )
return str; 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 // activate message from GTK
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -408,7 +442,7 @@ wxMenu *wxMenuBar::Remove(size_t pos)
static int FindMenuItemRecursive( const wxMenu *menu, const wxString &menuString, const wxString &itemString ) static int FindMenuItemRecursive( const wxMenu *menu, const wxString &menuString, const wxString &itemString )
{ {
if (wxMenuItem::GetLabelFromText(menu->GetTitle()) == wxMenuItem::GetLabelFromText(menuString)) if (wxMenuItem::GetLabelFromText(wxConvertFromGTKToWXLabel(menu->GetTitle())) == wxMenuItem::GetLabelFromText(menuString))
{ {
int res = menu->FindItem( itemString ); int res = menu->FindItem( itemString );
if (res != wxNOT_FOUND) if (res != wxNOT_FOUND)
@@ -501,23 +535,19 @@ wxString wxMenuBar::GetLabelTop( size_t pos ) const
wxMenu* menu = node->GetData(); wxMenu* menu = node->GetData();
wxString label; return wxStripMenuCodes(wxConvertFromGTKToWXLabel(menu->GetTitle()));
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 // Gets the original label at the top-level of the menubar
// it means that they were doubled to indicate "&" instead of accelerator wxString wxMenuBar::GetMenuLabel(size_t pos) const
{
wxMenuList::compatibility_iterator node = m_menus.Item( pos );
label += *pc; wxCHECK_MSG( node, wxT("invalid"), wxT("menu not found") );
}
return label; wxMenu* menu = node->GetData();
return wxConvertFromGTKToWXLabel(menu->GetTitle());
} }
void wxMenuBar::SetLabelTop( size_t pos, const wxString& label ) void wxMenuBar::SetLabelTop( size_t pos, const wxString& label )
@@ -736,6 +766,12 @@ wxMenuItem::~wxMenuItem()
/* static */ /* static */
wxString wxMenuItemBase::GetLabelFromText(const wxString& text) wxString wxMenuItemBase::GetLabelFromText(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; wxString label;
for ( const wxChar *pc = text.c_str(); *pc; pc++ ) for ( const wxChar *pc = text.c_str(); *pc; pc++ )
@@ -762,6 +798,7 @@ wxString wxMenuItemBase::GetLabelFromText(const wxString& text)
} }
// wxPrintf( wxT("GetLabelFromText(): text %s label %s\n"), text.c_str(), label.c_str() ); // wxPrintf( wxT("GetLabelFromText(): text %s label %s\n"), text.c_str(), label.c_str() );
#endif
return label; return label;
} }
@@ -927,6 +964,14 @@ bool wxMenuItem::IsChecked() const
return ((GtkCheckMenuItem*)m_menuItem)->active != 0; return ((GtkCheckMenuItem*)m_menuItem)->active != 0;
} }
wxString wxMenuItem::GetItemLabel() const
{
wxString label = wxConvertFromGTKToWXLabel(m_text);
if (!m_hotKey.IsEmpty())
label = label + wxT("\t") + m_hotKey;
return label;
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// wxMenu // wxMenu
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------

View File

@@ -94,14 +94,14 @@ void wxInsertMenuItemsInMenu(wxMenu* menu, MenuRef wm, MenuItemIndex insertAfter
subMenu = item->GetSubMenu() ; subMenu = item->GetSubMenu() ;
if (subMenu) if (subMenu)
{ {
wxInsertMenuItemsInMenu(subMenu, (MenuRef)subMenu->GetHMenu(), 0); wxInsertMenuItemsInMenu(subMenu, (MenuRef)subMenu->GetHMenu(), 0);
} }
if ( item->IsSeparator() ) if ( item->IsSeparator() )
{ {
if ( wm && newItems) if ( wm && newItems)
InsertMenuItemTextWithCFString( wm, InsertMenuItemTextWithCFString( wm,
CFSTR(""), insertAfter, kMenuItemAttrSeparator, 0); CFSTR(""), insertAfter, kMenuItemAttrSeparator, 0);
newItems = false; newItems = false;
} }
else else
@@ -110,9 +110,9 @@ void wxInsertMenuItemsInMenu(wxMenu* menu, MenuRef wm, MenuItemIndex insertAfter
entry = wxAcceleratorEntry::Create( item->GetText() ) ; entry = wxAcceleratorEntry::Create( item->GetText() ) ;
MenuItemIndex winListPos = (MenuItemIndex)-1; MenuItemIndex winListPos = (MenuItemIndex)-1;
OSStatus err = GetIndMenuItemWithCommandID(wm, OSStatus err = GetIndMenuItemWithCommandID(wm,
wxIdToMacCommand ( item->GetId() ), 1, NULL, &winListPos); wxIdToMacCommand ( item->GetId() ), 1, NULL, &winListPos);
if ( wm && err == menuItemNotFoundErr ) if ( wm && err == menuItemNotFoundErr )
{ {
// NB: the only way to determine whether or not we should add // NB: the only way to determine whether or not we should add
@@ -126,7 +126,7 @@ void wxInsertMenuItemsInMenu(wxMenu* menu, MenuRef wm, MenuItemIndex insertAfter
delete entry ; delete entry ;
} }
} }
} }
// ============================================================================ // ============================================================================
@@ -210,10 +210,10 @@ bool wxMenu::DoInsertOrAppend(wxMenuItem *pItem, size_t pos)
{ {
if ( pos == (size_t)-1 ) if ( pos == (size_t)-1 )
AppendMenuItemTextWithCFString( MAC_WXHMENU(m_hMenu), AppendMenuItemTextWithCFString( MAC_WXHMENU(m_hMenu),
CFSTR(""), kMenuItemAttrSeparator, 0,NULL); CFSTR(""), kMenuItemAttrSeparator, 0,NULL);
else else
InsertMenuItemTextWithCFString( MAC_WXHMENU(m_hMenu), InsertMenuItemTextWithCFString( MAC_WXHMENU(m_hMenu),
CFSTR(""), pos, kMenuItemAttrSeparator, 0); CFSTR(""), pos, kMenuItemAttrSeparator, 0);
} }
else else
{ {
@@ -655,10 +655,10 @@ void wxMenuBar::MacInstallMenuBar()
// However, the change from 10.2 to 10.3 suggests it is preferred // However, the change from 10.2 to 10.3 suggests it is preferred
#if TARGET_API_MAC_OSX #if TARGET_API_MAC_OSX
InsertMenuItemTextWithCFString( appleMenu, InsertMenuItemTextWithCFString( appleMenu,
CFSTR(""), 0, kMenuItemAttrSeparator, 0); CFSTR(""), 0, kMenuItemAttrSeparator, 0);
#endif #endif
InsertMenuItemTextWithCFString( appleMenu, InsertMenuItemTextWithCFString( appleMenu,
CFSTR("About..."), 0, 0, 0); CFSTR("About..."), 0, 0, 0);
MacInsertMenu( appleMenu , 0 ) ; MacInsertMenu( appleMenu , 0 ) ;
// clean-up the help menu before adding new items // clean-up the help menu before adding new items
@@ -738,7 +738,7 @@ void wxMenuBar::MacInstallMenuBar()
{ {
if ( mh ) if ( mh )
AppendMenuItemTextWithCFString( mh, AppendMenuItemTextWithCFString( mh,
CFSTR(""), kMenuItemAttrSeparator, 0,NULL); CFSTR(""), kMenuItemAttrSeparator, 0,NULL);
} }
else else
{ {
@@ -766,42 +766,42 @@ void wxMenuBar::MacInstallMenuBar()
} }
} }
} }
else if ( ( m_titles[i] == wxT("Window") || m_titles[i] == wxT("&Window") ) else if ( ( m_titles[i] == wxT("Window") || m_titles[i] == wxT("&Window") )
&& GetAutoWindowMenu() ) && GetAutoWindowMenu() )
{ {
if ( MacGetWindowMenuHMenu() == NULL ) if ( MacGetWindowMenuHMenu() == NULL )
{ {
CreateStandardWindowMenu( 0 , (MenuHandle*) &s_macWindowMenuHandle ) ; CreateStandardWindowMenu( 0 , (MenuHandle*) &s_macWindowMenuHandle ) ;
} }
MenuRef wm = (MenuRef)MacGetWindowMenuHMenu(); MenuRef wm = (MenuRef)MacGetWindowMenuHMenu();
if ( wm == NULL ) if ( wm == NULL )
break; break;
// get the insertion point in the standard menu // get the insertion point in the standard menu
MenuItemIndex winListStart; MenuItemIndex winListStart;
GetIndMenuItemWithCommandID(wm, GetIndMenuItemWithCommandID(wm,
kHICommandWindowListSeparator, 1, NULL, &winListStart); kHICommandWindowListSeparator, 1, NULL, &winListStart);
// add a separator so that the standard items and the custom items // add a separator so that the standard items and the custom items
// aren't mixed together, but only if this is the first run // aren't mixed together, but only if this is the first run
OSStatus err = GetIndMenuItemWithCommandID(wm, OSStatus err = GetIndMenuItemWithCommandID(wm,
'WXWM', 1, NULL, NULL); 'WXWM', 1, NULL, NULL);
if ( err == menuItemNotFoundErr ) if ( err == menuItemNotFoundErr )
{ {
InsertMenuItemTextWithCFString( wm, InsertMenuItemTextWithCFString( wm,
CFSTR(""), winListStart-1, kMenuItemAttrSeparator, 'WXWM'); CFSTR(""), winListStart-1, kMenuItemAttrSeparator, 'WXWM');
} }
wxInsertMenuItemsInMenu(menu, wm, winListStart); wxInsertMenuItemsInMenu(menu, wm, winListStart);
} }
else else
{ {
UMASetMenuTitle( MAC_WXHMENU(menu->GetHMenu()) , m_titles[i], m_font.GetEncoding() ) ; UMASetMenuTitle( MAC_WXHMENU(menu->GetHMenu()) , m_titles[i], m_font.GetEncoding() ) ;
menu->MacBeforeDisplay(false) ; menu->MacBeforeDisplay(false) ;
::InsertMenu(MAC_WXHMENU(_wxMenuAt(m_menus, i)->GetHMenu()), 0); ::InsertMenu(MAC_WXHMENU(_wxMenuAt(m_menus, i)->GetHMenu()), 0);
} }
} }
@@ -876,6 +876,15 @@ wxString wxMenuBar::GetLabelTop(size_t pos) const
wxCHECK_MSG( pos < GetMenuCount(), wxEmptyString, wxCHECK_MSG( pos < GetMenuCount(), wxEmptyString,
wxT("invalid menu index in wxMenuBar::GetLabelTop") ); wxT("invalid menu index in wxMenuBar::GetLabelTop") );
return wxStripMenuCodes(m_titles[pos]);
}
// Gets the original label at the top-level of the menubar
wxString wxMenuBar::GetMenuLabel(size_t pos) const
{
wxCHECK_MSG( pos < GetMenuCount(), wxEmptyString,
wxT("invalid menu index in wxMenuBar::GetMenuLabel") );
return m_titles[pos]; return m_titles[pos];
} }

View File

@@ -66,10 +66,10 @@ void wxMenuItem::UpdateItemBitmap()
DoUpdateItemBitmap( mhandle, index ); DoUpdateItemBitmap( mhandle, index );
} }
void wxMenuItem::DoUpdateItemBitmap( WXHMENU menu, wxUint16 index) void wxMenuItem::DoUpdateItemBitmap( WXHMENU menu, wxUint16 index)
{ {
MenuHandle mhandle = (MenuHandle) menu; MenuHandle mhandle = (MenuHandle) menu;
if ( mhandle == NULL || index == 0) if ( mhandle == NULL || index == 0)
return ; return ;
@@ -83,7 +83,7 @@ void wxMenuItem::DoUpdateItemBitmap( WXHMENU menu, wxUint16 index)
if ( info.contentType == kControlContentIconRef ) if ( info.contentType == kControlContentIconRef )
SetMenuItemIconHandle( mhandle , index , SetMenuItemIconHandle( mhandle , index ,
kMenuIconRefType , (Handle) info.u.iconRef ) ; kMenuIconRefType , (Handle) info.u.iconRef ) ;
else if ( info.contentType == kControlContentCGImageRef ) else if ( info.contentType == kControlContentCGImageRef )
SetMenuItemIconHandle( mhandle , index , SetMenuItemIconHandle( mhandle , index ,
kMenuCGImageRefType , (Handle) info.u.imageRef ) ; kMenuCGImageRefType , (Handle) info.u.imageRef ) ;
} }

View File

@@ -639,6 +639,15 @@ wxString wxMenuBar::GetLabelTop(size_t pos) const
wxCHECK_MSG( pos < GetMenuCount(), wxEmptyString, wxCHECK_MSG( pos < GetMenuCount(), wxEmptyString,
wxT("invalid menu index in wxMenuBar::GetLabelTop") ); wxT("invalid menu index in wxMenuBar::GetLabelTop") );
return wxStripMenuCodes(m_titles[pos]);
}
// Gets the original label at the top-level of the menubar
wxString wxMenuBar::GetMenuLabel(size_t pos) const
{
wxCHECK_MSG( pos < GetMenuCount(), wxEmptyString,
wxT("invalid menu index in wxMenuBar::GetMenuLabel") );
return m_titles[pos]; return m_titles[pos];
} }

View File

@@ -234,6 +234,8 @@ void wxMenuBar::SetLabelTop(size_t pos, const wxString& label)
if ( !menu ) if ( !menu )
return; return;
m_titles[pos] = label;
Widget w = (Widget)menu->GetButtonWidget(); Widget w = (Widget)menu->GetButtonWidget();
if (w) if (w)
{ {
@@ -247,6 +249,8 @@ void wxMenuBar::SetLabelTop(size_t pos, const wxString& label)
wxString wxMenuBar::GetLabelTop(size_t pos) const wxString wxMenuBar::GetLabelTop(size_t pos) const
{ {
return wxStripMenuCodes(m_titles[pos]);
#if 0
wxMenu *menu = GetMenu(pos); wxMenu *menu = GetMenu(pos);
if ( menu ) if ( menu )
{ {
@@ -263,8 +267,19 @@ wxString wxMenuBar::GetLabelTop(size_t pos) const
} }
return wxEmptyString; return wxEmptyString;
#endif
} }
// Gets the original label at the top-level of the menubar
wxString wxMenuBar::GetMenuLabel(size_t pos) const
{
wxCHECK_MSG( pos < GetMenuCount(), wxEmptyString,
wxT("invalid menu index in wxMenuBar::GetMenuLabel") );
return m_titles[pos];
}
bool wxMenuBar::Append(wxMenu * menu, const wxString& title) bool wxMenuBar::Append(wxMenu * menu, const wxString& title)
{ {
return Insert(GetMenuCount(), menu, title); return Insert(GetMenuCount(), menu, title);

View File

@@ -433,7 +433,7 @@ bool wxMenu::DoInsertOrAppend(wxMenuItem *pItem, size_t pos)
!pItem->GetBackgroundColour().Ok() && !pItem->GetBackgroundColour().Ok() &&
!pItem->GetFont().Ok() ) !pItem->GetFont().Ok() )
{ {
// try to use InsertMenuItem() as it's guaranteed to look correct // try to use InsertMenuItem() as it's guaranteed to look correct
// while our owner-drawn code is not // while our owner-drawn code is not
// first compile-time check // first compile-time check
@@ -441,7 +441,7 @@ bool wxMenu::DoInsertOrAppend(wxMenuItem *pItem, size_t pos)
#if defined(MIIM_BITMAP) && (_WIN32_WINNT >= 0x0500) #if defined(MIIM_BITMAP) && (_WIN32_WINNT >= 0x0500)
WinStruct<wxMENUITEMINFO_> mii; WinStruct<wxMENUITEMINFO_> mii;
if ( wxGetWinVersion() >= wxWinVersion_98 ) if ( wxGetWinVersion() >= wxWinVersion_98 )
{ {
mii.fMask = MIIM_STRING | MIIM_DATA | MIIM_BITMAP; mii.fMask = MIIM_STRING | MIIM_DATA | MIIM_BITMAP;
if ( pItem->IsCheckable() ) if ( pItem->IsCheckable() )
{ {
@@ -1086,6 +1086,15 @@ wxString wxMenuBar::GetLabelTop(size_t pos) const
return wxMenuItem::GetLabelFromText(m_titles[pos]); return wxMenuItem::GetLabelFromText(m_titles[pos]);
} }
// Gets the original label at the top-level of the menubar
wxString wxMenuBar::GetMenuLabel(size_t pos) const
{
wxCHECK_MSG( pos < GetMenuCount(), wxEmptyString,
wxT("invalid menu index in wxMenuBar::GetMenuLabel") );
return m_titles[pos];
}
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// wxMenuBar construction // wxMenuBar construction
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------

View File

@@ -892,9 +892,19 @@ wxString wxMenuBar::GetLabelTop(
{ {
wxCHECK_MSG( nPos < GetMenuCount(), wxEmptyString, wxCHECK_MSG( nPos < GetMenuCount(), wxEmptyString,
wxT("invalid menu index in wxMenuBar::GetLabelTop") ); wxT("invalid menu index in wxMenuBar::GetLabelTop") );
return m_titles[nPos]; return wxStripMenuCodes(m_titles[nPos]);
} // end of wxMenuBar::GetLabelTop } // end of wxMenuBar::GetLabelTop
// Gets the original label at the top-level of the menubar
wxString wxMenuBar::GetMenuLabel(size_t pos) const
{
wxCHECK_MSG( pos < GetMenuCount(), wxEmptyString,
wxT("invalid menu index in wxMenuBar::GetMenuLabel") );
return m_titles[pos];
}
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// wxMenuBar construction // wxMenuBar construction
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------

View File

@@ -395,6 +395,15 @@ wxString wxMenuBar::GetLabelTop(size_t pos) const
return wxMenuItem::GetLabelFromText(m_titles[pos]); return wxMenuItem::GetLabelFromText(m_titles[pos]);
} }
// Gets the original label at the top-level of the menubar
wxString wxMenuBar::GetMenuLabel(size_t pos) const
{
wxCHECK_MSG( pos < GetMenuCount(), wxEmptyString,
wxT("invalid menu index in wxMenuBar::GetMenuLabel") );
return m_titles[pos];
}
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// wxMenuBar construction // wxMenuBar construction
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------

View File

@@ -67,6 +67,8 @@ public:
void SetLabel(const wxString& text) void SetLabel(const wxString& text)
{ {
m_originalLabel = text;
// remember the accel char (may be -1 if none) // remember the accel char (may be -1 if none)
m_indexAccel = wxControl::FindAccelIndex(text, &m_label); m_indexAccel = wxControl::FindAccelIndex(text, &m_label);
@@ -79,6 +81,7 @@ public:
// accessors // accessors
const wxString& GetLabel() const { return m_label; } const wxString& GetLabel() const { return m_label; }
const wxString& GetOriginalLabel() const { return m_originalLabel; }
bool IsEnabled() const { return m_isEnabled; } bool IsEnabled() const { return m_isEnabled; }
wxCoord GetWidth(wxMenuBar *menubar) const wxCoord GetWidth(wxMenuBar *menubar) const
{ {
@@ -105,6 +108,7 @@ private:
} }
wxString m_label; wxString m_label;
wxString m_originalLabel;
wxCoord m_width; wxCoord m_width;
int m_indexAccel; int m_indexAccel;
bool m_isEnabled; bool m_isEnabled;
@@ -1822,9 +1826,9 @@ bool wxMenuBar::IsEnabledTop(size_t pos) const
void wxMenuBar::SetLabelTop(size_t pos, const wxString& label) void wxMenuBar::SetLabelTop(size_t pos, const wxString& label)
{ {
wxCHECK_RET( pos < GetCount(), _T("invalid index in EnableTop") ); wxCHECK_RET( pos < GetCount(), _T("invalid index in SetLabelTop") );
if ( label != m_menuInfos[pos].GetLabel() ) if ( label != m_menuInfos[pos].GetOriginalLabel() )
{ {
m_menuInfos[pos].SetLabel(label); m_menuInfos[pos].SetLabel(label);
@@ -1840,6 +1844,16 @@ wxString wxMenuBar::GetLabelTop(size_t pos) const
return m_menuInfos[pos].GetLabel(); return m_menuInfos[pos].GetLabel();
} }
// Gets the original label at the top-level of the menubar
wxString wxMenuBar::GetMenuLabel(size_t pos) const
{
wxCHECK_MSG( pos < GetMenuCount(), wxEmptyString,
wxT("invalid menu index in wxMenuBar::GetMenuLabel") );
return m_menuInfos[pos].GetOriginalLabel();
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxMenuBar drawing // wxMenuBar drawing
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@@ -39,6 +39,14 @@
*wxLog*DoCreateOnDemand*; *wxLog*DoCreateOnDemand*;
*wxLogChain*DetachOldLog*; *wxLogChain*DetachOldLog*;
*wxMemoryFSHandler*AddFileWithMimeType*; *wxMemoryFSHandler*AddFileWithMimeType*;
*wxMenuBar*GetMenuLabel*;
*wxMenuBarBase*SetMenuLabel*;
*wxMenuBarBase*GetMenuLabelText*;
*wxMenuBase*GetLabelText*;
*wxMenuItemBase*SetItemLabel*;
*wxMenuItemBase*GetItemLabelText*;
*wxMenuItemBase*GetLabelText*;
*wxMenuItem*GetItemLabel*;
*wxMetafileDC*DoGetTextExtent*; *wxMetafileDC*DoGetTextExtent*;
*wxWindowMSW*GetThemedBorderStyle*; *wxWindowMSW*GetThemedBorderStyle*;
*wxWizard*GetBitmap*; *wxWizard*GetBitmap*;