]> git.saurik.com Git - wxWidgets.git/commitdiff
Committed Jaako's renderer patch
authorRobert Roebling <robert@roebling.de>
Mon, 24 Apr 2006 16:57:27 +0000 (16:57 +0000)
committerRobert Roebling <robert@roebling.de>
Mon, 24 Apr 2006 16:57:27 +0000 (16:57 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@38891 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/latex/wx/renderer.tex
include/wx/renderer.h
src/generic/renderg.cpp
src/gtk/renderer.cpp
src/msw/renderer.cpp

index ec48042f025f19d0eb25a57e7ec592fb6394bdfa..9678cb65ae6deaaaa1c69d343d1baf6dc4e9d24d 100644 (file)
@@ -68,7 +68,8 @@ enum
     wxCONTROL_CURRENT    = 0x00000010,  // mouse is currently over the control
     wxCONTROL_SELECTED   = 0x00000020,  // selected item in e.g. listbox
     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}
 
@@ -91,6 +92,16 @@ No 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}
 
 \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}).
 
 
+\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}
 
 \func{void}{DrawSplitterBorder}{\param{wxWindow* }{win}, \param{wxDC\& }{dc}, \param{const wxRect\& }{rect}, \param{int }{flags = 0}}
index 8a8076c484cd78f190383ab66a4d2cdc495f0563..9d21e8db1d5759c2b55d57548be90e7910b4ffa7 100644 (file)
@@ -170,7 +170,6 @@ public:
                                const wxRect& rect,
                                int flags = 0) = 0;
 
-
     // draw check button
     //
     // flags may use wxCONTROL_CHECKED, wxCONTROL_UNDETERMINED and wxCONTROL_CURRENT
@@ -178,7 +177,15 @@ public:
                                  wxDC& dc,
                                  const wxRect& rect,
                                  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
     // ------------------
 
@@ -286,7 +293,13 @@ public:
                                  const wxRect& rect,
                                  int flags = 0 )
         { 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)
         { return m_rendererNative.GetSplitterParams(win); }
 
index 53e31a830f14bb23ca852e171f8ddb09f65fcf20..41a5bd65ff46901502d2fc2c4b465480699848ea 100644 (file)
@@ -82,7 +82,12 @@ public:
                                  wxDC& dc,
                                  const wxRect& rect,
                                  int flags = 0);
-                                 
+
+    virtual void DrawPushButton(wxWindow *win,
+                                wxDC& dc,
+                                const wxRect& rect,
+                                int flags = 0);
+
     virtual wxSplitterRenderParams GetSplitterParams(const wxWindow *win);
 
     virtual wxRendererVersion GetVersion() const
@@ -360,21 +365,12 @@ void
 wxRendererGeneric::DrawComboBoxDropButton(wxWindow *win,
                                           wxDC& dc,
                                           const wxRect& rect,
-                                          int WXUNUSED(flags))
+                                          int flags)
 {
-    // Creating a generic button background that would actually be
-    // useful is rather difficult to accomplish. Best compromise
-    // 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);
+    DrawPushButton(win,dc,rect,flags);
+    DrawDropArrow(win,dc,rect,flags);
 }
 
-
 void
 wxRendererGeneric::DrawDropArrow(wxWindow *win,
                                  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.
 // ----------------------------------------------------------------------------
index e4a3f236b76a9af070eaf13afa6b6bd3df1cc030..53ab9e764bb6d50857a3486c010ffc5297c980a7 100644 (file)
@@ -82,13 +82,18 @@ public:
                                  wxDC& dc,
                                  const wxRect& rect,
                                  int flags = 0);
-                                 
+
+    virtual void DrawPushButton(wxWindow *win,
+                                wxDC& dc,
+                                const wxRect& rect,
+                                int flags = 0);
+
     virtual wxSplitterRenderParams GetSplitterParams(const wxWindow *win);
 
 private:
     // FIXME: shouldn't we destroy these windows somewhere?
 
-    // used by DrawHeaderButton and DrawComboBoxDropButton
+    // used by DrawHeaderButton and DrawPushButton
     static GtkWidget *GetButtonWidget();
 
     // used by DrawTreeItemButton()
