]>
Commit | Line | Data |
---|---|---|
23324ae1 FM |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: renderer.h | |
e54c96f1 | 3 | // Purpose: interface of wxSplitterRenderParams |
23324ae1 FM |
4 | // Author: wxWidgets team |
5 | // RCS-ID: $Id$ | |
6 | // Licence: wxWindows license | |
7 | ///////////////////////////////////////////////////////////////////////////// | |
8 | ||
9 | /** | |
10 | @class wxSplitterRenderParams | |
11 | @wxheader{renderer.h} | |
7c913512 FM |
12 | |
13 | This is just a simple @c struct used as a return value of | |
23324ae1 | 14 | wxRendererNative::GetSplitterParams. |
7c913512 | 15 | |
23324ae1 FM |
16 | It doesn't have any methods and all of its fields are constant and so can be |
17 | only examined but not modified. | |
7c913512 | 18 | |
23324ae1 FM |
19 | @library{wxbase} |
20 | @category{FIXME} | |
21 | */ | |
7c913512 | 22 | class wxSplitterRenderParams |
23324ae1 FM |
23 | { |
24 | public: | |
25 | /** | |
26 | const wxCoord border | |
23324ae1 FM |
27 | The width of the border drawn by the splitter inside it, may be 0. |
28 | */ | |
29 | ||
30 | ||
31 | /** | |
32 | const bool isHotSensitive | |
23324ae1 FM |
33 | @true if the sash changes appearance when the mouse passes over it, @false |
34 | otherwise. | |
35 | */ | |
36 | ||
37 | ||
38 | /** | |
39 | const wxCoord widthSash | |
23324ae1 FM |
40 | The width of the splitter sash. |
41 | */ | |
42 | }; | |
43 | ||
44 | ||
e54c96f1 | 45 | |
23324ae1 FM |
46 | /** |
47 | @class wxDelegateRendererNative | |
48 | @wxheader{renderer.h} | |
7c913512 FM |
49 | |
50 | wxDelegateRendererNative allows reuse of renderers code by forwarding all the | |
23324ae1 FM |
51 | wxRendererNative methods to the given object and |
52 | thus allowing you to only modify some of its methods -- without having to | |
53 | reimplement all of them. | |
7c913512 | 54 | |
cdbcf4c2 | 55 | Note that the "normal", inheritance-based approach, doesn't work with the |
23324ae1 FM |
56 | renderers as it is impossible to derive from a class unknown at compile-time |
57 | and the renderer is only chosen at run-time. So suppose that you want to only | |
58 | add something to the drawing of the tree control buttons but leave all the | |
59 | other methods unchanged -- the only way to do it, considering that the renderer | |
60 | class which you want to customize might not even be written yet when you write | |
61 | your code (it could be written later and loaded from a DLL during run-time), is | |
62 | by using this class. | |
7c913512 FM |
63 | |
64 | Except for the constructor, it has exactly the same methods as | |
23324ae1 | 65 | wxRendererNative and their implementation is |
cdbcf4c2 | 66 | trivial: they are simply forwarded to the real renderer. Note that the "real" |
23324ae1 FM |
67 | renderer may, in turn, be a wxDelegateRendererNative as well and that there may |
68 | be arbitrarily many levels like this -- but at the end of the chain there must | |
69 | be a real renderer which does the drawing. | |
7c913512 | 70 | |
23324ae1 FM |
71 | @library{wxcore} |
72 | @category{FIXME} | |
73 | */ | |
74 | class wxDelegateRendererNative : public wxRendererNative | |
75 | { | |
76 | public: | |
77 | //@{ | |
78 | /** | |
79 | The default constructor does the same thing as the other one except that it | |
80 | uses the @ref wxRendererNative::getgeneric "generic renderer" instead of the | |
81 | user-specified @e rendererNative. | |
23324ae1 FM |
82 | In any case, this sets up the delegate renderer object to follow all calls to |
83 | the specified real renderer. | |
23324ae1 FM |
84 | Note that this object does not take ownership of (i.e. won't delete) |
85 | @e rendererNative. | |
86 | */ | |
87 | wxDelegateRendererNative(); | |
7c913512 | 88 | wxDelegateRendererNative(wxRendererNative& rendererNative); |
23324ae1 FM |
89 | //@} |
90 | ||
91 | /** | |
7c913512 | 92 | This class also provides all the virtual methods of |
23324ae1 FM |
93 | wxRendererNative, please refer to that class |
94 | documentation for the details. | |
95 | */ | |
7c913512 | 96 | DrawXXX(...); |
23324ae1 FM |
97 | }; |
98 | ||
99 | ||
e54c96f1 | 100 | |
23324ae1 FM |
101 | /** |
102 | @class wxRendererNative | |
103 | @wxheader{renderer.h} | |
7c913512 | 104 | |
23324ae1 | 105 | First, a brief introduction to wxRenderer and why it is needed. |
7c913512 | 106 | |
23324ae1 | 107 | Usually wxWidgets uses the underlying low level GUI system to draw all the |
cdbcf4c2 | 108 | controls - this is what we mean when we say that it is a "native" framework. |
23324ae1 FM |
109 | However not all controls exist under all (or even any) platforms and in this |
110 | case wxWidgets provides a default, generic, implementation of them written in | |
111 | wxWidgets itself. | |
7c913512 | 112 | |
23324ae1 FM |
113 | These controls don't have the native appearance if only the standard |
114 | line drawing and other graphics primitives are used, because the native | |
115 | appearance is different under different platforms while the lines are always | |
116 | drawn in the same way. | |
7c913512 | 117 | |
23324ae1 FM |
118 | This is why we have renderers: wxRenderer is a class which virtualizes the |
119 | drawing, i.e. it abstracts the drawing operations and allows you to draw say, a | |
120 | button, without caring about exactly how this is done. Of course, as we | |
121 | can draw the button differently in different renderers, this also allows us to | |
122 | emulate the native look and feel. | |
7c913512 | 123 | |
23324ae1 FM |
124 | So the renderers work by exposing a large set of high-level drawing functions |
125 | which are used by the generic controls. There is always a default global | |
7c913512 | 126 | renderer but it may be changed or extended by the user, see |
23324ae1 | 127 | @ref overview_samplerender "Render sample". |
7c913512 | 128 | |
23324ae1 | 129 | All drawing functions take some standard parameters: |
7c913512 | 130 | |
23324ae1 | 131 | @e win is the window being drawn. It is normally not used and when |
7c913512 | 132 | it is it should only be used as a generic wxWindow |
23324ae1 FM |
133 | (in order to get its low level handle, for example), but you should |
134 | not assume that it is of some given type as the same renderer | |
135 | function may be reused for drawing different kinds of control. | |
136 | @e dc is the wxDC to draw on. Only this device | |
137 | context should be used for drawing. It is not necessary to restore | |
138 | pens and brushes for it on function exit but, on the other hand, you | |
139 | shouldn't assume that it is in any specific state on function entry: | |
140 | the rendering functions should always prepare it. | |
141 | @e rect the bounding rectangle for the element to be drawn. | |
142 | @e flags the optional flags (none by default) which can be a | |
143 | combination of the @c wxCONTROL_XXX constants below. | |
7c913512 | 144 | |
23324ae1 FM |
145 | Note that each drawing function restores the wxDC attributes if |
146 | it changes them, so it is safe to assume that the same pen, brush and colours | |
147 | that were active before the call to this function are still in effect after it. | |
7c913512 | 148 | |
23324ae1 FM |
149 | @library{wxcore} |
150 | @category{gdi} | |
151 | */ | |
7c913512 | 152 | class wxRendererNative |
23324ae1 FM |
153 | { |
154 | public: | |
155 | /** | |
156 | Virtual destructor as for any base class. | |
157 | */ | |
158 | ~wxRendererNative(); | |
159 | ||
160 | /** | |
161 | Draw a check box (used by wxDataViewCtrl). | |
4cc4bfaf | 162 | @a flags may have the @c wxCONTROL_CHECKED, @c wxCONTROL_CURRENT or |
23324ae1 FM |
163 | @c wxCONTROL_UNDETERMINED bit set. |
164 | */ | |
4cc4bfaf | 165 | void DrawCheckBox(wxWindow* win, wxDC& dc, const wxRect& rect, |
23324ae1 FM |
166 | int flags); |
167 | ||
168 | /** | |
169 | Draw a button like the one used by wxComboBox to show a | |
170 | drop down window. The usual appearance is a downwards pointing arrow. | |
4cc4bfaf | 171 | @a flags may have the @c wxCONTROL_PRESSED or @c wxCONTROL_CURRENT bit set. |
23324ae1 | 172 | */ |
4cc4bfaf | 173 | void DrawComboBoxDropButton(wxWindow* win, wxDC& dc, |
23324ae1 FM |
174 | const wxRect& rect, |
175 | int flags); | |
176 | ||
177 | /** | |
178 | Draw a drop down arrow that is suitable for use outside a combo box. Arrow will | |
179 | have | |
180 | transparent background. | |
4cc4bfaf | 181 | @a rect is not entirely filled by the arrow. Instead, you should use bounding |
23324ae1 | 182 | rectangle of a drop down button which arrow matches the size you need. |
4cc4bfaf | 183 | @a flags may have the @c wxCONTROL_PRESSED or @c wxCONTROL_CURRENT bit set. |
23324ae1 | 184 | */ |
4cc4bfaf | 185 | void DrawDropArrow(wxWindow* win, wxDC& dc, const wxRect& rect, |
23324ae1 FM |
186 | int flags); |
187 | ||
188 | /** | |
189 | Draw a focus rectangle using the specified rectangle. | |
7c913512 | 190 | wxListCtrl. The only supported flags is |
23324ae1 FM |
191 | @c wxCONTROL_SELECTED for items which are selected. |
192 | */ | |
193 | void DrawFocusRect(wxWindow* win, wxDC& dc, const wxRect& rect, | |
194 | int flags = 0); | |
195 | ||
196 | /** | |
197 | Draw the header control button (used, for example, by | |
198 | wxListCtrl). Depending on platforms the | |
4cc4bfaf | 199 | @a flags parameter may support the @c wxCONTROL_SELECTED |
23324ae1 | 200 | @c wxCONTROL_DISABLED and @c wxCONTROL_CURRENT bits. |
4cc4bfaf | 201 | The @a sortArrow parameter can be one of |
23324ae1 FM |
202 | @c wxHDR_SORT_ICON_NONE, @c wxHDR_SORT_ICON_UP, or |
203 | @c wxHDR_SORT_ICON_DOWN. Additional values controlling the | |
204 | drawing of a text or bitmap label can be passed in @e params. The | |
205 | value returned is the optimal width to contain the the unabreviated | |
206 | label text or bitmap, the sort arrow if present, and internal margins. | |
207 | */ | |
208 | int DrawHeaderButton(wxWindow* win, wxDC& dc, const wxRect& rect, | |
209 | int flags = 0, | |
210 | wxHeaderSortIconType sortArrow = wxHDR_SORT_ICON_NONE, | |
4cc4bfaf | 211 | wxHeaderButtonParams* params = NULL); |
23324ae1 FM |
212 | |
213 | /** | |
7c913512 | 214 | Draw a selection rectangle underneath the text as used e.g. in a |
4cc4bfaf | 215 | wxListCtrl. The supported @a flags are |
23324ae1 FM |
216 | @c wxCONTROL_SELECTED for items which are selected (e.g. often a blue |
217 | rectangle) and @c wxCONTROL_CURRENT for the item that has the focus | |
218 | (often a dotted line around the item's text). @c wxCONTROL_FOCUSED may | |
219 | be used to indicate if the control has the focus (othewise the the selection | |
220 | rectangle is e.g. often grey and not blue). This may be ignored by the renderer | |
221 | or deduced by the code directly from the @e win. | |
222 | */ | |
223 | void DrawItemSelectionRect(wxWindow* win, wxDC& dc, | |
224 | const wxRect& rect, | |
225 | int flags = 0); | |
226 | ||
227 | /** | |
228 | Draw a blank push button that looks very similar to wxButton. | |
4cc4bfaf | 229 | @a flags may have the @c wxCONTROL_PRESSED, @c wxCONTROL_CURRENT or |
23324ae1 FM |
230 | @c wxCONTROL_ISDEFAULT bit set. |
231 | */ | |
4cc4bfaf | 232 | void DrawPushButton(wxWindow* win, wxDC& dc, const wxRect& rect, |
23324ae1 FM |
233 | int flags); |
234 | ||
235 | /** | |
236 | Draw the border for sash window: this border must be such that the sash | |
237 | drawn by @ref drawsplittersash() DrawSash blends into it | |
238 | well. | |
239 | */ | |
240 | void DrawSplitterBorder(wxWindow* win, wxDC& dc, | |
241 | const wxRect& rect, | |
242 | int flags = 0); | |
243 | ||
244 | /** | |
4cc4bfaf FM |
245 | Draw a sash. The @a orient parameter defines whether the sash should be |
246 | vertical or horizontal and how the @a position should be interpreted. | |
23324ae1 FM |
247 | */ |
248 | void DrawSplitterSash(wxWindow* win, wxDC& dc, | |
249 | const wxSize& size, | |
250 | wxCoord position, | |
251 | wxOrientation orient, | |
252 | int flags = 0); | |
253 | ||
254 | /** | |
255 | Draw the expanded/collapsed icon for a tree control item. To draw an expanded | |
4cc4bfaf | 256 | button the @a flags parameter must contain @c wxCONTROL_EXPANDED bit. |
23324ae1 FM |
257 | */ |
258 | void DrawTreeItemButton(wxWindow* win, wxDC& dc, | |
259 | const wxRect& rect, | |
260 | int flags = 0); | |
261 | ||
262 | /** | |
263 | Return the currently used renderer. | |
264 | */ | |
4cc4bfaf | 265 | wxRendererNative Get(); |
23324ae1 FM |
266 | |
267 | /** | |
268 | Return the default (native) implementation for this platform -- this is also | |
7c913512 | 269 | the one used by default but this may be changed by calling |
23324ae1 FM |
270 | Set() in which case the return value of this |
271 | method may be different from the return value of Get(). | |
272 | */ | |
273 | wxRendererNative GetDefault(); | |
274 | ||
275 | /** | |
276 | Return the generic implementation of the renderer. Under some platforms, this | |
277 | is the default renderer implementation, others have platform-specific default | |
278 | renderer which can be retrieved by calling GetDefault(). | |
279 | */ | |
280 | wxRendererNative GetGeneric(); | |
281 | ||
282 | /** | |
283 | Returns the height of a header button, either a fixed platform height if | |
7c913512 | 284 | available, or a |
23324ae1 FM |
285 | generic height based on the window's font. |
286 | */ | |
287 | int GetHeaderButtonHeight(const wxWindow* win); | |
288 | ||
289 | /** | |
7c913512 | 290 | Get the splitter parameters, see |
23324ae1 FM |
291 | wxSplitterRenderParams. |
292 | */ | |
293 | wxSplitterRenderParams GetSplitterParams(const wxWindow* win); | |
294 | ||
295 | /** | |
7c913512 | 296 | This function is used for version checking: Load() |
23324ae1 FM |
297 | refuses to load any shared libraries implementing an older or incompatible |
298 | version. | |
23324ae1 | 299 | The implementation of this method is always the same in all renderers (simply |
7c913512 | 300 | construct wxRendererVersion using the |
23324ae1 FM |
301 | @c wxRendererVersion::Current_XXX values), but it has to be in the derived, |
302 | not base, class, to detect mismatches between the renderers versions and so you | |
303 | have to implement it anew in all renderers. | |
304 | */ | |
328f5751 | 305 | wxRendererVersion GetVersion() const; |
23324ae1 FM |
306 | |
307 | /** | |
308 | Load the renderer from the specified DLL, the returned pointer must be | |
309 | deleted by caller if not @NULL when it is not used any more. | |
4cc4bfaf | 310 | The @a name should be just the base name of the renderer and not the full |
7c913512 FM |
311 | name of the DLL file which is constructed differently (using |
312 | wxDynamicLibrary::CanonicalizePluginName) | |
23324ae1 FM |
313 | on different systems. |
314 | */ | |
315 | wxRendererNative* Load(const wxString& name); | |
316 | ||
317 | /** | |
318 | Set the renderer to use, passing @NULL reverts to using the default | |
319 | renderer (the global renderer must always exist). | |
23324ae1 FM |
320 | Return the previous renderer used with Set() or @NULL if none. |
321 | */ | |
4cc4bfaf | 322 | wxRendererNative* Set(wxRendererNative* renderer); |
23324ae1 FM |
323 | }; |
324 | ||
325 | ||
e54c96f1 | 326 | |
23324ae1 FM |
327 | /** |
328 | @class wxRendererVersion | |
329 | @wxheader{renderer.h} | |
7c913512 FM |
330 | |
331 | This simple struct represents the wxRendererNative | |
332 | interface version and is only used as the return value of | |
23324ae1 | 333 | wxRendererNative::GetVersion. |
7c913512 | 334 | |
23324ae1 FM |
335 | The version has two components: the version itself and the age. If the main |
336 | program and the renderer have different versions they are never compatible with | |
337 | each other because the version is only changed when an existing virtual | |
338 | function is modified or removed. The age, on the other hand, is incremented | |
339 | each time a new virtual method is added and so, at least for the compilers | |
340 | using a common C++ object model, the calling program is compatible with any | |
341 | renderer which has the age greater or equal to its age. This verification is | |
e54c96f1 | 342 | done by IsCompatible() method. |
7c913512 | 343 | |
23324ae1 FM |
344 | @library{wxbase} |
345 | @category{FIXME} | |
346 | */ | |
7c913512 | 347 | class wxRendererVersion |
23324ae1 FM |
348 | { |
349 | public: | |
350 | /** | |
7c913512 | 351 | Checks if the main program is compatible with the renderer having the version |
23324ae1 | 352 | @e ver, returns @true if it is and @false otherwise. |
7c913512 | 353 | This method is used by |
23324ae1 FM |
354 | wxRendererNative::Load to determine whether a |
355 | renderer can be used. | |
356 | */ | |
357 | static bool IsCompatible(const wxRendererVersion& ver); | |
358 | ||
359 | /** | |
360 | const int age | |
23324ae1 FM |
361 | The age component. |
362 | */ | |
363 | ||
364 | ||
365 | /** | |
366 | const int version | |
23324ae1 FM |
367 | The version component. |
368 | */ | |
369 | }; | |
e54c96f1 | 370 |