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