Committed Jaako's renderer patch

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@38891 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
2006-04-24 16:57:27 +00:00
parent 6b5d2431fc
commit 2209baaee3
5 changed files with 188 additions and 53 deletions

View File

@@ -68,7 +68,8 @@ enum
wxCONTROL_CURRENT = 0x00000010, // mouse is currently over the control wxCONTROL_CURRENT = 0x00000010, // mouse is currently over the control
wxCONTROL_SELECTED = 0x00000020, // selected item in e.g. listbox wxCONTROL_SELECTED = 0x00000020, // selected item in e.g. listbox
wxCONTROL_CHECKED = 0x00000040, // (check/radio button) is checked wxCONTROL_CHECKED = 0x00000040, // (check/radio button) is checked
wxCONTROL_CHECKABLE = 0x00000080 // (menu) item can be checked wxCONTROL_CHECKABLE = 0x00000080, // (menu) item can be checked
wxCONTROL_UNDETERMINED = wxCONTROL_CHECKABLE // (check) undetermined state
}; };
\end{verbatim} \end{verbatim}
@@ -91,6 +92,16 @@ No base class
Virtual destructor as for any base class. Virtual destructor as for any base class.
\membersection{wxRendererNative::DrawCheckButton}\label{wxrenderernativedrawcheckbutton}
\func{void}{DrawCheckButton}{\param{wxWindow *}{win}, \param{wxDC\& }{dc}, \param{const wxRect\& }{rect}, \param{int }{flags}}
Draw a check box (used by wxDataViewCtrl).
\arg{flags} may have the \texttt{wxCONTROL\_CHECKED}, \texttt{wxCONTROL\_CURRENT} or
\texttt{wxCONTROL\_UNDETERMINED} bit set.
\membersection{wxRendererNative::DrawComboBoxDropButton}\label{wxrenderernativedrawcomboboxdropbutton} \membersection{wxRendererNative::DrawComboBoxDropButton}\label{wxrenderernativedrawcomboboxdropbutton}
\func{void}{DrawComboBoxDropButton}{\param{wxWindow *}{win}, \param{wxDC\& }{dc}, \param{const wxRect\& }{rect}, \param{int }{flags}} \func{void}{DrawComboBoxDropButton}{\param{wxWindow *}{win}, \param{wxDC\& }{dc}, \param{const wxRect\& }{rect}, \param{int }{flags}}
@@ -120,6 +131,16 @@ rectangle of a drop down button which arrow matches the size you need.
Draw the header control button (used by \helpref{wxListCtrl}{wxlistctrl}). Draw the header control button (used by \helpref{wxListCtrl}{wxlistctrl}).
\membersection{wxRendererNative::DrawPushButton}\label{wxrenderernativedrawpushbutton}
\func{void}{DrawPushButton}{\param{wxWindow *}{win}, \param{wxDC\& }{dc}, \param{const wxRect\& }{rect}, \param{int }{flags}}
Draw a blank push button that looks very similar to \helpref{wxButton}{wxbutton}.
\arg{flags} may have the \texttt{wxCONTROL\_PRESSED}, \texttt{wxCONTROL\_CURRENT} or
\texttt{wxCONTROL\_ISDEFAULT} bit set.
\membersection{wxRendererNative::DrawSplitterBorder}\label{wxrenderernativedrawsplitterborder} \membersection{wxRendererNative::DrawSplitterBorder}\label{wxrenderernativedrawsplitterborder}
\func{void}{DrawSplitterBorder}{\param{wxWindow* }{win}, \param{wxDC\& }{dc}, \param{const wxRect\& }{rect}, \param{int }{flags = 0}} \func{void}{DrawSplitterBorder}{\param{wxWindow* }{win}, \param{wxDC\& }{dc}, \param{const wxRect\& }{rect}, \param{int }{flags = 0}}

View File

