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