]>
git.saurik.com Git - wxWidgets.git/blob - interface/wx/artprov.h
   1 ///////////////////////////////////////////////////////////////////////////// 
   3 // Purpose:     interface of wxArtProvider 
   4 // Author:      wxWidgets team 
   6 // Licence:     wxWindows license 
   7 ///////////////////////////////////////////////////////////////////////////// 
  12     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. 
  19     All that is needed is to derive a class from wxArtProvider, override either its 
  20     wxArtProvider::CreateBitmap() and/or its wxArtProvider::CreateIconBundle() methods 
  21     and register the provider with wxArtProvider::Push(): 
  24       class MyProvider : public wxArtProvider 
  27         wxBitmap CreateBitmap(const wxArtID& id, 
  28                               const wxArtClient& client, 
  31         // optionally override this one as well 
  32         wxIconBundle CreateIconBundle(const wxArtID& id, 
  33                                       const wxArtClient& client) 
  37       wxArtProvider::Push(new MyProvider); 
  40     If you need bitmap images (of the same artwork) that should be displayed at 
  41     different sizes you should probably consider overriding wxArtProvider::CreateIconBundle 
  42     and supplying icon bundles that contain different bitmap sizes. 
  44     There's another way of taking advantage of this class: you can use it in your 
  45     code and use platform native icons as provided by wxArtProvider::GetBitmap or 
  46     wxArtProvider::GetIcon. 
  48     @todo IS THIS NB TRUE? 
  49     (@note this is not yet really possible as of wxWidgets 2.3.3, the set of wxArtProvider 
  50      bitmaps is too small). 
  52     @section artprovider_identify Identifying art resources 
  54     Every bitmap and icon bundle are known to wxArtProvider under an unique ID that 
  55     is used when requesting a resource from it. The ID is represented by wxArtID type 
  56     and can have one of these predefined values (you can see bitmaps represented by these 
  57     constants in the @ref page_samples_artprov): 
  65      @li wxART_ADD_BOOKMARK 
  66      @li wxART_DEL_BOOKMARK 
  67      @li wxART_HELP_SIDE_PANEL 
  68      @li wxART_HELP_SETTINGS 
  77      @li wxART_GO_TO_PARENT 
  88      @li wxART_EXECUTABLE_FILE 
  93      @li wxART_MISSING_IMAGE 
  97      @li wxART_FILE_SAVE_AS 
 106      @li wxART_FIND_AND_REPLACE 
 114     Additionally, any string recognized by custom art providers registered using 
 115     wxArtProvider::Push may be used. 
 118     When running under GTK+ 2, GTK+ stock item IDs (e.g. @c "gtk-cdrom") may be used 
 119     as well. Additionally, if wxGTK was compiled against GTK+ >= 2.4, then it is also 
 120     possible to load icons from current icon theme by specifying their name (without 
 121     extension and directory components). 
 122     Icon themes recognized by GTK+ follow the freedesktop.org Icon Themes specification 
 123     (see http://freedesktop.org/Standards/icon-theme-spec). 
 124     Note that themes are not guaranteed to contain all icons, so wxArtProvider may 
 125     return ::wxNullBitmap or ::wxNullIcon. 
 126     The default theme is typically installed in @c /usr/share/icons/hicolor. 
 129     @section artprovider_clients Clients 
 131     Client is the entity that calls wxArtProvider's GetBitmap or GetIcon function. 
 132     It is represented by wxClientID type and can have one of these values: 
 139     @li wxART_HELP_BROWSER 
 140     @li wxART_MESSAGE_BOX 
 141     @li wxART_OTHER (used for all requests that don't fit into any of the 
 144     Client ID servers as a hint to wxArtProvider that is supposed to help it to 
 145     choose the best looking bitmap. For example it is often desirable to use 
 146     slightly different icons in menus and toolbars even though they represent 
 147     the same action (e.g. wxART_FILE_OPEN). Remember that this is really only a 
 148     hint for wxArtProvider -- it is common that wxArtProvider::GetBitmap returns 
 149     identical bitmap for different client values! 
 154     @see the @ref page_samples_artprov for an example of wxArtProvider usage. 
 156 class wxArtProvider 
: public wxObject
 
 160         The destructor automatically removes the provider from the provider stack used 
 163     virtual ~wxArtProvider(); 
 166         Delete the given @a provider. 
 168     static bool Delete(wxArtProvider
* provider
); 
 171         Query registered providers for bitmap with given ID. 
 174             wxArtID unique identifier of the bitmap. 
 176             wxArtClient identifier of the client (i.e. who is asking for the bitmap). 
 178             Size of the returned bitmap or wxDefaultSize if size doesn't matter. 
 180         @return The bitmap if one of registered providers recognizes the ID or 
 181                 wxNullBitmap otherwise. 
 183     static wxBitmap 
GetBitmap(const wxArtID
& id
, 
 184                               const wxArtClient
& client 
= wxART_OTHER
, 
 185                               const wxSize
& size 
= wxDefaultSize
); 
 188         Same as wxArtProvider::GetBitmap, but return a wxIcon object 
 189         (or ::wxNullIcon on failure). 
 191     static wxIcon 
GetIcon(const wxArtID
& id
, 
 192                           const wxArtClient
& client 
= wxART_OTHER
, 
 193                           const wxSize
& size 
= wxDefaultSize
); 
 196         Returns native icon size for use specified by @a client hint. 
 198         If the platform has no commonly used default for this use or if 
 199         @a client is not recognized, returns wxDefaultSize. 
 201         @note In some cases, a platform may have @em several appropriate 
 202               native sizes (for example, wxART_FRAME_ICON for frame icons). 
 203               In that case, this method returns only one of them, picked 
 208     static wxSize 
GetNativeSizeHint(const wxArtClient
& client
); 
 211         Returns a suitable size hint for the given @e wxArtClient. 
 213         If @a platform_default is @true, return a size based on the current 
 214         platform using GetNativeSizeHint(), otherwise return the size from the 
 215         topmost wxArtProvider. @e wxDefaultSize may be returned if the client 
 216         doesn't have a specified size, like wxART_OTHER for example. 
 218         @see GetNativeSizeHint() 
 220     static wxSize 
GetSizeHint(const wxArtClient
& client
, 
 221                               bool platform_default 
= false); 
 224         Query registered providers for icon bundle with given ID. 
 227             wxArtID unique identifier of the icon bundle. 
 229             wxArtClient identifier of the client (i.e. who is asking for the icon 
 232         @return The icon bundle if one of registered providers recognizes the ID 
 233                 or wxNullIconBundle otherwise. 
 235     static wxIconBundle 
GetIconBundle(const wxArtID
& id
, 
 236                                       const wxArtClient
& client 
= wxART_OTHER
); 
 239         Returns true if the platform uses native icons provider that should 
 240         take precedence over any customizations. 
 242         This is true for any platform that has user-customizable icon themes, 
 243         currently only wxGTK. 
 245         A typical use for this method is to decide whether a custom art provider 
 246         should be plugged in using Push() or PushBack(). 
 250     static bool HasNativeProvider(); 
 253         @deprecated Use PushBack() instead. 
 255     static void Insert(wxArtProvider
* provider
); 
 258         Remove latest added provider and delete it. 
 263         Register new art provider and add it to the top of providers stack 
 264         (i.e. it will be queried as the first provider). 
 268     static void Push(wxArtProvider
* provider
); 
 271         Register new art provider and add it to the bottom of providers stack. 
 272         In other words, it will be queried as the last one, after all others, 
 273         including the default provider. 
 279     static void PushBack(wxArtProvider
* provider
); 
 282         Remove a provider from the stack if it is on it. The provider is not 
 283         deleted, unlike when using Delete(). 
 285     static bool Remove(wxArtProvider
* provider
); 
 290         Derived art provider classes must override this method to create requested art 
 291         resource. Note that returned bitmaps are cached by wxArtProvider and it is 
 292         therefore not necessary to optimize CreateBitmap() for speed (e.g. you may 
 293         create wxBitmap objects from XPMs here). 
 296             wxArtID unique identifier of the bitmap. 
 298             wxArtClient identifier of the client (i.e. who is asking for the bitmap). 
 299             This only servers as a hint. 
 301             Preferred size of the bitmap. The function may return a bitmap of different 
 302             dimensions, it will be automatically rescaled to meet client's request. 
 305         This is not part of wxArtProvider's public API, use wxArtProvider::GetBitmap 
 306         or wxArtProvider::GetIconBundle or wxArtProvider::GetIcon to query wxArtProvider 
 309         @see CreateIconBundle() 
 311     virtual wxBitmap 
CreateBitmap(const wxArtID
& id
, 
 312                                   const wxArtClient
& client
, 
 316         This method is similar to CreateBitmap() but can be used when a bitmap 
 317         (or an icon) exists in several sizes. 
 319     virtual wxIconBundle 
CreateIconBundle(const wxArtID
& id
, 
 320                                           const wxArtClient
& client
);