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