]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/renderer.cpp
moving all dataview files to advanced
[wxWidgets.git] / src / msw / renderer.cpp
index d5fe089eea3b92e6b471206b9798f36395921b42..8c31c761927c3a0cc4684f852283bf37e6efc17f 100644 (file)
 #define min(a,b)            (((a) < (b)) ? (a) : (b))
 #endif
 
+#include "wx/dcgraph.h"
 #include "gdiplus.h"
 using namespace Gdiplus;
-#endif
+#endif // wxUSE_GRAPHICS_CONTEXT
 
 // tmschema.h is in Win32 Platform SDK and might not be available with earlier
 // compilers
@@ -128,7 +129,7 @@ public:
         }
         else
 #endif
-            m_hdc = GetHdcOf(*dc);
+            m_hdc = GetHdcOf(*((wxMSWDCImpl*)dc->GetImpl()));
     }
 
     ~GraphicsHDC()
@@ -138,7 +139,7 @@ public:
             m_graphics->ReleaseHDC(m_hdc);
 #endif
     }
-    
+
     operator HDC() const { return m_hdc; }
 
 private:
@@ -161,11 +162,33 @@ private:
     #define DFCS_HOT 0x1000
 #endif
 
+// ----------------------------------------------------------------------------
+// methods common to wxRendererMSW and wxRendererXP
+// ----------------------------------------------------------------------------
+
+class wxRendererMSWBase : public wxDelegateRendererNative
+{
+public:
+    wxRendererMSWBase() { }
+    wxRendererMSWBase(wxRendererNative& rendererNative)
+        : wxDelegateRendererNative(rendererNative) { }
+
+    void DrawFocusRect(wxWindow * win,
+                        wxDC& dc,
+                        const wxRect& rect,
+                        int flags = 0);
+
+    void DrawItemSelectionRect(wxWindow *win,
+                                wxDC& dc,
+                                const wxRect& rect,
+                                int flags = 0);
+};
+
 // ----------------------------------------------------------------------------
 // wxRendererMSW: wxRendererNative implementation for "old" Win32 systems
 // ----------------------------------------------------------------------------
 
-class WXDLLEXPORT wxRendererMSW : public wxDelegateRendererNative
+class wxRendererMSW : public wxRendererMSWBase
 {
 public:
     wxRendererMSW() { }
@@ -187,29 +210,24 @@ public:
                                 const wxRect& rect,
                                 int flags = 0);
 
