]>
git.saurik.com Git - wxWidgets.git/blob - interface/artprov.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: documentation for wxArtProvider class
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
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
25 class MyProvider : public wxArtProvider
28 wxBitmap CreateBitmap(const wxArtID& id,
29 const wxArtClient& client,
32 // optionally override this one as well
33 wxIconBundle CreateIconBundle(const wxArtID& id,
34 const wxArtClient& client)
38 wxArtProvider::Push(new MyProvider);
41 If you need bitmap images (of the same artwork) that should be displayed at
43 you should probably consider overriding wxArtProvider::CreateIconBundle
44 and supplying icon bundles that contain different bitmap sizes.
46 There's another way of taking advantage of this class: you can use it in your
48 platform native icons as provided by wxArtProvider::GetBitmap or
49 wxArtProvider::GetIcon (NB: this is not yet really
50 possible as of wxWidgets 2.3.3, the set of wxArtProvider bitmaps is too
54 wxArtProvider::~wxArtProvider
55 wxArtProvider::CreateBitmap
56 wxArtProvider::CreateIconBundle
58 wxArtProvider::GetBitmap
59 wxArtProvider::GetIconBundle
60 wxArtProvider::GetIcon
67 Identifying art resources
69 Every bitmap and icon bundle are known to wxArtProvider under an unique ID that
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):
101 wxART_EXECUTABLE_FILE
118 wxART_FIND_AND_REPLACE
125 Additionally, any string recognized by custom art providers registered using
126 wxArtProvider::Push may be used.
132 See the artprov sample for an example of wxArtProvider usage.
134 class wxArtProvider
: public wxObject
138 The destructor automatically removes the provider from the provider stack used
144 Client is the entity that calls wxArtProvider's GetBitmap or GetIcon
145 function. It is represented by wxClientID type and can have one of these
155 wxART_OTHER (used for all requests that don't fit into any of the categories
158 Client ID servers as a hint to wxArtProvider that is supposed to help it to
159 choose the best looking bitmap. For example it is often desirable to use
160 slightly different icons in menus and toolbars even though they represent the
161 same action (e.g. @c wx_ART_FILE_OPEN). Remember that this is really
162 only a hint for wxArtProvider -- it is common that
164 returns identical bitmap for different @e client values!
166 @sa See the artprov sample for an example of wxArtProvider usage.
171 Derived art provider classes must override this method to create requested art
172 resource. Note that returned bitmaps are cached by wxArtProvider and it is
173 therefore not necessary to optimize CreateBitmap() for speed (e.g. you may
174 create wxBitmap objects from XPMs here).
177 wxArtID unique identifier of the bitmap.
180 wxArtClient identifier of the client (i.e. who is asking for the bitmap).
181 This only servers as a hint.
184 Preferred size of the bitmap. The function may return a bitmap of different
185 dimensions, it will be automatically rescaled to meet client's request.
187 @sa CreateIconBundle()
189 wxBitmap
CreateBitmap(const wxArtID
& id
,
190 const wxArtClient
& client
,
194 This method is similar to CreateBitmap() but
195 can be used when a bitmap (or an icon) exists in several sizes.
197 wxIconBundle
CreateIconBundle(const wxArtID
& id
,
198 const wxArtClient
& client
);
201 Delete the given @e provider.
203 static bool Delete(wxArtProvider
* provider
);
206 Query registered providers for bitmap with given ID.
209 wxArtID unique identifier of the bitmap.
212 wxArtClient identifier of the client (i.e. who is asking for the bitmap).
215 Size of the returned bitmap or wxDefaultSize if size doesn't matter.
217 @returns The bitmap if one of registered providers recognizes the ID or
218 wxNullBitmap otherwise.
220 static wxBitmap
GetBitmap(const wxArtID
& id
,
221 const wxArtClient
& client
= wxART_OTHER
,
222 const wxSize
& size
= wxDefaultSize
);
226 Returns a suitable size hint for the given @e wxArtClient. If
227 @e platform_default is @true, return a size based on the current platform,
228 otherwise return the size from the topmost wxArtProvider. @e wxDefaultSize may
230 returned if the client doesn't have a specified size, like wxART_OTHER for
233 static wxIcon
GetIcon(const wxArtID
& id
,
234 const wxArtClient
& client
= wxART_OTHER
,
235 const wxSize
& size
= wxDefaultSize
);
236 static wxSize
GetSizeHint(const wxArtClient
& client
,
237 bool platform_default
= @
false);
241 Query registered providers for icon bundle with given ID.
244 wxArtID unique identifier of the icon bundle.
247 wxArtClient identifier of the client (i.e. who is asking for the icon bundle).
249 @returns The icon bundle if one of registered providers recognizes the ID
250 or wxNullIconBundle otherwise.
252 static wxIconBundle
GetIconBundle(const wxArtID
& id
,
253 const wxArtClient
& client
= wxART_OTHER
);
256 Every bitmap and icon bundle are known to wxArtProvider under an unique ID that
258 requesting a resource from it. The ID is represented by wxArtID type and can
259 have one of these predefined values (you can see bitmaps represented by these
260 constants in the artprov sample):
268 wxART_HELP_SIDE_PANEL
288 wxART_EXECUTABLE_FILE
305 wxART_FIND_AND_REPLACE
311 Additionally, any string recognized by custom art providers registered using
317 Register new art provider and add it to the bottom of providers stack (i.e.
318 it will be queried as the last one).
322 static void Insert(wxArtProvider
* provider
);
325 Remove latest added provider and delete it.
327 #define static bool Pop() /* implementation is private */
330 Register new art provider and add it to the top of providers stack (i.e. it
331 will be queried as the first provider).
335 static void Push(wxArtProvider
* provider
);
338 Remove a provider from the stack if it is on it. The provider is not
339 deleted, unlike when using Delete().
341 static bool Remove(wxArtProvider
* provider
);