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 WXDLLIMPEXP_FWD_CORE 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(wxWindow
* win
, wxDC
& dc
, const wxRect
& rect
, int flags
= 0);
43 virtual void DrawLabel(wxDC
& dc
,
44 const wxString
& label
,
47 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
49 wxRect
*rectBounds
= NULL
);
50 virtual void DrawButtonLabel(wxDC
& dc
,
51 const wxString
& label
,
52 const wxBitmap
& image
,
55 int alignment
= wxALIGN_LEFT
| wxALIGN_TOP
,
57 wxRect
*rectBounds
= NULL
);
60 virtual void DrawBorder(wxDC
& dc
,
64 wxRect
*rectIn
= NULL
);
65 virtual void DrawTextBorder(wxDC
& dc
,
69 wxRect
*rectIn
= NULL
);
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
,
79 int alignment
= wxALIGN_LEFT
,
83 virtual void DrawItem(wxDC
& dc
,
84 const wxString
& label
,
87 virtual void DrawCheckItem(wxDC
& dc
,
88 const wxString
& label
,
89 const wxBitmap
& bitmap
,
93 virtual void DrawCheckButton(wxDC
& dc
,
94 const wxString
& label
,
95 const wxBitmap
& bitmap
,
98 wxAlignment align
= wxALIGN_LEFT
,
100 virtual void DrawRadioButton(wxDC
& dc
,
101 const wxString
& label
,
102 const wxBitmap
& bitmap
,
105 wxAlignment align
= wxALIGN_LEFT
,
106 int indexAccel
= -1);
108 virtual void DrawScrollbarArrow(wxDC
& dc
,
112 virtual void DrawScrollCorner(wxDC
& dc
,
116 virtual void DrawTextLine(wxDC
& dc
,
117 const wxString
& text
,
123 virtual void DrawLineWrapMark(wxDC
& dc
, const wxRect
& rect
);
125 virtual wxRect
GetTextTotalArea(const wxTextCtrl
*text
,
126 const wxRect
& rect
) const;
127 virtual wxRect
GetTextClientArea(const wxTextCtrl
*text
,
129 wxCoord
*extraSpaceBeyond
) const;
130 #endif // wxUSE_TEXTCTRL
132 virtual wxRect
GetBorderDimensions(wxBorder border
) const;
134 virtual bool AreScrollbarsInsideBorder() const;
136 virtual void AdjustSize(wxSize
*size
, const wxWindow
*window
);
138 virtual wxCoord
GetListboxItemHeight(wxCoord fontHeight
);
141 virtual void DrawStatusField(wxDC
& dc
,
143 const wxString
& label
,
144 int flags
= 0, int style
= 0);
146 virtual wxSize
GetStatusBarBorders() const;
148 virtual wxCoord
GetStatusBarBorderBetweenFields() const;
150 virtual wxSize
GetStatusBarFieldMargins() const;
151 #endif // wxUSE_STATUSBAR
153 virtual wxCoord
GetCheckItemMargin() const { return 0; }
156 virtual void DrawFrameTitleBar(wxDC
& dc
,
158 const wxString
& title
,
161 int specialButton
= 0,
162 int specialButtonFlag
= 0);
163 virtual void DrawFrameBorder(wxDC
& dc
,
166 virtual void DrawFrameBackground(wxDC
& dc
,
169 virtual void DrawFrameTitle(wxDC
& dc
,
171 const wxString
& title
,
173 virtual void DrawFrameIcon(wxDC
& dc
,
177 virtual void DrawFrameButton(wxDC
& dc
,
178 wxCoord x
, wxCoord y
,
182 virtual wxRect
GetFrameClientArea(const wxRect
& rect
, int flags
) const;
184 virtual wxSize
GetFrameTotalSize(const wxSize
& clientSize
, int flags
) const;
186 virtual wxSize
GetFrameMinSize(int flags
) const;
188 virtual wxSize
GetFrameIconSize() const;
190 virtual int HitTestFrame(const wxRect
& rect
,
192 int flags
= 0) const;
210 Arrow_InvertedDisabled
,
217 FrameButton_Minimize
,
218 FrameButton_Maximize
,
228 IndicatorType_MaxCtrl
,
229 IndicatorType_Menu
= IndicatorType_MaxCtrl
,
235 IndicatorState_Normal
,
236 IndicatorState_Pressed
, // this one is for check/radioboxes
237 IndicatorState_Disabled
,
238 IndicatorState_MaxCtrl
,
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
248 IndicatorStatus_Checked
,
249 IndicatorStatus_Unchecked
,
250 IndicatorStatus_Undetermined
,
254 // translate the appropriate bits in flags to the above enum elements
255 static void GetIndicatorsFromFlags(int flags
,
256 IndicatorState
& state
,
257 IndicatorStatus
& status
);
259 // translate wxDirection to ArrowDirection
260 static ArrowDirection
GetArrowDirection(wxDirection dir
);
263 // fill the rectangle with a brush of given colour (must be valid)
264 void DrawSolidRect(wxDC
& dc
, const wxColour
& col
, const wxRect
& rect
);
267 // all the functions in this section adjust the rect parameter to
268 // correspond to the interiour of the drawn area
270 // draw complete rectangle
271 void DrawRect(wxDC
& dc
, wxRect
*rect
, const wxPen
& pen
);
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
);
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
);
282 virtual void DrawBoxBorder(wxDC
& dc
, wxRect
*rect
);
283 virtual void DrawStaticBorder(wxDC
& dc
, wxRect
*rect
);
284 virtual void DrawExtraBorder(wxDC
& dc
, wxRect
*rect
);
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
,
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
);
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
,
309 // common routine for drawing check and radio buttons
310 void DrawCheckOrRadioButton(wxDC
& dc
,
311 const wxString
& label
,
312 const wxBitmap
& bitmap
,
318 // return the check/radio bitmap for the given flags
319 virtual wxBitmap
GetRadioBitmap(int flags
) = 0;
320 virtual wxBitmap
GetCheckBitmap(int flags
) = 0;
322 // return the frame icon bitmap
323 virtual wxBitmap
GetFrameButtonBitmap(FrameButtonType type
) = 0;
325 // get the width of either normal or resizeable frame border depending on
326 // whether flags contains wxTOPLEVEL_RESIZEABLE bit
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;
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
338 // GDI objects we often use
344 wxFont m_titlebarFont
;
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
;
350 wxDECLARE_NO_COPY_CLASS(wxStdRenderer
);
353 #endif // _WX_UNIV_STDREND_H_