-    virtual void DrawFocusRect(wxWindow* win,
-                               wxDC& dc,
-                               const wxRect& rect,
-                               int flags = 0);
-
-    virtual void DrawChoice(wxWindow* win, 
-                            wxDC& dc, 
-                            const wxRect& rect, 
+    virtual void DrawChoice(wxWindow* win,
+                            wxDC& dc,
+                            const wxRect& rect,
                             int flags=0);
 
-    virtual void DrawComboBox(wxWindow* win, 
-                                wxDC& dc, 
-                                const wxRect& rect, 
+    virtual void DrawComboBox(wxWindow* win,
+                                wxDC& dc,
+                                const wxRect& rect,
                                 int flags=0);
 
-    virtual void DrawTextCtrl(wxWindow* win, 
-                                wxDC& dc, 
-                                const wxRect& rect, 
+    virtual void DrawTextCtrl(wxWindow* win,
+                                wxDC& dc,
+                                const wxRect& rect,
                                 int flags=0);
 
-    virtual void DrawRadioButton(wxWindow* win, 
-                                wxDC& dc, 
-                                const wxRect& rect, 
+    virtual void DrawRadioButton(wxWindow* win,
+                                wxDC& dc,
+                                const wxRect& rect,
                                 int flags=0);
 
     virtual wxSize GetCheckBoxSize(wxWindow *win);
@@ -217,7 +235,7 @@ public:
     virtual int GetHeaderButtonHeight(wxWindow *win);
 
 private:
-    DECLARE_NO_COPY_CLASS(wxRendererMSW)
+    wxDECLARE_NO_COPY_CLASS(wxRendererMSW);
 };
 
 // ----------------------------------------------------------------------------
@@ -226,10 +244,10 @@ private:
 
 #if wxUSE_UXTHEME
 
-class WXDLLEXPORT wxRendererXP : public wxDelegateRendererNative
+class wxRendererXP : public wxRendererMSWBase
 {
 public:
-    wxRendererXP() : wxDelegateRendererNative(wxRendererMSW::Get()) { }
+    wxRendererXP() : wxRendererMSWBase(wxRendererMSW::Get()) { }
 
     static wxRendererNative& Get();
 
@@ -268,19 +286,60 @@ public:
                                 const wxRect& rect,
                                 int flags = 0);
 
-    virtual void DrawItemSelectionRect(wxWindow *win,
-                                       wxDC& dc,
-                                       const wxRect& rect,
-                                       int flags = 0 );
-
-
     virtual wxSplitterRenderParams GetSplitterParams(const wxWindow *win);
 private:
-    DECLARE_NO_COPY_CLASS(wxRendererXP)
+    wxDECLARE_NO_COPY_CLASS(wxRendererXP);
 };
 
 #endif // wxUSE_UXTHEME
 
+
+// ============================================================================
+// wxRendererMSWBase implementation
+// ============================================================================
+
+void wxRendererMSWBase::DrawFocusRect(wxWindow * WXUNUSED(win),
+                                      wxDC& dc,
+                                      const wxRect& rect,
+                                      int WXUNUSED(flags))
+{
+    RECT rc;
+    wxCopyRectToRECT(rect, rc);
+
+    ::DrawFocusRect(GraphicsHDC(&dc), &rc);
+}
+
+void wxRendererMSWBase::DrawItemSelectionRect(wxWindow *win,
+                                              wxDC& dc,
+                                              const wxRect& rect,
+                                              int flags)
+{
+    wxBrush brush;
+    if ( flags & wxCONTROL_SELECTED )
+    {
+        if ( flags & wxCONTROL_FOCUSED )
+        {
+            brush = wxBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT));
+        }
+        else // !focused
+        {
+            brush = wxBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));
+        }
+    }
+    else // !selected
+    {
+        brush = *wxTRANSPARENT_BRUSH;
+    }
+
+    dc.SetBrush(brush);
+    dc.SetPen(*wxTRANSPARENT_PEN);
+    dc.DrawRectangle( rect );
+
+    if ((flags & wxCONTROL_FOCUSED) && (flags & wxCONTROL_CURRENT))
+        DrawFocusRect( win, dc, rect, flags );
+}
+
+
 // ============================================================================
 // wxRendererNative and wxRendererMSW implementation
 // ============================================================================
@@ -320,7 +379,7 @@ wxRendererMSW::DrawComboBoxDropButton(wxWindow * WXUNUSED(win),
     if ( flags & wxCONTROL_PRESSED )
         style |= DFCS_PUSHED | DFCS_FLAT;
 
-    ::DrawFrameControl(GraphicsHDC((wxMSWDCImpl*)dc.GetImpl()).HDC(), &r, DFC_SCROLL, style);
+    ::DrawFrameControl(GraphicsHDC(&dc), &r, DFC_SCROLL, style);
 }
 
 void
@@ -344,7 +403,7 @@ wxRendererMSW::DrawCheckBox(wxWindow * WXUNUSED(win),
     if ( flags & wxCONTROL_CURRENT )
         style |= DFCS_HOT;
 
-    ::DrawFrameControl(GraphicsHDC((wxMSWDCImpl*)dc.GetImpl()).HDC(), &r, DFC_BUTTON, style);
+    ::DrawFrameControl(GraphicsHDC(&dc), &r, DFC_BUTTON, style);
 }
 
 void
@@ -373,18 +432,7 @@ wxRendererMSW::DrawPushButton(wxWindow * WXUNUSED(win),
     RECT rc;
     wxCopyRectToRECT(rect, rc);
 
-    ::DrawFrameControl(GraphicsHDC((wxMSWDCImpl*)dc.GetImpl()).HDC(), &rc, DFC_BUTTON, style);
-}
-
-void wxRendererMSW::DrawFocusRect(wxWindow * WXUNUSED(win),
-                                  wxDC& dc,
-                                  const wxRect& rect,
-                                  int WXUNUSED(flags))
-{
-    RECT rc;
-    wxCopyRectToRECT(rect, rc);
-
-    ::DrawFocusRect(GraphicsHDC((wxMSWDCImpl*)dc.GetImpl()).HDC(), &rc);
+    ::DrawFrameControl(GraphicsHDC(&dc), &rc, DFC_BUTTON, style);
 }
 
 wxSize wxRendererMSW::GetCheckBoxSize(wxWindow * WXUNUSED(win))
