]> git.saurik.com Git - wxWidgets.git/blame - include/wx/artprov.h
Optionally allow showing tooltips for disabled ribbon buttons.
[wxWidgets.git] / include / wx / artprov.h
CommitLineData
2aca4a98 1/////////////////////////////////////////////////////////////////////////////
ce7208d4 2// Name: wx/artprov.h
2aca4a98
VS
3// Purpose: wxArtProvider class
4// Author: Vaclav Slavik
5// Modified by:
6// Created: 18/03/2002
7// RCS-ID: $Id$
8// Copyright: (c) Vaclav Slavik
65571936 9// Licence: wxWindows licence
2aca4a98
VS
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_ARTPROV_H_
13#define _WX_ARTPROV_H_
14
2aca4a98
VS
15#include "wx/string.h"
16#include "wx/bitmap.h"
17#include "wx/icon.h"
52734360 18#include "wx/iconbndl.h"
2aca4a98 19
b5dbe15d
VS
20class WXDLLIMPEXP_FWD_CORE wxArtProvidersList;
21class WXDLLIMPEXP_FWD_CORE wxArtProviderCache;
2b5f62a0 22class wxArtProviderModule;
2aca4a98
VS
23
24// ----------------------------------------------------------------------------
25// Types
26// ----------------------------------------------------------------------------
27
57b0987b 28typedef wxString wxArtClient;
2aca4a98
VS
29typedef wxString wxArtID;
30
19be42b7
VZ
31#define wxART_MAKE_CLIENT_ID_FROM_STR(id) ((id) + "_C")
32#define wxART_MAKE_CLIENT_ID(id) (#id "_C")
6ada5c33 33#define wxART_MAKE_ART_ID_FROM_STR(id) (id)
19be42b7 34#define wxART_MAKE_ART_ID(id) (#id)
db70a2f2 35
57b0987b
VS
36// ----------------------------------------------------------------------------
37// Art clients
38// ----------------------------------------------------------------------------
39
4629016d
WS
40#define wxART_TOOLBAR wxART_MAKE_CLIENT_ID(wxART_TOOLBAR)
41#define wxART_MENU wxART_MAKE_CLIENT_ID(wxART_MENU)
42#define wxART_FRAME_ICON wxART_MAKE_CLIENT_ID(wxART_FRAME_ICON)
57b0987b 43
4629016d
WS
44#define wxART_CMN_DIALOG wxART_MAKE_CLIENT_ID(wxART_CMN_DIALOG)
45#define wxART_HELP_BROWSER wxART_MAKE_CLIENT_ID(wxART_HELP_BROWSER)
46#define wxART_MESSAGE_BOX wxART_MAKE_CLIENT_ID(wxART_MESSAGE_BOX)
b5cf8234 47#define wxART_BUTTON wxART_MAKE_CLIENT_ID(wxART_BUTTON)
52734360 48#define wxART_LIST wxART_MAKE_CLIENT_ID(wxART_LIST)
57b0987b 49
4629016d 50#define wxART_OTHER wxART_MAKE_CLIENT_ID(wxART_OTHER)
57b0987b
VS
51
52// ----------------------------------------------------------------------------
53// Art IDs
54// ----------------------------------------------------------------------------
55
4629016d
WS
56#define wxART_ADD_BOOKMARK wxART_MAKE_ART_ID(wxART_ADD_BOOKMARK)
57#define wxART_DEL_BOOKMARK wxART_MAKE_ART_ID(wxART_DEL_BOOKMARK)
58#define wxART_HELP_SIDE_PANEL wxART_MAKE_ART_ID(wxART_HELP_SIDE_PANEL)
59#define wxART_HELP_SETTINGS wxART_MAKE_ART_ID(wxART_HELP_SETTINGS)
60#define wxART_HELP_BOOK wxART_MAKE_ART_ID(wxART_HELP_BOOK)
61#define wxART_HELP_FOLDER wxART_MAKE_ART_ID(wxART_HELP_FOLDER)
62#define wxART_HELP_PAGE wxART_MAKE_ART_ID(wxART_HELP_PAGE)
63#define wxART_GO_BACK wxART_MAKE_ART_ID(wxART_GO_BACK)
64#define wxART_GO_FORWARD wxART_MAKE_ART_ID(wxART_GO_FORWARD)
65#define wxART_GO_UP wxART_MAKE_ART_ID(wxART_GO_UP)
66#define wxART_GO_DOWN wxART_MAKE_ART_ID(wxART_GO_DOWN)
67#define wxART_GO_TO_PARENT wxART_MAKE_ART_ID(wxART_GO_TO_PARENT)
68#define wxART_GO_HOME wxART_MAKE_ART_ID(wxART_GO_HOME)
a7cfad3a
VZ
69#define wxART_GOTO_FIRST wxART_MAKE_ART_ID(wxART_GOTO_FIRST)
70#define wxART_GOTO_LAST wxART_MAKE_ART_ID(wxART_GOTO_LAST)
4629016d 71#define wxART_FILE_OPEN wxART_MAKE_ART_ID(wxART_FILE_OPEN)
50f65637
VZ
72#define wxART_FILE_SAVE wxART_MAKE_ART_ID(wxART_FILE_SAVE)
73#define wxART_FILE_SAVE_AS wxART_MAKE_ART_ID(wxART_FILE_SAVE_AS)
4629016d
WS
74#define wxART_PRINT wxART_MAKE_ART_ID(wxART_PRINT)
75#define wxART_HELP wxART_MAKE_ART_ID(wxART_HELP)
76#define wxART_TIP wxART_MAKE_ART_ID(wxART_TIP)
77#define wxART_REPORT_VIEW wxART_MAKE_ART_ID(wxART_REPORT_VIEW)
78#define wxART_LIST_VIEW wxART_MAKE_ART_ID(wxART_LIST_VIEW)
79#define wxART_NEW_DIR wxART_MAKE_ART_ID(wxART_NEW_DIR)
ddf6088b
RR
80#define wxART_HARDDISK wxART_MAKE_ART_ID(wxART_HARDDISK)
81#define wxART_FLOPPY wxART_MAKE_ART_ID(wxART_FLOPPY)
82#define wxART_CDROM wxART_MAKE_ART_ID(wxART_CDROM)
83#define wxART_REMOVABLE wxART_MAKE_ART_ID(wxART_REMOVABLE)
4629016d 84#define wxART_FOLDER wxART_MAKE_ART_ID(wxART_FOLDER)
ddf6088b 85#define wxART_FOLDER_OPEN wxART_MAKE_ART_ID(wxART_FOLDER_OPEN)
4629016d
WS
86#define wxART_GO_DIR_UP wxART_MAKE_ART_ID(wxART_GO_DIR_UP)
87#define wxART_EXECUTABLE_FILE wxART_MAKE_ART_ID(wxART_EXECUTABLE_FILE)
88#define wxART_NORMAL_FILE wxART_MAKE_ART_ID(wxART_NORMAL_FILE)
89#define wxART_TICK_MARK wxART_MAKE_ART_ID(wxART_TICK_MARK)
90#define wxART_CROSS_MARK wxART_MAKE_ART_ID(wxART_CROSS_MARK)
91#define wxART_ERROR wxART_MAKE_ART_ID(wxART_ERROR)
92#define wxART_QUESTION wxART_MAKE_ART_ID(wxART_QUESTION)
93#define wxART_WARNING wxART_MAKE_ART_ID(wxART_WARNING)
94#define wxART_INFORMATION wxART_MAKE_ART_ID(wxART_INFORMATION)
cba5a276 95#define wxART_MISSING_IMAGE wxART_MAKE_ART_ID(wxART_MISSING_IMAGE)
57b0987b 96
50f65637
VZ
97#define wxART_COPY wxART_MAKE_ART_ID(wxART_COPY)
98#define wxART_CUT wxART_MAKE_ART_ID(wxART_CUT)
99#define wxART_PASTE wxART_MAKE_ART_ID(wxART_PASTE)
100#define wxART_DELETE wxART_MAKE_ART_ID(wxART_DELETE)
406011a8 101#define wxART_NEW wxART_MAKE_ART_ID(wxART_NEW)
50f65637
VZ
102
103#define wxART_UNDO wxART_MAKE_ART_ID(wxART_UNDO)
104#define wxART_REDO wxART_MAKE_ART_ID(wxART_REDO)
105
a7cfad3a
VZ
106#define wxART_PLUS wxART_MAKE_ART_ID(wxART_PLUS)
107#define wxART_MINUS wxART_MAKE_ART_ID(wxART_MINUS)
108
b9727751 109#define wxART_CLOSE wxART_MAKE_ART_ID(wxART_CLOSE)
50f65637
VZ
110#define wxART_QUIT wxART_MAKE_ART_ID(wxART_QUIT)
111
112#define wxART_FIND wxART_MAKE_ART_ID(wxART_FIND)
113#define wxART_FIND_AND_REPLACE wxART_MAKE_ART_ID(wxART_FIND_AND_REPLACE)
114
115
2aca4a98
VS
116// ----------------------------------------------------------------------------
117// wxArtProvider class
118// ----------------------------------------------------------------------------
119
53a2db12 120class WXDLLIMPEXP_CORE wxArtProvider : public wxObject
2aca4a98
VS
121{
122public:
571d2e0f
VZ
123 // Dtor removes the provider from providers stack if it's still on it
124 virtual ~wxArtProvider();
125
14440cc6
VS
126 // Does this platform implement native icons theme?
127 static bool HasNativeProvider();
571d2e0f 128
dd7d379e 129 // Add new provider to the top of providers stack (i.e. the provider will
571d2e0f
VZ
130 // be queried first of all).
131 static void Push(wxArtProvider *provider);
2aca4a98 132
dd7d379e
VS
133 // Add new provider to the bottom of providers stack (i.e. the provider
134 // will be queried as the last one).
14440cc6
VS
135 static void PushBack(wxArtProvider *provider);
136
137#if WXWIN_COMPATIBILITY_2_8
138 // use PushBack(), it's the same thing
d65e9d57 139 static wxDEPRECATED( void Insert(wxArtProvider *provider) );
14440cc6 140#endif
dd7d379e 141
2aca4a98 142 // Remove latest added provider and delete it.
571d2e0f
VZ
143 static bool Pop();
144
145 // Remove provider from providers stack but don't delete it.
146 static bool Remove(wxArtProvider *provider);
147
148 // Delete the given provider and remove it from the providers stack.
149 static bool Delete(wxArtProvider *provider);
2aca4a98 150
4629016d 151
2aca4a98
VS
152 // Query the providers for bitmap with given ID and return it. Return
153 // wxNullBitmap if no provider provides it.
4629016d 154 static wxBitmap GetBitmap(const wxArtID& id,
57b0987b 155 const wxArtClient& client = wxART_OTHER,
2aca4a98
VS
156 const wxSize& size = wxDefaultSize);
157
158 // Query the providers for icon with given ID and return it. Return
159 // wxNullIcon if no provider provides it.
57b0987b
VS
160 static wxIcon GetIcon(const wxArtID& id,
161 const wxArtClient& client = wxART_OTHER,
2aca4a98
VS
162 const wxSize& size = wxDefaultSize);
163
39f6b6ba
VZ
164 // Helper used by GetMessageBoxIcon(): return the art id corresponding to
165 // the standard wxICON_INFORMATION/WARNING/ERROR/QUESTION flags (only one
166 // can be set)
167 static wxArtID GetMessageBoxIconId(int flags);
168
1970409e
VZ
169 // Helper used by several generic classes: return the icon corresponding to
170 // the standard wxICON_INFORMATION/WARNING/ERROR/QUESTION flags (only one
171 // can be set)
39f6b6ba
VZ
172 static wxIcon GetMessageBoxIcon(int flags)
173 {
174 return GetIcon(GetMessageBoxIconId(flags), wxART_MESSAGE_BOX);
175 }
1970409e 176
52734360
VZ
177 // Query the providers for iconbundle with given ID and return it. Return
178 // wxNullIconBundle if no provider provides it.
179 static wxIconBundle GetIconBundle(const wxArtID& id,
180 const wxArtClient& client = wxART_OTHER);
181
a158acac
VS
182 // Gets native size for given 'client' or wxDefaultSize if it doesn't
183 // have native equivalent
184 static wxSize GetNativeSizeHint(const wxArtClient& client);
185
ce7208d4 186 // Get the size hint of an icon from a specific wxArtClient, queries
b737ad10 187 // the topmost provider if platform_dependent = false
e53a95bc 188 static wxSize GetSizeHint(const wxArtClient& client, bool platform_dependent = false);
b737ad10 189
571d2e0f
VZ
190#if WXWIN_COMPATIBILITY_2_6
191 // use the corresponding methods without redundant "Provider" suffix
d65e9d57
VZ
192 static wxDEPRECATED( void PushProvider(wxArtProvider *provider) );
193 static wxDEPRECATED( void InsertProvider(wxArtProvider *provider) );
194 static wxDEPRECATED( bool PopProvider() );
571d2e0f
VZ
195
196 // use Delete() if this is what you really need, or just delete the
197 // provider pointer, do not use Remove() as it does not delete the pointer
198 // unlike RemoveProvider() which does
d65e9d57 199 static wxDEPRECATED( bool RemoveProvider(wxArtProvider *provider) );
571d2e0f
VZ
200#endif // WXWIN_COMPATIBILITY_2_6
201
2b5f62a0
VZ
202protected:
203 friend class wxArtProviderModule;
2e9b5717 204#if wxUSE_ARTPROVIDER_STD
2b5f62a0
VZ
205 // Initializes default provider
206 static void InitStdProvider();
2e9b5717 207#endif // wxUSE_ARTPROVIDER_STD
c1d2466a
VZ
208 // Initializes Tango-based icon provider
209#if wxUSE_ARTPROVIDER_TANGO
210 static void InitTangoProvider();
211#endif // wxUSE_ARTPROVIDER_TANGO
b5cf8234
VS
212 // Initializes platform's native provider, if available (e.g. GTK2)
213 static void InitNativeProvider();
2aca4a98
VS
214 // Destroy caches & all providers
215 static void CleanUpProviders();
216
b737ad10 217 // Get the default size of an icon for a specific client
ce7208d4 218 virtual wxSize DoGetSizeHint(const wxArtClient& client)
b737ad10 219 {
e53a95bc 220 return GetSizeHint(client, true);
b737ad10 221 }
dd7d379e 222
52734360
VZ
223 // Derived classes must override CreateBitmap or CreateIconBundle
224 // (or both) to create requested art resource. This method is called
225 // only once per instance's lifetime for each requested wxArtID.
57b0987b
VS
226 virtual wxBitmap CreateBitmap(const wxArtID& WXUNUSED(id),
227 const wxArtClient& WXUNUSED(client),
b5c2a334
VS
228 const wxSize& WXUNUSED(size))
229 {
230 return wxNullBitmap;
231 }
52734360
VZ
232
233 virtual wxIconBundle CreateIconBundle(const wxArtID& WXUNUSED(id),
234 const wxArtClient& WXUNUSED(client))
235 {
236 return wxNullIconBundle;
237 }
2aca4a98 238
dd7d379e 239private:
1486fb5f 240 static void CommonAddingProvider();
b5c2a334
VS
241 static wxIconBundle DoGetIconBundle(const wxArtID& id,
242 const wxArtClient& client);
dd7d379e 243
2aca4a98
VS
244private:
245 // list of providers:
246 static wxArtProvidersList *sm_providers;
247 // art resources cache (so that CreateXXX is not called that often):
248 static wxArtProviderCache *sm_cache;
249
250 DECLARE_ABSTRACT_CLASS(wxArtProvider)
251};
252
253
a158acac 254#if !defined(__WXUNIVERSAL__) && \
e3c80a1d 255 ((defined(__WXGTK__) && defined(__WXGTK20__)) || defined(__WXMSW__) || \
ca9eebc3 256 defined(__WXMAC__))
a158acac
VS
257 // *some* (partial) native implementation of wxArtProvider exists; this is
258 // not the same as wxArtProvider::HasNativeProvider()!
259 #define wxHAS_NATIVE_ART_PROVIDER_IMPL
260#endif
261
2aca4a98 262#endif // _WX_ARTPROV_H_