Package totalcross.ui

Class Slider

  • All Implemented Interfaces:
    ControlAnimation.AnimationFinished, PathAnimation.SetPosition

    public class Slider
    extends ScrollBar
    Slider is a simple slider. You can set some properties of the slider, like drawTicks, invertDirection and drawFilledArea; read the javadocs of each for more information. You can change the thumb size by setting the minDragBarSize public field and then call setValues or setMaximum or setMinimum method (value must always be ODD!).
    Since:
    TotalCross 1.0
    • Field Detail

      • invertDirection

        public boolean invertDirection
        Inverts the direction of the marker. You must set this property before calling setValues (or the other min/max/value/visibleItems set methods) for the first time. For material UI, inverts the color area.
      • drawTicks

        public boolean drawTicks
        Set to true to draw the ticks. Should be set only when maximum-minimum is much smaller than width. You must set this property before calling setValues (or the other min/max/value/visibleItems set methods) for the first time.
      • drawFilledArea

        public boolean drawFilledArea
        Set to false to don't draw the filled area. You must set this property before calling setValues (or the other min/max/value/visibleItems set methods) for the first time.
      • sliderColor

        public int sliderColor
        The color of the slider
      • circleColor

        public int circleColor
        The color of the circle you drag to change the slider value.
      • ticksColor

        public int ticksColor
        The color of the slider ticks
      • barHeight

        public int barHeight
        Height of the bar
      • barBorderRound

        public boolean barBorderRound
        Bar border in horizontal mode is round
      • roundBorderRadius

        public int roundBorderRadius
        Radius of the round border
      • markerSize

        public int markerSize
        Size of the marker that indicates progress(when not using an image as a marker)
      • markerImage

        public Image markerImage
        Image used in place of the drawn marker
    • Constructor Detail

      • Slider

        public Slider()
        Constructs a HORIZONTAL Slider.
    • Method Detail

      • recomputeParams

        protected void recomputeParams​(boolean justValue)
        Overrides:
        recomputeParams in class ScrollBar
      • 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
      • onFontChanged

        public void onFontChanged()
        Description copied from class: Control
        Called after a setFont
        Overrides:
        onFontChanged in class ScrollBar
      • setRect

        public void setRect​(int x,
                            int y,
                            int width,
                            int height,
                            Control relative,
                            boolean screenChanged)
        Description copied from class: Control
        The relative positioning will be made with the given control (relative). Note that in this case, only the SAME,BEFORE,AFTER are affected by the given control. Here is an example of relative positioning:

        Important note: you can't use FILL/FIT with BEFORE/RIGHT/BOTTOM (for x,y).

         add(new Label("1"),CENTER,CENTER);
         add(new Label("2"),AFTER,SAME);
         add(new Label("3"),SAME,AFTER);
         add(new Label("4"),BEFORE,SAME);
         add(new Label("5"),BEFORE,BEFORE);
         
        You will see this on screen:
         512
          43
         
        Note: add(control, x,y) does: add(control); control.setRect(x,y,PREFERRED,PREFERRED);

        Important! Always add the control to the container before doing a setRect.

        The relative positioning does not work well if the control is placed outside screen bounds.

        Overrides:
        setRect in class Control
        Parameters:
        x - One of the relative positioning constants: LEFT, RIGHT, SAME, BEFORE, AFTER, CENTER, with a small adjustment. You can also use an absolute value, but this is strongly discouraged.
        y - One of the relative positioning constants: TOP, BOTTOM, SAME, BEFORE, AFTER, CENTER, with a small adjustment. You can also use an absolute value, but this is strongly discouraged.
        width - One of the relative positioning constants: PREFERRED, FILL, FIT, SAME. You can also use an absolute value, but this is strongly discouraged.
        height - One of the relative positioning constants: PREFERRED, FILL, FIT, SAME. You can also use an absolute value, but this is strongly discouraged.
        relative - To whom the position should be relative to; or null to be relative to the last control.
        screenChanged - Indicates that a screen change (resize, collapse) occured and the reposition method is calling this method. Set by the system. If you call this method directly, always pass false to it.
        See Also:
        Control.LEFT, Control.TOP, Control.RIGHT, Control.BOTTOM, Control.BEFORE, Control.AFTER, Control.CENTER, Control.SAME, Control.FILL, Control.PREFERRED, Control.FIT, Control.CENTER_OF, Control.RIGHT_OF, Control.BOTTOM_OF, Control.SCREENSIZE, Control.SCREENSIZEMIN, Control.SCREENSIZEMAX, Control.PARENTSIZE, Control.PARENTSIZEMIN, Control.PARENTSIZEMAX, Control.FONTSIZE, Container.add(Control, int, int), Container.add(Control, int, int, Control)
      • getDragBarPos

        public int getDragBarPos​(int value)
        Returns the drag bar position.
      • 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
      • 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