1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/univ/stdrend.h
3 // Purpose: wxStdRenderer class declaration
4 // Author: Vadim Zeitlin
7 // Copyright: (c) 2006 Vadim Zeitlin <vadim@wxwindows.org>
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_UNIV_STDREND_H_
12 #define _WX_UNIV_STDREND_H_
14 #include "wx/univ/renderer.h"
16 class WXDLLEXPORT wxColourScheme
;
18 // ----------------------------------------------------------------------------
19 // wxStdRenderer: implements as much of wxRenderer API as possible generically
20 // ----------------------------------------------------------------------------
22 class wxStdRenderer
: public wxRenderer
25 // the renderer will use the given scheme, whose lifetime must be at least
26 // as long as of this object itself, to choose the colours for drawing
27 wxStdRenderer(const wxColourScheme
*scheme
);
29 virtual void DrawBackground(wxDC
& dc
,
33 wxWindow
*window
= NULL
);
34 virtual void DrawButtonSurface(wxDC
& dc
,
40 virtual void DrawFocusRect(wxDC
& dc
, const wxRect
& rect
);
41 virtual void DrawLabel(wxDC
& dc
,
42 const wxString
& label
,
45 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
47 wxRect
*rectBounds
= NULL
);
48 virtual void DrawButtonLabel(wxDC
& dc
,
49 const wxString
& label
,
50 const wxBitmap
& image
,
53 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
55 wxRect
*rectBounds
= NULL
);
58 virtual void DrawBorder(wxDC
& dc
,
62 wxRect
*rectIn
= NULL
);
63 virtual void DrawTextBorder(wxDC
& dc
,
67 wxRect
*rectIn
= NULL
);
69 virtual void DrawHorizontalLine(wxDC
& dc
,
70 wxCoord y
, wxCoord x1
, wxCoord x2
);
71 virtual void DrawVerticalLine(wxDC
& dc
,
72 wxCoord x
, wxCoord y1
, wxCoord y2
);
73 virtual void DrawFrame(wxDC
& dc
,
74 const wxString
& label
,
77 int alignment
= wxALIGN_LEFT
,
81 virtual void DrawItem(wxDC
& dc
,
82 const wxString
& label
,
86 virtual void DrawCheckButton(wxDC
& dc
,
87 const wxString
& label
,
88 const wxBitmap
& bitmap
,
91 wxAlignment align
= wxALIGN_LEFT
,
93 virtual void DrawRadioButton(wxDC
& dc
,
94 const wxString
& label
,
95 const wxBitmap
& bitmap
,
98 wxAlignment align
= wxALIGN_LEFT
,
102 virtual void DrawTextLine(wxDC
& dc
,
103 const wxString
& text
,
109 virtual void DrawLineWrapMark(wxDC
& dc
, const wxRect
& rect
);
110 #endif // wxUSE_TEXTCTRL
112 virtual wxRect
GetBorderDimensions(wxBorder border
) const;
114 virtual bool AreScrollbarsInsideBorder() const;
117 virtual wxRect
GetScrollbarRect(const wxScrollBar
*scrollbar
,
118 wxScrollBar::Element elem
,
119 int thumbPos
= -1) const;
121 virtual wxCoord
GetScrollbarSize(const wxScrollBar
*scrollbar
);
123 virtual wxHitTest
HitTestScrollbar(const wxScrollBar
*scrollbar
,
124 const wxPoint
& pt
) const;
126 virtual wxCoord
ScrollbarToPixel(const wxScrollBar
*scrollbar
,
128 virtual int PixelToScrollbar(const wxScrollBar
*scrollbar
, wxCoord coord
);
129 #endif // wxUSE_SCROLLBAR
143 IndicatorState_Normal
,
144 IndicatorState_Pressed
, // this one is for check/radioboxes
145 IndicatorState_Disabled
,
146 IndicatorState_MaxCtrl
,
148 // the rest of the states are valid for menu items only
149 IndicatorState_Selected
= IndicatorState_Pressed
,
150 IndicatorState_SelectedDisabled
= IndicatorState_MaxCtrl
,
151 IndicatorState_MaxMenu
156 IndicatorStatus_Checked
,
157 IndicatorStatus_Unchecked
,
158 IndicatorStatus_Undetermined
,
162 // translate the appropriate bits in flags to the above enum elements
163 static void GetIndicatorsFromFlags(int flags
,
164 IndicatorState
& state
,
165 IndicatorStatus
& status
);
167 // fill the rectangle with a brush of given colour (must be valid)
168 void DrawSolidRect(wxDC
& dc
, const wxColour
& col
, const wxRect
& rect
);
171 // all the functions in this section adjust the rect parameter to
172 // correspond to the interiour of the drawn area
174 // draw complete rectangle
175 void DrawRect(wxDC
& dc
, wxRect
*rect
, const wxPen
& pen
);
177 // draw the rectange using the first pen for the left and top sides
178 // and the second one for the bottom and right ones
179 void DrawShadedRect(wxDC
& dc
, wxRect
*rect
,
180 const wxPen
& pen1
, const wxPen
& pen2
);
182 // border drawing routines, may be overridden in the derived class
183 virtual void DrawRaisedBorder(wxDC
& dc
, wxRect
*rect
);
184 virtual void DrawSunkenBorder(wxDC
& dc
, wxRect
*rect
);
185 virtual void DrawAntiSunkenBorder(wxDC
& dc
, wxRect
*rect
);
188 // draw the frame with non-empty label inside the given rectText
189 virtual void DrawFrameWithLabel(wxDC
& dc
,
190 const wxString
& label
,
191 const wxRect
& rectFrame
,
192 const wxRect
& rectText
,
197 // draw the (static box) frame without the part corresponding to rectLabel
198 void DrawFrameWithoutLabel(wxDC
& dc
,
199 const wxRect
& rectFrame
,
200 const wxRect
& rectLabel
);
203 // common routine for drawing check and radio buttons
204 void DrawCheckOrRadioButton(wxDC
& dc
,
205 const wxString
& label
,
206 const wxBitmap
& bitmap
,
212 // return the check/radio bitmap for the given flags
213 virtual wxBitmap
GetRadioBitmap(int flags
) = 0;
214 virtual wxBitmap
GetCheckBitmap(int flags
) = 0;
217 // return the starting and ending positions, in pixels, of the thumb of a
218 // scrollbar with the given logical position, thumb size and range and the
219 // given physical length
220 static void GetScrollBarThumbSize(wxCoord length
,
227 // GDI objects we often use
233 // the colours we use, they never change currently so we don't have to ever
234 // update m_penXXX objects above
235 const wxColourScheme
* const m_scheme
;
237 DECLARE_NO_COPY_CLASS(wxStdRenderer
)
240 #endif // _WX_UNIV_STDREND_H_