PulpCore

pulpcore.sprite
Class ScrollPane

java.lang.Object
  extended by pulpcore.sprite.Sprite
      extended by pulpcore.sprite.Group
          extended by pulpcore.sprite.ScrollPane
All Implemented Interfaces:
PropertyListener

public class ScrollPane
extends Group

A ScrollPane is a Viewport with scroll bars that appear as needed. Note, the scroll bars' appearance is currently limited (no dynamic thumb size).

To avoid a horizontal scroll bar automatically appearing, set the width of the ScrollPane to maxContentWidth + ScrollPane.SCROLLBAR_WIDTH.


Field Summary
static int SCROLLBAR_ALWAYS
          The scrollbar always appears.
static int SCROLLBAR_AUTO
          The scrollbar always automatically as needed.
static int SCROLLBAR_NEVER
          The scrollbar never appears.
static int SCROLLBAR_WIDTH
           
 Bool scrollPixelSnapping
          The flag to indicate pixel snapping for scroll location.
 Fixed scrollX
          The scroll x location.
 Fixed scrollY
          The scroll y location.
 
Fields inherited from class pulpcore.sprite.Sprite
alpha, anchorX, anchorY, angle, CENTER, DEFAULT, EAST, enabled, height, NORTH, NORTH_EAST, NORTH_WEST, pixelSnapping, SOUTH, SOUTH_EAST, SOUTH_WEST, visible, WEST, width, x, y
 
Constructor Summary
ScrollPane(int x, int y, int w, int h)
          Creates a ScrollPane where both the horizontal and vertical scrollbars appear automatically as needed.
ScrollPane(int x, int y, int w, int h, int verticalScrollBarAppears, int horizontalScrollBarAppears)
          Creates a ScrollPane where both the horizontal and vertical scrollbars appear according the the specified flags.
 
Method Summary
 void add(int index, Sprite sprite)
          Calls add(index, sprite) on the internal Viewport.
 void add(Sprite sprite)
          Calls add(sprite) on the internal Viewport.
protected  Button createDownButton()
          Creates a down arrow button for the vertical scroll bar, using the default appearance.
protected  Slider createHorizontalScrollBar(int width)
          Creates a horizontal scroll bar with the default appearance.
protected  Button createLeftButton()
          Creates a left arrow button for the horizontal scroll bar, using the default appearance.
protected  Button createRightButton()
          Creates a right arrow button for the vertical scroll bar, using the default appearance.
protected  Button createUpButton()
          Creates an up arrow button for the vertical scroll bar, using the default appearance.
protected  Slider createVerticalScrollBar(int height)
          Creates a vertical scroll bar with the default appearance.
 int getContentHeight()
           
 Group getContentPane()
           
 int getContentWidth()
           
 int getScrollUnitSize()
          Gets the amount to scroll when using the arrow keys.
 boolean hasFocus()
          Returns true if this ScrollPane automatically reacts to keyboard events for scrolling.
 void moveDown(Sprite sprite)
          Calls moveDown(sprite) on the internal Viewport.
 void moveToBottom(Sprite sprite)
          Calls moveToBottom(sprite) on the internal Viewport.
 void moveToTop(Sprite sprite)
          Calls moveToTop(sprite) on the internal Viewport.
 void moveUp(Sprite sprite)
          Calls moveUp(sprite) on the internal Viewport.
 void remove(Sprite sprite)
          Calls remove(sprite) on the internal Viewport.
 void removeAll()
          Calls removeAll() on the internal Viewport.
 void scrollDown()
          Scrolls down one unit, if possible.
 void scrollEnd()
          Scrolls to the bottom, if possible.
 void scrollHome()
          Scrolls to the top, if possible.
 void scrollHorizontal(int units)
          Scrolls horizontally by the specificed number of units, if possible.
 void scrollLeft()
          Scrolls left one unit, if possible.
 void scrollLeftSide()
          Scrolls to the left-most side, if possible.
 void scrollPageDown()
          Scrolls down one page, if possible.
 void scrollPageLeft()
          Scrolls left one page, if possible.
 void scrollPageRight()
          Scrolls right one page, if possible.
 void scrollPageUp()
          Scrolls up one page, if possible.
 void scrollRight()
          Scrolls right one unit, if possible.
 void scrollRightSide()
          Scrolls to the right-most side, if possible.
 void scrollUp()
          Scrolls up one unit, if possible.
 void scrollVertical(int units)
          Scrolls vertically by the specificed number of units, if possible.
 void setAnimationDuration(int unitDuration, int pageDuration)
          Sets the duration, in milliseconds, when scrolling.
 void setFocus(boolean hasFocus)
          Set whether this ScrollPane automatically reacts to keyboard events for scrolling.
 void setScrollUnitSize(int scrollUnitSize)
          Set the amount to scroll when using the arrow keys.
 void update(int elapsedTime)
          Updates all of this Sprite's properties.
 
