]> git.saurik.com Git - wxWidgets.git/blobdiff - src/os2/dc.cpp
Moving y pos transofrmation code to wxOS2::wxDC elimiantes need for some #ifdef __WXP...
[wxWidgets.git] / src / os2 / dc.cpp
index 7b85941824dbeff829bde59609848c0bbd45eb7c..c43a2d31933e6fcf5193874c5416f26810669daf 100644 (file)
@@ -22,6 +22,7 @@
     #include "wx/dcmemory.h"
     #include "wx/log.h"
     #include "wx/icon.h"
+    #include "wx/msgdlg.h"
 #endif
 
 #include "wx/dcprint.h"
@@ -143,16 +144,42 @@ wxDC::wxDC(void)
 
     m_bOwnsDC      = FALSE;
     m_hDC          = 0;
-    m_nDCCount     = 0;
     m_hOldPS       = NULL;
     m_hPS          = NULL;
     m_bIsPaintTime = FALSE; // True at Paint Time
     m_brush.GetColour().Set("WHITE");
-}
+} // end of wxDC::wxDC
 
 wxDC::~wxDC(void)
 {
-}
+    if ( m_hDC != 0 )
+    {
+        SelectOldObjects(m_hDC);
+
+        // if we own the HDC, we delete it, otherwise we just release it
+
+        if (m_bOwnsDC)
+        {
+            if(m_hPS)
+            {
+                ::GpiAssociate(m_hPS, NULLHANDLE);
+                ::GpiDestroyPS(m_hPS);
+            }
+            m_hPS = NULLHANDLE;
+            ::DevCloseDC((HDC)m_hDC);
+        }
+        else
+        {
+            //
+            // Just Dissacociate, not destroy if we don't own the DC
+            //
+            if(m_hPS)
+            {
+                ::GpiAssociate(m_hPS, NULLHANDLE);
+            }
+        }
+    }
+} // end of wxDC::~wxDC
 
 // This will select current objects out of the DC,
 // which is what you have to do before deleting the
@@ -187,7 +214,7 @@ void wxDC::SelectOldObjects(
     m_font            = wxNullFont;
     m_backgroundBrush = wxNullBrush;
     m_vSelectedBitmap = wxNullBitmap;
-}
+} // end of wxDC::SelectOldObjects
 
 // ---------------------------------------------------------------------------
 // clipping