]> git.saurik.com Git - wxWidgets.git/blame - include/wx/univ/stdrend.h
fix infinite recursion in DrawStatusField() after latest changes
[wxWidgets.git] / include / wx / univ / stdrend.h
CommitLineData
147b8a4a
VZ
1///////////////////////////////////////////////////////////////////////////////
2// Name: wx/univ/stdrend.h
3// Purpose: wxStdRenderer class declaration
4// Author: Vadim Zeitlin
5// Created: 2006-09-18
6// RCS-ID: $Id$
7// Copyright: (c) 2006 Vadim Zeitlin <vadim@wxwindows.org>
8// Licence: wxWindows licence
9///////////////////////////////////////////////////////////////////////////////
10
11#ifndef _WX_UNIV_STDREND_H_
12#define _WX_UNIV_STDREND_H_
13
14#include "wx/univ/renderer.h"
762ad185 15#include "wx/pen.h"
147b8a4a
VZ
16
17class WXDLLEXPORT wxColourScheme;
18
19// ----------------------------------------------------------------------------
20// wxStdRenderer: implements as much of wxRenderer API as possible generically
21// ----------------------------------------------------------------------------
22
23class wxStdRenderer : public wxRenderer
24{
25public:
26 // the renderer will use the given scheme, whose lifetime must be at least
27 // as long as of this object itself, to choose the colours for drawing
28 wxStdRenderer(const wxColourScheme *scheme);
29
30 virtual void DrawBackground(wxDC& dc,
31 const wxColour& col,
32 const wxRect& rect,
33 int flags = 0,
34 wxWindow *window = NULL);
35 virtual void DrawButtonSurface(wxDC& dc,
36 const wxColour& col,
37 const wxRect& rect,
38 int flags);
39
40
41 virtual void DrawFocusRect(wxDC& dc, const wxRect& rect);
42 virtual void DrawLabel(wxDC& dc,
43 const wxString& label,
44 const wxRect& rect,
45 int flags = 0,
46 int alignment = wxALIGN_LEFT | wxALIGN_TOP,
47 int indexAccel = -1,
48 wxRect *rectBounds = NULL);
49 virtual void DrawButtonLabel(wxDC& dc,
50 const wxString& label,
51 const wxBitmap& image,
52 const wxRect& rect,
53 int flags = 0,
54 int alignment = wxALIGN_LEFT | wxALIGN_TOP,
55 int indexAccel = -1,
56 wxRect *rectBounds = NULL);
57
58
59 virtual void DrawBorder(wxDC& dc,
60 wxBorder border,
61 const wxRect& rect,
62 int flags = 0,
63 wxRect *rectIn = NULL);
64 virtual void DrawTextBorder(wxDC& dc,
65 wxBorder border,
66 const wxRect& rect,
67 int flags = 0,
68 wxRect *rectIn = NULL);
69
70 virtual void DrawHorizontalLine(wxDC& dc,
71 wxCoord y, wxCoord x1, wxCoord x2);
72 virtual void DrawVerticalLine(wxDC& dc,
73 wxCoord x, wxCoord y1, wxCoord y2);
74 virtual void DrawFrame(wxDC& dc,
75 const wxString& label,
76 const wxRect& rect,
77 int flags = 0,
78 int alignment = wxALIGN_LEFT,
79 int indexAccel = -1);
80
81
82 virtual void DrawItem(wxDC& dc,
83 const wxString& label,
84 const wxRect& rect,
85 int flags = 0);
6229b92f
VZ
86 virtual void DrawCheckItem(wxDC& dc,
87 const wxString& label,
88 const wxBitmap& bitmap,
89 const wxRect& rect,
90 int flags = 0);
147b8a4a
VZ
91
92 virtual void DrawCheckButton(wxDC& dc,
93 const wxString& label,
94 const wxBitmap& bitmap,
95 const wxRect& rect,
96 int flags = 0,
97 wxAlignment align = wxALIGN_LEFT,
98 int indexAccel = -1);
99 virtual void DrawRadioButton(wxDC& dc,
100 const wxString& label,
101 const wxBitmap& bitmap,
102 const wxRect& rect,
103 int flags = 0,
104 wxAlignment align = wxALIGN_LEFT,
105 int indexAccel = -1);
106
0428ac8c
VZ
107 virtual void DrawScrollbarArrow(wxDC& dc,
108 wxDirection dir,
109 const wxRect& rect,
110 int flags = 0);
111 virtual void DrawScrollCorner(wxDC& dc,
112 const wxRect& rect);
113
147b8a4a
VZ
114#if wxUSE_TEXTCTRL
115 virtual void DrawTextLine(wxDC& dc,
116 const wxString& text,
117 const wxRect& rect,
118 int selStart = -1,
119 int selEnd = -1,
120 int flags = 0);
121
122 virtual void DrawLineWrapMark(wxDC& dc, const wxRect& rect);
6229b92f
VZ
123
124 virtual wxRect GetTextTotalArea(const wxTextCtrl *text,
125 const wxRect& rect) const;
126 virtual wxRect GetTextClientArea(const wxTextCtrl *text,
127 const wxRect& rect,
128 wxCoord *extraSpaceBeyond) const;
147b8a4a
VZ
129#endif // wxUSE_TEXTCTRL
130
131 virtual wxRect GetBorderDimensions(wxBorder border) const;
132
133 virtual bool AreScrollbarsInsideBorder() const;
134
1cd9779f
VZ
135 virtual void AdjustSize(wxSize *size, const wxWindow *window);
136
137 virtual wxCoord GetListboxItemHeight(wxCoord fontHeight);
138
147b8a4a
VZ
139#if wxUSE_SCROLLBAR
140 virtual wxRect GetScrollbarRect(const wxScrollBar *scrollbar,
141 wxScrollBar::Element elem,
142 int thumbPos = -1) const;
143
144 virtual wxCoord GetScrollbarSize(const wxScrollBar *scrollbar);
145
146 virtual wxHitTest HitTestScrollbar(const wxScrollBar *scrollbar,
147 const wxPoint& pt) const;
148
149 virtual wxCoord ScrollbarToPixel(const wxScrollBar *scrollbar,
150 int thumbPos = -1);
151 virtual int PixelToScrollbar(const wxScrollBar *scrollbar, wxCoord coord);
152#endif // wxUSE_SCROLLBAR
153
1cd9779f
VZ
154#if wxUSE_STATUSBAR
155 virtual void DrawStatusField(wxDC& dc,
156 const wxRect& rect,
157 const wxString& label,
158 int flags = 0, int style = 0);
159
160 virtual wxSize GetStatusBarBorders(wxCoord *borderBetweenFields) const;
161#endif // wxUSE_STATUSBAR
162
163 virtual wxCoord GetCheckItemMargin() const { return 0; }
164
147b8a4a
VZ
165protected:
166 // various constants
0428ac8c
VZ
167 enum ArrowDirection
168 {
169 Arrow_Left,
170 Arrow_Right,
171 Arrow_Up,
172 Arrow_Down,
173 Arrow_Max
174 };
175
176 enum ArrowStyle
177 {
178 Arrow_Normal,
179 Arrow_Disabled,
180 Arrow_Pressed,
181 Arrow_Inverted,
182 Arrow_InvertedDisabled,
183 Arrow_StateMax
184 };
185
147b8a4a
VZ
186 enum IndicatorType
187 {
188 IndicatorType_Check,
189 IndicatorType_Radio,
6229b92f
VZ
190 IndicatorType_MaxCtrl,
191 IndicatorType_Menu = IndicatorType_MaxCtrl,
147b8a4a
VZ
192 IndicatorType_Max
193 };
194
195 enum IndicatorState
196 {
197 IndicatorState_Normal,
198 IndicatorState_Pressed, // this one is for check/radioboxes
199 IndicatorState_Disabled,
200 IndicatorState_MaxCtrl,
201
202 // the rest of the states are valid for menu items only
203 IndicatorState_Selected = IndicatorState_Pressed,
204 IndicatorState_SelectedDisabled = IndicatorState_MaxCtrl,
205 IndicatorState_MaxMenu
206 };
207
208 enum IndicatorStatus
209 {
210 IndicatorStatus_Checked,
211 IndicatorStatus_Unchecked,
212 IndicatorStatus_Undetermined,
213 IndicatorStatus_Max
214 };
215
216 // translate the appropriate bits in flags to the above enum elements
217 static void GetIndicatorsFromFlags(int flags,
218 IndicatorState& state,
219 IndicatorStatus& status);
220
0428ac8c
VZ
221 // translate wxDirection to ArrowDirection
222 static ArrowDirection GetArrowDirection(wxDirection dir);
223
224
147b8a4a
VZ
225 // fill the rectangle with a brush of given colour (must be valid)
226 void DrawSolidRect(wxDC& dc, const wxColour& col, const wxRect& rect);
227
228
229 // all the functions in this section adjust the rect parameter to
230 // correspond to the interiour of the drawn area
231
232 // draw complete rectangle
233 void DrawRect(wxDC& dc, wxRect *rect, const wxPen& pen);
234
235 // draw the rectange using the first pen for the left and top sides
236 // and the second one for the bottom and right ones
237 void DrawShadedRect(wxDC& dc, wxRect *rect,
238 const wxPen& pen1, const wxPen& pen2);
239
240 // border drawing routines, may be overridden in the derived class
241 virtual void DrawRaisedBorder(wxDC& dc, wxRect *rect);
242 virtual void DrawSunkenBorder(wxDC& dc, wxRect *rect);
243 virtual void DrawAntiSunkenBorder(wxDC& dc, wxRect *rect);
6229b92f 244 virtual void DrawFrameBorder(wxDC& dc, wxRect *rect);
147b8a4a
VZ
245
246
247 // draw the frame with non-empty label inside the given rectText
248 virtual void DrawFrameWithLabel(wxDC& dc,
249 const wxString& label,
250 const wxRect& rectFrame,
251 const wxRect& rectText,
252 int flags,
253 int alignment,
254 int indexAccel);
255
256 // draw the (static box) frame without the part corresponding to rectLabel
257 void DrawFrameWithoutLabel(wxDC& dc,
258 const wxRect& rectFrame,
259 const wxRect& rectLabel);
260
261
6229b92f
VZ
262 // draw the bitmap for a check item (which is by default the same as check
263 // box one but may be different)
264 virtual void DrawCheckItemBitmap(wxDC& dc,
265 const wxBitmap& bitmap,
266 const wxRect& rect,
267 int flags);
268
147b8a4a
VZ
269 // common routine for drawing check and radio buttons
270 void DrawCheckOrRadioButton(wxDC& dc,
271 const wxString& label,
272 const wxBitmap& bitmap,
273 const wxRect& rect,
274 int flags,
275 wxAlignment align,
276 int indexAccel);
277
278 // return the check/radio bitmap for the given flags
279 virtual wxBitmap GetRadioBitmap(int flags) = 0;
280 virtual wxBitmap GetCheckBitmap(int flags) = 0;
281
6229b92f
VZ
282#if wxUSE_TEXTCTRL
283 // return the width of the border around the text area in the text control
284 virtual int GetTextBorderWidth(const wxTextCtrl *text) const;
285#endif // wxUSE_TEXTCTRL
147b8a4a
VZ
286
287 // return the starting and ending positions, in pixels, of the thumb of a
288 // scrollbar with the given logical position, thumb size and range and the
289 // given physical length
290 static void GetScrollBarThumbSize(wxCoord length,
291 int thumbPos,
292 int thumbSize,
293 int range,
294 wxCoord *thumbStart,
295 wxCoord *thumbEnd);
296
297 // GDI objects we often use
298 wxPen m_penBlack,
299 m_penDarkGrey,
300 m_penLightGrey,
301 m_penHighlight;
302
303 // the colours we use, they never change currently so we don't have to ever
304 // update m_penXXX objects above
305 const wxColourScheme * const m_scheme;
306
307 DECLARE_NO_COPY_CLASS(wxStdRenderer)
308};
309
310#endif // _WX_UNIV_STDREND_H_