diff --git a/include/wx/stockitem.h b/include/wx/stockitem.h index 19cdc59321..05814e8905 100644 --- a/include/wx/stockitem.h +++ b/include/wx/stockitem.h @@ -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" diff --git a/interface/wx/stockitem.h b/interface/wx/stockitem.h index 34801d6578..83baf0f802 100644 --- a/interface/wx/stockitem.h +++ b/interface/wx/stockitem.h @@ -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 */ diff --git a/src/common/stockitem.cpp b/src/common/stockitem.cpp index f9f3fc049e..bf218c5fce 100644 --- a/src/common/stockitem.cpp +++ b/src/common/stockitem.cpp @@ -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);