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:
@@ -2911,6 +2911,28 @@ See also \helpref{wxWriteResource}{wxwriteresource}, \helpref{wxConfigBase}{wxco
|
|||||||
<wx/utils.h>
|
<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}
|
\membersection{::wxGetTopLevelParent}\label{wxgettoplevelparent}
|
||||||
|
|
||||||
\func{wxWindow *}{wxGetTopLevelParent}{\param{wxWindow }{*win}}
|
\func{wxWindow *}{wxGetTopLevelParent}{\param{wxWindow }{*win}}
|
||||||
|
@@ -17,6 +17,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wx/defs.h"
|
#include "wx/defs.h"
|
||||||
|
#include "wx/wxchar.h"
|
||||||
#include "wx/string.h"
|
#include "wx/string.h"
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -32,7 +33,9 @@ WXDLLEXPORT bool wxIsStockLabel(wxWindowID id, const wxString& label);
|
|||||||
|
|
||||||
// Returns label that should be used for given stock UI element (e.g. "&OK"
|
// Returns label that should be used for given stock UI element (e.g. "&OK"
|
||||||
// for wxSTOCK_OK):
|
// for wxSTOCK_OK):
|
||||||
WXDLLEXPORT wxString wxGetStockLabel(wxWindowID id);
|
WXDLLEXPORT wxString wxGetStockLabel(wxWindowID id,
|
||||||
|
bool withCodes = true,
|
||||||
|
wxString accelerator = wxEmptyString);
|
||||||
|
|
||||||
#ifdef __WXGTK20__
|
#ifdef __WXGTK20__
|
||||||
// Translates stock ID to GTK+'s stock item string indentifier:
|
// Translates stock ID to GTK+'s stock item string indentifier:
|
||||||
|
@@ -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) \
|
#define STOCKITEM(stockid, label) \
|
||||||
case stockid: \
|
case stockid: \
|
||||||
return wxStripMenuCodes(label);
|
stockLabel = label; \
|
||||||
#else
|
break;
|
||||||
#define STOCKITEM(stockid, label) \
|
|
||||||
case stockid: \
|
|
||||||
return label;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
switch (id)
|
switch (id)
|
||||||
{
|
{
|
||||||
@@ -165,7 +162,17 @@ wxString wxGetStockLabel(wxWindowID id)
|
|||||||
|
|
||||||
#undef STOCKITEM
|
#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)
|
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_assigned = true;
|
||||||
m_id = id;
|
m_id = id;
|
||||||
if(label.empty() && wxIsStockID(id))
|
if(label.empty() && wxIsStockID(id))
|
||||||
m_label = wxGetStockLabel(id);
|
m_label = wxGetStockLabel(id, false);
|
||||||
else
|
else
|
||||||
m_label = label;
|
m_label = label;
|
||||||
m_menu = subMenu;
|
m_menu = subMenu;
|
||||||
|
@@ -40,9 +40,10 @@
|
|||||||
#include "wx/dcscreen.h"
|
#include "wx/dcscreen.h"
|
||||||
#include "wx/frame.h"
|
#include "wx/frame.h"
|
||||||
#include "wx/dialog.h"
|
#include "wx/dialog.h"
|
||||||
#include "wx/stockitem.h"
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "wx/stockitem.h"
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// macros
|
// macros
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -168,7 +169,7 @@ bool wxButton::Create(wxWindow *parent,
|
|||||||
// take the stock label
|
// take the stock label
|
||||||
wxString palmLabel = label;
|
wxString palmLabel = label;
|
||||||
if( palmLabel.empty() && wxIsStockID(id) )
|
if( palmLabel.empty() && wxIsStockID(id) )
|
||||||
palmLabel = wxGetStockLabel(id);
|
palmLabel = wxGetStockLabel(id, false);
|
||||||
|
|
||||||
if(!wxControl::Create(parent, id, palmPos, palmSize, style, validator, name))
|
if(!wxControl::Create(parent, id, palmPos, palmSize, style, validator, name))
|
||||||
return false;
|
return false;
|
||||||
|
Reference in New Issue
Block a user