]> git.saurik.com Git - wxWidgets.git/blobdiff - src/os2/dcclient.cpp
*** empty log message ***
[wxWidgets.git] / src / os2 / dcclient.cpp
index 75ffabc6ff7b5998f4c8182176a351e9e98e504f..9fa35aa9d7530f126f210b7475e23c13918e7701 100644 (file)
@@ -1,11 +1,11 @@
 /////////////////////////////////////////////////////////////////////////////
 // Name:        dcclient.cpp
 // Purpose:     wxClientDC class
 /////////////////////////////////////////////////////////////////////////////
 // Name:        dcclient.cpp
 // Purpose:     wxClientDC class
-// Author:      Julian Smart
+// Author:      David Webster
 // Modified by:
 // Modified by:
-// Created:     01/02/97
+// Created:     09/21/99
 // RCS-ID:      $Id$
 // RCS-ID:      $Id$
-// Copyright:   (c) Julian Smart and Markus Holzem
+// Copyright:   (c) David Webster
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
 // headers
 // ----------------------------------------------------------------------------
 
 // headers
 // ----------------------------------------------------------------------------
 
-#ifdef __GNUG__
-    #pragma implementation "dcclient.h"
-#endif
-
 // For compilers that support precompilation, includes "wx.h".
 #include "wx/wxprec.h"
 
 // For compilers that support precompilation, includes "wx.h".
 #include "wx/wxprec.h"
 
-#ifdef __BORLANDC__
-    #pragma hdrstop
-#endif
-
 #include "wx/string.h"
 #include "wx/log.h"
 #include "wx/window.h"
 
 #include "wx/string.h"
 #include "wx/log.h"
 #include "wx/window.h"
 
-#include "wx/msw/private.h"
+#include "wx/os2/private.h"
 
 #include "wx/dcclient.h"
 
 
 #include "wx/dcclient.h"
 
@@ -62,17 +54,15 @@ WX_DEFINE_OBJARRAY(wxArrayDCInfo);
 // macros
 // ----------------------------------------------------------------------------
 
 // macros
 // ----------------------------------------------------------------------------
 
-#if !USE_SHARED_LIBRARY
     IMPLEMENT_DYNAMIC_CLASS(wxWindowDC, wxDC)
     IMPLEMENT_DYNAMIC_CLASS(wxClientDC, wxWindowDC)
     IMPLEMENT_DYNAMIC_CLASS(wxPaintDC, wxWindowDC)
     IMPLEMENT_DYNAMIC_CLASS(wxWindowDC, wxDC)
     IMPLEMENT_DYNAMIC_CLASS(wxClientDC, wxWindowDC)
     IMPLEMENT_DYNAMIC_CLASS(wxPaintDC, wxWindowDC)
-#endif
 
 // ----------------------------------------------------------------------------
 // global variables
 // ----------------------------------------------------------------------------
 
 
 // ----------------------------------------------------------------------------
 // global variables
 // ----------------------------------------------------------------------------
 
-static PAINTSTRUCT g_paintStruct;
+static RECT        g_paintStruct;
 
 #ifdef __WXDEBUG__
     // a global variable which we check to verify that wxPaintDC are only
 
 #ifdef __WXDEBUG__
     // a global variable which we check to verify that wxPaintDC are only
@@ -100,7 +90,19 @@ wxWindowDC::wxWindowDC(wxWindow *the_canvas)
   m_canvas = the_canvas;
   m_hDC = (WXHDC) ::WinOpenWindowDC(GetWinHwnd(the_canvas) );
   m_hDCCount++;
   m_canvas = the_canvas;
   m_hDC = (WXHDC) ::WinOpenWindowDC(GetWinHwnd(the_canvas) );
   m_hDCCount++;
-
+  //
+  // default under PM is that Window and Client DC's are the same
+  // so we offer a separate Presentation Space to use for the
+  // entire window.  Otherwise, calling BeginPaint will just create
+  // chached-micro client presentation space
+  //
+   m_hPS = GpiCreatePS( m_hab
+                       ,m_hDC
+                       ,&m_PageSize
+                       ,PU_PELS | GPIF_LONG | GPIA_ASSOC
+                      );
+  ::GpiAssociate(m_hPS, NULLHANDLE);
+  ::GpiAssociate(m_hPS, m_hDC);
   SetBackground(wxBrush(m_canvas->GetBackgroundColour(), wxSOLID));
 }
 
   SetBackground(wxBrush(m_canvas->GetBackgroundColour(), wxSOLID));
 }
 
@@ -113,8 +115,12 @@ wxWindowDC::~wxWindowDC()
     //
     // In PM one does not explicitly close or release an open WindowDC
     // They automatically close with the window, unless explicitly detached
     //
     // In PM one does not explicitly close or release an open WindowDC
     // They automatically close with the window, unless explicitly detached
