]> git.saurik.com Git - wxWidgets.git/blame - src/common/stockitem.cpp
We need to update the scrollbar even if it's not shown, otherwise it can get stuck...
[wxWidgets.git] / src / common / stockitem.cpp
CommitLineData
401e3b6e
VS
1///////////////////////////////////////////////////////////////////////////////
2// Name: common/stockitem.cpp
3// Purpose: Stock buttons, menu and toolbar items labels
4// Author: Vaclav Slavik
5// Modified by:
6// Created: 2004-08-15
7// RCS-ID: $Id$
8// Copyright: (c) Vaclav Slavik, 2004
9// Licence: wxWindows licence
10///////////////////////////////////////////////////////////////////////////////
11
12// ============================================================================
13// declarations
14// ============================================================================
15
16// ----------------------------------------------------------------------------
17// headers
18// ----------------------------------------------------------------------------
19
20#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
21 #pragma implementation "stockitem.h"
22#endif
23
24// For compilers that support precompilation, includes "wx.h".
25#include "wx/wxprec.h"
26
27#ifdef __BORLANDC__
28 #pragma hdrstop
29#endif
30
31#include "wx/stockitem.h"
32#include "wx/intl.h"
33
5f7bcb48
VS
34
35bool wxIsStockID(wxWindowID id)
36{
37 switch (id)
38 {
39 case wxID_ADD:
40 case wxID_APPLY:
41 case wxID_BOLD:
42 case wxID_CANCEL:
43 case wxID_CLEAR:
44 case wxID_CLOSE:
45 case wxID_COPY:
46 case wxID_CUT:
47 case wxID_DELETE:
48 case wxID_FIND:
49 case wxID_REPLACE:
50 case wxID_BACKWARD:
51 case wxID_DOWN:
52 case wxID_FORWARD:
53 case wxID_UP:
54 case wxID_HELP:
55 case wxID_HOME:
56 case wxID_INDENT:
57 case wxID_INDEX:
58 case wxID_ITALIC:
59 case wxID_JUSTIFY_CENTER:
60 case wxID_JUSTIFY_FILL:
61 case wxID_JUSTIFY_LEFT:
62 case wxID_JUSTIFY_RIGHT:
63 case wxID_NEW:
64 case wxID_NO:
65 case wxID_OK:
66 case wxID_OPEN:
67 case wxID_PASTE:
68 case wxID_PREFERENCES:
69 case wxID_PRINT:
70 case wxID_PREVIEW:
71 case wxID_PROPERTIES:
72 case wxID_EXIT:
73 case wxID_REDO:
74 case wxID_REFRESH:
75 case wxID_REMOVE:
76 case wxID_REVERT_TO_SAVED:
77 case wxID_SAVE:
78 case wxID_SAVEAS:
79 case wxID_STOP:
80 case wxID_UNDELETE:
81 case wxID_UNDERLINE:
82 case wxID_UNDO:
83 case wxID_UNINDENT:
84 case wxID_YES:
85 case wxID_ZOOM_100:
86 case wxID_ZOOM_FIT:
87 case wxID_ZOOM_IN:
88 case wxID_ZOOM_OUT:
89 return true;
90
91 default:
92 return false;
93 };
94}
95
96wxString wxGetStockLabel(wxWindowID id)
401e3b6e 97{
06442f70
WS
98#ifdef __SMARTPHONE__
99 #define STOCKITEM(stockid, label) \
100 case stockid: \
101 return wxStripMenuCodes(label);
102#else
401e3b6e
VS
103 #define STOCKITEM(stockid, label) \
104 case stockid: \
b39a4e83 105 return label;
06442f70 106#endif
401e3b6e 107
5f7bcb48 108 switch (id)
401e3b6e 109 {
5f7bcb48
VS
110 STOCKITEM(wxID_ADD, _("Add"))
111 STOCKITEM(wxID_APPLY, _("&Apply"))
112 STOCKITEM(wxID_BOLD, _("&Bold"))
113 STOCKITEM(wxID_CANCEL, _("&Cancel"))
114 STOCKITEM(wxID_CLEAR, _("&Clear"))
115 STOCKITEM(wxID_CLOSE, _("&Close"))
116 STOCKITEM(wxID_COPY, _("&Copy"))
117 STOCKITEM(wxID_CUT, _("Cu&t"))
118 STOCKITEM(wxID_DELETE, _("&Delete"))
119 STOCKITEM(wxID_FIND, _("&Find"))
120 STOCKITEM(wxID_REPLACE, _("Rep&lace"))
121 STOCKITEM(wxID_BACKWARD, _("&Back"))
122 STOCKITEM(wxID_DOWN, _("&Down"))
123 STOCKITEM(wxID_FORWARD, _("&Forward"))
124 STOCKITEM(wxID_UP, _("&Up"))
125 STOCKITEM(wxID_HELP, _("&Help"))
126 STOCKITEM(wxID_HOME, _("&Home"))
127 STOCKITEM(wxID_INDENT, _("Indent"))
128 STOCKITEM(wxID_INDEX, _("&Index"))
129 STOCKITEM(wxID_ITALIC, _("&Italic"))
130 STOCKITEM(wxID_JUSTIFY_CENTER, _("Centered"))
131 STOCKITEM(wxID_JUSTIFY_FILL, _("Justified"))
132 STOCKITEM(wxID_JUSTIFY_LEFT, _("Align Left"))
133 STOCKITEM(wxID_JUSTIFY_RIGHT, _("Align Right"))
134 STOCKITEM(wxID_NEW, _("&New"))
135 STOCKITEM(wxID_NO, _("&No"))
136 STOCKITEM(wxID_OK, _("&OK"))
137 STOCKITEM(wxID_OPEN, _("&Open"))
138 STOCKITEM(wxID_PASTE, _("&Paste"))
139 STOCKITEM(wxID_PREFERENCES, _("&Preferences"))
140 STOCKITEM(wxID_PRINT, _("&Print"))
141 STOCKITEM(wxID_PREVIEW, _("Print previe&w"))
142 STOCKITEM(wxID_PROPERTIES, _("&Properties"))
143 STOCKITEM(wxID_EXIT, _("&Quit"))
144 STOCKITEM(wxID_REDO, _("&Redo"))
145 STOCKITEM(wxID_REFRESH, _("Refresh"))
146 STOCKITEM(wxID_REMOVE, _("Remove"))
147 STOCKITEM(wxID_REVERT_TO_SAVED, _("Revert to Saved"))
148 STOCKITEM(wxID_SAVE, _("&Save"))
149 STOCKITEM(wxID_SAVEAS, _("Save &As..."))
150 STOCKITEM(wxID_STOP, _("&Stop"))
151 STOCKITEM(wxID_UNDELETE, _("Undelete"))
152 STOCKITEM(wxID_UNDERLINE, _("&Underline"))
153 STOCKITEM(wxID_UNDO, _("&Undo"))
154 STOCKITEM(wxID_UNINDENT, _("&Unindent"))
155 STOCKITEM(wxID_YES, _("&Yes"))
156 STOCKITEM(wxID_ZOOM_100, _("&Actual Size"))
157 STOCKITEM(wxID_ZOOM_FIT, _("Zoom to &Fit"))
158 STOCKITEM(wxID_ZOOM_IN, _("Zoom &In"))
159 STOCKITEM(wxID_ZOOM_OUT, _("Zoom &Out"))
160
401e3b6e
VS
161 default:
162 wxFAIL_MSG( _T("invalid stock item ID") );
163 break;
164 };
165
166 #undef STOCKITEM
d775fa82 167
401e3b6e
VS
168 return wxEmptyString;
169}
170
5f7bcb48
VS
171bool wxIsStockLabel(wxWindowID id, const wxString& label)
172{
173 if (label.empty())
174 return true;
175
176 wxString stock = wxGetStockLabel(id);
177
178 if (label == stock)
179 return true;
d775fa82 180
5f7bcb48
VS
181 stock.Replace(_T("&"), wxEmptyString);
182 if (label == stock)
183 return true;
d775fa82 184
5f7bcb48
VS
185 return false;
186}
187
401e3b6e
VS
188
189#ifdef __WXGTK20__
190
191#include <gtk/gtk.h>
192
5f7bcb48 193const char *wxGetStockGtkID(wxWindowID id)
401e3b6e 194{
5f7bcb48
VS
195 #define STOCKITEM(wx,gtk) \
196 case wx: \
197 return gtk;
d775fa82 198
5f7bcb48 199 #define STOCKITEM_MISSING(wx) \
c4c3e30f 200 case wx: \
4b5966d7 201 return NULL;
c20889ab
VS
202
203 #if GTK_CHECK_VERSION(2,4,0)
5f7bcb48 204 #define STOCKITEM_24(wx,gtk) STOCKITEM(wx,gtk)
c20889ab 205 #else
5f7bcb48 206 #define STOCKITEM_24(wx,gtk) STOCKITEM_MISSING(wx)
c20889ab 207 #endif
401e3b6e 208
5f7bcb48 209 switch (id)
401e3b6e 210 {
5f7bcb48
VS
211 STOCKITEM(wxID_ADD, GTK_STOCK_ADD)
212 STOCKITEM(wxID_APPLY, GTK_STOCK_APPLY)
213 STOCKITEM(wxID_BOLD, GTK_STOCK_BOLD)
214 STOCKITEM(wxID_CANCEL, GTK_STOCK_CANCEL)
215 STOCKITEM(wxID_CLEAR, GTK_STOCK_CLEAR)
216 STOCKITEM(wxID_CLOSE, GTK_STOCK_CLOSE)
217 STOCKITEM(wxID_COPY, GTK_STOCK_COPY)
218 STOCKITEM(wxID_CUT, GTK_STOCK_CUT)
219 STOCKITEM(wxID_DELETE, GTK_STOCK_DELETE)
220 STOCKITEM(wxID_FIND, GTK_STOCK_FIND)
221 STOCKITEM(wxID_REPLACE, GTK_STOCK_FIND_AND_REPLACE)
222 STOCKITEM(wxID_BACKWARD, GTK_STOCK_GO_BACK)
223 STOCKITEM(wxID_DOWN, GTK_STOCK_GO_DOWN)
224 STOCKITEM(wxID_FORWARD, GTK_STOCK_GO_FORWARD)
225 STOCKITEM(wxID_UP, GTK_STOCK_GO_UP)
226 STOCKITEM(wxID_HELP, GTK_STOCK_HELP)
227 STOCKITEM(wxID_HOME, GTK_STOCK_HOME)
228 STOCKITEM_24(wxID_INDENT, GTK_STOCK_INDENT)
229 STOCKITEM(wxID_INDEX, GTK_STOCK_INDEX)
230 STOCKITEM(wxID_ITALIC, GTK_STOCK_ITALIC)
231 STOCKITEM(wxID_JUSTIFY_CENTER, GTK_STOCK_JUSTIFY_CENTER)
232 STOCKITEM(wxID_JUSTIFY_FILL, GTK_STOCK_JUSTIFY_FILL)
233 STOCKITEM(wxID_JUSTIFY_LEFT, GTK_STOCK_JUSTIFY_LEFT)
234 STOCKITEM(wxID_JUSTIFY_RIGHT, GTK_STOCK_JUSTIFY_RIGHT)
235 STOCKITEM(wxID_NEW, GTK_STOCK_NEW)
236 STOCKITEM(wxID_NO, GTK_STOCK_NO)
237 STOCKITEM(wxID_OK, GTK_STOCK_OK)
238 STOCKITEM(wxID_OPEN, GTK_STOCK_OPEN)
239 STOCKITEM(wxID_PASTE, GTK_STOCK_PASTE)
240 STOCKITEM(wxID_PREFERENCES, GTK_STOCK_PREFERENCES)
241 STOCKITEM(wxID_PRINT, GTK_STOCK_PRINT)
242 STOCKITEM(wxID_PREVIEW, GTK_STOCK_PRINT_PREVIEW)
243 STOCKITEM(wxID_PROPERTIES, GTK_STOCK_PROPERTIES)
244 STOCKITEM(wxID_EXIT, GTK_STOCK_QUIT)
245 STOCKITEM(wxID_REDO, GTK_STOCK_REDO)
246 STOCKITEM(wxID_REFRESH, GTK_STOCK_REFRESH)
247 STOCKITEM(wxID_REMOVE, GTK_STOCK_REMOVE)
248 STOCKITEM(wxID_REVERT_TO_SAVED, GTK_STOCK_REVERT_TO_SAVED)
249 STOCKITEM(wxID_SAVE, GTK_STOCK_SAVE)
250 STOCKITEM(wxID_SAVEAS, GTK_STOCK_SAVE_AS)
251 STOCKITEM(wxID_STOP, GTK_STOCK_STOP)
252 STOCKITEM(wxID_UNDELETE, GTK_STOCK_UNDELETE)
253 STOCKITEM(wxID_UNDERLINE, GTK_STOCK_UNDERLINE)
254 STOCKITEM(wxID_UNDO, GTK_STOCK_UNDO)
255 STOCKITEM_24(wxID_UNINDENT, GTK_STOCK_UNINDENT)
256 STOCKITEM(wxID_YES, GTK_STOCK_YES)
257 STOCKITEM(wxID_ZOOM_100, GTK_STOCK_ZOOM_100)
258 STOCKITEM(wxID_ZOOM_FIT, GTK_STOCK_ZOOM_FIT)
259 STOCKITEM(wxID_ZOOM_IN, GTK_STOCK_ZOOM_IN)
260 STOCKITEM(wxID_ZOOM_OUT, GTK_STOCK_ZOOM_OUT)
261
401e3b6e
VS
262 default:
263 wxFAIL_MSG( _T("invalid stock item ID") );
264 break;
265 };
266
267 #undef STOCKITEM
d775fa82 268
401e3b6e
VS
269 return NULL;
270}
271
272#endif // __WXGTK20__