Example #1
0
    def dock_info_at(self, x, y, size, is_control):
        """ Gets a DockInfo object at a specified x, y position.
        """
        if self.contents is not None:
            return self.contents.dock_info_at(x, y, size, is_control, True)

        return no_dock_info()
Example #2
0
    def mouse_move ( self, event ):
        """ Handles the mouse moving while the left mouse button is pressed.
        """
        # Exit if control is 'fixed' or a 'close' is pending:
        if self._closing or self.locked or (self.style == 'fixed'):
            return

        window = event.control

        # Check to see if we are in 'drag mode' yet:
        if not self._dragging:
            x, y = self._xy
            if (abs( x - event.x ) + abs( y - event.y )) < 3:
                return

            self._dragging  = True
            self._dock_info = no_dock_info()
            self._dock_size = self.tab_width
            self.mark_bounds( True )
            self._dock_info.draw( window, self._drag_bitmap )

        # Get the window and DockInfo object associated with the event:
        cur_dock_info = self._dock_info
        if cur_dock_info is None:
            return

        self._dock_info = dock_info = window.owner.dock_sizer.dock_info_at(
            event.x, event.y, self._dock_size, event.shift_down
        )

        # Make sure the new DockInfo is legal:
        region = self.parent
        if ((not event.control_down)     and
            (dock_info.region is region) and
            ((len( region.contents ) <= 1) or
             (DOCK_XCHG == dock_info.kind) or
             ((DOCK_TAB <= dock_info.kind <= DOCK_BAR) and
              (dock_info.control is self)))):
            self._dock_info = dock_info = no_dock_info()

        # If the DockInfo has not changed, then no update is needed:
        if ((cur_dock_info.kind == dock_info.kind)     and
            (cur_dock_info.region is dock_info.region) and
            (cur_dock_info.bounds == dock_info.bounds)):
            return

        # Draw the new region:
        dock_info.draw( window, self._drag_bitmap )

        # If this is the start of an export (i.e. drag and drop) request:
        if ((dock_info.kind == DOCK_EXPORT) and
            (self.export != '')             and
            (self.dockable is not None)):

            # Begin the drag and drop operation:
            self.mark_bounds( False )
            window.owner.set_cursor( 'arrow' )
            window.owner.release_mouse()
            try:
                window._dragging = True
                if window.drag( self, 'object' ) == 'ignore':
                    window.owner.handler.open_view_for( self )
            finally:
                window._dragging = False
        else:
            # Update the mouse pointer as required:
            cursor = 'sizing'
            if dock_info.kind == DOCK_BAR:
                cursor = 'hand'

            window.owner.set_cursor( cursor )