@@ -170,7 +170,6 @@ public:
const wxRect& rect, const wxRect& rect,
int flags = 0) = 0; int flags = 0) = 0;
// draw check button // draw check button
// //
// flags may use wxCONTROL_CHECKED, wxCONTROL_UNDETERMINED and wxCONTROL_CURRENT // flags may use wxCONTROL_CHECKED, wxCONTROL_UNDETERMINED and wxCONTROL_CURRENT
@@ -178,7 +177,15 @@ public:
wxDC& dc, wxDC& dc,
const wxRect& rect, const wxRect& rect,
int flags = 0) = 0; int flags = 0) = 0;
// draw blank button
//
// flags may use wxCONTROL_PRESSED, wxCONTROL_CURRENT and wxCONTROL_ISDEFAULT
virtual void DrawPushButton(wxWindow *win,
wxDC& dc,
const wxRect& rect,
int flags = 0) = 0;
// geometry functions // geometry functions
// ------------------ // ------------------
@@ -286,7 +293,13 @@ public:
const wxRect& rect, const wxRect& rect,
int flags = 0 ) int flags = 0 )
{ m_rendererNative.DrawCheckButton( win, dc, rect, flags ); } { m_rendererNative.DrawCheckButton( win, dc, rect, flags ); }
virtual void DrawPushButton(wxWindow *win,
wxDC& dc,
const wxRect& rect,
int flags = 0 )
{ m_rendererNative.DrawPushButton( win, dc, rect, flags ); }
virtual wxSplitterRenderParams GetSplitterParams(const wxWindow *win) virtual wxSplitterRenderParams GetSplitterParams(const wxWindow *win)
{ return m_rendererNative.GetSplitterParams(win); } { return m_rendererNative.GetSplitterParams(win); }

View File

