]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/dcmemory.cpp
Fix to MDI to restore 3D border; kludge to OGL Studio sample to redraw
[wxWidgets.git] / src / msw / dcmemory.cpp
index af483ed3af754e508d3274e0f54d45403d732c0b..f79d33b26eb8bc25392064b5aa6c78fd639c8b82 100644 (file)
@@ -41,9 +41,7 @@
 // wxWin macros
 // ----------------------------------------------------------------------------
 
 // wxWin macros
 // ----------------------------------------------------------------------------
 
-#if !USE_SHARED_LIBRARY
     IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC, wxDC)
     IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC, wxDC)
-#endif
 
 // ============================================================================
 // implementation
 
 // ============================================================================
 // implementation
@@ -141,3 +139,52 @@ void wxMemoryDC::DoGetSize(int *width, int *height) const
     }
 }
 
     }
 }
 
+// For some reason, drawing a rectangle on a memory DC has problems.
+// Use this substitute if we can.
+static void wxDrawRectangle(wxDC& dc, wxCoord x, wxCoord y, wxCoord width, wxCoord height)
+{
+    wxBrush brush(dc.GetBrush());
+    wxPen pen(dc.GetPen());
+    if (brush.Ok() && brush.GetStyle() != wxTRANSPARENT)
+    {
+        HBRUSH hBrush = (HBRUSH) brush.GetResourceHandle() ;
+        if (hBrush)
+        {
+            RECT rect;
+            rect.left = x; rect.top = y;
+            rect.right = x + width - 1;
+            rect.bottom = y + height - 1;
+            ::FillRect((HDC) dc.GetHDC(), &rect, hBrush);
+        }
+    }
+    width --; height --;
+    if (pen.Ok() && pen.GetStyle() != wxTRANSPARENT)
+    {
+        dc.DrawLine(x, y, x + width, y);
+        dc.DrawLine(x, y, x, y + height);
+        dc.DrawLine(x, y+height, x+width, y + height);
+        dc.DrawLine(x+width, y+height, x+width, y);
+    }
+}
+
+void wxMemoryDC::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
+{
+    // Set this to 1 to work around an apparent video driver bug
+    // (visible with e.g. 70x70 rectangle on a memory DC; see Drawing sample)
+#if 0
+    if (m_brush.Ok() && m_pen.Ok() &&
+        (m_brush.GetStyle() == wxSOLID || m_brush.GetStyle() == wxTRANSPARENT) &&
+        (m_pen.GetStyle() == wxSOLID || m_pen.GetStyle() == wxTRANSPARENT) &&
+        (GetLogicalFunction() == wxCOPY))
+    {
+        wxDrawRectangle(* this, x, y, width, height);
+    }
+    else
+    {
+        wxDC::DoDrawRectangle(x, y, width, height);
+    }
+#else
+    wxDC::DoDrawRectangle(x, y, width, height);
+#endif
+}
+