From 355ce7adea8043d72e02cd00aa7f475f3b3be92d Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 16 Oct 2009 21:32:51 +0000 Subject: [PATCH] Rename wxEllipsizeFlags elements to avoid confusion with wxEllipsizeMode. We shouldn't use the same "wxELLIPSIZE_" prefix for two different enums, so use wxELLIPSIZE_FLAGS one for wxEllipsizeFlags (they should be used less often than wxEllipsizeMode so it's better to keep the short prefix for the latter). Also add wxELLIPSIZE_FLAGS_NONE flag. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62432 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/control.h | 10 ++++++---- interface/wx/control.h | 40 ++++++++++++++++++++++++++-------------- src/common/ctrlcmn.cpp | 4 ++-- src/generic/statusbr.cpp | 2 +- src/msw/statusbar.cpp | 2 +- 5 files changed, 36 insertions(+), 22 deletions(-) diff --git a/include/wx/control.h b/include/wx/control.h index 9fa7a65c21..f947f0f203 100644 --- a/include/wx/control.h +++ b/include/wx/control.h @@ -31,10 +31,12 @@ extern WXDLLIMPEXP_DATA_CORE(const char) wxControlNameStr[]; enum wxEllipsizeFlags { - wxELLIPSIZE_PROCESS_MNEMONICS = 1, - wxELLIPSIZE_EXPAND_TAB = 2, + wxELLIPSIZE_FLAGS_NONE = 0, + wxELLIPSIZE_FLAGS_PROCESS_MNEMONICS = 1, + wxELLIPSIZE_FLAGS_EXPAND_TABS = 2, - wxELLIPSIZE_DEFAULT_FLAGS = wxELLIPSIZE_PROCESS_MNEMONICS|wxELLIPSIZE_EXPAND_TAB + wxELLIPSIZE_FLAGS_DEFAULT = wxELLIPSIZE_FLAGS_PROCESS_MNEMONICS | + wxELLIPSIZE_FLAGS_EXPAND_TABS }; enum wxEllipsizeMode @@ -115,7 +117,7 @@ public: // replaces parts of the (multiline) string with ellipsis if needed static wxString Ellipsize(const wxString& label, const wxDC& dc, wxEllipsizeMode mode, int maxWidth, - int flags = wxELLIPSIZE_DEFAULT_FLAGS); + int flags = wxELLIPSIZE_FLAGS_DEFAULT); // get the string without mnemonic characters ('&') static wxString GetLabelText(const wxString& label); diff --git a/interface/wx/control.h b/interface/wx/control.h index 2d56ad3c60..9dcbf8f136 100644 --- a/interface/wx/control.h +++ b/interface/wx/control.h @@ -11,21 +11,33 @@ */ enum wxEllipsizeFlags { - /// With this flag when calculating the size of the passed string, mnemonics - /// characters (see wxControl::SetLabel) will be automatically reduced to a - /// single character. - /// This leads to correct calculations only if the string passed to Ellipsize() - /// will be used with wxControl::SetLabel. If you don't want ampersand to - /// be interpreted as mnemonics (e.g. because you use wxControl::SetLabelText) - /// then don't use this flag. - wxELLIPSIZE_PROCESS_MNEMONICS = 1, - - /// This flag tells wxControl::Ellipsize to calculate the width of tab - /// characters @c '\\t' as 6 spaces. - wxELLIPSIZE_EXPAND_TAB = 2, + /// No special flags. + wxELLIPSIZE_FLAGS_NONE = 0, + + /** + Take mnemonics into account when calculating the text width. + + With this flag when calculating the size of the passed string, + mnemonics characters (see wxControl::SetLabel) will be automatically + reduced to a single character. This leads to correct calculations only + if the string passed to Ellipsize() will be used with + wxControl::SetLabel. If you don't want ampersand to be interpreted as + mnemonics (e.g. because you use wxControl::SetLabelText) then don't use + this flag. + */ + wxELLIPSIZE_FLAGS_PROCESS_MNEMONICS = 1, + + /** + Expand tabs in spaces when calculating the text width. + + This flag tells wxControl::Ellipsize() to calculate the width of tab + characters @c '\\t' as 6 spaces. + */ + wxELLIPSIZE_FLAGS_EXPAND_TABS = 2, /// The default flags for wxControl::Ellipsize. - wxELLIPSIZE_DEFAULT_FLAGS = wxELLIPSIZE_PROCESS_MNEMONICS|wxELLIPSIZE_EXPAND_TAB + wxELLIPSIZE_FLAGS_DEFAULT = wxELLIPSIZE_FLAGS_PROCESS_MNEMONICS| + wxELLIPSIZE_FLAGS_EXPAND_TABS }; @@ -96,7 +108,7 @@ public: */ static wxString Ellipsize(const wxString& label, const wxDC& dc, wxEllipsizeMode mode, int maxWidth, - int flags = wxELLIPSIZE_DEFAULT_FLAGS); + int flags = wxELLIPSIZE_FLAGS_DEFAULT); /** Returns the control's text. diff --git a/src/common/ctrlcmn.cpp b/src/common/ctrlcmn.cpp index f6dbd6eb2d..b4a0eb6e65 100644 --- a/src/common/ctrlcmn.cpp +++ b/src/common/ctrlcmn.cpp @@ -412,7 +412,7 @@ wxString wxControlBase::Ellipsize(const wxString& label, const wxDC& dc, } } // we need to remove mnemonics from the label for correct calculations - else if ( *pc == wxS('&') && (flags & wxELLIPSIZE_PROCESS_MNEMONICS) != 0 ) + else if ( *pc == wxS('&') && (flags & wxELLIPSIZE_FLAGS_PROCESS_MNEMONICS) ) { // pc+1 is safe: at worst we'll be at end() wxString::const_iterator next = pc + 1; @@ -421,7 +421,7 @@ wxString wxControlBase::Ellipsize(const wxString& label, const wxDC& dc, //else: remove this ampersand } // we need also to expand tabs to properly calc their size - else if ( *pc == wxS('\t') && (flags & wxELLIPSIZE_EXPAND_TAB) != 0 ) + else if ( *pc == wxS('\t') && (flags & wxELLIPSIZE_FLAGS_EXPAND_TABS) ) { // Windows natively expands the TABs to 6 spaces. Do the same: curLine += wxS(" "); diff --git a/src/generic/statusbr.cpp b/src/generic/statusbr.cpp index 740df48eed..4c24ee5c35 100644 --- a/src/generic/statusbr.cpp +++ b/src/generic/statusbr.cpp @@ -248,7 +248,7 @@ void wxStatusBarGeneric::DrawFieldText(wxDC& dc, const wxRect& rect, int i, int text = wxControl::Ellipsize(text, dc, ellmode, maxWidth, - wxELLIPSIZE_EXPAND_TAB); + wxELLIPSIZE_FLAGS_EXPAND_TABS); // Ellipsize() will do something only if necessary // update the ellipsization status for this pane; this is used later to diff --git a/src/msw/statusbar.cpp b/src/msw/statusbar.cpp index 663c7f6505..d0fe3d05fc 100644 --- a/src/msw/statusbar.cpp +++ b/src/msw/statusbar.cpp @@ -316,7 +316,7 @@ void wxStatusBar::DoUpdateStatusText(int nField) *m_pDC, ellmode, maxWidth, - wxELLIPSIZE_EXPAND_TAB); + wxELLIPSIZE_FLAGS_EXPAND_TABS); // update the ellipsization status for this pane; this is used later to // decide whether a tooltip should be shown or not for this pane -- 2.47.2