Package totalcross.ui
Class Slider
- java.lang.Object
-
- totalcross.ui.gfx.GfxSurface
-
- totalcross.ui.Control
-
- totalcross.ui.Container
-
- totalcross.ui.ScrollBar
-
- totalcross.ui.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 theminDragBarSizepublic field and then call setValues or setMaximum or setMinimum method (value must always be ODD!).- Since:
- TotalCross 1.0
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class totalcross.ui.Control
Control.TranslucentShape
-
-
Field Summary
Fields Modifier and Type Field Description booleanbarBorderRoundBar border in horizontal mode is roundintbarHeightHeight of the barintcircleColorThe color of the circle you drag to change the slider value.booleandrawFilledAreaSet to false to don't draw the filled area.booleandrawTicksSet to true to draw the ticks.booleaninvertDirectionInverts the direction of the marker.ImagemarkerImageImage used in place of the drawn markerintmarkerSizeSize of the marker that indicates progress(when not using an image as a marker)introundBorderRadiusRadius of the round borderintsliderColorThe color of the sliderintticksColorThe color of the slider ticks-
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, borderRadius, children, controlFound, finishedStart, ignoreOnAddAgain, ignoreOnRemove, insets, lastH, lastScreenWidth, lastW, lastX, lastY, npback, numChildren, started, tabOrder, tail, TRANSITION_TIME
-
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
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetDragBarPos(int value)Returns the drag bar position.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).voidonColorsChanged(boolean b)Called after a setEnabled, setForeColor and setBackColor and when a control has been added to a Container.voidonFontChanged()Called after a setFontvoidonPaint(Graphics g)Draws the border (if any).protected voidrecomputeParams(boolean justValue)voidsetRect(int x, int y, int width, int height, Control relative, boolean screenChanged)The relative positioning will be made with the given control (relative).protected voidupdateValue(int pos)-
Methods inherited from class totalcross.ui.ScrollBar
blockScroll, clear, getBlockIncrement, getMaximum, getMinimum, getUnitIncrement, getValue, getVisibleItems, handleGeographicalFocusChangeKeys, onAnimationFinished, onBoundsChanged, onEvent, setBlockIncrement, setEnabled, setHighlighting, setLiveScrolling, setMaximum, setMinimum, setNinePatchHandle, setPos, setUnitIncrement, setValue, setValues, setVisibleItems, tempShow
-
Methods inherited from class totalcross.ui.Container
add, add, add, add, add, broadcastEvent, fillBackground, 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
-
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, setSet, setTextShadowColor, setTranslucent, setVisible, showTip, takeInitialScreenShot, takeScreenShot, translateFromOrigin, uiStyleChanged, updateScreen, updateTemporary, willOpenKeyboard
-
-
-
-
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.
-
Slider
public Slider(byte orientation)
Constructs a Slider with the given orientation.- See Also:
ScrollBar.VERTICAL,ScrollBar.HORIZONTAL
-
-
Method Detail
-
recomputeParams
protected void recomputeParams(boolean justValue)
- Overrides:
recomputeParamsin classScrollBar
-
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
-
onFontChanged
public void onFontChanged()
Description copied from class:ControlCalled after a setFont- Overrides:
onFontChangedin classScrollBar
-
setRect
public void setRect(int x, int y, int width, int height, Control relative, boolean screenChanged)Description copied from class:ControlThe 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:
setRectin classControl- 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 therepositionmethod 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:ContainerDraws the border (if any). If you override this method, be sure to callsuper.onPaint(g);, or the border will not be drawn.
-
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
-
updateValue
protected void updateValue(int pos)
- Overrides:
updateValuein classScrollBar
-
-