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