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
This commit is contained in:
Vadim Zeitlin
2010-02-04 01:33:32 +00:00
parent 9439bc6955
commit 95ad763a77
3 changed files with 31 additions and 10 deletions

View File

@@ -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"

View File

@@ -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 */

View File

@@ -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__