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