]> git.saurik.com Git - wxWidgets.git/blob - include/wx/univ/stdrend.h
fixes to wxWindowDC flipping+clipping when painting on hidden windows or windows...
[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
16 class WXDLLEXPORT wxColourScheme;
17
18 // ----------------------------------------------------------------------------
19 // wxStdRenderer: implements as much of wxRenderer API as possible generically
20 // ----------------------------------------------------------------------------
21
22 class wxStdRenderer : public wxRenderer
23 {
24 public:
25 // the renderer will use the given scheme, whose lifetime must be at least
26 // as long as of this object itself, to choose the colours for drawing
27 wxStdRenderer(const wxColourScheme *scheme);
28
29 virtual void DrawBackground(wxDC& dc,
30 const wxColour& col,
31 const wxRect& rect,
32 int flags = 0,
33 wxWindow *window = NULL);
34 virtual void DrawButtonSurface(wxDC& dc,
35 const wxColour& col,
36 const wxRect& rect,
37 int flags);
38
39
40 virtual void DrawFocusRect(wxDC& dc, const wxRect& rect);
41 virtual void DrawLabel(wxDC& dc,
42 const wxString& label,
43 const wxRect& rect,
44 int flags = 0,
45 int alignment = wxALIGN_LEFT | wxALIGN_TOP,
46 int indexAccel = -1,
47 wxRect *rectBounds = NULL);
48 virtual void DrawButtonLabel(wxDC& dc,
49 const wxString& label,
50 const wxBitmap& image,
51 const wxRect& rect,
52 int flags = 0,
53 int alignment = wxALIGN_LEFT | wxALIGN_TOP,
54 int indexAccel = -1,
55 wxRect *rectBounds = NULL);
56
57
58 virtual void DrawBorder(wxDC& dc,
59 wxBorder border,
60 const wxRect& rect,
61 int flags = 0,
62 wxRect *rectIn = NULL);
63 virtual void DrawTextBorder(wxDC& dc,
64 wxBorder border,
65 const wxRect& rect,
66 int flags = 0,
67 wxRect *rectIn = NULL);
68
69 virtual void DrawHorizontalLine(wxDC& dc,
70 wxCoord y, wxCoord x1, wxCoord x2);
71 virtual void DrawVerticalLine(wxDC& dc,
72 wxCoord x, wxCoord y1, wxCoord y2);
73 virtual void DrawFrame(wxDC& dc,
74 const wxString& label,
75 const wxRect& rect,
76 int flags = 0,
77 int alignment = wxALIGN_LEFT,
78 int indexAccel = -1);
79
80
81 virtual void DrawItem(wxDC& dc,
82 const wxString& label,
83 const wxRect& rect,
84 int flags = 0);
85
86 virtual void DrawCheckButton(wxDC& dc,
87 const wxString& label,
88 const wxBitmap& bitmap,
89 const wxRect& rect,
90 int flags = 0,
91 wxAlignment align = wxALIGN_LEFT,
92 int indexAccel = -1);
93 virtual void DrawRadioButton(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
101 #if wxUSE_TEXTCTRL
102 virtual void DrawTextLine(wxDC& dc,
103 const wxString& text,
104 const wxRect& rect,
105 int selStart = -1,
106 int selEnd = -1,
107 int flags = 0);
108
109 virtual void DrawLineWrapMark(wxDC& dc, const wxRect& rect);
110 #endif // wxUSE_TEXTCTRL
111
112 virtual wxRect GetBorderDimensions(wxBorder border) const;
113
114 virtual bool AreScrollbarsInsideBorder() const;
115
116 #if wxUSE_SCROLLBAR
117 virtual wxRect GetScrollbarRect(const wxScrollBar *scrollbar,
118 wxScrollBar::Element elem,
119 int thumbPos = -1) const;
120
121 virtual wxCoord GetScrollbarSize(const wxScrollBar *scrollbar);
122
123 virtual wxHitTest HitTestScrollbar(const wxScrollBar *scrollbar,
124 const wxPoint& pt) const;
125
126 virtual wxCoord ScrollbarToPixel(const wxScrollBar *scrollbar,
127 int thumbPos = -1);
128 virtual int PixelToScrollbar(const wxScrollBar *scrollbar, wxCoord coord);
129 #endif // wxUSE_SCROLLBAR
130
131 protected:
132 // various constants
133 enum IndicatorType
134 {
135 IndicatorType_Check,
136 IndicatorType_Radio,
137 IndicatorType_Menu,
138 IndicatorType_Max
139 };
140
141 enum IndicatorState
142 {
143 IndicatorState_Normal,
144 IndicatorState_Pressed, // this one is for check/radioboxes
145 IndicatorState_Disabled,
146 IndicatorState_MaxCtrl,
147
148 // the rest of the states are valid for menu items only
149 IndicatorState_Selected = IndicatorState_Pressed,
150 IndicatorState_SelectedDisabled = IndicatorState_MaxCtrl,
151 IndicatorState_MaxMenu
152 };
153
154 enum IndicatorStatus
155 {
156 IndicatorStatus_Checked,
157 IndicatorStatus_Unchecked,
158 IndicatorStatus_Undetermined,
159 IndicatorStatus_Max
160 };
161
162 // translate the appropriate bits in flags to the above enum elements
163 static void GetIndicatorsFromFlags(int flags,
164 IndicatorState& state,
165 IndicatorStatus& status);
166
167 // fill the rectangle with a brush of given colour (must be valid)
168 void DrawSolidRect(wxDC& dc, const wxColour& col, const wxRect& rect);
169
170
171 // all the functions in this section adjust the rect parameter to
172 // correspond to the interiour of the drawn area
173
174 // draw complete rectangle
175 void DrawRect(wxDC& dc, wxRect *rect, const wxPen& pen);
176
177 // draw the rectange using the first pen for the left and top sides
178 // and the second one for the bottom and right ones
179 void DrawShadedRect(wxDC& dc, wxRect *rect,
180 const wxPen& pen1, const wxPen& pen2);
181
182 // border drawing routines, may be overridden in the derived class
183 virtual void DrawRaisedBorder(wxDC& dc, wxRect *rect);
184 virtual void DrawSunkenBorder(wxDC& dc, wxRect *rect);
185 virtual void DrawAntiSunkenBorder(wxDC& dc, wxRect *rect);
186
187
188 // draw the frame with non-empty label inside the given rectText
189 virtual void DrawFrameWithLabel(wxDC& dc,
190 const wxString& label,
191 const wxRect& rectFrame,
192 const wxRect& rectText,
193 int flags,
194 int alignment,
195 int indexAccel);
196
197 // draw the (static box) frame without the part corresponding to rectLabel
198 void DrawFrameWithoutLabel(wxDC& dc,
199 const wxRect& rectFrame,
200 const wxRect& rectLabel);
201
202
203 // common routine for drawing check and radio buttons
204 void DrawCheckOrRadioButton(wxDC& dc,
205 const wxString& label,
206 const wxBitmap& bitmap,
207 const wxRect& rect,
208 int flags,
209 wxAlignment align,
210 int indexAccel);
211
212 // return the check/radio bitmap for the given flags
213 virtual wxBitmap GetRadioBitmap(int flags) = 0;
214 virtual wxBitmap GetCheckBitmap(int flags) = 0;
215
216
217 // return the starting and ending positions, in pixels, of the thumb of a
218 // scrollbar with the given logical position, thumb size and range and the
219 // given physical length
220 static void GetScrollBarThumbSize(wxCoord length,
221 int thumbPos,
222 int thumbSize,
223 int range,
224 wxCoord *thumbStart,
225 wxCoord *thumbEnd);
226
227 // GDI objects we often use
228 wxPen m_penBlack,
229 m_penDarkGrey,
230 m_penLightGrey,
231 m_penHighlight;
232
233 // the colours we use, they never change currently so we don't have to ever
234 // update m_penXXX objects above
235 const wxColourScheme * const m_scheme;
236
237 DECLARE_NO_COPY_CLASS(wxStdRenderer)
238 };
239
240 #endif // _WX_UNIV_STDREND_H_
241