2008-03-08 13:52:38 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: artprov.h
|
2008-03-10 15:24:38 +00:00
|
|
|
// Purpose: interface of wxArtProvider
|
2008-03-08 13:52:38 +00:00
|
|
|
// Author: wxWidgets team
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Licence: wxWindows license
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/**
|
|
|
|
@class wxArtProvider
|
|
|
|
@wxheader{artprov.h}
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
wxArtProvider class is used to customize the look of wxWidgets application.
|
2008-03-14 15:35:10 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
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
|
2008-03-14 15:35:10 +00:00
|
|
|
replace standard art with their own version.
|
|
|
|
|
|
|
|
All that is needed is to derive a class from wxArtProvider, override either its
|
|
|
|
wxArtProvider::CreateBitmap and/or its wxArtProvider::CreateIconBundle methods
|
|
|
|
and register the provider with wxArtProvider::Push:
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
@code
|
2008-03-14 15:35:10 +00:00
|
|
|
class MyProvider : public wxArtProvider
|
2008-03-08 13:52:38 +00:00
|
|
|
{
|
|
|
|
protected:
|
2008-03-08 14:43:31 +00:00
|
|
|
wxBitmap CreateBitmap(const wxArtID& id,
|
2008-03-08 13:52:38 +00:00
|
|
|
const wxArtClient& client,
|
|
|
|
const wxSize size)
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
// optionally override this one as well
|
|
|
|
wxIconBundle CreateIconBundle(const wxArtID& id,
|
|
|
|
const wxArtClient& client)
|
|
|
|
{ ... }
|
|
|
|
};
|
|
|
|
...
|
|
|
|
wxArtProvider::Push(new MyProvider);
|
|
|
|
@endcode
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
If you need bitmap images (of the same artwork) that should be displayed at
|
2008-03-14 15:35:10 +00:00
|
|
|
different sizes you should probably consider overriding wxArtProvider::CreateIconBundle
|
2008-03-08 13:52:38 +00:00
|
|
|
and supplying icon bundles that contain different bitmap sizes.
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
There's another way of taking advantage of this class: you can use it in your
|
2008-03-14 15:35:10 +00:00
|
|
|
code and use platform native icons as provided by wxArtProvider::GetBitmap or
|
|
|
|
wxArtProvider::GetIcon.
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-14 15:35:10 +00:00
|
|
|
@todo IS THIS NB TRUE?
|
|
|
|
(NB: this is not yet really possible as of wxWidgets 2.3.3, the set of wxArtProvider
|
|
|
|
bitmaps is too small).
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-14 15:35:10 +00:00
|
|
|
@section wxartprovider_identify Identifying art resources
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
Every bitmap and icon bundle are known to wxArtProvider under an unique ID that
|
2008-03-14 15:35:10 +00:00
|
|
|
is used 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 @ref page_utils_samples_artprovider):
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-14 15:35:10 +00:00
|
|
|
<table>
|
|
|
|
<tr><td>
|
|
|
|
@li wxART_ERROR
|
|
|
|
@li wxART_QUESTION
|
|
|
|
@li wxART_WARNING
|
|
|
|
@li wxART_INFORMATION
|
|
|
|
@li wxART_ADD_BOOKMARK
|
|
|
|
@li wxART_DEL_BOOKMARK
|
|
|
|
@li wxART_HELP_SIDE_PANEL
|
|
|
|
@li wxART_HELP_SETTINGS
|
|
|
|
@li wxART_HELP_BOOK
|
|
|
|
@li wxART_HELP_FOLDER
|
|
|
|
@li wxART_HELP_PAGE
|
|
|
|
@li wxART_GO_BACK
|
|
|
|
@li wxART_GO_FORWARD
|
|
|
|
@li wxART_GO_UP
|
|
|
|
</td><td>
|
|
|
|
@li wxART_GO_DOWN
|
|
|
|
@li wxART_GO_TO_PARENT
|
|
|
|
@li wxART_GO_HOME
|
|
|
|
@li wxART_PRINT
|
|
|
|
@li wxART_HELP
|
|
|
|
@li wxART_TIP
|
|
|
|
@li wxART_REPORT_VIEW
|
|
|
|
@li wxART_LIST_VIEW
|
|
|
|
@li wxART_NEW_DIR
|
|
|
|
@li wxART_FOLDER
|
|
|
|
@li wxART_FOLDER_OPEN
|
|
|
|
@li wxART_GO_DIR_UP
|
|
|
|
@li wxART_EXECUTABLE_FILE
|
|
|
|
@li wxART_NORMAL_FILE
|
|
|
|
@li wxART_TICK_MARK
|
|
|
|
@li wxART_CROSS_MARK
|
|
|
|
</td><td>
|
|
|
|
@li wxART_MISSING_IMAGE
|
|
|
|
@li wxART_NEW
|
|
|
|
@li wxART_FILE_OPEN
|
|
|
|
@li wxART_FILE_SAVE
|
|
|
|
@li wxART_FILE_SAVE_AS
|
|
|
|
@li wxART_DELETE
|
|
|
|
@li wxART_COPY
|
|
|
|
@li wxART_CUT
|
|
|
|
@li wxART_PASTE
|
|
|
|
@li wxART_UNDO
|
|
|
|
@li wxART_REDO
|
|
|
|
@li wxART_QUIT
|
|
|
|
@li wxART_FIND
|
|
|
|
@li wxART_FIND_AND_REPLACE
|
|
|
|
@li wxART_HARDDISK
|
|
|
|
@li wxART_FLOPPY
|
|
|
|
@li wxART_CDROM
|
|
|
|
@li wxART_REMOVABLE
|
|
|
|
</td></tr>
|
|
|
|
</table>
|
2008-03-08 14:43:31 +00:00
|
|
|
|
|
|
|
Additionally, any string recognized by custom art providers registered using
|
2008-03-08 13:52:38 +00:00
|
|
|
wxArtProvider::Push may be used.
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-14 15:35:10 +00:00
|
|
|
@note
|
|
|
|
When running under GTK+ 2, GTK+ stock item IDs (e.g. @c "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
|
|
|
|
(see http://freedesktop.org/Standards/icon-theme-spec).
|
|
|
|
Note that themes are not guaranteed to contain all icons, so wxArtProvider may
|
|
|
|
return ::wxNullBitmap or ::wxNullIcon.
|
|
|
|
The default theme is typically installed in @c /usr/share/icons/hicolor.
|
|
|
|
|
|
|
|
|
|
|
|
@section wxartprovider_clients 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:
|
|
|
|
|
|
|
|
@li wxART_TOOLBAR
|
|
|
|
@li wxART_MENU
|
|
|
|
@li wxART_BUTTON
|
|
|
|
@li wxART_FRAME_ICON
|
|
|
|
@li wxART_CMN_DIALOG
|
|
|
|
@li wxART_HELP_BROWSER
|
|
|
|
@li wxART_MESSAGE_BOX
|
|
|
|
@li 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. wxART_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!
|
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
@library{wxcore}
|
2008-03-14 15:35:10 +00:00
|
|
|
@category{misc,data}
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-14 15:35:10 +00:00
|
|
|
@see the @ref page_utils_samples_artprovider for an example of wxArtProvider usage.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
class wxArtProvider : public wxObject
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
The destructor automatically removes the provider from the provider stack used
|
|
|
|
by GetBitmap().
|
|
|
|
*/
|
|
|
|
~wxArtProvider();
|
|
|
|
|
|
|
|
/**
|
|
|
|
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).
|
|
|
|
|
2008-03-08 14:43:31 +00:00
|
|
|
@param id
|
2008-03-09 12:33:59 +00:00
|
|
|
wxArtID unique identifier of the bitmap.
|
2008-03-08 14:43:31 +00:00
|
|
|
@param client
|
2008-03-09 12:33:59 +00:00
|
|
|
wxArtClient identifier of the client (i.e. who is asking for the bitmap).
|
|
|
|
This only servers as a hint.
|
2008-03-08 14:43:31 +00:00
|
|
|
@param size
|
2008-03-09 12:33:59 +00:00
|
|
|
Preferred size of the bitmap. The function may return a bitmap of different
|
|
|
|
dimensions, it will be automatically rescaled to meet client's request.
|
2008-03-14 15:35:10 +00:00
|
|
|
|
|
|
|
@note
|
|
|
|
This is not part of wxArtProvider's public API, use wxArtProvider::GetBitmap
|
|
|
|
or wxArtProvider::GetIconBundle or wxArtProvider::GetIcon to query wxArtProvider
|
|
|
|
for a resource.
|
2008-03-08 13:52:38 +00:00
|
|
|
|
2008-03-09 12:33:59 +00:00
|
|
|
@see CreateIconBundle()
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
wxBitmap CreateBitmap(const wxArtID& id,
|
|
|
|
const wxArtClient& client,
|
|
|
|
const wxSize& size);
|
|
|
|
|
|
|
|
/**
|
2008-03-14 15:35:10 +00:00
|
|
|
This method is similar to CreateBitmap() but can be used when a bitmap
|
|
|
|
(or an icon) exists in several sizes.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
wxIconBundle CreateIconBundle(const wxArtID& id,
|
|
|
|
const wxArtClient& client);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Delete the given @e provider.
|
|
|
|
*/
|
|
|
|
static bool Delete(wxArtProvider* provider);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Query registered providers for bitmap with given ID.
|
|
|
|
|
2008-03-08 14:43:31 +00:00
|
|
|
@param id
|
2008-03-09 12:33:59 +00:00
|
|
|
wxArtID unique identifier of the bitmap.
|
2008-03-08 14:43:31 +00:00
|
|
|
@param client
|
2008-03-09 12:33:59 +00:00
|
|
|
wxArtClient identifier of the client (i.e. who is asking for the bitmap).
|
2008-03-08 14:43:31 +00:00
|
|
|
@param size
|
2008-03-09 12:33:59 +00:00
|
|
|
Size of the returned bitmap or wxDefaultSize if size doesn't matter.
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
@returns The bitmap if one of registered providers recognizes the ID or
|
2008-03-09 12:33:59 +00:00
|
|
|
wxNullBitmap otherwise.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
static wxBitmap GetBitmap(const wxArtID& id,
|
|
|
|
const wxArtClient& client = wxART_OTHER,
|
|
|
|
const wxSize& size = wxDefaultSize);
|
|
|
|
|
2008-03-14 15:35:10 +00:00
|
|
|
/**
|
|
|
|
Same as wxArtProvider::GetBitmap, but return a wxIcon object
|
|
|
|
(or ::wxNullIcon on failure).
|
|
|
|
*/
|
|
|
|
static wxIcon GetIcon(const wxArtID& id,
|
|
|
|
const wxArtClient& client = wxART_OTHER,
|
|
|
|
const wxSize& size = wxDefaultSize);
|
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
/**
|
2008-03-08 14:43:31 +00:00
|
|
|
Returns a suitable size hint for the given @e wxArtClient. If
|
2008-03-09 12:33:59 +00:00
|
|
|
@a platform_default is @true, return a size based on the current platform,
|
2008-03-08 13:52:38 +00:00
|
|
|
otherwise return the size from the topmost wxArtProvider. @e wxDefaultSize may
|
2008-03-14 15:35:10 +00:00
|
|
|
be returned if the client doesn't have a specified size, like wxART_OTHER for
|
2008-03-08 13:52:38 +00:00
|
|
|
example.
|
|
|
|
*/
|
2008-03-08 14:43:31 +00:00
|
|
|
static wxSize GetSizeHint(const wxArtClient& client,
|
2008-03-09 12:33:59 +00:00
|
|
|
bool platform_default = false);
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Query registered providers for icon bundle with given ID.
|
|
|
|
|
2008-03-08 14:43:31 +00:00
|
|
|
@param id
|
2008-03-09 12:33:59 +00:00
|
|
|
wxArtID unique identifier of the icon bundle.
|
2008-03-08 14:43:31 +00:00
|
|
|
@param client
|
2008-03-09 12:33:59 +00:00
|
|
|
wxArtClient identifier of the client (i.e. who is asking for the icon
|
2008-03-14 15:35:10 +00:00
|
|
|
bundle).
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
@returns The icon bundle if one of registered providers recognizes the ID
|
2008-03-09 12:33:59 +00:00
|
|
|
or wxNullIconBundle otherwise.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
static wxIconBundle GetIconBundle(const wxArtID& id,
|
|
|
|
const wxArtClient& client = wxART_OTHER);
|
|
|
|
|
|
|
|
/**
|
2008-03-14 15:35:10 +00:00
|
|
|
Register new art provider and add it to the bottom of providers stack
|
|
|
|
(i.e. it will be queried as the last one).
|
2008-03-08 13:52:38 +00:00
|
|
|
|
2008-03-09 12:33:59 +00:00
|
|
|
@see Push()
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
static void Insert(wxArtProvider* provider);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Remove latest added provider and delete it.
|
|
|
|
*/
|
2008-03-09 12:33:59 +00:00
|
|
|
static bool Pop();
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2008-03-14 15:35:10 +00:00
|
|
|
Register new art provider and add it to the top of providers stack
|
|
|
|
(i.e. it will be queried as the first provider).
|
2008-03-08 13:52:38 +00:00
|
|
|
|
2008-03-09 12:33:59 +00:00
|
|
|
@see Insert()
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
static void Push(wxArtProvider* provider);
|
|
|
|
|
|
|
|
/**
|
2008-03-08 14:43:31 +00:00
|
|
|
Remove a provider from the stack if it is on it. The provider is not
|
2008-03-08 13:52:38 +00:00
|
|
|
deleted, unlike when using Delete().
|
|
|
|
*/
|
|
|
|
static bool Remove(wxArtProvider* provider);
|
|
|
|
};
|
2008-03-10 15:24:38 +00:00
|
|
|
|