Enhanced wxGetStockLabel() with parameters which replace platform specific #ifdefs for wxPalmOS and wxWinCE and better serve for getting consistent wxMenuItem and wxToolBar labels (with documentation).
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@31673 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -93,17 +93,14 @@ bool wxIsStockID(wxWindowID id)
|
||||
};
|
||||
}
|
||||
|
||||
wxString wxGetStockLabel(wxWindowID id)
|
||||
wxString wxGetStockLabel(wxWindowID id, bool withCodes, wxString accelerator)
|
||||
{
|
||||
#if defined(__SMARTPHONE__) || defined(__WXPALMOS__)
|
||||
wxString stockLabel;
|
||||
|
||||
#define STOCKITEM(stockid, label) \
|
||||
case stockid: \
|
||||
return wxStripMenuCodes(label);
|
||||
#else
|
||||
#define STOCKITEM(stockid, label) \
|
||||
case stockid: \
|
||||
return label;
|
||||
#endif
|
||||
stockLabel = label; \
|
||||
break;
|
||||
|
||||
switch (id)
|
||||
{
|
||||
@@ -165,7 +162,17 @@ wxString wxGetStockLabel(wxWindowID 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)
|
||||
|
@@ -84,7 +84,7 @@ void wxTopLevelWindowMSW::ButtonMenu::SetButton(int id, const wxString& label, w
|
||||
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;
|
||||
|
@@ -40,9 +40,10 @@
|
||||
#include "wx/dcscreen.h"
|
||||
#include "wx/frame.h"
|
||||
#include "wx/dialog.h"
|
||||
#include "wx/stockitem.h"
|
||||
#endif
|
||||
|
||||
#include "wx/stockitem.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// macros
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -168,7 +169,7 @@ bool wxButton::Create(wxWindow *parent,
|
||||
// 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;
|
||||
|
Reference in New Issue
Block a user