<wx/utils.h>
+\membersection{::wxGetStockLabel}\label{wxgetstocklabel}
+
+\func{wxString}{wxGetStockLabel}{\param{wxWindowID }{id}, \param{bool }{withCodes = true}, \param{wxString }{accelerator = wxEmptyString}}
+
+Returns label that should be used for given {\it id} element.
+
+\wxheading{Parameters}
+
+\docparam{id}{given id of the \helpref{wxMenuItem}{wxmenuitem}, \helpref{wxButton}{wxbutton}, \helpref{wxToolBar}{wxtoolbar} tool, etc.}
+
+\docparam{withCodes}{if false then strip accelerator code from the label;
+usefull for getting labels without accelerator char code like for toolbar tooltip or
+under platforms without traditional keyboard like smartphones}
+
+\docparam{accelerator}{optional accelerator string automatically added to label; useful
+for building labels for \helpref{wxMenuItem}{wxmenuitem}}
+
+\wxheading{Include files}
+
+<wx/stockitem.h>
+
+
\membersection{::wxGetTopLevelParent}\label{wxgettoplevelparent}
\func{wxWindow *}{wxGetTopLevelParent}{\param{wxWindow }{*win}}
#endif
#include "wx/defs.h"
+#include "wx/wxchar.h"
#include "wx/string.h"
// ----------------------------------------------------------------------------
// Returns label that should be used for given stock UI element (e.g. "&OK"
// for wxSTOCK_OK):
-WXDLLEXPORT wxString wxGetStockLabel(wxWindowID id);
+WXDLLEXPORT wxString wxGetStockLabel(wxWindowID id,
+ bool withCodes = true,
+ wxString accelerator = wxEmptyString);
#ifdef __WXGTK20__
// Translates stock ID to GTK+'s stock item string indentifier:
};
}
-wxString wxGetStockLabel(wxWindowID id)
+wxString wxGetStockLabel(wxWindowID id, bool withCodes, wxString accelerator)
{
-#if defined(__SMARTPHONE__) || defined(__WXPALMOS__)
- #define STOCKITEM(stockid, label) \
- case stockid: \
- return wxStripMenuCodes(label);
-#else
+ wxString stockLabel;
+
#define STOCKITEM(stockid, label) \
case stockid: \
- return label;
-#endif
+ stockLabel = label; \
+ break;
switch (id)
{
#undef STOCKITEM
- return wxEmptyString;
+ if(!withCodes)
+ {
+ stockLabel = wxStripMenuCodes( stockLabel );
+ }
+ else if (!stockLabel.empty() && !accelerator.empty())
+ {
+ stockLabel += _T("\t");
+ stockLabel += accelerator;
+ }
+
+ return stockLabel;
}
bool wxIsStockLabel(wxWindowID id, const wxString& label)
m_assigned = true;
m_id = id;
if(label.empty() && wxIsStockID(id))
- m_label = wxGetStockLabel(id);
+ m_label = wxGetStockLabel(id, false);
else
m_label = label;
m_menu = subMenu;
#include "wx/dcscreen.h"
#include "wx/frame.h"
#include "wx/dialog.h"
- #include "wx/stockitem.h"
#endif
+#include "wx/stockitem.h"
+
// ----------------------------------------------------------------------------
// macros
// ----------------------------------------------------------------------------
// take the stock label
wxString palmLabel = label;
if( palmLabel.empty() && wxIsStockID(id) )
- palmLabel = wxGetStockLabel(id);
+ palmLabel = wxGetStockLabel(id, false);
if(!wxControl::Create(parent, id, palmPos, palmSize, style, validator, name))
return false;