Package jexer.menu

Class TMenu

  • All Implemented Interfaces:
    java.lang.Comparable<TWidget>

    public class TMenu
    extends TWindow
    TMenu is a top-level collection of TMenuItems.
    • Field Detail

      • MID_UNUSED

        public static final int MID_UNUSED
        A menu item that will not generate a TMenuEvent.
        See Also:
        Constant Field Values
      • MID_VIEW_ANSI

        public static final int MID_VIEW_ANSI
        View ASCII/ANSI file.
        See Also:
        Constant Field Values
      • MID_SCREEN_OPTIONS

        public static final int MID_SCREEN_OPTIONS
        Screen options.
        See Also:
        Constant Field Values
      • MID_CUT

        public static final int MID_CUT
        Cut selected text and copy to the clipboard.
        See Also:
        Constant Field Values
      • MID_COPY

        public static final int MID_COPY
        Copy selected text to clipboard.
        See Also:
        Constant Field Values
      • MID_CLEAR

        public static final int MID_CLEAR
        Clear selected text without copying it to the clipboard.
        See Also:
        Constant Field Values
      • MID_SEARCH_AGAIN

        public static final int MID_SEARCH_AGAIN
        Search again.
        See Also:
        Constant Field Values
      • MID_GOTO_LINE

        public static final int MID_GOTO_LINE
        Go to line number.
        See Also:
        Constant Field Values
      • MID_CLOSE_ALL

        public static final int MID_CLOSE_ALL
        Close all windows.
        See Also:
        Constant Field Values
      • MID_WINDOW_MOVE

        public static final int MID_WINDOW_MOVE
        Size/move window.
        See Also:
        Constant Field Values
      • MID_WINDOW_ZOOM

        public static final int MID_WINDOW_ZOOM
        Move (move/resize) window.
        See Also:
        Constant Field Values
      • MID_WINDOW_NEXT

        public static final int MID_WINDOW_NEXT
        Next window (like Alt-TAB).
        See Also:
        Constant Field Values
      • MID_WINDOW_PREVIOUS

        public static final int MID_WINDOW_PREVIOUS
        Previous window (like Shift-Alt-TAB).
        See Also:
        Constant Field Values
      • MID_WINDOW_CLOSE

        public static final int MID_WINDOW_CLOSE
        Close window.
        See Also:
        Constant Field Values
      • MID_HELP_CONTENTS

        public static final int MID_HELP_CONTENTS
        Help system - Table of Contents.
        See Also:
        Constant Field Values
      • MID_HELP_INDEX

        public static final int MID_HELP_INDEX
        Help system - Index.
        See Also:
        Constant Field Values
      • MID_HELP_SEARCH

        public static final int MID_HELP_SEARCH
        Help system - Topic search.
        See Also:
        Constant Field Values
      • MID_HELP_PREVIOUS

        public static final int MID_HELP_PREVIOUS
        Help system - Previous topic.
        See Also:
        Constant Field Values
      • MID_HELP_HELP

        public static final int MID_HELP_HELP
        Help system - Help on help.
        See Also:
        Constant Field Values
      • MID_HELP_ACTIVE_FILE

        public static final int MID_HELP_ACTIVE_FILE
        Help system - Change active help file.
        See Also:
        Constant Field Values
      • MID_ABOUT

        public static final int MID_ABOUT
        Show "About Application" dialog.
        See Also:
        Constant Field Values
      • MID_TABLE_RENAME_ROW

        public static final int MID_TABLE_RENAME_ROW
        Rename row.
        See Also:
        Constant Field Values
      • MID_TABLE_RENAME_COLUMN

        public static final int MID_TABLE_RENAME_COLUMN
        Rename column.
        See Also:
        Constant Field Values
      • MID_TABLE_VIEW_ROW_LABELS

        public static final int MID_TABLE_VIEW_ROW_LABELS
        Show/hide row labels.
        See Also:
        Constant Field Values
      • MID_TABLE_VIEW_COLUMN_LABELS

        public static final int MID_TABLE_VIEW_COLUMN_LABELS
        Show/hide column labels.
        See Also:
        Constant Field Values
      • MID_TABLE_VIEW_HIGHLIGHT_ROW

        public static final int MID_TABLE_VIEW_HIGHLIGHT_ROW
        Enable/disable highlight selected row.
        See Also:
        Constant Field Values
      • MID_TABLE_VIEW_HIGHLIGHT_COLUMN

        public static final int MID_TABLE_VIEW_HIGHLIGHT_COLUMN
        Enable/disable highlight selected column.
        See Also:
        Constant Field Values
      • MID_TABLE_BORDER_NONE

        public static final int MID_TABLE_BORDER_NONE
        Remove all borders for the entire table.
        See Also:
        Constant Field Values
      • MID_TABLE_BORDER_ALL

        public static final int MID_TABLE_BORDER_ALL
        Set all borders for the entire table.
        See Also:
        Constant Field Values
      • MID_TABLE_BORDER_CELL_NONE

        public static final int MID_TABLE_BORDER_CELL_NONE
        Remove all borders for selected cell.
        See Also:
        Constant Field Values
      • MID_TABLE_BORDER_CELL_ALL

        public static final int MID_TABLE_BORDER_CELL_ALL
        Set all borders for selected cell.
        See Also:
        Constant Field Values
      • MID_TABLE_BORDER_RIGHT

        public static final int MID_TABLE_BORDER_RIGHT
        Set right border for selected cell.
        See Also:
        Constant Field Values
      • MID_TABLE_BORDER_LEFT

        public static final int MID_TABLE_BORDER_LEFT
        Set left border for selected cell.
        See Also:
        Constant Field Values
      • MID_TABLE_BORDER_TOP

        public static final int MID_TABLE_BORDER_TOP
        Set top border for selected cell.
        See Also:
        Constant Field Values
      • MID_TABLE_BORDER_BOTTOM

        public static final int MID_TABLE_BORDER_BOTTOM
        Set bottom border for selected cell.
        See Also:
        Constant Field Values
      • MID_TABLE_BORDER_DOUBLE_BOTTOM

        public static final int MID_TABLE_BORDER_DOUBLE_BOTTOM
        Set double-line bottom border for selected cell.
        See Also:
        Constant Field Values
      • MID_TABLE_BORDER_THICK_BOTTOM

        public static final int MID_TABLE_BORDER_THICK_BOTTOM
        Set thick bottom border for selected cell.
        See Also:
        Constant Field Values
      • MID_TABLE_DELETE_LEFT

        public static final int MID_TABLE_DELETE_LEFT
        Delete selected cell, shifting cells left.
        See Also:
        Constant Field Values
      • MID_TABLE_DELETE_UP

        public static final int MID_TABLE_DELETE_UP
        Delete selected cell, shifting cells up.
        See Also:
        Constant Field Values
      • MID_TABLE_DELETE_ROW

        public static final int MID_TABLE_DELETE_ROW
        Delete selected row.
        See Also:
        Constant Field Values
      • MID_TABLE_DELETE_COLUMN

        public static final int MID_TABLE_DELETE_COLUMN
        Delete selected column.
        See Also:
        Constant Field Values
      • MID_TABLE_INSERT_LEFT

        public static final int MID_TABLE_INSERT_LEFT
        Insert column to the left of selected cell.
        See Also:
        Constant Field Values
      • MID_TABLE_INSERT_RIGHT

        public static final int MID_TABLE_INSERT_RIGHT
        Insert column to the right of selected cell.
        See Also:
        Constant Field Values
      • MID_TABLE_INSERT_ABOVE

        public static final int MID_TABLE_INSERT_ABOVE
        Insert row above selected cell.
        See Also:
        Constant Field Values
      • MID_TABLE_INSERT_BELOW

        public static final int MID_TABLE_INSERT_BELOW
        Insert row below selected cell.
        See Also:
        Constant Field Values
      • MID_TABLE_COLUMN_NARROW

        public static final int MID_TABLE_COLUMN_NARROW
        Narrow column width of selected cell.
        See Also:
        Constant Field Values
      • MID_TABLE_COLUMN_WIDEN

        public static final int MID_TABLE_COLUMN_WIDEN
        Expand column width of selected cell.
        See Also:
        Constant Field Values
      • MID_TABLE_FILE_OPEN_CSV

        public static final int MID_TABLE_FILE_OPEN_CSV
        Open comma-separated-values (CSV) file as new table window.
        See Also:
        Constant Field Values
      • MID_TABLE_FILE_SAVE_CSV

        public static final int MID_TABLE_FILE_SAVE_CSV
        Save entire table to comma-separated-values (CSV) file.
        See Also:
        Constant Field Values
      • MID_TABLE_FILE_SAVE_TEXT

        public static final int MID_TABLE_FILE_SAVE_TEXT
        Save entire table to text file.
        See Also:
        Constant Field Values
    • Constructor Detail

      • TMenu

        public TMenu​(TApplication parent,
                     int x,
                     int y,
                     java.lang.String label)
        Public constructor.
        Parameters:
        parent - parent application
        x - column relative to parent
        y - row relative to parent
        label - mnemonic menu title. Label must contain a keyboard shortcut (mnemonic), denoted by prefixing a letter with "&", e.g. "&File"
    • Method Detail

      • onMouseDown

        public void onMouseDown​(TMouseEvent mouse)
        Handle mouse button presses.
        Overrides:
        onMouseDown in class TWindow
        Parameters:
        mouse - mouse button event
      • onMouseUp

        public void onMouseUp​(TMouseEvent mouse)
        Handle mouse button releases.
        Overrides:
        onMouseUp in class TWindow
        Parameters:
        mouse - mouse button release event
      • onMouseMotion

        public void onMouseMotion​(TMouseEvent mouse)
        Handle mouse movements.
        Overrides:
        onMouseMotion in class TWindow
        Parameters:
        mouse - mouse motion event
      • onKeypress

        public void onKeypress​(TKeypressEvent keypress)
        Handle keystrokes.
        Overrides:
        onKeypress in class TWindow
        Parameters:
        keypress - keystroke event
      • draw

        public void draw()
        Draw a top-level menu with title and menu items.
        Overrides:
        draw in class TWindow
      • setTitleX

        public void setTitleX​(int titleX)
        Set the menu title X position.
        Parameters:
        titleX - the position
      • getTitleX

        public int getTitleX()
        Get the menu title X position.
        Returns:
        the position
      • getMnemonic

        public MnemonicString getMnemonic()
        Get the mnemonic string.
        Returns:
        the full mnemonic string
      • isContext

        public boolean isContext()
        Get the context flag.
        Returns:
        true if this menu is a right-click context menu
      • setContext

        public void setContext​(boolean context,
                               int x,
                               int y)
        Set the context flag, used to open a context menu at a specific screen position.
        Parameters:
        context - if true, this is a context menu
        x - the screen X position
        y - the screen Y position
      • setContext

        public void setContext​(boolean context)
        Set the context flag.
        Parameters:
        context - if true, this is a context menu
      • addItem

        public TMenuItem addItem​(int id,
                                 java.lang.String label)
        Convenience function to add a menu item.
        Parameters:
        id - menu item ID. Must be greater than 1024.
        label - menu item label
        Returns:
        the new menu item
      • addItem

        public TMenuItem addItem​(int id,
                                 java.lang.String label,
                                 boolean enabled)
        Convenience function to add a menu item.
        Parameters:
        id - menu item ID. Must be greater than 1024.
        label - menu item label
        enabled - default state for enabled
        Returns:
        the new menu item
      • addItem

        public TMenuItem addItem​(int id,
                                 java.lang.String label,
                                 TKeypress key)
        Convenience function to add a custom menu item.
        Parameters:
        id - menu item ID. Must be greater than 1024.
        label - menu item label
        key - global keyboard accelerator
        Returns:
        the new menu item
      • addItem

        public TMenuItem addItem​(int id,
                                 java.lang.String label,
                                 TKeypress key,
                                 boolean enabled)
        Convenience function to add a custom menu item.
        Parameters:
        id - menu item ID. Must be greater than 1024.
        label - menu item label
        key - global keyboard accelerator
        enabled - default state for enabled
        Returns:
        the new menu item
      • addDefaultItem

        public TMenuItem addDefaultItem​(int id)
        Convenience function to add one of the default menu items.
        Parameters:
        id - menu item ID. Must be between 0 (inclusive) and 1023 (inclusive).
        Returns:
        the new menu item
      • addDefaultItem

        public TMenuItem addDefaultItem​(int id,
                                        boolean enabled)
        Convenience function to add one of the default menu items.
        Parameters:
        id - menu item ID. Must be between 0 (inclusive) and 1023 (inclusive).
        enabled - default state for enabled
        Returns:
        the new menu item
      • addSeparator

        public void addSeparator()
        Convenience function to add a menu separator.
      • addSubMenu

        public TSubMenu addSubMenu​(java.lang.String title)
        Convenience function to add a sub-menu.
        Parameters:
        title - menu title. Title must contain a keyboard shortcut, denoted by prefixing a letter with "&", e.g. "&File"
        Returns:
        the new sub-menu
      • resetTabOrder

        protected void resetTabOrder()
        Reset the tab order of children to match their position in the list. Available so that subclasses can re-order their widgets if needed.
        Overrides:
        resetTabOrder in class TWidget
      • setBorderStyleForeground

        public void setBorderStyleForeground​(java.lang.String borderStyle)
        Set the border style for the window when it is the foreground window.
        Overrides:
        setBorderStyleForeground in class TWindow
        Parameters:
        borderStyle - the border style string, one of: "default", "none", "single", "double", "singleVdoubleH", "singleHdoubleV", or "round"; or null to use the value from jexer.TMenu.borderStyle.
      • setBorderStyleModal

        public void setBorderStyleModal​(java.lang.String borderStyle)
        Set the border style for the window when it is the modal window.
        Overrides:
        setBorderStyleModal in class TWindow
        Parameters:
        borderStyle - the border style string, one of: "default", "none", "single", "double", "singleVdoubleH", "singleHdoubleV", or "round"; or null to use the value from jexer.TMenu.borderStyle.
      • setBorderStyleInactive

        public void setBorderStyleInactive​(java.lang.String borderStyle)
        Set the border style for the window when it is an inactive/background window.
        Overrides:
        setBorderStyleInactive in class TWindow
        Parameters:
        borderStyle - the border style string, one of: "default", "none", "single", "double", "singleVdoubleH", "singleHdoubleV", or "round"; or null to use the value from jexer.TMenu.borderStyle.
      • setBorderStyleMoving

        public void setBorderStyleMoving​(java.lang.String borderStyle)
        Set the border style for the window when it is being dragged/resize.
        Overrides:
        setBorderStyleMoving in class TWindow
        Parameters:
        borderStyle - the border style string, one of: "default", "none", "single", "double", "singleVdoubleH", "singleHdoubleV", or "round"; or null to use the value from jexer.TMenu.borderStyle.