public class TextMenu
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected int |
_height
number of rows displayed; set by constructor, used by display()
|
protected java.lang.String[] |
_items
array of items to be displayed ;set by constructor, used by select();
|
protected int |
_length
effective length of items array - number of items before null
|
protected boolean |
_quit
boolean to cause select to quit
|
protected int |
_startTime
start time for select()
|
protected java.lang.String |
_title
optional menu title displayed immediately above the list of items
|
protected int |
_topIndex
index of the list item at the top of the list; set by constructor, used by select()
|
protected int |
_topRow
location of the top row of the list; set by constructor, used by display()
|
protected static int |
BUTTON_POLL_INTERVAL
Timout used for
Button.waitForAnyPress(int) in select(int, int) . |
protected TextLCD |
lcd |
protected static char |
SEL_CHAR
identifies the currently selected item
|
Constructor and Description |
---|
TextMenu(java.lang.String[] items)
This constructor sets location of the top row of the item list to row 0 of the display.
|
TextMenu(java.lang.String[] items,
int topRow)
This constructor allows specification location of the item list .
|
TextMenu(java.lang.String[] items,
int topRow,
java.lang.String title)
This constuctor allows the specfication of a title (of up to 16 characters) and the location of the item list
The title is displayed in the row above the item list. |
Modifier and Type | Method and Description |
---|---|
protected void |
display(int selectedIndex,
int topIndex)
helper method used by select()
|
java.lang.String[] |
getItems()
Returns list of items in this menu;
|
void |
quit()
method to call from another thread to quit the menu
|
void |
resetTimeout()
Reset the timeout period.
|
int |
select()
Allows the user to scroll through the items, using the right and left buttons (forward and back) The Enter key closes the menu
and returns the index of the selected item. |
int |
select(int selectedIndex)
Version of select without timeout
|
int |
select(int selectedIndex,
int timeout)
Allows the user to scroll through the items, using the right and left buttons (forward and back) The Enter key closes the menu
and returns the index of the selected item. |
void |
setItems(java.lang.String[] items)
set the array of items to be displayed
|
void |
setTitle(java.lang.String title)
set menu title.
|
protected int _topRow
protected int _height
protected java.lang.String _title
protected java.lang.String[] _items
protected int _length
protected int _topIndex
protected static final char SEL_CHAR
protected boolean _quit
protected int _startTime
protected static final int BUTTON_POLL_INTERVAL
Button.waitForAnyPress(int)
in select(int, int)
.protected TextLCD lcd
public TextMenu(java.lang.String[] items)
public TextMenu(java.lang.String[] items, int topRow)
public TextMenu(java.lang.String[] items, int topRow, java.lang.String title)
items
- - string array containing the menu items. No items beyond the first null will be displayed.public void setTitle(java.lang.String title)
title
- the new titlepublic void setItems(java.lang.String[] items)
items
- public int select()
public int select(int selectedIndex)
public int select(int selectedIndex, int timeout)
selectedIndex
- the index to start the menu onpublic void quit()
protected void display(int selectedIndex, int topIndex)
public java.lang.String[] getItems()
public void resetTimeout()