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