]> git.saurik.com Git - wxWidgets.git/commitdiff
Improved wxDCPen/BrushChangers.
authorWłodzimierz Skiba <abx@abx.art.pl>
Tue, 23 May 2006 14:11:55 +0000 (14:11 +0000)
committerWłodzimierz Skiba <abx@abx.art.pl>
Tue, 23 May 2006 14:11:55 +0000 (14:11 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@39289 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/dc.h
src/generic/renderg.cpp

index e82459096650dfd9c7c3a6196d332ec7b0761ce2..84cd83b9b40203c05e52861784819e8f089bb1d9 100644 (file)
@@ -876,7 +876,10 @@ private:
 class WXDLLEXPORT wxDCPenChanger
 {
 public:
-    wxDCPenChanger(wxDC& dc) : m_dc(dc), m_penOld() { }
+    wxDCPenChanger(wxDC& dc, const wxPen& pen) : m_dc(dc), m_penOld(dc.GetPen())
+    {
+        m_dc.SetPen(pen);
+    }
 
     ~wxDCPenChanger()
     {
@@ -884,13 +887,6 @@ public:
             m_dc.SetPen(m_penOld);
     }
 
-    void Set(const wxPen& pen)
-    {
-        if ( !m_penOld.Ok() )
-            m_penOld = m_dc.GetPen();
-        m_dc.SetPen(pen);
-    }
-
 private:
     wxDC& m_dc;
 
@@ -907,7 +903,10 @@ private:
 class WXDLLEXPORT wxDCBrushChanger
 {
 public:
-    wxDCBrushChanger(wxDC& dc) : m_dc(dc), m_brushOld() { }
+    wxDCBrushChanger(wxDC& dc, const wxBrush& brush) : m_dc(dc), m_brushOld(dc.GetBrush())
+    {
+        m_dc.SetBrush(brush);
+    }
 
     ~wxDCBrushChanger()
     {
@@ -915,13 +914,6 @@ public:
             m_dc.SetBrush(m_brushOld);
     }
 
-    void Set(const wxBrush& brush)
-    {
-        if ( !m_brushOld.Ok() )
-            m_brushOld = m_dc.GetBrush();
-        m_dc.SetBrush(brush);
-    }
-
 private:
     wxDC& m_dc;
 
index b1b8fc76c4b76fdc92b48bae7a4b0d856adac156..0a4a4391d540b2f40eca89dba5833f11d16d93fc 100644 (file)
@@ -232,12 +232,8 @@ wxRendererGeneric::DrawTreeItemButton(wxWindow * WXUNUSED(win),
                                       int flags)
 {
     // store settings
-    wxDCPenChanger penChanger(dc);
-    wxDCBrushChanger brushChanger(dc);
-
-    // white background
-    penChanger.Set(*wxGREY_PEN);
-    brushChanger.Set(*wxWHITE_BRUSH);
+    wxDCPenChanger penChanger(dc, *wxGREY_PEN);
+    wxDCBrushChanger brushChanger(dc, *wxWHITE_BRUSH);
 
     dc.DrawRectangle(rect);