Methods inherited from class pulpcore.sprite.Group
contains, createBackBuffer, createBackBuffer, drawSprite, findWithTag, get, getBackBuffer, getBackBufferBlendMode, getNaturalHeight, getNaturalWidth, getNumSprites, getNumVisibleSprites, getRemovedSprites, hasBackBuffer, isAncestorOf, isOverflowClipped, iterator, pack, pick, pickEnabledAndVisible, propertyChange, removeBackBuffer, setBackBufferBlendMode, size
 
Methods inherited from class pulpcore.sprite.Sprite
bindLocationTo, bindSizeTo, clearCursor, clearDirtyRect, contains, draw, getBlendMode, getCursor, getDirtyRect, getFilter, getLocalX, getLocalY, getParent, getPixelLevelChecks, getRoot, getScene2D, getTag, getViewX, getViewX, getViewY, getViewY, intersects, isDirty, isEnabled, isEnabledAndVisible, isMouseDoubleClicked, isMouseDown, isMouseHover, isMouseOver, isMousePressed, isMouseReleased, isMouseTripleClicked, isMouseWheelRotated, isOpaque, isPick, isPickEnabledAndVisible, isTransparent, move, move, move, move, move, move, moveTo, moveTo, moveTo, moveTo, moveTo, moveTo, removeFromParent, scale, scale, scale, scale, scale, scale, scaleTo, scaleTo, scaleTo, scaleTo, scaleTo, scaleTo, setAnchor, setAnchor, setBlendMode, setCursor, setDirty, setFilter, setLocation, setLocation, setSize, setSize, setTag, translate, translate, updateDirtyRect
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SCROLLBAR_WIDTH

public static final int SCROLLBAR_WIDTH
See Also:
Constant Field Values

SCROLLBAR_NEVER

public static final int SCROLLBAR_NEVER
The scrollbar never appears.

See Also:
Constant Field Values

SCROLLBAR_ALWAYS

public static final int SCROLLBAR_ALWAYS
The scrollbar always appears.

See Also:
Constant Field Values

SCROLLBAR_AUTO

public static final int SCROLLBAR_AUTO
The scrollbar always automatically as needed.

See Also:
Constant Field Values

scrollX

public final Fixed scrollX
The scroll x location. Identical to getContentPane().x.


scrollY

public final Fixed scrollY
The scroll y location. Identical to getContentPane().y.


scrollPixelSnapping

public final Bool scrollPixelSnapping
The flag to indicate pixel snapping for scroll location. Initially set to true. Identical to getContentPane().pixelSnapping.

Constructor Detail

ScrollPane

public ScrollPane(int x,
                  int y,
                  int w,
                  int h)
Creates a ScrollPane where both the horizontal and vertical scrollbars appear automatically as needed.


ScrollPane

public ScrollPane(int x,
                  int y,
                  int w,
                  int h,
                  int verticalScrollBarAppears,
                  int horizontalScrollBarAppears)
Creates a ScrollPane where both the horizontal and vertical scrollbars appear according the the specified flags.

Parameters:
verticalScrollBarAppears - one of SCROLLBAR_NEVER, SCROLLBAR_ALWAYS, or SCROLLBAR_AUTO.
horizontalScrollBarAppears - one of SCROLLBAR_NEVER, SCROLLBAR_ALWAYS, or SCROLLBAR_AUTO.
Method Detail

hasFocus

public boolean hasFocus()
Returns true if this ScrollPane automatically reacts to keyboard events for scrolling.


setFocus

public void setFocus(boolean hasFocus)
Set whether this ScrollPane automatically reacts to keyboard events for scrolling.


update

public void update(int elapsedTime)
Description copied from class: Sprite
Updates all of this Sprite's properties. Subclasses that override this method should call super.update().

Overrides:
update in class Group

createVerticalScrollBar

protected Slider createVerticalScrollBar(int height)
Creates a vertical scroll bar with the default appearance.

Subclasses may override this method to provide a custom look and feel. The location, range, and value of the Slider is set automatically.


createHorizontalScrollBar

protected Slider createHorizontalScrollBar(int width)
Creates a horizontal scroll bar with the default appearance.

Subclasses may override this method to provide a custom look and feel. The location, range, and value of the Slider is set automatically.


createUpButton

protected Button createUpButton()
Creates an up arrow button for the vertical scroll bar, using the default appearance.

Subclasses may override this method to provide a custom look and feel, and may return null to allow no up button. The location of the Button is set automatically.


createDownButton

protected Button createDownButton()
Creates a down arrow button for the vertical scroll bar, using the default appearance.

Subclasses may override this method to provide a custom look and feel, and may return null to allow no down button. The location of the Button is set automatically.


createLeftButton

protected Button createLeftButton()
Creates a left arrow button for the horizontal scroll bar, using the default appearance.

Subclasses may override this method to provide a custom look and feel, and may return null to allow no left button. The location of the Button is set automatically.


createRightButton

protected Button createRightButton()
Creates a right arrow button for the vertical scroll bar, using the default appearance.

Subclasses may override this method to provide a custom look and feel, and may return null to allow no right button. The location of the Button is set automatically.


