Package totalcross.ui.dialog
Class CalculatorBox
- java.lang.Object
-
- totalcross.ui.gfx.GfxSurface
-
- totalcross.ui.Control
-
- totalcross.ui.Container
-
- totalcross.ui.Window
-
- totalcross.ui.dialog.CalculatorBox
-
public class CalculatorBox extends Window
This class is used by the Edit class when its mode is set to CURRENCY and displays a calculator with six basic operations and a numeric pad.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceCalculatorBox.RangeCheckImplement this interface to check if the given value is a valid value to be returned.-
Nested classes/interfaces inherited from class totalcross.ui.Control
Control.TranslucentShape
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String[]actionsStrings used to display the action messages.ControlcOrigThe control that had focus when this CalculatorBox was popped up.ControlcOrigDefaultThe desired control that will be the original one.static java.lang.StringdefaultTitleThe default title.java.lang.StringdefaultValueThe default value of the edit.EditedNumberThe Edit used to show the number.booleankeepOriginalValueSet to true to don't replace the original value in the Edit if user pressed Ok.intmaxLengthThe maximum length for the edit that will be created.java.lang.StringoptionalValueDefines an optional character to be used in the NumericBox.CalculatorBox.RangeCheckrangeCheckThe RangeCheck instance that will be called before the user closes the box.static booleanshowNextButtonInsteadOfClearSet to true to replace the "Clear" button by the "Next" button.-
Fields inherited from class totalcross.ui.Window
_controlEvent, _dragEvent, _focus, _keyEvent, _mouseEvent, _multiEvent, _penEvent, androidBorderThickness, beepIfOut, blocking, borderStyle, cancelPenUp, canDrag, dragThreshold, fadeOtherWindows, fadeValue, firstFocus, flickEnabled, focusOnPenUp, footerColor, footerH, gradientTitleEndColor, gradientTitleStartColor, headerColor, highlighted, highResPrepared, HORIZONTAL_GRADIENT, ignoreEventOfType, keyHook, lastShiftY, lastSwappedContainer, mainSwapContainer, menubar, multiTouching, needsPaint, NO_BORDER, ORIENTATION_INVERTED, ORIENTATION_LANDSCAPE, ORIENTATION_PORTRAIT, popped, RECT_BORDER, repaintOnSwap, robot, ROUND_BORDER, rTitle, sameBackgroundColor, shiftH, shiftY, SIP_BOTTOM, SIP_HIDE, SIP_SHOW, SIP_TOP, TAB_BORDER, TAB_ONLY_BORDER, tempTitle, title, titleAlign, titleColor, titleFont, titleGap, topMost, VERTICAL_GRADIENT, zStack
-
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, 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
-
-
Constructor Summary
Constructors Constructor Description CalculatorBox()Constructs a CalculatorBox with the 6 basic operations visible.CalculatorBox(boolean showOperations)Constructs a CalculatorBox with the 6 basic operations hidden.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Clears all children controls that arefocusTraversable, recursively.java.lang.StringgetAnswer()Gets the answer that the user selected to be pasted.protected ControlgotoNext()Returns the next control to be focused when Next is clicked.voidonEvent(Event event)Called to process key, pen, control and other posted events.voidonPopup()Placeholder called imediatly before the popup began.voidonUnpop()Placeholder called imediatly before the unpop began.voidpostPopup()Placeholder called after the popup is done and after the repaint of this window.protected voidpostUnpop()Placeholder called after the unpop is done and after the repaint of the other window.voidreposition()Reposition this control, calling again setRect with the original parameters.-
Methods inherited from class totalcross.ui.Window
_doPaint, _postEvent, destroyZStack, drawHighlight, getBorderStyle, getClientRect, getClientRect, getDefaultDragThreshold, getFocus, getHighlighted, getPopupCount, getPreferredHeight, getPreferredWidth, getSafeAreaInsets, getTitleFont, getTopMost, handleFocusChangeKeys, isScreenShifted, isSipShown, isSipShown4D, isTopMost, isVisible, loadBehind, makeUnmovable, onClickedOutside, onRobotKey, paintTitle, paintWindowBackground, popup, popupMenuBar, popupNonBlocking, postPressedEvent, pumpEvents, removeFocus, repaintActiveWindows, resize, resizeHeight, resizeWidth, screenResized, setBorderStyle, setDeviceTitle, setFocus, setGrabPenEvents, setHighlighted, setMenuBar, setOrientation, setSIP, setTitle, setTitleFont, shiftScreen, swap, swapFocus, unpop, validate
-
Methods inherited from class totalcross.ui.Container
add, add, add, add, add, broadcastEvent, fillBackground, fillBackground, findChild, findNearestChild, findNextFocusControl, getBorderRadius, getChildren, getChildrenCount, getFirstChild, getFocusableControls, getInsets, incLastX, incLastY, initUI, isPressed, moveFocusToNextControl, moveFocusToNextEditable, onAddAgain, onColorsChanged, onPaint, onRemove, onSwapFinished, paintChildren, remove, removeAll, setBorderRadius, setEnabled, setFocusTraversable, setHighlighting, 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, handleGeographicalFocusChangeKeys, hasFocus, internalSetEnabled, intXYWH, isActionEvent, isChildOf, isDisplayed, isEnabled, isFloating, isInsideOrNear, isObscured, isVisibleAndInside, onBoundsChanged, onFontChanged, onWindowPaintFinished, post, postEvent, releaseScreenShot, removeEnabledStateListener, removeFocusListener, removeGridListener, removeHandler, removeHighlightListener, removeKeyListener, removeListContainerListener, removeMouseListener, removeMultiTouchListener, removePenListener, removePressListener, removePushNotificationListener, removeTimer, removeTimerListener, removeWindowListener, repaint, repaintNow, reposition, repositionChildren, requestFocus, resetSetPositions, resetStyle, safeRepaintNow, safeUpdateScreen, sendToBack, setBackColor, setBackForeColors, setDoEffect, setFloating, setFocusLess, setFont, setForeColor, setNinePatch, setNinePatch, setRect, setRect, setRect, setRect, setSet, setTextShadowColor, setTranslucent, setVisible, showTip, takeInitialScreenShot, takeScreenShot, translateFromOrigin, uiStyleChanged, updateScreen, updateTemporary, willOpenKeyboard
-
-
-
-
Field Detail
-
rangeCheck
public CalculatorBox.RangeCheck rangeCheck
The RangeCheck instance that will be called before the user closes the box.
-
edNumber
public Edit edNumber
The Edit used to show the number.
-
actions
public static java.lang.String[] actions
Strings used to display the action messages. You can localize these strings if you wish.
-
defaultTitle
public static java.lang.String defaultTitle
The default title.
-
optionalValue
public java.lang.String optionalValue
Defines an optional character to be used in the NumericBox. Replaces the decimal separator / 00 char.- Since:
- TotalCross 1.5
-
maxLength
public int maxLength
The maximum length for the edit that will be created.
-
defaultValue
public java.lang.String defaultValue
The default value of the edit.
-
cOrig
public Control cOrig
The control that had focus when this CalculatorBox was popped up.
-
cOrigDefault
public Control cOrigDefault
The desired control that will be the original one.
-
keepOriginalValue
public boolean keepOriginalValue
Set to true to don't replace the original value in the Edit if user pressed Ok.
-
showNextButtonInsteadOfClear
public static boolean showNextButtonInsteadOfClear
Set to true to replace the "Clear" button by the "Next" button. This button is equivalent to the "Ok" button, but it also changes the focus to the next field. The user can still clean the edit by clicking the backspace << button. The default behaviour calls moveFocusToNextControl. You can change it by overriding the methodgotoNext.- Since:
- TotalCross 1.53
-
-
Method Detail
-
getAnswer
public java.lang.String getAnswer()
Gets the answer that the user selected to be pasted. It can be the first operator, the total computed or null if the user canceled.
-
clear
public void clear()
Description copied from class:ContainerClears all children controls that arefocusTraversable, recursively.
-
onUnpop
public void onUnpop()
Description copied from class:WindowPlaceholder called imediatly before the unpop began. The default implementation does nothing.
-
onPopup
public void onPopup()
Description copied from class:WindowPlaceholder called imediatly before the popup began. The default implementation does nothing.
-
postPopup
public void postPopup()
Description copied from class:WindowPlaceholder called after the popup is done and after the repaint of this window. The default implementation does nothing.
-
postUnpop
protected void postUnpop()
Description copied from class:WindowPlaceholder called after the unpop is done and after the repaint of the other window. The default implementation does nothing.
-
gotoNext
protected Control gotoNext()
Returns the next control to be focused when Next is clicked. By default, calls moveFocusToNextControl.- Since:
- TotalCross 1.53
-
onEvent
public void onEvent(Event event)
Description copied from class:ControlCalled to process key, pen, control and other posted events.
-
reposition
public void reposition()
Description copied from class:ControlReposition this control, calling again setRect with the original parameters.- Overrides:
repositionin classControl
-
-