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