]>
git.saurik.com Git - wxWidgets.git/blob - interface/artprov.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxArtProvider
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.
131 @see See the artprov() sample for an example of wxArtProvider usage.
133 class wxArtProvider
: public wxObject
137 The destructor automatically removes the provider from the provider stack used
143 Client is the entity that calls wxArtProvider's GetBitmap or GetIcon
144 function. It is represented by wxClientID type and can have one of these
153 wxART_OTHER (used for all requests that don't fit into any of the categories
155 Client ID servers as a hint to wxArtProvider that is supposed to help it to
156 choose the best looking bitmap. For example it is often desirable to use
157 slightly different icons in menus and toolbars even though they represent the
158 same action (e.g. @c wx_ART_FILE_OPEN). Remember that this is really
159 only a hint for wxArtProvider -- it is common that
161 returns identical bitmap for different @e client values!
163 @see See the artprov() sample for an example of wxArtProvider usage.
168 Derived art provider classes must override this method to create requested art
169 resource. Note that returned bitmaps are cached by wxArtProvider and it is
170 therefore not necessary to optimize CreateBitmap() for speed (e.g. you may
171 create wxBitmap objects from XPMs here).
174 wxArtID unique identifier of the bitmap.
176 wxArtClient identifier of the client (i.e. who is asking for the bitmap).
177 This only servers as a hint.
179 Preferred size of the bitmap. The function may return a bitmap of different
180 dimensions, it will be automatically rescaled to meet client's request.
182 @see CreateIconBundle()
184 wxBitmap
CreateBitmap(const wxArtID
& id
,
185 const wxArtClient
& client
,
189 This method is similar to CreateBitmap() but
190 can be used when a bitmap (or an icon) exists in several sizes.
192 wxIconBundle
CreateIconBundle(const wxArtID
& id
,
193 const wxArtClient
& client
);
196 Delete the given @e provider.
198 static bool Delete(wxArtProvider
* provider
);
201 Query registered providers for bitmap with given ID.
204 wxArtID unique identifier of the bitmap.
206 wxArtClient identifier of the client (i.e. who is asking for the bitmap).
208 Size of the returned bitmap or wxDefaultSize if size doesn't matter.
210 @returns The bitmap if one of registered providers recognizes the ID or
211 wxNullBitmap otherwise.
213 static wxBitmap
GetBitmap(const wxArtID
& id
,
214 const wxArtClient
& client
= wxART_OTHER
,
215 const wxSize
& size
= wxDefaultSize
);
219 Returns a suitable size hint for the given @e wxArtClient. If
220 @a platform_default is @true, return a size based on the current platform,
221 otherwise return the size from the topmost wxArtProvider. @e wxDefaultSize may
223 returned if the client doesn't have a specified size, like wxART_OTHER for
226 static wxIcon
GetIcon(const wxArtID
& id
,
227 const wxArtClient
& client
= wxART_OTHER
,
228 const wxSize
& size
= wxDefaultSize
);
229 static wxSize
GetSizeHint(const wxArtClient
& client
,
230 bool platform_default
= false);
234 Query registered providers for icon bundle with given ID.
237 wxArtID unique identifier of the icon bundle.
239 wxArtClient identifier of the client (i.e. who is asking for the icon
242 @returns The icon bundle if one of registered providers recognizes the ID
243 or wxNullIconBundle otherwise.
245 static wxIconBundle
GetIconBundle(const wxArtID
& id
,
246 const wxArtClient
& client
= wxART_OTHER
);
249 Every bitmap and icon bundle are known to wxArtProvider under an unique ID that
251 requesting a resource from it. The ID is represented by wxArtID type and can
252 have one of these predefined values (you can see bitmaps represented by these
253 constants in the artprov() sample):
261 wxART_HELP_SIDE_PANEL
281 wxART_EXECUTABLE_FILE
298 wxART_FIND_AND_REPLACE
303 Additionally, any string recognized by custom art providers registered using
309 Register new art provider and add it to the bottom of providers stack (i.e.
310 it will be queried as the last one).
314 static void Insert(wxArtProvider
* provider
);
317 Remove latest added provider and delete it.
322 Register new art provider and add it to the top of providers stack (i.e. it
323 will be queried as the first provider).
327 static void Push(wxArtProvider
* provider
);
330 Remove a provider from the stack if it is on it. The provider is not
331 deleted, unlike when using Delete().
333 static bool Remove(wxArtProvider
* provider
);