1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352
|
///////////////////////////////////////////////////////////////////////////////
// Name: wx/univ/stdrend.h
// Purpose: wxStdRenderer class declaration
// Author: Vadim Zeitlin
// Created: 2006-09-18
// Copyright: (c) 2006 Vadim Zeitlin <vadim@wxwindows.org>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_UNIV_STDREND_H_
#define _WX_UNIV_STDREND_H_
#include "wx/univ/renderer.h"
#include "wx/pen.h"
class WXDLLIMPEXP_FWD_CORE wxColourScheme;
// ----------------------------------------------------------------------------
// wxStdRenderer: implements as much of wxRenderer API as possible generically
// ----------------------------------------------------------------------------
class wxStdRenderer : public wxRenderer
{
public:
// the renderer will use the given scheme, whose lifetime must be at least
// as long as of this object itself, to choose the colours for drawing
wxStdRenderer(const wxColourScheme *scheme);
virtual void DrawBackground(wxDC& dc,
const wxColour& col,
const wxRect& rect,
int flags = 0,
wxWindow *window = NULL);
virtual void DrawButtonSurface(wxDC& dc,
const wxColour& col,
const wxRect& rect,
int flags);
virtual void DrawFocusRect(wxWindow* win, wxDC& dc, const wxRect& rect, int flags = 0);
virtual void DrawLabel(wxDC& dc,
const wxString& label,
const wxRect& rect,
int flags = 0,
int alignment = wxALIGN_LEFT | wxALIGN_TOP,
int indexAccel = -1,
wxRect *rectBounds = NULL);
virtual void DrawButtonLabel(wxDC& dc,
const wxString& label,
const wxBitmap& image,
const wxRect& rect,
int flags = 0,
int alignment = wxALIGN_LEFT | wxALIGN_TOP,
int indexAccel = -1,
wxRect *rectBounds = NULL);
virtual void DrawBorder(wxDC& dc,
wxBorder border,
const wxRect& rect,
int flags = 0,
wxRect *rectIn = NULL);
virtual void DrawTextBorder(wxDC& dc,
wxBorder border,
const wxRect& rect,
int flags = 0,
wxRect *rectIn = NULL);
virtual void DrawHorizontalLine(wxDC& dc,
wxCoord y, wxCoord x1, wxCoord x2);
virtual void DrawVerticalLine(wxDC& dc,
wxCoord x, wxCoord y1, wxCoord y2);
virtual void DrawFrame(wxDC& dc,
const wxString& label,
const wxRect& rect,
int flags = 0,
int alignment = wxALIGN_LEFT,
int indexAccel = -1);
virtual void DrawItem(wxDC& dc,
const wxString& label,
const wxRect& rect,
int flags = 0);
virtual void DrawCheckItem(wxDC& dc,
const wxString& label,
const wxBitmap& bitmap,
const wxRect& rect,
int flags = 0);
virtual void DrawCheckButton(wxDC& dc,
const wxString& label,
const wxBitmap& bitmap,
const wxRect& rect,
int flags = 0,
wxAlignment align = wxALIGN_LEFT,
int indexAccel = -1);
virtual void DrawRadioButton(wxDC& dc,
const wxString& label,
const wxBitmap& bitmap,
const wxRect& rect,
int flags = 0,
wxAlignment align = wxALIGN_LEFT,
int indexAccel = -1);
virtual void DrawScrollbarArrow(wxDC& dc,
wxDirection dir,
const wxRect& rect,
int flags = 0);
virtual void DrawScrollCorner(wxDC& dc,
const wxRect& rect);
#if wxUSE_TEXTCTRL
virtual void DrawTextLine(wxDC& dc,
const wxString& text,
const wxRect& rect,
int selStart = -1,
int selEnd = -1,
int flags = 0);
virtual void DrawLineWrapMark(wxDC& dc, const wxRect& rect);
virtual wxRect GetTextTotalArea(const wxTextCtrl *text,
const wxRect& rect) const;
virtual wxRect GetTextClientArea(const wxTextCtrl *text,
const wxRect& rect,
wxCoord *extraSpaceBeyond) const;
#endif // wxUSE_TEXTCTRL
virtual wxRect GetBorderDimensions(wxBorder border) const;
virtual bool AreScrollbarsInsideBorder() const;
virtual void AdjustSize(wxSize *size, const wxWindow *window);
virtual wxCoord GetListboxItemHeight(wxCoord fontHeight);
#if wxUSE_STATUSBAR
virtual void DrawStatusField(wxDC& dc,
const wxRect& rect,
const wxString& label,
int flags = 0, int style = 0);
virtual wxSize GetStatusBarBorders() const;
virtual wxCoord GetStatusBarBorderBetweenFields() const;
virtual wxSize GetStatusBarFieldMargins() const;
#endif // wxUSE_STATUSBAR
virtual wxCoord GetCheckItemMargin() const { return 0; }
virtual void DrawFrameTitleBar(wxDC& dc,
const wxRect& rect,
const wxString& title,
const wxIcon& icon,
int flags,
int specialButton = 0,
int specialButtonFlag = 0);
virtual void DrawFrameBorder(wxDC& dc,
const wxRect& rect,
int flags);
virtual void DrawFrameBackground(wxDC& dc,
const wxRect& rect,
int flags);
virtual void DrawFrameTitle(wxDC& dc,
const wxRect& rect,
const wxString& title,
int flags);
virtual void DrawFrameIcon(wxDC& dc,
const wxRect& rect,
const wxIcon& icon,
int flags);
virtual void DrawFrameButton(wxDC& dc,
wxCoord x, wxCoord y,
int button,
int flags = 0);
virtual wxRect GetFrameClientArea(const wxRect& rect, int flags) const;
virtual wxSize GetFrameTotalSize(const wxSize& clientSize, int flags) const;
virtual wxSize GetFrameMinSize(int flags) const;
virtual wxSize GetFrameIconSize() const;
virtual int HitTestFrame(const wxRect& rect,
const wxPoint& pt,
int flags = 0) const;
protected:
// various constants
enum ArrowDirection
{
Arrow_Left,
Arrow_Right,
Arrow_Up,
Arrow_Down,
Arrow_Max
};
enum ArrowStyle
{
Arrow_Normal,
Arrow_Disabled,
Arrow_Pressed,
Arrow_Inverted,
Arrow_InvertedDisabled,
Arrow_StateMax
};
enum FrameButtonType
{
FrameButton_Close,
FrameButton_Minimize,
FrameButton_Maximize,
FrameButton_Restore,
FrameButton_Help,
FrameButton_Max
};
enum IndicatorType
{
IndicatorType_Check,
IndicatorType_Radio,
IndicatorType_MaxCtrl,
IndicatorType_Menu = IndicatorType_MaxCtrl,
IndicatorType_Max
};
enum IndicatorState
{
IndicatorState_Normal,
IndicatorState_Pressed, // this one is for check/radioboxes
IndicatorState_Disabled,
IndicatorState_MaxCtrl,
// the rest of the states are valid for menu items only
IndicatorState_Selected = IndicatorState_Pressed,
IndicatorState_SelectedDisabled = IndicatorState_MaxCtrl,
IndicatorState_MaxMenu
};
enum IndicatorStatus
{
IndicatorStatus_Checked,
IndicatorStatus_Unchecked,
IndicatorStatus_Undetermined,
IndicatorStatus_Max
};
// translate the appropriate bits in flags to the above enum elements
static void GetIndicatorsFromFlags(int flags,
IndicatorState& state,
IndicatorStatus& status);
// translate wxDirection to ArrowDirection
static ArrowDirection GetArrowDirection(wxDirection dir);
// fill the rectangle with a brush of given colour (must be valid)
void DrawSolidRect(wxDC& dc, const wxColour& col, const wxRect& rect);
// all the functions in this section adjust the rect parameter to
// correspond to the interiour of the drawn area
// draw complete rectangle
void DrawRect(wxDC& dc, wxRect *rect, const wxPen& pen);
// draw the rectange using the first pen for the left and top sides
// and the second one for the bottom and right ones
void DrawShadedRect(wxDC& dc, wxRect *rect,
const wxPen& pen1, const wxPen& pen2);
// border drawing routines, may be overridden in the derived class
virtual void DrawRaisedBorder(wxDC& dc, wxRect *rect);
virtual void DrawSunkenBorder(wxDC& dc, wxRect *rect);
virtual void DrawAntiSunkenBorder(wxDC& dc, wxRect *rect);
virtual void DrawBoxBorder(wxDC& dc, wxRect *rect);
virtual void DrawStaticBorder(wxDC& dc, wxRect *rect);
virtual void DrawExtraBorder(wxDC& dc, wxRect *rect);
// draw the frame with non-empty label inside the given rectText
virtual void DrawFrameWithLabel(wxDC& dc,
const wxString& label,
const wxRect& rectFrame,
const wxRect& rectText,
int flags,
int alignment,
int indexAccel);
// draw the (static box) frame without the part corresponding to rectLabel
void DrawFrameWithoutLabel(wxDC& dc,
const wxRect& rectFrame,
const wxRect& rectLabel);
// draw the bitmap for a check item (which is by default the same as check
// box one but may be different)
virtual void DrawCheckItemBitmap(wxDC& dc,
const wxBitmap& bitmap,
const wxRect& rect,
int flags);
// common routine for drawing check and radio buttons
void DrawCheckOrRadioButton(wxDC& dc,
const wxString& label,
const wxBitmap& bitmap,
const wxRect& rect,
int flags,
wxAlignment align,
int indexAccel);
// return the check/radio bitmap for the given flags
virtual wxBitmap GetRadioBitmap(int flags) = 0;
virtual wxBitmap GetCheckBitmap(int flags) = 0;
// return the frame icon bitmap
virtual wxBitmap GetFrameButtonBitmap(FrameButtonType type) = 0;
// get the width of either normal or resizable frame border depending on
// whether flags contains wxTOPLEVEL_RESIZEABLE bit
//
// notice that these methods only make sense with standard border drawing
// code which uses the borders of the same width on all sides, this is why
// they are only present here and not in wxRenderer itself
virtual int GetFrameBorderWidth(int flags) const;
#if wxUSE_TEXTCTRL
// return the width of the border around the text area in the text control
virtual int GetTextBorderWidth(const wxTextCtrl *text) const;
#endif // wxUSE_TEXTCTRL
// GDI objects we often use
wxPen m_penBlack,
m_penDarkGrey,
m_penLightGrey,
m_penHighlight;
wxFont m_titlebarFont;
// the colours we use, they never change currently so we don't have to ever
// update m_penXXX objects above
const wxColourScheme * const m_scheme;
wxDECLARE_NO_COPY_CLASS(wxStdRenderer);
};
#endif // _WX_UNIV_STDREND_H_
|