]>
Commit | Line | Data |
---|---|---|
23324ae1 FM |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: artprov.h | |
3 | // Purpose: documentation for wxArtProvider class | |
4 | // Author: wxWidgets team | |
5 | // RCS-ID: $Id$ | |
6 | // Licence: wxWindows license | |
7 | ///////////////////////////////////////////////////////////////////////////// | |
8 | ||
9 | /** | |
10 | @class wxArtProvider | |
11 | @wxheader{artprov.h} | |
7c913512 | 12 | |
23324ae1 FM |
13 | wxArtProvider class is used to customize the look of wxWidgets application. |
14 | When wxWidgets needs to display an icon or a bitmap (e.g. in the standard file | |
15 | dialog), it does not use a hard-coded resource but asks wxArtProvider for it | |
16 | instead. This way users can plug in their own wxArtProvider class and easily | |
17 | replace standard art with their own version. All | |
18 | that is needed is to derive a class from wxArtProvider, override either its | |
19 | wxArtProvider::CreateBitmap and/or its | |
20 | wxArtProvider::CreateIconBundle methods | |
21 | and register the provider with | |
22 | wxArtProvider::Push: | |
7c913512 | 23 | |
23324ae1 FM |
24 | @code |
25 | class MyProvider : public wxArtProvider | |
26 | { | |
27 | protected: | |
7c913512 | 28 | wxBitmap CreateBitmap(const wxArtID& id, |
23324ae1 FM |
29 | const wxArtClient& client, |
30 | const wxSize size) | |
7c913512 | 31 | |
23324ae1 FM |
32 | // optionally override this one as well |
33 | wxIconBundle CreateIconBundle(const wxArtID& id, | |
34 | const wxArtClient& client) | |
35 | { ... } | |
36 | }; | |
37 | ... | |
38 | wxArtProvider::Push(new MyProvider); | |
39 | @endcode | |
7c913512 | 40 | |
23324ae1 FM |
41 | If you need bitmap images (of the same artwork) that should be displayed at |
42 | different sizes | |
7c913512 | 43 | you should probably consider overriding wxArtProvider::CreateIconBundle |
23324ae1 | 44 | and supplying icon bundles that contain different bitmap sizes. |
7c913512 | 45 | |
23324ae1 FM |
46 | There's another way of taking advantage of this class: you can use it in your |
47 | code and use | |
7c913512 | 48 | platform native icons as provided by wxArtProvider::GetBitmap or |
23324ae1 FM |
49 | wxArtProvider::GetIcon (NB: this is not yet really |
50 | possible as of wxWidgets 2.3.3, the set of wxArtProvider bitmaps is too | |
7c913512 FM |
51 | small). |
52 | ||
53 | ||
23324ae1 FM |
54 | wxArtProvider::~wxArtProvider |
55 | wxArtProvider::CreateBitmap | |
56 | wxArtProvider::CreateIconBundle | |
57 | wxArtProvider::Delete | |
58 | wxArtProvider::GetBitmap | |
59 | wxArtProvider::GetIconBundle | |
60 | wxArtProvider::GetIcon | |
61 | wxArtProvider::Insert | |
62 | wxArtProvider::Pop | |
63 | wxArtProvider::Push | |
64 | wxArtProvider::Remove | |
7c913512 FM |
65 | |
66 | ||
23324ae1 | 67 | Identifying art resources |
7c913512 | 68 | |
23324ae1 FM |
69 | Every bitmap and icon bundle are known to wxArtProvider under an unique ID that |
70 | is used when | |
71 | requesting a resource from it. The ID is represented by wxArtID type and can | |
72 | have one of these predefined values (you can see bitmaps represented by these | |
73 | constants in the artprov sample): | |
7c913512 | 74 | |
23324ae1 FM |
75 | wxART_ERROR |
76 | wxART_QUESTION | |
77 | wxART_WARNING | |
78 | wxART_INFORMATION | |
79 | wxART_ADD_BOOKMARK | |
80 | wxART_DEL_BOOKMARK | |
81 | wxART_HELP_SIDE_PANEL | |
82 | wxART_HELP_SETTINGS | |
83 | wxART_HELP_BOOK | |
84 | wxART_HELP_FOLDER | |
85 | wxART_HELP_PAGE | |
86 | wxART_GO_BACK | |
87 | wxART_GO_FORWARD | |
88 | wxART_GO_UP | |
89 | wxART_GO_DOWN | |
90 | wxART_GO_TO_PARENT | |
91 | wxART_GO_HOME | |
92 | wxART_PRINT | |
93 | wxART_HELP | |
94 | wxART_TIP | |
95 | wxART_REPORT_VIEW | |
96 | wxART_LIST_VIEW | |
97 | wxART_NEW_DIR | |
98 | wxART_FOLDER | |
99 | wxART_FOLDER_OPEN | |
100 | wxART_GO_DIR_UP | |
101 | wxART_EXECUTABLE_FILE | |
102 | wxART_NORMAL_FILE | |
103 | wxART_TICK_MARK | |
104 | wxART_CROSS_MARK | |
105 | wxART_MISSING_IMAGE | |
106 | wxART_NEW | |
107 | wxART_FILE_OPEN | |
108 | wxART_FILE_SAVE | |
109 | wxART_FILE_SAVE_AS | |
110 | wxART_DELETE | |
111 | wxART_COPY | |
112 | wxART_CUT | |
113 | wxART_PASTE | |
114 | wxART_UNDO | |
115 | wxART_REDO | |
116 | wxART_QUIT | |
117 | wxART_FIND | |
118 | wxART_FIND_AND_REPLACE | |
119 | wxART_HARDDISK | |
120 | wxART_FLOPPY | |
121 | wxART_CDROM | |
122 | wxART_REMOVABLE | |
7c913512 FM |
123 | |
124 | ||
125 | Additionally, any string recognized by custom art providers registered using | |
23324ae1 | 126 | wxArtProvider::Push may be used. |
7c913512 | 127 | |
23324ae1 FM |
128 | @library{wxcore} |
129 | @category{FIXME} | |
7c913512 | 130 | |
23324ae1 FM |
131 | @seealso |
132 | See the artprov sample for an example of wxArtProvider usage. | |
133 | */ | |
134 | class wxArtProvider : public wxObject | |
135 | { | |
136 | public: | |
137 | /** | |
138 | The destructor automatically removes the provider from the provider stack used | |
139 | by GetBitmap(). | |
140 | */ | |
141 | ~wxArtProvider(); | |
142 | ||
143 | /** | |
144 | Client is the entity that calls wxArtProvider's GetBitmap or GetIcon | |
7c913512 | 145 | function. It is represented by wxClientID type and can have one of these |
23324ae1 | 146 | values: |
23324ae1 FM |
147 | wxART_TOOLBAR |
148 | wxART_MENU | |
149 | wxART_BUTTON | |
150 | wxART_FRAME_ICON | |
151 | wxART_CMN_DIALOG | |
152 | wxART_HELP_BROWSER | |
153 | wxART_MESSAGE_BOX | |
154 | wxART_OTHER (used for all requests that don't fit into any of the categories | |
155 | above) | |
23324ae1 FM |
156 | Client ID servers as a hint to wxArtProvider that is supposed to help it to |
157 | choose the best looking bitmap. For example it is often desirable to use | |
158 | slightly different icons in menus and toolbars even though they represent the | |
159 | same action (e.g. @c wx_ART_FILE_OPEN). Remember that this is really | |
160 | only a hint for wxArtProvider -- it is common that | |
7c913512 | 161 | GetBitmap() |
23324ae1 FM |
162 | returns identical bitmap for different @e client values! |
163 | ||
4cc4bfaf | 164 | @see See the artprov sample for an example of wxArtProvider usage. |
23324ae1 FM |
165 | */ |
166 | ||
167 | ||
168 | /** | |
169 | Derived art provider classes must override this method to create requested art | |
170 | resource. Note that returned bitmaps are cached by wxArtProvider and it is | |
171 | therefore not necessary to optimize CreateBitmap() for speed (e.g. you may | |
172 | create wxBitmap objects from XPMs here). | |
173 | ||
7c913512 | 174 | @param id |
4cc4bfaf | 175 | wxArtID unique identifier of the bitmap. |
7c913512 | 176 | @param client |
4cc4bfaf FM |
177 | wxArtClient identifier of the client (i.e. who is asking for the bitmap). |
178 | This only servers as a hint. | |
7c913512 | 179 | @param size |
4cc4bfaf FM |
180 | Preferred size of the bitmap. The function may return a bitmap of different |
181 | dimensions, it will be automatically rescaled to meet client's request. | |
23324ae1 | 182 | |
4cc4bfaf | 183 | @see CreateIconBundle() |
23324ae1 FM |
184 | */ |
185 | wxBitmap CreateBitmap(const wxArtID& id, | |
186 | const wxArtClient& client, | |
187 | const wxSize& size); | |
188 | ||
189 | /** | |
190 | This method is similar to CreateBitmap() but | |
191 | can be used when a bitmap (or an icon) exists in several sizes. | |
192 | */ | |
193 | wxIconBundle CreateIconBundle(const wxArtID& id, | |
194 | const wxArtClient& client); | |
195 | ||
196 | /** | |
197 | Delete the given @e provider. | |
198 | */ | |
199 | static bool Delete(wxArtProvider* provider); | |
200 | ||
201 | /** | |
202 | Query registered providers for bitmap with given ID. | |
203 | ||
7c913512 | 204 | @param id |
4cc4bfaf | 205 | wxArtID unique identifier of the bitmap. |
7c913512 | 206 | @param client |
4cc4bfaf | 207 | wxArtClient identifier of the client (i.e. who is asking for the bitmap). |
7c913512 | 208 | @param size |
4cc4bfaf | 209 | Size of the returned bitmap or wxDefaultSize if size doesn't matter. |
23324ae1 FM |
210 | |
211 | @returns The bitmap if one of registered providers recognizes the ID or | |
4cc4bfaf | 212 | wxNullBitmap otherwise. |
23324ae1 FM |
213 | */ |
214 | static wxBitmap GetBitmap(const wxArtID& id, | |
215 | const wxArtClient& client = wxART_OTHER, | |
216 | const wxSize& size = wxDefaultSize); | |
217 | ||
218 | //@{ | |
219 | /** | |
7c913512 | 220 | Returns a suitable size hint for the given @e wxArtClient. If |
4cc4bfaf | 221 | @a platform_default is @true, return a size based on the current platform, |
23324ae1 | 222 | otherwise return the size from the topmost wxArtProvider. @e wxDefaultSize may |
7c913512 | 223 | be |
23324ae1 FM |
224 | returned if the client doesn't have a specified size, like wxART_OTHER for |
225 | example. | |
226 | */ | |
227 | static wxIcon GetIcon(const wxArtID& id, | |
228 | const wxArtClient& client = wxART_OTHER, | |
229 | const wxSize& size = wxDefaultSize); | |
7c913512 | 230 | static wxSize GetSizeHint(const wxArtClient& client, |
4cc4bfaf | 231 | bool platform_default = false); |
23324ae1 FM |
232 | //@} |
233 | ||
234 | /** | |
235 | Query registered providers for icon bundle with given ID. | |
236 | ||
7c913512 | 237 | @param id |
4cc4bfaf | 238 | wxArtID unique identifier of the icon bundle. |
7c913512 | 239 | @param client |
4cc4bfaf FM |
240 | wxArtClient identifier of the client (i.e. who is asking for the icon |
241 | bundle). | |
23324ae1 FM |
242 | |
243 | @returns The icon bundle if one of registered providers recognizes the ID | |
4cc4bfaf | 244 | or wxNullIconBundle otherwise. |
23324ae1 FM |
245 | */ |
246 | static wxIconBundle GetIconBundle(const wxArtID& id, | |
247 | const wxArtClient& client = wxART_OTHER); | |
248 | ||
249 | /** | |
250 | Every bitmap and icon bundle are known to wxArtProvider under an unique ID that | |
251 | is used when | |
252 | requesting a resource from it. The ID is represented by wxArtID type and can | |
253 | have one of these predefined values (you can see bitmaps represented by these | |
254 | constants in the artprov sample): | |
255 | ||
256 | wxART_ERROR | |
257 | wxART_QUESTION | |
258 | wxART_WARNING | |
259 | wxART_INFORMATION | |
260 | wxART_ADD_BOOKMARK | |
261 | wxART_DEL_BOOKMARK | |
262 | wxART_HELP_SIDE_PANEL | |
263 | wxART_HELP_SETTINGS | |
264 | wxART_HELP_BOOK | |
265 | wxART_HELP_FOLDER | |
266 | wxART_HELP_PAGE | |
267 | wxART_GO_BACK | |
268 | wxART_GO_FORWARD | |
269 | wxART_GO_UP | |
270 | wxART_GO_DOWN | |
271 | wxART_GO_TO_PARENT | |
272 | wxART_GO_HOME | |
273 | wxART_PRINT | |
274 | wxART_HELP | |
275 | wxART_TIP | |
276 | wxART_REPORT_VIEW | |
277 | wxART_LIST_VIEW | |
278 | wxART_NEW_DIR | |
279 | wxART_FOLDER | |
280 | wxART_FOLDER_OPEN | |
281 | wxART_GO_DIR_UP | |
282 | wxART_EXECUTABLE_FILE | |
283 | wxART_NORMAL_FILE | |
284 | wxART_TICK_MARK | |
285 | wxART_CROSS_MARK | |
286 | wxART_MISSING_IMAGE | |
287 | wxART_NEW | |
288 | wxART_FILE_OPEN | |
289 | wxART_FILE_SAVE | |
290 | wxART_FILE_SAVE_AS | |
291 | wxART_DELETE | |
292 | wxART_COPY | |
293 | wxART_CUT | |
294 | wxART_PASTE | |
295 | wxART_UNDO | |
296 | wxART_REDO | |
297 | wxART_QUIT | |
298 | wxART_FIND | |
299 | wxART_FIND_AND_REPLACE | |
300 | wxART_HARDDISK | |
301 | wxART_FLOPPY | |
302 | wxART_CDROM | |
303 | wxART_REMOVABLE | |
7c913512 | 304 | Additionally, any string recognized by custom art providers registered using |
23324ae1 FM |
305 | Push() may be used. |
306 | */ | |
307 | ||
308 | ||
309 | /** | |
310 | Register new art provider and add it to the bottom of providers stack (i.e. | |
311 | it will be queried as the last one). | |
312 | ||
4cc4bfaf | 313 | @see Push() |
23324ae1 FM |
314 | */ |
315 | static void Insert(wxArtProvider* provider); | |
316 | ||
317 | /** | |
318 | Remove latest added provider and delete it. | |
319 | */ | |
4cc4bfaf | 320 | static bool Pop(); |
23324ae1 FM |
321 | |
322 | /** | |
323 | Register new art provider and add it to the top of providers stack (i.e. it | |
324 | will be queried as the first provider). | |
325 | ||
4cc4bfaf | 326 | @see Insert() |
23324ae1 FM |
327 | */ |
328 | static void Push(wxArtProvider* provider); | |
329 | ||
330 | /** | |
7c913512 | 331 | Remove a provider from the stack if it is on it. The provider is not |
23324ae1 FM |
332 | deleted, unlike when using Delete(). |
333 | */ | |
334 | static bool Remove(wxArtProvider* provider); | |
335 | }; |