=== modified file 'common/zoom.cpp' --- old/common/zoom.cpp 2012-01-23 04:33:36 +0000 +++ new/common/zoom.cpp 2012-03-22 17:42:49 +0000 @@ -81,24 +81,36 @@ bool zoom_at_cursor = false; BASE_SCREEN* screen = GetScreen(); wxPoint center = screen->GetScrollCenterPosition(); + wxPoint MousePosition = screen->RefPos(true); // get the mouse position where the zoom command was issued + double magn_factor = screen->GetZoom(); // get the current zoom factor to calculate the magnification factor later on. + wxPoint canvascenter = m_canvas->GetScreenCenterLogicalPosition(); // the center of the currently seen section of the drawing area switch( id ) { case ID_POPUP_ZOOM_IN: - zoom_at_cursor = true; - center = screen->GetCrossHairPosition(); + if( screen->SetPreviousZoom() ) + { + magn_factor /= screen->GetZoom(); // calculate the relative magnification between the previous and the new zoom factor + // The center for redrawing the screen is somewhere on a line inbetween canvascenter and MousePosition. Where exactly is determined by the magnification factor. + center = wxPoint(wxRound((canvascenter.x-MousePosition.x)/magn_factor+MousePosition.x),wxRound((canvascenter.y-MousePosition.y)/magn_factor+MousePosition.y)); + RedrawScreen( center, zoom_at_cursor ); + } + break; - // fall thru case ID_ZOOM_IN: if( screen->SetPreviousZoom() ) RedrawScreen( center, zoom_at_cursor ); break; case ID_POPUP_ZOOM_OUT: - zoom_at_cursor = true; - center = screen->GetCrossHairPosition(); + if( screen->SetNextZoom() ) + { + magn_factor /= screen->GetZoom(); + center = wxPoint(wxRound((canvascenter.x-MousePosition.x)/magn_factor+MousePosition.x),wxRound((canvascenter.y-MousePosition.y)/magn_factor+MousePosition.y)); + RedrawScreen( center, zoom_at_cursor ); + } + break; - // fall thru case ID_ZOOM_OUT: if( screen->SetNextZoom() ) RedrawScreen( center, zoom_at_cursor );