ewe.ui
Class UpDownInput

java.lang.Object
  extended byewe.ui.ControlBase
      extended byewe.ui.Control
          extended byewe.ui.UpDownInput
All Implemented Interfaces:
CellConstants, ControlConstants, EventListener, ImageRefresher, Intable, TimerProc, UIConstants

public class UpDownInput
extends Control
implements Intable

An UpDownInput is generally used within groups within a single popup-window. This is because the Up/Down cursor keys will change the input value instead of moving from control to control. The Left/Right keys are will be used to go from one control to the next. The Back key is used to abort the entire input and the Action key is used to accept the entire input.

You would usually override the changeToNext() method to cycle through the values but you can either set the textValues Vector to specify a fixed set of text values, or set the integerValues Range to specify a range of allowed integer values.


Field Summary
 boolean allowNumericInput
          Set this false to disallow numeric input.
 int anchor
           
 boolean autoAdvance
          This is true by default and is used with the integerDigits value to allow the focus to move to the next field when the full number of digits for this field has been entered.
static int CHANGE_BY_KEYBOARD
           
static int CHANGE_DONT_FLASH
           
static int CHANGE_DOWN
           
static int CHANGE_OPTIONS_MASK
           
static int CHANGE_TYPE_MASK
           
static int CHANGE_UP
           
 boolean dataChangeOnEachPress
          This is false by default, and if it is set true then a DataChange event will be sent everytime the value changes instead of only when it loses focus (which is the default mode of operation).
 Color focusedColor
           
 boolean hasSplit
          Show the horizontal split line.
 int integerDigits
          If you are using this for integer input, this specifies the number of digits that will be input/displayed.
 Range integerValues
          If this is not null it will indicate a range of allowable integer values.
 Vector textValues
          If this is not null it will indicate a set of allowable text values.
static int VALIDATE_ACTION
           
static int VALIDATE_DATA_ENTRY
           
static int VALIDATE_LOSING_FOCUS
           
 boolean wrapAround
          This is true by default - if it is false the data will not wrap around.
 boolean zeroFillInteger
          If you are using this for integer input, this specifies whether zeros should be placed in front of integer values - it is false by default.
 boolean zeroIndexedText
          This is false by default and if this is true then, when using the textValues Vector to list the allowable text values, this indicates that the list of values should be zero-based indexed, otherwise it will be 1-based index (ie 1 represents the first item, instead of 0 representing the first item).
 
Fields inherited from class ewe.ui.Control
_debug, backGround, beforeRemoved, borderColor, borderStyle, borderWidth, children, columns, constraints, DoPaintMethod, dragging, dragResolution, dragTime, exitKeys, fieldTransfer, font, foreGround, haveNativePaint, height, holdDownPause, holdTick, hotKey, image, lastSelected, listeners, maxHeight, maxWidth, menuState, minHeight, minWidth, modifiers, MyClass, name, next, np, parent, penStatus, popupSound, popupSoundClip, preferredHeight, preferredWidth, prev, prompt, promptControl, rows, ss, standardBorder, standardEdge, startDragResolution, tags, tail, text, toolTip, width, x, y
 
Fields inherited from class ewe.ui.ControlBase
clipItems, clipObject, clipOwner, curPoint, currentPenEvent, debugControl, debugFlag, DidHoldDown, doubleBuffer, doubleClickTime, firstPress, globalDrawFlat, globalEditable, globalEnabled, globalPalmStyle, globalSmallControls, GotPenDown, PenIsOn, pressPoint, TAG_LAST_USER_DATA, TAG_USER_DATA, TAKE_FIRST_PRESS, unnamed, useNativeTextInput
 
