wxartproviderwxartprovider class is used to customize the look of wxwidgets application. when wxwidgets needs to display an icon or a bitmap (e.g. in the standard file dialog), it does not use a hard-coded resource but asks wxartprovider for it instead. this way users can plug in their own wxartprovider class and easily replace standard art with their own version. all that is needed is to derive a class from wxartprovider, override its createbitmap method and register the provider with wxartprovider::push:
class myprovider : public wxartprovider { protected: wxbitmap createbitmap(const wxartid& id, const wxartclient& client, const wxsize size) { ... } }; ... wxartprovider::push(new myprovider);there's another way of taking advantage of this class: you can use it in your code and use platform native icons as provided by wxartprovider::getbitmap or wxartprovider::geticon (nb: this is not yet really possible as of wxwidgets 2.3.3, the set of wxartprovider bitmaps is too small).
identifying art resources
identifying art resourcesevery bitmap is known to wxartprovider under an unique id that is used by when requesting a resource from it. the id is represented by wxartid type and can have one of these predefined values (you can see bitmaps represented by these constants in the artprov sample):
additionally, any string recognized by custom art providers registered using push may be used. gtk+ note when running under gtk+ 2, gtk+ stock item ids (e.g. "gtk-cdrom") may be used as well. additionally, if wxgtk was compiled against gtk+ >= 2.4, then it is also possible to load icons from current icon theme by specifying their name (without extension and directory components). icon themes recognized by gtk+ follow the freedesktop.org icon themes specification. note that themes are not guaranteed to contain all icons, so wxartprovider may return wxnullbitmap or wxnullicon. default theme is typically installed in /usr/share/icons/hicolor.
clientsclient is the entity that calls wxartprovider's getbitmap or geticon function. it is represented by wxclientid type and can have one of these values:
see also see the artprov sample for an example of wxartprovider usage. derived from include files <wx/artprov.h> members
wxartprovider::~wxartprovider~wxartprovider() the destructor automatically removes the provider from the provider stack used by getbitmap.
wxartprovider::createbitmapwxbitmap createbitmap(const wxartid& id, const wxartclient& client, const wxsize& size) derived art provider classes must override this method to create requested art resource. note that returned bitmaps are cached by wxartprovider and it is therefore not necessary to optimize createbitmap for speed (e.g. you may create wxbitmap objects from xpms here). parameters id
client
size
note this is not part of wxartprovider's public api, use wxartprovider::getbitmap or wxartprovider::geticon to query wxartprovider for a resource.
wxartprovider::deletestatic bool delete(wxartprovider* provider) delete the given provider.
wxartprovider::getbitmapstatic wxbitmap getbitmap(const wxartid& id, const wxartclient& client = wxart_other, const wxsize& size = wxdefaultsize) query registered providers for bitmap with given id. parameters id
client
size
return value the bitmap if one of registered providers recognizes the id or wxnullbitmap otherwise.
wxartprovider::geticonstatic wxicon geticon(const wxartid& id, const wxartclient& client = wxart_other, const wxsize& size = wxdefaultsize) same as wxartprovider::getbitmap, but return a wxicon object (or wxnullicon on failure). static wxsize getsizehint(const wxartclient& client, bool platform_default = false) returns a suitable size hint for the given wxartclient. if platform_default is true, return a size based on the current platform, otherwise return the size from the topmost wxartprovider. wxdefaultsize may be returned if the client doesn't have a specified size, like wxart_other for example.
wxartprovider::insertstatic void insert(wxartprovider* provider) register new art provider and add it to the bottom of providers stack (i.e. it will be queried as the last one). see also
wxartprovider::popstatic bool pop() remove latest added provider and delete it.
wxartprovider::pushstatic void push(wxartprovider* provider) register new art provider and add it to the top of providers stack (i.e. it will be queried as the first provider). see also
wxartprovider::removestatic bool remove(wxartprovider* provider) remove a provider from the stack if it is on it. the provider is not deleted, unlike when using delete().
|