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