]>
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 | |
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 |
20 | class WXDLLIMPEXP_FWD_CORE wxArtProvidersList; |
21 | class WXDLLIMPEXP_FWD_CORE wxArtProviderCache; | |
2b5f62a0 | 22 | class wxArtProviderModule; |
2aca4a98 VS |
23 | |
24 | // ---------------------------------------------------------------------------- | |
25 | // Types | |
26 | // ---------------------------------------------------------------------------- | |
27 | ||
57b0987b | 28 | typedef wxString wxArtClient; |
2aca4a98 VS |
29 | typedef wxString wxArtID; |
30 | ||
409ded0f | 31 | #define wxART_MAKE_CLIENT_ID_FROM_STR(id) (id + _T("_C")) |
6ada5c33 VS |
32 | #define wxART_MAKE_CLIENT_ID(id) _T(#id) _T("_C") |
33 | #define wxART_MAKE_ART_ID_FROM_STR(id) (id) | |
34 | #define wxART_MAKE_ART_ID(id) _T(#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) | |
69 | #define wxART_FILE_OPEN wxART_MAKE_ART_ID(wxART_FILE_OPEN) | |
50f65637 VZ |
70 | #define wxART_FILE_SAVE wxART_MAKE_ART_ID(wxART_FILE_SAVE) |
71 | #define wxART_FILE_SAVE_AS wxART_MAKE_ART_ID(wxART_FILE_SAVE_AS) | |
4629016d WS |
72 | #define wxART_PRINT wxART_MAKE_ART_ID(wxART_PRINT) |
73 | #define wxART_HELP wxART_MAKE_ART_ID(wxART_HELP) | |
74 | #define wxART_TIP wxART_MAKE_ART_ID(wxART_TIP) | |
75 | #define wxART_REPORT_VIEW wxART_MAKE_ART_ID(wxART_REPORT_VIEW) | |
76 | #define wxART_LIST_VIEW wxART_MAKE_ART_ID(wxART_LIST_VIEW) | |
77 | #define wxART_NEW_DIR wxART_MAKE_ART_ID(wxART_NEW_DIR) | |
ddf6088b RR |
78 | #define wxART_HARDDISK wxART_MAKE_ART_ID(wxART_HARDDISK) |
79 | #define wxART_FLOPPY wxART_MAKE_ART_ID(wxART_FLOPPY) | |
80 | #define wxART_CDROM wxART_MAKE_ART_ID(wxART_CDROM) | |
81 | #define wxART_REMOVABLE wxART_MAKE_ART_ID(wxART_REMOVABLE) | |
4629016d | 82 | #define wxART_FOLDER wxART_MAKE_ART_ID(wxART_FOLDER) |
ddf6088b | 83 | #define wxART_FOLDER_OPEN wxART_MAKE_ART_ID(wxART_FOLDER_OPEN) |
4629016d WS |
84 | #define wxART_GO_DIR_UP wxART_MAKE_ART_ID(wxART_GO_DIR_UP) |
85 | #define wxART_EXECUTABLE_FILE wxART_MAKE_ART_ID(wxART_EXECUTABLE_FILE) | |
86 | #define wxART_NORMAL_FILE wxART_MAKE_ART_ID(wxART_NORMAL_FILE) | |
87 | #define wxART_TICK_MARK wxART_MAKE_ART_ID(wxART_TICK_MARK) | |
88 | #define wxART_CROSS_MARK wxART_MAKE_ART_ID(wxART_CROSS_MARK) | |
89 | #define wxART_ERROR wxART_MAKE_ART_ID(wxART_ERROR) | |
90 | #define wxART_QUESTION wxART_MAKE_ART_ID(wxART_QUESTION) | |
91 | #define wxART_WARNING wxART_MAKE_ART_ID(wxART_WARNING) | |
92 | #define wxART_INFORMATION wxART_MAKE_ART_ID(wxART_INFORMATION) | |
cba5a276 | 93 | #define wxART_MISSING_IMAGE wxART_MAKE_ART_ID(wxART_MISSING_IMAGE) |
57b0987b | 94 | |
50f65637 VZ |
95 | #define wxART_COPY wxART_MAKE_ART_ID(wxART_COPY) |
96 | #define wxART_CUT wxART_MAKE_ART_ID(wxART_CUT) | |
97 | #define wxART_PASTE wxART_MAKE_ART_ID(wxART_PASTE) | |
98 | #define wxART_DELETE wxART_MAKE_ART_ID(wxART_DELETE) | |
406011a8 | 99 | #define wxART_NEW wxART_MAKE_ART_ID(wxART_NEW) |
50f65637 VZ |
100 | |
101 | #define wxART_UNDO wxART_MAKE_ART_ID(wxART_UNDO) | |
102 | #define wxART_REDO wxART_MAKE_ART_ID(wxART_REDO) | |
103 | ||
104 | #define wxART_QUIT wxART_MAKE_ART_ID(wxART_QUIT) | |
105 | ||
106 | #define wxART_FIND wxART_MAKE_ART_ID(wxART_FIND) | |
107 | #define wxART_FIND_AND_REPLACE wxART_MAKE_ART_ID(wxART_FIND_AND_REPLACE) | |
108 | ||
109 | ||
2aca4a98 VS |
110 | // ---------------------------------------------------------------------------- |
111 | // wxArtProvider class | |
112 | // ---------------------------------------------------------------------------- | |
113 | ||
53a2db12 | 114 | class WXDLLIMPEXP_CORE wxArtProvider : public wxObject |
2aca4a98 VS |
115 | { |
116 | public: | |
571d2e0f VZ |
117 | // Dtor removes the provider from providers stack if it's still on it |
118 | virtual ~wxArtProvider(); | |
119 | ||
14440cc6 VS |
120 | // Does this platform implement native icons theme? |
121 | static bool HasNativeProvider(); | |
571d2e0f | 122 | |
dd7d379e | 123 | // Add new provider to the top of providers stack (i.e. the provider will |
571d2e0f VZ |
124 | // be queried first of all). |
125 | static void Push(wxArtProvider *provider); | |
2aca4a98 | 126 | |
dd7d379e VS |
127 | // Add new provider to the bottom of providers stack (i.e. the provider |
128 | // will be queried as the last one). | |
14440cc6 VS |
129 | static void PushBack(wxArtProvider *provider); |
130 | ||
131 | #if WXWIN_COMPATIBILITY_2_8 | |
132 | // use PushBack(), it's the same thing | |
133 | wxDEPRECATED( static void Insert(wxArtProvider *provider) ); | |
134 | #endif | |
dd7d379e | 135 | |
2aca4a98 | 136 | // Remove latest added provider and delete it. |
571d2e0f VZ |
137 | static bool Pop(); |
138 | ||
139 | // Remove provider from providers stack but don't delete it. | |
140 | static bool Remove(wxArtProvider *provider); | |
141 | ||
142 | // Delete the given provider and remove it from the providers stack. | |
143 | static bool Delete(wxArtProvider *provider); | |
2aca4a98 | 144 | |
4629016d | 145 | |
2aca4a98 VS |
146 | // Query the providers for bitmap with given ID and return it. Return |
147 | // wxNullBitmap if no provider provides it. | |
4629016d | 148 | static wxBitmap GetBitmap(const wxArtID& id, |
57b0987b | 149 | const wxArtClient& client = wxART_OTHER, |
2aca4a98 VS |
150 | const wxSize& size = wxDefaultSize); |
151 | ||
152 | // Query the providers for icon with given ID and return it. Return | |
153 | // wxNullIcon if no provider provides it. | |
57b0987b VS |
154 | static wxIcon GetIcon(const wxArtID& id, |
155 | const wxArtClient& client = wxART_OTHER, | |
2aca4a98 VS |
156 | const wxSize& size = wxDefaultSize); |
157 | ||
1970409e VZ |
158 | // Helper used by several generic classes: return the icon corresponding to |
159 | // the standard wxICON_INFORMATION/WARNING/ERROR/QUESTION flags (only one | |
160 | // can be set) | |
161 | static wxIcon GetMessageBoxIcon(int flags); | |
162 | ||
52734360 VZ |
163 | // Query the providers for iconbundle with given ID and return it. Return |
164 | // wxNullIconBundle if no provider provides it. | |
165 | static wxIconBundle GetIconBundle(const wxArtID& id, | |
166 | const wxArtClient& client = wxART_OTHER); | |
167 | ||
a158acac VS |
168 | // Gets native size for given 'client' or wxDefaultSize if it doesn't |
169 | // have native equivalent | |
170 | static wxSize GetNativeSizeHint(const wxArtClient& client); | |
171 | ||
ce7208d4 | 172 | // Get the size hint of an icon from a specific wxArtClient, queries |
b737ad10 | 173 | // the topmost provider if platform_dependent = false |
e53a95bc | 174 | static wxSize GetSizeHint(const wxArtClient& client, bool platform_dependent = false); |
b737ad10 | 175 | |
571d2e0f VZ |
176 | #if WXWIN_COMPATIBILITY_2_6 |
177 | // use the corresponding methods without redundant "Provider" suffix | |
178 | wxDEPRECATED( static void PushProvider(wxArtProvider *provider) ); | |
179 | wxDEPRECATED( static void InsertProvider(wxArtProvider *provider) ); | |
180 | wxDEPRECATED( static bool PopProvider() ); | |
181 | ||
182 | // use Delete() if this is what you really need, or just delete the | |
183 | // provider pointer, do not use Remove() as it does not delete the pointer | |
184 | // unlike RemoveProvider() which does | |
185 | wxDEPRECATED( static bool RemoveProvider(wxArtProvider *provider) ); | |
186 | #endif // WXWIN_COMPATIBILITY_2_6 | |
187 | ||
2b5f62a0 VZ |
188 | protected: |
189 | friend class wxArtProviderModule; | |
190 | // Initializes default provider | |
191 | static void InitStdProvider(); | |
b5cf8234 VS |
192 | // Initializes platform's native provider, if available (e.g. GTK2) |
193 | static void InitNativeProvider(); | |
2aca4a98 VS |
194 | // Destroy caches & all providers |
195 | static void CleanUpProviders(); | |
196 | ||
b737ad10 | 197 | // Get the default size of an icon for a specific client |
ce7208d4 | 198 | virtual wxSize DoGetSizeHint(const wxArtClient& client) |
b737ad10 | 199 | { |
e53a95bc | 200 | return GetSizeHint(client, true); |
b737ad10 | 201 | } |
dd7d379e | 202 | |
52734360 VZ |
203 | // Derived classes must override CreateBitmap or CreateIconBundle |
204 | // (or both) to create requested art resource. This method is called | |
205 | // only once per instance's lifetime for each requested wxArtID. | |
57b0987b VS |
206 | virtual wxBitmap CreateBitmap(const wxArtID& WXUNUSED(id), |
207 | const wxArtClient& WXUNUSED(client), | |
52734360 VZ |
208 | const wxSize& WXUNUSED(size)) { return wxNullBitmap; } |
209 | ||
210 | virtual wxIconBundle CreateIconBundle(const wxArtID& WXUNUSED(id), | |
211 | const wxArtClient& WXUNUSED(client)) | |
212 | { | |
213 | return wxNullIconBundle; | |
214 | } | |
2aca4a98 | 215 | |
dd7d379e | 216 | private: |
1486fb5f | 217 | static void CommonAddingProvider(); |
dd7d379e | 218 | |
2aca4a98 VS |
219 | private: |
220 | // list of providers: | |
221 | static wxArtProvidersList *sm_providers; | |
222 | // art resources cache (so that CreateXXX is not called that often): | |
223 | static wxArtProviderCache *sm_cache; | |
224 | ||
225 | DECLARE_ABSTRACT_CLASS(wxArtProvider) | |
226 | }; | |
227 | ||
228 | ||
a158acac | 229 | #if !defined(__WXUNIVERSAL__) && \ |
e3c80a1d | 230 | ((defined(__WXGTK__) && defined(__WXGTK20__)) || defined(__WXMSW__) || \ |
1d61c554 | 231 | (defined(__WXMAC__) && wxOSX_USE_COCOA_OR_CARBON)) |
a158acac VS |
232 | // *some* (partial) native implementation of wxArtProvider exists; this is |
233 | // not the same as wxArtProvider::HasNativeProvider()! | |
234 | #define wxHAS_NATIVE_ART_PROVIDER_IMPL | |
235 | #endif | |
236 | ||
2aca4a98 | 237 | #endif // _WX_ARTPROV_H_ |