]> git.saurik.com Git - wxWidgets.git/commitdiff
added wxDC::CopyAttributes() and use it in wxBufferedDC to ensure that wxAutoBuffered...
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 31 May 2009 19:40:04 +0000 (19:40 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 31 May 2009 19:40:04 +0000 (19:40 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@60846 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/changes.txt
include/wx/dc.h
include/wx/dcbuffer.h
interface/wx/dc.h
src/common/dcbase.cpp

index ec02b9d205653203777a9926f5c4b3ec8710f507..ee3eab7fb96497f817bb906fa633829900be0a4a 100644 (file)
@@ -341,6 +341,7 @@ All (GUI):
 - Added wxMouseEventsManager.
 - Building OpenGL library is now enabled by default.
 - Improve wxTreeCtrl::ScrollTo() in generic version (Raanan Barzel).
+- Added wxDC::CopyAttributes() and use it in wxBufferedDC.
 
 MSW:
 
index b9283143868731be6805bd441b80f988f4c3de04..aa5110066df80a6335d2fd4432b9f88e6e9f838e 100644 (file)
@@ -702,6 +702,9 @@ private:
 class WXDLLIMPEXP_CORE wxDC : public wxObject
 {
 public:
+    // copy attributes (font, colours and writing direction) from another DC
+    void CopyAttributes(const wxDC& dc);
+
     virtual ~wxDC() { delete m_pimpl; }
 
     wxDCImpl *GetImpl()
index 4d5b4087124d476a8995c6bb6aca1589ae3b6442..e5c45a8247f1c4ba56d5cc13b71b72b680c123f1 100644 (file)
@@ -118,8 +118,8 @@ private:
         m_style = style;
 
         // inherit the same layout direction as the original DC
-        if (dc && dc->IsOk())
-            SetLayoutDirection(dc->GetLayoutDirection());
+        if ( dc && dc->IsOk() )
+            CopyAttributes(*dc);
     }
 
     // check that the bitmap is valid and use it
index a9ebbb3eabd544ecffae8956895b63e40c0c0038..1e4e08bc1a9aced71883fe56ce82c6e078ba7a15 100644 (file)
@@ -1122,6 +1122,19 @@ public:
     //@}
 
 
+    /**
+        Copy attributes from another DC.
+
+        The copied attributes currently are:
+            - Font
+            - Text foreground and background colours
+            - Background brush
+            - Layout direction
+
+        @param dc
+            A valid (i.e. its IsOk() must return @true) source device context.
+     */
+    void CopyAttributes(const wxDC& dc);
 
     /**
         Returns the depth (number of bits/pixel) of this DC.
index 1742bf8dadf501062060326c5f9ef153588d4b10..3427fe362ea357a1bb2591ffdea01de541eeb3ab 100644 (file)
@@ -1115,7 +1115,8 @@ void wxDCImpl::InheritAttributes(wxWindow *win)
     SetFont(win->GetFont());
     SetTextForeground(win->GetForegroundColour());
     SetTextBackground(win->GetBackgroundColour());
-    SetBackground(wxBrush(win->GetBackgroundColour()));
+    SetBackground(win->GetBackgroundColour());
+    SetLayoutDirection(win->GetLayoutDirection());
 }
 
 //-----------------------------------------------------------------------------
@@ -1124,6 +1125,15 @@ void wxDCImpl::InheritAttributes(wxWindow *win)
 
 IMPLEMENT_ABSTRACT_CLASS(wxDC, wxObject)
 
+void wxDC::CopyAttributes(const wxDC& dc)
+{
+    SetFont(dc.GetFont());
+    SetTextForeground(dc.GetTextForeground());
+    SetTextBackground(dc.GetTextBackground());
+    SetBackground(dc.GetBackground());
+    SetLayoutDirection(dc.GetLayoutDirection());
+}
+
 void wxDC::DrawLabel(const wxString& text,
                          const wxBitmap& bitmap,
                          const wxRect& rect,