]> git.saurik.com Git - wxWidgets.git/commitdiff
added HDCClipper() class which automatically unselects clipping region in its dtor
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 10 Apr 2005 11:30:37 +0000 (11:30 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 10 Apr 2005 11:30:37 +0000 (11:30 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@33468 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/msw/private.h

index 873855f0beb884f25a77584f9ae1f7d916e92c61..1b4729ab228191b7795b91baa41cfde12c5fa9eb 100644 (file)
@@ -449,6 +449,28 @@ public:
     operator HRGN() const { return (HRGN)GetObject(); }
 };
 
     operator HRGN() const { return (HRGN)GetObject(); }
 };
 
+// class sets the specified clipping region during its life time
+class HDCClipper
+{
+public:
+    HDCClipper(HDC hdc, HRGN hrgn)
+        : m_hdc(hdc)
+    {
+        if ( !::SelectClipRgn(hdc, hrgn) )
+            wxLogLastError(_T("SelectClipRgn"));
+    }
+
+    ~HDCClipper()
+    {
+        ::SelectClipRgn(m_hdc, NULL);
+    }
+
+private:
+    HDC m_hdc;
+
+    DECLARE_NO_COPY_CLASS(HDCClipper)
+};
+
 // when working with global pointers (which is unfortunately still necessary
 // sometimes, e.g. for clipboard) it is important to unlock them exactly as
 // many times as we lock them which just asks for using a "smart lock" class
 // when working with global pointers (which is unfortunately still necessary
 // sometimes, e.g. for clipboard) it is important to unlock them exactly as
 // many times as we lock them which just asks for using a "smart lock" class