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