+    // but we need to destroy our PS
     //
     //
-    m_hDC = 0;
+    ::GpiAssociate(m_hPS, NULLHANDLE);
+    ::GpiDestroyPS(m_hPS);
+    m_hPS = NULLHANDLE;
+    m_hDC = NULLHANDLE;
   }
 
   m_hDCCount--;
   }
 
   m_hDCCount--;
@@ -132,13 +138,15 @@ wxClientDC::wxClientDC()
 wxClientDC::wxClientDC(wxWindow *the_canvas)
 {
   m_canvas = the_canvas;
 wxClientDC::wxClientDC(wxWindow *the_canvas)
 {
   m_canvas = the_canvas;
-  m_hDC = (WXHDC) ::GetDC(GetWinHwnd(the_canvas));
 
 
-  // the background mode is only used for text background
-  // and is set in DrawText() to OPAQUE as required, other-
-  // wise always TRANSPARENT, RR
-  ::SetBkMode( GetHdc(), TRANSPARENT );
+  //
+  // default under PM is that Window and Client DC's are the same
+  //
+  m_hDC = (WXHDC) ::WinOpenWindowDC(GetWinHwnd(the_canvas));
 
 
+  //
+  // Default mode is BM_LEAVEALONE so we make no call Set the mix
+  //
   SetBackground(wxBrush(m_canvas->GetBackgroundColour(), wxSOLID));
 }
 
   SetBackground(wxBrush(m_canvas->GetBackgroundColour(), wxSOLID));
 }
 
@@ -148,7 +156,9 @@ wxClientDC::~wxClientDC()
   {
     SelectOldObjects(m_hDC);
 
   {
     SelectOldObjects(m_hDC);
 
-    ::ReleaseDC(GetWinHwnd(m_canvas), GetHdc());
+    // We don't explicitly release Device contexts in PM and
+    // the cached micro PS is already gone
+
     m_hDC = 0;
   }
 }
     m_hDC = 0;
   }
 }
@@ -183,12 +193,12 @@ wxPaintDC::wxPaintDC()
 
 wxPaintDC::wxPaintDC(wxWindow *canvas)
 {
 
 wxPaintDC::wxPaintDC(wxWindow *canvas)
 {
-    wxCHECK_RET( canvas, _T("NULL canvas in wxPaintDC ctor") );
+    wxCHECK_RET( canvas, wxT("NULL canvas in wxPaintDC ctor") );
 
 #ifdef __WXDEBUG__
     if ( g_isPainting <= 0 )
     {
 
 #ifdef __WXDEBUG__
     if ( g_isPainting <= 0 )
     {
-        wxFAIL_MSG( _T("wxPaintDC may be created only in EVT_PAINT handler!") );
+        wxFAIL_MSG( wxT("wxPaintDC may be created only in EVT_PAINT handler!") );
 
         return;
     }
 
         return;
     }
@@ -205,15 +215,9 @@ wxPaintDC::wxPaintDC(wxWindow *canvas)
     }
     else // not in cache, create a new one
     {
     }
     else // not in cache, create a new one
     {
-        m_hDC = (WXHDC)::BeginPaint(GetWinHwnd(m_canvas), &g_paintStruct);
+        m_hDC = (WXHDC)::WinBeginPaint(GetWinHwnd(m_canvas), NULLHANDLE, &g_paintStruct);
         ms_cache.Add(new wxPaintDCInfo(m_canvas, this));
     }
         ms_cache.Add(new wxPaintDCInfo(m_canvas, this));
     }
-
-    // the background mode is only used for text background
-    // and is set in DrawText() to OPAQUE as required, other-
-    // wise always TRANSPARENT, RR
-    ::SetBkMode( GetHdc(), TRANSPARENT );
-
     SetBackground(wxBrush(m_canvas->GetBackgroundColour(), wxSOLID));
 }
 
     SetBackground(wxBrush(m_canvas->GetBackgroundColour(), wxSOLID));
 }
 
@@ -226,11 +230,11 @@ wxPaintDC::~wxPaintDC()
         size_t index;
         wxPaintDCInfo *info = FindInCache(&index);
 
         size_t index;
         wxPaintDCInfo *info = FindInCache(&index);
 
-        wxCHECK_RET( info, _T("existing DC should have a cache entry") );
+        wxCHECK_RET( info, wxT("existing DC should have a cache entry") );
 
         if ( !--info->count )
         {
 
         if ( !--info->count )
         {
-            ::EndPaint(GetWinHwnd(m_canvas), &g_paintStruct);
+            ::WinEndPaint(m_hPS);
 
             ms_cache.Remove(index);
         }
 
             ms_cache.Remove(index);
         }