totalcross.ui
Class Check

totalcross.lang.Object
  extended by totalcross.ui.gfx.GfxSurface
      extended by totalcross.ui.Control
          extended by totalcross.ui.Check

public class Check
extends Control

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
 


Field Summary
 boolean leftJustify
          Set to true to left-justify the text in the control.
 
Fields inherited from class totalcross.ui.Control
AFTER, appId, appObj, asContainer, asWindow, backColor, BEFORE, BOTTOM, BOTTOM_OF, CENTER, CENTER_OF, clearValueInt, clearValueStr, enabled, enableUpdateScreen, FILL, FIT, fm, fmH, focusHandler, focusLess, focusOnPenDown, focusTraversable, font, foreColor, height, isHighlighting, KEEP, LEFT, onEventFirst, parent, PREFERRED, RANGE, repositionAllowed, RIGHT, RIGHT_OF, SAME, setFont, setH, setRel, setW, setX, setY, TOP, transparentBackground, uiCE, uiFlat, uiPalm, uiVista, visible, width, WILL_RESIZE, x, y
 
Constructor Summary
Check(String text)
          Creates a check control displaying the given text.
 
Method Summary
 void clear()
          Clears this control, checking it if clearValueInt is 1.
 int getPreferredHeight()
          returns the preffered height of this control.
 int getPreferredWidth()
          returns the preffered width of this control.
 String getText()
          Gets the text displayed in the check.
 boolean isChecked()
          Returns the checked state of the control.
protected  void onColorsChanged(boolean colorsChanged)
          Called after a setEnabled, setForeColor and setBackColor and when a control has been added to a Container.
 void onEvent(Event event)
          Called by the system to pass events to the check control.
protected  void onFontChanged()
          Called after a setFont
 void onPaint(Graphics g)
          Called by the system to draw the check control.
static void paintCheck(Graphics g, int fmH, int height)
          Paints a check in the given coordinates.
 void setChecked(boolean checked)
          Sets the checked state of the control.
 void setText(String text)
          Sets the text that is displayed in the check.
 
Methods inherited from class totalcross.ui.Control
_onEvent, addFocusListener, addGridListener, addHighlightListener, addKeyListener, addPenListener, addPressListener, addTimer, addTimer, addTimerListener, addWindowListener, changeHighlighted, contains, getAbsoluteRect, getBackColor, getEventListeners, getFont, getForeColor, getGraphics, getHeight, getNext, getParent, getParentWindow, getPos, getPressedEvent, getPrev, getRect, getSize, getWidth, getX, getX2, getY, getY2, handleGeographicalFocusChangeKeys, isDisplayed, isEnabled, isInsideOrNear, isVisible, isVisibleAndInside, onBoundsChanged, onWindowPaintFinished, postEvent, postPressedEvent, removeFocusListener, removeGridListener, removeHighlightListener, removeKeyListener, removePenListener, removePressListener, removeTimer, removeTimerListener, removeWindowListener, repaint, repaintNow, reposition, reposition, requestFocus, setBackColor, setBackForeColors, setEnabled, setFocusLess, setFont, setForeColor, setRect, setRect, setRect, setRect, setVisible, translateFromOrigin, uiStyleChanged, updateScreen, updateTemporary
 
Methods inherited from class totalcross.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

leftJustify

public boolean leftJustify
Set 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
Constructor Detail

Check

public Check(String text)
Creates a check control displaying the given text.

Method Detail

onEvent

public void onEvent(Event event)
Called by the system to pass events to the check control.

Overrides:
onEvent in class Control
Parameters:
event - the event to process
See Also:
Event, KeyEvent, PenEvent

setText

public void setText(String text)
Sets the text that is displayed in the check.


getText

public String getText()
Gets the text displayed in the check.


isChecked

public boolean isChecked()
Returns the checked state of the control.


setChecked

public void setChecked(boolean checked)
Sets the checked state of the control.


getPreferredWidth

public int getPreferredWidth()
returns the preffered width of this control.

Overrides:
getPreferredWidth in class Control

getPreferredHeight

public int getPreferredHeight()
returns the preffered height of this control.

Overrides:
getPreferredHeight in class Control

onColorsChanged

protected void onColorsChanged(boolean colorsChanged)
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 Control

onFontChanged

protected void onFontChanged()
Description copied from class: Control
Called after a setFont

Overrides:
onFontChanged in class Control

onPaint

public void onPaint(Graphics g)
Called by the system to draw the check control.

Overrides:
onPaint in class Control
Parameters:
g - the graphics object for drawing
See Also:
Graphics

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 member
height - 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.

Overrides:
clear in class Control