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"
36 #if !USE_SHARED_LIBRARY
37 IMPLEMENT_DYNAMIC_CLASS(wxClientDC
, wxDC
)
38 IMPLEMENT_DYNAMIC_CLASS(wxWindowDC
, wxDC
)
39 IMPLEMENT_DYNAMIC_CLASS(wxPaintDC
, wxDC
)
42 wxClientDC::wxClientDC(void)
47 wxClientDC::wxClientDC(wxWindow
*the_canvas
)
49 m_canvas
= the_canvas
;
51 m_hDC
= (WXHDC
) ::GetDC((HWND
) the_canvas
->GetHWND());
54 wxClientDC::~wxClientDC(void)
58 if (m_canvas
&& (HDC
) m_hDC
)
60 SelectOldObjects(m_hDC
);
62 ::ReleaseDC((HWND
) m_canvas
->GetHWND(), (HDC
) m_hDC
);
67 wxWindowDC::wxWindowDC(void)
72 wxWindowDC::wxWindowDC(wxWindow
*the_canvas
)
74 m_canvas
= the_canvas
;
75 // m_hDC = (WXHDC) ::GetDCEx((HWND) the_canvas->GetHWND(), NULL, DCX_WINDOW);
76 m_hDC
= (WXHDC
) ::GetWindowDC((HWND
) the_canvas
->GetHWND() );
80 wxWindowDC::~wxWindowDC(void)
82 if (m_canvas
&& m_hDC
)
84 SelectOldObjects(m_hDC
);
86 ::ReleaseDC((HWND
) m_canvas
->GetHWND(), (HDC
) m_hDC
);
92 wxPaintDC::wxPaintDC(void)
97 static PAINTSTRUCT g_paintStruct
;
99 // Don't call Begin/EndPaint if it's already been called:
100 // for example, if calling a base class OnPaint.
102 WXHDC
wxPaintDC::ms_PaintHDC
= 0;
103 uint
wxPaintDC::ms_PaintCount
= 0; // count of ms_PaintHDC usage
105 wxPaintDC::wxPaintDC(wxWindow
*canvas
)
107 wxCHECK_RET( canvas
, "NULL canvas in wxPaintDC ctor" );
110 if ( ms_PaintCount
> 0 ) {
111 // it means that we've already called BeginPaint and so we must just
112 // reuse the same HDC (BeginPaint shouldn't be called more than once)
113 wxASSERT( ms_PaintHDC
);
120 m_hDC
= (WXHDC
)::BeginPaint((HWND
)m_canvas
->GetHWND(), &g_paintStruct
);
126 wxPaintDC::~wxPaintDC()
129 if ( !--ms_PaintCount
) {
130 ::EndPaint((HWND
)m_canvas
->GetHWND(), &g_paintStruct
);
135 //else: ms_PaintHDC still in use