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