]>
Commit | Line | Data |
---|---|---|
1e6feb95 VZ |
1 | /////////////////////////////////////////////////////////////////////////////// |
2 | // Name: wx/univ/renderer.h | |
3 | // Purpose: wxRenderer class declaration | |
4 | // Author: Vadim Zeitlin | |
5 | // Modified by: | |
6 | // Created: 06.08.00 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) 2000 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr> | |
9 | // Licence: wxWindows license | |
10 | /////////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | /* | |
13 | wxRenderer class is used to draw all wxWindows controls. This is an ABC and | |
14 | the look of the application is determined by the concrete derivation of | |
15 | wxRenderer used in the program. | |
16 | ||
17 | It also contains a few static methods which may be used by the concrete | |
18 | renderers and provide the functionality which is often similar or identical | |
19 | in all renderers (using inheritance here would be more restrictive as the | |
20 | given concrete renderer may need an arbitrary subset of the base class | |
21 | methods) | |
22 | */ | |
23 | ||
24 | #ifdef __GNUG__ | |
25 | #pragma interface "renderer.h" | |
26 | #endif | |
27 | ||
28 | #ifndef _WX_UNIV_RENDERER_H_ | |
29 | #define _WX_UNIV_RENDERER_H_ | |
30 | ||
31 | class WXDLLEXPORT wxDC; | |
32 | class WXDLLEXPORT wxCheckListBox; | |
33 | class WXDLLEXPORT wxListBox; | |
34 | class WXDLLEXPORT wxMenu; | |
35 | class WXDLLEXPORT wxScrollBar; | |
36 | class WXDLLEXPORT wxTextCtrl; | |
37 | class WXDLLEXPORT wxWindow; | |
38 | ||
39 | #include "wx/string.h" | |
40 | #include "wx/gdicmn.h" | |
41 | #include "wx/scrolbar.h" // for wxScrollBar::Element | |
42 | ||
43 | #ifndef WX_PRECOMP | |
44 | #include "wx/menu.h" // for wxMenuGeometryInfo | |
45 | #endif // WX_PRECOMP | |
46 | ||
47 | // ---------------------------------------------------------------------------- | |
48 | // wxRenderer: abstract renderers interface | |
49 | // ---------------------------------------------------------------------------- | |
50 | ||
51 | class WXDLLEXPORT wxRenderer | |
52 | { | |
53 | public: | |
54 | // drawing functions | |
55 | // ----------------- | |
56 | ||
57 | // draw the controls background | |
58 | virtual void DrawBackground(wxDC& dc, | |
59 | const wxColour& col, | |
60 | const wxRect& rect, | |
61 | int flags) = 0; | |
62 | ||
63 | // draw the label inside the given rectangle with the specified alignment | |
64 | // and optionally emphasize the character with the given index | |
65 | virtual void DrawLabel(wxDC& dc, | |
66 | const wxString& label, | |
67 | const wxRect& rect, | |
68 | int flags = 0, | |
69 | int alignment = wxALIGN_LEFT | wxALIGN_TOP, | |
70 | int indexAccel = -1, | |
71 | wxRect *rectBounds = NULL) = 0; | |
72 | ||
73 | // same but also draw a bitmap if it is valid | |
74 | virtual void DrawButtonLabel(wxDC& dc, | |
75 | const wxString& label, | |
76 | const wxBitmap& image, | |
77 | const wxRect& rect, | |
78 | int flags = 0, | |
79 | int alignment = wxALIGN_LEFT | wxALIGN_TOP, | |
80 | int indexAccel = -1, | |
81 | wxRect *rectBounds = NULL) = 0; | |
82 | ||
83 | // draw the border and optionally return the rectangle containing the | |
84 | // region inside the border | |
85 | virtual void DrawBorder(wxDC& dc, | |
86 | wxBorder border, | |
87 | const wxRect& rect, | |
88 | int flags = 0, | |
89 | wxRect *rectIn = (wxRect *)NULL) = 0; | |
90 | ||
91 | // draw text control border (I hate to have a separate method for this but | |
92 | // it is needed to accomodate GTK+) | |
93 | virtual void DrawTextBorder(wxDC& dc, | |
94 | wxBorder border, | |
95 | const wxRect& rect, | |
96 | int flags = 0, | |
97 | wxRect *rectIn = (wxRect *)NULL) = 0; | |
98 | ||
99 | // draw push button border and return the rectangle left for the label | |
100 | virtual void DrawButtonBorder(wxDC& dc, | |
101 | const wxRect& rect, | |
102 | int flags = 0, | |
103 | wxRect *rectIn = (wxRect *)NULL) = 0; | |
104 | ||
105 | // draw a horizontal line | |
106 | virtual void DrawHorizontalLine(wxDC& dc, | |
107 | wxCoord y, wxCoord x1, wxCoord x2) = 0; | |
108 | ||
109 | // draw a vertical line | |
110 | virtual void DrawVerticalLine(wxDC& dc, | |
111 | wxCoord x, wxCoord y1, wxCoord y2) = 0; | |
112 | ||
113 | // draw a frame with the label (horizontal alignment can be specified) | |
114 | virtual void DrawFrame(wxDC& dc, | |
115 | const wxString& label, | |
116 | const wxRect& rect, | |
117 | int flags = 0, | |
118 | int alignment = wxALIGN_LEFT, | |
119 | int indexAccel = -1) = 0; | |
120 | ||
121 | // draw an arrow in the given direction | |
122 | virtual void DrawArrow(wxDC& dc, | |
123 | wxDirection dir, | |
124 | const wxRect& rect, | |
125 | int flags = 0) = 0; | |
126 | ||
127 | // draw a scrollbar arrow (may be the same as arrow but may be not) | |
128 | virtual void DrawScrollbarArrow(wxDC& dc, | |
129 | wxDirection dir, | |
130 | const wxRect& rect, | |
131 | int flags = 0) = 0; | |
132 | ||
133 | // draw the scrollbar thumb | |
134 | virtual void DrawScrollbarThumb(wxDC& dc, | |
135 | wxOrientation orient, | |
136 | const wxRect& rect, | |
137 | int flags = 0) = 0; | |
138 | ||
139 | // draw a (part of) scrollbar shaft | |
140 | virtual void DrawScrollbarShaft(wxDC& dc, | |
141 | wxOrientation orient, | |
142 | const wxRect& rect, | |
143 | int flags = 0) = 0; | |
144 | ||
145 | // draw the rectangle in the corner between two scrollbars | |
146 | virtual void DrawScrollCorner(wxDC& dc, | |
147 | const wxRect& rect) = 0; | |
148 | ||
149 | // draw an item of a wxListBox | |
150 | virtual void DrawItem(wxDC& dc, | |
151 | const wxString& label, | |
152 | const wxRect& rect, | |
153 | int flags = 0) = 0; | |
154 | ||
155 | // draw an item of a wxCheckListBox | |
156 | virtual void DrawCheckItem(wxDC& dc, | |
157 | const wxString& label, | |
158 | const wxBitmap& bitmap, | |
159 | const wxRect& rect, | |
160 | int flags = 0) = 0; | |
161 | ||
162 | // draw a checkbutton (bitmap may be invalid to use default one) | |
163 | virtual void DrawCheckButton(wxDC& dc, | |
164 | const wxString& label, | |
165 | const wxBitmap& bitmap, | |
166 | const wxRect& rect, | |
167 | int flags = 0, | |
168 | wxAlignment align = wxALIGN_LEFT, | |
169 | int indexAccel = -1) = 0; | |
170 | ||
171 | // draw a radio button | |
172 | virtual void DrawRadioButton(wxDC& dc, | |
173 | const wxString& label, | |
174 | const wxBitmap& bitmap, | |
175 | const wxRect& rect, | |
176 | int flags = 0, | |
177 | wxAlignment align = wxALIGN_LEFT, | |
178 | int indexAccel = -1) = 0; | |
179 | ||
180 | // draw a (part of) line in the text control | |
181 | virtual void DrawTextLine(wxDC& dc, | |
182 | const wxString& text, | |
183 | const wxRect& rect, | |
184 | int selStart = -1, | |
185 | int selEnd = -1, | |
186 | int flags = 0) = 0; | |
187 | ||
188 | // draw a line wrap indicator | |
189 | virtual void DrawLineWrapMark(wxDC& dc, const wxRect& rect) = 0; | |
190 | ||
191 | // draw a notebook tab | |
192 | virtual void DrawTab(wxDC& dc, | |
193 | const wxRect& rect, | |
194 | wxDirection dir, | |
195 | const wxString& label, | |
196 | const wxBitmap& bitmap = wxNullBitmap, | |
197 | int flags = 0, | |
198 | int indexAccel = -1) = 0; | |
199 | ||
200 | // draw the slider shaft | |
201 | virtual void DrawSliderShaft(wxDC& dc, | |
202 | const wxRect& rect, | |
203 | wxOrientation orient, | |
204 | int flags = 0, | |
205 | wxRect *rectShaft = NULL) = 0; | |
206 | ||
207 | // draw the slider thumb | |
208 | virtual void DrawSliderThumb(wxDC& dc, | |
209 | const wxRect& rect, | |
210 | wxOrientation orient, | |
211 | int flags = 0) = 0; | |
212 | ||
213 | // draw the slider ticks | |
214 | virtual void DrawSliderTicks(wxDC& dc, | |
215 | const wxRect& rect, | |
216 | const wxSize& sizeThumb, | |
217 | wxOrientation orient, | |
218 | int start, | |
219 | int end, | |
220 | int step = 1, | |
221 | int flags = 0) = 0; | |
222 | ||
223 | // draw a menu bar item | |
224 | virtual void DrawMenuBarItem(wxDC& dc, | |
225 | const wxRect& rect, | |
226 | const wxString& label, | |
227 | int flags = 0, | |
228 | int indexAccel = -1) = 0; | |
229 | ||
230 | // draw a menu item (also used for submenus if flags has ISSUBMENU flag) | |
231 | // | |
232 | // the geometryInfo is calculated by GetMenuGeometry() function from below | |
233 | virtual void DrawMenuItem(wxDC& dc, | |
234 | wxCoord y, | |
235 | const wxMenuGeometryInfo& geometryInfo, | |
236 | const wxString& label, | |
237 | const wxString& accel, | |
238 | const wxBitmap& bitmap = wxNullBitmap, | |
239 | int flags = 0, | |
240 | int indexAccel = -1) = 0; | |
241 | ||
242 | // draw a menu bar separator | |
243 | virtual void DrawMenuSeparator(wxDC& dc, | |
244 | wxCoord y, | |
245 | const wxMenuGeometryInfo& geomInfo) = 0; | |
246 | ||
247 | // misc functions | |
248 | // -------------- | |
249 | ||
250 | // return the bitmaps to use for combobox button | |
251 | virtual void GetComboBitmaps(wxBitmap *bmpNormal, | |
252 | wxBitmap *bmpPressed, | |
253 | wxBitmap *bmpDisabled) = 0; | |
254 | ||
255 | // geometry functions | |
256 | // ------------------ | |
257 | ||
258 | // get the dimensions of the border: rect.x/y contain the width/height of | |
259 | // the left/top side, width/heigh - of the right/bottom one | |
260 | virtual wxRect GetBorderDimensions(wxBorder border) const = 0; | |
261 | ||
262 | // the scrollbars may be drawn either inside the window border or outside | |
263 | // it - this function is used to decide how to draw them | |
264 | virtual bool AreScrollbarsInsideBorder() const = 0; | |
265 | ||
266 | // adjust the size of the control of the given class: for most controls, | |
267 | // this just takes into account the border, but for some (buttons, for | |
268 | // example) it is more complicated - the result being, in any case, that | |
269 | // the control looks "nice" if it uses the adjusted rectangle | |
270 | virtual void AdjustSize(wxSize *size, const wxWindow *window) = 0; | |
271 | ||
272 | // get the size of a scrollbar arrow | |
273 | virtual wxSize GetScrollbarArrowSize() const = 0; | |
274 | ||
275 | // gets the bounding box for a scrollbar element for the given (by default | |
276 | // - current) thumb position | |
277 | virtual wxRect GetScrollbarRect(const wxScrollBar *scrollbar, | |
278 | wxScrollBar::Element elem, | |
279 | int thumbPos = -1) const = 0; | |
280 | ||
281 | // returns the size of the scrollbar shaft excluding the arrows | |
282 | virtual wxCoord GetScrollbarSize(const wxScrollBar *scrollbar) = 0; | |
283 | ||
284 | // returns one of wxHT_SCROLLBAR_XXX constants | |
285 | virtual wxHitTest HitTestScrollbar(const wxScrollBar *scrollbar, | |
286 | const wxPoint& pt) const = 0; | |
287 | ||
288 | // translate the scrollbar position (in logical units) into physical | |
289 | // coordinate (in pixels) and the other way round | |
290 | virtual wxCoord ScrollbarToPixel(const wxScrollBar *scrollbar, | |
291 | int thumbPos = -1) = 0; | |
292 | virtual int PixelToScrollbar(const wxScrollBar *scrollbar, | |
293 | wxCoord coord) = 0; | |
294 | ||
295 | // get the height of a listbox item from the base font height | |
296 | virtual wxCoord GetListboxItemHeight(wxCoord fontHeight) = 0; | |
297 | ||
298 | // get the size of a checkbox/radio button bitmap | |
299 | virtual wxSize GetCheckBitmapSize() const = 0; | |
300 | virtual wxSize GetRadioBitmapSize() const = 0; | |
301 | virtual wxCoord GetCheckItemMargin() const = 0; | |
302 | ||
303 | // convert between text rectangle and client rectangle for text controls: | |
304 | // the former is typicall smaller to leave margins around text | |
305 | virtual wxRect GetTextTotalArea(const wxTextCtrl *text, | |
306 | const wxRect& rectText) = 0; | |
307 | ||
308 | // extra space is for line indicators | |
309 | virtual wxRect GetTextClientArea(const wxTextCtrl *text, | |
310 | const wxRect& rectTotal, | |
311 | wxCoord *extraSpaceBeyond) = 0; | |
312 | ||
313 | // get the overhang of a selected tab | |
314 | virtual wxSize GetTabIndent() const = 0; | |
315 | ||
316 | // get the padding around the text in a tab | |
317 | virtual wxSize GetTabPadding() const = 0; | |
318 | ||
319 | // get the default size of the slider in lesser dimension (i.e. height of a | |
320 | // horizontal slider or width of a vertical one) | |
321 | virtual wxCoord GetSliderDim() const = 0; | |
322 | ||
323 | // get the length of the slider ticks displayed along side slider | |
324 | virtual wxCoord GetSliderTickLen() const = 0; | |
325 | ||
326 | // get the slider shaft rect from the total slider rect | |
327 | virtual wxRect GetSliderShaftRect(const wxRect& rect, | |
328 | wxOrientation orient) const = 0; | |
329 | ||
330 | // get the size of the slider thumb for the given total slider rect | |
331 | virtual wxSize GetSliderThumbSize(const wxRect& rect, | |
332 | wxOrientation orient) const = 0; | |
333 | ||
334 | // get the size of one progress bar step (in horz and vertical directions) | |
335 | virtual wxSize GetProgressBarStep() const = 0; | |
336 | ||
337 | // get the size of rectangle to use in the menubar for the given text rect | |
338 | virtual wxSize GetMenuBarItemSize(const wxSize& sizeText) const = 0; | |
339 | ||
340 | // get the struct storing all layout info needed to draw all menu items | |
341 | // (this can't be calculated for each item separately as they should be | |
342 | // aligned) | |
343 | // | |
344 | // the returned pointer must be deleted by the caller | |
345 | virtual wxMenuGeometryInfo *GetMenuGeometry(wxWindow *win, | |
346 | const wxMenu& menu) const = 0; | |
347 | ||
348 | // virtual dtor for any base class | |
349 | virtual ~wxRenderer(); | |
350 | ||
351 | protected: | |
352 | // draw a frame around rectFrame rectangle but not touching the rectLabel | |
353 | // one: this is used by DrawFrame() | |
354 | void StandardDrawFrame(wxDC& dc, | |
355 | const wxRect& rectFrame, | |
356 | const wxRect& rectLabel); | |
357 | ||
358 | // standard text line drawing: just use DrawText() and highlight the | |
359 | // selected part | |
360 | static void StandardDrawTextLine(wxDC& dc, | |
361 | const wxString& text, | |
362 | const wxRect& rect, | |
363 | int selStart, int selEnd, | |
364 | int flags); | |
365 | ||
366 | // standard scrollbar hit testing: this assumes that it only has 2 arrows | |
367 | // and a thumb, so the themes which have more complicated scrollbars (e.g. | |
368 | // BeOS) can't use this method | |
369 | static wxRect StandardGetScrollbarRect(const wxScrollBar *scrollbar, | |
370 | wxScrollBar::Element elem, | |
371 | int thumbPos, | |
372 | const wxSize& sizeArrow); | |
373 | static wxHitTest StandardHitTestScrollbar(const wxScrollBar *scrollbar, | |
374 | const wxPoint& pt, | |
375 | const wxSize& sizeArrow); | |
376 | static wxCoord StandardScrollbarToPixel(const wxScrollBar *scrollbar, | |
377 | int thumbPos, | |
378 | const wxSize& sizeArrow); | |
379 | static int StandardPixelToScrollbar(const wxScrollBar *scrollbar, | |
380 | wxCoord coord, | |
381 | const wxSize& sizeArrow); | |
382 | static wxCoord StandardScrollBarSize(const wxScrollBar *scrollbar, | |
383 | const wxSize& sizeArrow); | |
384 | static void StandardScrollBarThumbSize(wxCoord lenBar, | |
385 | int thumbPos, | |
386 | int thumbSize, | |
387 | int range, | |
388 | wxCoord *thumbStart, | |
389 | wxCoord *thumbEnd); | |
390 | }; | |
391 | ||
392 | // ---------------------------------------------------------------------------- | |
393 | // wxDelegateRenderer: it is impossible to inherit from any of standard | |
394 | // renderers as their declarations are in private code, but you can use this | |
395 | // class to override only some of the Draw() functions - all the other ones | |
396 | // will be left to the original renderer | |
397 | // ---------------------------------------------------------------------------- | |
398 | ||
399 | class WXDLLEXPORT wxDelegateRenderer : public wxRenderer | |
400 | { | |
401 | public: | |
402 | wxDelegateRenderer(wxRenderer *renderer) : m_renderer(renderer) { } | |
403 | ||
404 | virtual void DrawBackground(wxDC& dc, | |
405 | const wxColour& col, | |
406 | const wxRect& rect, | |
407 | int flags) | |
408 | { m_renderer->DrawBackground(dc, col, rect, flags); } | |
409 | virtual void DrawLabel(wxDC& dc, | |
410 | const wxString& label, | |
411 | const wxRect& rect, | |
412 | int flags = 0, | |
413 | int align = wxALIGN_LEFT | wxALIGN_TOP, | |
414 | int indexAccel = -1, | |
415 | wxRect *rectBounds = NULL) | |
416 | { m_renderer->DrawLabel(dc, label, rect, | |
417 | flags, align, indexAccel, rectBounds); } | |
418 | virtual void DrawButtonLabel(wxDC& dc, | |
419 | const wxString& label, | |
420 | const wxBitmap& image, | |
421 | const wxRect& rect, | |
422 | int flags = 0, | |
423 | int align = wxALIGN_LEFT | wxALIGN_TOP, | |
424 | int indexAccel = -1, | |
425 | wxRect *rectBounds = NULL) | |
426 | { m_renderer->DrawButtonLabel(dc, label, image, rect, | |
427 | flags, align, indexAccel, rectBounds); } | |
428 | virtual void DrawBorder(wxDC& dc, | |
429 | wxBorder border, | |
430 | const wxRect& rect, | |
431 | int flags = 0, | |
432 | wxRect *rectIn = (wxRect *)NULL) | |
433 | { m_renderer->DrawBorder(dc, border, rect, flags, rectIn); } | |
434 | virtual void DrawTextBorder(wxDC& dc, | |
435 | wxBorder border, | |
436 | const wxRect& rect, | |
437 | int flags = 0, | |
438 | wxRect *rectIn = (wxRect *)NULL) | |
439 | { m_renderer->DrawTextBorder(dc, border, rect, flags, rectIn); } | |
440 | virtual void DrawButtonBorder(wxDC& dc, | |
441 | const wxRect& rect, | |
442 | int flags = 0, | |
443 | wxRect *rectIn = (wxRect *)NULL) | |
444 | { m_renderer->DrawButtonBorder(dc, rect, flags, rectIn); } | |
445 | virtual void DrawFrame(wxDC& dc, | |
446 | const wxString& label, | |
447 | const wxRect& rect, | |
448 | int flags = 0, | |
449 | int align = wxALIGN_LEFT, | |
450 | int indexAccel = -1) | |
451 | { m_renderer->DrawFrame(dc, label, rect, flags, align, indexAccel); } | |
452 | virtual void DrawHorizontalLine(wxDC& dc, | |
453 | wxCoord y, wxCoord x1, wxCoord x2) | |
454 | { m_renderer->DrawHorizontalLine(dc, y, x1, x2); } | |
455 | virtual void DrawVerticalLine(wxDC& dc, | |
456 | wxCoord x, wxCoord y1, wxCoord y2) | |
457 | { m_renderer->DrawVerticalLine(dc, x, y1, y2); } | |
458 | virtual void DrawArrow(wxDC& dc, | |
459 | wxDirection dir, | |
460 | const wxRect& rect, | |
461 | int flags = 0) | |
462 | { m_renderer->DrawArrow(dc, dir, rect, flags); } | |
463 | virtual void DrawScrollbarArrow(wxDC& dc, | |
464 | wxDirection dir, | |
465 | const wxRect& rect, | |
466 | int flags = 0) | |
467 | { m_renderer->DrawScrollbarArrow(dc, dir, rect, flags); } | |
468 | virtual void DrawScrollbarThumb(wxDC& dc, | |
469 | wxOrientation orient, | |
470 | const wxRect& rect, | |
471 | int flags = 0) | |
472 | { m_renderer->DrawScrollbarThumb(dc, orient, rect, flags); } | |
473 | virtual void DrawScrollbarShaft(wxDC& dc, | |
474 | wxOrientation orient, | |
475 | const wxRect& rect, | |
476 | int flags = 0) | |
477 | { m_renderer->DrawScrollbarShaft(dc, orient, rect, flags); } | |
478 | virtual void DrawScrollCorner(wxDC& dc, | |
479 | const wxRect& rect) | |
480 | { m_renderer->DrawScrollCorner(dc, rect); } | |
481 | virtual void DrawItem(wxDC& dc, | |
482 | const wxString& label, | |
483 | const wxRect& rect, | |
484 | int flags = 0) | |
485 | { m_renderer->DrawItem(dc, label, rect, flags); } | |
486 | virtual void DrawCheckItem(wxDC& dc, | |
487 | const wxString& label, | |
488 | const wxBitmap& bitmap, | |
489 | const wxRect& rect, | |
490 | int flags = 0) | |
491 | { m_renderer->DrawCheckItem(dc, label, bitmap, rect, flags); } | |
492 | virtual void DrawCheckButton(wxDC& dc, | |
493 | const wxString& label, | |
494 | const wxBitmap& bitmap, | |
495 | const wxRect& rect, | |
496 | int flags = 0, | |
497 | wxAlignment align = wxALIGN_LEFT, | |
498 | int indexAccel = -1) | |
499 | { m_renderer->DrawCheckButton(dc, label, bitmap, rect, | |
500 | flags, align, indexAccel); } | |
501 | virtual void DrawRadioButton(wxDC& dc, | |
502 | const wxString& label, | |
503 | const wxBitmap& bitmap, | |
504 | const wxRect& rect, | |
505 | int flags = 0, | |
506 | wxAlignment align = wxALIGN_LEFT, | |
507 | int indexAccel = -1) | |
508 | { m_renderer->DrawRadioButton(dc, label, bitmap, rect, | |
509 | flags, align, indexAccel); } | |
510 | virtual void DrawTextLine(wxDC& dc, | |
511 | const wxString& text, | |
512 | const wxRect& rect, | |
513 | int selStart = -1, | |
514 | int selEnd = -1) | |
515 | { m_renderer->DrawTextLine(dc, text, rect, selStart, selEnd); } | |
516 | virtual void DrawLineWrapMark(wxDC& dc, const wxRect& rect) | |
517 | { m_renderer->DrawLineWrapMark(dc, rect); } | |
518 | ||
519 | virtual void DrawTab(wxDC& dc, | |
520 | const wxRect& rect, | |
521 | wxDirection dir, | |
522 | const wxString& label, | |
523 | const wxBitmap& bitmap = wxNullBitmap, | |
524 | int flags = 0, | |
525 | int accel = -1) | |
526 | { m_renderer->DrawTab(dc, rect, dir, label, bitmap, flags, accel); } | |
527 | ||
528 | virtual void DrawSliderShaft(wxDC& dc, | |
529 | const wxRect& rect, | |
530 | wxOrientation orient, | |
531 | int flags = 0, | |
532 | wxRect *rectShaft = NULL) | |
533 | { m_renderer->DrawSliderShaft(dc, rect, orient, flags, rectShaft); } | |
534 | virtual void DrawSliderThumb(wxDC& dc, | |
535 | const wxRect& rect, | |
536 | wxOrientation orient, | |
537 | int flags = 0) | |
538 | { m_renderer->DrawSliderThumb(dc, rect, orient, flags); } | |
539 | virtual void DrawSliderTicks(wxDC& dc, | |
540 | const wxRect& rect, | |
541 | const wxSize& sizeThumb, | |
542 | wxOrientation orient, | |
543 | int start, | |
544 | int end, | |
545 | int step = 1, | |
546 | int flags = 0) | |
547 | { m_renderer->DrawSliderTicks(dc, rect, sizeThumb, orient, | |
548 | start, end, start, flags); } | |
549 | ||
550 | virtual void DrawMenuBarItem(wxDC& dc, | |
551 | const wxRect& rect, | |
552 | const wxString& label, | |
553 | int flags = 0, | |
554 | int indexAccel = -1) | |
555 | { m_renderer->DrawMenuBarItem(dc, rect, label, flags, indexAccel); } | |
556 | virtual void DrawMenuItem(wxDC& dc, | |
557 | wxCoord y, | |
558 | const wxMenuGeometryInfo& gi, | |
559 | const wxString& label, | |
560 | const wxString& accel, | |
561 | const wxBitmap& bitmap = wxNullBitmap, | |
562 | int flags = 0, | |
563 | int indexAccel = -1) | |
564 | { m_renderer->DrawMenuItem(dc, y, gi, label, accel, | |
565 | bitmap, flags, indexAccel); } | |
566 | virtual void DrawMenuSeparator(wxDC& dc, | |
567 | wxCoord y, | |
568 | const wxMenuGeometryInfo& geomInfo) | |
569 | { m_renderer->DrawMenuSeparator(dc, y, geomInfo); } | |
570 | ||
571 | virtual void GetComboBitmaps(wxBitmap *bmpNormal, | |
572 | wxBitmap *bmpPressed, | |
573 | wxBitmap *bmpDisabled) | |
574 | { m_renderer->GetComboBitmaps(bmpNormal, bmpPressed, bmpDisabled); } | |
575 | ||
576 | virtual void AdjustSize(wxSize *size, const wxWindow *window) | |
577 | { m_renderer->AdjustSize(size, window); } | |
578 | virtual wxRect GetBorderDimensions(wxBorder border) const | |
579 | { return m_renderer->GetBorderDimensions(border); } | |
580 | virtual bool AreScrollbarsInsideBorder() const | |
581 | { return m_renderer->AreScrollbarsInsideBorder(); } | |
582 | ||
583 | virtual wxSize GetScrollbarArrowSize() const | |
584 | { return m_renderer->GetScrollbarArrowSize(); } | |
585 | virtual wxRect GetScrollbarRect(const wxScrollBar *scrollbar, | |
586 | wxScrollBar::Element elem, | |
587 | int thumbPos = -1) const | |
588 | { return m_renderer->GetScrollbarRect(scrollbar, elem, thumbPos); } | |
589 | virtual wxCoord GetScrollbarSize(const wxScrollBar *scrollbar) | |
590 | { return m_renderer->GetScrollbarSize(scrollbar); } | |
591 | virtual wxHitTest HitTestScrollbar(const wxScrollBar *scrollbar, | |
592 | const wxPoint& pt) const | |
593 | { return m_renderer->HitTestScrollbar(scrollbar, pt); } | |
594 | virtual wxCoord ScrollbarToPixel(const wxScrollBar *scrollbar, | |
595 | int thumbPos = -1) | |
596 | { return m_renderer->ScrollbarToPixel(scrollbar, thumbPos); } | |
597 | virtual int PixelToScrollbar(const wxScrollBar *scrollbar, | |
598 | wxCoord coord) | |
599 | { return m_renderer->PixelToScrollbar(scrollbar, coord); } | |
600 | virtual wxCoord GetListboxItemHeight(wxCoord fontHeight) | |
601 | { return m_renderer->GetListboxItemHeight(fontHeight); } | |
602 | virtual wxSize GetCheckBitmapSize() const | |
603 | { return m_renderer->GetCheckBitmapSize(); } | |
604 | virtual wxSize GetRadioBitmapSize() const | |
605 | { return m_renderer->GetRadioBitmapSize(); } | |
606 | virtual wxCoord GetCheckItemMargin() const | |
607 | { return m_renderer->GetCheckItemMargin(); } | |
608 | ||
609 | virtual wxRect GetTextTotalArea(const wxTextCtrl *text, const wxRect& rect) | |
610 | { return m_renderer->GetTextTotalArea(text, rect); } | |
611 | virtual wxRect GetTextClientArea(const wxTextCtrl *text, | |
612 | const wxRect& rect, | |
613 | wxCoord *extraSpaceBeyond) | |
614 | { return m_renderer->GetTextClientArea(text, rect, extraSpaceBeyond); } | |
615 | ||
616 | virtual wxSize GetTabIndent() const { return m_renderer->GetTabIndent(); } | |
617 | virtual wxSize GetTabPadding() const { return m_renderer->GetTabPadding(); } | |
618 | ||
619 | virtual wxCoord GetSliderDim() const | |
620 | { return m_renderer->GetSliderDim(); } | |
621 | virtual wxCoord GetSliderTickLen() const | |
622 | { return m_renderer->GetSliderTickLen(); } | |
623 | virtual wxRect GetSliderShaftRect(const wxRect& rect, | |
624 | wxOrientation orient) const | |
625 | { return GetSliderShaftRect(rect, orient); } | |
626 | virtual wxSize GetSliderThumbSize(const wxRect& rect, | |
627 | wxOrientation orient) const | |
628 | { return m_renderer->GetSliderThumbSize(rect, orient); } | |
629 | virtual wxSize GetProgressBarStep() const | |
630 | { return m_renderer->GetProgressBarStep(); } | |
631 | virtual wxSize GetMenuBarItemSize(const wxSize& sizeText) const | |
632 | { return m_renderer->GetMenuBarItemSize(sizeText); } | |
633 | virtual wxMenuGeometryInfo *GetMenuGeometry(wxWindow *win, | |
634 | const wxMenu& menu) const | |
635 | { return m_renderer->GetMenuGeometry(win, menu); } | |
636 | ||
637 | protected: | |
638 | wxRenderer *m_renderer; | |
639 | }; | |
640 | ||
641 | // ---------------------------------------------------------------------------- | |
642 | // wxControlRenderer: wraps the wxRenderer functions in a form easy to use from | |
643 | // OnPaint() | |
644 | // ---------------------------------------------------------------------------- | |
645 | ||
646 | class WXDLLEXPORT wxControlRenderer | |
647 | { | |
648 | public: | |
649 | // create a renderer for this dc with this "fundamental" renderer | |
650 | wxControlRenderer(wxWindow *control, wxDC& dc, wxRenderer *renderer); | |
651 | ||
652 | // operations | |
653 | void DrawLabel(const wxBitmap& bitmap = wxNullBitmap, | |
654 | wxCoord marginX = 0, wxCoord marginY = 0); | |
655 | #if wxUSE_LISTBOX | |
656 | void DrawItems(const wxListBox *listbox, | |
657 | size_t itemFirst, size_t itemLast); | |
658 | #endif // wxUSE_LISTBOX | |
659 | #if wxUSE_CHECKLISTBOX | |
660 | void DrawCheckItems(const wxCheckListBox *listbox, | |
661 | size_t itemFirst, size_t itemLast); | |
662 | #endif // wxUSE_CHECKLISTBOX | |
663 | void DrawButtonBorder(); | |
664 | // the line must be either horizontal or vertical | |
665 | void DrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2); | |
666 | void DrawFrame(); | |
667 | void DrawBitmap(const wxBitmap& bitmap); | |
668 | void DrawBackgroundBitmap(); | |
669 | void DrawScrollbar(const wxScrollBar *scrollbar, int thumbPosOld); | |
670 | #if wxUSE_GAUGE | |
671 | void DrawProgressBar(const wxGauge *gauge); | |
672 | #endif // wxUSE_GAUGE | |
673 | ||
674 | // accessors | |
675 | wxWindow *GetWindow() const { return m_window; } | |
676 | wxRenderer *GetRenderer() const { return m_renderer; } | |
677 | ||
678 | wxDC& GetDC() { return m_dc; } | |
679 | ||
680 | const wxRect& GetRect() const { return m_rect; } | |
681 | wxRect& GetRect() { return m_rect; } | |
682 | ||
683 | // static helpers | |
684 | static void DrawBitmap(wxDC &dc, | |
685 | const wxBitmap& bitmap, | |
686 | const wxRect& rect, | |
687 | int alignment = wxALIGN_CENTRE | | |
688 | wxALIGN_CENTRE_VERTICAL, | |
689 | wxStretch stretch = wxSTRETCH_NOT); | |
690 | ||
691 | private: | |
692 | // common part of DrawItems() and DrawCheckItems() | |
693 | void DoDrawItems(const wxListBox *listbox, | |
694 | size_t itemFirst, size_t itemLast, | |
695 | bool isCheckLbox = FALSE); | |
696 | ||
697 | wxWindow *m_window; | |
698 | wxRenderer *m_renderer; | |
699 | wxDC& m_dc; | |
700 | wxRect m_rect; | |
701 | }; | |
702 | ||
703 | #endif // _WX_UNIV_RENDERER_H_ | |
704 |