Package totalcross.ui

Class ScrollPosition

    • 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.
    • Method Detail

      • setNeverShow

        public void setNeverShow()
        Call this to never show the ScrollPosition
      • tempShow

        public void tempShow()
        Description copied from class: ScrollBar
        Used by ScrollPosition
        Overrides:
        tempShow in class ScrollBar
      • onBoundsChanged

        public void onBoundsChanged​(boolean b)
        Description copied from class: Control
        Called after a setRect.
        Overrides:
        onBoundsChanged in class ScrollBar
        Parameters:
        b - If the bounds were changed due to a screen change (rotation, collapse)
      • onColorsChanged

        public void onColorsChanged​(boolean b)
        Description copied from class: Control
        Called 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:
        onColorsChanged in class ScrollBar
      • setVisible

        public void setVisible​(boolean b)
        Don't allow change the visibility. This is done automatically.
        Overrides:
        setVisible in class Control
      • onPaint

        public void onPaint​(Graphics g)
        Description copied from class: Container
        Draws the border (if any). If you override this method, be sure to call super.onPaint(g);, or the border will not be drawn.
        Overrides:
        onPaint in class ScrollBar
        Parameters:
        g - the graphics object for drawing
        See Also:
        Graphics
      • onEvent

        public void onEvent​(Event e)
        Description copied from class: Control
        Called to process key, pen, control and other posted events.
        Overrides:
        onEvent in class ScrollBar
        Parameters:
        e - the event to process
        See Also:
        Event, KeyEvent, PenEvent
      • getPreferredWidth

        public int getPreferredWidth()
        Description copied from class: ScrollBar
        If this is a vertical scroll bar, i strongly suggest you use PREFERRED in your control's width (with small adjustments).
        Overrides:
        getPreferredWidth in class ScrollBar
      • getPreferredHeight

        public int getPreferredHeight()
        Description copied from class: ScrollBar
        If this is a horizontal scroll bar, i strongly suggest you use PREFERRED in your control's height (with small adjustments)
        Overrides:
        getPreferredHeight in class ScrollBar
      • flickStarted

        public boolean flickStarted()
        Description copied from interface: Scrollable
        Called when the flick animation is started.
        Specified by:
        flickStarted in interface Scrollable
      • flickEnded

        public void flickEnded​(boolean atPenDown)
        Description copied from interface: Scrollable
        Called when the flick animation is ended.
        Specified by:
        flickEnded in interface Scrollable
        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: Scrollable
        Checks if there is room to flick this container in the given direction.
        Specified by:
        canScrollContent in interface Scrollable
        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: Scrollable
        Performs a relative move.
        Specified by:
        scrollContent in interface Scrollable
        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: Scrollable
        Returns the current position given the direction. Used on page scrolls.
        Specified by:
        getScrollPosition in interface Scrollable
      • getFlick

        public Flick getFlick()
        Description copied from interface: Scrollable
        Returns the current flick object.
        Specified by:
        getFlick in interface Scrollable
      • wasScrolled

        public boolean wasScrolled()
        Description copied from interface: Scrollable
        Returns true if the control was scrolled since last pen down
        Specified by:
        wasScrolled in interface Scrollable
      • clear

        public void clear()
        Resets position to 0 and posts a pressed event.
        Overrides:
        clear in class ScrollBar