コード例 #1
0
ファイル: component_editor.py プロジェクト: pib/enable
class _ComponentEditor( Editor ):

    #---------------------------------------------------------------------------
    #  Trait definitions:
    #---------------------------------------------------------------------------

    # The plot editor is scrollable (overrides Traits UI Editor).
    scrollable = True

    def init( self, parent ):
        """ Finishes initializing the editor by creating the underlying toolkit
        widget.
        """
        self._window = Window( parent, size=self.factory.size, component=self.value )
        self.control = self._window.control
        self._window.bgcolor = self.factory.bgcolor
        self._parent = parent

    def dispose(self):
        """ Disposes of the contents of an editor.
        """
        self._window.cleanup()
        self._window = None
        self._parent = None
        super(_ComponentEditor, self).dispose()

    def update_editor( self ):
        """ Updates the editor when the object trait changes externally to the
        editor.
        """
        self._window.component = self.value
        return
コード例 #2
0
class MouseWheelTestCase(TestCase):

    def setUp(self):
        import wx

        # set up Enable components and tools
        self.container = Container(postion=[0, 0], bounds=[600, 600])
        self.tool = MouseEventTool(component=self.container)
        self.container.tools.append(self.tool)

        # set up wx components and tools
        self.parent = wx.Frame(None, size=(600, 600))
        self.window = Window(
            self.parent,
            size=(600, 600),
            component=self.container
        )

        # Hack: event processing code skips if window not actually shown by
        # testing for value of _size
        self.window._size = (600, 600)

    def test_vertical_mouse_wheel(self):
        import wx

        # create and mock a mouse wheel event
        wx_event = wx.MouseEvent(mouseType=wx.wxEVT_MOUSEWHEEL)
        wx_event.GetWheelRotation = MagicMock(return_value=200)
        wx_event.GetWheelAxis = MagicMock(return_value=wx.MOUSE_WHEEL_VERTICAL)
        wx_event.GetLinesPerAction = MagicMock(return_value=1)
        wx_event.GetWheelDelta = MagicMock(return_value=120)

        # dispatch event
        self.window._on_mouse_wheel(wx_event)

        # validate results
        self.assertEqual(self.tool.event.mouse_wheel_axis, 'vertical')
        self.assertAlmostEqual(self.tool.event.mouse_wheel, 5.0/3.0)
        self.assertEqual(self.tool.event.mouse_wheel_delta, (0, 200))

    def test_horizontal_mouse_wheel(self):
        import wx

        # create and mock a mouse wheel event
        wx_event = wx.MouseEvent(mouseType=wx.wxEVT_MOUSEWHEEL)
        wx_event.GetWheelRotation = MagicMock(return_value=200)
        wx_event.GetWheelAxis = MagicMock(
            return_value=wx.MOUSE_WHEEL_HORIZONTAL)
        wx_event.GetLinesPerAction = MagicMock(return_value=1)
        wx_event.GetWheelDelta = MagicMock(return_value=120)

        # dispatch event
        self.window._handle_mouse_event('mouse_wheel', wx_event)

        # validate results
        self.assertEqual(self.tool.event.mouse_wheel_axis, 'horizontal')
        self.assertAlmostEqual(self.tool.event.mouse_wheel, 5.0/3.0)
        self.assertEqual(self.tool.event.mouse_wheel_delta, (200, 0))
コード例 #3
0
ファイル: component_editor.py プロジェクト: GaZ3ll3/enable
class _ComponentEditor( Editor ):

    #---------------------------------------------------------------------------
    #  Trait definitions:
    #---------------------------------------------------------------------------

    # The plot editor is scrollable (overrides Traits UI Editor).
    scrollable = True

    def init( self, parent ):
        """ Finishes initializing the editor by creating the underlying toolkit
        widget.
        """

        size = self._get_initial_size()

        self._window = Window(parent,
                              size=size,
                              component=self.value)

        self.control = self._window.control
        self._window.bgcolor = self.factory.bgcolor
        self._parent = parent

    def dispose(self):
        """ Disposes of the contents of an editor.
        """
        self._window.cleanup()
        self._window = None
        self._parent = None
        super(_ComponentEditor, self).dispose()

    def update_editor( self ):
        """ Updates the editor when the object trait changes externally to the
        editor.
        """
        self._window.component = self.value
        return

    def _get_initial_size(self):
        """ Compute the initial size of the component.

        Use the item size to set the size of the component;
        if not specified, use the default size given in ComponentEditor.size
        """

        width = self.item.width
        if width < 0:
            width = self.factory.size[0]

        height = self.item.height
        if height < 0:
            height = self.factory.size[1]

        return width, height
