]> git.saurik.com Git - wxWidgets.git/commitdiff
Extract wxSTOCK_WITHOUT_ELLIPSIS from wxSTOCK_FOR_BUTTON.
authorVadim Zeitlin <vadim@wxwidgets.org>
Thu, 4 Feb 2010 01:33:32 +0000 (01:33 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Thu, 4 Feb 2010 01:33:32 +0000 (01:33 +0000)
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

include/wx/stockitem.h
interface/wx/stockitem.h
src/common/stockitem.cpp

index 05814e8905be6c5359b165f0d2ea7b59031eb8d5..b13f84dc127079703eeb263fa58deee6bb64bb26 100644 (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"
index 83baf0f802a11f792f62b9c25c0216eef027af61..d08b17c7d5e25aa4dfb978519243d0980d7d0a15 100644 (file)
@@ -23,8 +23,8 @@ enum wxStockLabelQueryFlag
 
     /**
         Request the label with mnemonics character.
-       
-        E.g. "&amp;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 */
index 9a02d8bf5845f071d2dacf0a9c0cbf768a8d41c4..1d0e914631b16b506a745b71eac2d79eb7f59eab 100644 (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__