DrawCircle() added

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2484 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
1999-05-17 14:35:48 +00:00
parent 0f0c61d0ad
commit 220af862c1
2 changed files with 22 additions and 10 deletions

View File

@@ -57,7 +57,7 @@ public:
m_deviceOriginX = m_deviceOriginY = 0; m_deviceOriginX = m_deviceOriginY = 0;
m_logicalScaleX = m_logicalScaleY = m_logicalScaleX = m_logicalScaleY =
m_userScaleX = m_userScaleY = m_userScaleX = m_userScaleY =
m_scaleX = m_scaleY = 1.0; m_scaleX = m_scaleY = 1.0;
m_logicalFunction = -1; m_logicalFunction = -1;
@@ -181,6 +181,8 @@ public:
void DrawRoundedRectangle(const wxRect& r, double radius) void DrawRoundedRectangle(const wxRect& r, double radius)
{ DoDrawRoundedRectangle(r.x, r.y, r.width, r.height, 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) void DrawEllipse(long x, long y, long width, long height)
{ DoDrawEllipse(x, y, width, height); } { DoDrawEllipse(x, y, width, height); }
void DrawEllipse(const wxPoint& pt, const wxSize& sz) void DrawEllipse(const wxPoint& pt, const wxSize& sz)

View File

@@ -75,7 +75,8 @@ public:
void OnOption(wxCommandEvent &event); void OnOption(wxCommandEvent &event);
void OnMouseMove(wxMouseEvent &event); void OnMouseMove(wxMouseEvent &event);
wxColour SelectColour() const; wxColour SelectColour();
void PrepareDC(wxDC& dc);
protected: protected:
int m_backgroundMode; 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" ); menuUserScale->Append( UserScale_Restore, "Restore to normal\tCtrl-0" );
wxMenu *menuAxis = new wxMenu; wxMenu *menuAxis = new wxMenu;
menuAxis->Append( AxisMirror_Horiz, "Mirror horizontally\tCtrl-\\", "", TRUE ); menuAxis->Append( AxisMirror_Horiz, "Mirror horizontally\tCtrl-M", "", TRUE );
menuAxis->Append( AxisMirror_Vertic, "Mirror vertically\tCtrl-/", "", TRUE ); menuAxis->Append( AxisMirror_Vertic, "Mirror vertically\tCtrl-N", "", TRUE );
wxMenu *menuLogical = new wxMenu; wxMenu *menuLogical = new wxMenu;
menuLogical->Append( LogicalOrigin_MoveDown, "Move &down\tCtrl-D" ); menuLogical->Append( LogicalOrigin_MoveDown, "Move &down\tCtrl-D" );
@@ -363,13 +364,18 @@ void MyFrame::OnOption(wxCommandEvent &event)
Refresh(); Refresh();
} }
void MyFrame::OnPaint(wxPaintEvent &WXUNUSED(event) ) void MyFrame::PrepareDC(wxDC& dc)
{ {
wxPaintDC dc(this);
dc.SetMapMode( m_mapMode ); dc.SetMapMode( m_mapMode );
dc.SetUserScale( m_xUserScale, m_yUserScale ); dc.SetUserScale( m_xUserScale, m_yUserScale );
dc.SetLogicalOrigin( m_xLogicalOrigin, m_yLogicalOrigin ); dc.SetLogicalOrigin( m_xLogicalOrigin, m_yLogicalOrigin );
dc.SetAxisOrientation( m_xAxisReversed, m_yAxisReversed ); dc.SetAxisOrientation( m_xAxisReversed, m_yAxisReversed );
}
void MyFrame::OnPaint(wxPaintEvent &WXUNUSED(event) )
{
wxPaintDC dc(this);
PrepareDC(dc);
dc.SetBackgroundMode( m_backgroundMode ); dc.SetBackgroundMode( m_backgroundMode );
if ( m_backgroundBrush.Ok() ) if ( m_backgroundBrush.Ok() )
@@ -379,6 +385,12 @@ void MyFrame::OnPaint(wxPaintEvent &WXUNUSED(event) )
if ( m_colourBackground.Ok() ) if ( m_colourBackground.Ok() )
dc.SetTextBackground( m_colourBackground ); 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.DrawRectangle( 10, 10, 90, 90 );
dc.DrawRoundedRectangle( 10, 110, 90, 90, 5 ); dc.DrawRoundedRectangle( 10, 110, 90, 90, 5 );
@@ -390,9 +402,7 @@ void MyFrame::OnPaint(wxPaintEvent &WXUNUSED(event) )
void MyFrame::OnMouseMove(wxMouseEvent &event) void MyFrame::OnMouseMove(wxMouseEvent &event)
{ {
wxClientDC dc(this); wxClientDC dc(this);
dc.SetMapMode( m_mapMode ); PrepareDC(dc);
dc.SetUserScale( m_xUserScale, m_yUserScale );
dc.SetLogicalOrigin( m_xLogicalOrigin, m_yLogicalOrigin );
wxPoint pos = event.GetPosition(); wxPoint pos = event.GetPosition();
long x = dc.DeviceToLogicalX( pos.x ); long x = dc.DeviceToLogicalX( pos.x );
@@ -402,7 +412,7 @@ void MyFrame::OnMouseMove(wxMouseEvent &event)
SetStatusText( str ); SetStatusText( str );
} }
wxColour MyFrame::SelectColour() const wxColour MyFrame::SelectColour()
{ {
wxColour col; wxColour col;
wxColourData data; wxColourData data;