+
+ DECLARE_CLASS(wxMSWDCImpl)
+ wxDECLARE_NO_COPY_CLASS(wxMSWDCImpl);
+};
+
+// ----------------------------------------------------------------------------
+// wxDCTemp: a wxDC which doesn't free the given HDC (used by wxWidgets
+// only/mainly)
+// ----------------------------------------------------------------------------
+
+class WXDLLIMPEXP_CORE wxDCTempImpl : public wxMSWDCImpl
+{
+public:
+ // construct a temporary DC with the specified HDC and size (it should be
+ // specified whenever we know it for this HDC)
+ wxDCTempImpl(wxDC *owner, WXHDC hdc, const wxSize& size )
+ : wxMSWDCImpl( owner, hdc ),
+ m_size(size)
+ {
+ }
+
+ virtual ~wxDCTempImpl()
+ {
+ // prevent base class dtor from freeing it
+ SetHDC((WXHDC)NULL);
+ }
+
+ virtual void DoGetSize(int *w, int *h) const
+ {
+ wxASSERT_MSG( m_size.IsFullySpecified(),
+ wxT("size of this DC hadn't been set and is unknown") );
+
+ if ( w )
+ *w = m_size.x;
+ if ( h )
+ *h = m_size.y;
+ }
+
+private:
+ // size of this DC must be explicitly set by SetSize() as we have no way to
+ // find it ourselves
+ const wxSize m_size;
+
+ wxDECLARE_NO_COPY_CLASS(wxDCTempImpl);
+};
+
+class WXDLLIMPEXP_CORE wxDCTemp : public wxDC
+{
+public:
+ wxDCTemp(WXHDC hdc, const wxSize& size = wxDefaultSize)
+ : wxDC(new wxDCTempImpl(this, hdc, size))
+ {
+ }
+};
+
+#endif // _WX_MSW_DC_H_
+