Package totalcross.ui
Class Check
- java.lang.Object
-
- totalcross.ui.gfx.GfxSurface
-
- totalcross.ui.Control
-
- totalcross.ui.Check
-
- All Implemented Interfaces:
MaterialEffect.SideEffect,TextControl
public class Check extends Control implements TextControl, MaterialEffect.SideEffect
Check is a control with a box and a check inside of it when the state is checked.Here is an example showing a check being used:
public class MyProgram extends MainWindow { Check check; public void initUI() { add(check = new Check("Check me"), LEFT, AFTER); } public void onEvent(Event event) { if (event.type == ControlEvent.PRESSED && event.target == check) { bool checked = check.isChecked(); ... handle check being pressed
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class totalcross.ui.Control
Control.TranslucentShape
-
-
Field Summary
Fields Modifier and Type Field Description booleanautoSplitSet to true to let the Check split its text based on the width every time its width changes.intcheckColorSet to the color of the check, if you want to make it different of the foreground color.booleanleftJustifyDeprecated.Now the align is always at leftinttextColorSets the text color of the check.-
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 Check(java.lang.String text)Creates a check control displaying the given text.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Clears this control, checking it if clearValueInt is 1.intgetMaxTextWidth()Returns the maximum text width for the lines of this Label.intgetPreferredHeight()returns the preffered height of this control.intgetPreferredWidth()returns the preffered width of this control.java.lang.StringgetText()Gets the text displayed in the check.booleanisChecked()Returns the checked state of the control.protected voidonBoundsChanged(boolean screenChanged)Called after a setRect.protected voidonColorsChanged(boolean colorsChanged)Called after a setEnabled, setForeColor and setBackColor and when a control has been added to a Container.voidonEvent(Event event)Called by the system to pass events to the check control.protected voidonFontChanged()Called after a setFontvoidonPaint(Graphics g)Called by the system to draw the check control.static voidpaintCheck(Graphics g, int fmH, int height)Paints a check in the given coordinates.voidsetChecked(boolean checked)Sets the checked state of the control.voidsetChecked(boolean checked, boolean sendPress)Sets the checked state of the control, and send the press event if desired.voidsetText(java.lang.String text)Sets the text that is displayed in the check.voidsidePaint(Graphics g, int alpha)voidsideStart()voidsideStop()voidsplit(int maxWidth)Splits the text to the given width.-
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, contains, drawTranslucentBackground, getAbsoluteRect, getBackColor, 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, handleGeographicalFocusChangeKeys, hasFocus, internalSetEnabled, intXYWH, isActionEvent, isChildOf, isDisplayed, isEnabled, isInsideOrNear, isObscured, isTopMost, isVisible, isVisibleAndInside, 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
-
-
-
-
Field Detail
-
leftJustify
@Deprecated public boolean leftJustify
Deprecated.Now the align is always at leftSet to true to left-justify the text in the control. The default is right-justified, if the control's width is greater than the preferred one.- Since:
- TotalCross 1.0
-
textColor
public int textColor
Sets the text color of the check. Defaults to the foreground color.- Since:
- TotalCross 2.0.
-
checkColor
public int checkColor
Set to the color of the check, if you want to make it different of the foreground color.- Since:
- TotalCross 1.3
-
autoSplit
public boolean autoSplit
Set to true to let the Check split its text based on the width every time its width changes. If the height is PREFERRED, the Label will change its size accordingly. You may change the height again calling setRect.- Since:
- TotalCross 1.14
-
-
Method Detail
-
onEvent
public void onEvent(Event event)
Called by the system to pass events to the check control.
-
setText
public void setText(java.lang.String text)
Sets the text that is displayed in the check.- Specified by:
setTextin interfaceTextControl
-
getText
public java.lang.String getText()
Gets the text displayed in the check.- Specified by:
getTextin interfaceTextControl
-
isChecked
public boolean isChecked()
Returns the checked state of the control.
-
setChecked
public void setChecked(boolean checked)
Sets the checked state of the control.
-
setChecked
public void setChecked(boolean checked, boolean sendPress)Sets the checked state of the control, and send the press event if desired.
-
getMaxTextWidth
public int getMaxTextWidth()
Returns the maximum text width for the lines of this Label.
-
getPreferredWidth
public int getPreferredWidth()
returns the preffered width of this control.- Overrides:
getPreferredWidthin classControl
-
getPreferredHeight
public int getPreferredHeight()
returns the preffered height of this control.- Overrides:
getPreferredHeightin classControl
-
onColorsChanged
protected 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
-
onPaint
public void onPaint(Graphics g)
Called by the system to draw the check control.
-
paintCheck
public static void paintCheck(Graphics g, int fmH, int height)
Paints a check in the given coordinates. The g must have been translated to destination x,y coordinates.- Parameters:
g- The desired Graphics object where to paint. The forecolor must already be set.fmH- The fmH memberheight- The height of the control. The check will be vertical aligned based on this height.- Since:
- SuperWaba 5.5
-
clear
public void clear()
Clears this control, checking it if clearValueInt is 1.
-
split
public void split(int maxWidth)
Splits the text to the given width. Remember to set the font (or add the Label to its parent) before calling this method.- Since:
- TotalCross 1.14
- See Also:
autoSplit
-
onFontChanged
protected void onFontChanged()
Description copied from class:ControlCalled after a setFont- Overrides:
onFontChangedin classControl
-
onBoundsChanged
protected void onBoundsChanged(boolean screenChanged)
Description copied from class:ControlCalled after a setRect.- Overrides:
onBoundsChangedin classControl- Parameters:
screenChanged- If the bounds were changed due to a screen change (rotation, collapse)
-
sideStart
public void sideStart()
- Specified by:
sideStartin interfaceMaterialEffect.SideEffect
-
sideStop
public void sideStop()
- Specified by:
sideStopin interfaceMaterialEffect.SideEffect
-
sidePaint
public void sidePaint(Graphics g, int alpha)
- Specified by:
sidePaintin interfaceMaterialEffect.SideEffect
-
-