de.matthiasmann.twl
Class Scrollbar

java.lang.Object
  extended by de.matthiasmann.twl.Widget
      extended by de.matthiasmann.twl.Scrollbar

public class Scrollbar
extends Widget

A scroll bar.

The Scrollbar supports two optional image parameters which can be used to color the track on up/left and right/bottom side of the thumb differently:

These image are drawn in the inner widget area up the the edge of the thumb. use inset to exclude/include more area.


Nested Class Summary
static class Scrollbar.Orientation
           
 
Nested classes/interfaces inherited from class de.matthiasmann.twl.Widget
Widget.OffscreenMouseAdjustments, Widget.RenderOffscreen
 
Field Summary
 
Fields inherited from class de.matthiasmann.twl.Widget
STATE_DISABLED, STATE_HAS_FOCUSED_CHILD, STATE_HAS_OPEN_POPUPS, STATE_KEYBOARD_FOCUS
 
Constructor Summary
Scrollbar()
           
Scrollbar(Scrollbar.Orientation orientation)
           
 
Method Summary
 void addCallback(java.lang.Runnable cb)
           
protected  void afterAddToGUI(GUI gui)
          Called after this widget has been added to a GUI tree.
protected  void applyTheme(ThemeInfo themeInfo)
          Apply the given theme.
protected  void applyThemeScrollbar(ThemeInfo themeInfo)
           
protected  void beforeRemoveFromGUI(GUI gui)
          Called when this widget is removed from the GUI tree.
protected  void doCallback()
           
 void externalDragged(int deltaX, int deltaY)
           
 void externalDragStart()
           
 void externalDragStopped()
           
 int getMaxValue()
           
 int getMinHeight()
          Returns the minimum height of the widget.
 int getMinValue()
           
 int getMinWidth()
          Returns the minimum width of the widget.
 IntegerModel getModel()
           
 Scrollbar.Orientation getOrientation()
           
 int getPageSize()
           
 int getPreferredHeight()
          Returns the preferred height.
 int getPreferredWidth()
          Returns the preferred width based on it's children and preferred inner width.
 int getStepSize()
           
 java.lang.Object getThumbTooltipContent()
           
 int getValue()
           
 boolean handleEvent(Event evt)
          Called when an event occurred that this widget could be interested in.
 boolean isDownRightButtonArmed()
           
 boolean isScaleThumb()
           
 boolean isThumbDragged()
           
 boolean isUpLeftButtonArmed()
           
protected  void layout()
          Called when the layoutInvalid flag is set.
protected  void paintWidget(GUI gui)
          Called by Widget.paint(de.matthiasmann.twl.GUI) after painting the background and before painting all children.
 void removeCallback(java.lang.Runnable cb)
           
 void scroll(int amount)
           
 void scrollToArea(int start, int size, int extra)
          Tries to make the specified area completely visible.
 void setMinMaxValue(int minValue, int maxValue)
           
 void setModel(IntegerModel model)
           
 void setPageSize(int pageSize)
           
 void setScaleThumb(boolean scaleThumb)
           
 void setStepSize(int stepSize)
           
 void setThumbTooltipContent(java.lang.Object tooltipContent)
           
 void setValue(int current)
           
 void setValue(int value, boolean fireCallbacks)
           
 
