Package totalcross.ui
Class ScrollPosition
- java.lang.Object
-
- totalcross.ui.gfx.GfxSurface
-
- totalcross.ui.Control
-
- totalcross.ui.Container
-
- totalcross.ui.ScrollBar
-
- totalcross.ui.ScrollPosition
-
- All Implemented Interfaces:
ControlAnimation.AnimationFinished,PathAnimation.SetPosition,EventHandler,PenListener,TimerListener,Scrollable
public class ScrollPosition extends ScrollBar implements Scrollable, PenListener, TimerListener
ScrollPosition implements the auto-hide scrollbar that exists in finger-touched devices. This special scrollbar is just a small position indicator that appears when the area is dragged. The ScrollPosition does not take an area of the control, since it appears and disappears automatically. All Scrollable controls change their ScrollBar by the ScrollPosition when Settings.fingerTouch is true. If the back color and the bar color are the same, the bar is not drawn; this is how the ButtonMenu class hides this control.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class totalcross.ui.Control
Control.TranslucentShape
-
-
Field Summary
Fields Modifier and Type Field Description static booleanAUTO_HIDESet to false to make the PositionBar always show (instead of the default auto-hide behaviour).intbarColorThe bar color.static intheightMultiplierToShowHandleDefines the height multiplier that must be reached to show the handle while scrolling.static intVISIBLE_COUNTBy default, the ScrollPosition is shown during 1 second to let the user know that he can scroll.-
Fields inherited from class totalcross.ui.ScrollBar
AUTO_DELAY, bColor, blockIncrement, btnDec, btnInc, btnWH, directMove, disableBlockIncrement, dragBarMax, dragBarMin, dragBarPos, dragBarSize, enableAutoScroll, extraSize, fourColors, HORIZONTAL, INITIAL_DELAY, liveScrolling, maximum, midBarSize, minDragBarSize, minimum, npPartsHandle, sbColor, sbColorDis, sfColor, size, startDragPos, unitIncrement, value, valuesPerPixel, VERTICAL, verticalBar, visibleItems
-
Fields inherited from class totalcross.ui.Container
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, children, controlFound, finishedStart, ignoreOnAddAgain, ignoreOnRemove, insets, lastH, lastScreenWidth, lastW, lastX, lastY, numChildren, started, tabOrder, tail, TRANSITION_CLOSE, TRANSITION_FADE, TRANSITION_NONE, TRANSITION_OPEN, TRANSITION_TIME, transitionEffect
-
Fields inherited from class totalcross.ui.Control
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 Summary
Constructors Constructor Description ScrollPosition()Constructs a vertical ScrollPosition.ScrollPosition(byte orientation)Constructs a ScrollPosition with the given orientation.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancanScrollContent(int direction, java.lang.Object target)Checks if there is room to flick this container in the given direction.voidclear()Resets position to 0 and posts a pressed event.voidflickEnded(boolean atPenDown)Called when the flick animation is ended.booleanflickStarted()Called when the flick animation is started.FlickgetFlick()Returns the current flick object.intgetPreferredHeight()If this is a horizontal scroll bar, i strongly suggest you use PREFERRED in your control's height (with small adjustments)intgetPreferredWidth()If this is a vertical scroll bar, i strongly suggest you use PREFERRED in your control's width (with small adjustments).intgetScrollPosition(int direction)Returns the current position given the direction.voidonBoundsChanged(boolean b)Called after a setRect.voidonColorsChanged(boolean b)Called after a setEnabled, setForeColor and setBackColor and when a control has been added to a Container.voidonEvent(Event e)Called to process key, pen, control and other posted events.voidonPaint(Graphics g)Draws the border (if any).voidpenDown(PenEvent e)A PEN_DOWN event was dispatched.voidpenDrag(DragEvent e)A PEN_DRAG event was dispatched.voidpenDragEnd(DragEvent e)A PEN_DRAG_END event was dispatched.voidpenDragStart(DragEvent e)A PEN_DRAG_START event was dispatched.voidpenUp(PenEvent e)A PEN_UP event was dispatched.booleanscrollContent(int xDelta, int yDelta, boolean fromFlick)Performs a relative move.voidsetHandleVisibility(boolean visible)Sets the visibility of the temporary scrollbar handler.voidsetNeverShow()Call this to never show the ScrollPositionvoidtempShow()Used by ScrollPositionvoidtimerTriggered(TimerEvent e)A TRIGGERED event was dispatched.booleanwasScrolled()Returns true if the control was scrolled since last pen down-
Methods inherited from class totalcross.ui.ScrollBar
blockScroll, getBlockIncrement, getMaximum, getMinimum, getUnitIncrement, getValue, getVisibleItems, handleGeographicalFocusChangeKeys, onAnimationFinished, onFontChanged, recomputeParams, setBlockIncrement, setEnabled, setHighlighting, setLiveScrolling, setMaximum, setMinimum, setNinePatchHandle, setPos, setUnitIncrement, setValue, setValues, setVisibleItems, updateValue
-
Methods inherited from class totalcross.ui.Container
add, add, add, add, add, applyTransitionEffect, broadcastEvent, fillBackground, findChild, findNearestChild, findNextFocusControl, getBorderStyle, getChildren, getChildrenCount, getClientRect, getClientRect, getFirstChild, getFocusableControls, getInsets, incLastX, incLastY, initUI, isPressed, moveFocusToNextControl, moveFocusToNextEditable, onAddAgain, onRemove, onSwapFinished, paintChildren, remove, removeAll, resize, resizeHeight, resizeWidth, setBorderStyle, setFocusTraversable, setInsets, setNextTransitionEffect, setPressColor, setPressed, swapToTopmostWindow
-
Methods inherited from class totalcross.ui.Control
_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
-
-
-
-
Field Detail
-
AUTO_HIDE
public static boolean AUTO_HIDE
Set to false to make the PositionBar always show (instead of the default auto-hide behaviour).
-
VISIBLE_COUNT
public static int VISIBLE_COUNT
By default, the ScrollPosition is shown during 1 second to let the user know that he can scroll. This value is a number that will be multiplied by 500. Defaults to 2, set to 0 to disable this feature.- Since:
- TotalCross 3.07
-
barColor
public int barColor
The bar color. Defaults to UIColors.positionbarColor but can be changed to something else.
-
heightMultiplierToShowHandle
public static int heightMultiplierToShowHandle
Defines the height multiplier that must be reached to show the handle while scrolling. The handle speeds up scrolling since the user can drag it (like the bar in a ProgressBar). It is very useful for long lists. Setting this to 10 will make the handle appear when the height of the item's list exceeds 10 times the height of the ScrollContainer. Set it to 0 will always show the handle, set to something very big (like Convert.MAX_INT) to never show the handle. Defaults to 7.- Since:
- TotalCross 1.3
-
-
Constructor Detail
-
ScrollPosition
public ScrollPosition()
Constructs a vertical ScrollPosition.
-
ScrollPosition
public ScrollPosition(byte orientation)
Constructs a ScrollPosition with the given orientation.- See Also:
ScrollBar.VERTICAL,ScrollBar.HORIZONTAL
-
-
Method Detail
-
setNeverShow
public void setNeverShow()
Call this to never show the ScrollPosition
-
tempShow
public void tempShow()
Description copied from class:ScrollBarUsed by ScrollPosition
-
onBoundsChanged
public void onBoundsChanged(boolean b)
Description copied from class:ControlCalled after a setRect.- Overrides:
onBoundsChangedin classScrollBar- Parameters:
b- If the bounds were changed due to a screen change (rotation, collapse)
-
onColorsChanged
public void onColorsChanged(boolean b)
Description copied from class:ControlCalled after a setEnabled, setForeColor and setBackColor and when a control has been added to a Container. If colorsChanged is true, it was called from setForeColor/setBackColor/Container.add; otherwise, it was called from setEnabled- Overrides:
onColorsChangedin classScrollBar
-
onPaint
public void onPaint(Graphics g)
Description copied from class:ContainerDraws the border (if any). If you override this method, be sure to callsuper.onPaint(g);, or the border will not be drawn.
-
onEvent
public void onEvent(Event e)
Description copied from class:ControlCalled to process key, pen, control and other posted events.
-
getPreferredWidth
public int getPreferredWidth()
Description copied from class:ScrollBarIf this is a vertical scroll bar, i strongly suggest you use PREFERRED in your control's width (with small adjustments).- Overrides:
getPreferredWidthin classScrollBar
-
getPreferredHeight
public int getPreferredHeight()
Description copied from class:ScrollBarIf this is a horizontal scroll bar, i strongly suggest you use PREFERRED in your control's height (with small adjustments)- Overrides:
getPreferredHeightin classScrollBar
-
flickStarted
public boolean flickStarted()
Description copied from interface:ScrollableCalled when the flick animation is started.- Specified by:
flickStartedin interfaceScrollable
-
flickEnded
public void flickEnded(boolean atPenDown)
Description copied from interface:ScrollableCalled when the flick animation is ended.- Specified by:
flickEndedin interfaceScrollable- Parameters:
atPenDown- Flag indicating if the animation ended due to a pendown event.
-
canScrollContent
public boolean canScrollContent(int direction, java.lang.Object target)Description copied from interface:ScrollableChecks if there is room to flick this container in the given direction.- Specified by:
canScrollContentin interfaceScrollable- Parameters:
direction- The direction we want to flick given by one of the following constants:target- The target of the series of PEN events that triggered this flick attempt.- Returns:
- true if the container can flick in the indicated direction.
-
scrollContent
public boolean scrollContent(int xDelta, int yDelta, boolean fromFlick)Description copied from interface:ScrollablePerforms a relative move.- Specified by:
scrollContentin interfaceScrollable- Parameters:
xDelta- The relative amount of pixels to move in the X axis.yDelta- The relative amount of pixels to move in the Y axis.
-
getScrollPosition
public int getScrollPosition(int direction)
Description copied from interface:ScrollableReturns the current position given the direction. Used on page scrolls.- Specified by:
getScrollPositionin interfaceScrollable
-
getFlick
public Flick getFlick()
Description copied from interface:ScrollableReturns the current flick object.- Specified by:
getFlickin interfaceScrollable
-
penDown
public void penDown(PenEvent e)
Description copied from interface:PenListenerA PEN_DOWN event was dispatched.- Specified by:
penDownin interfacePenListener- See Also:
PenEvent
-
penUp
public void penUp(PenEvent e)
Description copied from interface:PenListenerA PEN_UP event was dispatched.- Specified by:
penUpin interfacePenListener- See Also:
PenEvent
-
penDrag
public void penDrag(DragEvent e)
Description copied from interface:PenListenerA PEN_DRAG event was dispatched.- Specified by:
penDragin interfacePenListener- See Also:
PenEvent
-
penDragStart
public void penDragStart(DragEvent e)
Description copied from interface:PenListenerA PEN_DRAG_START event was dispatched.- Specified by:
penDragStartin interfacePenListener- See Also:
PenEvent
-
penDragEnd
public void penDragEnd(DragEvent e)
Description copied from interface:PenListenerA PEN_DRAG_END event was dispatched.- Specified by:
penDragEndin interfacePenListener- See Also:
PenEvent
-
setHandleVisibility
public void setHandleVisibility(boolean visible)
Sets the visibility of the temporary scrollbar handler.
-
timerTriggered
public void timerTriggered(TimerEvent e)
Description copied from interface:TimerListenerA TRIGGERED event was dispatched.- Specified by:
timerTriggeredin interfaceTimerListener- See Also:
TimerEvent
-
wasScrolled
public boolean wasScrolled()
Description copied from interface:ScrollableReturns true if the control was scrolled since last pen down- Specified by:
wasScrolledin interfaceScrollable
-
-