setAnimationDuration

public void setAnimationDuration(int unitDuration,
                                 int pageDuration)
Sets the duration, in milliseconds, when scrolling. By default, both animation durations are set to zero.


setScrollUnitSize

public void setScrollUnitSize(int scrollUnitSize)
Set the amount to scroll when using the arrow keys. By default, the value is 1.


getScrollUnitSize

public int getScrollUnitSize()
Gets the amount to scroll when using the arrow keys. By default, the value is 1.


scrollVertical

public void scrollVertical(int units)
Scrolls vertically by the specificed number of units, if possible.

See Also:
setScrollUnitSize(int), setAnimationDuration(int, int)

scrollHorizontal

public void scrollHorizontal(int units)
Scrolls horizontally by the specificed number of units, if possible.

See Also:
setScrollUnitSize(int), setAnimationDuration(int, int)

scrollHome

public void scrollHome()
Scrolls to the top, if possible. No animation is performed.


scrollEnd

public void scrollEnd()
Scrolls to the bottom, if possible. No animation is performed.


scrollLeftSide

public void scrollLeftSide()
Scrolls to the left-most side, if possible. No animation is performed.


scrollRightSide

public void scrollRightSide()
Scrolls to the right-most side, if possible. No animation is performed.


scrollUp

public void scrollUp()
Scrolls up one unit, if possible.

See Also:
setScrollUnitSize(int), setAnimationDuration(int, int)

scrollDown

public void scrollDown()
Scrolls down one unit, if possible.

See Also:
setScrollUnitSize(int), setAnimationDuration(int, int)

scrollLeft

public void scrollLeft()
Scrolls left one unit, if possible.

See Also:
setScrollUnitSize(int), setAnimationDuration(int, int)

scrollRight

public void scrollRight()
Scrolls right one unit, if possible.

See Also:
setScrollUnitSize(int), setAnimationDuration(int, int)

scrollPageUp

public void scrollPageUp()
Scrolls up one page, if possible.

See Also:
setAnimationDuration(int, int)

scrollPageDown

public void scrollPageDown()
Scrolls down one page, if possible.

See Also:
setAnimationDuration(int, int)

scrollPageLeft

public void scrollPageLeft()
Scrolls left one page, if possible.

See Also:
setAnimationDuration(int, int)

scrollPageRight

public void scrollPageRight()
Scrolls right one page, if possible.

See Also:
setAnimationDuration(int, int)

getContentPane

public Group getContentPane()

getContentWidth

public int getContentWidth()

getContentHeight

public int getContentHeight()

add

public void add(Sprite sprite)
Calls add(sprite) on the internal Viewport.

Adds a Sprite to this Group. The Sprite is added so it appears above all other sprites in this Group. If this Sprite already belongs to a Group, it is first removed from that Group before added to this one.

Overrides:
add in class Group

add

public void add(int index,
                Sprite sprite)
Calls add(index, sprite) on the internal Viewport.

Inserts a Sprite to this Group at the specified position. The Sprite at the current position (if any) and any subsequent Sprites are moved up in the z-order (adds one to their indices).

If the index is less than zero, the sprite is inserted at position zero (the bottom in the z-order). If the index is greater than or equal to Group.size(), the sprite is inserted at position Group.size() (the top in the z-order).

Overrides:
add in class Group

remove

public void remove(Sprite sprite)
Calls remove(sprite) on the internal Viewport.

Removes a Sprite from this Group.

Overrides:
remove in class Group

removeAll

public void removeAll()
Calls removeAll() on the internal Viewport.

Removes all Sprites from this Group.

Overrides:
removeAll in class Group

moveToTop

public void moveToTop(Sprite sprite)
Calls moveToTop(sprite) on the internal Viewport.

Moves the specified Sprite to the top of the z-order, so that all the other Sprites currently in this Group appear underneath it. If the specified Sprite is not in this Group, or the Sprite is already at the top, this method does nothing.

Overrides:
moveToTop in class Group

moveToBottom

public void moveToBottom(Sprite sprite)
Calls moveToBottom(sprite) on the internal Viewport.

Moves the specified Sprite to the bottom of the z-order, so that all the other Sprites currently in this Group appear above it. If the specified Sprite is not in this Group, or the Sprite is already at the bottom, this method does nothing.

Overrides:
moveToBottom in class Group

moveUp

public void moveUp(Sprite sprite)
Calls moveUp(sprite) on the internal Viewport.

Moves the specified Sprite up in z-order, swapping places with the first Sprite that appears above it. If the specified Sprite is not in this Group, or the Sprite is already at the top, this method does nothing.

Overrides:
moveUp in class Group

moveDown

public void moveDown(Sprite sprite)
Calls moveDown(sprite) on the internal Viewport.

Moves the specified Sprite down in z-order, swapping places with the first Sprite that appears below it. If the specified Sprite is not in this Group, or the Sprite is already at the bottom, this method does nothing.

Overrides:
moveDown in class Group

PulpCore

Copyright © 2007-2009 Interactive Pulp, LLC.