コード例 #4
0
class MouseWheelTestCase(TestCase):
    def setUp(self):
        import wx

        # set up Enable components and tools
        self.container = Container(postion=[0, 0], bounds=[600, 600])
        self.tool = MouseEventTool(component=self.container)
        self.container.tools.append(self.tool)

        # set up wx components and tools
        self.parent = wx.Frame(None, size=(600, 600))
        self.window = Window(self.parent,
                             size=(600, 600),
                             component=self.container)

        # Hack: event processing code skips if window not actually shown by
        # testing for value of _size
        self.window._size = (600, 600)

    def test_vertical_mouse_wheel(self):
        import wx

        # create and mock a mouse wheel event
        wx_event = wx.MouseEvent(mouseType=wx.wxEVT_MOUSEWHEEL)
        wx_event.GetWheelRotation = MagicMock(return_value=200)
        wx_event.GetWheelAxis = MagicMock(return_value=wx.MOUSE_WHEEL_VERTICAL)
        wx_event.GetLinesPerAction = MagicMock(return_value=1)
        wx_event.GetWheelDelta = MagicMock(return_value=120)

        # dispatch event
        self.window._on_mouse_wheel(wx_event)

        # validate results
        self.assertEqual(self.tool.event.mouse_wheel_axis, 'vertical')
        self.assertAlmostEqual(self.tool.event.mouse_wheel, 5.0 / 3.0)
        self.assertEqual(self.tool.event.mouse_wheel_delta, (0, 200))

    def test_horizontal_mouse_wheel(self):
        import wx

        # create and mock a mouse wheel event
        wx_event = wx.MouseEvent(mouseType=wx.wxEVT_MOUSEWHEEL)
        wx_event.GetWheelRotation = MagicMock(return_value=200)
        wx_event.GetWheelAxis = MagicMock(
            return_value=wx.MOUSE_WHEEL_HORIZONTAL)
        wx_event.GetLinesPerAction = MagicMock(return_value=1)
        wx_event.GetWheelDelta = MagicMock(return_value=120)

        # dispatch event
        self.window._handle_mouse_event('mouse_wheel', wx_event)

        # validate results
        self.assertEqual(self.tool.event.mouse_wheel_axis, 'horizontal')
        self.assertAlmostEqual(self.tool.event.mouse_wheel, 5.0 / 3.0)
        self.assertEqual(self.tool.event.mouse_wheel_delta, (200, 0))
コード例 #5
0
    def init(self, parent):
        """ Finishes initializing the editor by creating the underlying toolkit
        widget.
        """

        size = self._get_initial_size()

        self._window = Window(parent, size=size, component=self.value)

        self.control = self._window.control
        self._window.bgcolor = self.factory.bgcolor
        self._parent = parent
コード例 #6
0
class _ComponentEditor(Editor):

    # The plot editor is scrollable (overrides Traits UI Editor).
    scrollable = True

    def init(self, parent):
        """ Finishes initializing the editor by creating the underlying toolkit
        widget.
        """

        size = self._get_initial_size()

        self._window = Window(
            parent,
            size=size,
            component=self.value,
            high_resolution=self.factory.high_resolution,
        )

        self.control = self._window.control
        self._window.bgcolor = self.factory.bgcolor
        self._parent = parent

    def dispose(self):
        """ Disposes of the contents of an editor.
        """
        self._window.cleanup()
        self._window = None
        self._parent = None
        super().dispose()

    def update_editor(self):
        """ Updates the editor when the object trait changes externally to the
        editor.
        """
        self._window.component = self.value

    def _get_initial_size(self):
        """ Compute the initial size of the component.

        Use the item size to set the size of the component;
        if not specified, use the default size given in ComponentEditor.size
        """

        width = self.item.width
        if width < 0:
            width = self.factory.size[0]

        height = self.item.height
        if height < 0:
            height = self.factory.size[1]

        return width, height