@@ -82,7 +82,12 @@ public:
wxDC& dc, wxDC& dc,
const wxRect& rect, const wxRect& rect,
int flags = 0); int flags = 0);
virtual void DrawPushButton(wxWindow *win,
wxDC& dc,
const wxRect& rect,
int flags = 0);
virtual wxSplitterRenderParams GetSplitterParams(const wxWindow *win); virtual wxSplitterRenderParams GetSplitterParams(const wxWindow *win);
virtual wxRendererVersion GetVersion() const virtual wxRendererVersion GetVersion() const
@@ -360,21 +365,12 @@ void
wxRendererGeneric::DrawComboBoxDropButton(wxWindow *win, wxRendererGeneric::DrawComboBoxDropButton(wxWindow *win,
wxDC& dc, wxDC& dc,
const wxRect& rect, const wxRect& rect,
int WXUNUSED(flags)) int flags)
{ {
// Creating a generic button background that would actually be DrawPushButton(win,dc,rect,flags);
// useful is rather difficult to accomplish. Best compromise DrawDropArrow(win,dc,rect,flags);
// is to use window's background colour to achieve transparent'
// ish appearance that should look decent in combo box style
// controls.
wxColour col = win->GetBackgroundColour();
dc.SetBrush(wxBrush(col));
dc.SetPen(wxPen(col));
dc.DrawRectangle(rect);
DrawDropArrow(win,dc,rect);
} }
void void
wxRendererGeneric::DrawDropArrow(wxWindow *win, wxRendererGeneric::DrawDropArrow(wxWindow *win,
wxDC& dc, wxDC& dc,
@@ -416,6 +412,22 @@ wxRendererGeneric::DrawCheckButton(wxWindow *WXUNUSED(win),
} }
} }
void
wxRendererGeneric::DrawPushButton(wxWindow *win,
wxDC& dc,
const wxRect& rect,
int flags)
{
// Don't try anything too fancy. It'll just turn out looking
// out-of-place on most platforms.
wxColour bgCol = flags & wxCONTROL_DISABLED ?
wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE) :
win->GetBackgroundColour();
dc.SetBrush(wxBrush(bgCol));
dc.SetPen(wxPen(bgCol));
dc.DrawRectangle(rect);
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// A module to allow cleanup of generic renderer. // A module to allow cleanup of generic renderer.
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@@ -82,13 +82,18 @@ public:
wxDC& dc, wxDC& dc,
const wxRect& rect, const wxRect& rect,
int flags = 0); int flags = 0);
virtual void DrawPushButton(wxWindow *win,
wxDC& dc,
const wxRect& rect,
int flags = 0);
virtual wxSplitterRenderParams GetSplitterParams(const wxWindow *win); virtual wxSplitterRenderParams GetSplitterParams(const wxWindow *win);
private: private:
// FIXME: shouldn't we destroy these windows somewhere? // FIXME: shouldn't we destroy these windows somewhere?
// used by DrawHeaderButton and DrawComboBoxDropButton // used by DrawHeaderButton and DrawPushButton
static GtkWidget *GetButtonWidget(); static GtkWidget *GetButtonWidget();
// used by DrawTreeItemButton() // used by DrawTreeItemButton()
@@ -185,7 +190,7 @@ wxRendererGTK::DrawHeaderButton(wxWindow *win,
( (
button->style, button->style,
// FIXME: I suppose GTK_PIZZA(win->m_wxwindow)->bin_window doesn't work with wxMemoryDC. // FIXME: I suppose GTK_PIZZA(win->m_wxwindow)->bin_window doesn't work with wxMemoryDC.
// Maybe use code similar as in DrawComboBoxDropButton below? // Maybe use code similar as in DrawPushButton below?
GTK_PIZZA(win->m_wxwindow)->bin_window, GTK_PIZZA(win->m_wxwindow)->bin_window,
flags & wxCONTROL_DISABLED ? GTK_STATE_INSENSITIVE : GTK_STATE_NORMAL, flags & wxCONTROL_DISABLED ? GTK_STATE_INSENSITIVE : GTK_STATE_NORMAL,
GTK_SHADOW_OUT, GTK_SHADOW_OUT,
@@ -422,39 +427,8 @@ wxRendererGTK::DrawComboBoxDropButton(wxWindow *win,
const wxRect& rect, const wxRect& rect,
int flags) int flags)
{ {
GtkWidget *button = GetButtonWidget(); DrawPushButton(win,dc,rect,flags);
DrawDropArrow(win,dc,rect);
// for reason why we do this, see DrawDropArrow
wxWindowDC& wdc = (wxWindowDC&)dc;
wxASSERT ( wdc.IsKindOf(CLASSINFO(wxWindowDC)) );
// draw button
GtkStateType state;
if ( flags & wxCONTROL_PRESSED )
state = GTK_STATE_ACTIVE;
else if ( flags & wxCONTROL_DISABLED )
state = GTK_STATE_INSENSITIVE;
else if ( flags & wxCONTROL_CURRENT )
state = GTK_STATE_PRELIGHT;
else
state = GTK_STATE_NORMAL;
gtk_paint_box
(
button->style,
wdc.m_window,
state,
flags & wxCONTROL_PRESSED ? GTK_SHADOW_IN : GTK_SHADOW_OUT,
NULL,
button,
"button",
rect.x, rect.y, rect.width, rect.height
);
// draw arrow on button
DrawDropArrow(win,dc,rect,flags);
} }
void void
@@ -492,3 +466,40 @@ wxRendererGTK::DrawCheckButton(wxWindow *win,
rect.x, rect.y, 13, 13 rect.x, rect.y, 13, 13
); );
} }
void
wxRendererGTK::DrawPushButton(wxWindow *win,
wxDC& dc,
const wxRect& rect,
int flags)
{
GtkWidget *button = GetButtonWidget();
// for reason why we do this, see DrawDropArrow
wxWindowDC& wdc = (wxWindowDC&)dc;
wxASSERT ( wdc.IsKindOf(CLASSINFO(wxWindowDC)) );
// draw button
GtkStateType state;
if ( flags & wxCONTROL_PRESSED )
state = GTK_STATE_ACTIVE;
else if ( flags & wxCONTROL_DISABLED )
state = GTK_STATE_INSENSITIVE;
else if ( flags & wxCONTROL_CURRENT )
state = GTK_STATE_PRELIGHT;
else
state = GTK_STATE_NORMAL;
gtk_paint_box
(
button->style,
wdc.m_window,
state,
flags & wxCONTROL_PRESSED ? GTK_SHADOW_IN : GTK_SHADOW_OUT,
NULL,
button,
"button",
rect.x, rect.y, rect.width, rect.height
);
}

View File

