]> git.saurik.com Git - wxWidgets.git/commitdiff
Added wxSTOCK_FOR_BUTTON flag for wxGetStockLabel().
authorVadim Zeitlin <vadim@wxwidgets.org>
Sat, 25 Jul 2009 16:41:05 +0000 (16:41 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sat, 25 Jul 2009 16:41:05 +0000 (16:41 +0000)
This allows to retrieve labels appropriate for the buttons and not menu items which currently means without trailing ellipsis.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61526 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

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

index 19cdc593214764f82bbed8469ee425ab301d4942..05814e8905be6c5359b165f0d2ea7b59031eb8d5 100644 (file)
@@ -33,7 +33,11 @@ enum wxStockLabelQueryFlag
     wxSTOCK_NOFLAGS = 0,
 
     wxSTOCK_WITH_MNEMONIC = 1,
-    wxSTOCK_WITH_ACCELERATOR = 2
+    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
 };
 
 // Returns label that should be used for given stock UI element (e.g. "&OK"
index 34801d65781574664b5737e6bddd13a3bb18459e..83baf0f802a11f792f62b9c25c0216eef027af61 100644 (file)
@@ -34,7 +34,19 @@ enum wxStockLabelQueryFlag
         E.g. "Print...\tCtrl-P". This can be combined with
         wxSTOCK_WITH_MNEMONIC to get "&Print...\tCtrl-P".
      */
-    wxSTOCK_WITH_ACCELERATOR = 2
+    wxSTOCK_WITH_ACCELERATOR = 2,
+
+    /**
+        Return the label appropriate for a button and not a menu item.
+
+        Currently the main difference is that the trailing ellipsis used in
+        some stock labels is never included in the returned label. Also, the
+        mnemonics is included if this flag is used. So the returned value for
+        wxID_PRINT when this flag is used is "&Print".
+
+        This flag can't be combined with wxSTOCK_WITH_ACCELERATOR.
+     */
+    wxSTOCK_FOR_BUTTON = 5
 };
 
 /** @addtogroup group_funcmacro_misc */
index f9f3fc049ea4e73a456b9f2ad47b247c5d10bb54..bf218c5fced004ca8d595cdf0c5e94192e101f25 100644 (file)
@@ -205,6 +205,18 @@ 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 )
+    {
+        wxString baseLabel;
+        if ( stockLabel.EndsWith("...", &baseLabel) )
+            stockLabel = baseLabel;
+
+        wxASSERT_MSG( !(flags & wxSTOCK_WITH_ACCELERATOR),
+                        "button labels never use accelerators" );
+    }
+
     if ( !(flags & wxSTOCK_WITH_MNEMONIC) )
     {
         stockLabel = wxStripMenuCodes(stockLabel);