コード例 #7
0
    def setUp(self):

        # set up Enable components and tools
        self.container = Container(postion=[0, 0], bounds=[600, 600])
        self.tool = MouseEventTool(component=self.container)
        self.container.tools.append(self.tool)

        # set up qt components
        self.window = Window(None, size=(600, 600), component=self.container)

        # Hack: event processing code skips if window not actually shown by
        # testing for value of _size
        self.window._size = (600, 600)
コード例 #8
0
    def init(self, parent):
        factory = self.factory
        container = OverlayPlotContainer(bgcolor='transparent',
                                         padding=0, spacing=0)

        window = Window(parent, component=container)

        interval = self.high - self.low
        data = ([self.low, self.high], [0.5]*2)
        plot = create_line_plot(data, color='black', bgcolor="sys_window")
        plot.x_mapper.range.low = self.low - interval*0.1
        plot.x_mapper.range.high = self.high + interval*0.1
        plot.y_mapper.range.high = 1.0
        plot.y_mapper.range.low = 0.0

        range_selection = RangeSelection(plot, left_button_selects=True)
        # Do not allow the user to reset the range
        range_selection.event_state = "selected"
        range_selection.deselect = lambda x: None
        range_selection.on_trait_change(self.update_interval, 'selection')

        plot.tools.append(range_selection)
        plot.overlays.append(RangeKnobsOverlay(plot))
        self.plot = plot
        container.add(self.plot)

        # To set the low and high, we're actually going to set the
        # 'selection' metadata on the line plot to the tuple (low,high).
        plot.index.metadata["selections"] = (0, 1.0)

        # Tell the editor what to display
        self.control = window.control
        self.control.SetSize((factory.width, factory.height))
コード例 #9
0
ファイル: component_editor.py プロジェクト: pib/enable
 def init( self, parent ):
     """ Finishes initializing the editor by creating the underlying toolkit
     widget.
     """
     self._window = Window( parent, size=self.factory.size, component=self.value )
     self.control = self._window.control
     self._window.bgcolor = self.factory.bgcolor
     self._parent = parent
コード例 #10
0
ファイル: rgba_color_editor.py プロジェクト: alexlib/enable
 def init(self, parent):
     """ Finishes initializing the editor by creating the underlying toolkit
         widget.
     """
     window = Window(parent,
                     component=Label("", border_size=1, font="modern 9"))
     self._swatch = window.component
     self.control = window.control
     self.control.SetSize((110, 20))
コード例 #11
0
ファイル: processing_editor.py プロジェクト: sgallet/pychron
 def create(self, widget):
     #        g = Graph()
     #        g.new_plot()
     #        g.new_series(
     #                   x=[1, 3, 4, 5, 10],
     #                   y=[1, 34, 1235, 112, 312]
     #                   )
     #        self.graph = g
     self._window = Window(
         widget,
         # #                              size=self.factory.size,
         #                               component=self.value
         component=self.component)
     self.control = self._window.control
コード例 #12
0
ファイル: scrollbar_test.py プロジェクト: pingleewu/ShareRoot
    def setUp(self):
        from pyface.qt.QtGui import QApplication
        from pyface.ui.qt4.util.event_loop_helper import EventLoopHelper

        qt_app = QApplication.instance()
        if qt_app is None:
            qt_app = QApplication([])
        self.qt_app = qt_app

        if NativeScrollBar is None:
            raise unittest.SkipTest("Qt4 NativeScrollbar not available.")
        self.gui = GUI()
        self.event_loop_helper = EventLoopHelper(gui=self.gui, qt_app=qt_app)
        self.container = Container(position=[0, 0], bounds=[600, 600])
        self.window = Window(None, size=(600, 600), component=self.container)
コード例 #13
0
    def setUp(self):

        # set up Enable components and tools
        self.container = Container(postion=[0, 0], bounds=[600, 600])
        self.tool = MouseEventTool(component=self.container)
        self.container.tools.append(self.tool)

        # set up qt components
        self.window = Window(
            None,
            size=(600, 600),
            component=self.container
        )

        # Hack: event processing code skips if window not actually shown by
        # testing for value of _size
        self.window._size = (600, 600)