Fields inherited from interface ewe.ui.UIConstants
BDR_DOTTED, BDR_INNER, BDR_NOBORDER, BDR_OUTER, BDR_OUTLINE, BDR_RAISEDINNER, BDR_RAISEDOUTER, BDR_SUNKENINNER, BDR_SUNKENOUTER, BF_BOTTOM, BF_BOTTOMLEFT, BF_BOTTOMRIGHT, BF_BUTTON, BF_DIAGONAL, BF_DIAGONAL_ENDBOTTOMLEFT, BF_DIAGONAL_ENDBOTTOMRIGHT, BF_DIAGONAL_ENDTOPLEFT, BF_DIAGONAL_ENDTOPRIGHT, BF_EXACT, BF_FLAT, BF_LEFT, BF_MIDDLE, BF_MONO, BF_PALM, BF_RECT, BF_RIGHT, BF_SOFT, BF_SQUARE, BF_TOP, BF_TOPLEFT, BF_TOPRIGHT, EDGE_BUMP, EDGE_ETCHED, EDGE_RAISED, EDGE_SUNKEN
 
Fields inherited from interface ewe.ui.CellConstants
BORDER, BOTTOM, CELLFLAG, CELLMASK, CENTER, CONTROLMASK, DONTCHANGE, DONTFILL, DONTSTRETCH, EAST, FILL, FIXEDSIZE, GROW, HCENTER, HCONTRACT, HEXPAND, HFILL, HGROW, HSHRINK, HSTRETCH, INITIALLY_CLOSED, INITIALLY_MINIMIZED, INITIALLY_PREFERRED_SIZE, INSETS, LEFT, MAXIMUMSIZE, MINIMUMSIZE, NORTH, NORTHEAST, NORTHWEST, PREFERREDSIZE, RECT, RIGHT, SHRINK, SOUTH, SOUTHEAST, SOUTHWEST, SPAN, STRETCH, TEXTSIZE, TOP, VCENTER, VCONTRACT, VEXPAND, VFILL, VGROW, VSHRINK, VSTRETCH, WEST
 
Fields inherited from interface ewe.ui.ControlConstants
All, AlwaysEnabled, AlwaysRecalculateSizes, ByDeferredMouse, ByDeferredPen, ByFrameChange, ByKeyboard, ByMouse, ByPen, ByRequest, CalculatedSizes, Disabled, DisablePopupMenu, DisplayOnly, Down, DrawFlat, Flag, ForceResize, HasData, Invisible, KeepImage, KeepSIP, Left, MakeMenuAtLeastAsWide, Maximize, Minimize, MouseSensitive, NoFocus, NotAnEditor, NotEditable, PaintDataOnly, PaintOutsideOnly, PenTransparent, PreferredSizeOnly, Right, SendUpKeyEvents, SendUpPenEvents, ShowSIP, ShrinkToNothing, SmallControl, SpecialBackground, TakeControlEvents, TakesKeyFocus, Transparent, Up, WantDrag, WantHoldDown
 
Fields inherited from interface ewe.fx.ImageRefresher
KEEP_VISIBLE
 
Constructor Summary
UpDownInput(int columns)
          Create an UpDownInput that is a specific number of columns wide.
 
Method Summary
protected  boolean changeToNext(int changeType)
          This is called to change the value.
 void changeValue(int changeType)
          This is called when the user presses Up or Down but can also be called programmatically.
 void doPaint(Graphics g, Rect area)
           
 int getInt()
          Return the integer value in the control - by default it simply converts the text value to an integer.
 void gotFocus(int how)
           
 boolean hasChangedSinceGotFocus()
          This returns true if the value represented by the Control has changed since it got the focus.
 void lostFocus(int how)
           
 void numberKeyPressed(int digitValue)
           
 void onKeyEvent(KeyEvent ev)
           
 void penHeld(Point where)
          Called when the Pen or Mouse button is held down on the control.
 void penPressed(Point where)
          Called when the Pen or Mouse button is pressed on the control.
 void setInt(int value)
          Return the integer value in the control - by default it simply converts the text value to an integer.
protected  boolean validateData(int how)
          This is called when the control loses focus or if the action key is pressed.
 
