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