]> git.saurik.com Git - wxWidgets.git/blob - include/wx/univ/renderer.h
fixed huge memory leak in wxFileDialog (closes patch 544060)
[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 wxOrientation orient,
232 int flags = 0,
233 wxRect *rectShaft = NULL) = 0;
234
235 // draw the slider thumb
236 virtual void DrawSliderThumb(wxDC& dc,
237 const wxRect& rect,
238 wxOrientation orient,
239 int flags = 0) = 0;
240
241 // draw the slider ticks
242 virtual void DrawSliderTicks(wxDC& dc,
243 const wxRect& rect,
244 const wxSize& sizeThumb,
245 wxOrientation orient,
246 int start,
247 int end,
248 int step = 1,
249 int flags = 0) = 0;
250
251 // draw a menu bar item
252 virtual void DrawMenuBarItem(wxDC& dc,
253 const wxRect& rect,
254 const wxString& label,
255 int flags = 0,
256 int indexAccel = -1) = 0;
257
258 // draw a menu item (also used for submenus if flags has ISSUBMENU flag)
259 //
260 // the geometryInfo is calculated by GetMenuGeometry() function from below
261 virtual void DrawMenuItem(wxDC& dc,
262 wxCoord y,
263 const wxMenuGeometryInfo& geometryInfo,
264 const wxString& label,
265 const wxString& accel,
266 const wxBitmap& bitmap = wxNullBitmap,
267 int flags = 0,
268 int indexAccel = -1) = 0;
269
270 // draw a menu bar separator
271 virtual void DrawMenuSeparator(wxDC& dc,
272 wxCoord y,
273 const wxMenuGeometryInfo& geomInfo) = 0;
274
275 // draw a status bar field: wxCONTROL_ISDEFAULT bit in the flags is
276 // interpreted specially and means "draw the status bar grip" here
277 virtual void DrawStatusField(wxDC& dc,
278 const wxRect& rect,
279 const wxString& label,
280 int flags = 0) = 0;
281
282 // draw complete frame/dialog titlebar
283 virtual void DrawFrameTitleBar(wxDC& dc,
284 const wxRect& rect,
285 const wxString& title,
286 const wxIcon& icon,
287 int flags,
288 int specialButton = 0,
289 int specialButtonFlags = 0) = 0;
290
291 // draw frame borders
292 virtual void DrawFrameBorder(wxDC& dc,
293 const wxRect& rect,
294 int flags) = 0;
295
296 // draw frame titlebar background
297 virtual void DrawFrameBackground(wxDC& dc,
298 const wxRect& rect,
299 int flags) = 0;
300
301 // draw frame title
302 virtual void DrawFrameTitle(wxDC& dc,
303 const wxRect& rect,
304 const wxString& title,
305 int flags) = 0;
306
307 // draw frame icon
308 virtual void DrawFrameIcon(wxDC& dc,
309 const wxRect& rect,
310 const wxIcon& icon,
311 int flags) = 0;
312
313 // draw frame buttons
314 virtual void DrawFrameButton(wxDC& dc,
315 wxCoord x, wxCoord y,
316 int button,
317 int flags = 0) = 0;
318
319 // misc functions
320 // --------------
321
322 // return the bitmaps to use for combobox button
323 virtual void GetComboBitmaps(wxBitmap *bmpNormal,
324 wxBitmap *bmpFocus,
325 wxBitmap *bmpPressed,
326 wxBitmap *bmpDisabled) = 0;
327
328 // geometry functions
329 // ------------------
330
331 // get the dimensions of the border: rect.x/y contain the width/height of
332 // the left/top side, width/heigh - of the right/bottom one
333 virtual wxRect GetBorderDimensions(wxBorder border) const = 0;
334
335 // the scrollbars may be drawn either inside the window border or outside
336 // it - this function is used to decide how to draw them
337 virtual bool AreScrollbarsInsideBorder() const = 0;
338
339 // adjust the size of the control of the given class: for most controls,
340 // this just takes into account the border, but for some (buttons, for
341 // example) it is more complicated - the result being, in any case, that
342 // the control looks "nice" if it uses the adjusted rectangle
343 virtual void AdjustSize(wxSize *size, const wxWindow *window) = 0;
344
345 // get the size of a scrollbar arrow
346 virtual wxSize GetScrollbarArrowSize() const = 0;
347
348 // gets the bounding box for a scrollbar element for the given (by default
349 // - current) thumb position
350 virtual wxRect GetScrollbarRect(const wxScrollBar *scrollbar,
351 wxScrollBar::Element elem,
352 int thumbPos = -1) const = 0;
353
354 // returns the size of the scrollbar shaft excluding the arrows
355 virtual wxCoord GetScrollbarSize(const wxScrollBar *scrollbar) = 0;
356
357 // returns one of wxHT_SCROLLBAR_XXX constants
358 virtual wxHitTest HitTestScrollbar(const wxScrollBar *scrollbar,
359 const wxPoint& pt) const = 0;
360
361 // translate the scrollbar position (in logical units) into physical
362 // coordinate (in pixels) and the other way round
363 virtual wxCoord ScrollbarToPixel(const wxScrollBar *scrollbar,
364 int thumbPos = -1) = 0;
365 virtual int PixelToScrollbar(const wxScrollBar *scrollbar,
366 wxCoord coord) = 0;
367
368 // get the height of a listbox item from the base font height
369 virtual wxCoord GetListboxItemHeight(wxCoord fontHeight) = 0;
370
371 // get the size of a checkbox/radio button bitmap
372 virtual wxSize GetCheckBitmapSize() const = 0;
373 virtual wxSize GetRadioBitmapSize() const = 0;
374 virtual wxCoord GetCheckItemMargin() const = 0;
375
376 // get the standard size of a toolbar button and also return the size of
377 // a toolbar separator in the provided pointer
378 virtual wxSize GetToolBarButtonSize(wxCoord *separator) const = 0;
379
380 // get the margins between/around the toolbar buttons
381 virtual wxSize GetToolBarMargin() const = 0;
382
383 // convert between text rectangle and client rectangle for text controls:
384 // the former is typicall smaller to leave margins around text
385 virtual wxRect GetTextTotalArea(const wxTextCtrl *text,
386 const wxRect& rectText) const = 0;
387
388 // extra space is for line indicators
389 virtual wxRect GetTextClientArea(const wxTextCtrl *text,
390 const wxRect& rectTotal,
391 wxCoord *extraSpaceBeyond) const = 0;
392
393 // get the overhang of a selected tab
394 virtual wxSize GetTabIndent() const = 0;
395
396 // get the padding around the text in a tab
397 virtual wxSize GetTabPadding() const = 0;
398
399 // get the default size of the slider in lesser dimension (i.e. height of a
400 // horizontal slider or width of a vertical one)
401 virtual wxCoord GetSliderDim() const = 0;
402
403 // get the length of the slider ticks displayed along side slider
404 virtual wxCoord GetSliderTickLen() const = 0;
405
406 // get the slider shaft rect from the total slider rect
407 virtual wxRect GetSliderShaftRect(const wxRect& rect,
408 wxOrientation orient) const = 0;
409
410 // get the size of the slider thumb for the given total slider rect
411 virtual wxSize GetSliderThumbSize(const wxRect& rect,
412 wxOrientation orient) const = 0;
413
414 // get the size of one progress bar step (in horz and vertical directions)
415 virtual wxSize GetProgressBarStep() const = 0;
416
417 // get the size of rectangle to use in the menubar for the given text rect
418 virtual wxSize GetMenuBarItemSize(const wxSize& sizeText) const = 0;
419
420 // get the struct storing all layout info needed to draw all menu items
421 // (this can't be calculated for each item separately as they should be
422 // aligned)
423 //
424 // the returned pointer must be deleted by the caller
425 virtual wxMenuGeometryInfo *GetMenuGeometry(wxWindow *win,
426 const wxMenu& menu) const = 0;
427
428 // get the borders around the status bar fields (x and y fields of the
429 // return value) and also, optionally, the border between the fields
430 virtual wxSize GetStatusBarBorders(wxCoord *borderBetweenFields) const = 0;
431
432 // get client area rectangle of top level window (i.e. subtract
433 // decorations from given rectangle)
434 virtual wxRect GetFrameClientArea(const wxRect& rect, int flags) const = 0;
435
436 // get size of whole top level window, given size of its client area size
437 virtual wxSize GetFrameTotalSize(const wxSize& clientSize, int flags) const = 0;
438
439 // get the minimal size of top level window
440 virtual wxSize GetFrameMinSize(int flags) const = 0;
441
442 // get titlebar icon size
443 virtual wxSize GetFrameIconSize() const = 0;
444
445 // returns one of wxHT_TOPLEVEL_XXX constants
446 virtual int HitTestFrame(const wxRect& rect,
447 const wxPoint& pt,
448 int flags = 0) const = 0;
449
450 // virtual dtor for any base class
451 virtual ~wxRenderer();
452
453 protected:
454 // draw a frame around rectFrame rectangle but not touching the rectLabel
455 // one: this is used by DrawFrame()
456 void StandardDrawFrame(wxDC& dc,
457 const wxRect& rectFrame,
458 const wxRect& rectLabel);
459
460 // standard text line drawing: just use DrawText() and highlight the
461 // selected part
462 static void StandardDrawTextLine(wxDC& dc,
463 const wxString& text,
464 const wxRect& rect,
465 int selStart, int selEnd,
466 int flags);
467
468 // standard scrollbar hit testing: this assumes that it only has 2 arrows
469 // and a thumb, so the themes which have more complicated scrollbars (e.g.
470 // BeOS) can't use this method
471 static wxRect StandardGetScrollbarRect(const wxScrollBar *scrollbar,
472 wxScrollBar::Element elem,
473 int thumbPos,
474 const wxSize& sizeArrow);
475 static wxHitTest StandardHitTestScrollbar(const wxScrollBar *scrollbar,
476 const wxPoint& pt,
477 const wxSize& sizeArrow);
478 static wxCoord StandardScrollbarToPixel(const wxScrollBar *scrollbar,
479 int thumbPos,
480 const wxSize& sizeArrow);
481 static int StandardPixelToScrollbar(const wxScrollBar *scrollbar,
482 wxCoord coord,
483 const wxSize& sizeArrow);
484 static wxCoord StandardScrollBarSize(const wxScrollBar *scrollbar,
485 const wxSize& sizeArrow);
486 static void StandardScrollBarThumbSize(wxCoord lenBar,
487 int thumbPos,
488 int thumbSize,
489 int range,
490 wxCoord *thumbStart,
491 wxCoord *thumbEnd);
492 };
493
494 // ----------------------------------------------------------------------------
495 // wxDelegateRenderer: it is impossible to inherit from any of standard
496 // renderers as their declarations are in private code, but you can use this
497 // class to override only some of the Draw() functions - all the other ones
498 // will be left to the original renderer
499 // ----------------------------------------------------------------------------
500
501 class WXDLLEXPORT wxDelegateRenderer : public wxRenderer
502 {
503 public:
504 wxDelegateRenderer(wxRenderer *renderer) : m_renderer(renderer) { }
505
506 virtual void DrawBackground(wxDC& dc,
507 const wxColour& col,
508 const wxRect& rect,
509 int flags,
510 wxWindow *window = NULL )
511 { m_renderer->DrawBackground(dc, col, rect, flags, window ); }
512 virtual void DrawLabel(wxDC& dc,
513 const wxString& label,
514 const wxRect& rect,
515 int flags = 0,
516 int align = wxALIGN_LEFT | wxALIGN_TOP,
517 int indexAccel = -1,
518 wxRect *rectBounds = NULL)
519 { m_renderer->DrawLabel(dc, label, rect,
520 flags, align, indexAccel, rectBounds); }
521 virtual void DrawButtonLabel(wxDC& dc,
522 const wxString& label,
523 const wxBitmap& image,
524 const wxRect& rect,
525 int flags = 0,
526 int align = wxALIGN_LEFT | wxALIGN_TOP,
527 int indexAccel = -1,
528 wxRect *rectBounds = NULL)
529 { m_renderer->DrawButtonLabel(dc, label, image, rect,
530 flags, align, indexAccel, rectBounds); }
531 virtual void DrawBorder(wxDC& dc,
532 wxBorder border,
533 const wxRect& rect,
534 int flags = 0,
535 wxRect *rectIn = (wxRect *)NULL)
536 { m_renderer->DrawBorder(dc, border, rect, flags, rectIn); }
537 virtual void DrawTextBorder(wxDC& dc,
538 wxBorder border,
539 const wxRect& rect,
540 int flags = 0,
541 wxRect *rectIn = (wxRect *)NULL)
542 { m_renderer->DrawTextBorder(dc, border, rect, flags, rectIn); }
543 virtual void DrawButtonBorder(wxDC& dc,
544 const wxRect& rect,
545 int flags = 0,
546 wxRect *rectIn = (wxRect *)NULL)
547 { m_renderer->DrawButtonBorder(dc, rect, flags, rectIn); }
548 virtual void DrawFrame(wxDC& dc,
549 const wxString& label,
550 const wxRect& rect,
551 int flags = 0,
552 int align = wxALIGN_LEFT,
553 int indexAccel = -1)
554 { m_renderer->DrawFrame(dc, label, rect, flags, align, indexAccel); }
555 virtual void DrawHorizontalLine(wxDC& dc,
556 wxCoord y, wxCoord x1, wxCoord x2)
557 { m_renderer->DrawHorizontalLine(dc, y, x1, x2); }
558 virtual void DrawVerticalLine(wxDC& dc,
559 wxCoord x, wxCoord y1, wxCoord y2)
560 { m_renderer->DrawVerticalLine(dc, x, y1, y2); }
561 virtual void DrawArrow(wxDC& dc,
562 wxDirection dir,
563 const wxRect& rect,
564 int flags = 0)
565 { m_renderer->DrawArrow(dc, dir, rect, flags); }
566 virtual void DrawScrollbarArrow(wxDC& dc,
567 wxDirection dir,
568 const wxRect& rect,
569 int flags = 0)
570 { m_renderer->DrawScrollbarArrow(dc, dir, rect, flags); }
571 virtual void DrawScrollbarThumb(wxDC& dc,
572 wxOrientation orient,
573 const wxRect& rect,
574 int flags = 0)
575 { m_renderer->DrawScrollbarThumb(dc, orient, rect, flags); }
576 virtual void DrawScrollbarShaft(wxDC& dc,
577 wxOrientation orient,
578 const wxRect& rect,
579 int flags = 0)
580 { m_renderer->DrawScrollbarShaft(dc, orient, rect, flags); }
581 virtual void DrawScrollCorner(wxDC& dc,
582 const wxRect& rect)
583 { m_renderer->DrawScrollCorner(dc, rect); }
584 virtual void DrawItem(wxDC& dc,
585 const wxString& label,
586 const wxRect& rect,
587 int flags = 0)
588 { m_renderer->DrawItem(dc, label, rect, flags); }
589 virtual void DrawCheckItem(wxDC& dc,
590 const wxString& label,
591 const wxBitmap& bitmap,
592 const wxRect& rect,
593 int flags = 0)
594 { m_renderer->DrawCheckItem(dc, label, bitmap, rect, flags); }
595 virtual void DrawCheckButton(wxDC& dc,
596 const wxString& label,
597 const wxBitmap& bitmap,
598 const wxRect& rect,
599 int flags = 0,
600 wxAlignment align = wxALIGN_LEFT,
601 int indexAccel = -1)
602 { m_renderer->DrawCheckButton(dc, label, bitmap, rect,
603 flags, align, indexAccel); }
604 virtual void DrawRadioButton(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->DrawRadioButton(dc, label, bitmap, rect,
612 flags, align, indexAccel); }
613 virtual void DrawToolBarButton(wxDC& dc,
614 const wxString& label,
615 const wxBitmap& bitmap,
616 const wxRect& rect,
617 int flags = 0)
618 { m_renderer->DrawToolBarButton(dc, label, bitmap, rect, flags); }
619 virtual void DrawTextLine(wxDC& dc,
620 const wxString& text,
621 const wxRect& rect,
622 int selStart = -1,
623 int selEnd = -1)
624 { m_renderer->DrawTextLine(dc, text, rect, selStart, selEnd); }
625 virtual void DrawLineWrapMark(wxDC& dc, const wxRect& rect)
626 { m_renderer->DrawLineWrapMark(dc, rect); }
627
628 virtual void DrawTab(wxDC& dc,
629 const wxRect& rect,
630 wxDirection dir,
631 const wxString& label,
632 const wxBitmap& bitmap = wxNullBitmap,
633 int flags = 0,
634 int accel = -1)
635 { m_renderer->DrawTab(dc, rect, dir, label, bitmap, flags, accel); }
636
637 virtual void DrawSliderShaft(wxDC& dc,
638 const wxRect& rect,
639 wxOrientation orient,
640 int flags = 0,
641 wxRect *rectShaft = NULL)
642 { m_renderer->DrawSliderShaft(dc, rect, orient, flags, rectShaft); }
643 virtual void DrawSliderThumb(wxDC& dc,
644 const wxRect& rect,
645 wxOrientation orient,
646 int flags = 0)
647 { m_renderer->DrawSliderThumb(dc, rect, orient, flags); }
648 virtual void DrawSliderTicks(wxDC& dc,
649 const wxRect& rect,
650 const wxSize& sizeThumb,
651 wxOrientation orient,
652 int start,
653 int end,
654 int step = 1,
655 int flags = 0)
656 { m_renderer->DrawSliderTicks(dc, rect, sizeThumb, orient,
657 start, end, start, flags); }
658
659 virtual void DrawMenuBarItem(wxDC& dc,
660 const wxRect& rect,
661 const wxString& label,
662 int flags = 0,
663 int indexAccel = -1)
664 { m_renderer->DrawMenuBarItem(dc, rect, label, flags, indexAccel); }
665 virtual void DrawMenuItem(wxDC& dc,
666 wxCoord y,
667 const wxMenuGeometryInfo& gi,
668 const wxString& label,
669 const wxString& accel,
670 const wxBitmap& bitmap = wxNullBitmap,
671 int flags = 0,
672 int indexAccel = -1)
673 { m_renderer->DrawMenuItem(dc, y, gi, label, accel,
674 bitmap, flags, indexAccel); }
675 virtual void DrawMenuSeparator(wxDC& dc,
676 wxCoord y,
677 const wxMenuGeometryInfo& geomInfo)
678 { m_renderer->DrawMenuSeparator(dc, y, geomInfo); }
679
680 virtual void DrawStatusField(wxDC& dc,
681 const wxRect& rect,
682 const wxString& label,
683 int flags = 0)
684 { m_renderer->DrawStatusField(dc, rect, label, flags); }
685
686 virtual void DrawFrameTitleBar(wxDC& dc,
687 const wxRect& rect,
688 const wxString& title,
689 const wxIcon& icon,
690 int flags,
691 int specialButton = 0,
692 int specialButtonFlag = 0)
693 { m_renderer->DrawFrameTitleBar(dc, rect, title, icon, flags,
694 specialButton, specialButtonFlag); }
695 virtual void DrawFrameBorder(wxDC& dc,
696 const wxRect& rect,
697 int flags)
698 { m_renderer->DrawFrameBorder(dc, rect, flags); }
699 virtual void DrawFrameBackground(wxDC& dc,
700 const wxRect& rect,
701 int flags)
702 { m_renderer->DrawFrameBackground(dc, rect, flags); }
703 virtual void DrawFrameTitle(wxDC& dc,
704 const wxRect& rect,
705 const wxString& title,
706 int flags)
707 { m_renderer->DrawFrameTitle(dc, rect, title, flags); }
708 virtual void DrawFrameIcon(wxDC& dc,
709 const wxRect& rect,
710 const wxIcon& icon,
711 int flags)
712 { m_renderer->DrawFrameIcon(dc, rect, icon, flags); }
713 virtual void DrawFrameButton(wxDC& dc,
714 wxCoord x, wxCoord y,
715 int button,
716 int flags = 0)
717 { m_renderer->DrawFrameButton(dc, x, y, button, flags); }
718
719 virtual void GetComboBitmaps(wxBitmap *bmpNormal,
720 wxBitmap *bmpFocus,
721 wxBitmap *bmpPressed,
722 wxBitmap *bmpDisabled) const
723 { m_renderer->GetComboBitmaps(bmpNormal, bmpFocus,
724 bmpPressed, bmpDisabled); }
725
726 virtual void AdjustSize(wxSize *size, const wxWindow *window)
727 { m_renderer->AdjustSize(size, window); }
728 virtual wxRect GetBorderDimensions(wxBorder border) const
729 { return m_renderer->GetBorderDimensions(border); }
730 virtual bool AreScrollbarsInsideBorder() const
731 { return m_renderer->AreScrollbarsInsideBorder(); }
732
733 virtual wxSize GetScrollbarArrowSize() const
734 { return m_renderer->GetScrollbarArrowSize(); }
735 virtual wxRect GetScrollbarRect(const wxScrollBar *scrollbar,
736 wxScrollBar::Element elem,
737 int thumbPos = -1) const
738 { return m_renderer->GetScrollbarRect(scrollbar, elem, thumbPos); }
739 virtual wxCoord GetScrollbarSize(const wxScrollBar *scrollbar)
740 { return m_renderer->GetScrollbarSize(scrollbar); }
741 virtual wxHitTest HitTestScrollbar(const wxScrollBar *scrollbar,
742 const wxPoint& pt) const
743 { return m_renderer->HitTestScrollbar(scrollbar, pt); }
744 virtual wxCoord ScrollbarToPixel(const wxScrollBar *scrollbar,
745 int thumbPos = -1)
746 { return m_renderer->ScrollbarToPixel(scrollbar, thumbPos); }
747 virtual int PixelToScrollbar(const wxScrollBar *scrollbar,
748 wxCoord coord)
749 { return m_renderer->PixelToScrollbar(scrollbar, coord); }
750 virtual wxCoord GetListboxItemHeight(wxCoord fontHeight)
751 { return m_renderer->GetListboxItemHeight(fontHeight); }
752 virtual wxSize GetCheckBitmapSize() const
753 { return m_renderer->GetCheckBitmapSize(); }
754 virtual wxSize GetRadioBitmapSize() const
755 { return m_renderer->GetRadioBitmapSize(); }
756 virtual wxCoord GetCheckItemMargin() const
757 { return m_renderer->GetCheckItemMargin(); }
758
759 virtual wxSize GetToolBarButtonSize(wxCoord *separator) const
760 { return m_renderer->GetToolBarButtonSize(separator); }
761 virtual wxSize GetToolBarMargin() const
762 { return m_renderer->GetToolBarMargin(); }
763
764 virtual wxRect GetTextTotalArea(const wxTextCtrl *text,
765 const wxRect& rect) const
766 { return m_renderer->GetTextTotalArea(text, rect); }
767 virtual wxRect GetTextClientArea(const wxTextCtrl *text,
768 const wxRect& rect,
769 wxCoord *extraSpaceBeyond) const
770 { return m_renderer->GetTextClientArea(text, rect, extraSpaceBeyond); }
771
772 virtual wxSize GetTabIndent() const { return m_renderer->GetTabIndent(); }
773 virtual wxSize GetTabPadding() const { return m_renderer->GetTabPadding(); }
774
775 virtual wxCoord GetSliderDim() const
776 { return m_renderer->GetSliderDim(); }
777 virtual wxCoord GetSliderTickLen() const
778 { return m_renderer->GetSliderTickLen(); }
779 virtual wxRect GetSliderShaftRect(const wxRect& rect,
780 wxOrientation orient) const
781 { return GetSliderShaftRect(rect, orient); }
782 virtual wxSize GetSliderThumbSize(const wxRect& rect,
783 wxOrientation orient) const
784 { return m_renderer->GetSliderThumbSize(rect, orient); }
785 virtual wxSize GetProgressBarStep() const
786 { return m_renderer->GetProgressBarStep(); }
787 virtual wxSize GetMenuBarItemSize(const wxSize& sizeText) const
788 { return m_renderer->GetMenuBarItemSize(sizeText); }
789 virtual wxMenuGeometryInfo *GetMenuGeometry(wxWindow *win,
790 const wxMenu& menu) const
791 { return m_renderer->GetMenuGeometry(win, menu); }
792 virtual wxSize GetStatusBarBorders(wxCoord *borderBetweenFields) const
793 { return m_renderer->GetStatusBarBorders(borderBetweenFields); }
794 virtual wxRect GetFrameClientArea(const wxRect& rect, int flags) const
795 { return m_renderer->GetFrameClientArea(rect, flags); }
796 virtual wxSize GetFrameTotalSize(const wxSize& clientSize, int flags) const
797 { return m_renderer->GetFrameTotalSize(clientSize, flags); }
798 virtual wxSize GetFrameMinSize(int flags) const
799 { return m_renderer->GetFrameMinSize(flags); }
800 virtual wxSize GetFrameIconSize() const
801 { return m_renderer->GetFrameIconSize(); }
802 virtual int HitTestFrame(const wxRect& rect,
803 const wxPoint& pt,
804 int flags) const
805 { return m_renderer->HitTestFrame(rect, pt, flags); }
806
807 protected:
808 wxRenderer *m_renderer;
809 };
810
811 // ----------------------------------------------------------------------------
812 // wxControlRenderer: wraps the wxRenderer functions in a form easy to use from
813 // OnPaint()
814 // ----------------------------------------------------------------------------
815
816 class WXDLLEXPORT wxControlRenderer
817 {
818 public:
819 // create a renderer for this dc with this "fundamental" renderer
820 wxControlRenderer(wxWindow *control, wxDC& dc, wxRenderer *renderer);
821
822 // operations
823 void DrawLabel(const wxBitmap& bitmap = wxNullBitmap,
824 wxCoord marginX = 0, wxCoord marginY = 0);
825 #if wxUSE_LISTBOX
826 void DrawItems(const wxListBox *listbox,
827 size_t itemFirst, size_t itemLast);
828 #endif // wxUSE_LISTBOX
829 #if wxUSE_CHECKLISTBOX
830 void DrawCheckItems(const wxCheckListBox *listbox,
831 size_t itemFirst, size_t itemLast);
832 #endif // wxUSE_CHECKLISTBOX
833 void DrawButtonBorder();
834 // the line must be either horizontal or vertical
835 void DrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2);
836 void DrawFrame();
837 void DrawBitmap(const wxBitmap& bitmap);
838 void DrawBackgroundBitmap();
839 void DrawScrollbar(const wxScrollBar *scrollbar, int thumbPosOld);
840 #if wxUSE_GAUGE
841 void DrawProgressBar(const wxGauge *gauge);
842 #endif // wxUSE_GAUGE
843
844 // accessors
845 wxWindow *GetWindow() const { return m_window; }
846 wxRenderer *GetRenderer() const { return m_renderer; }
847
848 wxDC& GetDC() { return m_dc; }
849
850 const wxRect& GetRect() const { return m_rect; }
851 wxRect& GetRect() { return m_rect; }
852
853 // static helpers
854 static void DrawBitmap(wxDC &dc,
855 const wxBitmap& bitmap,
856 const wxRect& rect,
857 int alignment = wxALIGN_CENTRE |
858 wxALIGN_CENTRE_VERTICAL,
859 wxStretch stretch = wxSTRETCH_NOT);
860
861 private:
862 // common part of DrawItems() and DrawCheckItems()
863 void DoDrawItems(const wxListBox *listbox,
864 size_t itemFirst, size_t itemLast,
865 bool isCheckLbox = FALSE);
866
867 wxWindow *m_window;
868 wxRenderer *m_renderer;
869 wxDC& m_dc;
870 wxRect m_rect;
871 };
872
873 #endif // _WX_UNIV_RENDERER_H_
874