@@ -185,7 +190,7 @@ wxRendererGTK::DrawHeaderButton(wxWindow *win,
     (
         button->style,
         // 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,
         flags & wxCONTROL_DISABLED ? GTK_STATE_INSENSITIVE : GTK_STATE_NORMAL,
         GTK_SHADOW_OUT,
@@ -422,13 +427,22 @@ wxRendererGTK::DrawComboBoxDropButton(wxWindow *win,
                                       const wxRect& rect,
                                       int flags)
 {
-    GtkWidget *button = GetButtonWidget();
+    DrawPushButton(win,dc,rect,flags);
+    DrawDropArrow(win,dc,rect);
+}
+
+void 
+wxRendererGTK::DrawCheckButton(wxWindow *win,
+                                 wxDC& dc,
+                                 const wxRect& rect,
+                                 int flags )
+{
+    GtkWidget *button = GetCheckButtonWidget();
 
     // 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 )
@@ -439,36 +453,33 @@ wxRendererGTK::DrawComboBoxDropButton(wxWindow *win,
         state = GTK_STATE_PRELIGHT;
     else
         state = GTK_STATE_NORMAL;
-
-    gtk_paint_box
+    
+    gtk_paint_check
     (
         button->style,
         wdc.m_window,
         state,
-        flags & wxCONTROL_PRESSED ? GTK_SHADOW_IN : GTK_SHADOW_OUT,
+        flags & wxCONTROL_CHECKED ? GTK_SHADOW_IN : GTK_SHADOW_OUT,
         NULL,
         button,
-        "button",
-        rect.x, rect.y, rect.width, rect.height
+        "cellcheck",
+        rect.x, rect.y, 13, 13
     );
-
-    // draw arrow on button
-    DrawDropArrow(win,dc,rect,flags);
-
 }
 
-void 
-wxRendererGTK::DrawCheckButton(wxWindow *win,
-                                 wxDC& dc,
-                                 const wxRect& rect,
-                                 int flags )
+void
+wxRendererGTK::DrawPushButton(wxWindow *win,
+                              wxDC& dc,
+                              const wxRect& rect,
+                              int flags)
 {
-    GtkWidget *button = GetCheckButtonWidget();
+    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 )
@@ -479,16 +490,16 @@ wxRendererGTK::DrawCheckButton(wxWindow *win,
         state = GTK_STATE_PRELIGHT;
     else
         state = GTK_STATE_NORMAL;
-    
-    gtk_paint_check
+
+    gtk_paint_box
     (
         button->style,
         wdc.m_window,
         state,
-        flags & wxCONTROL_CHECKED ? GTK_SHADOW_IN : GTK_SHADOW_OUT,
+        flags & wxCONTROL_PRESSED ? GTK_SHADOW_IN : GTK_SHADOW_OUT,
         NULL,
         button,
-        "cellcheck",
-        rect.x, rect.y, 13, 13
+        "button",
+        rect.x, rect.y, rect.width, rect.height
     );
 }
index 4763dfe7bdec6d4f1c9319a2e27f750961148302..ca355bdf172605987f82be7d27f811a700712e3a 100644 (file)
 // tmschema.h is in Win32 Platform SDK and might not be available with earlier
 // compilers
 #ifndef CP_DROPDOWNBUTTON
+    #define BP_PUSHBUTTON      1
     #define BP_CHECKBOX        3
     #define CBS_UNCHECKEDNORMAL 1
     #define CBS_CHECKEDNORMAL   (CBS_UNCHECKEDNORMAL + 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 CBXS_NORMAL        1
@@ -83,6 +90,11 @@ public:
                                         const wxRect& rect,
                                         int flags = 0);
 
+    virtual void DrawPushButton(wxWindow *win,
+                                wxDC& dc,
+                                const wxRect& rect,
+                                int flags = 0);
+
 private:
     DECLARE_NO_COPY_CLASS(wxRendererMSW)
 };
@@ -127,6 +139,11 @@ public:
                                  const wxRect& rect,
                                  int flags = 0);
 
+    virtual void DrawPushButton(wxWindow *win,
+                                wxDC& dc,
+                                const wxRect& rect,
+                                int flags = 0);
+
     virtual wxSplitterRenderParams GetSplitterParams(const wxWindow *win);
 private:
     DECLARE_NO_COPY_CLASS(wxRendererXP)
@@ -179,6 +196,27 @@ wxRendererMSW::DrawComboBoxDropButton(wxWindow * WXUNUSED(win),
     ::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
 // ============================================================================
@@ -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
 // ----------------------------------------------------------------------------