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