Class 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.
    • 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 method gotoNext.
        Since:
        TotalCross 1.53
    • Constructor Detail

      • CalculatorBox

        public CalculatorBox()
        Constructs a CalculatorBox with the 6 basic operations visible.
      • CalculatorBox

        public CalculatorBox​(boolean showOperations)
        Constructs a CalculatorBox with the 6 basic operations hidden.
    • 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: Container
        Clears all children controls that are focusTraversable, recursively.
        Overrides:
        clear in class Container
      • onUnpop

        public void onUnpop()
        Description copied from class: Window
        Placeholder called imediatly before the unpop began. The default implementation does nothing.
        Overrides:
        onUnpop in class Window
      • onPopup

        public void onPopup()
        Description copied from class: Window
        Placeholder called imediatly before the popup began. The default implementation does nothing.
        Overrides:
        onPopup in class Window
      • postPopup

        public void postPopup()
        Description copied from class: Window
        Placeholder called after the popup is done and after the repaint of this window. The default implementation does nothing.
        Overrides:
        postPopup in class Window
      • postUnpop

        protected void postUnpop()
        Description copied from class: Window
        Placeholder called after the unpop is done and after the repaint of the other window. The default implementation does nothing.
        Overrides:
        postUnpop in class Window
      • 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: Control
        Called to process key, pen, control and other posted events.
        Overrides:
        onEvent in class Control
        Parameters:
        event - the event to process
        See Also:
        Event, KeyEvent, PenEvent
      • reposition

        public void reposition()
        Description copied from class: Control
        Reposition this control, calling again setRect with the original parameters.
        Overrides:
        reposition in class Control