Methods inherited from class de.matthiasmann.twl.Widget
add, addActionMapping, addPropertyChangeListener, addPropertyChangeListener, adjustSize, allChildrenRemoved, applyThemeBackground, applyThemeBorder, applyThemeInputMap, applyThemeMaxSize, applyThemeMinSize, applyThemeMouseCursor, applyThemeOffscreenExtra, applyThemeOverlay, applyThemeTooltip, borderChanged, canAcceptKeyboardFocus, childAdded, childInvalidateLayout, childRemoved, childVisibilityChanged, computeSize, destroy, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, focusFirstChild, focusLastChild, focusNextChild, focusPrevChild, getActionMap, getAnimationState, getBackground, getBorderBottom, getBorderHorizontal, getBorderLeft, getBorderRight, getBorderTop, getBorderVertical, getBottom, getChild, getChildAt, getChildIndex, getGUI, getHeight, getInnerBottom, getInnerHeight, getInnerRight, getInnerWidth, getInnerX, getInnerY, getInputMap, getKeyboardFocusOrder, getMaxHeight, getMaxWidth, getMouseCursor, getMouseCursor, getNumChildren, getOffscreenExtraBottom, getOffscreenExtraLeft, getOffscreenExtraRight, getOffscreenExtraTop, getOrCreateActionMap, getOverlay, getParent, getPreferredInnerHeight, getPreferredInnerWidth, getRenderOffscreen, getRight, getRootWidget, getTheme, getThemePath, getThemeTooltipContent, getTintAnimator, getTooltipContent, getTooltipContentAt, getWidgetAt, getWidth, getX, getY, giveupKeyboardFocus, handleKeyStrokeAction, hasKeyboardFocus, hasOpenPopups, hasSharedAnimationState, insertChild, invalidateLayout, invalidateLayoutLocally, isAbsoluteTheme, isClip, isDepthFocusTraversal, isEnabled, isFocusKeyEnabled, isInside, isLocallyEnabled, isMouseInside, isVisible, keyboardFocusChildChanged, keyboardFocusGained, keyboardFocusGained, keyboardFocusLost, layoutChildFullInnerArea, layoutChildrenFullInnerArea, moveChild, paint, paintBackground, paintChild, paintChildren, paintDragOverlay, paintOverlay, positionChanged, reapplyTheme, removeAllChildren, removeChild, removeChild, removePropertyChangeListener, removePropertyChangeListener, requestKeyboardFocus, requestKeyboardFocus, resetTooltip, setActionMap, setBackground, setBorderSize, setBorderSize, setBorderSize, setBorderSize, setCanAcceptKeyboardFocus, setClip, setDepthFocusTraversal, setEnabled, setFocusKeyEnabled, setInnerSize, setInputMap, setMaxSize, setMinSize, setMouseCursor, setOffscreenExtra, setOffscreenExtra, setOverlay, setPosition, setRenderOffscreen, setSize, setTheme, setTintAnimator, setTooltipContent, setVisible, sizeChanged, updateTintAnimation, updateTooltip, validateLayout, widgetDisabled
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Scrollbar

public Scrollbar()

Scrollbar

public Scrollbar(Scrollbar.Orientation orientation)
Method Detail

addCallback

public void addCallback(java.lang.Runnable cb)

removeCallback

public void removeCallback(java.lang.Runnable cb)

doCallback

protected void doCallback()

getOrientation

public Scrollbar.Orientation getOrientation()

getModel

public IntegerModel getModel()

setModel

public void setModel(IntegerModel model)

getValue

public int getValue()

setValue

public void setValue(int current)

setValue

public void setValue(int value,
                     boolean fireCallbacks)

scroll

public void scroll(int amount)

scrollToArea

public void scrollToArea(int start,
                         int size,
                         int extra)
Tries to make the specified area completely visible. If it is larger then the page size then it scrolls to the start of the area.

Parameters:
start - the position of the area
size - size of the area
extra - the extra space which should be visible around the area

getMinValue

public int getMinValue()

getMaxValue

public int getMaxValue()

setMinMaxValue

public void setMinMaxValue(int minValue,
                           int maxValue)

getPageSize

public int getPageSize()

setPageSize

public void setPageSize(int pageSize)

getStepSize

public int getStepSize()

setStepSize

public void setStepSize(int stepSize)

isScaleThumb

public boolean isScaleThumb()

setScaleThumb

public void setScaleThumb(boolean scaleThumb)

externalDragStart

public void externalDragStart()

externalDragged

public void externalDragged(int deltaX,
                            int deltaY)

externalDragStopped

public void externalDragStopped()

isUpLeftButtonArmed

public boolean isUpLeftButtonArmed()

isDownRightButtonArmed

public boolean isDownRightButtonArmed()

isThumbDragged

public boolean isThumbDragged()

