1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxClientDC class
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "dcclient.h"
17 #pragma implementation
18 #pragma implementation "dcclient.h"
21 // For compilers that support precompilation, includes "wx.h".
22 #include "wx/wxprec.h"
31 #include "wx/dcclient.h"
35 #if !USE_SHARED_LIBRARY
36 IMPLEMENT_DYNAMIC_CLASS(wxClientDC
, wxDC
)
37 IMPLEMENT_DYNAMIC_CLASS(wxWindowDC
, wxDC
)
38 IMPLEMENT_DYNAMIC_CLASS(wxPaintDC
, wxDC
)
41 wxClientDC::wxClientDC(void)
46 wxClientDC::wxClientDC(wxWindow
*the_canvas
)
48 m_canvas
= the_canvas
;
50 m_hDC
= (WXHDC
) ::GetDC((HWND
) the_canvas
->GetHWND());
53 wxClientDC::~wxClientDC(void)
57 if (m_canvas
&& (HDC
) m_hDC
)
59 SelectOldObjects(m_hDC
);
61 ::ReleaseDC((HWND
) m_canvas
->GetHWND(), (HDC
) m_hDC
);
66 wxWindowDC::wxWindowDC(void)
71 wxWindowDC::wxWindowDC(wxWindow
*the_canvas
)
73 m_canvas
= the_canvas
;
74 // m_hDC = (WXHDC) ::GetDCEx((HWND) the_canvas->GetHWND(), NULL, DCX_WINDOW);
75 m_hDC
= (WXHDC
) ::GetWindowDC((HWND
) the_canvas
->GetHWND() );
79 wxWindowDC::~wxWindowDC(void)
81 if (m_canvas
&& m_hDC
)
83 SelectOldObjects(m_hDC
);
85 ::ReleaseDC((HWND
) m_canvas
->GetHWND(), (HDC
) m_hDC
);
91 wxPaintDC::wxPaintDC(void)
96 static PAINTSTRUCT g_paintStruct
;
98 // Don't call Begin/EndPaint if it's already been called:
99 // for example, if calling a base class OnPaint.
101 WXHDC
wxPaintDC::m_staticPaintHDC
= 0;
102 int wxPaintDC::m_staticPaintCount
= 0;
104 wxPaintDC::wxPaintDC(wxWindow
*the_canvas
)
106 if ( the_canvas
&& (m_staticPaintCount
== 0))
108 m_hDC
= (WXHDC
) ::BeginPaint((HWND
) the_canvas
->GetHWND(), &g_paintStruct
);
110 m_staticPaintCount
++ ;
111 m_staticPaintHDC
= m_hDC
;
115 wxDebugMsg("wxPaintDC: Using existing HDC\n");
116 m_hDC
= m_staticPaintHDC
;
119 m_canvas
= the_canvas
;
120 RECT updateRect1
= g_paintStruct
.rcPaint
;
121 m_canvas
->m_updateRect
.x
= updateRect1
.left
;
122 m_canvas
->m_updateRect
.y
= updateRect1
.top
;
123 m_canvas
->m_updateRect
.width
= updateRect1
.right
- updateRect1
.left
;
124 m_canvas
->m_updateRect
.height
= updateRect1
.bottom
- updateRect1
.top
;
125 // m_canvas->m_paintHDC = m_staticPaintHDC ;
128 wxPaintDC::~wxPaintDC(void)
130 m_staticPaintCount
-- ;
132 if (m_staticPaintCount
== 0)
134 // m_canvas->m_paintHDC = 0;
136 if ( m_hDC
&& m_canvas
)
138 ::EndPaint((HWND
) m_canvas
->GetHWND(), &g_paintStruct
);
143 wxDebugMsg("~wxPaintDC: Did not release HDC\n");
145 m_staticPaintHDC
= 0 ;
149 wxDebugMsg("~wxPaintDC: Did not release HDC\n");