]> git.saurik.com Git - wxWidgets.git/blame - include/wx/univ/stdrend.h
Warning fixes after char->wxChar in wxVariant.
[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
b19d4eb9 41 virtual void DrawFocusRect(wxDC& dc, const wxRect& rect, int flags = 0);
147b8a4a
VZ
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
283c797c
VS
160 virtual wxSize GetStatusBarBorders() const;
161
162 virtual wxCoord GetStatusBarBorderBetweenFields() const;
163
164 virtual wxSize GetStatusBarFieldMargins() const;
1cd9779f
VZ
165#endif // wxUSE_STATUSBAR
166
167 virtual wxCoord GetCheckItemMargin() const { return 0; }
168
249803fb
VZ
169
170 virtual void DrawFrameTitleBar(wxDC& dc,
171 const wxRect& rect,
172 const wxString& title,
173 const wxIcon& icon,
174 int flags,
175 int specialButton = 0,
176 int specialButtonFlag = 0);
177 virtual void DrawFrameBorder(wxDC& dc,
178 const wxRect& rect,
179 int flags);
180 virtual void DrawFrameBackground(wxDC& dc,
181 const wxRect& rect,
182 int flags);
183 virtual void DrawFrameTitle(wxDC& dc,
184 const wxRect& rect,
185 const wxString& title,
186 int flags);
187 virtual void DrawFrameIcon(wxDC& dc,
188 const wxRect& rect,
189 const wxIcon& icon,
190 int flags);
191 virtual void DrawFrameButton(wxDC& dc,
192 wxCoord x, wxCoord y,
193 int button,
194 int flags = 0);
195
196 virtual wxRect GetFrameClientArea(const wxRect& rect, int flags) const;
197
198 virtual wxSize GetFrameTotalSize(const wxSize& clientSize, int flags) const;
199
200 virtual wxSize GetFrameMinSize(int flags) const;
201
202 virtual wxSize GetFrameIconSize() const;
203
204 virtual int HitTestFrame(const wxRect& rect,
205 const wxPoint& pt,
206 int flags = 0) const;
147b8a4a
VZ
207protected:
208 // various constants
0428ac8c
VZ
209 enum ArrowDirection
210 {
211 Arrow_Left,
212 Arrow_Right,
213 Arrow_Up,
214 Arrow_Down,
215 Arrow_Max
216 };
217
218 enum ArrowStyle
219 {
220 Arrow_Normal,
221 Arrow_Disabled,
222 Arrow_Pressed,
223 Arrow_Inverted,
224 Arrow_InvertedDisabled,
225 Arrow_StateMax
226 };
227
249803fb
VZ
228 enum FrameButtonType
229 {
230 FrameButton_Close,
231 FrameButton_Minimize,
232 FrameButton_Maximize,
233 FrameButton_Restore,
234 FrameButton_Help,
235 FrameButton_Max
236 };
237
147b8a4a
VZ
238 enum IndicatorType
239 {
240 IndicatorType_Check,
241 IndicatorType_Radio,
6229b92f
VZ
242 IndicatorType_MaxCtrl,
243 IndicatorType_Menu = IndicatorType_MaxCtrl,
147b8a4a
VZ
244 IndicatorType_Max
245 };
246
247 enum IndicatorState
248 {
249 IndicatorState_Normal,
250 IndicatorState_Pressed, // this one is for check/radioboxes
251 IndicatorState_Disabled,
252 IndicatorState_MaxCtrl,
253
254 // the rest of the states are valid for menu items only
255 IndicatorState_Selected = IndicatorState_Pressed,
256 IndicatorState_SelectedDisabled = IndicatorState_MaxCtrl,
257 IndicatorState_MaxMenu
258 };
259
260 enum IndicatorStatus
261 {
262 IndicatorStatus_Checked,
263 IndicatorStatus_Unchecked,
264 IndicatorStatus_Undetermined,
265 IndicatorStatus_Max
266 };
267
268 // translate the appropriate bits in flags to the above enum elements
269 static void GetIndicatorsFromFlags(int flags,
270 IndicatorState& state,
271 IndicatorStatus& status);
272
0428ac8c
VZ
273 // translate wxDirection to ArrowDirection
274 static ArrowDirection GetArrowDirection(wxDirection dir);
275
276
147b8a4a
VZ
277 // fill the rectangle with a brush of given colour (must be valid)
278 void DrawSolidRect(wxDC& dc, const wxColour& col, const wxRect& rect);
279
280
281 // all the functions in this section adjust the rect parameter to
282 // correspond to the interiour of the drawn area
283
284 // draw complete rectangle
285 void DrawRect(wxDC& dc, wxRect *rect, const wxPen& pen);
286
287 // draw the rectange using the first pen for the left and top sides
288 // and the second one for the bottom and right ones
289 void DrawShadedRect(wxDC& dc, wxRect *rect,
290 const wxPen& pen1, const wxPen& pen2);
291
292 // border drawing routines, may be overridden in the derived class
293 virtual void DrawRaisedBorder(wxDC& dc, wxRect *rect);
294 virtual void DrawSunkenBorder(wxDC& dc, wxRect *rect);
295 virtual void DrawAntiSunkenBorder(wxDC& dc, wxRect *rect);
7419ba02
VZ
296 virtual void DrawBoxBorder(wxDC& dc, wxRect *rect);
297 virtual void DrawStaticBorder(wxDC& dc, wxRect *rect);
298 virtual void DrawExtraBorder(wxDC& dc, wxRect *rect);
147b8a4a
VZ
299
300
301 // draw the frame with non-empty label inside the given rectText
302 virtual void DrawFrameWithLabel(wxDC& dc,
303 const wxString& label,
304 const wxRect& rectFrame,
305 const wxRect& rectText,
306 int flags,
307 int alignment,
308 int indexAccel);
309
310 // draw the (static box) frame without the part corresponding to rectLabel
311 void DrawFrameWithoutLabel(wxDC& dc,
312 const wxRect& rectFrame,
313 const wxRect& rectLabel);
314
315
6229b92f
VZ
316 // draw the bitmap for a check item (which is by default the same as check
317 // box one but may be different)
318 virtual void DrawCheckItemBitmap(wxDC& dc,
319 const wxBitmap& bitmap,
320 const wxRect& rect,
321 int flags);
322
147b8a4a
VZ
323 // common routine for drawing check and radio buttons
324 void DrawCheckOrRadioButton(wxDC& dc,
325 const wxString& label,
326 const wxBitmap& bitmap,
327 const wxRect& rect,
328 int flags,
329 wxAlignment align,
330 int indexAccel);
331
332 // return the check/radio bitmap for the given flags
333 virtual wxBitmap GetRadioBitmap(int flags) = 0;
334 virtual wxBitmap GetCheckBitmap(int flags) = 0;
335
249803fb
VZ
336 // return the frame icon bitmap
337 virtual wxBitmap GetFrameButtonBitmap(FrameButtonType type) = 0;
338
b13862ee
VZ
339 // get the width of either normal or resizeable frame border depending on
340 // whether flags contains wxTOPLEVEL_RESIZEABLE bit
341 //
342 // notice that these methods only make sense with standard border drawing
343 // code which uses the borders of the same width on all sides, this is why
344 // they are only present here and not in wxRenderer itself
345 virtual int GetFrameBorderWidth(int flags) const;
346
6229b92f
VZ
347#if wxUSE_TEXTCTRL
348 // return the width of the border around the text area in the text control
349 virtual int GetTextBorderWidth(const wxTextCtrl *text) const;
350#endif // wxUSE_TEXTCTRL
147b8a4a
VZ
351
352 // return the starting and ending positions, in pixels, of the thumb of a
353 // scrollbar with the given logical position, thumb size and range and the
354 // given physical length
355 static void GetScrollBarThumbSize(wxCoord length,
356 int thumbPos,
357 int thumbSize,
358 int range,
359 wxCoord *thumbStart,
360 wxCoord *thumbEnd);
361
362 // GDI objects we often use
363 wxPen m_penBlack,
364 m_penDarkGrey,
365 m_penLightGrey,
366 m_penHighlight;
367
249803fb
VZ
368 wxFont m_titlebarFont;
369
147b8a4a
VZ
370 // the colours we use, they never change currently so we don't have to ever
371 // update m_penXXX objects above
372 const wxColourScheme * const m_scheme;
373
374 DECLARE_NO_COPY_CLASS(wxStdRenderer)
375};
376
377#endif // _WX_UNIV_STDREND_H_