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