git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@8357
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
class wxCanvasPolygon: public wxCanvasObject
{
public:
class wxCanvasPolygon: public wxCanvasObject
{
public:
- wxCanvasPolygon(int n, wxPoint2DDouble points[]);
+ wxCanvasPolygon( int n, wxPoint2DDouble points[] );
- 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; };
public:
wxCanvasPolyline(int n, wxPoint2DDouble points[]);
~wxCanvasPolyline();
public:
wxCanvasPolyline(int n, wxPoint2DDouble points[]);
~wxCanvasPolyline();
- SetPen(wxPen& pen){m_pen = pen;};
+ void SetPen(wxPen& pen) { m_pen = pen; };
class wxCanvasRect: public wxCanvasObject
{
public:
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 WriteSVG( wxTextOutputStream &stream );
private:
virtual void WriteSVG( wxTextOutputStream &stream );
private:
+ wxPen m_pen;
+ wxBrush m_brush;
+
double m_x;
double m_y;
double m_width;
double m_height;
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:
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 WriteSVG( wxTextOutputStream &stream );
private:
virtual void WriteSVG( wxTextOutputStream &stream );
private:
double m_x1;
double m_y1;
double m_x2;
double m_y2;
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;
bool m_frozen;
wxCanvasObject *m_lastMouse;
wxCanvasObject *m_captureMouse;
+
+ int m_oldDeviceX,m_oldDeviceY;
friend class wxCanvasObject;
friend class wxCanvasObject;
int i;
for (i = 10; i < 300; i+=10)
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_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 ) );
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( 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 );
m_sm4 = new MywxCanvasImage( image, 0,270,64,32 );
m_canvas->Append( m_sm4 );
/*
//make a group of wxCanvasObjects
wxCanvasObjectGroup* group1 = new wxCanvasObjectGroup();
/*
//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 ) );
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_n = n;
m_points = points;
- m_pen = wxPen(wxColour(0,0,0),1,wxSOLID);
}
wxCanvasPolyline::~wxCanvasPolyline()
}
wxCanvasPolyline::~wxCanvasPolyline()
{
m_n = n;
m_points = points;
{
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()
}
wxCanvasPolygon::~wxCanvasPolygon()
// wxCanvasRect
//----------------------------------------------------------------------------
// 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;
: wxCanvasObject()
{
m_x = x;
m_width = w;
m_height = h;
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()
}
void wxCanvasRect::Recreate()
image->SetRGB( x, y, m_red, m_green, m_blue );
#else
wxMemoryDC *dc = m_owner->GetDC();
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
}
dc->DrawRectangle( clip_x-buffer_x, clip_y-buffer_y, clip_width, clip_height );
#endif
}
// wxCanvasLine
//----------------------------------------------------------------------------
// 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;
: wxCanvasObject()
{
m_x1 = x1;
- m_red = red;
- m_green = green;
- m_blue = blue;
}
void wxCanvasLine::Recreate()
}
void wxCanvasLine::Recreate()
#else
wxMemoryDC *dc = m_owner->GetDC();
dc->SetClippingRegion( clip_x-buffer_x, clip_y-buffer_y, clip_width, clip_height );
#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->DrawLine( x1-buffer_x, y1-buffer_y, x2-buffer_x, y2-buffer_y );
dc->DestroyClippingRegion();
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_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 );
//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 )
{
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
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
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.
// The buffer always starts at the top left corner of the
// client area. Indeed, it is the client area.