From 32cd189dfcfe96c41e32c3b9827bf67484c60b13 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 25 Jul 2006 18:47:39 +0000 Subject: [PATCH] use GetLabelText() instead of wxStripMenuCodes() to avoid stripping the part of the string after TAB git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@40331 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/cocoa/button.mm | 4 ++-- src/cocoa/checkbox.mm | 2 +- src/cocoa/statbox.mm | 2 +- src/mac/carbon/radiobox.cpp | 2 +- src/mac/carbon/stattext.cpp | 4 ++-- src/mac/carbon/window.cpp | 4 ++-- src/mac/classic/control.cpp | 6 +++--- src/motif/button.cpp | 3 +-- src/motif/checkbox.cpp | 3 +-- src/motif/choice.cpp | 2 +- src/motif/control.cpp | 2 +- src/motif/radiobox.cpp | 6 +++--- src/motif/radiobut.cpp | 2 +- src/motif/statbox.cpp | 2 +- src/motif/stattext.cpp | 4 ++-- src/msw/button.cpp | 6 +++--- src/msw/checkbox.cpp | 2 +- src/msw/radiobox.cpp | 2 +- src/msw/radiobut.cpp | 2 +- src/msw/statbox.cpp | 2 +- src/msw/stattext.cpp | 3 +-- src/msw/tglbtn.cpp | 2 +- 22 files changed, 32 insertions(+), 35 deletions(-) diff --git a/src/cocoa/button.mm b/src/cocoa/button.mm index 0485809e1b..2e9cb7103c 100644 --- a/src/cocoa/button.mm +++ b/src/cocoa/button.mm @@ -48,7 +48,7 @@ bool wxButton::Create(wxWindow *parent, wxWindowID winid, [m_cocoaNSView release]; [GetNSButton() setBezelStyle:NSRoundedBezelStyle]; - [GetNSButton() setTitle:wxNSStringWithWxString(wxStripMenuCodes(label))]; + [GetNSButton() setTitle:wxNSStringWithWxString(GetLabelText(label))]; [GetNSControl() sizeToFit]; if(m_parent) @@ -78,7 +78,7 @@ wxString wxButton::GetLabel() const void wxButton::SetLabel(const wxString& label) { - [GetNSButton() setTitle:wxNSStringWithWxString(wxStripMenuCodes(label))]; + [GetNSButton() setTitle:wxNSStringWithWxString(GetLabelText(label))]; } wxSize wxButton::DoGetBestSize() const diff --git a/src/cocoa/checkbox.mm b/src/cocoa/checkbox.mm index dccffa0053..0e73912c1f 100644 --- a/src/cocoa/checkbox.mm +++ b/src/cocoa/checkbox.mm @@ -47,7 +47,7 @@ bool wxCheckBox::Create(wxWindow *parent, wxWindowID winid, [m_cocoaNSView release]; [GetNSButton() setButtonType: NSSwitchButton]; [GetNSButton() setAllowsMixedState: Is3State()]; - [GetNSButton() setTitle:wxNSStringWithWxString(wxStripMenuCodes(label))]; + [GetNSButton() setTitle:wxNSStringWithWxString(GetLabelText(label))]; [GetNSControl() sizeToFit]; if(m_parent) diff --git a/src/cocoa/statbox.mm b/src/cocoa/statbox.mm index bc36016905..289294fff6 100644 --- a/src/cocoa/statbox.mm +++ b/src/cocoa/statbox.mm @@ -37,7 +37,7 @@ bool wxStaticBox::Create(wxWindow *parent, wxWindowID winid, return false; m_cocoaNSView = NULL; SetNSBox([[NSBox alloc] initWithFrame:MakeDefaultNSRect(size)]); - [GetNSBox() setTitle:wxNSStringWithWxString(wxStripMenuCodes(title))]; + [GetNSBox() setTitle:wxNSStringWithWxString(GetLabelText(title))]; if(m_parent) m_parent->CocoaAddChild(this); SetInitialFrameRect(pos,size); diff --git a/src/mac/carbon/radiobox.cpp b/src/mac/carbon/radiobox.cpp index 102bc58cbc..649aa592a2 100644 --- a/src/mac/carbon/radiobox.cpp +++ b/src/mac/carbon/radiobox.cpp @@ -128,7 +128,7 @@ bool wxRadioBox::Create( wxWindow *parent, wxRadioButton *radBtn = new wxRadioButton( this, wxID_ANY, - wxStripMenuCodes(choices[i]), + GetLabelText(choices[i]), wxPoint( 5, 20 * i + 10 ), wxDefaultSize, i == 0 ? wxRB_GROUP : 0 ); diff --git a/src/mac/carbon/stattext.cpp b/src/mac/carbon/stattext.cpp index 7c45e73eab..0898022392 100644 --- a/src/mac/carbon/stattext.cpp +++ b/src/mac/carbon/stattext.cpp @@ -43,7 +43,7 @@ bool wxStaticText::Create( wxWindow *parent, { m_macIsUserPane = false; - m_label = wxStripMenuCodes( label ); + m_label = GetLabelText( label ); if ( !wxControl::Create( parent, id, pos, size, style, wxDefaultValidator, name ) ) return false; @@ -113,7 +113,7 @@ wxSize wxStaticText::DoGetBestSize() const void wxStaticText::SetLabel( const wxString& st ) { - m_label = wxStripMenuCodes( st ); + m_label = GetLabelText( st ); wxMacCFStringHolder str( m_label, m_font.GetEncoding() ); CFStringRef ref = str; diff --git a/src/mac/carbon/window.cpp b/src/mac/carbon/window.cpp index ef5d9dc053..09dfc658d6 100644 --- a/src/mac/carbon/window.cpp +++ b/src/mac/carbon/window.cpp @@ -1136,7 +1136,7 @@ void wxWindowMac::MacPostControlCreate(const wxPoint& pos, const wxSize& size) // adjust font, controlsize etc DoSetWindowVariant( m_windowVariant ) ; - m_peer->SetLabel( wxStripMenuCodes(m_label) ) ; + m_peer->SetLabel( wxStripMenuCodes(m_label, wxStrip_Mnemonics) ) ; if (!m_macIsUserPane) SetInitialBestSize(size); @@ -2088,7 +2088,7 @@ void wxWindowMac::DoSetClientSize(int clientwidth, int clientheight) void wxWindowMac::SetLabel(const wxString& title) { - m_label = wxStripMenuCodes(title) ; + m_label = wxStripMenuCodes(title, wxStrip_Mnemonics) ; if ( m_peer && m_peer->Ok() ) m_peer->SetLabel( m_label ) ; diff --git a/src/mac/classic/control.cpp b/src/mac/classic/control.cpp index 5edc253f73..d5c0ca1880 100644 --- a/src/mac/classic/control.cpp +++ b/src/mac/classic/control.cpp @@ -207,7 +207,7 @@ wxControl::~wxControl() void wxControl::SetLabel(const wxString& title) { - m_label = wxStripMenuCodes(title) ; + m_label = GetLabelText(title) ; if ( m_macControl ) { @@ -309,7 +309,7 @@ void wxControl::MacPreControlCreate( wxWindow *parent, wxWindowID id, wxString l ((Rect*)outBounds)->bottom = 0; ((Rect*)outBounds)->right = 0; - wxMacStringToPascal( wxStripMenuCodes(label) , maclabel ) ; + wxMacStringToPascal( GetLabelText(label) , maclabel ) ; } void wxControl::MacPostControlCreate() @@ -398,7 +398,7 @@ void wxControl::MacPostControlCreate() SetSize(pos.x, pos.y, new_size.x, new_size.y); #if wxUSE_UNICODE - UMASetControlTitle( (ControlHandle) m_macControl , wxStripMenuCodes(m_label) , m_font.GetEncoding() ) ; + UMASetControlTitle( (ControlHandle) m_macControl , GetLabelText(m_label) , m_font.GetEncoding() ) ; #endif if ( m_macControlIsShown ) diff --git a/src/motif/button.cpp b/src/motif/button.cpp index b917a07c12..77ce5c0242 100644 --- a/src/motif/button.cpp +++ b/src/motif/button.cpp @@ -58,8 +58,7 @@ bool wxButton::Create(wxWindow *parent, wxWindowID id, const wxString& lbl, if( !CreateControl( parent, id, pos, size, style, validator, name ) ) return false; - wxString label1(wxStripMenuCodes(label)); - wxXmString text( label1 ); + wxXmString text( GetLabelText(label) ); Widget parentWidget = (Widget) parent->GetClientWidget(); diff --git a/src/motif/checkbox.cpp b/src/motif/checkbox.cpp index 6d03da153a..f4b8b88644 100644 --- a/src/motif/checkbox.cpp +++ b/src/motif/checkbox.cpp @@ -63,8 +63,7 @@ bool wxCheckBox::Create(wxWindow *parent, wxWindowID id, const wxString& label, name ) ) return false; - wxString label1(wxStripMenuCodes(label)); - wxXmString text( label1 ); + wxXmString text( GetLabelText(label) ); Widget parentWidget = (Widget) parent->GetClientWidget(); diff --git a/src/motif/choice.cpp b/src/motif/choice.cpp index 11153b562d..585c467600 100644 --- a/src/motif/choice.cpp +++ b/src/motif/choice.cpp @@ -195,7 +195,7 @@ int wxChoice::DoInsert(const wxString& item, unsigned int pos) #ifndef XmNpositionIndex wxCHECK_MSG( pos == GetCount(), -1, wxT("insert not implemented")); #endif - Widget w = XtVaCreateManagedWidget (wxStripMenuCodes(item), + Widget w = XtVaCreateManagedWidget (GetLabelText(item), #if wxUSE_GADGETS xmPushButtonGadgetClass, (Widget) m_menuWidget, #else diff --git a/src/motif/control.cpp b/src/motif/control.cpp index 13b8146af7..4026913541 100644 --- a/src/motif/control.cpp +++ b/src/motif/control.cpp @@ -85,7 +85,7 @@ void wxControl::SetLabel(const wxString& label) if (!widget) return; - wxXmString label_str(wxStripMenuCodes(label)); + wxXmString label_str(GetLabelText(label)); XtVaSetValues (widget, XmNlabelString, label_str(), diff --git a/src/motif/radiobox.cpp b/src/motif/radiobox.cpp index 35faf81059..aecbbea5f3 100644 --- a/src/motif/radiobox.cpp +++ b/src/motif/radiobox.cpp @@ -76,7 +76,7 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& title, XmNresizeWidth, True, NULL); - wxString label1(wxStripMenuCodes(title)); + wxString label1(GetLabelText(title)); if (!label1.empty()) { @@ -120,7 +120,7 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& title, int i; for (i = 0; i < n; i++) { - wxString str(wxStripMenuCodes(choices[i])); + wxString str(GetLabelText(choices[i])); m_radioButtonLabels.push_back(str); Widget radioItem = XtVaCreateManagedWidget ( wxConstCast(str.c_str(), char), @@ -179,7 +179,7 @@ void wxRadioBox::SetString(unsigned int item, const wxString& label) Widget widget = (Widget)m_radioButtons[item]; if (!label.empty()) { - wxString label1(wxStripMenuCodes(label)); + wxString label1(GetLabelText(label)); wxXmString text( label1 ); m_radioButtonLabels[item] = label1; XtVaSetValues (widget, diff --git a/src/motif/radiobut.cpp b/src/motif/radiobut.cpp index c0886ce554..5a6680e165 100644 --- a/src/motif/radiobut.cpp +++ b/src/motif/radiobut.cpp @@ -55,7 +55,7 @@ bool wxRadioButton::Create(wxWindow *parent, wxWindowID id, Widget parentWidget = (Widget) parent->GetClientWidget(); Display* dpy = XtDisplay(parentWidget); - wxString label1(wxStripMenuCodes(label)); + wxString label1(GetLabelText(label)); wxXmString text( label1 ); diff --git a/src/motif/statbox.cpp b/src/motif/statbox.cpp index f6d4fa2b5e..ae4838acdc 100644 --- a/src/motif/statbox.cpp +++ b/src/motif/statbox.cpp @@ -104,7 +104,7 @@ bool wxStaticBox::Create(wxWindow *parent, wxWindowID id, if (!label.empty()) { - wxString label1(wxStripMenuCodes(label)); + wxString label1(GetLabelText(label)); wxXmString text(label1); Display* dpy = XtDisplay( parentWidget ); diff --git a/src/motif/stattext.cpp b/src/motif/stattext.cpp index 953f4cd659..e109caae2d 100644 --- a/src/motif/stattext.cpp +++ b/src/motif/stattext.cpp @@ -47,7 +47,7 @@ bool wxStaticText::Create(wxWindow *parent, wxWindowID id, Widget borderWidget = (Widget) wxCreateBorderWidget( (WXWidget)parentWidget, style ); - wxXmString text( wxStripMenuCodes( label ) ); + wxXmString text( GetLabelText( label ) ); m_labelWidget = XtVaCreateManagedWidget (wxConstCast(name.c_str(), char), @@ -73,7 +73,7 @@ bool wxStaticText::Create(wxWindow *parent, wxWindowID id, void wxStaticText::SetLabel(const wxString& label) { - wxXmString label_str(wxStripMenuCodes(label)); + wxXmString label_str(GetLabelText(label)); // This variable means we don't need so many casts later. Widget widget = (Widget) m_labelWidget; diff --git a/src/msw/button.cpp b/src/msw/button.cpp index d8fd8eea60..05c20f9b88 100644 --- a/src/msw/button.cpp +++ b/src/msw/button.cpp @@ -254,7 +254,7 @@ wxSize wxButton::DoGetBestSize() const wxCoord wBtn, hBtn; - dc.GetMultiLineTextExtent(wxStripMenuCodes(GetLabel()), &wBtn, &hBtn); + dc.GetMultiLineTextExtent(GetLabelText(), &wBtn, &hBtn); // add a margin -- the button is wider than just its label wBtn += 3*GetCharWidth(); @@ -850,8 +850,8 @@ bool wxButton::MSWOnDraw(WXDRAWITEMSTRUCT *wxdis) COLORREF colFg = wxColourToRGB(GetForegroundColour()); DrawButtonText(hdc, &rectBtn, - (state & ODS_NOACCEL ? wxStripMenuCodes(GetLabel()) - : GetLabel()), + state & ODS_NOACCEL ? GetLabelText() + : GetLabel(), state & ODS_DISABLED ? GetSysColor(COLOR_GRAYTEXT) : colFg); diff --git a/src/msw/checkbox.cpp b/src/msw/checkbox.cpp index 8cbda8d72e..4a11fa5c46 100644 --- a/src/msw/checkbox.cpp +++ b/src/msw/checkbox.cpp @@ -215,7 +215,7 @@ wxSize wxCheckBox::DoGetBestSize() const int wCheckbox, hCheckbox; if ( !str.empty() ) { - GetTextExtent(wxStripMenuCodes(str), &wCheckbox, &hCheckbox); + GetTextExtent(GetLabelText(str), &wCheckbox, &hCheckbox); wCheckbox += s_checkSize + GetCharWidth(); if ( hCheckbox < s_checkSize ) diff --git a/src/msw/radiobox.cpp b/src/msw/radiobox.cpp index 66534b1e2a..94ffdaf7aa 100644 --- a/src/msw/radiobox.cpp +++ b/src/msw/radiobox.cpp @@ -495,7 +495,7 @@ wxSize wxRadioBox::GetTotalButtonSize(const wxSize& sizeBtn) const // and also wide enough for its label int widthLabel; - GetTextExtent(wxStripMenuCodes(GetLabel()), &widthLabel, NULL); + GetTextExtent(GetLabelText(), &widthLabel, NULL); widthLabel += RADIO_SIZE; // FIXME this is bogus too if ( widthLabel > width ) width = widthLabel; diff --git a/src/msw/radiobut.cpp b/src/msw/radiobut.cpp index 5196c0ba05..61ab90ded2 100644 --- a/src/msw/radiobut.cpp +++ b/src/msw/radiobut.cpp @@ -297,7 +297,7 @@ wxSize wxRadioButton::DoGetBestSize() const int wRadio, hRadio; if ( !str.empty() ) { - GetTextExtent(wxStripMenuCodes(str), &wRadio, &hRadio); + GetTextExtent(GetLabelText(str), &wRadio, &hRadio); wRadio += s_radioSize + GetCharWidth(); if ( hRadio < s_radioSize ) diff --git a/src/msw/statbox.cpp b/src/msw/statbox.cpp index 54aeee7068..b426f923e4 100644 --- a/src/msw/statbox.cpp +++ b/src/msw/statbox.cpp @@ -160,7 +160,7 @@ wxSize wxStaticBox::DoGetBestSize() const wxGetCharSize(GetHWND(), &cx, &cy, GetFont()); int wBox; - GetTextExtent(wxStripMenuCodes(wxGetWindowText(m_hWnd)), &wBox, &cy); + GetTextExtent(GetLabelText(wxGetWindowText(m_hWnd)), &wBox, &cy); wBox += 3*cx; int hBox = EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy); diff --git a/src/msw/stattext.cpp b/src/msw/stattext.cpp index 1d93adb87b..20ae8b9c92 100644 --- a/src/msw/stattext.cpp +++ b/src/msw/stattext.cpp @@ -136,8 +136,7 @@ wxSize wxStaticText::DoGetBestSize() const dc.SetFont(font); wxCoord widthTextMax, heightTextTotal; - dc.GetMultiLineTextExtent(::wxStripMenuCodes(GetLabel()), - &widthTextMax, &heightTextTotal); + dc.GetMultiLineTextExtent(GetLabelText(), &widthTextMax, &heightTextTotal); #ifdef __WXWINCE__ if ( widthTextMax ) diff --git a/src/msw/tglbtn.cpp b/src/msw/tglbtn.cpp index e3e986fe8c..a0b22727df 100644 --- a/src/msw/tglbtn.cpp +++ b/src/msw/tglbtn.cpp @@ -114,7 +114,7 @@ wxSize wxToggleButton::DoGetBestSize() const { wxString label = wxGetWindowText(GetHWND()); int wBtn; - GetTextExtent(wxStripMenuCodes(label), &wBtn, NULL); + GetTextExtent(GetLabelText(label), &wBtn, NULL); int wChar, hChar; wxGetCharSize(GetHWND(), &wChar, &hChar, GetFont()); -- 2.45.2