- unsigned char *source = data;
- unsigned char *dest = data + (dy * m_buffer.GetWidth() * 3);
- 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( 0, 0, m_buffer.GetWidth(), dy, FALSE );
- }
- else
- {
- unsigned char *dest = data;
- unsigned char *source = data + (-dy * m_buffer.GetWidth() * 3);
- 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( 0, 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( 0,0, 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_buffer.GetWidth()+dx, 0, -dx, m_buffer.GetHeight(), FALSE );
- }
- }
-#else
-
- if (dy != 0)
- {
- if (dy > 0 && dy < m_buffer.GetHeight())
- {
- wxRect rect( 0, 0, m_buffer.GetWidth(), m_buffer.GetHeight()-dy);
- wxBitmap sub_bitmap( m_buffer.GetSubBitmap( rect ) );
- wxMemoryDC dcm;
- dcm.SelectObject( m_buffer );
- dcm.DrawBitmap( sub_bitmap, 0, dy, TRUE );
- dcm.SelectObject( wxNullBitmap );
-
- Update( 0, 0, m_buffer.GetWidth(), dy, TRUE );
- }
- else if (dy < 0 && dy > -m_buffer.GetHeight())
- {
- wxRect rect( 0, -dy, m_buffer.GetWidth(), m_buffer.GetHeight()+dy);
- wxBitmap sub_bitmap( m_buffer.GetSubBitmap( rect ) );
- wxMemoryDC dcm;
- dcm.SelectObject( m_buffer );
- dcm.DrawBitmap( sub_bitmap, 0, 0, TRUE );
- dcm.SelectObject( wxNullBitmap );
-
- Update( 0, m_buffer.GetHeight()+dy, m_buffer.GetWidth(), m_buffer.GetHeight(), TRUE );
- }
- else
- Update( 0, 0, m_buffer.GetWidth(), m_buffer.GetHeight(), TRUE );
- }
-
- if (dx != 0)
- {
- if (dx > 0 && dx < m_buffer.GetWidth())
- {
- wxRect rect( 0, 0, m_buffer.GetWidth()-dx, m_buffer.GetHeight());
- wxBitmap sub_bitmap( m_buffer.GetSubBitmap( rect ) );
- wxMemoryDC dcm;
- dcm.SelectObject( m_buffer );
- dcm.DrawBitmap( sub_bitmap, dx, 0, TRUE );
- dcm.SelectObject( wxNullBitmap );
-
- Update( 0, 0, dx, m_buffer.GetHeight(), TRUE );
- }
- else if (dx < 0 && dx > -m_buffer.GetWidth())
- {
- wxRect rect( -dx, 0, m_buffer.GetWidth()+dx, m_buffer.GetHeight());
- wxBitmap sub_bitmap( m_buffer.GetSubBitmap( rect ) );
- wxMemoryDC dcm;
- dcm.SelectObject( m_buffer );
- dcm.DrawBitmap( sub_bitmap, 0, 0, TRUE );
- dcm.SelectObject( wxNullBitmap );
-
- Update( m_buffer.GetWidth()+dx, 0, m_buffer.GetWidth(), m_buffer.GetHeight(), TRUE );
- }
- else
- Update( 0,0, m_buffer.GetWidth(), m_buffer.GetHeight(), TRUE );
- }
-#endif
- wxWindow::ScrollWindow( dx, dy, rect );
-
- //must be done now because quick repeated scrolling will prevent wxPaint
- //from doing it properly
- UpdateNow();
-}
-
-void wxCanvas::OnMouse(wxMouseEvent &event)
-{
- m_admin->SetActive(this);
- if (!m_root)
- {
- event.Skip();
- return;
- }
-
- int x = event.GetX();
- int y = event.GetY();
-
- //to world coordinates to do hit test in world coordinates
- double xw = DeviceToLogicalX( x );
- double yw = DeviceToLogicalY( y );
-
- //make a select margin of 2 pixels, so also zero line thickness will be hit
- double margin = DeviceToLogicalXRel( 2 );
-
- if (event.GetEventType() == wxEVT_MOTION)
- {
- if (m_captureMouse) //no matter what go to this one
- {
- wxMouseEvent child_event( wxEVT_MOTION );
- child_event.SetEventObject(m_captureMouse);
- child_event.m_x = x;
- child_event.m_y = y;
- child_event.m_leftDown = event.m_leftDown;
- child_event.m_rightDown = event.m_rightDown;
- child_event.m_middleDown = event.m_middleDown;
- child_event.m_controlDown = event.m_controlDown;
- child_event.m_shiftDown = event.m_shiftDown;
- child_event.m_altDown = event.m_altDown;
- child_event.m_metaDown = event.m_metaDown;
-
- m_captureMouse->ProcessCanvasObjectEvent( child_event );
- return;