]> git.saurik.com Git - wxWidgets.git/blob - include/wx/univ/renderer.h
wxInputConsumer
[wxWidgets.git] / include / wx / univ / renderer.h
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 SciTech Software, Inc. (www.scitechsoft.com)
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 wxMenuGeometryInfo;
36 class WXDLLEXPORT wxScrollBar;
37 class WXDLLEXPORT wxTextCtrl;
38 class WXDLLEXPORT wxWindow;
39 #if wxUSE_GAUGE
40 class WXDLLEXPORT wxGauge;
41 #endif // wxUSE_GAUGE
42
43 #include "wx/string.h"
44 #include "wx/gdicmn.h"
45 #include "wx/scrolbar.h" // for wxScrollBar::Element
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 #if wxUSE_MENUS
224 // draw a menu bar item
225 virtual void DrawMenuBarItem(wxDC& dc,
226 const wxRect& rect,
227 const wxString& label,
228 int flags = 0,
229 int indexAccel = -1) = 0;
230
231 // draw a menu item (also used for submenus if flags has ISSUBMENU flag)
232 //
233 // the geometryInfo is calculated by GetMenuGeometry() function from below
234 virtual void DrawMenuItem(wxDC& dc,
235 wxCoord y,
236 const wxMenuGeometryInfo& geometryInfo,
237 const wxString& label,
238 const wxString& accel,
239 const wxBitmap& bitmap = wxNullBitmap,
240 int flags = 0,
241 int indexAccel = -1) = 0;
242
243 // draw a menu bar separator
244 virtual void DrawMenuSeparator(wxDC& dc,
245 wxCoord y,
246 const wxMenuGeometryInfo& geomInfo) = 0;
247 #endif
248 // misc functions
249 // --------------
250
251 // return the bitmaps to use for combobox button
252 virtual void GetComboBitmaps(wxBitmap *bmpNormal,
253 wxBitmap *bmpFocus,
254 wxBitmap *bmpPressed,
255 wxBitmap *bmpDisabled) = 0;
256
257 // geometry functions
258 // ------------------
259
260 // get the dimensions of the border: rect.x/y contain the width/height of
261 // the left/top side, width/heigh - of the right/bottom one
262 virtual wxRect GetBorderDimensions(wxBorder border) const = 0;
263
264 // the scrollbars may be drawn either inside the window border or outside
265 // it - this function is used to decide how to draw them
266 virtual bool AreScrollbarsInsideBorder() const = 0;
267
268 // adjust the size of the control of the given class: for most controls,
269 // this just takes into account the border, but for some (buttons, for
270 // example) it is more complicated - the result being, in any case, that
271 // the control looks "nice" if it uses the adjusted rectangle
272 virtual void AdjustSize(wxSize *size, const wxWindow *window) = 0;
273
274 // get the size of a scrollbar arrow
275 virtual wxSize GetScrollbarArrowSize() const = 0;
276
277 // gets the bounding box for a scrollbar element for the given (by default
278 // - current) thumb position
279 virtual wxRect GetScrollbarRect(const wxScrollBar *scrollbar,
280 wxScrollBar::Element elem,
281 int thumbPos = -1) const = 0;
282
283 // returns the size of the scrollbar shaft excluding the arrows
284 virtual wxCoord GetScrollbarSize(const wxScrollBar *scrollbar) = 0;
285
286 // returns one of wxHT_SCROLLBAR_XXX constants
287 virtual wxHitTest HitTestScrollbar(const wxScrollBar *scrollbar,
288 const wxPoint& pt) const = 0;
289
290 // translate the scrollbar position (in logical units) into physical
291 // coordinate (in pixels) and the other way round
292 virtual wxCoord ScrollbarToPixel(const wxScrollBar *scrollbar,
293 int thumbPos = -1) = 0;
294 virtual int PixelToScrollbar(const wxScrollBar *scrollbar,
295 wxCoord coord) = 0;
296
297 // get the height of a listbox item from the base font height
298 virtual wxCoord GetListboxItemHeight(wxCoord fontHeight) = 0;
299
300 // get the size of a checkbox/radio button bitmap
301 virtual wxSize GetCheckBitmapSize() const = 0;
302 virtual wxSize GetRadioBitmapSize() const = 0;
303 virtual wxCoord GetCheckItemMargin() const = 0;
304
305 // convert between text rectangle and client rectangle for text controls:
306 // the former is typicall smaller to leave margins around text
307 virtual wxRect GetTextTotalArea(const wxTextCtrl *text,
308 const wxRect& rectText) = 0;
309
310 // extra space is for line indicators
311 virtual wxRect GetTextClientArea(const wxTextCtrl *text,
312 const wxRect& rectTotal,
313 wxCoord *extraSpaceBeyond) = 0;
314
315 // get the overhang of a selected tab
316 virtual wxSize GetTabIndent() const = 0;
317
318 // get the padding around the text in a tab
319 virtual wxSize GetTabPadding() const = 0;
320
321 // get the default size of the slider in lesser dimension (i.e. height of a
322 // horizontal slider or width of a vertical one)
323 virtual wxCoord GetSliderDim() const = 0;
324
325 // get the length of the slider ticks displayed along side slider
326 virtual wxCoord GetSliderTickLen() const = 0;
327
328 // get the slider shaft rect from the total slider rect
329 virtual wxRect GetSliderShaftRect(const wxRect& rect,
330 wxOrientation orient) const = 0;
331
332 // get the size of the slider thumb for the given total slider rect
333 virtual wxSize GetSliderThumbSize(const wxRect& rect,
334 wxOrientation orient) const = 0;
335
336 // get the size of one progress bar step (in horz and vertical directions)
337 virtual wxSize GetProgressBarStep() const = 0;
338
339 #if wxUSE_MENUS
340 // get the size of rectangle to use in the menubar for the given text rect
341 virtual wxSize GetMenuBarItemSize(const wxSize& sizeText) const = 0;
342
343 // get the struct storing all layout info needed to draw all menu items
344 // (this can't be calculated for each item separately as they should be
345 // aligned)
346 //
347 // the returned pointer must be deleted by the caller
348 virtual wxMenuGeometryInfo *GetMenuGeometry(wxWindow *win,
349 const wxMenu& menu) const = 0;
350 #endif
351 // virtual dtor for any base class
352 virtual ~wxRenderer();
353
354 protected:
355 // draw a frame around rectFrame rectangle but not touching the rectLabel
356 // one: this is used by DrawFrame()
357 void StandardDrawFrame(wxDC& dc,
358 const wxRect& rectFrame,
359 const wxRect& rectLabel);
360
361 // standard text line drawing: just use DrawText() and highlight the
362 // selected part
363 static void StandardDrawTextLine(wxDC& dc,
364 const wxString& text,
365 const wxRect& rect,
366 int selStart, int selEnd,
367 int flags);
368
369 // standard scrollbar hit testing: this assumes that it only has 2 arrows
370 // and a thumb, so the themes which have more complicated scrollbars (e.g.
371 // BeOS) can't use this method
372 static wxRect StandardGetScrollbarRect(const wxScrollBar *scrollbar,
373 wxScrollBar::Element elem,
374 int thumbPos,
375 const wxSize& sizeArrow);
376 static wxHitTest StandardHitTestScrollbar(const wxScrollBar *scrollbar,
377 const wxPoint& pt,
378 const wxSize& sizeArrow);
379 static wxCoord StandardScrollbarToPixel(const wxScrollBar *scrollbar,
380 int thumbPos,
381 const wxSize& sizeArrow);
382 static int StandardPixelToScrollbar(const wxScrollBar *scrollbar,
383 wxCoord coord,
384 const wxSize& sizeArrow);
385 static wxCoord StandardScrollBarSize(const wxScrollBar *scrollbar,
386 const wxSize& sizeArrow);
387 static void StandardScrollBarThumbSize(wxCoord lenBar,
388 int thumbPos,
389 int thumbSize,
390 int range,
391 wxCoord *thumbStart,
392 wxCoord *thumbEnd);
393 };
394
395 // ----------------------------------------------------------------------------
396 // wxDelegateRenderer: it is impossible to inherit from any of standard
397 // renderers as their declarations are in private code, but you can use this
398 // class to override only some of the Draw() functions - all the other ones
399 // will be left to the original renderer
400 // ----------------------------------------------------------------------------
401
402 class WXDLLEXPORT wxDelegateRenderer : public wxRenderer
403 {
404 public:
405 wxDelegateRenderer(wxRenderer *renderer) : m_renderer(renderer) { }
406
407 virtual void DrawBackground(wxDC& dc,
408 const wxColour& col,
409 const wxRect& rect,
410 int flags)
411 { m_renderer->DrawBackground(dc, col, rect, flags); }
412 virtual void DrawLabel(wxDC& dc,
413 const wxString& label,
414 const wxRect& rect,
415 int flags = 0,
416 int align = wxALIGN_LEFT | wxALIGN_TOP,
417 int indexAccel = -1,
418 wxRect *rectBounds = NULL)
419 { m_renderer->DrawLabel(dc, label, rect,
420 flags, align, indexAccel, rectBounds); }
421 virtual void DrawButtonLabel(wxDC& dc,
422 const wxString& label,
423 const wxBitmap& image,
424 const wxRect& rect,
425 int flags = 0,
426 int align = wxALIGN_LEFT | wxALIGN_TOP,
427 int indexAccel = -1,
428 wxRect *rectBounds = NULL)
429 { m_renderer->DrawButtonLabel(dc, label, image, rect,
430 flags, align, indexAccel, rectBounds); }
431 virtual void DrawBorder(wxDC& dc,
432 wxBorder border,
433 const wxRect& rect,
434 int flags = 0,
435 wxRect *rectIn = (wxRect *)NULL)
436 { m_renderer->DrawBorder(dc, border, rect, flags, rectIn); }
437 virtual void DrawTextBorder(wxDC& dc,
438 wxBorder border,
439 const wxRect& rect,
440 int flags = 0,
441 wxRect *rectIn = (wxRect *)NULL)
442 { m_renderer->DrawTextBorder(dc, border, rect, flags, rectIn); }
443 virtual void DrawButtonBorder(wxDC& dc,
444 const wxRect& rect,
445 int flags = 0,
446 wxRect *rectIn = (wxRect *)NULL)
447 { m_renderer->DrawButtonBorder(dc, rect, flags, rectIn); }
448 virtual void DrawFrame(wxDC& dc,
449 const wxString& label,
450 const wxRect& rect,
451 int flags = 0,
452 int align = wxALIGN_LEFT,
453 int indexAccel = -1)
454 { m_renderer->DrawFrame(dc, label, rect, flags, align, indexAccel); }
455 virtual void DrawHorizontalLine(wxDC& dc,
456 wxCoord y, wxCoord x1, wxCoord x2)
457 { m_renderer->DrawHorizontalLine(dc, y, x1, x2); }
458 virtual void DrawVerticalLine(wxDC& dc,
459 wxCoord x, wxCoord y1, wxCoord y2)
460 { m_renderer->DrawVerticalLine(dc, x, y1, y2); }
461 virtual void DrawArrow(wxDC& dc,
462 wxDirection dir,
463 const wxRect& rect,
464 int flags = 0)
465 { m_renderer->DrawArrow(dc, dir, rect, flags); }
466 virtual void DrawScrollbarArrow(wxDC& dc,
467 wxDirection dir,
468 const wxRect& rect,
469 int flags = 0)
470 { m_renderer->DrawScrollbarArrow(dc, dir, rect, flags); }
471 virtual void DrawScrollbarThumb(wxDC& dc,
472 wxOrientation orient,
473 const wxRect& rect,
474 int flags = 0)
475 { m_renderer->DrawScrollbarThumb(dc, orient, rect, flags); }
476 virtual void DrawScrollbarShaft(wxDC& dc,
477 wxOrientation orient,
478 const wxRect& rect,
479 int flags = 0)
480 { m_renderer->DrawScrollbarShaft(dc, orient, rect, flags); }
481 virtual void DrawScrollCorner(wxDC& dc,
482 const wxRect& rect)
483 { m_renderer->DrawScrollCorner(dc, rect); }
484 virtual void DrawItem(wxDC& dc,
485 const wxString& label,
486 const wxRect& rect,
487 int flags = 0)
488 { m_renderer->DrawItem(dc, label, rect, flags); }
489 virtual void DrawCheckItem(wxDC& dc,
490 const wxString& label,
491 const wxBitmap& bitmap,
492 const wxRect& rect,
493 int flags = 0)
494 { m_renderer->DrawCheckItem(dc, label, bitmap, rect, flags); }
495 virtual void DrawCheckButton(wxDC& dc,
496 const wxString& label,
497 const wxBitmap& bitmap,
498 const wxRect& rect,
499 int flags = 0,
500 wxAlignment align = wxALIGN_LEFT,
501 int indexAccel = -1)
502 { m_renderer->DrawCheckButton(dc, label, bitmap, rect,
503 flags, align, indexAccel); }
504 virtual void DrawRadioButton(wxDC& dc,
505 const wxString& label,
506 const wxBitmap& bitmap,
507 const wxRect& rect,
508 int flags = 0,
509 wxAlignment align = wxALIGN_LEFT,
510 int indexAccel = -1)
511 { m_renderer->DrawRadioButton(dc, label, bitmap, rect,
512 flags, align, indexAccel); }
513 virtual void DrawTextLine(wxDC& dc,
514 const wxString& text,
515 const wxRect& rect,
516 int selStart = -1,
517 int selEnd = -1)
518 { m_renderer->DrawTextLine(dc, text, rect, selStart, selEnd); }
519 virtual void DrawLineWrapMark(wxDC& dc, const wxRect& rect)
520 { m_renderer->DrawLineWrapMark(dc, rect); }
521
522 virtual void DrawTab(wxDC& dc,
523 const wxRect& rect,
524 wxDirection dir,
525 const wxString& label,
526 const wxBitmap& bitmap = wxNullBitmap,
527 int flags = 0,
528 int accel = -1)
529 { m_renderer->DrawTab(dc, rect, dir, label, bitmap, flags, accel); }
530
531 virtual void DrawSliderShaft(wxDC& dc,
532 const wxRect& rect,
533 wxOrientation orient,
534 int flags = 0,
535 wxRect *rectShaft = NULL)
536 { m_renderer->DrawSliderShaft(dc, rect, orient, flags, rectShaft); }
537 virtual void DrawSliderThumb(wxDC& dc,
538 const wxRect& rect,
539 wxOrientation orient,
540 int flags = 0)
541 { m_renderer->DrawSliderThumb(dc, rect, orient, flags); }
542 virtual void DrawSliderTicks(wxDC& dc,
543 const wxRect& rect,
544 const wxSize& sizeThumb,
545 wxOrientation orient,
546 int start,
547 int end,
548 int step = 1,
549 int flags = 0)
550 { m_renderer->DrawSliderTicks(dc, rect, sizeThumb, orient,
551 start, end, start, flags); }
552 #if wxUSE_MENUS
553
554 virtual void DrawMenuBarItem(wxDC& dc,
555 const wxRect& rect,
556 const wxString& label,
557 int flags = 0,
558 int indexAccel = -1)
559 { m_renderer->DrawMenuBarItem(dc, rect, label, flags, indexAccel); }
560 virtual void DrawMenuItem(wxDC& dc,
561 wxCoord y,
562 const wxMenuGeometryInfo& gi,
563 const wxString& label,
564 const wxString& accel,
565 const wxBitmap& bitmap = wxNullBitmap,
566 int flags = 0,
567 int indexAccel = -1)
568 { m_renderer->DrawMenuItem(dc, y, gi, label, accel,
569 bitmap, flags, indexAccel); }
570 virtual void DrawMenuSeparator(wxDC& dc,
571 wxCoord y,
572 const wxMenuGeometryInfo& geomInfo)
573 { m_renderer->DrawMenuSeparator(dc, y, geomInfo); }
574 #endif
575 virtual void GetComboBitmaps(wxBitmap *bmpNormal,
576 wxBitmap *bmpFocus,
577 wxBitmap *bmpPressed,
578 wxBitmap *bmpDisabled)
579 { m_renderer->GetComboBitmaps(bmpNormal, bmpFocus,
580 bmpPressed, bmpDisabled); }
581
582 virtual void AdjustSize(wxSize *size, const wxWindow *window)
583 { m_renderer->AdjustSize(size, window); }
584 virtual wxRect GetBorderDimensions(wxBorder border) const
585 { return m_renderer->GetBorderDimensions(border); }
586 virtual bool AreScrollbarsInsideBorder() const
587 { return m_renderer->AreScrollbarsInsideBorder(); }
588
589 virtual wxSize GetScrollbarArrowSize() const
590 { return m_renderer->GetScrollbarArrowSize(); }
591 virtual wxRect GetScrollbarRect(const wxScrollBar *scrollbar,
592 wxScrollBar::Element elem,
593 int thumbPos = -1) const
594 { return m_renderer->GetScrollbarRect(scrollbar, elem, thumbPos); }
595 virtual wxCoord GetScrollbarSize(const wxScrollBar *scrollbar)
596 { return m_renderer->GetScrollbarSize(scrollbar); }
597 virtual wxHitTest HitTestScrollbar(const wxScrollBar *scrollbar,
598 const wxPoint& pt) const
599 { return m_renderer->HitTestScrollbar(scrollbar, pt); }
600 virtual wxCoord ScrollbarToPixel(const wxScrollBar *scrollbar,
601 int thumbPos = -1)
602 { return m_renderer->ScrollbarToPixel(scrollbar, thumbPos); }
603 virtual int PixelToScrollbar(const wxScrollBar *scrollbar,
604 wxCoord coord)
605 { return m_renderer->PixelToScrollbar(scrollbar, coord); }
606 virtual wxCoord GetListboxItemHeight(wxCoord fontHeight)
607 { return m_renderer->GetListboxItemHeight(fontHeight); }
608 virtual wxSize GetCheckBitmapSize() const
609 { return m_renderer->GetCheckBitmapSize(); }
610 virtual wxSize GetRadioBitmapSize() const
611 { return m_renderer->GetRadioBitmapSize(); }
612 virtual wxCoord GetCheckItemMargin() const
613 { return m_renderer->GetCheckItemMargin(); }
614
615 virtual wxRect GetTextTotalArea(const wxTextCtrl *text, const wxRect& rect)
616 { return m_renderer->GetTextTotalArea(text, rect); }
617 virtual wxRect GetTextClientArea(const wxTextCtrl *text,
618 const wxRect& rect,
619 wxCoord *extraSpaceBeyond)
620 { return m_renderer->GetTextClientArea(text, rect, extraSpaceBeyond); }
621
622 virtual wxSize GetTabIndent() const { return m_renderer->GetTabIndent(); }
623 virtual wxSize GetTabPadding() const { return m_renderer->GetTabPadding(); }
624
625 virtual wxCoord GetSliderDim() const
626 { return m_renderer->GetSliderDim(); }
627 virtual wxCoord GetSliderTickLen() const
628 { return m_renderer->GetSliderTickLen(); }
629 virtual wxRect GetSliderShaftRect(const wxRect& rect,
630 wxOrientation orient) const
631 { return GetSliderShaftRect(rect, orient); }
632 virtual wxSize GetSliderThumbSize(const wxRect& rect,
633 wxOrientation orient) const
634 { return m_renderer->GetSliderThumbSize(rect, orient); }
635 virtual wxSize GetProgressBarStep() const
636 { return m_renderer->GetProgressBarStep(); }
637 #if wxUSE_MENUS
638 virtual wxSize GetMenuBarItemSize(const wxSize& sizeText) const
639 { return m_renderer->GetMenuBarItemSize(sizeText); }
640 virtual wxMenuGeometryInfo *GetMenuGeometry(wxWindow *win,
641 const wxMenu& menu) const
642 { return m_renderer->GetMenuGeometry(win, menu); }
643 #endif
644 protected:
645 wxRenderer *m_renderer;
646 };
647
648 // ----------------------------------------------------------------------------
649 // wxControlRenderer: wraps the wxRenderer functions in a form easy to use from
650 // OnPaint()
651 // ----------------------------------------------------------------------------
652
653 class WXDLLEXPORT wxControlRenderer
654 {
655 public:
656 // create a renderer for this dc with this "fundamental" renderer
657 wxControlRenderer(wxWindow *control, wxDC& dc, wxRenderer *renderer);
658
659 // operations
660 void DrawLabel(const wxBitmap& bitmap = wxNullBitmap,
661 wxCoord marginX = 0, wxCoord marginY = 0);
662 #if wxUSE_LISTBOX
663 void DrawItems(const wxListBox *listbox,
664 size_t itemFirst, size_t itemLast);
665 #endif // wxUSE_LISTBOX
666 #if wxUSE_CHECKLISTBOX
667 void DrawCheckItems(const wxCheckListBox *listbox,
668 size_t itemFirst, size_t itemLast);
669 #endif // wxUSE_CHECKLISTBOX
670 void DrawButtonBorder();
671 // the line must be either horizontal or vertical
672 void DrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2);
673 void DrawFrame();
674 void DrawBitmap(const wxBitmap& bitmap);
675 void DrawBackgroundBitmap();
676 void DrawScrollbar(const wxScrollBar *scrollbar, int thumbPosOld);
677 #if wxUSE_GAUGE
678 void DrawProgressBar(const wxGauge *gauge);
679 #endif // wxUSE_GAUGE
680
681 // accessors
682 wxWindow *GetWindow() const { return m_window; }
683 wxRenderer *GetRenderer() const { return m_renderer; }
684
685 wxDC& GetDC() { return m_dc; }
686
687 const wxRect& GetRect() const { return m_rect; }
688 wxRect& GetRect() { return m_rect; }
689
690 // static helpers
691 static void DrawBitmap(wxDC &dc,
692 const wxBitmap& bitmap,
693 const wxRect& rect,
694 int alignment = wxALIGN_CENTRE |
695 wxALIGN_CENTRE_VERTICAL,
696 wxStretch stretch = wxSTRETCH_NOT);
697
698 private:
699 // common part of DrawItems() and DrawCheckItems()
700 void DoDrawItems(const wxListBox *listbox,
701 size_t itemFirst, size_t itemLast,
702 bool isCheckLbox = FALSE);
703
704 wxWindow *m_window;
705 wxRenderer *m_renderer;
706 wxDC& m_dc;
707 wxRect m_rect;
708 };
709
710 #endif // _WX_UNIV_RENDERER_H_
711