Package totalcross.ui.dialog
Class CalendarBox
- java.lang.Object
-
- totalcross.ui.gfx.GfxSurface
-
- totalcross.ui.Control
-
- totalcross.ui.Container
-
- totalcross.ui.Window
-
- totalcross.ui.dialog.CalendarBox
-
public class CalendarBox extends Window
The Calendar class displays a calendar with buttons used to advance the month and the year. It uses the Date class for all operations.
Instead of create a new instance (which consumes memory), you may use the Edit's static field calendarIf there is something in the edit box which poped up the calendar, the clear button will clear it. Cancel will leave whatever was in there.
The month can be changed via keyboard using the left/right keys, and the year can be changed using up/down keys.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class totalcross.ui.Control
Control.TranslucentShape
-
-
Field Summary
Fields Modifier and Type Field Description protected booleancancelDragbooleancanceledTrue if the user had canceled without selectingstatic java.lang.String[]monthNamesThe 12 month names painted in the control.static java.lang.String[]weekNamesThe 7 week names painted in the control.static intYEAR_ARRAY_LENGTHDefines the array length of year window.static java.lang.String[]yearMonthThe labels between the arrows: Month, Year-
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 CalendarBox()Constructs Calendar set to the current day.CalendarBox(int fore)CalendarBox(int fore, Date date)CalendarBox(Date date)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DategetSelectedDate()Returns the selected Date.voidonEvent(Event event)Called to process key, pen, control and other posted events.voidonPaint(Graphics g)Draws the border (if any).protected voidonPopup()Placeholder called imediatly before the popup began.protected voidonUnpop()Placeholder called imediatly before the unpop began.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.voidsetSelectedDate(Date d)Sets the current day to the Date specified.-
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, postPopup, 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, clear, fillBackground, fillBackground, findChild, findNearestChild, findNextFocusControl, getBorderRadius, getChildren, getChildrenCount, getFirstChild, getFocusableControls, getInsets, incLastX, incLastY, initUI, isPressed, moveFocusToNextControl, moveFocusToNextEditable, onAddAgain, onColorsChanged, 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
-
YEAR_ARRAY_LENGTH
public static int YEAR_ARRAY_LENGTH
Defines the array length of year window. If array length is 20, and current year is 2010, the list goes from 2000 to 2019.- Since:
- TotalCross 1.66
-
canceled
public boolean canceled
True if the user had canceled without selecting
-
weekNames
public static java.lang.String[] weekNames
The 7 week names painted in the control.
-
monthNames
public static java.lang.String[] monthNames
The 12 month names painted in the control.
-
yearMonth
public static java.lang.String[] yearMonth
The labels between the arrows: Month, Year
-
cancelDrag
protected boolean cancelDrag
-
-
Method Detail
-
getSelectedDate
public Date getSelectedDate()
Returns the selected Date.- Returns:
- Date object set to the selected day, or null if an error occurs.
-
setSelectedDate
public void setSelectedDate(Date d)
Sets the current day to the Date specified. If its null, sets the date to today.
-
onEvent
public void onEvent(Event event)
Description copied from class:ControlCalled to process key, pen, control and other posted events.
-
onPaint
public void onPaint(Graphics g)
Description copied from class:ContainerDraws the border (if any). If you override this method, be sure to callsuper.onPaint(g);, or the border will not be drawn.
-
onPopup
protected void onPopup()
Description copied from class:WindowPlaceholder called imediatly before the popup began. The default implementation does nothing.
-
reposition
public void reposition()
Description copied from class:ControlReposition this control, calling again setRect with the original parameters.- Overrides:
repositionin classControl
-
onUnpop
protected void onUnpop()
Description copied from class:WindowPlaceholder called imediatly before the unpop began. The default implementation does nothing.
-
-