@@ -422,7 +470,7 @@ void wxRendererMSW::DrawTextCtrl(wxWindow* win, wxDC& dc, const wxRect& rect, in
     wxColour fill;
     wxColour bdr;
     COLORREF cref;
-    
+
 #if wxUSE_UXTHEME
     wxUxThemeHandle hTheme(win, L"EDIT");
     if (hTheme)
@@ -436,10 +484,10 @@ void wxRendererMSW::DrawTextCtrl(wxWindow* win, wxDC& dc, const wxRect& rect, in
             etsState = ETS_DISABLED;
         else
             etsState = ETS_NORMAL;
-        
+
         wxUxThemeEngine::Get()->GetThemeColor(hTheme, EP_EDITTEXT,
                                               etsState, TMT_BORDERCOLOR, &cref);
-        bdr = wxRGBToColour(cref);        
+        bdr = wxRGBToColour(cref);
     }
     else
 #endif
@@ -447,7 +495,7 @@ void wxRendererMSW::DrawTextCtrl(wxWindow* win, wxDC& dc, const wxRect& rect, in
         fill = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
         bdr = *wxBLACK;
     }
-    
+
     dc.SetPen( bdr );
     dc.SetBrush( fill );
     dc.DrawRectangle(rect);
@@ -458,8 +506,8 @@ void wxRendererMSW::DrawTextCtrl(wxWindow* win, wxDC& dc, const wxRect& rect, in
 void wxRendererMSW::DrawComboBox(wxWindow* win, wxDC& dc, const wxRect& rect, int flags)
 {
     // Draw the main part of the control same as TextCtrl
-    DrawTextCtrl(win, dc, rect, flags);    
-    
+    DrawTextCtrl(win, dc, rect, flags);
+
     // Draw the button inside the border, on the right side
     wxRect br(rect);
     br.height -= 2;
@@ -477,7 +525,7 @@ void wxRendererMSW::DrawChoice(wxWindow* win, wxDC& dc,
     DrawComboBox(win, dc, rect, flags);
 }
 
-    
+
 // Draw a themed radio button
 void wxRendererMSW::DrawRadioButton(wxWindow* win, wxDC& dc, const wxRect& rect, int flags)
 {
@@ -513,7 +561,7 @@ void wxRendererMSW::DrawRadioButton(wxWindow* win, wxDC& dc, const wxRect& rect,
     wxUxThemeEngine::Get()->DrawThemeBackground
                             (
                                 hTheme,
-                                GraphicsHDC(&dc).HDC(),
+                                GraphicsHDC(&dc),
                                 BP_RADIOBUTTON,
                                 state,
                                 &r,
@@ -739,38 +787,6 @@ wxRendererXP::DrawPushButton(wxWindow * win,
                             );
 }
 
-void
-wxRendererXP::DrawItemSelectionRect(wxWindow *win,
-                                    wxDC& dc,
-                                    const wxRect& rect,
-                                    int flags)
-{
-    wxBrush brush;
-    if ( flags & wxCONTROL_SELECTED )
-    {
-        if ( flags & wxCONTROL_FOCUSED )
-        {
-            brush = wxBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT));
-        }
-        else // !focused
-        {
-            brush = wxBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));
-        }
-    }
-    else // !selected
-    {
-        brush = *wxTRANSPARENT_BRUSH;
-    }
-
-    dc.SetBrush(brush);
-    dc.SetPen(*wxTRANSPARENT_PEN);
-    dc.DrawRectangle( rect );
-
-    if ((flags & wxCONTROL_FOCUSED) && (flags & wxCONTROL_CURRENT))
-        DrawFocusRect( win, dc, rect, flags );
-}
-
-
 
 // ----------------------------------------------------------------------------
 // splitter drawing