コード例 #14
0
ファイル: test_mouse_wheel.py プロジェクト: alexlib/enable
class MouseWheelTestCase(TestCase):
    def setUp(self):
        import wx

        # set up Enable components and tools
        self.container = Container(postion=[0, 0], bounds=[600, 600])
        self.tool = MouseEventTool(component=self.container)
        self.container.tools.append(self.tool)

        # set up wx components and tools
        self.parent = wx.Frame(None, size=(600, 600))
        self.window = Window(
            self.parent, size=(600, 600), component=self.container
        )

        # Hack: event processing code skips if window not actually shown by
        # testing for value of _size
        self.window._size = (600, 600)

    def test_vertical_mouse_wheel(self):
        import wx

        # create and mock a mouse wheel event
        wx_event = wx.MouseEvent(wx.wxEVT_MOUSEWHEEL)
        wx_event.GetWheelRotation = MagicMock(return_value=200)
        wx_event.GetWheelAxis = MagicMock(return_value=wx.MOUSE_WHEEL_VERTICAL)
        wx_event.GetLinesPerAction = MagicMock(return_value=1)
        wx_event.GetWheelDelta = MagicMock(return_value=120)

        # dispatch event
        self.window._on_mouse_wheel(wx_event)

        # validate results
        self.assertEqual(self.tool.event.mouse_wheel_axis, "vertical")
        self.assertAlmostEqual(self.tool.event.mouse_wheel, 5.0 / 3.0)

        # "Expected failure" here
        # The expected value is probably wrong.
        # When the test was written, the expected value was (0, 200)
        # (0, 200) would match Qt test (enthought/enable#458)
        self.assertEqual(self.tool.event.mouse_wheel_delta, (0, 1.0))

    def test_horizontal_mouse_wheel(self):
        import wx

        # create and mock a mouse wheel event
        wx_event = wx.MouseEvent(wx.wxEVT_MOUSEWHEEL)
        wx_event.GetWheelRotation = MagicMock(return_value=200)
        wx_event.GetWheelAxis = MagicMock(
            return_value=wx.MOUSE_WHEEL_HORIZONTAL
        )
        wx_event.GetLinesPerAction = MagicMock(return_value=1)
        wx_event.GetWheelDelta = MagicMock(return_value=120)

        # dispatch event
        self.window._handle_mouse_event("mouse_wheel", wx_event)

        # validate results
        self.assertEqual(self.tool.event.mouse_wheel_axis, "horizontal")
        self.assertAlmostEqual(self.tool.event.mouse_wheel, 5.0 / 3.0)

        # "Expected failure" here
        # The expected value is probably wrong.
        # When the test was written, the expected value was (200, 0)
        # (200, 0) would match Qt test (enthought/enable#458)
        self.assertEqual(self.tool.event.mouse_wheel_delta, (1.0, 0))
