brf.j2me.dynaworks.ui
Class ScrollBar

java.lang.Object
  |
  +--brf.j2me.dynaworks.ui.BasicWidget
        |
        +--brf.j2me.dynaworks.ui.ScrollBar
All Implemented Interfaces:
UserWidget

public class ScrollBar
extends BasicWidget

Custom user control widget for a scrollbar.

Implements a horizontally or vertically oriented scroll control. The size of the scroll marker is proportional to the size of the view.

Version:
1.0
Author:
Bernd R. Fix
See Also:
BasicWidget, UserWidget

Field Summary
private static Bitmap[] button
          "button" bitmaps
private  int scrollMax
          range value (maximum).
private  int scrollMin
          range value (minimum).
private  int scrollPos
          position of the scroll.
private  int scrollSize
          size of the scroll area.
static int SIZE
          size (width/height) of the control in non-scrolling direction.
private  boolean vertMode
          vertical / horizontal scrollbar.
 
Fields inherited from class brf.j2me.dynaworks.ui.BasicWidget
g, h, w, x, y
 
Constructor Summary
ScrollBar(int x, int y, int len, boolean vertical)
          constructor.
 
Method Summary
(package private) static void ()
           
 int checkPosition(int pos, int size)
          check if a marker at position 'pos' and size 'size' fits into the scrollbar.
 int getCorrespondingPosition(int xc, int yc)
          compute the corresponding scroll marker position for a point 'pt'.
 int getPosition()
          get the current position.
 int getSize()
          get the current size.
 ActionEvent handlePenDown(int xc, int yc)
          Handle a "pen down" event.
 ActionEvent handlePenMove(int xc, int yc)
          Handle a "pen move" event.
 void paint()
          Paint the user control.
 int setPosition(int pos, boolean redraw)
          set the position of the scroll marker.
 void setRange(int min, int max, boolean redraw)
          set the range for the ScrollBar.
 int setSize(int size, boolean redraw)
          set the size of the scroll marker.
 
Methods inherited from class brf.j2me.dynaworks.ui.BasicWidget
contains, handleKeyDown, handlePenUp, handleSysKeyDown, hasFocus, loseFocus, setFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

SIZE

public static final int SIZE
size (width/height) of the control in non-scrolling direction.


scrollMin

private int scrollMin
range value (minimum).


scrollMax

private int scrollMax
range value (maximum).


scrollPos

private int scrollPos
position of the scroll.


scrollSize

private int scrollSize
size of the scroll area.


vertMode

private boolean vertMode
vertical / horizontal scrollbar.


button

private static Bitmap[] button
"button" bitmaps

Constructor Detail

ScrollBar

public ScrollBar(int x,
                 int y,
                 int len,
                 boolean vertical)
constructor.

Parameters:
x - int - x coordinate of upper-left corner.
y - int - y coordinate of upper-left corner.
length - int - length of scrollbar.
vert - boolean - vertical orientation?
Method Detail

static void ()

checkPosition

public int checkPosition(int pos,
                         int size)
check if a marker at position 'pos' and size 'size' fits into the scrollbar. Correct the alignment if neccessary.

Parameters:
pos - int - check position
size - int - check size
Returns:
int - corrected position or -1 for failure.

getCorrespondingPosition

public int getCorrespondingPosition(int xc,
                                    int yc)
compute the corresponding scroll marker position for a point 'pt'.

Parameters:
xc - int - x-coordinate of point pt.
yc - int - y-coordinate of point pt.
Returns:
int - corresponding position or -1 for failure.

setRange

public void setRange(int min,
                     int max,
                     boolean redraw)
set the range for the ScrollBar.

Parameters:
min - int - minimum scroll value.
max - int - maximum scroll value.
redraw - boolean - redraw the control?
pos - int - start position for scroll marker.

setPosition

public int setPosition(int pos,
                       boolean redraw)
set the position of the scroll marker.

Parameters:
pos - int - new position of scroll marker.
redraw - boolean - redraw the control?
Returns:
int - old position of scroll marker.

setSize

public int setSize(int size,
                   boolean redraw)
set the size of the scroll marker.

Parameters:
size - int - new size of scroll marker.
redraw - boolean - redraw the control?
Returns:
int - old size of scroll marker.

getPosition

public int getPosition()
get the current position.

Returns:
int - current position of the scroll marker.

getSize

public int getSize()
get the current size.

Returns:
int - current size of the scroll marker.

handlePenDown

public ActionEvent handlePenDown(int xc,
                                 int yc)
Handle a "pen down" event. Return an ActionEvent if neccessary.

Overrides:
handlePenDown in class BasicWidget
Parameters:
xc - int - x coordinate of hit point.
yc - int - y coordinate of hit point.
Returns:
ActionEvent - event triggered by PenDown (or null).
See Also:
ActionEvent

handlePenMove

public ActionEvent handlePenMove(int xc,
                                 int yc)
Handle a "pen move" event. Return an ActionEvent if neccessary.

Overrides:
handlePenMove in class BasicWidget
Parameters:
xc - int - x coordinate of pen point.
yc - int - y coordinate of pen point.
Returns:
ActionEvent - event triggered by PenMove (or null).
See Also:
ActionEvent

paint

public void paint()
Paint the user control.

Overrides:
paint in class BasicWidget