Commit | Line | Data |
---|---|---|
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 | 16 | |
b5dbe15d | 17 | class WXDLLIMPEXP_FWD_CORE wxColourScheme; |
147b8a4a VZ |
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 | ||
6d789987 JS |
41 | virtual void DrawFocusRect(wxWindow* win, wxDC& dc, const wxRect& rect, int flags = 0); |
42 | ||
147b8a4a VZ |
43 | virtual void DrawLabel(wxDC& dc, |
44 | const wxString& label, | |
45 | const wxRect& rect, | |
46 | int flags = 0, | |
47 | int alignment = wxALIGN_LEFT | wxALIGN_TOP, | |
48 | int indexAccel = -1, | |
49 | wxRect *rectBounds = NULL); | |
50 | virtual void DrawButtonLabel(wxDC& dc, | |
51 | const wxString& label, | |
52 | const wxBitmap& image, | |
53 | const wxRect& rect, | |
54 | int flags = 0, | |
55 | int alignment = wxALIGN_LEFT | wxALIGN_TOP, | |
56 | int indexAccel = -1, | |
57 | wxRect *rectBounds = NULL); | |
58 | ||
59 | ||
60 | virtual void DrawBorder(wxDC& dc, | |
61 | wxBorder border, | |
62 | const wxRect& rect, | |
63 | int flags = 0, | |
64 | wxRect *rectIn = NULL); | |
65 | virtual void DrawTextBorder(wxDC& dc, | |
66 | wxBorder border, | |
67 | const wxRect& rect, | |
68 | int flags = 0, | |
69 | wxRect *rectIn = NULL); | |
70 | ||
71 | virtual void DrawHorizontalLine(wxDC& dc, | |
72 | wxCoord y, wxCoord x1, wxCoord x2); | |
73 | virtual void DrawVerticalLine(wxDC& dc, | |
74 | wxCoord x, wxCoord y1, wxCoord y2); | |
75 | virtual void DrawFrame(wxDC& dc, | |
76 | const wxString& label, | |
77 | const wxRect& rect, | |
78 | int flags = 0, | |
79 | int alignment = wxALIGN_LEFT, | |
80 | int indexAccel = -1); | |
81 | ||
82 | ||
83 | virtual void DrawItem(wxDC& dc, | |
84 | const wxString& label, | |
85 | const wxRect& rect, | |
86 | int flags = 0); | |
6229b92f VZ |
87 | virtual void DrawCheckItem(wxDC& dc, |
88 | const wxString& label, | |
89 | const wxBitmap& bitmap, | |
90 | const wxRect& rect, | |
91 | int flags = 0); | |
147b8a4a VZ |
92 | |
93 | virtual void DrawCheckButton(wxDC& dc, | |
94 | const wxString& label, | |
95 | const wxBitmap& bitmap, | |
96 | const wxRect& rect, | |
97 | int flags = 0, | |
98 | wxAlignment align = wxALIGN_LEFT, | |
99 | int indexAccel = -1); | |
100 | virtual void DrawRadioButton(wxDC& dc, | |
101 | const wxString& label, | |
102 | const wxBitmap& bitmap, | |
103 | const wxRect& rect, | |
104 | int flags = 0, | |
105 | wxAlignment align = wxALIGN_LEFT, | |
106 | int indexAccel = -1); | |
107 | ||
0428ac8c VZ |
108 | virtual void DrawScrollbarArrow(wxDC& dc, |
109 | wxDirection dir, | |
110 | const wxRect& rect, | |
111 | int flags = 0); | |
112 | virtual void DrawScrollCorner(wxDC& dc, | |
113 | const wxRect& rect); | |
114 | ||
147b8a4a VZ |
115 | #if wxUSE_TEXTCTRL |
116 | virtual void DrawTextLine(wxDC& dc, | |
117 | const wxString& text, | |
118 | const wxRect& rect, | |
119 | int selStart = -1, | |
120 | int selEnd = -1, | |
121 | int flags = 0); | |
122 | ||
123 | virtual void DrawLineWrapMark(wxDC& dc, const wxRect& rect); | |
6229b92f VZ |
124 | |
125 | virtual wxRect GetTextTotalArea(const wxTextCtrl *text, | |
126 | const wxRect& rect) const; | |
127 | virtual wxRect GetTextClientArea(const wxTextCtrl *text, | |
128 | const wxRect& rect, | |
129 | wxCoord *extraSpaceBeyond) const; | |
147b8a4a VZ |
130 | #endif // wxUSE_TEXTCTRL |
131 | ||
132 | virtual wxRect GetBorderDimensions(wxBorder border) const; | |
133 | ||
134 | virtual bool AreScrollbarsInsideBorder() const; | |
135 | ||
1cd9779f VZ |
136 | virtual void AdjustSize(wxSize *size, const wxWindow *window); |
137 | ||
138 | virtual wxCoord GetListboxItemHeight(wxCoord fontHeight); | |
139 | ||
1cd9779f VZ |
140 | #if wxUSE_STATUSBAR |
141 | virtual void DrawStatusField(wxDC& dc, | |
142 | const wxRect& rect, | |
143 | const wxString& label, | |
144 | int flags = 0, int style = 0); | |
145 | ||
283c797c VS |
146 | virtual wxSize GetStatusBarBorders() const; |
147 | ||
148 | virtual wxCoord GetStatusBarBorderBetweenFields() const; | |
149 | ||
150 | virtual wxSize GetStatusBarFieldMargins() const; | |
1cd9779f VZ |
151 | #endif // wxUSE_STATUSBAR |
152 | ||
153 | virtual wxCoord GetCheckItemMargin() const { return 0; } | |
154 | ||
249803fb VZ |
155 | |
156 | virtual void DrawFrameTitleBar(wxDC& dc, | |
157 | const wxRect& rect, | |
158 | const wxString& title, | |
159 | const wxIcon& icon, | |
160 | int flags, | |
161 | int specialButton = 0, | |
162 | int specialButtonFlag = 0); | |
163 | virtual void DrawFrameBorder(wxDC& dc, | |
164 | const wxRect& rect, | |
165 | int flags); | |
166 | virtual void DrawFrameBackground(wxDC& dc, | |
167 | const wxRect& rect, | |
168 | int flags); | |
169 | virtual void DrawFrameTitle(wxDC& dc, | |
170 | const wxRect& rect, | |
171 | const wxString& title, | |
172 | int flags); | |
173 | virtual void DrawFrameIcon(wxDC& dc, | |
174 | const wxRect& rect, | |
175 | const wxIcon& icon, | |
176 | int flags); | |
177 | virtual void DrawFrameButton(wxDC& dc, | |
178 | wxCoord x, wxCoord y, | |
179 | int button, | |
180 | int flags = 0); | |
181 | ||
182 | virtual wxRect GetFrameClientArea(const wxRect& rect, int flags) const; | |
183 | ||
184 | virtual wxSize GetFrameTotalSize(const wxSize& clientSize, int flags) const; | |
185 | ||
186 | virtual wxSize GetFrameMinSize(int flags) const; | |
187 | ||
188 | virtual wxSize GetFrameIconSize() const; | |
189 | ||
190 | virtual int HitTestFrame(const wxRect& rect, | |
191 | const wxPoint& pt, | |
192 | int flags = 0) const; | |
147b8a4a VZ |
193 | protected: |
194 | // various constants | |
0428ac8c VZ |
195 | enum ArrowDirection |
196 | { | |
197 | Arrow_Left, | |
198 | Arrow_Right, | |
199 | Arrow_Up, | |
200 | Arrow_Down, | |
201 | Arrow_Max | |
202 | }; | |
203 | ||
204 | enum ArrowStyle | |
205 | { | |
206 | Arrow_Normal, | |
207 | Arrow_Disabled, | |
208 | Arrow_Pressed, | |
209 | Arrow_Inverted, | |
210 | Arrow_InvertedDisabled, | |
211 | Arrow_StateMax | |
212 | }; | |
213 | ||
249803fb VZ |
214 | enum FrameButtonType |
215 | { | |
216 | FrameButton_Close, | |
217 | FrameButton_Minimize, | |
218 | FrameButton_Maximize, | |
219 | FrameButton_Restore, | |
220 | FrameButton_Help, | |
221 | FrameButton_Max | |
222 | }; | |
223 | ||
147b8a4a VZ |
224 | enum IndicatorType |
225 | { | |
226 | IndicatorType_Check, | |
227 | IndicatorType_Radio, | |
6229b92f VZ |
228 | IndicatorType_MaxCtrl, |
229 | IndicatorType_Menu = IndicatorType_MaxCtrl, | |
147b8a4a VZ |
230 | IndicatorType_Max |
231 | }; | |
232 | ||
233 | enum IndicatorState | |
234 | { | |
235 | IndicatorState_Normal, | |
236 | IndicatorState_Pressed, // this one is for check/radioboxes | |
237 | IndicatorState_Disabled, | |
238 | IndicatorState_MaxCtrl, | |
239 | ||
240 | // the rest of the states are valid for menu items only | |
241 | IndicatorState_Selected = IndicatorState_Pressed, | |
242 | IndicatorState_SelectedDisabled = IndicatorState_MaxCtrl, | |
243 | IndicatorState_MaxMenu | |
244 | }; | |
245 | ||
246 | enum IndicatorStatus | |
247 | { | |
248 | IndicatorStatus_Checked, | |
249 | IndicatorStatus_Unchecked, | |
250 | IndicatorStatus_Undetermined, | |
251 | IndicatorStatus_Max | |
252 | }; | |
253 | ||
254 | // translate the appropriate bits in flags to the above enum elements | |
255 | static void GetIndicatorsFromFlags(int flags, | |
256 | IndicatorState& state, | |
257 | IndicatorStatus& status); | |
258 | ||
0428ac8c VZ |
259 | // translate wxDirection to ArrowDirection |
260 | static ArrowDirection GetArrowDirection(wxDirection dir); | |
261 | ||
262 | ||
147b8a4a VZ |
263 | // fill the rectangle with a brush of given colour (must be valid) |
264 | void DrawSolidRect(wxDC& dc, const wxColour& col, const wxRect& rect); | |
265 | ||
266 | ||
267 | // all the functions in this section adjust the rect parameter to | |
268 | // correspond to the interiour of the drawn area | |
269 | ||
270 | // draw complete rectangle | |
271 | void DrawRect(wxDC& dc, wxRect *rect, const wxPen& pen); | |
272 | ||
273 | // draw the rectange using the first pen for the left and top sides | |
274 | // and the second one for the bottom and right ones | |
275 | void DrawShadedRect(wxDC& dc, wxRect *rect, | |
276 | const wxPen& pen1, const wxPen& pen2); | |
277 | ||
278 | // border drawing routines, may be overridden in the derived class | |
279 | virtual void DrawRaisedBorder(wxDC& dc, wxRect *rect); | |
280 | virtual void DrawSunkenBorder(wxDC& dc, wxRect *rect); | |
281 | virtual void DrawAntiSunkenBorder(wxDC& dc, wxRect *rect); | |
7419ba02 VZ |
282 | virtual void DrawBoxBorder(wxDC& dc, wxRect *rect); |
283 | virtual void DrawStaticBorder(wxDC& dc, wxRect *rect); | |
284 | virtual void DrawExtraBorder(wxDC& dc, wxRect *rect); | |
147b8a4a VZ |
285 | |
286 | ||
287 | // draw the frame with non-empty label inside the given rectText | |
288 | virtual void DrawFrameWithLabel(wxDC& dc, | |
289 | const wxString& label, | |
290 | const wxRect& rectFrame, | |
291 | const wxRect& rectText, | |
292 | int flags, | |
293 | int alignment, | |
294 | int indexAccel); | |
295 | ||
296 | // draw the (static box) frame without the part corresponding to rectLabel | |
297 | void DrawFrameWithoutLabel(wxDC& dc, | |
298 | const wxRect& rectFrame, | |
299 | const wxRect& rectLabel); | |
300 | ||
301 | ||
6229b92f VZ |
302 | // draw the bitmap for a check item (which is by default the same as check |
303 | // box one but may be different) | |
304 | virtual void DrawCheckItemBitmap(wxDC& dc, | |
305 | const wxBitmap& bitmap, | |
306 | const wxRect& rect, | |
307 | int flags); | |
308 | ||
147b8a4a VZ |
309 | // common routine for drawing check and radio buttons |
310 | void DrawCheckOrRadioButton(wxDC& dc, | |
311 | const wxString& label, | |
312 | const wxBitmap& bitmap, | |
313 | const wxRect& rect, | |
314 | int flags, | |
315 | wxAlignment align, | |
316 | int indexAccel); | |
317 | ||
318 | // return the check/radio bitmap for the given flags | |
319 | virtual wxBitmap GetRadioBitmap(int flags) = 0; | |
320 | virtual wxBitmap GetCheckBitmap(int flags) = 0; | |
321 | ||
249803fb VZ |
322 | // return the frame icon bitmap |
323 | virtual wxBitmap GetFrameButtonBitmap(FrameButtonType type) = 0; | |
324 | ||
d13b34d3 | 325 | // get the width of either normal or resizable frame border depending on |
b13862ee VZ |
326 | // whether flags contains wxTOPLEVEL_RESIZEABLE bit |
327 | // | |
328 | // notice that these methods only make sense with standard border drawing | |
329 | // code which uses the borders of the same width on all sides, this is why | |
330 | // they are only present here and not in wxRenderer itself | |
331 | virtual int GetFrameBorderWidth(int flags) const; | |
332 | ||
6229b92f VZ |
333 | #if wxUSE_TEXTCTRL |
334 | // return the width of the border around the text area in the text control | |
335 | virtual int GetTextBorderWidth(const wxTextCtrl *text) const; | |
336 | #endif // wxUSE_TEXTCTRL | |
147b8a4a | 337 | |
147b8a4a VZ |
338 | // GDI objects we often use |
339 | wxPen m_penBlack, | |
340 | m_penDarkGrey, | |
341 | m_penLightGrey, | |
342 | m_penHighlight; | |
343 | ||
249803fb VZ |
344 | wxFont m_titlebarFont; |
345 | ||
147b8a4a VZ |
346 | // the colours we use, they never change currently so we don't have to ever |
347 | // update m_penXXX objects above | |
348 | const wxColourScheme * const m_scheme; | |
349 | ||
c0c133e1 | 350 | wxDECLARE_NO_COPY_CLASS(wxStdRenderer); |
147b8a4a VZ |
351 | }; |
352 | ||
353 | #endif // _WX_UNIV_STDREND_H_ |