setThumbTooltipContent

public void setThumbTooltipContent(java.lang.Object tooltipContent)

getThumbTooltipContent

public java.lang.Object getThumbTooltipContent()

applyTheme

protected void applyTheme(ThemeInfo themeInfo)
Description copied from class: Widget
Apply the given theme. This method also calls invalidateLayout()

Overrides:
applyTheme in class Widget
Parameters:
themeInfo - The theme info for this widget

applyThemeScrollbar

protected void applyThemeScrollbar(ThemeInfo themeInfo)

paintWidget

protected void paintWidget(GUI gui)
Description copied from class: Widget
Called by Widget.paint(de.matthiasmann.twl.GUI) after painting the background and before painting all children.

This should be overwritten instead of paint if normal themeable painting is desired by the subclass.

The default implementation does nothing.

Overrides:
paintWidget in class Widget
Parameters:
gui - the GUI object - it's the same as getGUI()

afterAddToGUI

protected void afterAddToGUI(GUI gui)
Description copied from class: Widget
Called after this widget has been added to a GUI tree.

Overrides:
afterAddToGUI in class Widget
Parameters:
gui - the GUI object - same as getGUI()
See Also:
Widget.getGUI()

beforeRemoveFromGUI

protected void beforeRemoveFromGUI(GUI gui)
Description copied from class: Widget
Called when this widget is removed from the GUI tree. After this call getGUI() will return null.

Overrides:
beforeRemoveFromGUI in class Widget
Parameters:
gui - the GUI object - same as getGUI()
See Also:
Widget.getGUI()

handleEvent

public boolean handleEvent(Event evt)
Description copied from class: Widget
Called when an event occurred that this widget could be interested in.

The default implementation handles only keyboard events and delegates them to the child widget which has keyboard focus. If focusKey handling is enabled then this widget cycles the keyboard focus through it's children. If the key was not consumed by a child or focusKey and an inputMap is specified then the event is translated by the InputMap and handleKeyStrokeAction is called when a mapping was found.

If the widget wants to receive mouse events then it must return true for all mouse events except for MOUSE_WHEEL (which is optional) event. Otherwise the following mouse event are not send. Before mouse movement or button events are send a MOUSE_ENTERED event is send first.

Overrides:
handleEvent in class Widget
Parameters:
evt - The event - do not store this object - it may be reused
Returns:
true if the widget handled this event
See Also:
Widget.setFocusKeyEnabled(boolean), Widget.handleKeyStrokeAction(java.lang.String, de.matthiasmann.twl.Event), Widget.setInputMap(de.matthiasmann.twl.InputMap)

getMinWidth

public int getMinWidth()
Description copied from class: Widget
Returns the minimum width of the widget. Layout manager will allocate atleast the minimum width to a widget even when the container is not big enough. The default implementation will not return values smaller then the current border width.

Overrides:
getMinWidth in class Widget
Returns:
the minimum width of the widget

getMinHeight

public int getMinHeight()
Description copied from class: Widget
Returns the minimum height of the widget. Layout manager will allocate atleast the minimum height to a widget even when the container is not big enough. The default implementation will not return values smaller then the current border width.

Overrides:
getMinHeight in class Widget
Returns:
the minimum height of the widget

getPreferredWidth

public int getPreferredWidth()
Description copied from class: Widget
Returns the preferred width based on it's children and preferred inner width. Subclasses can overwrite this method to compute the preferred size differently.

Overrides:
getPreferredWidth in class Widget
Returns:
the preferred width.
See Also:
Widget.getPreferredInnerWidth()

getPreferredHeight

public int getPreferredHeight()
Description copied from class: Widget
Returns the preferred height. This method determines the preferred height based on it's children. Subclasses can overwrite this method to compute the preferred size differently.

Overrides:
getPreferredHeight in class Widget
Returns:
the preferred height.
See Also:
Widget.getPreferredInnerHeight()

layout

protected void layout()
Description copied from class: Widget
Called when the layoutInvalid flag is set. The default implementation does nothing.

Overrides:
layout in class Widget