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