m_canvas = new wxCanvas( this, -1, wxPoint(0,0), wxSize(10,10) );
- m_canvas->SetArea( 400, 600 );
+ m_canvas->SetArea( 1400, 600 );
m_canvas->SetColour( 255, 255, 255 );
wxBitmap bitmap( smile_xpm );
m_sm1 = new wxCanvasImage( image, 0,70,16,16 );
m_canvas->Append( m_sm1 );
-
+
int i;
for (i = 10; i < 300; i+=10)
m_canvas->Append( new wxCanvasRect( i,50,3,140, 255,0,0 ) );
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,-1500e6,50,300000e6, 0,255,0 ) );
-// m_canvas->Append( new wxCanvasLine( 10,-150000,50,300000, 0,255,0 ) );
-
m_sm4 = new MywxCanvasImage( image, 0,270,64,32 );
m_canvas->Append( m_sm4 );
+// m_canvas->Append( new wxCanvasLine( 10,-1500e6,50,300000e6, 0,255,0 ) );
+// m_canvas->Append( new wxCanvasLine( 10,-150000,50,300000, 0,255,0 ) );
+
m_log = new wxTextCtrl( this, -1, "", wxPoint(0,0), wxSize(100,100), wxTE_MULTILINE );
wxLog *old_log = wxLog::SetActiveTarget( new wxLogTextCtrl( m_log ) );
delete old_log;
wxImage *image = m_owner->GetBuffer();
int buffer_x = m_owner->GetBufferX();
int buffer_y = m_owner->GetBufferY();
-
+
if ((m_area.width == 0) && (m_area.height == 0))
{
image->SetRGB( m_area.x-buffer_x, m_area.y-buffer_y, m_red, m_green, m_blue );
while (ii != x1)
{
- if ((ii >= clip_x) && (ii <= clip_x+clip_width) &&
- (jj >= clip_y) && (jj <= clip_y+clip_height))
+ if ((ii >= clip_x) && (ii < clip_x+clip_width) &&
+ (jj >= clip_y) && (jj < clip_y+clip_height))
{
image->SetRGB( ii-buffer_x, jj-buffer_y, m_red, m_blue, m_green );
}
while (jj != y1)
{
- if ((ii >= clip_x) && (ii <= clip_x+clip_width) &&
- (jj >= clip_y) && (jj <= clip_y+clip_height))
+ if ((ii >= clip_x) && (ii < clip_x+clip_width) &&
+ (jj >= clip_y) && (jj < clip_y+clip_height))
{
image->SetRGB( ii-buffer_x, jj-buffer_y, m_red, m_blue, m_green );
}
EVT_MOUSE_EVENTS( wxCanvas::OnMouse )
EVT_SET_FOCUS( wxCanvas::OnSetFocus )
EVT_KILL_FOCUS( wxCanvas::OnKillFocus )
+ EVT_ERASE_BACKGROUND( wxCanvas::OnEraseBackground )
END_EVENT_TABLE()
wxCanvas::wxCanvas( wxWindow *parent, wxWindowID id,
m_green = green;
m_blue = blue;
+ SetBackgroundColour( wxColour( red, green, blue ) );
+
if (m_frozen) return;
unsigned char *data = m_buffer.GetData();
void wxCanvas::UpdateNow()
{
+ if (m_frozen) return;
+
if (!m_needUpdate) return;
wxClientDC dc( this );
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();
+ // The buffer always starts at the top left corner of the
+ // client area. Indeed, it is the client area.
CalcUnscrolledPosition( 0, 0, &m_bufferX, &m_bufferY );
unsigned char* data = m_buffer.GetData();
size_t count = (size_t) (m_buffer.GetWidth() * 3 * (m_buffer.GetHeight()-dy));
memmove( dest, source, count );
+ // We update the new buffer area, but there is no need to
+ // blit (last param FALSE) since the ensuing paint event will
+ // do that anyway.
Update( m_bufferX, m_bufferY, m_buffer.GetWidth(), dy, FALSE );
}
else
size_t count = (size_t) (m_buffer.GetWidth() * 3 * (m_buffer.GetHeight()+dy));
memmove( dest, source, count );
+ // We update the new buffer area, but there is no need to
+ // blit (last param FALSE) since the ensuing paint event will
+ // do that anyway.
Update( m_bufferX, m_bufferY+m_buffer.GetHeight()+dy, m_buffer.GetWidth(), -dy, FALSE );
}
}
if (dx != 0)
{
+ if (dx > 0)
+ {
+ unsigned char *source = data;
+ for (int y = 0; y < m_buffer.GetHeight(); y++)
+ {
+ unsigned char *dest = source + dx*3;
+ memmove( dest, source, (m_buffer.GetWidth()-dx) * 3 );
+ source += m_buffer.GetWidth()*3;
+ }
+
+ // We update the new buffer area, but there is no need to
+ // blit (last param FALSE) since the ensuing paint event will
+ // do that anyway.
+ Update( m_bufferX, m_bufferY, dx, m_buffer.GetHeight(), FALSE );
+ }
+ else
+ {
+ unsigned char *dest = data;
+ for (int y = 0; y < m_buffer.GetHeight(); y++)
+ {
+ unsigned char *source = dest - dx*3;
+ memmove( dest, source, (m_buffer.GetWidth()+dx) * 3 );
+ dest += m_buffer.GetWidth()*3;
+ }
+
+ // We update the new buffer area, but there is no need to
+ // blit (last param FALSE) since the ensuing paint event will
+ // do that anyway.
+ Update( m_bufferX+m_buffer.GetWidth()+dx, m_bufferY, -dx, m_buffer.GetHeight(), FALSE );
+ }
}
wxWindow::ScrollWindow( dx, dy, rect );
event.Skip();
}
+void wxCanvas::OnEraseBackground(wxEraseEvent &event)
+{
+}
+
//--------------------------------------------------------------------
// wxCanvasModule
//--------------------------------------------------------------------