mirror of
https://github.com/wxWidgets/Phoenix.git
synced 2025-12-16 01:30:07 +01:00
- missed change from SVN, zoom mixin
This commit is contained in:
@@ -28,6 +28,7 @@ import numpy as N
|
||||
from . import FCEvents, Resources
|
||||
from .Utilities import BBox
|
||||
|
||||
|
||||
class Cursors(object):
|
||||
"""
|
||||
Class to hold the standard Cursors
|
||||
@@ -121,6 +122,17 @@ class GUIBase(object):
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
## some mix-ins for use with the other modes:
|
||||
class ZoomWithMouseWheel():
|
||||
def OnWheel(self, event):
|
||||
point = event.Position
|
||||
if event.GetWheelRotation() < 0:
|
||||
self.Canvas.Zoom(0.9, point, centerCoords = "pixel", keepPointInPlace=True)
|
||||
else:
|
||||
self.Canvas.Zoom(1.1, point, centerCoords = "pixel", keepPointInPlace=True)
|
||||
|
||||
|
||||
class GUIMouse(GUIBase):
|
||||
"""
|
||||
|
||||
@@ -183,11 +195,16 @@ class GUIMouse(GUIBase):
|
||||
|
||||
def OnMove(self, event):
|
||||
## The Move event always gets raised, even if there is a hit-test
|
||||
EventType = FCEvents.EVT_FC_MOTION
|
||||
# process the object hit test for EVT_MOTION bindings
|
||||
self.Canvas.HitTest(event, EventType)
|
||||
# process enter and leave events
|
||||
self.Canvas.MouseOverTest(event)
|
||||
self.Canvas._RaiseMouseEvent(event,FCEvents.EVT_FC_MOTION)
|
||||
# then raise the event on the canvas
|
||||
self.Canvas._RaiseMouseEvent(event, EventType)
|
||||
|
||||
|
||||
class GUIMove(GUIBase):
|
||||
class GUIMove(ZoomWithMouseWheel, GUIBase):
|
||||
"""
|
||||
Mode that moves the image (pans).
|
||||
It doesn't change any coordinates, it only changes what the viewport is
|
||||
@@ -293,20 +310,11 @@ class GUIMove(GUIBase):
|
||||
dc.DrawBitmap(self.Canvas._Buffer,xy_tl)
|
||||
#self.Canvas.Update()
|
||||
|
||||
def OnWheel(self, event):
|
||||
"""
|
||||
By default, zoom in/out by a 0.1 factor per Wheel event.
|
||||
"""
|
||||
if event.GetWheelRotation() < 0:
|
||||
self.Canvas.Zoom(0.9)
|
||||
else:
|
||||
self.Canvas.Zoom(1.1)
|
||||
|
||||
class GUIZoomIn(GUIBase):
|
||||
class GUIZoomIn(ZoomWithMouseWheel, GUIBase):
|
||||
"""
|
||||
Mode to zoom in.
|
||||
"""
|
||||
|
||||
def __init__(self, canvas=None):
|
||||
GUIBase.__init__(self, canvas)
|
||||
self.StartRBBox = None
|
||||
@@ -369,17 +377,11 @@ class GUIZoomIn(GUIBase):
|
||||
def OnRightDown(self, event):
|
||||
self.Canvas.Zoom(1/1.5, event.GetPosition(), centerCoords="pixel")
|
||||
|
||||
def OnWheel(self, event):
|
||||
if event.GetWheelRotation() < 0:
|
||||
self.Canvas.Zoom(0.9)
|
||||
else:
|
||||
self.Canvas.Zoom(1.1)
|
||||
|
||||
class GUIZoomOut(GUIBase):
|
||||
class GUIZoomOut(ZoomWithMouseWheel, GUIBase):
|
||||
"""
|
||||
Mode to zoom out.
|
||||
"""
|
||||
|
||||
def __init__(self, Canvas=None):
|
||||
GUIBase.__init__(self, Canvas)
|
||||
self.Cursor = self.Cursors.MagMinusCursor
|
||||
@@ -390,13 +392,6 @@ class GUIZoomOut(GUIBase):
|
||||
def OnRightDown(self, event):
|
||||
self.Canvas.Zoom(1.5, event.GetPosition(), centerCoords="pixel")
|
||||
|
||||
def OnWheel(self, event):
|
||||
if event.GetWheelRotation() < 0:
|
||||
self.Canvas.Zoom(0.9)
|
||||
else:
|
||||
self.Canvas.Zoom(1.1)
|
||||
|
||||
def OnMove(self, event):
|
||||
# Always raise the Move event.
|
||||
self.Canvas._RaiseMouseEvent(event,FCEvents.EVT_FC_MOTION)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user