Package totalcross.ui
Class TopMenu
- java.lang.Object
-
- totalcross.ui.gfx.GfxSurface
-
- totalcross.ui.Control
-
- totalcross.ui.Container
-
- totalcross.ui.Window
-
- totalcross.ui.TopMenu
-
public class TopMenu extends Window
This is a top menu like those on Android. It opens and closes using animation and fading effects.- Since:
- TotalCross 3.03
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceTopMenu.AnimationListenerstatic classTopMenu.Item-
Nested classes/interfaces inherited from class totalcross.ui.Control
Control.TranslucentShape
-
-
Field Summary
Fields Modifier and Type Field Description booleanautoCloseSet to false to disable the close when pressing in a button of the menu.ImagebackImageAn optional image to be used as backgroundintbackImageAlphaThe alpha value to be applied to the background imagebooleandrawSeparatorsContainerheaderdoubleitemHeightFactorprotected Control[]itemsstatic intpercCapThe percentage of the area used for the icon and the captionstatic intpercIconThe percentage of the area used for the icon and the captionintpercWidthThe percentage of the screen that this TopMenu will take: LEFT/RIGHT will take 50% of the screen's width, other directions will take 80% of the screen's width.InsetsscInsetsInsets used to place the ScrollContainer.protected intselectedintseparatorColorbooleanshowElevationinttotalTimeDefines the animation delayintwidthInPixelsThe width in pixels instead of percentage of screen's width.-
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, children, controlFound, finishedStart, ignoreOnAddAgain, ignoreOnRemove, insets, lastH, lastScreenWidth, lastW, npback, numChildren, started, tabOrder, tail, TRANSITION_CLOSE, TRANSITION_FADE, TRANSITION_NONE, TRANSITION_OPEN, TRANSITION_TIME, transitionEffect
-
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
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetSelectedIndex()voidinitUI()Called to initialize the User Interface of this container.booleanisFadeOnPopAndUnpop()Returns if this control fades in/out on pop/unpopprotected booleanonClickedOutside(PenEvent event)called when the user clicks outside the bounds of this window.voidonEvent(Event e)Called to process key, pen, control and other posted events.voidonPopup()Placeholder called imediatly before the popup began.voidpopup()Pops up this window, blocking the execution until the window closes.protected voidpostPopup()Placeholder called after the popup is done and after the repaint of this window.voidpostUnpop()Placeholder called after the unpop is done and after the repaint of the other window.voidscreenResized()Called when the screen is resized, probably caused by a rotation.voidsetFadeOnPopAndUnpop(boolean fadeOnPopAndUnpop)sets if this control fades in/out on pop/unpopprotected voidsetRect(boolean screenResized)voidunpop()Unpops the current TopMenuvoidunpop(TopMenu.AnimationListener alist)Unpops the current TopMenu with the given animation listener.-
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, onRobotKey, onUnpop, paintTitle, paintWindowBackground, popupMenuBar, popupNonBlocking, postPressedEvent, pumpEvents, removeFocus, repaintActiveWindows, resize, resizeHeight, resizeWidth, setBorderStyle, setDeviceTitle, setFocus, setGrabPenEvents, setHighlighted, setMenuBar, setOrientation, setSIP, setTitle, setTitleFont, shiftScreen, swap, swapFocus, validate
-
Methods inherited from class totalcross.ui.Container
add, add, add, add, add, applyTransitionEffect, broadcastEvent, clear, fillBackground, fillBackground, findChild, findNearestChild, findNextFocusControl, getChildren, getChildrenCount, getFirstChild, getFocusableControls, getInsets, incLastX, incLastY, isPressed, moveFocusToNextControl, moveFocusToNextEditable, onAddAgain, onColorsChanged, onPaint, onRemove, onSwapFinished, paintChildren, remove, removeAll, setEnabled, setFocusTraversable, setHighlighting, setInsets, setNextTransitionEffect, 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, 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
-
percIcon
public static int percIcon
The percentage of the area used for the icon and the caption
-
percCap
public static int percCap
The percentage of the area used for the icon and the caption
-
items
protected Control[] items
-
selected
protected int selected
-
autoClose
public boolean autoClose
Set to false to disable the close when pressing in a button of the menu.
-
totalTime
public int totalTime
Defines the animation delay
-
percWidth
public int percWidth
The percentage of the screen that this TopMenu will take: LEFT/RIGHT will take 50% of the screen's width, other directions will take 80% of the screen's width. Must be ser before callingpopup().
-
widthInPixels
public int widthInPixels
The width in pixels instead of percentage of screen's width.
-
backImage
public Image backImage
An optional image to be used as background
-
backImageAlpha
public int backImageAlpha
The alpha value to be applied to the background image
-
scInsets
public Insets scInsets
Insets used to place the ScrollContainer.
-
drawSeparators
public boolean drawSeparators
-
separatorColor
public int separatorColor
-
showElevation
public boolean showElevation
-
itemHeightFactor
public double itemHeightFactor
-
header
public Container header
-
-
Method Detail
-
popup
public void popup()
Description copied from class:WindowPops up this window, blocking the execution until the window closes.
-
setRect
protected void setRect(boolean screenResized)
-
initUI
public void initUI()
Description copied from class:ContainerCalled to initialize the User Interface of this container. This differs from the onAddAgain method by that this method is called only once, at the first time the control is added to the parent. When the container is being setup, the initUI method is called; then, the onAddAgain is called every time the container is added again.
-
onEvent
public void onEvent(Event e)
Description copied from class:ControlCalled to process key, pen, control and other posted events.
-
screenResized
public void screenResized()
Description copied from class:WindowCalled when the screen is resized, probably caused by a rotation. ATTENTION: THIS CALL CANNOT BE BLOCKED OR THE SYSTEM WILL LOCK!- Overrides:
screenResizedin classWindow
-
onClickedOutside
protected boolean onClickedOutside(PenEvent event)
Description copied from class:Windowcalled when the user clicks outside the bounds of this window. must return true if the event was handled, false otherwise. If false is returned andbeepIfOutis true, then a beep is played and nothing more happens.- Overrides:
onClickedOutsidein classWindow
-
unpop
public void unpop(TopMenu.AnimationListener alist)
Unpops the current TopMenu with the given animation listener. This listener will be notified when the unpop animation ends.- Parameters:
alist-
-
postUnpop
public 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.
-
onPopup
public void onPopup()
Description copied from class:WindowPlaceholder called imediatly before the popup began. The default implementation does nothing.
-
postPopup
protected 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.
-
getSelectedIndex
public int getSelectedIndex()
-
isFadeOnPopAndUnpop
public boolean isFadeOnPopAndUnpop()
Returns if this control fades in/out on pop/unpop
-
setFadeOnPopAndUnpop
public void setFadeOnPopAndUnpop(boolean fadeOnPopAndUnpop)
sets if this control fades in/out on pop/unpop
-
-