de.cau.cs.kieler.core.ui.util
Class DragDropScrollHandler

java.lang.Object
  extended by de.cau.cs.kieler.core.ui.util.DragDropScrollHandler
All Implemented Interfaces:
EventListener, MouseListener, MouseMoveListener, org.eclipse.swt.internal.SWTEventListener

public class DragDropScrollHandler
extends Object
implements MouseListener, MouseMoveListener

Adds drag and drop scrolling functionality to a given scrollable. That is, the user can then not only use the scroll bars to scroll, but can click anywhere in the control and drag the mouse to scroll. The control's cursor is optionally set to the hand cursor.

This class assumes that dragging the mouse by 1 pixel would result in changeing the scroll bar value by 1. When dragging occurs, the values of the scroll bar(s) is/are modified and a custom Selection event sent to their selection listeners.

Rating yellow
2010-03-14 reviewed by haf, msp, pkl

Constructor Summary
DragDropScrollHandler(Scrollable control)
          Constructs a new instance managing the given control and sets the control's cursor to the hand cursor.
DragDropScrollHandler(Scrollable control, boolean setCursor)
          Constructs a new instance manageing the given control, optionally setting the control's cursor to the hand cursor.
 
Method Summary
protected  ScrollBar getHorizontalBar()
          Returns the horizontal scroll bar, if any.
protected  ScrollBar getVerticalBar()
          Returns the vertical scroll bar, if any.
 void mouseDoubleClick(MouseEvent e)
          
 void mouseDown(MouseEvent e)
          
 void mouseMove(MouseEvent e)
          
 void mouseUp(MouseEvent e)
          
protected  void notifiyOfValueChange()
          Sends out the event of a scroll bar's value having changed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DragDropScrollHandler

public DragDropScrollHandler(Scrollable control)
Constructs a new instance managing the given control and sets the control's cursor to the hand cursor.

Parameters:
control - the control to manage. Must have at least one of the two styles, H_SCROLL or V_SCROLL, set.

DragDropScrollHandler

public DragDropScrollHandler(Scrollable control,
                             boolean setCursor)
Constructs a new instance manageing the given control, optionally setting the control's cursor to the hand cursor.

Parameters:
control - the control to manage. Must have at least one of the two styles, H_SCROLL or V_SCROLL, set.
setCursor - true if the control's cursor should be set to the hand cursor.
Method Detail

getHorizontalBar

protected ScrollBar getHorizontalBar()
Returns the horizontal scroll bar, if any.

Returns:
the horizontal scroll bar.

getVerticalBar

protected ScrollBar getVerticalBar()
Returns the vertical scroll bar, if any.

Returns:
the vertical scroll bar.

notifiyOfValueChange

protected void notifiyOfValueChange()
Sends out the event of a scroll bar's value having changed. May be overridden.


mouseMove

public void mouseMove(MouseEvent e)

Specified by:
mouseMove in interface MouseMoveListener

mouseDown

public void mouseDown(MouseEvent e)

Specified by:
mouseDown in interface MouseListener

mouseUp

public void mouseUp(MouseEvent e)

Specified by:
mouseUp in interface MouseListener

mouseDoubleClick

public void mouseDoubleClick(MouseEvent e)

Specified by:
mouseDoubleClick in interface MouseListener