i'm currently working on a nice application that displays vectorized graphics. i want to zoom in and also, when the image is bigger than it can be displayed, i want to "scroll" around by drag and drop on the screen.
here the code how the image gets drawn:
Code: Select all
void MyFrame::OnPaint( wxPaintEvent &event )
{
wxAutoBufferedPaintDC pdc( this );
pdc.Clear();
// draw the grid if needed
DrawGrid( &pdc );
// now print all objects and points to the gui
SerializeToGUI( &pdc );
pdc.SetUserScale( m_fZoomFactor, m_fZoomFactor );
pdc.SetDeviceOrigin( m_pZoomPoint.x, m_pZoomPoint.y );
event.Skip();
}
m_pZoomPoint is a wxPoint that gets changed when a drag'n'drop event occurs to move the zoomed image around.
Everything works fine except of two things:
1) When i move the "image" around and a position smaller than wxPoint(0,0) is rendered, the last colours on the 0 coordinates get copied (see attached picture). i cant stop this, not with pdc.Clear() and not with pdc.DrawRectangle(0,0,-2000,-2000)
2) i zoom in, move a little bit around and i'm now clicking on the screen (normal mouse event processing). i would need the coordinate of the position i clicked onto. with event.GetPosition() i do get a wxPoint, but that position is not in relation to the zooming factor or the device origin. so how can this position (its only the position i clicked on that wxPanel) be processed that it shows me the position without zooming or device origin?
hope you have answers,
regards j