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"
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
26 #include "wx/dcclient.h"
31 #if !USE_SHARED_LIBRARY
32 IMPLEMENT_DYNAMIC_CLASS(wxClientDC
, wxDC
)
33 IMPLEMENT_DYNAMIC_CLASS(wxWindowDC
, wxDC
)
34 IMPLEMENT_DYNAMIC_CLASS(wxPaintDC
, wxDC
)
37 wxClientDC::wxClientDC(void)
42 wxClientDC::wxClientDC(wxWindow
*the_canvas
)
44 m_canvas
= the_canvas
;
46 m_hDC
= (WXHDC
) ::GetDC((HWND
) the_canvas
->GetHWND());
49 wxClientDC::~wxClientDC(void)
53 if (m_canvas
&& (HDC
) m_hDC
)
55 SelectOldObjects(m_hDC
);
57 ::ReleaseDC((HWND
) m_canvas
->GetHWND(), (HDC
) m_hDC
);
62 wxWindowDC::wxWindowDC(void)
67 wxWindowDC::wxWindowDC(wxWindow
*the_canvas
)
69 m_canvas
= the_canvas
;
70 // m_hDC = (WXHDC) ::GetDCEx((HWND) the_canvas->GetHWND(), NULL, DCX_WINDOW);
71 m_hDC
= (WXHDC
) ::GetWindowDC((HWND
) the_canvas
->GetHWND() );
75 wxWindowDC::~wxWindowDC(void)
77 if (m_canvas
&& m_hDC
)
79 SelectOldObjects(m_hDC
);
81 ::ReleaseDC((HWND
) m_canvas
->GetHWND(), (HDC
) m_hDC
);
87 wxPaintDC::wxPaintDC(void)
92 static PAINTSTRUCT g_paintStruct
;
94 // Don't call Begin/EndPaint if it's already been called:
95 // for example, if calling a base class OnPaint.
97 WXHDC
wxPaintDC::ms_PaintHDC
= 0;
98 size_t wxPaintDC::ms_PaintCount
= 0; // count of ms_PaintHDC usage
100 wxPaintDC::wxPaintDC(wxWindow
*canvas
)
102 wxCHECK_RET( canvas
, "NULL canvas in wxPaintDC ctor" );
105 if ( ms_PaintCount
> 0 ) {
106 // it means that we've already called BeginPaint and so we must just
107 // reuse the same HDC (BeginPaint shouldn't be called more than once)
108 wxASSERT( ms_PaintHDC
);
115 m_hDC
= (WXHDC
)::BeginPaint((HWND
)m_canvas
->GetHWND(), &g_paintStruct
);
121 wxPaintDC::~wxPaintDC()
124 if ( !--ms_PaintCount
) {
125 ::EndPaint((HWND
)m_canvas
->GetHWND(), &g_paintStruct
);
130 else { }//: ms_PaintHDC still in use