Methods inherited from class ewe.ui.Control
acceptsData, activate, addListener, addTimer, amOnTopFrame, calculateSizes, calculateTextSize, cancelCut, cancelHoldDown, canEdit, chainDataChange, change, checkClipboardOperations, checkExitKey, checkMenu, checkMenuKey, checkModifiers, checkPenTransparent, clearTag, clipboardToString, clipboardTransfer, closeMenu, contains, contains, createGraphics, dataAccepted, dataBeingRemoved, dataDraggedOff, dataDraggedOver, dataDraggedOver, dataDroppedOn, dataTransferCancelled, deactivate, defaultTo, doAction, doActionKey, doBackground, doBorder, doHotKey, doMenu, dontAcceptDrop, doPaintChildren, doPaintChildren, doPaintChildren, doPaintData, doPaintData, doShowMenu, dragged, exitEntry, fillBackground, formClosing, fromClipboard, fromField, fromField, getAllDescendants, getAllSubControls, getBackground, getChildren, getChildrenBackwards, getClipboardMenu, getClipObject, getControlBuffer, getControlBuffer, getDataRect, getDataToCopy, getDataToDragAndDrop, getDim, getDisplayText, getDragAndDropContext, getFont, getFontMetrics, getFontMetrics, getForeground, getFrame, getFrameOrContainer, getGraphics, getImage, getLastSelected, getLocation, getMaximumSize, getMenu, getMinimumSize, getModifiers, getNext, getNextKeyFocus, getParent, getPasswordCharacter, getPosInFrame, getPosInParent, getPreferredSize, getPrompt, getPromptText, getRect, getRect, getServer, getSize, getSizes, getSubControls, getTag, getText, getToolTip, getWindow, hasModifier, hasPopupFormAttached, hasTag, inheritModifiers, isChildOf, isModal, isOnMe, isSomeonesHotKey, make, makeFrameTopMost, makeHot, menuIsActive, modify, modifyAll, modifyAll, notifyAction, notifyDataChange, notifyDataChange, notNative_doPaintChildren, oldButWorksDoPaintChildren, oldPaintChildren, oldPostEvent, onControlEvent, onEvent, onLabelPenEvent, onPaint, onPenEvent, paintBackground, paintChildren, penClicked, penDoubleClicked, penReleased, penRightReleased, popupBeep, popupMenuClosed, popupMenuEvent, popupMenuEvent, postEvent, recalculatePreferredSize, redisplay, refresh, removeListener, removeTimer, repaint, repaintDataNow, repaintNow, repaintNow, repaintNow, requestPaint, requestResizeTo, resetRect, resizeTo, restore, scrollAndRepaint, sendToListeners, set, setBorder, setCell, setClipObject, setControl, setCursor, setFixedSize, setFont, setHotKey, setHotKey, setLocation, setMaximumSize, setMenu, setMinimumSize, setPreferredSize, setPromptControl, setRect, setRect, setServer, setTag, setTags, setText, setTextSize, setToolTip, show, shown, standardOnKeyEvent, startDragAndDrop, startDragAndDrop, startDragging, stopDragging, takeData, takeFocus, takeFromClipboard, takePromptControl, testDim, ticked, toClipboard, toField, toField, toString, toTextData, transferPenPress, transferPenPress, tryDragAndDrop, tryNext, tryStartMenu, updateData, willAcceptDrop, willShowFrame
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode
 

Field Detail

anchor

public int anchor

hasSplit

public boolean hasSplit
Show the horizontal split line.


integerValues

public Range integerValues
If this is not null it will indicate a range of allowable integer values.


textValues

public Vector textValues
If this is not null it will indicate a set of allowable text values.


integerDigits

public int integerDigits
If you are using this for integer input, this specifies the number of digits that will be input/displayed.


zeroFillInteger

public boolean zeroFillInteger
If you are using this for integer input, this specifies whether zeros should be placed in front of integer values - it is false by default.


wrapAround

public boolean wrapAround
This is true by default - if it is false the data will not wrap around.


autoAdvance

public boolean autoAdvance
This is true by default and is used with the integerDigits value to allow the focus to move to the next field when the full number of digits for this field has been entered.


allowNumericInput

public boolean allowNumericInput
Set this false to disallow numeric input. Numeric input is only allowed when the integerValues Range is not null.


zeroIndexedText

public boolean zeroIndexedText
This is false by default and if this is true then, when using the textValues Vector to list the allowable text values, this indicates that the list of values should be zero-based indexed, otherwise it will be 1-based index (ie 1 represents the first item, instead of 0 representing the first item).


dataChangeOnEachPress

