public class ScrollBar extends Container implements PathAnimation.SetPosition, ControlAnimation.AnimationFinished
// declarations ScrollBar sb1; ScrollBar sb2; ScrollBar sb3; ScrollBar sb4; // init public void testScrollBars() { add(sb1 = new ScrollBar(ScrollBar.VERTICAL), RIGHT, CENTER, PREFERRED, totalcross.sys.Settings.screenHeight/2); add(sb2 = new ScrollBar(ScrollBar.VERTICAL), BEFORE, SAME, PREFERRED, SAME); sb2.setLiveScrolling(true); add(sb3 = new ScrollBar(ScrollBar.HORIZONTAL), LEFT,CENTER,totalcross.sys.Settings.screenWidth/2, PREFERRED); add(sb4 = new ScrollBar(ScrollBar.HORIZONTAL), SAME, AFTER, SAME, PREFERRED); } public void onEvent(Event event) { if (event.type == ControlEvent.PRESSED && event.target == sb2) { int value = sb2.getValue(); sb1.setValue(value); sb3.setValue(value); sb4.setValue(value); } }
Control.TranslucentShape
Modifier and Type | Field and Description |
---|---|
static int |
AUTO_DELAY
The frequency in which the scroll will be done.
|
protected int |
bColor |
protected int |
blockIncrement |
protected ArrowButton |
btnDec |
protected ArrowButton |
btnInc |
protected int |
btnWH |
protected boolean |
directMove |
boolean |
disableBlockIncrement
Set to true to disable block increments, which occurs when the user clicks outside the bar and buttons.
|
protected int |
dragBarMax |
protected int |
dragBarMin |
protected int |
dragBarPos |
protected int |
dragBarSize |
protected boolean |
enableAutoScroll |
static int |
extraSize
The extra size (width for vertical ScrollBars or height for horizontal ones) used in all ScrollBars.
|
protected int[] |
fourColors |
static byte |
HORIZONTAL
To be passed in the constructor
|
static int |
INITIAL_DELAY
The initial delay to start the automatic scroll.
|
protected boolean |
liveScrolling |
protected int |
maximum |
protected int |
midBarSize |
int |
minDragBarSize
The minimum dragbar size in pixels.
|
protected int |
minimum |
protected NinePatch.Parts |
npPartsHandle |
protected int |
sbColor |
protected int |
sbColorDis |
protected int |
sfColor |
protected int |
size |
protected int |
startDragPos |
protected int |
unitIncrement |
protected int |
value |
protected double |
valuesPerPixel |
static byte |
VERTICAL
To be passed in the constructor
|
protected boolean |
verticalBar |
protected int |
visibleItems |
alwaysEraseBackground, BACKGROUND_CYLINDRIC_SHADED, BACKGROUND_SHADED, BACKGROUND_SHADED_INV, BACKGROUND_SOLID, backgroundStyle, BORDER_LOWERED, BORDER_NONE, BORDER_RAISED, BORDER_ROUNDED, BORDER_SIMPLE, BORDER_TOP, borderColor, borderRadius, children, controlFound, finishedStart, ignoreOnAddAgain, ignoreOnRemove, insets, lastH, lastScreenWidth, lastW, lastX, lastY, numChildren, started, tabOrder, tail, TRANSITION_TIME
AFTER, alphaValue, appId, appObj, asContainer, asWindow, backColor, BEFORE, BOTTOM, BOTTOM_OF, BRIGHTER_BACKGROUND, callListenersOnAllTargets, CENTER, CENTER_OF, clearValueInt, clearValueStr, DARKER_BACKGROUND, DP, effect, enableUpdateScreen, esce, eventsEnabled, FILL, fillColor, FIT, floating, fm, fmH, focusHandler, focusLess, focusOnPenDown, focusTraversable, font, FONTSIZE, foreColor, height, ignoreInsets, isHighlighting, isTablet, KEEP, keepDisabled, keepEnabled, LEFT, next, nextTabControl, npParts, offscreen, offscreen0, onEventFirst, parent, PARENTSIZE, PARENTSIZEMAX, PARENTSIZEMIN, PREFERRED, prev, RANGE, repositionAllowed, RIGHT, RIGHT_OF, SAME, SCREENSIZE, SCREENSIZEMAX, SCREENSIZEMIN, setFont, setH, setRel, setW, setX, SETX_NOT_SET, setY, tempW, textShadowColor, TOP, translucentShape, transparentBackground, uiAdjustmentsBasedOnFontHeightIsSupported, uiAndroid, UICONST, uiFlat, uiHolo, uiMaterial, uiVista, visible, width, WILL_RESIZE, x, y
Constructor and Description |
---|
ScrollBar()
Creates Scrollbar with default values:
maximum = 100 minimum = 0 orientation = VERTICAL blockIncrement = 50 unitIncrement = 1 value = 0 visibleItems = blockIncrement |
ScrollBar(byte orientation)
Creates Scrollbar with the given orientation and these default values:
maximum = 100 minimum = 0 blockIncrement = 50 unitIncrement = 1 value = 0 visibleItems = blockIncrement |
Modifier and Type | Method and Description |
---|---|
void |
blockScroll(boolean inc)
Scrolls a block, and post the PRESSED event if the value changes.
|
void |
clear()
Clears this control, setting the value to clearValueInt.
|
int |
getBlockIncrement()
Get the amount to increment the value when clicking above the bar.
|
int |
getMaximum()
Get the maximum value
|
int |
getMinimum()
Get the minimum value
|
int |
getPreferredHeight()
If this is a horizontal scroll bar, i strongly suggest you use PREFERRED in your control's height (with small adjustments)
|
int |
getPreferredWidth()
If this is a vertical scroll bar, i strongly suggest you use PREFERRED in your control's width (with small adjustments).
|
int |
getUnitIncrement()
Get the amount to increment the value when clicking the up or down buttons
|
int |
getValue()
Get the value.
|
int |
getVisibleItems()
Get the count of visible items for the scrollbar
|
Control |
handleGeographicalFocusChangeKeys(KeyEvent ke)
Used by the main event loop to give the currently focused control an opportunity to act directly on
the KeyEvent.
|
void |
onAnimationFinished(ControlAnimation anim) |
protected void |
onBoundsChanged(boolean screenChanged)
Called after a setRect.
|
protected void |
onColorsChanged(boolean colorsChanged)
Called after a setEnabled, setForeColor and setBackColor and when a control has
been added to a Container.
|
void |
onEvent(Event event)
Called to process key, pen, control and other posted events.
|
void |
onFontChanged()
Called after a setFont
|
void |
onPaint(Graphics g)
Draws the border (if any).
|
protected void |
recomputeParams(boolean justValue) |
void |
setBlockIncrement(int i)
Set the amount to increment the value when clicking above the bar.
|
void |
setEnabled(boolean enabled)
Sets if this container and all childrens can or not accept events
|
void |
setHighlighting()
Called by the event dispatcher to set highlighting back to true.
|
void |
setLiveScrolling(boolean liveScrolling)
Set the live scrolling.
|
void |
setMaximum(int i)
Set the maximum value.
|
void |
setMinimum(int i)
Set the minimum value
|
void |
setNinePatchHandle(Image img,
int corner,
int side)
Set the Handle NinePatch image
|
void |
setPos(int x,
int y) |
void |
setUnitIncrement(int i)
Set the amount to increment the value when clicking the up or down buttons
|
void |
setValue(int i)
Sets the value.
|
void |
setValues(int newValue,
int newVisibleItems,
int newMinimum,
int newMaximum)
Sets the value, visibleItems, minimum and maximum values
|
void |
setVisibleItems(int i)
Set the count of visible items for the scrollbar.
|
void |
tempShow()
Used by ScrollPosition
|
protected void |
updateValue(int pos) |
add, add, add, add, add, broadcastEvent, fillBackground, findChild, findNearestChild, findNextFocusControl, getBorderRadius, getBorderStyle, getChildren, getChildrenCount, getClientRect, getClientRect, getFirstChild, getFocusableControls, getInsets, incLastX, incLastY, initUI, isPressed, moveFocusToNextControl, moveFocusToNextEditable, onAddAgain, onRemove, onSwapFinished, paintChildren, remove, removeAll, resize, resizeHeight, resizeWidth, setBorderRadius, setBorderStyle, setFocusTraversable, setInsets, setPressColor, setPressed, swapToTopmostWindow
_onEvent, addEnabledStateListener, addFocusListener, addFontChangeHandler, addGridListener, addHandler, addHighlightListener, addKeyListener, addListContainerListener, addMouseListener, addMultiTouchListener, addPenListener, addPressListener, addPushNotificationListener, addSizeChangeHandler, addTimer, addTimer, addTimerListener, addValueChangeHandler, addWindowListener, bringToFront, changeHighlighted, contains, drawTranslucentBackground, getAbsoluteRect, getBackColor, getDoEffect, getEffectH, getEffectW, getEffectX, getEffectY, getEventListeners, getFont, getForeColor, getGap, getGraphics, getHeight, getNext, getParent, getParentWindow, getPos, getPressedEvent, getPrev, getRect, getSize, getTextShadowColor, getWidth, getX, getX2, getY, getY2, hadParentScrolled, hasFocus, internalSetEnabled, intXYWH, isActionEvent, isChildOf, isDisplayed, isEnabled, isFloating, isInsideOrNear, isObscured, isTopMost, isVisible, isVisibleAndInside, onWindowPaintFinished, post, postEvent, postPressedEvent, releaseScreenShot, removeEnabledStateListener, removeFocusListener, removeGridListener, removeHandler, removeHighlightListener, removeKeyListener, removeListContainerListener, removeMouseListener, removeMultiTouchListener, removePenListener, removePressListener, removePushNotificationListener, removeTimer, removeTimerListener, removeWindowListener, repaint, repaintNow, reposition, reposition, repositionChildren, requestFocus, resetSetPositions, resetStyle, safeRepaintNow, safeUpdateScreen, sendToBack, setBackColor, setBackForeColors, setDoEffect, setFloating, setFocusLess, setFont, setForeColor, setNinePatch, setNinePatch, setRect, setRect, setRect, setRect, setSet, setTextShadowColor, setTranslucent, setVisible, showTip, takeInitialScreenShot, takeScreenShot, translateFromOrigin, uiStyleChanged, updateScreen, updateTemporary, willOpenKeyboard
public static final byte VERTICAL
public static final byte HORIZONTAL
public boolean disableBlockIncrement
protected int maximum
protected int minimum
protected int blockIncrement
protected int unitIncrement
protected int value
protected int visibleItems
protected double valuesPerPixel
protected int dragBarSize
protected int btnWH
protected ArrowButton btnInc
protected ArrowButton btnDec
protected int startDragPos
protected boolean verticalBar
protected int dragBarPos
protected boolean liveScrolling
protected int size
protected int dragBarMax
protected int dragBarMin
protected int bColor
protected int sbColor
protected int sfColor
protected int sbColorDis
protected int[] fourColors
protected NinePatch.Parts npPartsHandle
protected boolean directMove
protected int midBarSize
public int minDragBarSize
protected boolean enableAutoScroll
public static int INITIAL_DELAY
public static int AUTO_DELAY
public static int extraSize
public ScrollBar()
public ScrollBar(byte orientation)
public void setValues(int newValue, int newVisibleItems, int newMinimum, int newMaximum)
public void setMaximum(int i)
public int getMaximum()
public void setMinimum(int i)
public int getMinimum()
public void setBlockIncrement(int i)
public int getBlockIncrement()
public void setUnitIncrement(int i)
public int getUnitIncrement()
public void setValue(int i)
public int getValue()
public void setVisibleItems(int i)
public int getVisibleItems()
public void setLiveScrolling(boolean liveScrolling)
public void setNinePatchHandle(Image img, int corner, int side)
protected void recomputeParams(boolean justValue)
public void onEvent(Event event)
Control
protected void updateValue(int pos)
public void blockScroll(boolean inc)
public void setEnabled(boolean enabled)
Container
setEnabled
in class Container
protected void onColorsChanged(boolean colorsChanged)
Control
onColorsChanged
in class Container
public void onPaint(Graphics g)
Container
super.onPaint(g);
, or the border will not be drawn.public int getPreferredWidth()
getPreferredWidth
in class Control
public int getPreferredHeight()
getPreferredHeight
in class Control
public void onFontChanged()
Control
onFontChanged
in class Control
protected void onBoundsChanged(boolean screenChanged)
Control
onBoundsChanged
in class Control
screenChanged
- If the bounds were changed due to a screen change (rotation, collapse)public void setHighlighting()
Container
setHighlighting
in class Container
public void clear()
public Control handleGeographicalFocusChangeKeys(KeyEvent ke)
Control
handleGeographicalFocusChangeKeys
in class Control
ke
- The KeyEvent to be processedSettings.geographicalFocus
public void tempShow()
public void setPos(int x, int y)
setPos
in interface PathAnimation.SetPosition
public void onAnimationFinished(ControlAnimation anim)
onAnimationFinished
in interface ControlAnimation.AnimationFinished