]> git.saurik.com Git - wxWidgets.git/commitdiff
Removed redundant wxColour constructor (how come this didn't cause problems before...)
authorJulian Smart <julian@anthemion.co.uk>
Thu, 17 Feb 2000 20:36:52 +0000 (20:36 +0000)
committerJulian Smart <julian@anthemion.co.uk>
Thu, 17 Feb 2000 20:36:52 +0000 (20:36 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@6125 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/msw/colour.h
include/wx/msw/dcmemory.h
samples/drawing/drawing.cpp
src/msw/dcmemory.cpp

index 7546b611c3a9cbe7f081eecc7de007cd18ba4777..3f0c568c4ac4ff5943ee68059c9e8bb9647f02c4 100644 (file)
@@ -35,7 +35,7 @@ public:
 
     // copy ctors and assignment operators
   wxColour( const wxColour& col );
-  wxColour( const wxColour* col );
+/*  wxColour( const wxColour* col ); */
   wxColour& operator = ( const wxColour& col );
 
     // dtor
index da908bf3a489f4e3304413aefbe262d42f2824e2..85d83bd981d166dad853a31743fea3fd5e5a32e1 100644 (file)
@@ -26,6 +26,7 @@ public:
 
     ~wxMemoryDC();
 
+    virtual void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
     virtual void SelectObject(const wxBitmap& bitmap);
 
     virtual void DoGetSize(int* width, int* height) const;
index 06f587a9a33809a2a5656efe93d12643e7dbff91..aa985078e8736eb3b0669e92b68ff48bdf019044 100644 (file)
@@ -598,7 +598,9 @@ void MyCanvas::DrawDefault(wxDC& dc)
     //dc.SetBrush( *wxTRANSPARENT_BRUSH );
     #include "../image/smile.xpm"
     wxBitmap bmp(smile_xpm);
-    dc.DrawBitmap(bmp, x + rectSize - 20, rectSize - 10, TRUE);
+
+    if (bmp.Ok())
+        dc.DrawBitmap(bmp, x + rectSize - 20, rectSize - 10, TRUE);
 
     dc.SetBrush( *wxBLACK_BRUSH );
     dc.DrawRectangle( 0, 160, 1000, 300 );
@@ -717,12 +719,11 @@ void MyCanvas::DrawDefault(wxDC& dc)
     wxMemoryDC memdc2;
     memdc2.SelectObject(bitmap2);
 
-    memdc2.SetBackground(*wxWHITE_BRUSH);
+    wxBrush yellowBrush(wxColour(255, 255, 0), wxSOLID);
+    memdc2.SetBackground(yellowBrush);
+    memdc2.Clear();
 
-    // Draw a yellow rectangle filling the bitmap
-    memdc2.SetPen(wxPen(wxColour(255, 255, 0), 1, wxSOLID));
-    memdc2.SetBrush(wxBrush(wxColour(255, 255, 0), wxSOLID));
-    memdc2.DrawRectangle(0, 0, totalWidth+2, totalHeight+2); // Just to make sure!
+    wxPen yellowPen(wxColour(255, 255, 0), 1, wxSOLID);
 
     // Now draw a white rectangle with red outline. It should
     // entirely eclipse the yellow background.
@@ -736,6 +737,21 @@ void MyCanvas::DrawDefault(wxDC& dc)
     memdc2.SelectObject(wxNullBitmap);
 
     dc.DrawBitmap(bitmap2, 500, 270);
+
+    // Repeat, but draw directly on dc
+    // Draw a yellow rectangle filling the bitmap
+
+    x = 600; int y = 270;
+    dc.SetPen(yellowPen);
+    dc.SetBrush(yellowBrush);
+    dc.DrawRectangle(x, y, totalWidth, totalHeight);
+
+    // Now draw a white rectangle with red outline. It should
+    // entirely eclipse the yellow background.
+    dc.SetPen(*wxRED_PEN);
+    dc.SetBrush(*wxWHITE_BRUSH);
+
+    dc.DrawRectangle(x, y, totalWidth, totalHeight);
 }
 
 void MyCanvas::DrawText(wxDC& dc)
index 1a59e066277c9083bb5d34ec57ac2276590567da..64ff3c778f42183b6224a59a5f5f90d3564c0e29 100644 (file)
@@ -139,3 +139,50 @@ 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 0 to demonstrate strange rectangle behaviour in the 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))
+    {
+        wxDrawRectangle(* this, x, y, width, height);
+    }
+    else
+    {
+        wxDC::DoDrawRectangle(x, y, width, height);
+    }
+#else
+    wxDC::DoDrawRectangle(x, y, width, height);
+#endif
+}
+