@@ -39,11 +39,18 @@
// tmschema.h is in Win32 Platform SDK and might not be available with earlier // tmschema.h is in Win32 Platform SDK and might not be available with earlier
// compilers // compilers
#ifndef CP_DROPDOWNBUTTON #ifndef CP_DROPDOWNBUTTON
#define BP_PUSHBUTTON 1
#define BP_CHECKBOX 3 #define BP_CHECKBOX 3
#define CBS_UNCHECKEDNORMAL 1 #define CBS_UNCHECKEDNORMAL 1
#define CBS_CHECKEDNORMAL (CBS_UNCHECKEDNORMAL + 4) #define CBS_CHECKEDNORMAL (CBS_UNCHECKEDNORMAL + 4)
#define CBS_MIXEDNORMAL (CBS_CHECKEDNORMAL + 4) #define CBS_MIXEDNORMAL (CBS_CHECKEDNORMAL + 4)
#define PBS_NORMAL 1
#define PBS_HOT 2
#define PBS_PRESSED 3
#define PBS_DISABLED 4
#define PBS_DEFAULTED 5
#define CP_DROPDOWNBUTTON 1 #define CP_DROPDOWNBUTTON 1
#define CBXS_NORMAL 1 #define CBXS_NORMAL 1
@@ -83,6 +90,11 @@ public:
const wxRect& rect, const wxRect& rect,
int flags = 0); int flags = 0);
virtual void DrawPushButton(wxWindow *win,
wxDC& dc,
const wxRect& rect,
int flags = 0);
private: private:
DECLARE_NO_COPY_CLASS(wxRendererMSW) DECLARE_NO_COPY_CLASS(wxRendererMSW)
}; };
@@ -127,6 +139,11 @@ public:
const wxRect& rect, const wxRect& rect,
int flags = 0); int flags = 0);
virtual void DrawPushButton(wxWindow *win,
wxDC& dc,
const wxRect& rect,
int flags = 0);
virtual wxSplitterRenderParams GetSplitterParams(const wxWindow *win); virtual wxSplitterRenderParams GetSplitterParams(const wxWindow *win);
private: private:
DECLARE_NO_COPY_CLASS(wxRendererXP) DECLARE_NO_COPY_CLASS(wxRendererXP)
@@ -179,6 +196,27 @@ wxRendererMSW::DrawComboBoxDropButton(wxWindow * WXUNUSED(win),
::DrawFrameControl(GetHdcOf(dc), &r, DFC_SCROLL, style); ::DrawFrameControl(GetHdcOf(dc), &r, DFC_SCROLL, style);
} }
void
wxRendererMSW::DrawPushButton(wxWindow * WXUNUSED(win),
wxDC& dc,
const wxRect& rect,
int flags)
{
RECT r;
r.left = rect.GetLeft();
r.top = rect.GetTop();
r.bottom = rect.y + rect.height;
r.right = rect.x + rect.width;
int style = DFCS_BUTTONPUSH;
if ( flags & wxCONTROL_DISABLED )
style |= DFCS_INACTIVE;
if ( flags & wxCONTROL_PRESSED )
style |= DFCS_PUSHED | DFCS_FLAT;
::DrawFrameControl(GetHdcOf(dc), &r, DFC_BUTTON, style);
}
// ============================================================================ // ============================================================================
// wxRendererXP implementation // wxRendererXP implementation
// ============================================================================ // ============================================================================
@@ -339,6 +377,46 @@ wxRendererXP::DrawCheckButton(wxWindow *win,
); );
} }
void
wxRendererXP::DrawPushButton(wxWindow * win,
wxDC& dc,
const wxRect& rect,
int flags)
{
wxUxThemeHandle hTheme(win, L"BUTTON");
if ( !hTheme )
{
m_rendererNative.DrawPushButton(win, dc, rect, flags);
return;
}
RECT r;
wxCopyRectToRECT(rect, r);
int state;
if ( flags & wxCONTROL_PRESSED )
state = PBS_PRESSED;
else if ( flags & wxCONTROL_CURRENT )
state = PBS_HOT;
else if ( flags & wxCONTROL_DISABLED )
state = PBS_DISABLED;
else if ( flags & wxCONTROL_ISDEFAULT )
state = PBS_DEFAULTED;
else
state = PBS_NORMAL;
wxUxThemeEngine::Get()->DrawThemeBackground
(
hTheme,
GetHdcOf(dc),
BP_PUSHBUTTON,
state,
&r,
NULL
);
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// splitter drawing // splitter drawing
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------