From: Vadim Zeitlin Date: Thu, 4 Feb 2010 01:33:32 +0000 (+0000) Subject: Extract wxSTOCK_WITHOUT_ELLIPSIS from wxSTOCK_FOR_BUTTON. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/95ad763a77ad999bc302a7fead376d091baae2c2 Extract wxSTOCK_WITHOUT_ELLIPSIS from wxSTOCK_FOR_BUTTON. Make it possible to use this flag on its own, without wxSTOCK_WITH_MNEMONIC which is also part of wxSTOCK_FOR_BUTTON. This can be useful for e.g. toolbar buttons. Closes #11681, #11682. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63383 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/stockitem.h b/include/wx/stockitem.h index 05814e8905..b13f84dc12 100644 --- a/include/wx/stockitem.h +++ b/include/wx/stockitem.h @@ -35,9 +35,13 @@ enum wxStockLabelQueryFlag wxSTOCK_WITH_MNEMONIC = 1, wxSTOCK_WITH_ACCELERATOR = 2, - // return label for button, not menu item: notice that this always included - // wxSTOCK_WITH_MNEMONIC as buttons should use mnemonics - wxSTOCK_FOR_BUTTON = 5 + // by default, stock items text is returned with ellipsis, if appropriate, + // this flag allows to avoid having it + wxSTOCK_WITHOUT_ELLIPSIS = 4, + + // return label for button, not menu item: buttons should always use + // mnemonics and never use ellipsis + wxSTOCK_FOR_BUTTON = wxSTOCK_WITHOUT_ELLIPSIS | wxSTOCK_WITH_MNEMONIC }; // Returns label that should be used for given stock UI element (e.g. "&OK" diff --git a/interface/wx/stockitem.h b/interface/wx/stockitem.h index 83baf0f802..d08b17c7d5 100644 --- a/interface/wx/stockitem.h +++ b/interface/wx/stockitem.h @@ -23,8 +23,8 @@ enum wxStockLabelQueryFlag /** Request the label with mnemonics character. - - E.g. "&Print...". + + E.g. "&Print...". */ wxSTOCK_WITH_MNEMONIC = 1, @@ -36,6 +36,20 @@ enum wxStockLabelQueryFlag */ wxSTOCK_WITH_ACCELERATOR = 2, + /** + Return the label without any ellipsis at the end. + + By default, stock items text is returned with ellipsis, if appropriate, + this flag allows to avoid having it. So using the same example as + above, the returned string would be "Print" or "&Print" if + wxSTOCK_WITH_MNEMONIC were also used. + + This flag can't be combined with wxSTOCK_WITH_ACCELERATOR. + + @since 2.9.1 + */ + wxSTOCK_WITHOUT_ELLIPSIS = 4, + /** Return the label appropriate for a button and not a menu item. @@ -45,8 +59,10 @@ enum wxStockLabelQueryFlag wxID_PRINT when this flag is used is "&Print". This flag can't be combined with wxSTOCK_WITH_ACCELERATOR. + + @since 2.9.1 */ - wxSTOCK_FOR_BUTTON = 5 + wxSTOCK_FOR_BUTTON = wxSTOCK_WITHOUT_ELLIPSIS | wxSTOCK_WITH_MNEMONIC }; /** @addtogroup group_funcmacro_misc */ diff --git a/src/common/stockitem.cpp b/src/common/stockitem.cpp index 9a02d8bf58..1d0e914631 100644 --- a/src/common/stockitem.cpp +++ b/src/common/stockitem.cpp @@ -205,16 +205,17 @@ wxString wxGetStockLabel(wxWindowID id, long flags) #undef STOCKITEM - // we assume that buttons use the same labels as menu items but unlike them - // they should never use ellipsis - if ( (flags & wxSTOCK_FOR_BUTTON) == wxSTOCK_FOR_BUTTON ) + if ( flags & wxSTOCK_WITHOUT_ELLIPSIS ) { wxString baseLabel; if ( stockLabel.EndsWith("...", &baseLabel) ) stockLabel = baseLabel; + // accelerators only make sense for the menu items which should have + // ellipsis too while wxSTOCK_WITHOUT_ELLIPSIS is mostly useful for + // buttons which shouldn't have accelerators in their labels wxASSERT_MSG( !(flags & wxSTOCK_WITH_ACCELERATOR), - "button labels never use accelerators" ); + "labels without ellipsis shouldn't use accelerators" ); } #ifdef __WXMSW__