Package totalcross.ui
Class MultiButton
- java.lang.Object
-
- totalcross.ui.gfx.GfxSurface
-
- totalcross.ui.Control
-
- totalcross.ui.MultiButton
-
public class MultiButton extends Control
MultiButton is a control that displays a single line button with a set of titles. Can be used to replace a Check (with on/off) or a Radio (with their options). Sample:MultiButton b = new MultiButton(new String[]{"+","-"}); b.setBackColor(Color.CYAN); add(b,LEFT+50,TOP+50,200,FONTSIZE+150);- Since:
- TotalCross 2.0
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class totalcross.ui.Control
Control.TranslucentShape
-
-
Field Summary
Fields Modifier and Type Field Description intdivColorThe color used to divide the texts.booleanis3dTextDefines if the text will have a 3d style.booleanisStickySet to true to behave like a Radio, false like a ButtonintselColorThe selection color.-
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, effect, enableUpdateScreen, esce, eventsEnabled, FILL, fillColor, FIT, fm, fmH, focusHandler, focusLess, focusOnPenDown, focusTraversable, font, FONTSIZE, foreColor, height, ignoreInsets, isHighlighting, isTablet, KEEP, keepDisabled, keepEnabled, LEFT, nextTabControl, offscreen, offscreen0, onEventFirst, parent, PARENTSIZE, PARENTSIZEMAX, PARENTSIZEMIN, PREFERRED, RANGE, repositionAllowed, RIGHT, RIGHT_OF, SAME, SCREENSIZE, SCREENSIZEMAX, SCREENSIZEMIN, setFont, setH, setRel, setW, setX, setY, tempW, textShadowColor, TOP, translucentShape, transparentBackground, uiAdjustmentsBasedOnFontHeightIsSupported, uiAndroid, UICONST, uiFlat, uiHolo, uiMaterial, uiVista, visible, width, WILL_RESIZE, x, y
-
-
Constructor Summary
Constructors Constructor Description MultiButton(java.lang.String[] captions)Constructs a MultiButton with the given captions.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetEffectH()intgetEffectW()intgetEffectX()intgetEffectY()intgetPreferredHeight()Returns the preferred height of this control.intgetPreferredWidth()Returns the preferred width of this control.intgetSelectedIndex()Returns the selected indexbooleanisEnabled(int idx)Returns if a caption is enabled or notvoidonBoundsChanged(boolean colorsChanged)Called after a setRect.voidonColorsChanged(boolean colorsChanged)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)Called to draw the control.voidsetEnabled(int idx, boolean enabled)Enables or disables a captionvoidsetSelectedIndex(int sel)Sets the selected index, or -1 to unset it.-
Methods inherited from class totalcross.ui.Control
_onEvent, addEnabledStateListener, addFocusListener, addGridListener, addHighlightListener, addKeyListener, addListContainerListener, addMouseListener, addMultiTouchListener, addPenListener, addPressListener, addPushNotificationListener, addTimer, addTimer, addTimerListener, addWindowListener, bringToFront, changeHighlighted, clear, contains, drawTranslucentBackground, getAbsoluteRect, getBackColor, getEventListeners, getFont, getForeColor, getGap, getGraphics, getHeight, getNext, getParent, getParentWindow, getPos, getPressedEvent, getPrev, getRect, getSize, getTextShadowColor, getWidth, getX, getX2, getY, getY2, hadParentScrolled, handleGeographicalFocusChangeKeys, hasFocus, internalSetEnabled, intXYWH, isActionEvent, isChildOf, isDisplayed, isEnabled, isInsideOrNear, isObscured, isTopMost, isVisible, isVisibleAndInside, onFontChanged, onWindowPaintFinished, post, postEvent, postPressedEvent, releaseScreenShot, removeEnabledStateListener, removeFocusListener, removeGridListener, removeHighlightListener, removeKeyListener, removeListContainerListener, removeMouseListener, removeMultiTouchListener, removePenListener, removePressListener, removePushNotificationListener, removeTimer, removeTimerListener, removeWindowListener, repaint, repaintNow, reposition, reposition, repositionChildren, requestFocus, resetSetPositions, safeRepaintNow, safeUpdateScreen, sendToBack, setBackColor, setBackForeColors, setEnabled, setFocusLess, setFont, setForeColor, setRect, setRect, setRect, setRect, setSet, setTextShadowColor, setTranslucent, setVisible, showTip, takeInitialScreenShot, takeScreenShot, translateFromOrigin, uiStyleChanged, updateScreen, updateTemporary, willOpenKeyboard
-
-
-
-
Method Detail
-
onColorsChanged
public void onColorsChanged(boolean colorsChanged)
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 classControl
-
onBoundsChanged
public void onBoundsChanged(boolean colorsChanged)
Description copied from class:ControlCalled after a setRect.- Overrides:
onBoundsChangedin classControl- Parameters:
colorsChanged- If the bounds were changed due to a screen change (rotation, collapse)
-
setSelectedIndex
public void setSelectedIndex(int sel)
Sets the selected index, or -1 to unset it. Only an enabled index can be selected.
-
setEnabled
public void setEnabled(int idx, boolean enabled)Enables or disables a caption
-
isEnabled
public boolean isEnabled(int idx)
Returns if a caption is enabled or not
-
getSelectedIndex
public int getSelectedIndex()
Returns the selected index
-
onPaint
public void onPaint(Graphics g)
Description copied from class:ControlCalled 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.
-
getEffectW
public int getEffectW()
- Overrides:
getEffectWin classControl
-
getEffectH
public int getEffectH()
- Overrides:
getEffectHin classControl
-
getEffectX
public int getEffectX()
- Overrides:
getEffectXin classControl
-
getEffectY
public int getEffectY()
- Overrides:
getEffectYin classControl
-
onEvent
public void onEvent(Event e)
Description copied from class:ControlCalled to process key, pen, control and other posted events.
-
getPreferredHeight
public int getPreferredHeight()
Description copied from class:ControlReturns the preferred height of this control.- Overrides:
getPreferredHeightin classControl
-
getPreferredWidth
public int getPreferredWidth()
Description copied from class:ControlReturns the preferred width of this control.- Overrides:
getPreferredWidthin classControl
-
-