void OnOption(wxCommandEvent &event);
void OnMouseMove(wxMouseEvent &event);
- wxColour SelectColour() const;
+ wxColour SelectColour();
+ void PrepareDC(wxDC& dc);
protected:
int m_backgroundMode;
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" );
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 );
+ 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() )
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 );
+ dc.DrawRoundedRectangle( 110, 10, 90, 90, 5 );
+
+ dc.SetPen( *wxWHITE_PEN );
+ dc.DrawLine( 10, 110, 100, 110 );
+ dc.SetPen( *wxBLACK_PEN );
+ dc.DrawLine( 100, 110, 100, 200 );
+ dc.SetPen( *wxWHITE_PEN );
+ dc.DrawLine( 100, 200, 10, 200 );
+ dc.SetPen( *wxBLACK_PEN );
+ dc.DrawLine( 10, 200, 10, 110 );
+
+ wxPen white_butt( "white", 1, wxSOLID );
+ white_butt.SetCap( wxCAP_BUTT );
+ wxPen black_butt( "black", 1, wxSOLID );
+ black_butt.SetCap( wxCAP_BUTT );
+
+ dc.SetPen( white_butt );
+ dc.DrawLine( 110, 110, 200, 110 );
+ dc.SetPen( black_butt );
+ dc.DrawLine( 200, 110, 200, 200 );
+ dc.SetPen( white_butt );
+ dc.DrawLine( 200, 200, 110, 200 );
+ dc.SetPen( black_butt );
+ dc.DrawLine( 110, 200, 110, 110 );
+
+ wxPen white_miter( "white", 1, wxSOLID );
+ white_miter.SetJoin( wxJOIN_MITER );
+ wxPen black_miter( "black", 1, wxSOLID );
+ black_miter.SetJoin( wxJOIN_MITER );
+
+ dc.SetPen( white_miter );
+ dc.DrawLine( 210, 110, 300, 110 );
+ dc.SetPen( black_miter );
+ dc.DrawLine( 300, 110, 300, 200 );
+ dc.SetPen( white_miter );
+ dc.DrawLine( 300, 200, 210, 200 );
+ dc.SetPen( black_miter );
+ dc.DrawLine( 210, 200, 210, 110 );
+
dc.DrawText( "This is text\n(on multiple lines)", 110, 10 );
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 );
SetStatusText( str );
}
-wxColour MyFrame::SelectColour() const
+wxColour MyFrame::SelectColour()
{
wxColour col;
wxColourData data;
if ( dialog.ShowModal() == wxID_OK )
{
- col = data.GetColour();
+ col = dialog.GetColourData().GetColour();
}
return col;