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 // Copyright:   (c) 2000 SciTech Software, Inc. (www.scitechsoft.com)
8 // Licence:     wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
10 
11 #ifndef _WX_UNIV_RENDERER_H_
12 #define _WX_UNIV_RENDERER_H_
13 
14 /*
15    wxRenderer class is used to draw all wxWidgets controls. This is an ABC and
16    the look of the application is determined by the concrete derivation of
17    wxRenderer used in the program.
18 
19    It also contains a few static methods which may be used by the concrete
20    renderers and provide the functionality which is often similar or identical
21    in all renderers (using inheritance here would be more restrictive as the
22    given concrete renderer may need an arbitrary subset of the base class
23    methods).
24 
25    Finally note that wxRenderer supersedes wxRendererNative in wxUniv build and
26    includes the latters functionality (which it may delegate to the generic
27    implementation of the latter or reimplement itself).
28  */
29 
30 #include "wx/renderer.h"
31 
32 class WXDLLIMPEXP_FWD_CORE wxWindow;
33 class WXDLLIMPEXP_FWD_CORE wxDC;
34 class WXDLLIMPEXP_FWD_CORE wxCheckListBox;
35 
36 #if wxUSE_LISTBOX
37     class WXDLLIMPEXP_FWD_CORE wxListBox;
38 #endif // wxUSE_LISTBOX
39 
40 #if wxUSE_MENUS
41    class WXDLLIMPEXP_FWD_CORE wxMenu;
42    class WXDLLIMPEXP_FWD_CORE wxMenuGeometryInfo;
43 #endif // wxUSE_MENUS
44 
45 class WXDLLIMPEXP_FWD_CORE wxScrollBar;
46 
47 #if wxUSE_TEXTCTRL
48     class WXDLLIMPEXP_FWD_CORE wxTextCtrl;
49 #endif
50 
51 #if wxUSE_GAUGE
52     class WXDLLIMPEXP_FWD_CORE wxGauge;
53 #endif // wxUSE_GAUGE
54 
55 #include "wx/string.h"
56 #include "wx/gdicmn.h"
57 #include "wx/icon.h"
58 
59 // helper class used by wxMenu-related functions
60 class WXDLLIMPEXP_CORE wxMenuGeometryInfo
61 {
62 public:
63     // get the total size of the menu
64     virtual wxSize GetSize() const = 0;
65 
66     virtual ~wxMenuGeometryInfo();
67 };
68 
69 // ----------------------------------------------------------------------------
70 // wxRenderer: abstract renderers interface
71 // ----------------------------------------------------------------------------
72 
73 class WXDLLIMPEXP_CORE wxRenderer : public wxDelegateRendererNative
74 {
75 public:
76     // drawing functions
77     // -----------------
78 
79     // draw the controls background
80     virtual void DrawBackground(wxDC& dc,
81                                 const wxColour& col,
82                                 const wxRect& rect,
83                                 int flags,
84                                 wxWindow *window = NULL) = 0;
85 
86     // draw the button surface
87     virtual void DrawButtonSurface(wxDC& dc,
88                                    const wxColour& col,
89                                    const wxRect& rect,
90                                    int flags) = 0;
91 
92     // draw the label inside the given rectangle with the specified alignment
93     // and optionally emphasize the character with the given index
94     virtual void DrawLabel(wxDC& dc,
95                            const wxString& label,
96                            const wxRect& rect,
97                            int flags = 0,
98                            int alignment = wxALIGN_LEFT | wxALIGN_TOP,
99                            int indexAccel = -1,
100                            wxRect *rectBounds = NULL) = 0;
101 
102     // same but also draw a bitmap if it is valid
103     virtual void DrawButtonLabel(wxDC& dc,
104                                  const wxString& label,
105                                  const wxBitmap& image,
106                                  const wxRect& rect,
107                                  int flags = 0,
108                                  int alignment = wxALIGN_LEFT | wxALIGN_TOP,
109                                  int indexAccel = -1,
110                                  wxRect *rectBounds = NULL) = 0;
111 
112 
113     // draw the border and optionally return the rectangle containing the
114     // region inside the border
115     virtual void DrawBorder(wxDC& dc,
116                             wxBorder border,
117                             const wxRect& rect,
118                             int flags = 0,
119                             wxRect *rectIn = NULL) = 0;
120 
121     // draw text control border (I hate to have a separate method for this but
122     // it is needed to accommodate GTK+)
123     virtual void DrawTextBorder(wxDC& dc,
124                                 wxBorder border,
125                                 const wxRect& rect,
126                                 int flags = 0,
127                                 wxRect *rectIn = NULL) = 0;
128 
129     // draw push button border and return the rectangle left for the label
130     virtual void DrawButtonBorder(wxDC& dc,
131                                   const wxRect& rect,
132                                   int flags = 0,
133                                   wxRect *rectIn = NULL) = 0;
134 
135     // draw a horizontal line
136     virtual void DrawHorizontalLine(wxDC& dc,
137                                     wxCoord y, wxCoord x1, wxCoord x2) = 0;
138 
139     // draw a vertical line
140     virtual void DrawVerticalLine(wxDC& dc,
141                                   wxCoord x, wxCoord y1, wxCoord y2) = 0;
142 
143     // draw a frame with the label (horizontal alignment can be specified)
144     virtual void DrawFrame(wxDC& dc,
145                            const wxString& label,
146                            const wxRect& rect,
147                            int flags = 0,
148                            int alignment = wxALIGN_LEFT,
149                            int indexAccel = -1) = 0;
150 
151     // draw an arrow in the given direction
152     virtual void DrawArrow(wxDC& dc,
153                            wxDirection dir,
154                            const wxRect& rect,
155                            int flags = 0) = 0;
156 
157     // draw a scrollbar arrow (may be the same as arrow but may be not)
158     virtual void DrawScrollbarArrow(wxDC& dc,
159                                     wxDirection dir,
160                                     const wxRect& rect,
161                                     int flags = 0) = 0;
162 
163     // draw the scrollbar thumb
164     virtual void DrawScrollbarThumb(wxDC& dc,
165                                     wxOrientation orient,
166                                     const wxRect& rect,
167                                     int flags = 0) = 0;
168 
169     // draw a (part of) scrollbar shaft
170     virtual void DrawScrollbarShaft(wxDC& dc,
171                                     wxOrientation orient,
172                                     const wxRect& rect,
173                                     int flags = 0) = 0;
174 
175     // draw the rectangle in the corner between two scrollbars
176     virtual void DrawScrollCorner(wxDC& dc,
177                                   const wxRect& rect) = 0;
178 
179     // draw an item of a wxListBox
180     virtual void DrawItem(wxDC& dc,
181                           const wxString& label,
182                           const wxRect& rect,
183                           int flags = 0) = 0;
184 
185     // draw an item of a wxCheckListBox
186     virtual void DrawCheckItem(wxDC& dc,
187                                const wxString& label,
188                                const wxBitmap& bitmap,
189                                const wxRect& rect,
190                                int flags = 0) = 0;
191 
192     // draw a checkbutton (bitmap may be invalid to use default one)
193     virtual void DrawCheckButton(wxDC& dc,
194                                  const wxString& label,
195                                  const wxBitmap& bitmap,
196                                  const wxRect& rect,
197                                  int flags = 0,
198                                  wxAlignment align = wxALIGN_LEFT,
199                                  int indexAccel = -1) = 0;
200 
201     // draw a radio button
202     virtual void DrawRadioButton(wxDC& dc,
203                                  const wxString& label,
204                                  const wxBitmap& bitmap,
205                                  const wxRect& rect,
206                                  int flags = 0,
207                                  wxAlignment align = wxALIGN_LEFT,
208                                  int indexAccel = -1) = 0;
209 
210 #if wxUSE_TOOLBAR
211     // draw a toolbar button (label may be empty, bitmap may be invalid, if
212     // both conditions are true this function draws a separator)
213     virtual void DrawToolBarButton(wxDC& dc,
214                                    const wxString& label,
215                                    const wxBitmap& bitmap,
216                                    const wxRect& rect,
217                                    int flags = 0,
218                                    long style = 0,
219                                    int tbarStyle = 0) = 0;
220 #endif // wxUSE_TOOLBAR
221 
222 #if wxUSE_TEXTCTRL
223     // draw a (part of) line in the text control
224     virtual void DrawTextLine(wxDC& dc,
225                               const wxString& text,
226                               const wxRect& rect,
227                               int selStart = -1,
228                               int selEnd = -1,
229                               int flags = 0) = 0;
230 
231     // draw a line wrap indicator
232     virtual void DrawLineWrapMark(wxDC& dc, const wxRect& rect) = 0;
233 #endif // wxUSE_TEXTCTRL
234 
235 #if wxUSE_NOTEBOOK
236     // draw a notebook tab
237     virtual void DrawTab(wxDC& dc,
238                          const wxRect& rect,
239                          wxDirection dir,
240                          const wxString& label,
241                          const wxBitmap& bitmap = wxNullBitmap,
242                          int flags = 0,
243                          int indexAccel = -1) = 0;
244 #endif // wxUSE_NOTEBOOK
245 
246 #if wxUSE_SLIDER
247 
248     // draw the slider shaft
249     virtual void DrawSliderShaft(wxDC& dc,
250                                  const wxRect& rect,
251                                  int lenThumb,
252                                  wxOrientation orient,
253                                  int flags = 0,
254                                  long style = 0,
255                                  wxRect *rectShaft = NULL) = 0;
256 
257     // draw the slider thumb
258     virtual void DrawSliderThumb(wxDC& dc,
259                                  const wxRect& rect,
260                                  wxOrientation orient,
261                                  int flags = 0,
262                                  long style = 0) = 0;
263 
264     // draw the slider ticks
265     virtual void DrawSliderTicks(wxDC& dc,
266                                  const wxRect& rect,
267                                  int lenThumb,
268                                  wxOrientation orient,
269                                  int start,
270                                  int end,
271                                  int step = 1,
272                                  int flags = 0,
273                                  long style = 0) = 0;
274 #endif // wxUSE_SLIDER
275 
276 #if wxUSE_MENUS
277     // draw a menu bar item
278     virtual void DrawMenuBarItem(wxDC& dc,
279                                  const wxRect& rect,
280                                  const wxString& label,
281                                  int flags = 0,
282                                  int indexAccel = -1) = 0;
283 
284     // draw a menu item (also used for submenus if flags has ISSUBMENU flag)
285     //
286     // the geometryInfo is calculated by GetMenuGeometry() function from below
287     virtual void DrawMenuItem(wxDC& dc,
288                               wxCoord y,
289                               const wxMenuGeometryInfo& geometryInfo,
290                               const wxString& label,
291                               const wxString& accel,
292                               const wxBitmap& bitmap = wxNullBitmap,
293                               int flags = 0,
294                               int indexAccel = -1) = 0;
295 
296     // draw a menu bar separator
297     virtual void DrawMenuSeparator(wxDC& dc,
298                                    wxCoord y,
299                                    const wxMenuGeometryInfo& geomInfo) = 0;
300 #endif // wxUSE_MENUS
301 
302 #if wxUSE_STATUSBAR
303     // draw a status bar field: wxCONTROL_ISDEFAULT bit in the flags is
304     // interpreted specially and means "draw the status bar grip" here
305     virtual void DrawStatusField(wxDC& dc,
306                                  const wxRect& rect,
307                                  const wxString& label,
308                                  int flags = 0, int style = 0) = 0;
309 #endif // wxUSE_STATUSBAR
310 
311     // draw complete frame/dialog titlebar
312     virtual void DrawFrameTitleBar(wxDC& dc,
313                                    const wxRect& rect,
314                                    const wxString& title,
315                                    const wxIcon& icon,
316                                    int flags,
317                                    int specialButton = 0,
318                                    int specialButtonFlags = 0) = 0;
319 
320     // draw frame borders
321     virtual void DrawFrameBorder(wxDC& dc,
322                                  const wxRect& rect,
323                                  int flags) = 0;
324 
325     // draw frame titlebar background
326     virtual void DrawFrameBackground(wxDC& dc,
327                                      const wxRect& rect,
328                                      int flags) = 0;
329 
330     // draw frame title
331     virtual void DrawFrameTitle(wxDC& dc,
332                                 const wxRect& rect,
333                                 const wxString& title,
334                                 int flags) = 0;
335 
336     // draw frame icon
337     virtual void DrawFrameIcon(wxDC& dc,
338                                const wxRect& rect,
339                                const wxIcon& icon,
340                                int flags) = 0;
341 
342     // draw frame buttons
343     virtual void DrawFrameButton(wxDC& dc,
344                                  wxCoord x, wxCoord y,
345                                  int button,
346                                  int flags = 0) = 0;
347 
348     // misc functions
349     // --------------
350 
351 #if wxUSE_COMBOBOX
352     // return the bitmaps to use for combobox button
353     virtual void GetComboBitmaps(wxBitmap *bmpNormal,
354                                  wxBitmap *bmpFocus,
355                                  wxBitmap *bmpPressed,
356                                  wxBitmap *bmpDisabled) = 0;
357 #endif // wxUSE_COMBOBOX
358 
359     // geometry functions
360     // ------------------
361 
362     // get the dimensions of the border: rect.x/y contain the width/height of
363     // the left/top side, width/heigh - of the right/bottom one
364     virtual wxRect GetBorderDimensions(wxBorder border) const = 0;
365 
366     // the scrollbars may be drawn either inside the window border or outside
367     // it - this function is used to decide how to draw them
368     virtual bool AreScrollbarsInsideBorder() const = 0;
369 
370     // adjust the size of the control of the given class: for most controls,
371     // this just takes into account the border, but for some (buttons, for
372     // example) it is more complicated - the result being, in any case, that
373     // the control looks "nice" if it uses the adjusted rectangle
374     virtual void AdjustSize(wxSize *size, const wxWindow *window) = 0;
375 
376 #if wxUSE_SCROLLBAR
377     // get the size of a scrollbar arrow
378     virtual wxSize GetScrollbarArrowSize() const = 0;
379 #endif // wxUSE_SCROLLBAR
380 
381     // get the height of a listbox item from the base font height
382     virtual wxCoord GetListboxItemHeight(wxCoord fontHeight) = 0;
383 
384     // get the size of a checkbox/radio button bitmap
385     virtual wxSize GetCheckBitmapSize() const = 0;
386     virtual wxSize GetRadioBitmapSize() const = 0;
387     virtual wxCoord GetCheckItemMargin() const = 0;
388 
389 #if wxUSE_TOOLBAR
390     // get the standard size of a toolbar button and also return the size of
391     // a toolbar separator in the provided pointer
392     virtual wxSize GetToolBarButtonSize(wxCoord *separator) const = 0;
393 
394     // get the margins between/around the toolbar buttons
395     virtual wxSize GetToolBarMargin() const = 0;
396 #endif // wxUSE_TOOLBAR
397 
398 #if wxUSE_TEXTCTRL
399     // convert between text rectangle and client rectangle for text controls:
400     // the former is typicall smaller to leave margins around text
401     virtual wxRect GetTextTotalArea(const wxTextCtrl *text,
402                                     const wxRect& rectText) const = 0;
403 
404     // extra space is for line indicators
405     virtual wxRect GetTextClientArea(const wxTextCtrl *text,
406                                      const wxRect& rectTotal,
407                                      wxCoord *extraSpaceBeyond) const = 0;
408 #endif // wxUSE_TEXTCTRL
409 
410 #if wxUSE_NOTEBOOK
411     // get the overhang of a selected tab
412     virtual wxSize GetTabIndent() const = 0;
413 
414     // get the padding around the text in a tab
415     virtual wxSize GetTabPadding() const = 0;
416 #endif // wxUSE_NOTEBOOK
417 
418 #if wxUSE_SLIDER
419     // get the default size of the slider in lesser dimension (i.e. height of a
420     // horizontal slider or width of a vertical one)
421     virtual wxCoord GetSliderDim() const = 0;
422 
423     // get the length of the slider ticks displayed along side slider
424     virtual wxCoord GetSliderTickLen() const = 0;
425 
426     // get the slider shaft rect from the total slider rect
427     virtual wxRect GetSliderShaftRect(const wxRect& rect,
428                                       int lenThumb,
429                                       wxOrientation orient,
430                                       long style = 0) const = 0;
431 
432     // get the size of the slider thumb for the given total slider rect
433     virtual wxSize GetSliderThumbSize(const wxRect& rect,
434                                       int lenThumb,
435                                       wxOrientation orient) const = 0;
436 #endif // wxUSE_SLIDER
437 
438     // get the size of one progress bar step (in horz and vertical directions)
439     virtual wxSize GetProgressBarStep() const = 0;
440 
441 #if wxUSE_MENUS
442     // get the size of rectangle to use in the menubar for the given text rect
443     virtual wxSize GetMenuBarItemSize(const wxSize& sizeText) const = 0;
444 
445     // get the struct storing all layout info needed to draw all menu items
446     // (this can't be calculated for each item separately as they should be
447     // aligned)
448     //
449     // the returned pointer must be deleted by the caller
450     virtual wxMenuGeometryInfo *GetMenuGeometry(wxWindow *win,
451                                                 const wxMenu& menu) const = 0;
452 #endif // wxUSE_MENUS
453 
454 #if wxUSE_STATUSBAR
455     // get the borders around the status bar fields (x and y fields of the
456     // return value)
457     virtual wxSize GetStatusBarBorders() const = 0;
458 
459     // get the border between the status bar fields
460     virtual wxCoord GetStatusBarBorderBetweenFields() const = 0;
461 
462     // get the mergin between a field and its border
463     virtual wxSize GetStatusBarFieldMargins() const = 0;
464 #endif // wxUSE_STATUSBAR
465 
466     // get client area rectangle of top level window (i.e. subtract
467     // decorations from given rectangle)
468     virtual wxRect GetFrameClientArea(const wxRect& rect, int flags) const = 0;
469 
470     // get size of whole top level window, given size of its client area size
471     virtual wxSize GetFrameTotalSize(const wxSize& clientSize, int flags) const = 0;
472 
473     // get the minimal size of top level window
474     virtual wxSize GetFrameMinSize(int flags) const = 0;
475 
476     // get titlebar icon size
477     virtual wxSize GetFrameIconSize() const = 0;
478 
479     // returns one of wxHT_TOPLEVEL_XXX constants
480     virtual int HitTestFrame(const wxRect& rect,
481                              const wxPoint& pt,
482                              int flags = 0) const = 0;
483 
484     // virtual dtor for any base class
485     virtual ~wxRenderer();
486 };
487 
488 // ----------------------------------------------------------------------------
489 // wxDelegateRenderer: it is impossible to inherit from any of standard
490 // renderers as their declarations are in private code, but you can use this
491 // class to override only some of the Draw() functions - all the other ones
492 // will be left to the original renderer
493 // ----------------------------------------------------------------------------
494 
495 class WXDLLIMPEXP_CORE wxDelegateRenderer : public wxRenderer
496 {
497 public:
wxDelegateRenderer(wxRenderer * renderer)498     wxDelegateRenderer(wxRenderer *renderer) : m_renderer(renderer) { }
499 
500     virtual void DrawBackground(wxDC& dc,
501                                 const wxColour& col,
502                                 const wxRect& rect,
503                                 int flags,
504                                 wxWindow *window = NULL )
505         { m_renderer->DrawBackground(dc, col, rect, flags, window ); }
DrawButtonSurface(wxDC & dc,const wxColour & col,const wxRect & rect,int flags)506     virtual void DrawButtonSurface(wxDC& dc,
507                                    const wxColour& col,
508                                    const wxRect& rect,
509                                    int flags)
510         { m_renderer->DrawButtonSurface(dc, col, rect, flags); }
511     virtual void DrawFocusRect(wxWindow* win, wxDC& dc, const wxRect& rect, int flags = 0)
512         { m_renderer->DrawFocusRect(win, dc, rect, flags); }
513     virtual void DrawLabel(wxDC& dc,
514                            const wxString& label,
515                            const wxRect& rect,
516                            int flags = 0,
517                            int align = wxALIGN_LEFT | wxALIGN_TOP,
518                            int indexAccel = -1,
519                            wxRect *rectBounds = NULL)
520         { m_renderer->DrawLabel(dc, label, rect,
521                                 flags, align, indexAccel, rectBounds); }
522     virtual void DrawButtonLabel(wxDC& dc,
523                                  const wxString& label,
524                                  const wxBitmap& image,
525                                  const wxRect& rect,
526                                  int flags = 0,
527                                  int align = wxALIGN_LEFT | wxALIGN_TOP,
528                                  int indexAccel = -1,
529                                  wxRect *rectBounds = NULL)
530         { m_renderer->DrawButtonLabel(dc, label, image, rect,
531                                       flags, align, indexAccel, rectBounds); }
532     virtual void DrawBorder(wxDC& dc,
533                             wxBorder border,
534                             const wxRect& rect,
535                             int flags = 0,
536                             wxRect *rectIn = NULL)
537         { m_renderer->DrawBorder(dc, border, rect, flags, rectIn); }
538     virtual void DrawTextBorder(wxDC& dc,
539                                 wxBorder border,
540                                 const wxRect& rect,
541                                 int flags = 0,
542                                 wxRect *rectIn = NULL)
543         { m_renderer->DrawTextBorder(dc, border, rect, flags, rectIn); }
544     virtual void DrawButtonBorder(wxDC& dc,
545                                   const wxRect& rect,
546                                   int flags = 0,
547                                   wxRect *rectIn = NULL)
548         { m_renderer->DrawButtonBorder(dc, rect, flags, rectIn); }
549     virtual void DrawFrame(wxDC& dc,
550                            const wxString& label,
551                            const wxRect& rect,
552                            int flags = 0,
553                            int align = wxALIGN_LEFT,
554                            int indexAccel = -1)
555         { m_renderer->DrawFrame(dc, label, rect, flags, align, indexAccel); }
DrawHorizontalLine(wxDC & dc,wxCoord y,wxCoord x1,wxCoord x2)556     virtual void DrawHorizontalLine(wxDC& dc,
557                                     wxCoord y, wxCoord x1, wxCoord x2)
558         { m_renderer->DrawHorizontalLine(dc, y, x1, x2); }
DrawVerticalLine(wxDC & dc,wxCoord x,wxCoord y1,wxCoord y2)559     virtual void DrawVerticalLine(wxDC& dc,
560                                   wxCoord x, wxCoord y1, wxCoord y2)
561         { m_renderer->DrawVerticalLine(dc, x, y1, y2); }
562     virtual void DrawArrow(wxDC& dc,
563                            wxDirection dir,
564                            const wxRect& rect,
565                            int flags = 0)
566         { m_renderer->DrawArrow(dc, dir, rect, flags); }
567     virtual void DrawScrollbarArrow(wxDC& dc,
568                            wxDirection dir,
569                            const wxRect& rect,
570                            int flags = 0)
571         { m_renderer->DrawScrollbarArrow(dc, dir, rect, flags); }
572     virtual void DrawScrollbarThumb(wxDC& dc,
573                                     wxOrientation orient,
574                                     const wxRect& rect,
575                                     int flags = 0)
576         { m_renderer->DrawScrollbarThumb(dc, orient, rect, flags); }
577     virtual void DrawScrollbarShaft(wxDC& dc,
578                                     wxOrientation orient,
579                                     const wxRect& rect,
580                                     int flags = 0)
581         { m_renderer->DrawScrollbarShaft(dc, orient, rect, flags); }
DrawScrollCorner(wxDC & dc,const wxRect & rect)582     virtual void DrawScrollCorner(wxDC& dc,
583                                   const wxRect& rect)
584         { m_renderer->DrawScrollCorner(dc, rect); }
585     virtual void DrawItem(wxDC& dc,
586                           const wxString& label,
587                           const wxRect& rect,
588                           int flags = 0)
589         { m_renderer->DrawItem(dc, label, rect, flags); }
590     virtual void DrawCheckItem(wxDC& dc,
591                                const wxString& label,
592                                const wxBitmap& bitmap,
593                                const wxRect& rect,
594                                int flags = 0)
595         { m_renderer->DrawCheckItem(dc, label, bitmap, rect, flags); }
596     virtual void DrawCheckButton(wxDC& dc,
597                                  const wxString& label,
598                                  const wxBitmap& bitmap,
599                                  const wxRect& rect,
600                                  int flags = 0,
601                                  wxAlignment align = wxALIGN_LEFT,
602                                  int indexAccel = -1)
603         { m_renderer->DrawCheckButton(dc, label, bitmap, rect,
604                                       flags, align, indexAccel); }
605     virtual void DrawRadioButton(wxDC& dc,
606                                  const wxString& label,
607                                  const wxBitmap& bitmap,
608                                  const wxRect& rect,
609                                  int flags = 0,
610                                  wxAlignment align = wxALIGN_LEFT,
611                                  int indexAccel = -1)
612         { m_renderer->DrawRadioButton(dc, label, bitmap, rect,
613                                       flags, align, indexAccel); }
614 #if wxUSE_TOOLBAR
615     virtual void DrawToolBarButton(wxDC& dc,
616                                    const wxString& label,
617                                    const wxBitmap& bitmap,
618                                    const wxRect& rect,
619                                    int flags = 0,
620                                    long style = 0,
621                                    int tbarStyle = 0)
622         { m_renderer->DrawToolBarButton(dc, label, bitmap, rect, flags, style, tbarStyle); }
623 #endif // wxUSE_TOOLBAR
624 
625 #if wxUSE_TEXTCTRL
626     virtual void DrawTextLine(wxDC& dc,
627                               const wxString& text,
628                               const wxRect& rect,
629                               int selStart = -1,
630                               int selEnd = -1,
631                               int flags = 0)
632         { m_renderer->DrawTextLine(dc, text, rect, selStart, selEnd, flags); }
DrawLineWrapMark(wxDC & dc,const wxRect & rect)633     virtual void DrawLineWrapMark(wxDC& dc, const wxRect& rect)
634         { m_renderer->DrawLineWrapMark(dc, rect); }
635 #endif // wxUSE_TEXTCTRL
636 
637 #if wxUSE_NOTEBOOK
638     virtual void DrawTab(wxDC& dc,
639                          const wxRect& rect,
640                          wxDirection dir,
641                          const wxString& label,
642                          const wxBitmap& bitmap = wxNullBitmap,
643                          int flags = 0,
644                          int accel = -1)
645         { m_renderer->DrawTab(dc, rect, dir, label, bitmap, flags, accel); }
646 #endif // wxUSE_NOTEBOOK
647 
648 #if wxUSE_SLIDER
649 
650     virtual void DrawSliderShaft(wxDC& dc,
651                                  const wxRect& rect,
652                                  int lenThumb,
653                                  wxOrientation orient,
654                                  int flags = 0,
655                                  long style = 0,
656                                  wxRect *rectShaft = NULL)
657         { m_renderer->DrawSliderShaft(dc, rect, lenThumb, orient, flags, style, rectShaft); }
658     virtual void DrawSliderThumb(wxDC& dc,
659                                  const wxRect& rect,
660                                  wxOrientation orient,
661                                  int flags = 0,
662                                  long style = 0)
663         { m_renderer->DrawSliderThumb(dc, rect, orient, flags, style); }
664     virtual void DrawSliderTicks(wxDC& dc,
665                                  const wxRect& rect,
666                                  int lenThumb,
667                                  wxOrientation orient,
668                                  int start,
669                                  int end,
670                                  int WXUNUSED(step) = 1,
671                                  int flags = 0,
672                                  long style = 0)
673         { m_renderer->DrawSliderTicks(dc, rect, lenThumb, orient,
674                                       start, end, start, flags, style); }
675 #endif // wxUSE_SLIDER
676 
677 #if wxUSE_MENUS
678     virtual void DrawMenuBarItem(wxDC& dc,
679                                  const wxRect& rect,
680                                  const wxString& label,
681                                  int flags = 0,
682                                  int indexAccel = -1)
683         { m_renderer->DrawMenuBarItem(dc, rect, label, flags, indexAccel); }
684     virtual void DrawMenuItem(wxDC& dc,
685                               wxCoord y,
686                               const wxMenuGeometryInfo& gi,
687                               const wxString& label,
688                               const wxString& accel,
689                               const wxBitmap& bitmap = wxNullBitmap,
690                               int flags = 0,
691                               int indexAccel = -1)
692         { m_renderer->DrawMenuItem(dc, y, gi, label, accel,
693                                    bitmap, flags, indexAccel); }
DrawMenuSeparator(wxDC & dc,wxCoord y,const wxMenuGeometryInfo & geomInfo)694     virtual void DrawMenuSeparator(wxDC& dc,
695                                    wxCoord y,
696                                    const wxMenuGeometryInfo& geomInfo)
697         { m_renderer->DrawMenuSeparator(dc, y, geomInfo); }
698 #endif // wxUSE_MENUS
699 
700 #if wxUSE_STATUSBAR
701     virtual void DrawStatusField(wxDC& dc,
702                                  const wxRect& rect,
703                                  const wxString& label,
704                                  int flags = 0, int style = 0)
705         { m_renderer->DrawStatusField(dc, rect, label, flags, style); }
706 #endif // wxUSE_STATUSBAR
707 
708     virtual void DrawFrameTitleBar(wxDC& dc,
709                                    const wxRect& rect,
710                                    const wxString& title,
711                                    const wxIcon& icon,
712                                    int flags,
713                                    int specialButton = 0,
714                                    int specialButtonFlag = 0)
715         { m_renderer->DrawFrameTitleBar(dc, rect, title, icon, flags,
716                                         specialButton, specialButtonFlag); }
DrawFrameBorder(wxDC & dc,const wxRect & rect,int flags)717     virtual void DrawFrameBorder(wxDC& dc,
718                                  const wxRect& rect,
719                                  int flags)
720         { m_renderer->DrawFrameBorder(dc, rect, flags); }
DrawFrameBackground(wxDC & dc,const wxRect & rect,int flags)721     virtual void DrawFrameBackground(wxDC& dc,
722                                      const wxRect& rect,
723                                      int flags)
724         { m_renderer->DrawFrameBackground(dc, rect, flags); }
DrawFrameTitle(wxDC & dc,const wxRect & rect,const wxString & title,int flags)725     virtual void DrawFrameTitle(wxDC& dc,
726                                 const wxRect& rect,
727                                 const wxString& title,
728                                 int flags)
729         { m_renderer->DrawFrameTitle(dc, rect, title, flags); }
DrawFrameIcon(wxDC & dc,const wxRect & rect,const wxIcon & icon,int flags)730     virtual void DrawFrameIcon(wxDC& dc,
731                                const wxRect& rect,
732                                const wxIcon& icon,
733                                int flags)
734         { m_renderer->DrawFrameIcon(dc, rect, icon, flags); }
735     virtual void DrawFrameButton(wxDC& dc,
736                                  wxCoord x, wxCoord y,
737                                  int button,
738                                  int flags = 0)
739         { m_renderer->DrawFrameButton(dc, x, y, button, flags); }
740 
741 #if wxUSE_COMBOBOX
GetComboBitmaps(wxBitmap * bmpNormal,wxBitmap * bmpFocus,wxBitmap * bmpPressed,wxBitmap * bmpDisabled)742     virtual void GetComboBitmaps(wxBitmap *bmpNormal,
743                                  wxBitmap *bmpFocus,
744                                  wxBitmap *bmpPressed,
745                                  wxBitmap *bmpDisabled)
746         { m_renderer->GetComboBitmaps(bmpNormal, bmpFocus,
747                                       bmpPressed, bmpDisabled); }
748 #endif // wxUSE_COMBOBOX
749 
AdjustSize(wxSize * size,const wxWindow * window)750     virtual void AdjustSize(wxSize *size, const wxWindow *window)
751         { m_renderer->AdjustSize(size, window); }
GetBorderDimensions(wxBorder border)752     virtual wxRect GetBorderDimensions(wxBorder border) const
753         { return m_renderer->GetBorderDimensions(border); }
AreScrollbarsInsideBorder()754     virtual bool AreScrollbarsInsideBorder() const
755         { return m_renderer->AreScrollbarsInsideBorder(); }
756 
757 #if wxUSE_SCROLLBAR
GetScrollbarArrowSize()758     virtual wxSize GetScrollbarArrowSize() const
759         { return m_renderer->GetScrollbarArrowSize(); }
760 #endif // wxUSE_SCROLLBAR
761 
GetListboxItemHeight(wxCoord fontHeight)762     virtual wxCoord GetListboxItemHeight(wxCoord fontHeight)
763         { return m_renderer->GetListboxItemHeight(fontHeight); }
GetCheckBitmapSize()764     virtual wxSize GetCheckBitmapSize() const
765         { return m_renderer->GetCheckBitmapSize(); }
GetRadioBitmapSize()766     virtual wxSize GetRadioBitmapSize() const
767         { return m_renderer->GetRadioBitmapSize(); }
GetCheckItemMargin()768     virtual wxCoord GetCheckItemMargin() const
769         { return m_renderer->GetCheckItemMargin(); }
770 
771 #if wxUSE_TOOLBAR
GetToolBarButtonSize(wxCoord * separator)772     virtual wxSize GetToolBarButtonSize(wxCoord *separator) const
773         { return m_renderer->GetToolBarButtonSize(separator); }
GetToolBarMargin()774     virtual wxSize GetToolBarMargin() const
775         { return m_renderer->GetToolBarMargin(); }
776 #endif // wxUSE_TOOLBAR
777 
778 #if wxUSE_TEXTCTRL
GetTextTotalArea(const wxTextCtrl * text,const wxRect & rect)779     virtual wxRect GetTextTotalArea(const wxTextCtrl *text,
780                                     const wxRect& rect) const
781         { return m_renderer->GetTextTotalArea(text, rect); }
GetTextClientArea(const wxTextCtrl * text,const wxRect & rect,wxCoord * extraSpaceBeyond)782     virtual wxRect GetTextClientArea(const wxTextCtrl *text,
783                                      const wxRect& rect,
784                                      wxCoord *extraSpaceBeyond) const
785         { return m_renderer->GetTextClientArea(text, rect, extraSpaceBeyond); }
786 #endif // wxUSE_TEXTCTRL
787 
788 #if wxUSE_NOTEBOOK
GetTabIndent()789     virtual wxSize GetTabIndent() const { return m_renderer->GetTabIndent(); }
GetTabPadding()790     virtual wxSize GetTabPadding() const { return m_renderer->GetTabPadding(); }
791 #endif // wxUSE_NOTEBOOK
792 
793 #if wxUSE_SLIDER
GetSliderDim()794     virtual wxCoord GetSliderDim() const
795         { return m_renderer->GetSliderDim(); }
GetSliderTickLen()796     virtual wxCoord GetSliderTickLen() const
797         { return m_renderer->GetSliderTickLen(); }
798 
799     virtual wxRect GetSliderShaftRect(const wxRect& rect,
800                                       int lenThumb,
801                                       wxOrientation orient,
802                                       long style = 0) const
803         { return m_renderer->GetSliderShaftRect(rect, lenThumb, orient, style); }
GetSliderThumbSize(const wxRect & rect,int lenThumb,wxOrientation orient)804     virtual wxSize GetSliderThumbSize(const wxRect& rect,
805                                       int lenThumb,
806                                       wxOrientation orient) const
807         { return m_renderer->GetSliderThumbSize(rect, lenThumb, orient); }
808 #endif // wxUSE_SLIDER
809 
GetProgressBarStep()810     virtual wxSize GetProgressBarStep() const
811         { return m_renderer->GetProgressBarStep(); }
812 
813 #if wxUSE_MENUS
GetMenuBarItemSize(const wxSize & sizeText)814     virtual wxSize GetMenuBarItemSize(const wxSize& sizeText) const
815         { return m_renderer->GetMenuBarItemSize(sizeText); }
GetMenuGeometry(wxWindow * win,const wxMenu & menu)816     virtual wxMenuGeometryInfo *GetMenuGeometry(wxWindow *win,
817                                                 const wxMenu& menu) const
818         { return m_renderer->GetMenuGeometry(win, menu); }
819 #endif // wxUSE_MENUS
820 
821 #if wxUSE_STATUSBAR
GetStatusBarBorders()822     virtual wxSize GetStatusBarBorders() const
823         { return m_renderer->GetStatusBarBorders(); }
GetStatusBarBorderBetweenFields()824     virtual wxCoord GetStatusBarBorderBetweenFields() const
825         { return m_renderer->GetStatusBarBorderBetweenFields(); }
GetStatusBarFieldMargins()826     virtual wxSize GetStatusBarFieldMargins() const
827         { return m_renderer->GetStatusBarFieldMargins(); }
828 #endif // wxUSE_STATUSBAR
829 
GetFrameClientArea(const wxRect & rect,int flags)830     virtual wxRect GetFrameClientArea(const wxRect& rect, int flags) const
831         { return m_renderer->GetFrameClientArea(rect, flags); }
GetFrameTotalSize(const wxSize & clientSize,int flags)832     virtual wxSize GetFrameTotalSize(const wxSize& clientSize, int flags) const
833         { return m_renderer->GetFrameTotalSize(clientSize, flags); }
GetFrameMinSize(int flags)834     virtual wxSize GetFrameMinSize(int flags) const
835         { return m_renderer->GetFrameMinSize(flags); }
GetFrameIconSize()836     virtual wxSize GetFrameIconSize() const
837         { return m_renderer->GetFrameIconSize(); }
HitTestFrame(const wxRect & rect,const wxPoint & pt,int flags)838     virtual int HitTestFrame(const wxRect& rect,
839                              const wxPoint& pt,
840                              int flags) const
841         { return m_renderer->HitTestFrame(rect, pt, flags); }
842 
843     virtual int  DrawHeaderButton(wxWindow *win,
844                                   wxDC& dc,
845                                   const wxRect& rect,
846                                   int flags = 0,
847                                   wxHeaderSortIconType sortIcon = wxHDR_SORT_ICON_NONE,
848                                   wxHeaderButtonParams* params = NULL)
849         { return m_renderer->DrawHeaderButton(win, dc, rect, flags, sortIcon, params); }
850     virtual void DrawTreeItemButton(wxWindow *win,
851                                     wxDC& dc,
852                                     const wxRect& rect,
853                                     int flags = 0)
854         { m_renderer->DrawTreeItemButton(win, dc, rect, flags); }
855 
856 protected:
857     wxRenderer *m_renderer;
858 };
859 
860 // ----------------------------------------------------------------------------
861 // wxControlRenderer: wraps the wxRenderer functions in a form easy to use from
862 // OnPaint()
863 // ----------------------------------------------------------------------------
864 
865 class WXDLLIMPEXP_CORE wxControlRenderer
866 {
867 public:
868     // create a renderer for this dc with this "fundamental" renderer
869     wxControlRenderer(wxWindow *control, wxDC& dc, wxRenderer *renderer);
870 
871     // operations
872     void DrawLabel();
873     void DrawButtonLabel(const wxBitmap& bitmap = wxNullBitmap,
874                          wxCoord marginX = 0, wxCoord marginY = 0);
875 #if wxUSE_LISTBOX
876     void DrawItems(const wxListBox *listbox,
877                    size_t itemFirst, size_t itemLast);
878 #endif // wxUSE_LISTBOX
879 #if wxUSE_CHECKLISTBOX
880     void DrawCheckItems(const wxCheckListBox *listbox,
881                         size_t itemFirst, size_t itemLast);
882 #endif // wxUSE_CHECKLISTBOX
883     void DrawButtonBorder();
884     // the line must be either horizontal or vertical
885     void DrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2);
886     void DrawFrame();
887     void DrawBitmap(const wxBitmap& bitmap);
888     void DrawBackgroundBitmap();
889     void DrawScrollbar(const wxScrollBar *scrollbar, int thumbPosOld);
890 #if wxUSE_GAUGE
891     void DrawProgressBar(const wxGauge *gauge);
892 #endif // wxUSE_GAUGE
893 
894     // accessors
GetWindow()895     wxWindow *GetWindow() const { return m_window; }
GetRenderer()896     wxRenderer *GetRenderer() const { return m_renderer; }
897 
GetDC()898     wxDC& GetDC() { return m_dc; }
899 
GetRect()900     const wxRect& GetRect() const { return m_rect; }
GetRect()901     wxRect& GetRect() { return m_rect; }
902 
903     // static helpers
904     static void DrawBitmap(wxDC &dc,
905                            const wxBitmap& bitmap,
906                            const wxRect& rect,
907                            int alignment = wxALIGN_CENTRE |
908                                            wxALIGN_CENTRE_VERTICAL,
909                            wxStretch stretch = wxSTRETCH_NOT);
910 
911 private:
912 
913 #if wxUSE_LISTBOX
914     // common part of DrawItems() and DrawCheckItems()
915     void DoDrawItems(const wxListBox *listbox,
916                      size_t itemFirst, size_t itemLast,
917                      bool isCheckLbox = false);
918 #endif // wxUSE_LISTBOX
919 
920     wxWindow *m_window;
921     wxRenderer *m_renderer;
922     wxDC& m_dc;
923     wxRect m_rect;
924 };
925 
926 #endif // _WX_UNIV_RENDERER_H_
927