class wxCanvasPolygon: public wxCanvasObject
{
public:
- wxCanvasPolygon(int n, wxPoint2DDouble points[]);
+ wxCanvasPolygon( int n, wxPoint2DDouble points[] );
~wxCanvasPolygon();
- SetBrush(wxBrush& brush){m_brush = brush;};
- SetPen(wxPen& pen){m_pen = pen;};
+ void SetBrush(wxBrush& brush) { m_brush = brush; };
+ void SetPen(wxPen& pen) { m_pen = pen; };
virtual void Recreate();
public:
wxCanvasPolyline(int n, wxPoint2DDouble points[]);
~wxCanvasPolyline();
- SetPen(wxPen& pen){m_pen = pen;};
+ void SetPen(wxPen& pen) { m_pen = pen; };
virtual void Recreate();
class wxCanvasRect: public wxCanvasObject
{
public:
- wxCanvasRect( double x, double y, double w, double h,
- unsigned char red, unsigned char green, unsigned char blue );
+ wxCanvasRect( double x, double y, double w, double h );
+ void SetBrush(wxBrush& brush) { m_brush = brush; };
+ void SetPen(wxPen& pen) { m_pen = pen; };
virtual void Recreate();
virtual void WriteSVG( wxTextOutputStream &stream );
private:
+ wxPen m_pen;
+ wxBrush m_brush;
+
double m_x;
double m_y;
double m_width;
double m_height;
-
- unsigned char m_red;
- unsigned char m_green;
- unsigned char m_blue;
};
//----------------------------------------------------------------------------
class wxCanvasLine: public wxCanvasObject
{
public:
- wxCanvasLine( double x1, double y1, double x2, double y2,
- unsigned char red, unsigned char green, unsigned char blue );
+ wxCanvasLine( double x1, double y1, double x2, double y2 );
+ void SetPen(wxPen& pen) { m_pen = pen; };
virtual void Recreate();
virtual void WriteSVG( wxTextOutputStream &stream );
private:
+ wxPen m_pen;
+
double m_x1;
double m_y1;
double m_x2;
double m_y2;
-
- unsigned char m_red;
- unsigned char m_green;
- unsigned char m_blue;
};
//----------------------------------------------------------------------------
bool m_frozen;
wxCanvasObject *m_lastMouse;
wxCanvasObject *m_captureMouse;
+
+ int m_oldDeviceX,m_oldDeviceY;
friend class wxCanvasObject;
int i;
for (i = 10; i < 300; i+=10)
- m_canvas->Append( new wxCanvasRect( i,50,3,140, 255,0,0 ) );
+ {
+ wxCanvasRect *r = new wxCanvasRect( i,50,3,140 );
+ r->SetBrush( *wxRED_BRUSH );
+ m_canvas->Append( r );
+ }
m_sm2 = new wxCanvasImage( image, 0,140,24,24 );
m_canvas->Append( m_sm2 );
for (i = 15; i < 300; i+=10)
- m_canvas->Append( new wxCanvasRect( i,50,3,140, 255,0,0 ) );
+ m_canvas->Append( new wxCanvasRect( i,50,3,140 ) );
wxButton *button = new wxButton( m_canvas, -1, "Hello", wxPoint(80,50) );
m_canvas->Append( new wxCanvasControl( button ) );
m_canvas->Append( m_sm3 );
for (i = 10; i < 300; i+=10)
- m_canvas->Append( new wxCanvasLine( 10,-15,i,300, 0,255,0 ) );
+ m_canvas->Append( new wxCanvasLine( 10,-15,i,300 ) );
m_sm4 = new MywxCanvasImage( image, 0,270,64,32 );
m_canvas->Append( m_sm4 );
/*
//make a group of wxCanvasObjects
wxCanvasObjectGroup* group1 = new wxCanvasObjectGroup();
- group1->Prepend( new wxCanvasLine( 10,-35,50,190,100,255,0 ) );
+ group1->Prepend( new wxCanvasLine( 10,-35,50,190 ) );
group1->Prepend( new wxCanvasImage( image, 4,38,32,32 ) );
group1->Prepend( new wxCanvasRect(20,-20,50,170,0,20,240 ) );
{
m_n = n;
m_points = points;
- m_pen = wxPen(wxColour(0,0,0),1,wxSOLID);
+ m_pen = *wxBLACK_PEN;
}
wxCanvasPolyline::~wxCanvasPolyline()
{
m_n = n;
m_points = points;
- m_brush = wxBrush(wxColour(0,0,0),wxSOLID);
- m_pen = wxPen(wxColour(0,0,0),1,wxSOLID);
+ m_brush = *wxBLACK_BRUSH;
+ m_pen = *wxTRANSPARENT_PEN;
}
wxCanvasPolygon::~wxCanvasPolygon()
// wxCanvasRect
//----------------------------------------------------------------------------
-wxCanvasRect::wxCanvasRect( double x, double y, double w, double h,
- unsigned char red, unsigned char green, unsigned char blue )
+wxCanvasRect::wxCanvasRect( double x, double y, double w, double h )
: wxCanvasObject()
{
m_x = x;
m_width = w;
m_height = h;
- m_red = red;
- m_green = green;
- m_blue = blue;
+ m_brush = *wxBLACK_BRUSH;
+ m_pen = *wxTRANSPARENT_PEN;
}
void wxCanvasRect::Recreate()
image->SetRGB( x, y, m_red, m_green, m_blue );
#else
wxMemoryDC *dc = m_owner->GetDC();
- dc->SetPen( *wxTRANSPARENT_PEN );
- wxBrush brush( wxColour( m_red,m_green,m_blue), wxSOLID );
- dc->SetBrush( brush );
-
+ dc->SetPen( m_pen );
+ dc->SetBrush( m_brush );
dc->DrawRectangle( clip_x-buffer_x, clip_y-buffer_y, clip_width, clip_height );
#endif
}
// wxCanvasLine
//----------------------------------------------------------------------------
-wxCanvasLine::wxCanvasLine( double x1, double y1, double x2, double y2,
- unsigned char red, unsigned char green, unsigned char blue )
+wxCanvasLine::wxCanvasLine( double x1, double y1, double x2, double y2 )
: wxCanvasObject()
{
m_x1 = x1;
m_x2 = x2;
m_y2 = y2;
- m_red = red;
- m_green = green;
- m_blue = blue;
+ m_pen = *wxBLACK_PEN;
}
void wxCanvasLine::Recreate()
#else
wxMemoryDC *dc = m_owner->GetDC();
dc->SetClippingRegion( clip_x-buffer_x, clip_y-buffer_y, clip_width, clip_height );
-
- wxPen pen( wxColour(m_red,m_green,m_blue), 0, wxSOLID );
- dc->SetPen( pen );
+ dc->SetPen( m_pen );
dc->DrawLine( x1-buffer_x, y1-buffer_y, x2-buffer_x, y2-buffer_y );
dc->DestroyClippingRegion();
m_lastMouse = (wxCanvasObject*)NULL;
m_captureMouse = (wxCanvasObject*)NULL;
m_frozen = TRUE;
-
+ m_oldDeviceX = 0;
+ m_oldDeviceY = 0;
+
//root group always at 0,0
m_root = new wxCanvasObjectGroup();
m_root->DeleteContents( TRUE );
void wxCanvas::Update( int x, int y, int width, int height, bool blit )
{
+ CalcScrolledPosition( 0, 0, &m_oldDeviceX, &m_oldDeviceY );
+
if (m_frozen) return;
// clip to buffer
void wxCanvas::ScrollWindow( int dx, int dy, const wxRect* rect )
{
// If any updates are pending, do them now since they will
- // expect the previous m_bufferX and m_bufferY values.
- UpdateNow();
+ // expect the previous m_bufferX and m_bufferY as well as
+ // the previous device origin values.
+ wxClientDC dc( this );
+ dc.SetDeviceOrigin( m_oldDeviceX, m_oldDeviceY );
+ BlitBuffer( dc );
// The buffer always starts at the top left corner of the
// client area. Indeed, it is the client area.