]> git.saurik.com Git - wxWidgets.git/blob - include/wx/univ/renderer.h
MSW fixes; added wxUSE_XPM to wxUniv's setup.h so now widgets sample works
[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 wxScrollBar;
36 class WXDLLEXPORT wxTextCtrl;
37 class WXDLLEXPORT wxWindow;
38 #if wxUSE_GAUGE
39 class WXDLLEXPORT wxGauge;
40 #endif // wxUSE_GAUGE
41
42 #include "wx/string.h"
43 #include "wx/gdicmn.h"
44 #include "wx/scrolbar.h" // for wxScrollBar::Element
45
46 #ifndef WX_PRECOMP
47 #include "wx/menu.h" // for wxMenuGeometryInfo
48 #endif // WX_PRECOMP
49
50 // ----------------------------------------------------------------------------
51 // wxRenderer: abstract renderers interface
52 // ----------------------------------------------------------------------------
53
54 class WXDLLEXPORT wxRenderer
55 {
56 public:
57 // drawing functions
58 // -----------------
59
60 // draw the controls background
61 virtual void DrawBackground(wxDC& dc,
62 const wxColour& col,
63 const wxRect& rect,
64 int flags) = 0;
65
66 // draw the label inside the given rectangle with the specified alignment
67 // and optionally emphasize the character with the given index
68 virtual void DrawLabel(wxDC& dc,
69 const wxString& label,
70 const wxRect& rect,
71 int flags = 0,
72 int alignment = wxALIGN_LEFT | wxALIGN_TOP,
73 int indexAccel = -1,
74 wxRect *rectBounds = NULL) = 0;
75
76 // same but also draw a bitmap if it is valid
77 virtual void DrawButtonLabel(wxDC& dc,
78 const wxString& label,
79 const wxBitmap& image,
80 const wxRect& rect,
81 int flags = 0,
82 int alignment = wxALIGN_LEFT | wxALIGN_TOP,
83 int indexAccel = -1,
84 wxRect *rectBounds = NULL) = 0;
85
86 // draw the border and optionally return the rectangle containing the
87 // region inside the border
88 virtual void DrawBorder(wxDC& dc,
89 wxBorder border,
90 const wxRect& rect,
91 int flags = 0,
92 wxRect *rectIn = (wxRect *)NULL) = 0;
93
94 // draw text control border (I hate to have a separate method for this but
95 // it is needed to accomodate GTK+)
96 virtual void DrawTextBorder(wxDC& dc,
97 wxBorder border,
98 const wxRect& rect,
99 int flags = 0,
100 wxRect *rectIn = (wxRect *)NULL) = 0;
101
102 // draw push button border and return the rectangle left for the label
103 virtual void DrawButtonBorder(wxDC& dc,
104 const wxRect& rect,
105 int flags = 0,
106 wxRect *rectIn = (wxRect *)NULL) = 0;
107
108 // draw a horizontal line
109 virtual void DrawHorizontalLine(wxDC& dc,
110 wxCoord y, wxCoord x1, wxCoord x2) = 0;
111
112 // draw a vertical line
113 virtual void DrawVerticalLine(wxDC& dc,
114 wxCoord x, wxCoord y1, wxCoord y2) = 0;
115
116 // draw a frame with the label (horizontal alignment can be specified)
117 virtual void DrawFrame(wxDC& dc,
118 const wxString& label,
119 const wxRect& rect,
120 int flags = 0,
121 int alignment = wxALIGN_LEFT,
122 int indexAccel = -1) = 0;
123
124 // draw an arrow in the given direction
125 virtual void DrawArrow(wxDC& dc,
126 wxDirection dir,
127 const wxRect& rect,
128 int flags = 0) = 0;
129
130 // draw a scrollbar arrow (may be the same as arrow but may be not)
131 virtual void DrawScrollbarArrow(wxDC& dc,
132 wxDirection dir,
133 const wxRect& rect,
134 int flags = 0) = 0;
135
136 // draw the scrollbar thumb
137 virtual void DrawScrollbarThumb(wxDC& dc,
138 wxOrientation orient,
139 const wxRect& rect,
140 int flags = 0) = 0;
141
142 // draw a (part of) scrollbar shaft
143 virtual void DrawScrollbarShaft(wxDC& dc,
144 wxOrientation orient,
145 const wxRect& rect,
146 int flags = 0) = 0;
147
148 // draw the rectangle in the corner between two scrollbars
149 virtual void DrawScrollCorner(wxDC& dc,
150 const wxRect& rect) = 0;
151
152 // draw an item of a wxListBox
153 virtual void DrawItem(wxDC& dc,
154 const wxString& label,
155 const wxRect& rect,
156 int flags = 0) = 0;
157
158 // draw an item of a wxCheckListBox
159 virtual void DrawCheckItem(wxDC& dc,
160 const wxString& label,
161 const wxBitmap& bitmap,
162 const wxRect& rect,
163 int flags = 0) = 0;
164
165 // draw a checkbutton (bitmap may be invalid to use default one)
166 virtual void DrawCheckButton(wxDC& dc,
167 const wxString& label,
168 const wxBitmap& bitmap,
169 const wxRect& rect,
170 int flags = 0,
171 wxAlignment align = wxALIGN_LEFT,
172 int indexAccel = -1) = 0;
173
174 // draw a radio button
175 virtual void DrawRadioButton(wxDC& dc,
176 const wxString& label,
177 const wxBitmap& bitmap,
178 const wxRect& rect,
179 int flags = 0,
180 wxAlignment align = wxALIGN_LEFT,
181 int indexAccel = -1) = 0;
182
183 // draw a (part of) line in the text control
184 virtual void DrawTextLine(wxDC& dc,
185 const wxString& text,
186 const wxRect& rect,
187 int selStart = -1,
188 int selEnd = -1,
189 int flags = 0) = 0;
190
191 // draw a line wrap indicator
192 virtual void DrawLineWrapMark(wxDC& dc, const wxRect& rect) = 0;
193
194 // draw a notebook tab
195 virtual void DrawTab(wxDC& dc,
196 const wxRect& rect,
197 wxDirection dir,
198 const wxString& label,
199 const wxBitmap& bitmap = wxNullBitmap,
200 int flags = 0,
201 int indexAccel = -1) = 0;
202
203 // draw the slider shaft
204 virtual void DrawSliderShaft(wxDC& dc,
205 const wxRect& rect,
206 wxOrientation orient,
207 int flags = 0,
208 wxRect *rectShaft = NULL) = 0;
209
210 // draw the slider thumb
211 virtual void DrawSliderThumb(wxDC& dc,
212 const wxRect& rect,
213 wxOrientation orient,
214 int flags = 0) = 0;
215
216 // draw the slider ticks
217 virtual void DrawSliderTicks(wxDC& dc,
218 const wxRect& rect,
219 const wxSize& sizeThumb,
220 wxOrientation orient,
221 int start,
222 int end,
223 int step = 1,
224 int flags = 0) = 0;
225
226 // draw a menu bar item
227 virtual void DrawMenuBarItem(wxDC& dc,
228 const wxRect& rect,
229 const wxString& label,
230 int flags = 0,
231 int indexAccel = -1) = 0;
232
233 // draw a menu item (also used for submenus if flags has ISSUBMENU flag)
234 //
235 // the geometryInfo is calculated by GetMenuGeometry() function from below
236 virtual void DrawMenuItem(wxDC& dc,
237 wxCoord y,
238 const wxMenuGeometryInfo& geometryInfo,
239 const wxString& label,
240 const wxString& accel,
241 const wxBitmap& bitmap = wxNullBitmap,
242 int flags = 0,
243 int indexAccel = -1) = 0;
244
245 // draw a menu bar separator
246 virtual void DrawMenuSeparator(wxDC& dc,
247 wxCoord y,
248 const wxMenuGeometryInfo& geomInfo) = 0;
249
250 // misc functions
251 // --------------
252
253 // return the bitmaps to use for combobox button
254 virtual void GetComboBitmaps(wxBitmap *bmpNormal,
255 wxBitmap *bmpPressed,
256 wxBitmap *bmpDisabled) = 0;
257
258 // geometry functions
259 // ------------------
260
261 // get the dimensions of the border: rect.x/y contain the width/height of
262 // the left/top side, width/heigh - of the right/bottom one
263 virtual wxRect GetBorderDimensions(wxBorder border) const = 0;
264
265 // the scrollbars may be drawn either inside the window border or outside
266 // it - this function is used to decide how to draw them
267 virtual bool AreScrollbarsInsideBorder() const = 0;
268
269 // adjust the size of the control of the given class: for most controls,
270 // this just takes into account the border, but for some (buttons, for
271 // example) it is more complicated - the result being, in any case, that
272 // the control looks "nice" if it uses the adjusted rectangle
273 virtual void AdjustSize(wxSize *size, const wxWindow *window) = 0;
274
275 // get the size of a scrollbar arrow
276 virtual wxSize GetScrollbarArrowSize() const = 0;
277
278 // gets the bounding box for a scrollbar element for the given (by default
279 // - current) thumb position
280 virtual wxRect GetScrollbarRect(const wxScrollBar *scrollbar,
281 wxScrollBar::Element elem,
282 int thumbPos = -1) const = 0;
283
284 // returns the size of the scrollbar shaft excluding the arrows
285 virtual wxCoord GetScrollbarSize(const wxScrollBar *scrollbar) = 0;
286
287 // returns one of wxHT_SCROLLBAR_XXX constants
288 virtual wxHitTest HitTestScrollbar(const wxScrollBar *scrollbar,
289 const wxPoint& pt) const = 0;
290
291 // translate the scrollbar position (in logical units) into physical
292 // coordinate (in pixels) and the other way round
293 virtual wxCoord ScrollbarToPixel(const wxScrollBar *scrollbar,
294 int thumbPos = -1) = 0;
295 virtual int PixelToScrollbar(const wxScrollBar *scrollbar,
296 wxCoord coord) = 0;
297
298 // get the height of a listbox item from the base font height
299 virtual wxCoord GetListboxItemHeight(wxCoord fontHeight) = 0;
300
301 // get the size of a checkbox/radio button bitmap
302 virtual wxSize GetCheckBitmapSize() const = 0;
303 virtual wxSize GetRadioBitmapSize() const = 0;
304 virtual wxCoord GetCheckItemMargin() const = 0;
305
306 // convert between text rectangle and client rectangle for text controls:
307 // the former is typicall smaller to leave margins around text
308 virtual wxRect GetTextTotalArea(const wxTextCtrl *text,
309 const wxRect& rectText) = 0;
310
311 // extra space is for line indicators
312 virtual wxRect GetTextClientArea(const wxTextCtrl *text,
313 const wxRect& rectTotal,
314 wxCoord *extraSpaceBeyond) = 0;
315
316 // get the overhang of a selected tab
317 virtual wxSize GetTabIndent() const = 0;
318
319 // get the padding around the text in a tab
320 virtual wxSize GetTabPadding() const = 0;
321
322 // get the default size of the slider in lesser dimension (i.e. height of a
323 // horizontal slider or width of a vertical one)
324 virtual wxCoord GetSliderDim() const = 0;
325
326 // get the length of the slider ticks displayed along side slider
327 virtual wxCoord GetSliderTickLen() const = 0;
328
329 // get the slider shaft rect from the total slider rect
330 virtual wxRect GetSliderShaftRect(const wxRect& rect,
331 wxOrientation orient) const = 0;
332
333 // get the size of the slider thumb for the given total slider rect
334 virtual wxSize GetSliderThumbSize(const wxRect& rect,
335 wxOrientation orient) const = 0;
336
337 // get the size of one progress bar step (in horz and vertical directions)
338 virtual wxSize GetProgressBarStep() const = 0;
339
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
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
553 virtual void DrawMenuBarItem(wxDC& dc,
554 const wxRect& rect,
555 const wxString& label,
556 int flags = 0,
557 int indexAccel = -1)
558 { m_renderer->DrawMenuBarItem(dc, rect, label, flags, indexAccel); }
559 virtual void DrawMenuItem(wxDC& dc,
560 wxCoord y,
561 const wxMenuGeometryInfo& gi,
562 const wxString& label,
563 const wxString& accel,
564 const wxBitmap& bitmap = wxNullBitmap,
565 int flags = 0,
566 int indexAccel = -1)
567 { m_renderer->DrawMenuItem(dc, y, gi, label, accel,
568 bitmap, flags, indexAccel); }
569 virtual void DrawMenuSeparator(wxDC& dc,
570 wxCoord y,
571 const wxMenuGeometryInfo& geomInfo)
572 { m_renderer->DrawMenuSeparator(dc, y, geomInfo); }
573
574 virtual void GetComboBitmaps(wxBitmap *bmpNormal,
575 wxBitmap *bmpPressed,
576 wxBitmap *bmpDisabled)
577 { m_renderer->GetComboBitmaps(bmpNormal, bmpPressed, bmpDisabled); }
578
579 virtual void AdjustSize(wxSize *size, const wxWindow *window)
580 { m_renderer->AdjustSize(size, window); }
581 virtual wxRect GetBorderDimensions(wxBorder border) const
582 { return m_renderer->GetBorderDimensions(border); }
583 virtual bool AreScrollbarsInsideBorder() const
584 { return m_renderer->AreScrollbarsInsideBorder(); }
585
586 virtual wxSize GetScrollbarArrowSize() const
587 { return m_renderer->GetScrollbarArrowSize(); }
588 virtual wxRect GetScrollbarRect(const wxScrollBar *scrollbar,
589 wxScrollBar::Element elem,
590 int thumbPos = -1) const
591 { return m_renderer->GetScrollbarRect(scrollbar, elem, thumbPos); }
592 virtual wxCoord GetScrollbarSize(const wxScrollBar *scrollbar)
593 { return m_renderer->GetScrollbarSize(scrollbar); }
594 virtual wxHitTest HitTestScrollbar(const wxScrollBar *scrollbar,
595 const wxPoint& pt) const
596 { return m_renderer->HitTestScrollbar(scrollbar, pt); }
597 virtual wxCoord ScrollbarToPixel(const wxScrollBar *scrollbar,
598 int thumbPos = -1)
599 { return m_renderer->ScrollbarToPixel(scrollbar, thumbPos); }
600 virtual int PixelToScrollbar(const wxScrollBar *scrollbar,
601 wxCoord coord)
602 { return m_renderer->PixelToScrollbar(scrollbar, coord); }
603 virtual wxCoord GetListboxItemHeight(wxCoord fontHeight)
604 { return m_renderer->GetListboxItemHeight(fontHeight); }
605 virtual wxSize GetCheckBitmapSize() const
606 { return m_renderer->GetCheckBitmapSize(); }
607 virtual wxSize GetRadioBitmapSize() const
608 { return m_renderer->GetRadioBitmapSize(); }
609 virtual wxCoord GetCheckItemMargin() const
610 { return m_renderer->GetCheckItemMargin(); }
611
612 virtual wxRect GetTextTotalArea(const wxTextCtrl *text, const wxRect& rect)
613 { return m_renderer->GetTextTotalArea(text, rect); }
614 virtual wxRect GetTextClientArea(const wxTextCtrl *text,
615 const wxRect& rect,
616 wxCoord *extraSpaceBeyond)
617 { return m_renderer->GetTextClientArea(text, rect, extraSpaceBeyond); }
618
619 virtual wxSize GetTabIndent() const { return m_renderer->GetTabIndent(); }
620 virtual wxSize GetTabPadding() const { return m_renderer->GetTabPadding(); }
621
622 virtual wxCoord GetSliderDim() const
623 { return m_renderer->GetSliderDim(); }
624 virtual wxCoord GetSliderTickLen() const
625 { return m_renderer->GetSliderTickLen(); }
626 virtual wxRect GetSliderShaftRect(const wxRect& rect,
627 wxOrientation orient) const
628 { return GetSliderShaftRect(rect, orient); }
629 virtual wxSize GetSliderThumbSize(const wxRect& rect,
630 wxOrientation orient) const
631 { return m_renderer->GetSliderThumbSize(rect, orient); }
632 virtual wxSize GetProgressBarStep() const
633 { return m_renderer->GetProgressBarStep(); }
634 virtual wxSize GetMenuBarItemSize(const wxSize& sizeText) const
635 { return m_renderer->GetMenuBarItemSize(sizeText); }
636 virtual wxMenuGeometryInfo *GetMenuGeometry(wxWindow *win,
637 const wxMenu& menu) const
638 { return m_renderer->GetMenuGeometry(win, menu); }
639
640 protected:
641 wxRenderer *m_renderer;
642 };
643
644 // ----------------------------------------------------------------------------
645 // wxControlRenderer: wraps the wxRenderer functions in a form easy to use from
646 // OnPaint()
647 // ----------------------------------------------------------------------------
648
649 class WXDLLEXPORT wxControlRenderer
650 {
651 public:
652 // create a renderer for this dc with this "fundamental" renderer
653 wxControlRenderer(wxWindow *control, wxDC& dc, wxRenderer *renderer);
654
655 // operations
656 void DrawLabel(const wxBitmap& bitmap = wxNullBitmap,
657 wxCoord marginX = 0, wxCoord marginY = 0);
658 #if wxUSE_LISTBOX
659 void DrawItems(const wxListBox *listbox,
660 size_t itemFirst, size_t itemLast);
661 #endif // wxUSE_LISTBOX
662 #if wxUSE_CHECKLISTBOX
663 void DrawCheckItems(const wxCheckListBox *listbox,
664 size_t itemFirst, size_t itemLast);
665 #endif // wxUSE_CHECKLISTBOX
666 void DrawButtonBorder();
667 // the line must be either horizontal or vertical
668 void DrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2);
669 void DrawFrame();
670 void DrawBitmap(const wxBitmap& bitmap);
671 void DrawBackgroundBitmap();
672 void DrawScrollbar(const wxScrollBar *scrollbar, int thumbPosOld);
673 #if wxUSE_GAUGE
674 void DrawProgressBar(const wxGauge *gauge);
675 #endif // wxUSE_GAUGE
676
677 // accessors
678 wxWindow *GetWindow() const { return m_window; }
679 wxRenderer *GetRenderer() const { return m_renderer; }
680
681 wxDC& GetDC() { return m_dc; }
682
683 const wxRect& GetRect() const { return m_rect; }
684 wxRect& GetRect() { return m_rect; }
685
686 // static helpers
687 static void DrawBitmap(wxDC &dc,
688 const wxBitmap& bitmap,
689 const wxRect& rect,
690 int alignment = wxALIGN_CENTRE |
691 wxALIGN_CENTRE_VERTICAL,
692 wxStretch stretch = wxSTRETCH_NOT);
693
694 private:
695 // common part of DrawItems() and DrawCheckItems()
696 void DoDrawItems(const wxListBox *listbox,
697 size_t itemFirst, size_t itemLast,
698 bool isCheckLbox = FALSE);
699
700 wxWindow *m_window;
701 wxRenderer *m_renderer;
702 wxDC& m_dc;
703 wxRect m_rect;
704 };
705
706 #endif // _WX_UNIV_RENDERER_H_
707