コード例 #15
0
class MouseWheelTestCase(TestCase):
    def setUp(self):

        # set up Enable components and tools
        self.container = Container(postion=[0, 0], bounds=[600, 600])
        self.tool = MouseEventTool(component=self.container)
        self.container.tools.append(self.tool)

        # set up qt components
        self.window = Window(None, size=(600, 600), component=self.container)

        # Hack: event processing code skips if window not actually shown by
        # testing for value of _size
        self.window._size = (600, 600)

    def test_vertical_mouse_wheel(self):
        from pyface.qt import QtCore, QtGui

        is_qt4 = (QtCore.__version_info__[0] <= 4)

        # create and mock a mouse wheel event
        if is_qt4:
            qt_event = QtGui.QWheelEvent(QtCore.QPoint(0, 0), 200,
                                         QtCore.Qt.NoButton,
                                         QtCore.Qt.NoModifier,
                                         QtCore.Qt.Vertical)
        else:
            qt_event = QtGui.QWheelEvent(
                QtCore.QPointF(0, 0),
                self.window.control.mapToGlobal(QtCore.QPoint(0, 0)),
                QtCore.QPoint(0, 200), QtCore.QPoint(0, 200), 200,
                QtCore.Qt.Vertical, QtCore.Qt.NoButton, QtCore.Qt.NoModifier,
                QtCore.Qt.ScrollUpdate)

        # dispatch event
        self.window._on_mouse_wheel(qt_event)

        # validate results
        self.assertEqual(self.tool.event.mouse_wheel_axis, 'vertical')
        self.assertAlmostEqual(self.tool.event.mouse_wheel, 5.0 / 3.0)
        self.assertEqual(self.tool.event.mouse_wheel_delta, (0, 200))

    def test_horizontal_mouse_wheel(self):
        from pyface.qt import QtCore, QtGui

        is_qt4 = (QtCore.__version_info__[0] <= 4)

        # create and mock a mouse wheel event
        if is_qt4:
            qt_event = QtGui.QWheelEvent(QtCore.QPoint(0, 0), 200,
                                         QtCore.Qt.NoButton,
                                         QtCore.Qt.NoModifier,
                                         QtCore.Qt.Horizontal)
        else:
            qt_event = QtGui.QWheelEvent(
                QtCore.QPoint(0, 0),
                self.window.control.mapToGlobal(QtCore.QPoint(0, 0)),
                QtCore.QPoint(200, 0), QtCore.QPoint(200, 0), 200,
                QtCore.Qt.Vertical, QtCore.Qt.NoButton, QtCore.Qt.NoModifier,
                QtCore.Qt.ScrollUpdate)

        # dispatch event
        self.window._on_mouse_wheel(qt_event)

        # validate results
        self.assertEqual(self.tool.event.mouse_wheel_axis, 'horizontal')
        self.assertAlmostEqual(self.tool.event.mouse_wheel, 5.0 / 3.0)
        self.assertEqual(self.tool.event.mouse_wheel_delta, (200, 0))

    def test_vertical_mouse_wheel_without_pixel_delta(self):
        from pyface.qt import QtCore, QtGui
        is_qt4 = (QtCore.__version_info__[0] <= 4)
        if is_qt4:
            self.skipTest("Not directly applicable in Qt4")

        # create and mock a mouse wheel event
        qt_event = QtGui.QWheelEvent(
            QtCore.QPointF(0, 0),
            self.window.control.mapToGlobal(QtCore.QPoint(0, 0)),
            QtCore.QPoint(0, 0), QtCore.QPoint(0,
                                               200), 200, QtCore.Qt.Vertical,
            QtCore.Qt.NoButton, QtCore.Qt.NoModifier, QtCore.Qt.ScrollUpdate)

        # dispatch event
        self.window._on_mouse_wheel(qt_event)

        # validate results
        self.assertEqual(self.tool.event.mouse_wheel_axis, 'vertical')
        self.assertEqual(self.tool.event.mouse_wheel, 5.0 / 3.0)
        self.assertEqual(self.tool.event.mouse_wheel_delta, (0, 200))
