]>
Commit | Line | Data |
---|---|---|
f4fcc291 JS |
1 | % |
2 | % automatically generated by HelpGen $Revision$ from | |
3 | % artprov.h at 08/Apr/02 17:44:57 | |
4 | % | |
5 | ||
6 | \section{\class{wxArtProvider}}\label{wxartprovider} | |
7 | ||
fc2171bd | 8 | wxArtProvider class is used to customize the look of wxWidgets application. |
25057aba JS |
9 | When wxWidgets needs to display an icon or a bitmap (e.g. in the standard file |
10 | dialog), it does not use a hard-coded resource but asks wxArtProvider for it | |
11 | instead. This way users can plug in their own wxArtProvider class and easily | |
12 | replace standard art with their own version. All | |
52734360 VZ |
13 | that is needed is to derive a class from wxArtProvider, override either its |
14 | \helpref{CreateBitmap}{wxartprovidercreatebitmap} and/or its | |
15 | \helpref{CreateIconBundle}{wxartprovidercreateiconbundle} methods | |
16 | and register the provider with | |
571d2e0f | 17 | \helpref{wxArtProvider::Push}{wxartproviderpush}: |
e7300ec6 VS |
18 | |
19 | \begin{verbatim} | |
20 | class MyProvider : public wxArtProvider | |
21 | { | |
22 | protected: | |
23 | wxBitmap CreateBitmap(const wxArtID& id, | |
24 | const wxArtClient& client, | |
25 | const wxSize size) | |
52734360 VZ |
26 | |
27 | // optionally override this one as well | |
28 | wxIconBundle CreateIconBundle(const wxArtID& id, | |
29 | const wxArtClient& client) | |
e7300ec6 VS |
30 | { ... } |
31 | }; | |
32 | ... | |
571d2e0f | 33 | wxArtProvider::Push(new MyProvider); |
e7300ec6 VS |
34 | \end{verbatim} |
35 | ||
52734360 VZ |
36 | If you need bitmap images (of the same artwork) that should be displayed at different sizes |
37 | you should probably consider overriding \helpref{CreateIconBundle()}{wxartprovidercreateiconbundle} | |
38 | and supplying icon bundles that contain different bitmap sizes. | |
39 | ||
e7300ec6 | 40 | There's another way of taking advantage of this class: you can use it in your code and use |
dceb1c09 | 41 | platform native icons as provided by \helpref{wxArtProvider::GetBitmap}{wxartprovidergetbitmap} or |
e7300ec6 | 42 | \helpref{wxArtProvider::GetIcon}{wxartprovidergeticon} (NB: this is not yet really |
fc2171bd | 43 | possible as of wxWidgets 2.3.3, the set of wxArtProvider bitmaps is too |
e7300ec6 VS |
44 | small). |
45 | ||
571d2e0f | 46 | |
f510b7b2 | 47 | \membersection{Identifying art resources}\label{artprovideridentifying} |
e7300ec6 | 48 | |
52734360 | 49 | Every bitmap and icon bundle are known to wxArtProvider under an unique ID that is used when |
e7300ec6 VS |
50 | requesting a resource from it. The ID is represented by wxArtID type and can |
51 | have one of these predefined values (you can see bitmaps represented by these | |
52 | constants in the \helpref{artprov}{sampleartprovider} sample): | |
53 | \begin{itemize}\itemsep=0pt | |
d6b7a928 VZ |
54 | |
55 | \item wxART\_ERROR | |
56 | \item wxART\_QUESTION | |
57 | \item wxART\_WARNING | |
58 | \item wxART\_INFORMATION | |
59 | \item wxART\_ADD\_BOOKMARK | |
60 | \item wxART\_DEL\_BOOKMARK | |
61 | \item wxART\_HELP\_SIDE\_PANEL | |
62 | \item wxART\_HELP\_SETTINGS | |
63 | \item wxART\_HELP\_BOOK | |
64 | \item wxART\_HELP\_FOLDER | |
65 | \item wxART\_HELP\_PAGE | |
66 | \item wxART\_GO\_BACK | |
67 | \item wxART\_GO\_FORWARD | |
68 | \item wxART\_GO\_UP | |
69 | \item wxART\_GO\_DOWN | |
70 | \item wxART\_GO\_TO\_PARENT | |
71 | \item wxART\_GO\_HOME | |
72 | \item wxART\_PRINT | |
73 | \item wxART\_HELP | |
74 | \item wxART\_TIP | |
75 | \item wxART\_REPORT\_VIEW | |
76 | \item wxART\_LIST\_VIEW | |
77 | \item wxART\_NEW\_DIR | |
78 | \item wxART\_FOLDER | |
79 | \item wxART\_FOLDER\_OPEN | |
80 | \item wxART\_GO\_DIR\_UP | |
81 | \item wxART\_EXECUTABLE\_FILE | |
82 | \item wxART\_NORMAL\_FILE | |
83 | \item wxART\_TICK\_MARK | |
84 | \item wxART\_CROSS\_MARK | |
85 | \item wxART\_MISSING\_IMAGE | |
86 | \item wxART\_NEW | |
87 | \item wxART\_FILE\_OPEN | |
88 | \item wxART\_FILE\_SAVE | |
89 | \item wxART\_FILE\_SAVE\_AS | |
90 | \item wxART\_DELETE | |
91 | \item wxART\_COPY | |
92 | \item wxART\_CUT | |
93 | \item wxART\_PASTE | |
94 | \item wxART\_UNDO | |
95 | \item wxART\_REDO | |
96 | \item wxART\_QUIT | |
97 | \item wxART\_FIND | |
98 | \item wxART\_FIND\_AND\_REPLACE | |
99 | \item wxART\_HARDDISK | |
100 | \item wxART\_FLOPPY | |
101 | \item wxART\_CDROM | |
102 | \item wxART\_REMOVABLE | |
103 | ||
e7300ec6 VS |
104 | \end{itemize} |
105 | ||
571d2e0f VZ |
106 | Additionally, any string recognized by custom art providers registered using |
107 | \helpref{Push}{wxartproviderpush} may be used. | |
b5ab476a VS |
108 | |
109 | \wxheading{GTK+ Note} | |
110 | ||
111 | When running under GTK+ 2, GTK+ stock item IDs (e.g. {\tt "gtk-cdrom"}) may | |
112 | be used as well. Additionally, if wxGTK was compiled against GTK+ >= 2.4, then | |
113 | it is also possible to load icons from current icon theme by specifying their | |
114 | name (without extension and directory components). Icon themes recognized | |
115 | by GTK+ follow the | |
116 | \urlref{freedesktop.org Icon Themes specification}{http://freedesktop.org/Standards/icon-theme-spec}. Note that themes are not guaranteed to contain all | |
117 | icons, so wxArtProvider may return {\tt wxNullBitmap} or {\tt wxNullIcon}. | |
118 | Default theme is typically installed in {\tt /usr/share/icons/hicolor}. | |
7bebedd8 | 119 | |
571d2e0f | 120 | |
f510b7b2 | 121 | \membersection{Clients}\label{artproviderclients} |
e7300ec6 VS |
122 | |
123 | Client is the entity that calls wxArtProvider's GetBitmap or GetIcon | |
124 | function. It is represented by wxClientID type and can have one of these | |
125 | values: | |
126 | \begin{itemize}\itemsep=0pt | |
127 | \item wxART\_TOOLBAR | |
128 | \item wxART\_MENU | |
b5cf8234 | 129 | \item wxART\_BUTTON |
e7300ec6 VS |
130 | \item wxART\_FRAME\_ICON |
131 | \item wxART\_CMN\_DIALOG | |
132 | \item wxART\_HELP\_BROWSER | |
133 | \item wxART\_MESSAGE\_BOX | |
134 | \item wxART\_OTHER (used for all requests that don't fit into any of the categories above) | |
135 | \end{itemize} | |
136 | Client ID servers as a hint to wxArtProvider that is supposed to help it to | |
137 | choose the best looking bitmap. For example it is often desirable to use | |
138 | slightly different icons in menus and toolbars even though they represent the | |
139 | same action (e.g. {\tt wx\_ART\_FILE\_OPEN}). Remember that this is really | |
140 | only a hint for wxArtProvider -- it is common that | |
141 | \helpref{wxArtProvider::GetBitmap}{wxartprovidergetbitmap} | |
142 | returns identical bitmap for different {\it client} values! | |
143 | ||
144 | \wxheading{See also} | |
145 | ||
146 | See the \helpref{artprov}{sampleartprovider} sample for an example of wxArtProvider usage. | |
f4fcc291 JS |
147 | |
148 | \wxheading{Derived from} | |
149 | ||
150 | \helpref{wxObject}{wxobject} | |
151 | ||
152 | \wxheading{Include files} | |
153 | ||
154 | <wx/artprov.h> | |
155 | ||
a7af285d VZ |
156 | \wxheading{Library} |
157 | ||
158 | \helpref{wxCore}{librarieslist} | |
159 | ||
e7300ec6 | 160 | \latexignore{\rtfignore{\wxheading{Members}}} |
f4fcc291 | 161 | |
571d2e0f VZ |
162 | |
163 | \membersection{wxArtProvider::\destruct{wxArtProvider}}\label{wxartproviderdtor} | |
164 | ||
165 | \func{}{\destruct{wxArtProvider}}{\void} | |
166 | ||
167 | The destructor automatically removes the provider from the provider stack used | |
168 | by \helpref{GetBitmap}{wxartprovidergetbitmap}. | |
169 | ||
170 | ||
e7300ec6 | 171 | \membersection{wxArtProvider::CreateBitmap}\label{wxartprovidercreatebitmap} |
f4fcc291 | 172 | |
e7300ec6 | 173 | \func{wxBitmap}{CreateBitmap}{\param{const wxArtID\& }{id}, \param{const wxArtClient\& }{client}, \param{const wxSize\& }{size}} |
f4fcc291 | 174 | |
bafddbe8 VZ |
175 | Derived art provider classes must override this method to create requested art |
176 | resource. Note that returned bitmaps are cached by wxArtProvider and it is | |
177 | therefore not necessary to optimize CreateBitmap() for speed (e.g. you may | |
178 | create wxBitmap objects from XPMs here). | |
f4fcc291 | 179 | |
e7300ec6 | 180 | \wxheading{Parameters} |
f4fcc291 | 181 | |
e7300ec6 | 182 | \docparam{id}{wxArtID unique identifier of the bitmap.} |
f4fcc291 | 183 | |
e7300ec6 VS |
184 | \docparam{client}{wxArtClient identifier of the client (i.e. who is asking for the bitmap). |
185 | This only servers as a hint.} | |
186 | ||
dbd94b75 | 187 | \docparam{size}{Preferred size of the bitmap. The function may return a bitmap of different |
e7300ec6 | 188 | dimensions, it will be automatically rescaled to meet client's request.} |
f4fcc291 | 189 | |
e7300ec6 | 190 | \wxheading{Note} |
f4fcc291 | 191 | |
e7300ec6 VS |
192 | This is {\bf not} part of wxArtProvider's public API, use |
193 | \helpref{wxArtProvider::GetBitmap}{wxartprovidergetbitmap} or | |
52734360 | 194 | \helpref{wxArtProvider::GetIconBundle}{wxartprovidergeticonbundle} or |
e7300ec6 VS |
195 | \helpref{wxArtProvider::GetIcon}{wxartprovidergeticon} |
196 | to query wxArtProvider for a resource. | |
f4fcc291 | 197 | |
bafddbe8 | 198 | \wxheading{See also} |
571d2e0f | 199 | |
bafddbe8 | 200 | \helpref{CreateIconBundle}{wxartprovidercreateiconbundle} |
52734360 | 201 | |
52734360 | 202 | |
bafddbe8 | 203 | \membersection{wxArtProvider::CreateIconBundle}\label{wxartprovidercreateiconbundle} |
52734360 | 204 | |
bafddbe8 | 205 | \func{wxIconBundle}{CreateIconBundle}{\param{const wxArtID\& }{id}, \param{const wxArtClient\& }{client}} |
52734360 | 206 | |
bafddbe8 VZ |
207 | This method is similar to \helpref{CreateBitmap}{wxartprovidercreatebitmap} but |
208 | can be used when a bitmap (or an icon) exists in several sizes. | |
52734360 | 209 | |
52734360 | 210 | |
52734360 | 211 | |
571d2e0f VZ |
212 | \membersection{wxArtProvider::Delete}\label{wxartproviderdelete} |
213 | ||
214 | \func{static bool}{Delete}{\param{wxArtProvider* }{provider}} | |
215 | ||
216 | Delete the given \arg{provider}. | |
217 | ||
218 | ||
f4fcc291 JS |
219 | \membersection{wxArtProvider::GetBitmap}\label{wxartprovidergetbitmap} |
220 | ||
e7300ec6 VS |
221 | \func{static wxBitmap}{GetBitmap}{\param{const wxArtID\& }{id}, \param{const wxArtClient\& }{client = wxART\_OTHER}, \param{const wxSize\& }{size = wxDefaultSize}} |
222 | ||
223 | Query registered providers for bitmap with given ID. | |
224 | ||
225 | \wxheading{Parameters} | |
226 | ||
227 | \docparam{id}{wxArtID unique identifier of the bitmap.} | |
228 | ||
229 | \docparam{client}{wxArtClient identifier of the client (i.e. who is asking for the bitmap).} | |
230 | ||
231 | \docparam{size}{Size of the returned bitmap or {\tt wxDefaultSize} if size doesn't matter.} | |
232 | ||
233 | \wxheading{Return value} | |
f4fcc291 | 234 | |
e7300ec6 | 235 | The bitmap if one of registered providers recognizes the ID or wxNullBitmap otherwise. |
f4fcc291 | 236 | |
571d2e0f | 237 | |
52734360 VZ |
238 | \membersection{wxArtProvider::GetIconBundle}\label{wxartprovidergeticonbundle} |
239 | ||
240 | \func{static wxIconBundle}{GetIconBundle}{\param{const wxArtID\& }{id}, \param{const wxArtClient\& }{client = wxART\_OTHER}} | |
241 | ||
242 | Query registered providers for icon bundle with given ID. | |
243 | ||
244 | \wxheading{Parameters} | |
245 | ||
246 | \docparam{id}{wxArtID unique identifier of the icon bundle.} | |
247 | ||
248 | \docparam{client}{wxArtClient identifier of the client (i.e. who is asking for the icon bundle).} | |
249 | ||
250 | \wxheading{Return value} | |
251 | ||
252 | The icon bundle if one of registered providers recognizes the ID or wxNullIconBundle otherwise. | |
253 | ||
254 | ||
f4fcc291 JS |
255 | \membersection{wxArtProvider::GetIcon}\label{wxartprovidergeticon} |
256 | ||
e7300ec6 | 257 | \func{static wxIcon}{GetIcon}{\param{const wxArtID\& }{id}, \param{const wxArtClient\& }{client = wxART\_OTHER}, \param{const wxSize\& }{size = wxDefaultSize}} |
f4fcc291 | 258 | |
e7300ec6 VS |
259 | Same as \helpref{wxArtProvider::GetBitmap}{wxartprovidergetbitmap}, but |
260 | return a wxIcon object (or wxNullIcon on failure). | |
f4fcc291 | 261 | |
40ca9449 | 262 | \func{static wxSize}{GetSizeHint}{\param{const wxArtClient\& }{client}, \param{bool }{platform\_default = false}} |
b737ad10 | 263 | |
e53a95bc | 264 | Returns a suitable size hint for the given {\it wxArtClient}. If |
40ca9449 | 265 | {\it platform\_default} is \true, return a size based on the current platform, |
e53a95bc | 266 | otherwise return the size from the topmost wxArtProvider. {\it wxDefaultSize} may be |
40ca9449 | 267 | returned if the client doesn't have a specified size, like wxART\_OTHER for example. |
b737ad10 | 268 | |
dd7d379e | 269 | |
571d2e0f VZ |
270 | \membersection{wxArtProvider::Insert}\label{wxartproviderinsert} |
271 | ||
272 | \func{static void}{Insert}{\param{wxArtProvider* }{provider}} | |
dd7d379e VS |
273 | |
274 | Register new art provider and add it to the bottom of providers stack (i.e. | |
275 | it will be queried as the last one). | |
276 | ||
277 | \wxheading{See also} | |
278 | ||
571d2e0f VZ |
279 | \helpref{Push}{wxartproviderpush} |
280 | ||
dd7d379e | 281 | |
571d2e0f | 282 | \membersection{wxArtProvider::Pop}\label{wxartproviderctor} |
f4fcc291 | 283 | |
571d2e0f | 284 | \func{static bool}{Pop}{\void} |
f4fcc291 JS |
285 | |
286 | Remove latest added provider and delete it. | |
287 | ||
f4fcc291 | 288 | |
571d2e0f VZ |
289 | \membersection{wxArtProvider::Push}\label{wxartproviderpush} |
290 | ||
291 | \func{static void}{Push}{\param{wxArtProvider* }{provider}} | |
f4fcc291 | 292 | |
dd7d379e VS |
293 | Register new art provider and add it to the top of providers stack (i.e. it |
294 | will be queried as the first provider). | |
295 | ||
296 | \wxheading{See also} | |
297 | ||
571d2e0f VZ |
298 | \helpref{Insert}{wxartproviderinsert} |
299 | ||
f4fcc291 | 300 | |
571d2e0f | 301 | \membersection{wxArtProvider::Remove}\label{wxartproviderremove} |
f4fcc291 | 302 | |
571d2e0f | 303 | \func{static bool}{Remove}{\param{wxArtProvider* }{provider}} |
f4fcc291 | 304 | |
571d2e0f VZ |
305 | Remove a provider from the stack if it is on it. The provider is {\emph not} |
306 | deleted, unlike when using \helpref{Delete()}{wxartproviderdelete}. | |
f4fcc291 | 307 |