refactor some existing themes methods in a new base wxStdRenderer class (before adding a new theme)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@41289 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -83,16 +83,18 @@ public:
|
||||
const wxColour& col,
|
||||
const wxRect& rect,
|
||||
int flags,
|
||||
wxWindow *window = NULL ) = 0;
|
||||
wxWindow *window = NULL) = 0;
|
||||
|
||||
// draw the button surface
|
||||
virtual void DrawButtonSurface(wxDC& dc,
|
||||
const wxColour& col,
|
||||
const wxRect& rect,
|
||||
int flags )
|
||||
{ DrawBackground( dc, col, rect, flags ); }
|
||||
const wxColour& col,
|
||||
const wxRect& rect,
|
||||
int flags) = 0;
|
||||
|
||||
|
||||
// draw the focus rectangle around the label contained in the given rect
|
||||
virtual void DrawFocusRect(wxDC& dc, const wxRect& rect) = 0;
|
||||
|
||||
// draw the label inside the given rectangle with the specified alignment
|
||||
// and optionally emphasize the character with the given index
|
||||
virtual void DrawLabel(wxDC& dc,
|
||||
@@ -113,6 +115,7 @@ public:
|
||||
int indexAccel = -1,
|
||||
wxRect *rectBounds = NULL) = 0;
|
||||
|
||||
|
||||
// draw the border and optionally return the rectangle containing the
|
||||
// region inside the border
|
||||
virtual void DrawBorder(wxDC& dc,
|
||||
@@ -222,6 +225,7 @@ public:
|
||||
int tbarStyle = 0) = 0;
|
||||
#endif // wxUSE_TOOLBAR
|
||||
|
||||
#if wxUSE_TEXTCTRL
|
||||
// draw a (part of) line in the text control
|
||||
virtual void DrawTextLine(wxDC& dc,
|
||||
const wxString& text,
|
||||
@@ -232,7 +236,9 @@ public:
|
||||
|
||||
// draw a line wrap indicator
|
||||
virtual void DrawLineWrapMark(wxDC& dc, const wxRect& rect) = 0;
|
||||
#endif // wxUSE_TEXTCTRL
|
||||
|
||||
#if wxUSE_NOTEBOOK
|
||||
// draw a notebook tab
|
||||
virtual void DrawTab(wxDC& dc,
|
||||
const wxRect& rect,
|
||||
@@ -241,6 +247,7 @@ public:
|
||||
const wxBitmap& bitmap = wxNullBitmap,
|
||||
int flags = 0,
|
||||
int indexAccel = -1) = 0;
|
||||
#endif // wxUSE_NOTEBOOK
|
||||
|
||||
#if wxUSE_SLIDER
|
||||
|
||||
@@ -347,11 +354,13 @@ public:
|
||||
// misc functions
|
||||
// --------------
|
||||
|
||||
#if wxUSE_COMBOBOX
|
||||
// return the bitmaps to use for combobox button
|
||||
virtual void GetComboBitmaps(wxBitmap *bmpNormal,
|
||||
wxBitmap *bmpFocus,
|
||||
wxBitmap *bmpPressed,
|
||||
wxBitmap *bmpDisabled) = 0;
|
||||
#endif // wxUSE_COMBOBOX
|
||||
|
||||
// geometry functions
|
||||
// ------------------
|
||||
@@ -424,11 +433,13 @@ public:
|
||||
wxCoord *extraSpaceBeyond) const = 0;
|
||||
#endif // wxUSE_TEXTCTRL
|
||||
|
||||
#if wxUSE_NOTEBOOK
|
||||
// get the overhang of a selected tab
|
||||
virtual wxSize GetTabIndent() const = 0;
|
||||
|
||||
// get the padding around the text in a tab
|
||||
virtual wxSize GetTabPadding() const = 0;
|
||||
#endif // wxUSE_NOTEBOOK
|
||||
|
||||
#if wxUSE_SLIDER
|
||||
// get the default size of the slider in lesser dimension (i.e. height of a
|
||||
@@ -492,50 +503,6 @@ public:
|
||||
|
||||
// virtual dtor for any base class
|
||||
virtual ~wxRenderer();
|
||||
|
||||
|
||||
protected:
|
||||
// draw a frame around rectFrame rectangle but not touching the rectLabel
|
||||
// one: this is used by DrawFrame()
|
||||
void StandardDrawFrame(wxDC& dc,
|
||||
const wxRect& rectFrame,
|
||||
const wxRect& rectLabel);
|
||||
|
||||
// standard text line drawing: just use DrawText() and highlight the
|
||||
// selected part
|
||||
static void StandardDrawTextLine(wxDC& dc,
|
||||
const wxString& text,
|
||||
const wxRect& rect,
|
||||
int selStart, int selEnd,
|
||||
int flags);
|
||||
|
||||
#if wxUSE_SCROLLBAR
|
||||
// standard scrollbar hit testing: this assumes that it only has 2 arrows
|
||||
// and a thumb, so the themes which have more complicated scrollbars (e.g.
|
||||
// BeOS) can't use this method
|
||||
static wxRect StandardGetScrollbarRect(const wxScrollBar *scrollbar,
|
||||
wxScrollBar::Element elem,
|
||||
int thumbPos,
|
||||
const wxSize& sizeArrow);
|
||||
static wxHitTest StandardHitTestScrollbar(const wxScrollBar *scrollbar,
|
||||
const wxPoint& pt,
|
||||
const wxSize& sizeArrow);
|
||||
static wxCoord StandardScrollbarToPixel(const wxScrollBar *scrollbar,
|
||||
int thumbPos,
|
||||
const wxSize& sizeArrow);
|
||||
static int StandardPixelToScrollbar(const wxScrollBar *scrollbar,
|
||||
wxCoord coord,
|
||||
const wxSize& sizeArrow);
|
||||
static wxCoord StandardScrollBarSize(const wxScrollBar *scrollbar,
|
||||
const wxSize& sizeArrow);
|
||||
static void StandardScrollBarThumbSize(wxCoord lenBar,
|
||||
int thumbPos,
|
||||
int thumbSize,
|
||||
int range,
|
||||
wxCoord *thumbStart,
|
||||
wxCoord *thumbEnd);
|
||||
#endif // wxUSE_SCROLLBAR
|
||||
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -556,6 +523,13 @@ public:
|
||||
int flags,
|
||||
wxWindow *window = NULL )
|
||||
{ m_renderer->DrawBackground(dc, col, rect, flags, window ); }
|
||||
virtual void DrawButtonSurface(wxDC& dc,
|
||||
const wxColour& col,
|
||||
const wxRect& rect,
|
||||
int flags)
|
||||
{ m_renderer->DrawButtonSurface(dc, col, rect, flags); }
|
||||
virtual void DrawFocusRect(wxDC& dc, const wxRect& rect)
|
||||
{ m_renderer->DrawFocusRect(dc, rect); }
|
||||
virtual void DrawLabel(wxDC& dc,
|
||||
const wxString& label,
|
||||
const wxRect& rect,
|
||||
@@ -667,6 +641,8 @@ public:
|
||||
int tbarStyle = 0)
|
||||
{ m_renderer->DrawToolBarButton(dc, label, bitmap, rect, flags, style, tbarStyle); }
|
||||
#endif // wxUSE_TOOLBAR
|
||||
|
||||
#if wxUSE_TEXTCTRL
|
||||
virtual void DrawTextLine(wxDC& dc,
|
||||
const wxString& text,
|
||||
const wxRect& rect,
|
||||
@@ -676,7 +652,9 @@ public:
|
||||
{ m_renderer->DrawTextLine(dc, text, rect, selStart, selEnd, flags); }
|
||||
virtual void DrawLineWrapMark(wxDC& dc, const wxRect& rect)
|
||||
{ m_renderer->DrawLineWrapMark(dc, rect); }
|
||||
#endif // wxUSE_TEXTCTRL
|
||||
|
||||
#if wxUSE_NOTEBOOK
|
||||
virtual void DrawTab(wxDC& dc,
|
||||
const wxRect& rect,
|
||||
wxDirection dir,
|
||||
@@ -685,6 +663,7 @@ public:
|
||||
int flags = 0,
|
||||
int accel = -1)
|
||||
{ m_renderer->DrawTab(dc, rect, dir, label, bitmap, flags, accel); }
|
||||
#endif // wxUSE_NOTEBOOK
|
||||
|
||||
#if wxUSE_SLIDER
|
||||
|
||||
@@ -779,12 +758,14 @@ public:
|
||||
int flags = 0)
|
||||
{ m_renderer->DrawFrameButton(dc, x, y, button, flags); }
|
||||
|
||||
#if wxUSE_COMBOBOX
|
||||
virtual void GetComboBitmaps(wxBitmap *bmpNormal,
|
||||
wxBitmap *bmpFocus,
|
||||
wxBitmap *bmpPressed,
|
||||
wxBitmap *bmpDisabled)
|
||||
{ m_renderer->GetComboBitmaps(bmpNormal, bmpFocus,
|
||||
bmpPressed, bmpDisabled); }
|
||||
#endif // wxUSE_COMBOBOX
|
||||
|
||||
virtual void AdjustSize(wxSize *size, const wxWindow *window)
|
||||
{ m_renderer->AdjustSize(size, window); }
|
||||
@@ -889,9 +870,9 @@ public:
|
||||
wxDC& dc,
|
||||
const wxRect& rect,
|
||||
int flags = 0,
|
||||
wxHeaderSortIconType sortArrow = wxHDR_SORT_ICON_NONE,
|
||||
wxHeaderButtonParams* params=NULL)
|
||||
{ m_renderer->DrawHeaderButton(win, dc, rect, flags, sortArrow, params); }
|
||||
wxHeaderSortIconType sortIcon = wxHDR_SORT_ICON_NONE,
|
||||
wxHeaderButtonParams* params = NULL)
|
||||
{ m_renderer->DrawHeaderButton(win, dc, rect, flags, sortIcon, params); }
|
||||
virtual void DrawTreeItemButton(wxWindow *win,
|
||||
wxDC& dc,
|
||||
const wxRect& rect,
|
||||
|
241
include/wx/univ/stdrend.h
Normal file
241
include/wx/univ/stdrend.h
Normal file
@@ -0,0 +1,241 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/univ/stdrend.h
|
||||
// Purpose: wxStdRenderer class declaration
|
||||
// Author: Vadim Zeitlin
|
||||
// Created: 2006-09-18
|
||||
// RCS-ID: $Id$
|
||||
// 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"
|
||||
|
||||
class WXDLLEXPORT 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(wxDC& dc, const wxRect& rect);
|
||||
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 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);
|
||||
|
||||
#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);
|
||||
#endif // wxUSE_TEXTCTRL
|
||||
|
||||
virtual wxRect GetBorderDimensions(wxBorder border) const;
|
||||
|
||||
virtual bool AreScrollbarsInsideBorder() const;
|
||||
|
||||
#if wxUSE_SCROLLBAR
|
||||
virtual wxRect GetScrollbarRect(const wxScrollBar *scrollbar,
|
||||
wxScrollBar::Element elem,
|
||||
int thumbPos = -1) const;
|
||||
|
||||
virtual wxCoord GetScrollbarSize(const wxScrollBar *scrollbar);
|
||||
|
||||
virtual wxHitTest HitTestScrollbar(const wxScrollBar *scrollbar,
|
||||
const wxPoint& pt) const;
|
||||
|
||||
virtual wxCoord ScrollbarToPixel(const wxScrollBar *scrollbar,
|
||||
int thumbPos = -1);
|
||||
virtual int PixelToScrollbar(const wxScrollBar *scrollbar, wxCoord coord);
|
||||
#endif // wxUSE_SCROLLBAR
|
||||
|
||||
protected:
|
||||
// various constants
|
||||
enum IndicatorType
|
||||
{
|
||||
IndicatorType_Check,
|
||||
IndicatorType_Radio,
|
||||
IndicatorType_Menu,
|
||||
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);
|
||||
|
||||
// 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);
|
||||
|
||||
|
||||
// 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);
|
||||
|
||||
|
||||
// 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 starting and ending positions, in pixels, of the thumb of a
|
||||
// scrollbar with the given logical position, thumb size and range and the
|
||||
// given physical length
|
||||
static void GetScrollBarThumbSize(wxCoord length,
|
||||
int thumbPos,
|
||||
int thumbSize,
|
||||
int range,
|
||||
wxCoord *thumbStart,
|
||||
wxCoord *thumbEnd);
|
||||
|
||||
// GDI objects we often use
|
||||
wxPen m_penBlack,
|
||||
m_penDarkGrey,
|
||||
m_penLightGrey,
|
||||
m_penHighlight;
|
||||
|
||||
// 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;
|
||||
|
||||
DECLARE_NO_COPY_CLASS(wxStdRenderer)
|
||||
};
|
||||
|
||||
#endif // _WX_UNIV_STDREND_H_
|
||||
|
Reference in New Issue
Block a user