+ // helper class for SetXXXLabels() methods: it makes it possible to pass
+ // either a stock id (wxID_CLOSE) or a string ("&Close") to them
+ class ButtonLabel
+ {
+ public:
+ // ctors are not explicit, objects of this class can be implicitly
+ // constructed from either stock ids or strings
+ ButtonLabel(int stockId)
+ : m_stockId(stockId)
+ {
+ wxASSERT_MSG( wxIsStockID(stockId), "invalid stock id" );
+ }
+
+ ButtonLabel(const wxString& label)
+ : m_label(label), m_stockId(wxID_NONE)
+ {
+ }
+
+ ButtonLabel(const char *label)
+ : m_label(label), m_stockId(wxID_NONE)
+ {
+ }
+
+ ButtonLabel(const wchar_t *label)
+ : m_label(label), m_stockId(wxID_NONE)
+ {
+ }
+
+ ButtonLabel(const wxCStrData& label)
+ : m_label(label), m_stockId(wxID_NONE)
+ {
+ }
+
+ // default copy ctor and dtor are ok
+
+ // get the string label, whether it was originally specified directly
+ // or as a stock id -- this is only useful for platforms without native
+ // stock items id support
+ wxString GetAsString() const
+ {
+ return m_stockId == wxID_NONE
+ ? m_label
+ : wxGetStockLabel(m_stockId, wxSTOCK_FOR_BUTTON);
+ }
+
+ // return the stock id or wxID_NONE if this is not a stock label
+ int GetStockId() const { return m_stockId; }
+
+ private:
+ // the label if explicitly given or empty if this is a stock item
+ const wxString m_label;
+
+ // the stock item id or wxID_NONE if m_label should be used
+ const int m_stockId;
+ };
+