コード例 #16
0
class MouseWheelTestCase(TestCase):

    def setUp(self):

        # set up Enable components and tools
        self.container = Container(postion=[0, 0], bounds=[600, 600])
        self.tool = MouseEventTool(component=self.container)
        self.container.tools.append(self.tool)

        # set up qt components
        self.window = Window(
            None,
            size=(600, 600),
            component=self.container
        )

        # Hack: event processing code skips if window not actually shown by
        # testing for value of _size
        self.window._size = (600, 600)

    def test_vertical_mouse_wheel(self):
        from pyface.qt import QtCore, QtGui

        is_qt4 = (QtCore.__version_info__[0] <= 4)

        # create and mock a mouse wheel event
        if is_qt4:
            qt_event = QtGui.QWheelEvent(
                QtCore.QPoint(0, 0), 200, QtCore.Qt.NoButton,
                QtCore.Qt.NoModifier, QtCore.Qt.Vertical
            )
        else:
            qt_event = QtGui.QWheelEvent(
                QtCore.QPointF(0, 0),
                self.window.control.mapToGlobal(QtCore.QPoint(0, 0)),
                QtCore.QPoint(0, 200), QtCore.QPoint(0, 200), 200,
                QtCore.Qt.Vertical, QtCore.Qt.NoButton, QtCore.Qt.NoModifier,
                QtCore.Qt.ScrollUpdate
            )

        # dispatch event
        self.window._on_mouse_wheel(qt_event)

        # validate results
        self.assertEqual(self.tool.event.mouse_wheel_axis, 'vertical')
        self.assertAlmostEqual(self.tool.event.mouse_wheel, 5.0/3.0)
        self.assertEqual(self.tool.event.mouse_wheel_delta, (0, 200))

    def test_horizontal_mouse_wheel(self):
        from pyface.qt import QtCore, QtGui

        is_qt4 = (QtCore.__version_info__[0] <= 4)

        # create and mock a mouse wheel event
        if is_qt4:
            qt_event = QtGui.QWheelEvent(
                QtCore.QPoint(0, 0), 200, QtCore.Qt.NoButton,
                QtCore.Qt.NoModifier, QtCore.Qt.Horizontal
            )
        else:
            qt_event = QtGui.QWheelEvent(
                QtCore.QPoint(0, 0),
                self.window.control.mapToGlobal(QtCore.QPoint(0, 0)),
                QtCore.QPoint(200, 0), QtCore.QPoint(200, 0), 200,
                QtCore.Qt.Vertical, QtCore.Qt.NoButton, QtCore.Qt.NoModifier,
                QtCore.Qt.ScrollUpdate
            )

        # dispatch event
        self.window._on_mouse_wheel(qt_event)

        # validate results
        self.assertEqual(self.tool.event.mouse_wheel_axis, 'horizontal')
        self.assertAlmostEqual(self.tool.event.mouse_wheel, 5.0/3.0)
        self.assertEqual(self.tool.event.mouse_wheel_delta, (200, 0))

    def test_vertical_mouse_wheel_without_pixel_delta(self):
        from pyface.qt import QtCore, QtGui
        is_qt4 = (QtCore.__version_info__[0] <= 4)
        if is_qt4:
            self.skipTest("Not directly applicable in Qt4")

        # create and mock a mouse wheel event
        qt_event = QtGui.QWheelEvent(
            QtCore.QPointF(0, 0),
            self.window.control.mapToGlobal(QtCore.QPoint(0, 0)),
            QtCore.QPoint(0, 0), QtCore.QPoint(0, 200), 200,
            QtCore.Qt.Vertical, QtCore.Qt.NoButton, QtCore.Qt.NoModifier,
            QtCore.Qt.ScrollUpdate
        )

        # dispatch event
        self.window._on_mouse_wheel(qt_event)

        # validate results
        self.assertEqual(self.tool.event.mouse_wheel_axis, 'vertical')
        self.assertEqual(self.tool.event.mouse_wheel, 5.0/3.0)
        self.assertEqual(self.tool.event.mouse_wheel_delta, (0, 200))
