]>
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 VZ |
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); | |
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 | ||
107 | #if wxUSE_TEXTCTRL | |
108 | virtual void DrawTextLine(wxDC& dc, | |
109 | const wxString& text, | |
110 | const wxRect& rect, | |
111 | int selStart = -1, | |
112 | int selEnd = -1, | |
113 | int flags = 0); | |
114 | ||
115 | virtual void DrawLineWrapMark(wxDC& dc, const wxRect& rect); | |
6229b92f VZ |
116 | |
117 | virtual wxRect GetTextTotalArea(const wxTextCtrl *text, | |
118 | const wxRect& rect) const; | |
119 | virtual wxRect GetTextClientArea(const wxTextCtrl *text, | |
120 | const wxRect& rect, | |
121 | wxCoord *extraSpaceBeyond) const; | |
147b8a4a VZ |
122 | #endif // wxUSE_TEXTCTRL |
123 | ||
124 | virtual wxRect GetBorderDimensions(wxBorder border) const; | |
125 | ||
126 | virtual bool AreScrollbarsInsideBorder() const; | |
127 | ||
128 | #if wxUSE_SCROLLBAR | |
129 | virtual wxRect GetScrollbarRect(const wxScrollBar *scrollbar, | |
130 | wxScrollBar::Element elem, | |
131 | int thumbPos = -1) const; | |
132 | ||
133 | virtual wxCoord GetScrollbarSize(const wxScrollBar *scrollbar); | |
134 | ||
135 | virtual wxHitTest HitTestScrollbar(const wxScrollBar *scrollbar, | |
136 | const wxPoint& pt) const; | |
137 | ||
138 | virtual wxCoord ScrollbarToPixel(const wxScrollBar *scrollbar, | |
139 | int thumbPos = -1); | |
140 | virtual int PixelToScrollbar(const wxScrollBar *scrollbar, wxCoord coord); | |
141 | #endif // wxUSE_SCROLLBAR | |
142 | ||
143 | protected: | |
144 | // various constants | |
145 | enum IndicatorType | |
146 | { | |
147 | IndicatorType_Check, | |
148 | IndicatorType_Radio, | |
6229b92f VZ |
149 | IndicatorType_MaxCtrl, |
150 | IndicatorType_Menu = IndicatorType_MaxCtrl, | |
147b8a4a VZ |
151 | IndicatorType_Max |
152 | }; | |
153 | ||
154 | enum IndicatorState | |
155 | { | |
156 | IndicatorState_Normal, | |
157 | IndicatorState_Pressed, // this one is for check/radioboxes | |
158 | IndicatorState_Disabled, | |
159 | IndicatorState_MaxCtrl, | |
160 | ||
161 | // the rest of the states are valid for menu items only | |
162 | IndicatorState_Selected = IndicatorState_Pressed, | |
163 | IndicatorState_SelectedDisabled = IndicatorState_MaxCtrl, | |
164 | IndicatorState_MaxMenu | |
165 | }; | |
166 | ||
167 | enum IndicatorStatus | |
168 | { | |
169 | IndicatorStatus_Checked, | |
170 | IndicatorStatus_Unchecked, | |
171 | IndicatorStatus_Undetermined, | |
172 | IndicatorStatus_Max | |
173 | }; | |
174 | ||
175 | // translate the appropriate bits in flags to the above enum elements | |
176 | static void GetIndicatorsFromFlags(int flags, | |
177 | IndicatorState& state, | |
178 | IndicatorStatus& status); | |
179 | ||
180 | // fill the rectangle with a brush of given colour (must be valid) | |
181 | void DrawSolidRect(wxDC& dc, const wxColour& col, const wxRect& rect); | |
182 | ||
183 | ||
184 | // all the functions in this section adjust the rect parameter to | |
185 | // correspond to the interiour of the drawn area | |
186 | ||
187 | // draw complete rectangle | |
188 | void DrawRect(wxDC& dc, wxRect *rect, const wxPen& pen); | |
189 | ||
190 | // draw the rectange using the first pen for the left and top sides | |
191 | // and the second one for the bottom and right ones | |
192 | void DrawShadedRect(wxDC& dc, wxRect *rect, | |
193 | const wxPen& pen1, const wxPen& pen2); | |
194 | ||
195 | // border drawing routines, may be overridden in the derived class | |
196 | virtual void DrawRaisedBorder(wxDC& dc, wxRect *rect); | |
197 | virtual void DrawSunkenBorder(wxDC& dc, wxRect *rect); | |
198 | virtual void DrawAntiSunkenBorder(wxDC& dc, wxRect *rect); | |
6229b92f | 199 | virtual void DrawFrameBorder(wxDC& dc, wxRect *rect); |
147b8a4a VZ |
200 | |
201 | ||
202 | // draw the frame with non-empty label inside the given rectText | |
203 | virtual void DrawFrameWithLabel(wxDC& dc, | |
204 | const wxString& label, | |
205 | const wxRect& rectFrame, | |
206 | const wxRect& rectText, | |
207 | int flags, | |
208 | int alignment, | |
209 | int indexAccel); | |
210 | ||
211 | // draw the (static box) frame without the part corresponding to rectLabel | |
212 | void DrawFrameWithoutLabel(wxDC& dc, | |
213 | const wxRect& rectFrame, | |
214 | const wxRect& rectLabel); | |
215 | ||
216 | ||
6229b92f VZ |
217 | // draw the bitmap for a check item (which is by default the same as check |
218 | // box one but may be different) | |
219 | virtual void DrawCheckItemBitmap(wxDC& dc, | |
220 | const wxBitmap& bitmap, | |
221 | const wxRect& rect, | |
222 | int flags); | |
223 | ||
147b8a4a VZ |
224 | // common routine for drawing check and radio buttons |
225 | void DrawCheckOrRadioButton(wxDC& dc, | |
226 | const wxString& label, | |
227 | const wxBitmap& bitmap, | |
228 | const wxRect& rect, | |
229 | int flags, | |
230 | wxAlignment align, | |
231 | int indexAccel); | |
232 | ||
233 | // return the check/radio bitmap for the given flags | |
234 | virtual wxBitmap GetRadioBitmap(int flags) = 0; | |
235 | virtual wxBitmap GetCheckBitmap(int flags) = 0; | |
236 | ||
6229b92f VZ |
237 | #if wxUSE_TEXTCTRL |
238 | // return the width of the border around the text area in the text control | |
239 | virtual int GetTextBorderWidth(const wxTextCtrl *text) const; | |
240 | #endif // wxUSE_TEXTCTRL | |
147b8a4a VZ |
241 | |
242 | // return the starting and ending positions, in pixels, of the thumb of a | |
243 | // scrollbar with the given logical position, thumb size and range and the | |
244 | // given physical length | |
245 | static void GetScrollBarThumbSize(wxCoord length, | |
246 | int thumbPos, | |
247 | int thumbSize, | |
248 | int range, | |
249 | wxCoord *thumbStart, | |
250 | wxCoord *thumbEnd); | |
251 | ||
252 | // GDI objects we often use | |
253 | wxPen m_penBlack, | |
254 | m_penDarkGrey, | |
255 | m_penLightGrey, | |
256 | m_penHighlight; | |
257 | ||
258 | // the colours we use, they never change currently so we don't have to ever | |
259 | // update m_penXXX objects above | |
260 | const wxColourScheme * const m_scheme; | |
261 | ||
262 | DECLARE_NO_COPY_CLASS(wxStdRenderer) | |
263 | }; | |
264 | ||
265 | #endif // _WX_UNIV_STDREND_H_ |