From 220af862c14ef432584fae3ef096aa17a6cfaf2d Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 17 May 1999 14:35:48 +0000 Subject: [PATCH] DrawCircle() added git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2484 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/dc.h | 4 +++- samples/drawing/drawing.cpp | 28 +++++++++++++++++++--------- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/include/wx/dc.h b/include/wx/dc.h index 052ec417d6..21f4542bd3 100644 --- a/include/wx/dc.h +++ b/include/wx/dc.h @@ -57,7 +57,7 @@ public: m_deviceOriginX = m_deviceOriginY = 0; m_logicalScaleX = m_logicalScaleY = - m_userScaleX = m_userScaleY = + m_userScaleX = m_userScaleY = m_scaleX = m_scaleY = 1.0; m_logicalFunction = -1; @@ -181,6 +181,8 @@ public: void DrawRoundedRectangle(const wxRect& r, double radius) { DoDrawRoundedRectangle(r.x, r.y, r.width, r.height, radius); } + void DrawCircle(long x, long y, long radius) + { DoDrawEllipse(x - radius, y - radius, 2*radius, 2*radius); } void DrawEllipse(long x, long y, long width, long height) { DoDrawEllipse(x, y, width, height); } void DrawEllipse(const wxPoint& pt, const wxSize& sz) diff --git a/samples/drawing/drawing.cpp b/samples/drawing/drawing.cpp index cbb669192f..eb8846a16a 100644 --- a/samples/drawing/drawing.cpp +++ b/samples/drawing/drawing.cpp @@ -75,7 +75,8 @@ public: void OnOption(wxCommandEvent &event); void OnMouseMove(wxMouseEvent &event); - wxColour SelectColour() const; + wxColour SelectColour(); + void PrepareDC(wxDC& dc); protected: int m_backgroundMode; @@ -218,8 +219,8 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size) menuUserScale->Append( UserScale_Restore, "Restore to normal\tCtrl-0" ); wxMenu *menuAxis = new wxMenu; - menuAxis->Append( AxisMirror_Horiz, "Mirror horizontally\tCtrl-\\", "", TRUE ); - menuAxis->Append( AxisMirror_Vertic, "Mirror vertically\tCtrl-/", "", TRUE ); + menuAxis->Append( AxisMirror_Horiz, "Mirror horizontally\tCtrl-M", "", TRUE ); + menuAxis->Append( AxisMirror_Vertic, "Mirror vertically\tCtrl-N", "", TRUE ); wxMenu *menuLogical = new wxMenu; menuLogical->Append( LogicalOrigin_MoveDown, "Move &down\tCtrl-D" ); @@ -363,13 +364,18 @@ void MyFrame::OnOption(wxCommandEvent &event) Refresh(); } -void MyFrame::OnPaint(wxPaintEvent &WXUNUSED(event) ) +void MyFrame::PrepareDC(wxDC& dc) { - wxPaintDC dc(this); dc.SetMapMode( m_mapMode ); dc.SetUserScale( m_xUserScale, m_yUserScale ); dc.SetLogicalOrigin( m_xLogicalOrigin, m_yLogicalOrigin ); dc.SetAxisOrientation( m_xAxisReversed, m_yAxisReversed ); +} + +void MyFrame::OnPaint(wxPaintEvent &WXUNUSED(event) ) +{ + wxPaintDC dc(this); + PrepareDC(dc); dc.SetBackgroundMode( m_backgroundMode ); if ( m_backgroundBrush.Ok() ) @@ -379,6 +385,12 @@ void MyFrame::OnPaint(wxPaintEvent &WXUNUSED(event) ) if ( m_colourBackground.Ok() ) dc.SetTextBackground( m_colourBackground ); + // mark the origin + dc.DrawCircle(0, 0, 10); +#ifndef __WXGTK__ // not implemented in wxGTK :-( + dc.FloodFill(0, 0, wxColour(255, 0, 0)); +#endif // __WXGTK__ + dc.DrawRectangle( 10, 10, 90, 90 ); dc.DrawRoundedRectangle( 10, 110, 90, 90, 5 ); @@ -390,9 +402,7 @@ void MyFrame::OnPaint(wxPaintEvent &WXUNUSED(event) ) void MyFrame::OnMouseMove(wxMouseEvent &event) { wxClientDC dc(this); - dc.SetMapMode( m_mapMode ); - dc.SetUserScale( m_xUserScale, m_yUserScale ); - dc.SetLogicalOrigin( m_xLogicalOrigin, m_yLogicalOrigin ); + PrepareDC(dc); wxPoint pos = event.GetPosition(); long x = dc.DeviceToLogicalX( pos.x ); @@ -402,7 +412,7 @@ void MyFrame::OnMouseMove(wxMouseEvent &event) SetStatusText( str ); } -wxColour MyFrame::SelectColour() const +wxColour MyFrame::SelectColour() { wxColour col; wxColourData data; -- 2.45.2