コード例 #17
0
ファイル: test_mouse_wheel.py プロジェクト: alexlib/enable
class MouseWheelTestCase(TestCase):
    def setUp(self):

        # set up Enable components and tools
        self.container = Container(postion=[0, 0], bounds=[600, 600])
        self.tool = MouseEventTool(component=self.container)
        self.container.tools.append(self.tool)

        # set up qt components
        self.window = Window(None, size=(600, 600), component=self.container)

        # Hack: event processing code skips if window not actually shown by
        # testing for value of _size
        self.window._size = (600, 600)

    def test_vertical_mouse_wheel(self):
        from pyface.qt import QtCore, QtGui, is_qt4, is_qt5

        # create and mock a mouse wheel event
        if is_qt4:
            qt_event = QtGui.QWheelEvent(
                QtCore.QPoint(0, 0),  # pos
                200,  # delta
                QtCore.Qt.NoButton,  # buttons
                QtCore.Qt.NoModifier,  # modifiers
                QtCore.Qt.Vertical,  # orient
            )
        elif is_qt5:
            qt_event = QtGui.QWheelEvent(
                QtCore.QPoint(0, 0),  # pos
                self.window.control.mapToGlobal(QtCore.QPoint(0,
                                                              0)),  # globalPos
                QtCore.QPoint(0, 200),  # pixelDelta
                QtCore.QPoint(0, 200),  # angleDelta
                200,  # qt4Delta
                QtCore.Qt.Vertical,  # qt4Orietation
                QtCore.Qt.NoButton,  # buttons
                QtCore.Qt.NoModifier,  # modifiers
                QtCore.Qt.ScrollUpdate,  # phase
            )
        else:
            qt_event = QtGui.QWheelEvent(
                QtCore.QPointF(0, 0),  # pos
                self.window.control.mapToGlobal(QtCore.QPointF(
                    0, 0)),  # globalPos
                QtCore.QPoint(0, 200),  # pixelDelta
                QtCore.QPoint(0, 200),  # angleDelta
                QtCore.Qt.NoButton,  # buttons
                QtCore.Qt.NoModifier,  # modifiers
                QtCore.Qt.ScrollUpdate,  # phase
                False,  # inverted
            )

        # dispatch event
        self.window._on_mouse_wheel(qt_event)

        # validate results
        self.assertEqual(self.tool.event.mouse_wheel_axis, "vertical")
        self.assertAlmostEqual(self.tool.event.mouse_wheel, 5.0 / 3.0)
        self.assertEqual(self.tool.event.mouse_wheel_delta, (0, 200))

    def test_horizontal_mouse_wheel(self):
        from pyface.qt import QtCore, QtGui, is_qt4, is_qt5

        # create and mock a mouse wheel event
        if is_qt4:
            qt_event = QtGui.QWheelEvent(
                QtCore.QPoint(0, 0),  # pos
                200,  # delta
                QtCore.Qt.NoButton,  # buttons
                QtCore.Qt.NoModifier,  # modifiers
                QtCore.Qt.Horizontal,  # orient
            )
        elif is_qt5:
            qt_event = QtGui.QWheelEvent(
                QtCore.QPoint(0, 0),  # pos
                self.window.control.mapToGlobal(QtCore.QPoint(0,
                                                              0)),  # globalPos
                QtCore.QPoint(200, 0),  # pixelDelta
                QtCore.QPoint(200, 0),  # angleDelta
                200,  # qt4Delta
                QtCore.Qt.Horizontal,  # qt4Orietation
                QtCore.Qt.NoButton,  # buttons
                QtCore.Qt.NoModifier,  # modifiers
                QtCore.Qt.ScrollUpdate,  # phase
            )
        else:
            qt_event = QtGui.QWheelEvent(
                QtCore.QPointF(0, 0),  # pos
                self.window.control.mapToGlobal(QtCore.QPointF(
                    0, 0)),  # globalPos
                QtCore.QPoint(200, 0),  # pixelDelta
                QtCore.QPoint(200, 0),  # angleDelta
                QtCore.Qt.NoButton,  # buttons
                QtCore.Qt.NoModifier,  # modifiers
                QtCore.Qt.ScrollUpdate,  # phase
                False,  # inverted
            )

        # dispatch event
        self.window._on_mouse_wheel(qt_event)

        # validate results
        self.assertEqual(self.tool.event.mouse_wheel_axis, "horizontal")
        self.assertAlmostEqual(self.tool.event.mouse_wheel, 5.0 / 3.0)
        self.assertEqual(self.tool.event.mouse_wheel_delta, (200, 0))

    def test_vertical_mouse_wheel_without_pixel_delta(self):
        from pyface.qt import QtCore, QtGui, is_qt4, is_qt5

        # create and mock a mouse wheel event
        if is_qt4:
            qt_event = QtGui.QWheelEvent(
                QtCore.QPoint(0, 0),  # pos
                200,  # delta
                QtCore.Qt.NoButton,  # buttons
                QtCore.Qt.NoModifier,  # modifiers
                QtCore.Qt.Vertical,  # orient
            )
        elif is_qt5:
            qt_event = QtGui.QWheelEvent(
                QtCore.QPoint(0, 0),  # pos
                self.window.control.mapToGlobal(QtCore.QPoint(0,
                                                              0)),  # globalPos
                QtCore.QPoint(0, 0),  # pixelDelta
                QtCore.QPoint(0, 200),  # angleDelta
                200,  # qt4Delta
                QtCore.Qt.Horizontal,  # qt4Orientation
                QtCore.Qt.NoButton,  # buttons
                QtCore.Qt.NoModifier,  # modifiers
                QtCore.Qt.ScrollUpdate,  # phase
            )
        else:
            qt_event = QtGui.QWheelEvent(
                QtCore.QPointF(0, 0),  # pos
                self.window.control.mapToGlobal(QtCore.QPointF(
                    0, 0)),  # globalPos
                QtCore.QPoint(0, 0),  # pixelDelta
                QtCore.QPoint(0, 200),  # angleDelta
                QtCore.Qt.NoButton,  # buttos
                QtCore.Qt.NoModifier,  # modifiers
                QtCore.Qt.ScrollUpdate,  # phase
                False,  # inverted
            )

        # dispatch event
        self.window._on_mouse_wheel(qt_event)

        # validate results
        self.assertEqual(self.tool.event.mouse_wheel_axis, "vertical")
        self.assertEqual(self.tool.event.mouse_wheel, 5.0 / 3.0)
        self.assertEqual(self.tool.event.mouse_wheel_delta, (0, 200))