]> git.saurik.com Git - wxWidgets.git/blob - include/wx/univ/stdrend.h
moved Arrow_ constants to the base class
[wxWidgets.git] / include / wx / univ / stdrend.h
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"
15 #include "wx/pen.h"
16
17 class WXDLLEXPORT wxColourScheme;
18
19 // ----------------------------------------------------------------------------
20 // wxStdRenderer: implements as much of wxRenderer API as possible generically
21 // ----------------------------------------------------------------------------
22
23 class wxStdRenderer : public wxRenderer
24 {
25 public:
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);
86 virtual void DrawCheckItem(wxDC& dc,
87 const wxString& label,
88 const wxBitmap& bitmap,
89 const wxRect& rect,
90 int flags = 0);
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
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
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);
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;
129 #endif // wxUSE_TEXTCTRL
130
131 virtual wxRect GetBorderDimensions(wxBorder border) const;
132
133 virtual bool AreScrollbarsInsideBorder() const;
134
135 #if wxUSE_SCROLLBAR
136 virtual wxRect GetScrollbarRect(const wxScrollBar *scrollbar,
137 wxScrollBar::Element elem,
138 int thumbPos = -1) const;
139
140 virtual wxCoord GetScrollbarSize(const wxScrollBar *scrollbar);
141
142 virtual wxHitTest HitTestScrollbar(const wxScrollBar *scrollbar,
143 const wxPoint& pt) const;
144
145 virtual wxCoord ScrollbarToPixel(const wxScrollBar *scrollbar,
146 int thumbPos = -1);
147 virtual int PixelToScrollbar(const wxScrollBar *scrollbar, wxCoord coord);
148 #endif // wxUSE_SCROLLBAR
149
150 protected:
151 // various constants
152 enum ArrowDirection
153 {
154 Arrow_Left,
155 Arrow_Right,
156 Arrow_Up,
157 Arrow_Down,
158 Arrow_Max
159 };
160
161 enum ArrowStyle
162 {
163 Arrow_Normal,
164 Arrow_Disabled,
165 Arrow_Pressed,
166 Arrow_Inverted,
167 Arrow_InvertedDisabled,
168 Arrow_StateMax
169 };
170
171 enum IndicatorType
172 {
173 IndicatorType_Check,
174 IndicatorType_Radio,
175 IndicatorType_MaxCtrl,
176 IndicatorType_Menu = IndicatorType_MaxCtrl,
177 IndicatorType_Max
178 };
179
180 enum IndicatorState
181 {
182 IndicatorState_Normal,
183 IndicatorState_Pressed, // this one is for check/radioboxes
184 IndicatorState_Disabled,
185 IndicatorState_MaxCtrl,
186
187 // the rest of the states are valid for menu items only
188 IndicatorState_Selected = IndicatorState_Pressed,
189 IndicatorState_SelectedDisabled = IndicatorState_MaxCtrl,
190 IndicatorState_MaxMenu
191 };
192
193 enum IndicatorStatus
194 {
195 IndicatorStatus_Checked,
196 IndicatorStatus_Unchecked,
197 IndicatorStatus_Undetermined,
198 IndicatorStatus_Max
199 };
200
201 // translate the appropriate bits in flags to the above enum elements
202 static void GetIndicatorsFromFlags(int flags,
203 IndicatorState& state,
204 IndicatorStatus& status);
205
206 // translate wxDirection to ArrowDirection
207 static ArrowDirection GetArrowDirection(wxDirection dir);
208
209
210 // fill the rectangle with a brush of given colour (must be valid)
211 void DrawSolidRect(wxDC& dc, const wxColour& col, const wxRect& rect);
212
213
214 // all the functions in this section adjust the rect parameter to
215 // correspond to the interiour of the drawn area
216
217 // draw complete rectangle
218 void DrawRect(wxDC& dc, wxRect *rect, const wxPen& pen);
219
220 // draw the rectange using the first pen for the left and top sides
221 // and the second one for the bottom and right ones
222 void DrawShadedRect(wxDC& dc, wxRect *rect,
223 const wxPen& pen1, const wxPen& pen2);
224
225 // border drawing routines, may be overridden in the derived class
226 virtual void DrawRaisedBorder(wxDC& dc, wxRect *rect);
227 virtual void DrawSunkenBorder(wxDC& dc, wxRect *rect);
228 virtual void DrawAntiSunkenBorder(wxDC& dc, wxRect *rect);
229 virtual void DrawFrameBorder(wxDC& dc, wxRect *rect);
230
231
232 // draw the frame with non-empty label inside the given rectText
233 virtual void DrawFrameWithLabel(wxDC& dc,
234 const wxString& label,
235 const wxRect& rectFrame,
236 const wxRect& rectText,
237 int flags,
238 int alignment,
239 int indexAccel);
240
241 // draw the (static box) frame without the part corresponding to rectLabel
242 void DrawFrameWithoutLabel(wxDC& dc,
243 const wxRect& rectFrame,
244 const wxRect& rectLabel);
245
246
247 // draw the bitmap for a check item (which is by default the same as check
248 // box one but may be different)
249 virtual void DrawCheckItemBitmap(wxDC& dc,
250 const wxBitmap& bitmap,
251 const wxRect& rect,
252 int flags);
253
254 // common routine for drawing check and radio buttons
255 void DrawCheckOrRadioButton(wxDC& dc,
256 const wxString& label,
257 const wxBitmap& bitmap,
258 const wxRect& rect,
259 int flags,
260 wxAlignment align,
261 int indexAccel);
262
263 // return the check/radio bitmap for the given flags
264 virtual wxBitmap GetRadioBitmap(int flags) = 0;
265 virtual wxBitmap GetCheckBitmap(int flags) = 0;
266
267 #if wxUSE_TEXTCTRL
268 // return the width of the border around the text area in the text control
269 virtual int GetTextBorderWidth(const wxTextCtrl *text) const;
270 #endif // wxUSE_TEXTCTRL
271
272 // return the starting and ending positions, in pixels, of the thumb of a
273 // scrollbar with the given logical position, thumb size and range and the
274 // given physical length
275 static void GetScrollBarThumbSize(wxCoord length,
276 int thumbPos,
277 int thumbSize,
278 int range,
279 wxCoord *thumbStart,
280 wxCoord *thumbEnd);
281
282 // GDI objects we often use
283 wxPen m_penBlack,
284 m_penDarkGrey,
285 m_penLightGrey,
286 m_penHighlight;
287
288 // the colours we use, they never change currently so we don't have to ever
289 // update m_penXXX objects above
290 const wxColourScheme * const m_scheme;
291
292 DECLARE_NO_COPY_CLASS(wxStdRenderer)
293 };
294
295 #endif // _WX_UNIV_STDREND_H_