-#if !USE_SHARED_LIBRARY
- IMPLEMENT_DYNAMIC_CLASS(wxWindowDC, wxDC)
- IMPLEMENT_DYNAMIC_CLASS(wxClientDC, wxWindowDC)
- IMPLEMENT_DYNAMIC_CLASS(wxPaintDC, wxWindowDC)
-#endif
+private:
+ // This helper is only needed in order to call it from the ctor initializer
+ // list.
+ static PAINTSTRUCT* GetPaintStructPtr(PAINTSTRUCT& ps)
+ {
+ wxZeroMemory(ps);
+ return &ps;
+ }
+
+ const HWND m_hwnd;
+ PAINTSTRUCT m_ps;
+
+ wxDECLARE_NO_COPY_CLASS(wxPaintDCInfoOur);
+};
+
+// This subclass contains information for the HDCs we receive from outside, as
+// WPARAM of WM_PAINT itself.
+class wxPaintDCInfoExternal : public wxPaintDCInfo
+{
+public:
+ wxPaintDCInfoExternal(HDC hdc)
+ : wxPaintDCInfo(hdc),
+ m_state(::SaveDC(hdc))
+ {
+ }
+
+ virtual ~wxPaintDCInfoExternal()
+ {
+ ::RestoreDC(m_hdc, m_state);
+ }
+
+private:
+ const int m_state;
+
+ wxDECLARE_NO_COPY_CLASS(wxPaintDCInfoExternal);
+};
+
+// The global map containing HDC to use for the given window. The entries in
+// this map only exist during WM_PAINT processing and are destroyed when it is
+// over.
+//
+// It is needed because in some circumstances it can happen that more than one
+// wxPaintDC is created for the same window during its WM_PAINT handling (and
+// as this can happen implicitly, e.g. by calling a function in some library,
+// this can be quite difficult to find) but we need to reuse the same HDC for
+// all of them because we can't call BeginPaint() more than once. So we cache
+// the first HDC created for the window in this map and then reuse it later if
+// needed. And, of course, remove it from the map when the painting is done.
+WX_DECLARE_HASH_MAP(wxWindow *, wxPaintDCInfo *,
+ wxPointerHash, wxPointerEqual,
+ PaintDCInfos);
+
+PaintDCInfos gs_PaintDCInfos;
+
+} // anonymous namespace