]> git.saurik.com Git - wxWidgets.git/blob - include/wx/artprov.h
check that the version of __sync_sub_and_fetch that returns a value is supported...
[wxWidgets.git] / include / wx / artprov.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/artprov.h
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
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_ARTPROV_H_
13 #define _WX_ARTPROV_H_
14
15 #include "wx/string.h"
16 #include "wx/bitmap.h"
17 #include "wx/icon.h"
18 #include "wx/iconbndl.h"
19
20 class WXDLLIMPEXP_FWD_CORE wxArtProvidersList;
21 class WXDLLIMPEXP_FWD_CORE wxArtProviderCache;
22 class wxArtProviderModule;
23
24 // ----------------------------------------------------------------------------
25 // Types
26 // ----------------------------------------------------------------------------
27
28 typedef wxString wxArtClient;
29 typedef wxString wxArtID;
30
31 #define wxART_MAKE_CLIENT_ID_FROM_STR(id) (id + _T("_C"))
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)
35
36 // ----------------------------------------------------------------------------
37 // Art clients
38 // ----------------------------------------------------------------------------
39
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)
43
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)
47 #define wxART_BUTTON wxART_MAKE_CLIENT_ID(wxART_BUTTON)
48 #define wxART_LIST wxART_MAKE_CLIENT_ID(wxART_LIST)
49
50 #define wxART_OTHER wxART_MAKE_CLIENT_ID(wxART_OTHER)
51
52 // ----------------------------------------------------------------------------
53 // Art IDs
54 // ----------------------------------------------------------------------------
55
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)
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)
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)
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)
82 #define wxART_FOLDER wxART_MAKE_ART_ID(wxART_FOLDER)
83 #define wxART_FOLDER_OPEN wxART_MAKE_ART_ID(wxART_FOLDER_OPEN)
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)
93 #define wxART_MISSING_IMAGE wxART_MAKE_ART_ID(wxART_MISSING_IMAGE)
94
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)
99 #define wxART_NEW wxART_MAKE_ART_ID(wxART_NEW)
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
110 // ----------------------------------------------------------------------------
111 // wxArtProvider class
112 // ----------------------------------------------------------------------------
113
114 class WXDLLEXPORT wxArtProvider : public wxObject
115 {
116 public:
117 // Dtor removes the provider from providers stack if it's still on it
118 virtual ~wxArtProvider();
119
120
121 // Add new provider to the top of providers stack (i.e. the provider will
122 // be queried first of all).
123 static void Push(wxArtProvider *provider);
124
125 // Add new provider to the bottom of providers stack (i.e. the provider
126 // will be queried as the last one).
127 static void Insert(wxArtProvider *provider);
128
129 // Remove latest added provider and delete it.
130 static bool Pop();
131
132 // Remove provider from providers stack but don't delete it.
133 static bool Remove(wxArtProvider *provider);
134
135 // Delete the given provider and remove it from the providers stack.
136 static bool Delete(wxArtProvider *provider);
137
138
139 // Query the providers for bitmap with given ID and return it. Return
140 // wxNullBitmap if no provider provides it.
141 static wxBitmap GetBitmap(const wxArtID& id,
142 const wxArtClient& client = wxART_OTHER,
143 const wxSize& size = wxDefaultSize);
144
145 // Query the providers for icon with given ID and return it. Return
146 // wxNullIcon if no provider provides it.
147 static wxIcon GetIcon(const wxArtID& id,
148 const wxArtClient& client = wxART_OTHER,
149 const wxSize& size = wxDefaultSize);
150
151 // Helper used by several generic classes: return the icon corresponding to
152 // the standard wxICON_INFORMATION/WARNING/ERROR/QUESTION flags (only one
153 // can be set)
154 static wxIcon GetMessageBoxIcon(int flags);
155
156 // Query the providers for iconbundle with given ID and return it. Return
157 // wxNullIconBundle if no provider provides it.
158 static wxIconBundle GetIconBundle(const wxArtID& id,
159 const wxArtClient& client = wxART_OTHER);
160
161 // Get the size hint of an icon from a specific wxArtClient, queries
162 // the topmost provider if platform_dependent = false
163 static wxSize GetSizeHint(const wxArtClient& client, bool platform_dependent = false);
164
165 #if WXWIN_COMPATIBILITY_2_6
166 // use the corresponding methods without redundant "Provider" suffix
167 wxDEPRECATED( static void PushProvider(wxArtProvider *provider) );
168 wxDEPRECATED( static void InsertProvider(wxArtProvider *provider) );
169 wxDEPRECATED( static bool PopProvider() );
170
171 // use Delete() if this is what you really need, or just delete the
172 // provider pointer, do not use Remove() as it does not delete the pointer
173 // unlike RemoveProvider() which does
174 wxDEPRECATED( static bool RemoveProvider(wxArtProvider *provider) );
175 #endif // WXWIN_COMPATIBILITY_2_6
176
177 protected:
178 friend class wxArtProviderModule;
179 // Initializes default provider
180 static void InitStdProvider();
181 // Initializes platform's native provider, if available (e.g. GTK2)
182 static void InitNativeProvider();
183 // Destroy caches & all providers
184 static void CleanUpProviders();
185
186 // Get the default size of an icon for a specific client
187 virtual wxSize DoGetSizeHint(const wxArtClient& client)
188 {
189 return GetSizeHint(client, true);
190 }
191
192 // Derived classes must override CreateBitmap or CreateIconBundle
193 // (or both) to create requested art resource. This method is called
194 // only once per instance's lifetime for each requested wxArtID.
195 virtual wxBitmap CreateBitmap(const wxArtID& WXUNUSED(id),
196 const wxArtClient& WXUNUSED(client),
197 const wxSize& WXUNUSED(size)) { return wxNullBitmap; }
198
199 virtual wxIconBundle CreateIconBundle(const wxArtID& WXUNUSED(id),
200 const wxArtClient& WXUNUSED(client))
201 {
202 return wxNullIconBundle;
203 }
204
205 private:
206 static void CommonAddingProvider();
207
208 private:
209 // list of providers:
210 static wxArtProvidersList *sm_providers;
211 // art resources cache (so that CreateXXX is not called that often):
212 static wxArtProviderCache *sm_cache;
213
214 DECLARE_ABSTRACT_CLASS(wxArtProvider)
215 };
216
217
218 #endif // _WX_ARTPROV_H_