Package totalcross.ui

Class PagePosition

  • Direct Known Subclasses:
    NumericPagePosition

    public class PagePosition
    extends Control
    PagePosition implements the empty and filled balls that indicates the current page in a set of pages, very common on Android and iPhone. It has three properties:
    1. visible count: the number of visible balls
    2. count: the number of balls that will be displayed. Can be less, equal or greater than visible count
    3. position: the current position of the filled ball
    Since:
    TotalCross 1.3
    • Field Detail

      • visibleCount

        protected int visibleCount
      • count

        protected int count
      • position

        protected int position
    • Constructor Detail

      • PagePosition

        public PagePosition​(int visibleCount)
        Constructs a new PagePosition with the given number of visible balls. This number cannot be changed later.
    • Method Detail

      • setCount

        public void setCount​(int c)
        Sets the balls count. Invalid values are forced to a valid range.
      • setPosition

        public void setPosition​(int p)
        Sets the current position (starting at 1). Invalid values are forced to a valid range.
      • getVisibleCount

        public int getVisibleCount()
        Returns the visibleCount passed in the constructor.
      • getCount

        public int getCount()
        Returns the ball count.
      • getPosition

        public int getPosition()
        Returns the current position
      • inc

        public void inc​(boolean wrap)
        Increments the current position. If wrap is true, when position gets above count, it wraps to 1.
      • dec

        public void dec​(boolean wrap)
        Decrements the current position. If wrap is true, when position gets below 1, it wraps to count.
      • onPaint

        public void onPaint​(Graphics g)
        Description copied from class: Control
        Called to draw the control. When this method is called, the graphics object passed has been translated into the coordinate system of the control and the area behind the control has already been painted.
        Overrides:
        onPaint in class Control
        Parameters:
        g - the graphics object for drawing
        See Also:
        Graphics
      • getPreferredWidth

        public int getPreferredWidth()
        Description copied from class: Control
        Returns the preferred width of this control.
        Overrides:
        getPreferredWidth in class Control
      • getPreferredHeight

        public int getPreferredHeight()
        Description copied from class: Control
        Returns the preferred height of this control.
        Overrides:
        getPreferredHeight in class Control