## wxArtProvider

wxArtProvider class is used to customize the look of wxWindows application. When wxWindows need to display an icon or a bitmap (e.g. in the standard file dialog), it does not use hard-coded resource but asks wxArtProvider for it instead. This way the users can plug in own wxArtProvider class and easily replace standard art with his/her own version. It is easy thing to do: all that is needed is to derive a class from wxArtProvider, override it's CreateBitmap method and register the provider with wxArtProvider::PushProvider:

      class MyProvider : public wxArtProvider
      {
      protected:
        wxBitmap CreateBitmap(const wxArtID& id,
                              const wxArtClient& client,
                              const wxSize size)
        { ... }
      };
      ...
      wxArtProvider::PushProvider(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 wxWindows 2.3.3, the set of wxArtProvider bitmaps is too small).

Identifying art resources
Clients
wxArtProvider::CreateBitmap
wxArtProvider::GetBitmap
wxArtProvider::GetIcon
wxArtProvider::PopProvider
wxArtProvider::PushProvider
wxArtProvider::RemoveProvider

### Identifying art resources

Every 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):

- wxART_ADD_BOOKMARK
- wxART_DEL_BOOKMARK
- wxART_HELP_SIDE_PANEL
- wxART_HELP_SETTINGS
- wxART_HELP_BOOK
- wxART_HELP_FOLDER
- wxART_HELP_PAGE
- wxART_GO_BACK
- wxART_GO_FORWARD
- wxART_GO_UP
- wxART_GO_DOWN
- wxART_GO_TO_PARENT
- wxART_GO_HOME
- wxART_FILE_OPEN
- wxART_PRINT
- wxART_HELP
- wxART_TIP
- wxART_REPORT_VIEW
- wxART_LIST_VIEW
- wxART_NEW_DIR
- wxART_FOLDER
- wxART_GO_DIR_UP
- wxART_EXECUTABLE_FILE
- wxART_NORMAL_FILE
- wxART_TICK_MARK
- wxART_CROSS_MARK
- wxART_ERROR
- wxART_QUESTION
- wxART_WARNING
- wxART_INFORMATION

### Clients

Client is the entity that calls wxArtProvider's GetBitmap or GetIcon function. It is represented by wxClientID type and can have one of these values:

- wxART_TOOLBAR
- wxART_MENU
- wxART_FRAME_ICON
- wxART_CMN_DIALOG
- wxART_HELP_BROWSER
- wxART_MESSAGE_BOX
- wxART_OTHER (used for all requests that don't fit into any of the categories above)

Client ID servers as a hint to wxArtProvider that is supposed to help it to choose the best looking bitmap. For example it is often desirable to use slightly different icons in menus and toolbars even though they represent the same action (e.g. `wx_ART_FILE_OPEN`). Remember that this is really only a hint for wxArtProvider -- it is common that wxArtProvider::GetBitmap returns identical bitmap for different client values!

See also

See the artprov sample for an example of wxArtProvider usage.

Derived from

wxObject

Include files

<wx/artprov.h>

Members

### wxArtProvider::CreateBitmap

wxBitmap 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 neccessary to optimize CreateBitmap for speed (e.g. you may create wxBitmap objects from XPMs here).

Parameters

id

wxArtID unique identifier of the bitmap.

client

wxArtClient identifier of the client (i.e. who is asking for the bitmap). This only servers as a hint.

size

Prefered size of the bitmap. The function may return a bitmap of different dimensions, it will be automatically rescaled to meet client's request.

Note

This is not part of wxArtProvider's public API, use wxArtProvider::GetBitmap or wxArtProvider::GetIcon to query wxArtProvider for a resource.

### wxArtProvider::GetBitmap

static wxBitmap GetBitmap(const wxArtID& id, const wxArtClient& client = wxART_OTHER, const wxSize& size = wxDefaultSize)

Query registered providers for bitmap with given ID.

Parameters

id

wxArtID unique identifier of the bitmap.

client

wxArtClient identifier of the client (i.e. who is asking for the bitmap).

size

Size of the returned bitmap or `wxDefaultSize` if size doesn't matter.

Return value

The bitmap if one of registered providers recognizes the ID or wxNullBitmap otherwise.

### wxArtProvider::GetIcon

static 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).

### wxArtProvider::PopProvider

static bool PopProvider()

Remove latest added provider and delete it.

### wxArtProvider::PushProvider

static void PushProvider(wxArtProvider* provider)

Register new art provider (add it to the top of providers stack).

### wxArtProvider::RemoveProvider

static bool RemoveProvider(wxArtProvider* provider)

Remove a provider from the stack. The provider must have been added previously and is not deleted.