2008-03-08 08:52:38 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: artprov.h
|
2008-03-10 11:24:38 -04:00
|
|
|
// Purpose: interface of wxArtProvider
|
2008-03-08 08:52:38 -05:00
|
|
|
// Author: wxWidgets team
|
|
|
|
// RCS-ID: $Id$
|
2010-07-13 09:29:13 -04:00
|
|
|
// Licence: wxWindows licence
|
2008-03-08 08:52:38 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2008-12-03 15:33:08 -05:00
|
|
|
/**
|
|
|
|
This type identifies the client of the art objects requested to wxArtProvider.
|
|
|
|
*/
|
2010-05-16 08:31:52 -04:00
|
|
|
typedef class wxString wxArtClient;
|
2008-12-03 15:33:08 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
This type identifies a specific art object which can be requested to wxArtProvider.
|
|
|
|
*/
|
2010-05-16 08:31:52 -04:00
|
|
|
typedef class wxString wxArtID;
|
2008-12-03 15:33:08 -05:00
|
|
|
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
@class wxArtProvider
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
wxArtProvider class is used to customize the look of wxWidgets application.
|
2008-03-14 11:35:10 -04:00
|
|
|
|
2008-03-08 08:52:38 -05: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 11:35:10 -04:00
|
|
|
replace standard art with their own version.
|
|
|
|
|
|
|
|
All that is needed is to derive a class from wxArtProvider, override either its
|
2008-03-21 10:22:27 -04:00
|
|
|
wxArtProvider::CreateBitmap() and/or its wxArtProvider::CreateIconBundle() methods
|
|
|
|
and register the provider with wxArtProvider::Push():
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@code
|
2008-03-14 11:35:10 -04:00
|
|
|
class MyProvider : public wxArtProvider
|
2008-03-08 08:52:38 -05:00
|
|
|
{
|
|
|
|
protected:
|
2008-03-08 09:43:31 -05:00
|
|
|
wxBitmap CreateBitmap(const wxArtID& id,
|
2008-03-08 08:52:38 -05:00
|
|
|
const wxArtClient& client,
|
|
|
|
const wxSize size)
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
// optionally override this one as well
|
|
|
|
wxIconBundle CreateIconBundle(const wxArtID& id,
|
|
|
|
const wxArtClient& client)
|
|
|
|
{ ... }
|
|
|
|
};
|
|
|
|
...
|
|
|
|
wxArtProvider::Push(new MyProvider);
|
|
|
|
@endcode
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
If you need bitmap images (of the same artwork) that should be displayed at
|
2008-03-14 11:35:10 -04:00
|
|
|
different sizes you should probably consider overriding wxArtProvider::CreateIconBundle
|
2008-03-08 08:52:38 -05:00
|
|
|
and supplying icon bundles that contain different bitmap sizes.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
There's another way of taking advantage of this class: you can use it in your
|
2008-03-14 11:35:10 -04:00
|
|
|
code and use platform native icons as provided by wxArtProvider::GetBitmap or
|
|
|
|
wxArtProvider::GetIcon.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-10-19 11:30:20 -04:00
|
|
|
@section artprovider_identify Identifying art resources
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
Every bitmap and icon bundle are known to wxArtProvider under an unique ID that
|
2009-04-12 08:43:38 -04:00
|
|
|
is used when requesting a resource from it. The ID is represented by the ::wxArtID type
|
2008-03-14 11:35:10 -04:00
|
|
|
and can have one of these predefined values (you can see bitmaps represented by these
|
2008-09-25 10:07:25 -04:00
|
|
|
constants in the @ref page_samples_artprov):
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-14 11:35:10 -04:00
|
|
|
<table>
|
|
|
|
<tr><td>
|
2011-11-05 07:54:14 -04:00
|
|
|
@li @c wxART_ERROR
|
|
|
|
@li @c wxART_QUESTION
|
|
|
|
@li @c wxART_WARNING
|
|
|
|
@li @c wxART_INFORMATION
|
|
|
|
@li @c wxART_ADD_BOOKMARK
|
|
|
|
@li @c wxART_DEL_BOOKMARK
|
|
|
|
@li @c wxART_HELP_SIDE_PANEL
|
|
|
|
@li @c wxART_HELP_SETTINGS
|
|
|
|
@li @c wxART_HELP_BOOK
|
|
|
|
@li @c wxART_HELP_FOLDER
|
|
|
|
@li @c wxART_HELP_PAGE
|
|
|
|
@li @c wxART_GO_BACK
|
|
|
|
@li @c wxART_GO_FORWARD
|
|
|
|
@li @c wxART_GO_UP
|
|
|
|
@li @c wxART_GO_DOWN
|
|
|
|
@li @c wxART_GO_TO_PARENT
|
|
|
|
@li @c wxART_GO_HOME
|
|
|
|
@li @c wxART_GOTO_FIRST (since 2.9.2)
|
2010-12-31 12:39:01 -05:00
|
|
|
</td><td>
|
2011-11-05 07:54:14 -04:00
|
|
|
@li @c wxART_GOTO_LAST (since 2.9.2)
|
|
|
|
@li @c wxART_PRINT
|
|
|
|
@li @c wxART_HELP
|
|
|
|
@li @c wxART_TIP
|
|
|
|
@li @c wxART_REPORT_VIEW
|
|
|
|
@li @c wxART_LIST_VIEW
|
|
|
|
@li @c wxART_NEW_DIR
|
|
|
|
@li @c wxART_FOLDER
|
|
|
|
@li @c wxART_FOLDER_OPEN
|
|
|
|
@li @c wxART_GO_DIR_UP
|
|
|
|
@li @c wxART_EXECUTABLE_FILE
|
|
|
|
@li @c wxART_NORMAL_FILE
|
|
|
|
@li @c wxART_TICK_MARK
|
|
|
|
@li @c wxART_CROSS_MARK
|
|
|
|
@li @c wxART_MISSING_IMAGE
|
|
|
|
@li @c wxART_NEW
|
|
|
|
@li @c wxART_FILE_OPEN
|
|
|
|
@li @c wxART_FILE_SAVE
|
2010-12-31 12:39:01 -05:00
|
|
|
</td><td>
|
2011-11-05 07:54:14 -04:00
|
|
|
@li @c wxART_FILE_SAVE_AS
|
|
|
|
@li @c wxART_DELETE
|
|
|
|
@li @c wxART_COPY
|
|
|
|
@li @c wxART_CUT
|
|
|
|
@li @c wxART_PASTE
|
|
|
|
@li @c wxART_UNDO
|
|
|
|
@li @c wxART_REDO
|
|
|
|
@li @c wxART_PLUS (since 2.9.2)
|
|
|
|
@li @c wxART_MINUS (since 2.9.2)
|
|
|
|
@li @c wxART_CLOSE
|
|
|
|
@li @c wxART_QUIT
|
|
|
|
@li @c wxART_FIND
|
|
|
|
@li @c wxART_FIND_AND_REPLACE
|
|
|
|
@li @c wxART_HARDDISK
|
|
|
|
@li @c wxART_FLOPPY
|
|
|
|
@li @c wxART_CDROM
|
|
|
|
@li @c wxART_REMOVABLE
|
2008-03-14 11:35:10 -04:00
|
|
|
</td></tr>
|
|
|
|
</table>
|
2008-03-08 09:43:31 -05:00
|
|
|
|
|
|
|
Additionally, any string recognized by custom art providers registered using
|
2008-03-08 08:52:38 -05:00
|
|
|
wxArtProvider::Push may be used.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-14 11:35:10 -04:00
|
|
|
@note
|
|
|
|
When running under GTK+ 2, GTK+ stock item IDs (e.g. @c "gtk-cdrom") may be used
|
2008-12-03 15:33:08 -05:00
|
|
|
as well:
|
|
|
|
@code
|
2009-04-12 08:43:38 -04:00
|
|
|
#ifdef __WXGTK__
|
2008-12-03 15:33:08 -05:00
|
|
|
wxBitmap bmp = wxArtProvider::GetBitmap("gtk-cdrom", wxART_MENU);
|
2009-04-12 08:43:38 -04:00
|
|
|
#endif
|
2008-12-03 15:33:08 -05:00
|
|
|
@endcode
|
2010-08-22 18:16:05 -04:00
|
|
|
For a list of the GTK+ stock items please refer to the
|
|
|
|
<a href="http://library.gnome.org/devel/gtk/stable/gtk-Stock-Items.html">GTK+ documentation
|
|
|
|
page</a>.
|
2009-04-12 08:43:38 -04:00
|
|
|
It is also possible to load icons from the current icon theme by specifying their name
|
|
|
|
(without extension and directory components).
|
2010-08-22 18:16:05 -04:00
|
|
|
Icon themes recognized by GTK+ follow the freedesktop.org
|
|
|
|
<a href="http://freedesktop.org/Standards/icon-theme-spec">Icon Themes specification</a>.
|
2008-03-14 11:35:10 -04:00
|
|
|
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.
|
|
|
|
|
|
|
|
|
2008-10-19 11:30:20 -04:00
|
|
|
@section artprovider_clients Clients
|
2008-03-14 11:35:10 -04:00
|
|
|
|
2008-12-03 15:33:08 -05:00
|
|
|
The @e client is the entity that calls wxArtProvider's GetBitmap() or GetIcon() function.
|
2008-03-14 11:35:10 -04:00
|
|
|
It is represented by wxClientID type and can have one of these values:
|
|
|
|
|
2011-11-05 07:54:14 -04:00
|
|
|
@li @c wxART_TOOLBAR
|
|
|
|
@li @c wxART_MENU
|
|
|
|
@li @c wxART_BUTTON
|
|
|
|
@li @c wxART_FRAME_ICON
|
|
|
|
@li @c wxART_CMN_DIALOG
|
|
|
|
@li @c wxART_HELP_BROWSER
|
|
|
|
@li @c wxART_MESSAGE_BOX
|
|
|
|
@li @c wxART_OTHER (used for all requests that don't fit into any of the
|
2008-03-14 11:35:10 -04:00
|
|
|
categories above)
|
|
|
|
|
2008-12-03 15:33:08 -05:00
|
|
|
Client ID serve as a hint to wxArtProvider that is supposed to help it to
|
2008-03-14 11:35:10 -04:00
|
|
|
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 08:52:38 -05:00
|
|
|
@library{wxcore}
|
2009-02-20 06:34:52 -05:00
|
|
|
@category{misc}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2011-11-05 07:54:14 -04:00
|
|
|
@see @ref page_samples_artprov for an example of wxArtProvider usage;
|
|
|
|
@ref page_stockitems "stock ID list"
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
class wxArtProvider : public wxObject
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
The destructor automatically removes the provider from the provider stack used
|
|
|
|
by GetBitmap().
|
|
|
|
*/
|
2008-03-23 21:02:55 -04:00
|
|
|
virtual ~wxArtProvider();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-03-24 08:45:43 -04:00
|
|
|
Delete the given @a provider.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
static bool Delete(wxArtProvider* provider);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Query registered providers for bitmap with given ID.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param id
|
2008-03-09 08:33:59 -04:00
|
|
|
wxArtID unique identifier of the bitmap.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param client
|
2008-03-09 08:33:59 -04:00
|
|
|
wxArtClient identifier of the client (i.e. who is asking for the bitmap).
|
2008-03-08 09:43:31 -05:00
|
|
|
@param size
|
2008-03-09 08:33:59 -04:00
|
|
|
Size of the returned bitmap or wxDefaultSize if size doesn't matter.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-05-10 21:38:53 -04:00
|
|
|
@return The bitmap if one of registered providers recognizes the ID or
|
|
|
|
wxNullBitmap otherwise.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
static wxBitmap GetBitmap(const wxArtID& id,
|
|
|
|
const wxArtClient& client = wxART_OTHER,
|
|
|
|
const wxSize& size = wxDefaultSize);
|
|
|
|
|
2008-03-14 11:35:10 -04: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 08:52:38 -05:00
|
|
|
/**
|
2008-10-16 15:07:42 -04:00
|
|
|
Returns native icon size for use specified by @a client hint.
|
|
|
|
|
|
|
|
If the platform has no commonly used default for this use or if
|
|
|
|
@a client is not recognized, returns wxDefaultSize.
|
|
|
|
|
|
|
|
@note In some cases, a platform may have @em several appropriate
|
|
|
|
native sizes (for example, wxART_FRAME_ICON for frame icons).
|
|
|
|
In that case, this method returns only one of them, picked
|
|
|
|
reasonably.
|
|
|
|
|
|
|
|
@since 2.9.0
|
|
|
|
*/
|
|
|
|
static wxSize GetNativeSizeHint(const wxArtClient& client);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Returns a suitable size hint for the given @e wxArtClient.
|
|
|
|
|
|
|
|
If @a platform_default is @true, return a size based on the current
|
|
|
|
platform using GetNativeSizeHint(), otherwise return the size from the
|
|
|
|
topmost wxArtProvider. @e wxDefaultSize may be returned if the client
|
|
|
|
doesn't have a specified size, like wxART_OTHER for example.
|
|
|
|
|
|
|
|
@see GetNativeSizeHint()
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-08 09:43:31 -05:00
|
|
|
static wxSize GetSizeHint(const wxArtClient& client,
|
2008-03-09 08:33:59 -04:00
|
|
|
bool platform_default = false);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Query registered providers for icon bundle with given ID.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param id
|
2008-03-09 08:33:59 -04:00
|
|
|
wxArtID unique identifier of the icon bundle.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param client
|
2008-03-09 08:33:59 -04:00
|
|
|
wxArtClient identifier of the client (i.e. who is asking for the icon
|
2008-03-14 11:35:10 -04:00
|
|
|
bundle).
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-05-10 21:38:53 -04:00
|
|
|
@return The icon bundle if one of registered providers recognizes the ID
|
|
|
|
or wxNullIconBundle otherwise.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
static wxIconBundle GetIconBundle(const wxArtID& id,
|
|
|
|
const wxArtClient& client = wxART_OTHER);
|
|
|
|
|
|
|
|
/**
|
2008-08-07 07:46:59 -04:00
|
|
|
Returns true if the platform uses native icons provider that should
|
|
|
|
take precedence over any customizations.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-08-07 07:46:59 -04:00
|
|
|
This is true for any platform that has user-customizable icon themes,
|
|
|
|
currently only wxGTK.
|
|
|
|
|
|
|
|
A typical use for this method is to decide whether a custom art provider
|
|
|
|
should be plugged in using Push() or PushBack().
|
|
|
|
|
|
|
|
@since 2.9.0
|
|
|
|
*/
|
|
|
|
static bool HasNativeProvider();
|
|
|
|
|
|
|
|
/**
|
|
|
|
@deprecated Use PushBack() instead.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
static void Insert(wxArtProvider* provider);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Remove latest added provider and delete it.
|
|
|
|
*/
|
2008-03-09 08:33:59 -04:00
|
|
|
static bool Pop();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-03-14 11:35:10 -04: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-20 09:45:17 -04:00
|
|
|
|
2008-08-07 07:46:59 -04:00
|
|
|
@see PushBack()
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
static void Push(wxArtProvider* provider);
|
|
|
|
|
2008-08-07 07:46:59 -04:00
|
|
|
/**
|
|
|
|
Register new art provider and add it to the bottom of providers stack.
|
|
|
|
In other words, it will be queried as the last one, after all others,
|
|
|
|
including the default provider.
|
|
|
|
|
|
|
|
@see Push()
|
|
|
|
|
|
|
|
@since 2.9.0
|
|
|
|
*/
|
|
|
|
static void PushBack(wxArtProvider* provider);
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
2008-03-08 09:43:31 -05:00
|
|
|
Remove a provider from the stack if it is on it. The provider is not
|
2008-03-08 08:52:38 -05:00
|
|
|
deleted, unlike when using Delete().
|
|
|
|
*/
|
|
|
|
static bool Remove(wxArtProvider* provider);
|
2008-03-24 14:17:11 -04:00
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
/**
|
|
|
|
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).
|
|
|
|
|
|
|
|
@param id
|
|
|
|
wxArtID unique identifier of the bitmap.
|
|
|
|
@param client
|
|
|
|
wxArtClient identifier of the client (i.e. who is asking for the bitmap).
|
|
|
|
This only servers as a hint.
|
|
|
|
@param size
|
|
|
|
Preferred 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::GetIconBundle or wxArtProvider::GetIcon to query wxArtProvider
|
|
|
|
for a resource.
|
|
|
|
|
|
|
|
@see CreateIconBundle()
|
|
|
|
*/
|
|
|
|
virtual wxBitmap CreateBitmap(const wxArtID& id,
|
|
|
|
const wxArtClient& client,
|
|
|
|
const wxSize& size);
|
|
|
|
|
|
|
|
/**
|
|
|
|
This method is similar to CreateBitmap() but can be used when a bitmap
|
|
|
|
(or an icon) exists in several sizes.
|
|
|
|
*/
|
|
|
|
virtual wxIconBundle CreateIconBundle(const wxArtID& id,
|
|
|
|
const wxArtClient& client);
|
2008-03-08 08:52:38 -05:00
|
|
|
};
|
2008-03-10 11:24:38 -04:00
|
|
|
|