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