ScrollArrowLayerpublic class ScrollArrowLayer extends ScrollIndLayer A ScrollArrowLayer is a region of the display used for showing scroll indicator
status arrows. |
Fields Summary |
---|
protected boolean | upVizTrue if up arrow is visible | protected boolean | downVizTrue if down arrow is visible |
Constructors Summary |
---|
public ScrollArrowLayer(CLayer layer)Construct a new ScrollIndLayer, visible, but transparent :)
this(layer, null);
| public ScrollArrowLayer(CLayer layer, ScrollListener listener)Additional constructor.
super(layer, listener);
|
Methods Summary |
---|
private int | getScrollType(int x, int y)Determine he scroll type basing on the pointer coordinates
int ret = SCROLL_NONE;
if (x >= 0 && x <= bounds[W] &&
y >= 0 && y <= bounds[H]) {
if (upViz && y < bounds[H] / 2) {
ret = SCROLL_LINEUP;
} else if (downViz && y > bounds[H] / 2) {
ret = SCROLL_LINEDOWN;
}
}
return ret;
| protected void | paintBody(Graphics g)Paint the scroll indicator. The indicator arrows may be appear
individually
or together, and may vary in appearance based on whether they appear
in the normalsoft button region or an alert's softbutton region.
The visible state is based on the state of the alertMode ,
upViz , and downViz variables set by the
setVerticalScroll method.
if (upViz) {
Image i = ScrollIndSkin.IMAGE_UP;
if (alertMode && ScrollIndSkin.IMAGE_AU_UP != null) {
i = ScrollIndSkin.IMAGE_AU_UP;
}
if (i != null) {
g.drawImage(i, 0, 0, Graphics.LEFT| Graphics.TOP);
}
}
if (downViz) {
Image i = ScrollIndSkin.IMAGE_DN;
if (alertMode && ScrollIndSkin.IMAGE_AU_DN != null) {
i = ScrollIndSkin.IMAGE_AU_DN;
}
if (i != null) {
g.drawImage(i, 0,
bounds[H] - ScrollIndSkin.IMAGE_DN.getHeight(),
Graphics.LEFT | Graphics.TOP);
}
}
| public boolean | pointerInput(int type, int x, int y)Handle input from a pen tap. Parameters describe
the type of pen event and the x,y location in the
layer at which the event occurred. Important : the
x,y location of the pen tap will already be translated
into the coordinate space of the layer.
switch(type) {
case EventConstants.PRESSED:
// case EventConstants.HOLD:
// no action for tap-and-hold in scrollbar
// cancel timer for any press.
int scrollType = getScrollType(x, y);
if (scrollType == SCROLL_LINEDOWN ||
scrollType == SCROLL_LINEUP) {
listener.scrollContent(scrollType, 0);
}
break;
case EventConstants.RELEASED:
// do nothing
break;
default:
break;
}
/* we should process all of the pointer event inside scroll layer
and don't pass it to underlying layer */
return true;
| public void | setBounds()Calculate layer bounds depending on the scrollable
bounds[H] = SoftButtonSkin.HEIGHT;
if (ScrollIndSkin.IMAGE_UP != null) {
bounds[W] = ScrollIndSkin.IMAGE_UP.getWidth();
bounds[H] = (2 * ScrollIndSkin.IMAGE_UP.getHeight());
bounds[Y] = (SoftButtonSkin.HEIGHT - bounds[H]) / 3;
bounds[H] += bounds[Y];
bounds[Y] = ScreenSkin.HEIGHT - SoftButtonSkin.HEIGHT +
bounds[Y];
} else {
bounds[W] = ScrollIndSkin.WIDTH;
bounds[Y] = 3;
}
bounds[X] = (ScreenSkin.WIDTH - bounds[W]) / 2;
| public boolean | setScrollable(CLayer layer)Set new scrollable
boolean ret = super.setScrollable(layer);
if (ret) {
alertMode |= scrollable instanceof MenuLayer;
}
upViz = downViz = false;
return ret;
| public void | setVerticalScroll(int scrollPosition, int scrollProportion)Set the current vertical scroll position and proportion.
boolean up = upViz;
boolean dn = downViz;
if ( (scrollable != null) &&
(scrollProportion < 100)) {
upViz = (scrollPosition > 0);
downViz = (scrollPosition < 100);
} else {
upViz = downViz = false;
}
setVisible(upViz || downViz);
if (up != upViz || dn != downViz) {
requestRepaint();
}
|
|