public boolean dataChangeOnEachPress
This is false by default, and if it is set true then a DataChange event will be sent everytime the value changes instead of only when it loses focus (which is the default mode of operation).


focusedColor

public Color focusedColor

VALIDATE_LOSING_FOCUS

public static final int VALIDATE_LOSING_FOCUS
See Also:
Constant Field Values

VALIDATE_ACTION

public static final int VALIDATE_ACTION
See Also:
Constant Field Values

VALIDATE_DATA_ENTRY

public static final int VALIDATE_DATA_ENTRY
See Also:
Constant Field Values

CHANGE_UP

public static final int CHANGE_UP
See Also:
Constant Field Values

CHANGE_DOWN

public static final int CHANGE_DOWN
See Also:
Constant Field Values

CHANGE_TYPE_MASK

public static final int CHANGE_TYPE_MASK
See Also:
Constant Field Values

CHANGE_OPTIONS_MASK

public static final int CHANGE_OPTIONS_MASK
See Also:
Constant Field Values

CHANGE_BY_KEYBOARD

public static final int CHANGE_BY_KEYBOARD
See Also:
Constant Field Values

CHANGE_DONT_FLASH

public static final int CHANGE_DONT_FLASH
See Also:
Constant Field Values
Constructor Detail

UpDownInput

public UpDownInput(int columns)
Create an UpDownInput that is a specific number of columns wide.

Method Detail

hasChangedSinceGotFocus

public boolean hasChangedSinceGotFocus()
This returns true if the value represented by the Control has changed since it got the focus.


gotFocus

public void gotFocus(int how)
Overrides:
gotFocus in class Control

lostFocus

public void lostFocus(int how)
Overrides:
lostFocus in class Control

validateData

protected boolean validateData(int how)
This is called when the control loses focus or if the action key is pressed. If the data is invalid you should correct the data.

Parameters:
how - one of the VALIDATE_XXX values.
Returns:
true if the data entered was valid, false if it was not.

doPaint

public void doPaint(Graphics g,
                    Rect area)
Overrides:
doPaint in class Control

changeValue

public void changeValue(int changeType)
This is called when the user presses Up or Down but can also be called programmatically. You would usually not override this, instead override changeToNext().

Parameters:
changeType - either CHANGE_UP or CHANGE_DOWN possibly ORed with CHANGE_BY_KEYBOARD if the change was called by a key press.

getInt

public int getInt()
Return the integer value in the control - by default it simply converts the text value to an integer.

Specified by:
getInt in interface Intable

setInt

public void setInt(int value)
Return the integer value in the control - by default it simply converts the text value to an integer.

Specified by:
setInt in interface Intable

changeToNext

protected boolean changeToNext(int changeType)
This is called to change the value. You should change the text or Image of the input based on changeType.

Parameters:
changeType - either CHANGE_UP or CHANGE_DOWN
Returns:
true if a change was made, false if no change was made.

numberKeyPressed

public void numberKeyPressed(int digitValue)

onKeyEvent

public void onKeyEvent(KeyEvent ev)
Overrides:
onKeyEvent in class Control

penPressed

public void penPressed(Point where)
Description copied from class: Control
Called when the Pen or Mouse button is pressed on the control. This is called by the onPenEvent(PenEvent ev) method.

Within this method you can use the Control.currentPenEvent value to find out more about the PenEvent that caused this - including any modifiers (e.g. SHIFT keys) or determine if the left or right mouse button was pressed.

Overrides:
penPressed in class Control
Parameters:
where - The point on the Control where the pen was pressed.

penHeld

public void penHeld(Point where)
Description copied from class: Control
Called when the Pen or Mouse button is held down on the control. This will only get called if the WantHoldDown modifier has been set for this control. This is called by the onPenEvent(PenEvent ev) method.

Within this method you can use the Control.currentPenEvent value to find out more about the PenEvent that caused this - including any modifiers (e.g. SHIFT keys) or determine if the left or right mouse button was pressed.

This method is usually used to display a context sensitive menu. In fact the default code for it is:

                if (!menuIsActive()) doMenu(p);
        

Overrides:
penHeld in class Control
Parameters:
where - The point on the Control where the pen was held.