1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: common/stockitem.cpp
3 // Purpose: Stock buttons, menu and toolbar items labels
4 // Author: Vaclav Slavik
8 // Copyright: (c) Vaclav Slavik, 2004
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
20 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
21 #pragma implementation "stockitem.h"
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
31 #include "wx/stockitem.h"
33 #include "wx/utils.h" // for wxStripMenuCodes()
35 bool wxIsStockID(wxWindowID id
)
59 case wxID_JUSTIFY_CENTER
:
60 case wxID_JUSTIFY_FILL
:
61 case wxID_JUSTIFY_LEFT
:
62 case wxID_JUSTIFY_RIGHT
:
68 case wxID_PREFERENCES
:
76 case wxID_REVERT_TO_SAVED
:
96 wxString
wxGetStockLabel(wxWindowID id
, bool withCodes
, wxString accelerator
)
100 #define STOCKITEM(stockid, label) \
102 stockLabel = label; \
107 STOCKITEM(wxID_ADD
, _("Add"))
108 STOCKITEM(wxID_APPLY
, _("&Apply"))
109 STOCKITEM(wxID_BOLD
, _("&Bold"))
110 STOCKITEM(wxID_CANCEL
, _("&Cancel"))
111 STOCKITEM(wxID_CLEAR
, _("&Clear"))
112 STOCKITEM(wxID_CLOSE
, _("&Close"))
113 STOCKITEM(wxID_COPY
, _("&Copy"))
114 STOCKITEM(wxID_CUT
, _("Cu&t"))
115 STOCKITEM(wxID_DELETE
, _("&Delete"))
116 STOCKITEM(wxID_FIND
, _("&Find"))
117 STOCKITEM(wxID_REPLACE
, _("Rep&lace"))
118 STOCKITEM(wxID_BACKWARD
, _("&Back"))
119 STOCKITEM(wxID_DOWN
, _("&Down"))
120 STOCKITEM(wxID_FORWARD
, _("&Forward"))
121 STOCKITEM(wxID_UP
, _("&Up"))
122 STOCKITEM(wxID_HELP
, _("&Help"))
123 STOCKITEM(wxID_HOME
, _("&Home"))
124 STOCKITEM(wxID_INDENT
, _("Indent"))
125 STOCKITEM(wxID_INDEX
, _("&Index"))
126 STOCKITEM(wxID_ITALIC
, _("&Italic"))
127 STOCKITEM(wxID_JUSTIFY_CENTER
, _("Centered"))
128 STOCKITEM(wxID_JUSTIFY_FILL
, _("Justified"))
129 STOCKITEM(wxID_JUSTIFY_LEFT
, _("Align Left"))
130 STOCKITEM(wxID_JUSTIFY_RIGHT
, _("Align Right"))
131 STOCKITEM(wxID_NEW
, _("&New"))
132 STOCKITEM(wxID_NO
, _("&No"))
133 STOCKITEM(wxID_OK
, _("&OK"))
134 STOCKITEM(wxID_OPEN
, _("&Open"))
135 STOCKITEM(wxID_PASTE
, _("&Paste"))
136 STOCKITEM(wxID_PREFERENCES
, _("&Preferences"))
137 STOCKITEM(wxID_PRINT
, _("&Print"))
138 STOCKITEM(wxID_PREVIEW
, _("Print previe&w"))
139 STOCKITEM(wxID_PROPERTIES
, _("&Properties"))
140 STOCKITEM(wxID_EXIT
, _("&Quit"))
141 STOCKITEM(wxID_REDO
, _("&Redo"))
142 STOCKITEM(wxID_REFRESH
, _("Refresh"))
143 STOCKITEM(wxID_REMOVE
, _("Remove"))
144 STOCKITEM(wxID_REVERT_TO_SAVED
, _("Revert to Saved"))
145 STOCKITEM(wxID_SAVE
, _("&Save"))
146 STOCKITEM(wxID_SAVEAS
, _("Save &As..."))
147 STOCKITEM(wxID_STOP
, _("&Stop"))
148 STOCKITEM(wxID_UNDELETE
, _("Undelete"))
149 STOCKITEM(wxID_UNDERLINE
, _("&Underline"))
150 STOCKITEM(wxID_UNDO
, _("&Undo"))
151 STOCKITEM(wxID_UNINDENT
, _("&Unindent"))
152 STOCKITEM(wxID_YES
, _("&Yes"))
153 STOCKITEM(wxID_ZOOM_100
, _("&Actual Size"))
154 STOCKITEM(wxID_ZOOM_FIT
, _("Zoom to &Fit"))
155 STOCKITEM(wxID_ZOOM_IN
, _("Zoom &In"))
156 STOCKITEM(wxID_ZOOM_OUT
, _("Zoom &Out"))
159 wxFAIL_MSG( _T("invalid stock item ID") );
167 stockLabel
= wxStripMenuCodes( stockLabel
);
169 else if (!stockLabel
.empty() && !accelerator
.empty())
171 stockLabel
+= _T("\t");
172 stockLabel
+= accelerator
;
178 bool wxIsStockLabel(wxWindowID id
, const wxString
& label
)
183 wxString stock
= wxGetStockLabel(id
);
188 stock
.Replace(_T("&"), wxEmptyString
);
200 const char *wxGetStockGtkID(wxWindowID id
)
202 #define STOCKITEM(wx,gtk) \
206 #define STOCKITEM_MISSING(wx) \
210 #if GTK_CHECK_VERSION(2,4,0)
211 #define STOCKITEM_24(wx,gtk) STOCKITEM(wx,gtk)
213 #define STOCKITEM_24(wx,gtk) STOCKITEM_MISSING(wx)
218 STOCKITEM(wxID_ADD
, GTK_STOCK_ADD
)
219 STOCKITEM(wxID_APPLY
, GTK_STOCK_APPLY
)
220 STOCKITEM(wxID_BOLD
, GTK_STOCK_BOLD
)
221 STOCKITEM(wxID_CANCEL
, GTK_STOCK_CANCEL
)
222 STOCKITEM(wxID_CLEAR
, GTK_STOCK_CLEAR
)
223 STOCKITEM(wxID_CLOSE
, GTK_STOCK_CLOSE
)
224 STOCKITEM(wxID_COPY
, GTK_STOCK_COPY
)
225 STOCKITEM(wxID_CUT
, GTK_STOCK_CUT
)
226 STOCKITEM(wxID_DELETE
, GTK_STOCK_DELETE
)
227 STOCKITEM(wxID_FIND
, GTK_STOCK_FIND
)
228 STOCKITEM(wxID_REPLACE
, GTK_STOCK_FIND_AND_REPLACE
)
229 STOCKITEM(wxID_BACKWARD
, GTK_STOCK_GO_BACK
)
230 STOCKITEM(wxID_DOWN
, GTK_STOCK_GO_DOWN
)
231 STOCKITEM(wxID_FORWARD
, GTK_STOCK_GO_FORWARD
)
232 STOCKITEM(wxID_UP
, GTK_STOCK_GO_UP
)
233 STOCKITEM(wxID_HELP
, GTK_STOCK_HELP
)
234 STOCKITEM(wxID_HOME
, GTK_STOCK_HOME
)
235 STOCKITEM_24(wxID_INDENT
, GTK_STOCK_INDENT
)
236 STOCKITEM(wxID_INDEX
, GTK_STOCK_INDEX
)
237 STOCKITEM(wxID_ITALIC
, GTK_STOCK_ITALIC
)
238 STOCKITEM(wxID_JUSTIFY_CENTER
, GTK_STOCK_JUSTIFY_CENTER
)
239 STOCKITEM(wxID_JUSTIFY_FILL
, GTK_STOCK_JUSTIFY_FILL
)
240 STOCKITEM(wxID_JUSTIFY_LEFT
, GTK_STOCK_JUSTIFY_LEFT
)
241 STOCKITEM(wxID_JUSTIFY_RIGHT
, GTK_STOCK_JUSTIFY_RIGHT
)
242 STOCKITEM(wxID_NEW
, GTK_STOCK_NEW
)
243 STOCKITEM(wxID_NO
, GTK_STOCK_NO
)
244 STOCKITEM(wxID_OK
, GTK_STOCK_OK
)
245 STOCKITEM(wxID_OPEN
, GTK_STOCK_OPEN
)
246 STOCKITEM(wxID_PASTE
, GTK_STOCK_PASTE
)
247 STOCKITEM(wxID_PREFERENCES
, GTK_STOCK_PREFERENCES
)
248 STOCKITEM(wxID_PRINT
, GTK_STOCK_PRINT
)
249 STOCKITEM(wxID_PREVIEW
, GTK_STOCK_PRINT_PREVIEW
)
250 STOCKITEM(wxID_PROPERTIES
, GTK_STOCK_PROPERTIES
)
251 STOCKITEM(wxID_EXIT
, GTK_STOCK_QUIT
)
252 STOCKITEM(wxID_REDO
, GTK_STOCK_REDO
)
253 STOCKITEM(wxID_REFRESH
, GTK_STOCK_REFRESH
)
254 STOCKITEM(wxID_REMOVE
, GTK_STOCK_REMOVE
)
255 STOCKITEM(wxID_REVERT_TO_SAVED
, GTK_STOCK_REVERT_TO_SAVED
)
256 STOCKITEM(wxID_SAVE
, GTK_STOCK_SAVE
)
257 STOCKITEM(wxID_SAVEAS
, GTK_STOCK_SAVE_AS
)
258 STOCKITEM(wxID_STOP
, GTK_STOCK_STOP
)
259 STOCKITEM(wxID_UNDELETE
, GTK_STOCK_UNDELETE
)
260 STOCKITEM(wxID_UNDERLINE
, GTK_STOCK_UNDERLINE
)
261 STOCKITEM(wxID_UNDO
, GTK_STOCK_UNDO
)
262 STOCKITEM_24(wxID_UNINDENT
, GTK_STOCK_UNINDENT
)
263 STOCKITEM(wxID_YES
, GTK_STOCK_YES
)
264 STOCKITEM(wxID_ZOOM_100
, GTK_STOCK_ZOOM_100
)
265 STOCKITEM(wxID_ZOOM_FIT
, GTK_STOCK_ZOOM_FIT
)
266 STOCKITEM(wxID_ZOOM_IN
, GTK_STOCK_ZOOM_IN
)
267 STOCKITEM(wxID_ZOOM_OUT
, GTK_STOCK_ZOOM_OUT
)
270 wxFAIL_MSG( _T("invalid stock item ID") );
279 #endif // __WXGTK20__