From f88c1a172efd0391ad65621898e6a8823160c4f9 Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Mon, 1 Apr 2002 21:47:02 +0000 Subject: [PATCH] Added FloodFill patch for samples git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14895 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- samples/dnd/dnd.cpp | 15 +++++++-------- samples/drawing/drawing.cpp | 10 ++++++---- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/samples/dnd/dnd.cpp b/samples/dnd/dnd.cpp index 9af14885d2..7788cfdc7d 100644 --- a/samples/dnd/dnd.cpp +++ b/samples/dnd/dnd.cpp @@ -332,9 +332,10 @@ public: } protected: + //get a point 1 up and 1 left, otherwise the mid-point of a triangle is on the line wxPoint GetCentre() const - { return wxPoint(m_pos.x + m_size.x / 2, m_pos.y + m_size.y / 2); } - + { return wxPoint(m_pos.x + m_size.x / 2 - 1, m_pos.y + m_size.y / 2 - 1); } + struct ShapeDump { int x, y, // position @@ -379,9 +380,9 @@ public: dc.DrawLine(p2, p3); dc.DrawLine(p3, p1); -#ifdef __WXMSW__ + //works in multicolor modes; on GTK (at least) will fail in 16-bit color + dc.SetBrush(wxBrush(m_col, wxSOLID)); dc.FloodFill(GetCentre(), m_col, wxFLOOD_BORDER); -#endif } }; @@ -416,9 +417,8 @@ public: dc.DrawLine(p3, p4); dc.DrawLine(p4, p1); -#ifdef __WXMSW__ + dc.SetBrush(wxBrush(m_col, wxSOLID)); dc.FloodFill(GetCentre(), m_col, wxFLOOD_BORDER); -#endif } }; @@ -445,9 +445,8 @@ public: dc.DrawEllipse(m_pos, m_size); -#ifdef __WXMSW__ + dc.SetBrush(wxBrush(m_col, wxSOLID)); dc.FloodFill(GetCentre(), m_col, wxFLOOD_BORDER); -#endif } }; diff --git a/samples/drawing/drawing.cpp b/samples/drawing/drawing.cpp index b8c1079ae3..5c71ee2b09 100644 --- a/samples/drawing/drawing.cpp +++ b/samples/drawing/drawing.cpp @@ -475,10 +475,12 @@ void MyCanvas::DrawDefault(wxDC& dc) { // mark the origin dc.DrawCircle(0, 0, 10); -#if !(defined __WXGTK__) && !(defined __WXX11__) && !(defined __WXMOTIF__) && !(defined __WXMGL__) - // not implemented in wxGTK or wxMOTIF or wxX11 :-( - dc.FloodFill(0, 0, wxColour(255, 0, 0)); -#endif // + + //flood fill using brush, starting at 1,1 and replacing whatever colour we find there + dc.SetBrush(wxBrush(wxColour(128,128,0), wxSOLID)); + wxColour tmpColour ; + dc.GetPixel(1,1, &tmpColour); + dc.FloodFill(1,1, tmpColour, wxFLOOD_SURFACE); dc.DrawCheckMark(5, 80, 15, 15); dc.DrawCheckMark(25, 80, 30, 30); -- 2.45.2