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(wxWindowDC
, wxDC
)
33 IMPLEMENT_DYNAMIC_CLASS(wxClientDC
, wxWindowDC
)
34 IMPLEMENT_DYNAMIC_CLASS(wxPaintDC
, wxWindowDC
)
41 wxWindowDC::wxWindowDC(void)
46 wxWindowDC::wxWindowDC(wxWindow
*the_canvas
)
48 m_canvas
= the_canvas
;
49 // m_hDC = (WXHDC) ::GetDCEx((HWND) the_canvas->GetHWND(), NULL, DCX_WINDOW);
50 m_hDC
= (WXHDC
) ::GetWindowDC((HWND
) the_canvas
->GetHWND() );
54 wxWindowDC::~wxWindowDC(void)
56 if (m_canvas
&& m_hDC
)
58 SelectOldObjects(m_hDC
);
60 ::ReleaseDC((HWND
) m_canvas
->GetHWND(), (HDC
) m_hDC
);
70 wxClientDC::wxClientDC(void)
75 wxClientDC::wxClientDC(wxWindow
*the_canvas
)
77 m_canvas
= the_canvas
;
79 m_hDC
= (WXHDC
) ::GetDC((HWND
) the_canvas
->GetHWND());
82 wxClientDC::~wxClientDC(void)
86 if (m_canvas
&& (HDC
) m_hDC
)
88 SelectOldObjects(m_hDC
);
90 ::ReleaseDC((HWND
) m_canvas
->GetHWND(), (HDC
) m_hDC
);
99 wxPaintDC::wxPaintDC(void)
104 static PAINTSTRUCT g_paintStruct
;
106 // Don't call Begin/EndPaint if it's already been called:
107 // for example, if calling a base class OnPaint.
109 WXHDC
wxPaintDC::ms_PaintHDC
= 0;
110 size_t wxPaintDC::ms_PaintCount
= 0; // count of ms_PaintHDC usage
112 wxPaintDC::wxPaintDC(wxWindow
*canvas
)
114 wxCHECK_RET( canvas
, "NULL canvas in wxPaintDC ctor" );
117 if ( ms_PaintCount
> 0 ) {
118 // it means that we've already called BeginPaint and so we must just
119 // reuse the same HDC (BeginPaint shouldn't be called more than once)
120 wxASSERT( ms_PaintHDC
);
127 m_hDC
= (WXHDC
)::BeginPaint((HWND
)m_canvas
->GetHWND(), &g_paintStruct
);
133 wxPaintDC::~wxPaintDC()
136 if ( !--ms_PaintCount
) {
137 ::EndPaint((HWND
)m_canvas
->GetHWND(), &g_paintStruct
);
139 m_hDC
= (WXHDC
) NULL
;
140 ms_PaintHDC
= (WXHDC
) NULL
;
142 else { }//: ms_PaintHDC still in use