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