1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/univ/stdrend.h
3 // Purpose: wxStdRenderer class declaration
4 // Author: Vadim Zeitlin
7 // Copyright: (c) 2006 Vadim Zeitlin <vadim@wxwindows.org>
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_UNIV_STDREND_H_
12 #define _WX_UNIV_STDREND_H_
14 #include "wx/univ/renderer.h"
17 class WXDLLEXPORT wxColourScheme
;
19 // ----------------------------------------------------------------------------
20 // wxStdRenderer: implements as much of wxRenderer API as possible generically
21 // ----------------------------------------------------------------------------
23 class wxStdRenderer
: public wxRenderer
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
);
30 virtual void DrawBackground(wxDC
& dc
,
34 wxWindow
*window
= NULL
);
35 virtual void DrawButtonSurface(wxDC
& dc
,
41 virtual void DrawFocusRect(wxDC
& dc
, const wxRect
& rect
);
42 virtual void DrawLabel(wxDC
& dc
,
43 const wxString
& label
,
46 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
48 wxRect
*rectBounds
= NULL
);
49 virtual void DrawButtonLabel(wxDC
& dc
,
50 const wxString
& label
,
51 const wxBitmap
& image
,
54 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
56 wxRect
*rectBounds
= NULL
);
59 virtual void DrawBorder(wxDC
& dc
,
63 wxRect
*rectIn
= NULL
);
64 virtual void DrawTextBorder(wxDC
& dc
,
68 wxRect
*rectIn
= NULL
);
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
,
78 int alignment
= wxALIGN_LEFT
,
82 virtual void DrawItem(wxDC
& dc
,
83 const wxString
& label
,
86 virtual void DrawCheckItem(wxDC
& dc
,
87 const wxString
& label
,
88 const wxBitmap
& bitmap
,
92 virtual void DrawCheckButton(wxDC
& dc
,
93 const wxString
& label
,
94 const wxBitmap
& bitmap
,
97 wxAlignment align
= wxALIGN_LEFT
,
99 virtual void DrawRadioButton(wxDC
& dc
,
100 const wxString
& label
,
101 const wxBitmap
& bitmap
,
104 wxAlignment align
= wxALIGN_LEFT
,
105 int indexAccel
= -1);
107 virtual void DrawScrollbarArrow(wxDC
& dc
,
111 virtual void DrawScrollCorner(wxDC
& dc
,
115 virtual void DrawTextLine(wxDC
& dc
,
116 const wxString
& text
,
122 virtual void DrawLineWrapMark(wxDC
& dc
, const wxRect
& rect
);
124 virtual wxRect
GetTextTotalArea(const wxTextCtrl
*text
,
125 const wxRect
& rect
) const;
126 virtual wxRect
GetTextClientArea(const wxTextCtrl
*text
,
128 wxCoord
*extraSpaceBeyond
) const;
129 #endif // wxUSE_TEXTCTRL
131 virtual wxRect
GetBorderDimensions(wxBorder border
) const;
133 virtual bool AreScrollbarsInsideBorder() const;
135 virtual void AdjustSize(wxSize
*size
, const wxWindow
*window
);
137 virtual wxCoord
GetListboxItemHeight(wxCoord fontHeight
);
140 virtual wxRect
GetScrollbarRect(const wxScrollBar
*scrollbar
,
141 wxScrollBar::Element elem
,
142 int thumbPos
= -1) const;
144 virtual wxCoord
GetScrollbarSize(const wxScrollBar
*scrollbar
);
146 virtual wxHitTest
HitTestScrollbar(const wxScrollBar
*scrollbar
,
147 const wxPoint
& pt
) const;
149 virtual wxCoord
ScrollbarToPixel(const wxScrollBar
*scrollbar
,
151 virtual int PixelToScrollbar(const wxScrollBar
*scrollbar
, wxCoord coord
);
152 #endif // wxUSE_SCROLLBAR
155 virtual void DrawStatusField(wxDC
& dc
,
157 const wxString
& label
,
158 int flags
= 0, int style
= 0);
160 virtual wxSize
GetStatusBarBorders(wxCoord
*borderBetweenFields
) const;
161 #endif // wxUSE_STATUSBAR
163 virtual wxCoord
GetCheckItemMargin() const { return 0; }
166 virtual void DrawFrameTitleBar(wxDC
& dc
,
168 const wxString
& title
,
171 int specialButton
= 0,
172 int specialButtonFlag
= 0);
173 virtual void DrawFrameBorder(wxDC
& dc
,
176 virtual void DrawFrameBackground(wxDC
& dc
,
179 virtual void DrawFrameTitle(wxDC
& dc
,
181 const wxString
& title
,
183 virtual void DrawFrameIcon(wxDC
& dc
,
187 virtual void DrawFrameButton(wxDC
& dc
,
188 wxCoord x
, wxCoord y
,
192 virtual wxRect
GetFrameClientArea(const wxRect
& rect
, int flags
) const;
194 virtual wxSize
GetFrameTotalSize(const wxSize
& clientSize
, int flags
) const;
196 virtual wxSize
GetFrameMinSize(int flags
) const;
198 virtual wxSize
GetFrameIconSize() const;
200 virtual int HitTestFrame(const wxRect
& rect
,
202 int flags
= 0) const;
220 Arrow_InvertedDisabled
,
227 FrameButton_Minimize
,
228 FrameButton_Maximize
,
238 IndicatorType_MaxCtrl
,
239 IndicatorType_Menu
= IndicatorType_MaxCtrl
,
245 IndicatorState_Normal
,
246 IndicatorState_Pressed
, // this one is for check/radioboxes
247 IndicatorState_Disabled
,
248 IndicatorState_MaxCtrl
,
250 // the rest of the states are valid for menu items only
251 IndicatorState_Selected
= IndicatorState_Pressed
,
252 IndicatorState_SelectedDisabled
= IndicatorState_MaxCtrl
,
253 IndicatorState_MaxMenu
258 IndicatorStatus_Checked
,
259 IndicatorStatus_Unchecked
,
260 IndicatorStatus_Undetermined
,
264 // translate the appropriate bits in flags to the above enum elements
265 static void GetIndicatorsFromFlags(int flags
,
266 IndicatorState
& state
,
267 IndicatorStatus
& status
);
269 // translate wxDirection to ArrowDirection
270 static ArrowDirection
GetArrowDirection(wxDirection dir
);
273 // fill the rectangle with a brush of given colour (must be valid)
274 void DrawSolidRect(wxDC
& dc
, const wxColour
& col
, const wxRect
& rect
);
277 // all the functions in this section adjust the rect parameter to
278 // correspond to the interiour of the drawn area
280 // draw complete rectangle
281 void DrawRect(wxDC
& dc
, wxRect
*rect
, const wxPen
& pen
);
283 // draw the rectange using the first pen for the left and top sides
284 // and the second one for the bottom and right ones
285 void DrawShadedRect(wxDC
& dc
, wxRect
*rect
,
286 const wxPen
& pen1
, const wxPen
& pen2
);
288 // border drawing routines, may be overridden in the derived class
289 virtual void DrawRaisedBorder(wxDC
& dc
, wxRect
*rect
);
290 virtual void DrawSunkenBorder(wxDC
& dc
, wxRect
*rect
);
291 virtual void DrawAntiSunkenBorder(wxDC
& dc
, wxRect
*rect
);
292 virtual void DrawBoxBorder(wxDC
& dc
, wxRect
*rect
);
293 virtual void DrawStaticBorder(wxDC
& dc
, wxRect
*rect
);
294 virtual void DrawExtraBorder(wxDC
& dc
, wxRect
*rect
);
297 // draw the frame with non-empty label inside the given rectText
298 virtual void DrawFrameWithLabel(wxDC
& dc
,
299 const wxString
& label
,
300 const wxRect
& rectFrame
,
301 const wxRect
& rectText
,
306 // draw the (static box) frame without the part corresponding to rectLabel
307 void DrawFrameWithoutLabel(wxDC
& dc
,
308 const wxRect
& rectFrame
,
309 const wxRect
& rectLabel
);
312 // draw the bitmap for a check item (which is by default the same as check
313 // box one but may be different)
314 virtual void DrawCheckItemBitmap(wxDC
& dc
,
315 const wxBitmap
& bitmap
,
319 // common routine for drawing check and radio buttons
320 void DrawCheckOrRadioButton(wxDC
& dc
,
321 const wxString
& label
,
322 const wxBitmap
& bitmap
,
328 // return the check/radio bitmap for the given flags
329 virtual wxBitmap
GetRadioBitmap(int flags
) = 0;
330 virtual wxBitmap
GetCheckBitmap(int flags
) = 0;
332 // return the frame icon bitmap
333 virtual wxBitmap
GetFrameButtonBitmap(FrameButtonType type
) = 0;
335 // get the width of either normal or resizeable frame border depending on
336 // whether flags contains wxTOPLEVEL_RESIZEABLE bit
338 // notice that these methods only make sense with standard border drawing
339 // code which uses the borders of the same width on all sides, this is why
340 // they are only present here and not in wxRenderer itself
341 virtual int GetFrameBorderWidth(int flags
) const;
344 // return the width of the border around the text area in the text control
345 virtual int GetTextBorderWidth(const wxTextCtrl
*text
) const;
346 #endif // wxUSE_TEXTCTRL
348 // return the starting and ending positions, in pixels, of the thumb of a
349 // scrollbar with the given logical position, thumb size and range and the
350 // given physical length
351 static void GetScrollBarThumbSize(wxCoord length
,
358 // GDI objects we often use
364 wxFont m_titlebarFont
;
366 // the colours we use, they never change currently so we don't have to ever
367 // update m_penXXX objects above
368 const wxColourScheme
* const m_scheme
;
370 DECLARE_NO_COPY_CLASS(wxStdRenderer
)
373 #endif // _WX_UNIV_STDREND_H_