Package totalcross.ui

Class 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
    • 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
      • 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 calling popup().
      • 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
    • Constructor Detail

      • TopMenu

        public TopMenu​(Control[] items,
                       int animDir,
                       byte borderStyle)
        Parameters:
        animDir - LEFT, RIGHT, TOP, BOTTOM, CENTER
      • TopMenu

        public TopMenu​(Control[] items,
                       int animDir)
        Parameters:
        animDir - LEFT, RIGHT, TOP, BOTTOM, CENTER
    • Method Detail

      • popup

        public void popup()
        Description copied from class: Window
        Pops up this window, blocking the execution until the window closes.
        Overrides:
        popup in class Window
      • setRect

        protected void setRect​(boolean screenResized)
      • initUI

        public void initUI()
        Description copied from class: Container
        Called 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.
        Overrides:
        initUI in class Container
      • onEvent

        public void onEvent​(Event e)
        Description copied from class: Control
        Called to process key, pen, control and other posted events.
        Overrides:
        onEvent in class Control
        Parameters:
        e - the event to process
        See Also:
        Event, KeyEvent, PenEvent
      • screenResized

        public void screenResized()
        Description copied from class: Window
        Called when the screen is resized, probably caused by a rotation. ATTENTION: THIS CALL CANNOT BE BLOCKED OR THE SYSTEM WILL LOCK!
        Overrides:
        screenResized in class Window
      • onClickedOutside

        protected boolean onClickedOutside​(PenEvent event)
        Description copied from class: Window
        called when the user clicks outside the bounds of this window. must return true if the event was handled, false otherwise. If false is returned and beepIfOut is true, then a beep is played and nothing more happens.
        Overrides:
        onClickedOutside in class Window
      • unpop

        public void unpop()
        Unpops the current TopMenu
        Overrides:
        unpop in class Window
      • 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: 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
      • 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

        protected 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
      • 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