|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectdanger.app.Listener
danger.ui.View
danger.ui.Container
danger.ui.FolderView
public class FolderView
This class is a UI object that manages and draws a one-deep list of folders and their contents.
Folders can be referenced by their numerical index or name (case-insensitive). As such, there can be only one folder with a given name.
This handles all expected HI. The arrow keys and the wheel can be used to navigate up and down through the list. The return key and the wheel button can be used to open and close folders.
If you want customized drawing to take place you will need to
subclass and override drawFolderLine(danger.ui.Pen, java.lang.Object, danger.ui.Rect, boolean) and drawItemLine(danger.ui.Pen, java.lang.Object, danger.ui.Rect, boolean).
If you want this object to actually do something when a folder item is selected
and the wheel button or return key is hit then you will need to subclass
and override eventKeyDown(char, danger.app.Event) and eventWidgetDown(int, danger.app.Event).
If you want to have something happen when the selection switches
between a folder and one of its items (for instance, changing the
contents of the action menu), then again, you'll need to override eventWidgetUp(int, danger.app.Event) and eventWidgetDown(int, danger.app.Event).
NOTE: You will note that several of the methods in here are
public even though it seems like they shouldn't be. This is
so that classes in other packages which subclass from FolderView can
override these methods. XXX--why aren't these declared
protected?
| Field Summary | |
|---|---|
static int |
COLUMN_GAP
Deprecated. For internal use only. |
int |
mAscent
Deprecated. For internal use only. |
protected int |
mCurrentFolder
Deprecated. For internal use only. |
protected int |
mCurrentItem
Deprecated. Use getSelection() instead. |
protected Vector |
mFolders
Deprecated. Use setFolders(java.util.Vector) and addFolder(danger.util.Folder) instead. |
Font |
mFontBold
Deprecated. For internal use only. |
Font |
mFontPlain
Deprecated. For internal use only. |
protected boolean |
mHasBorder
Deprecated. Use setHasBorder(boolean) and getHasBorder() instead. |
protected int |
mLineHeight
Deprecated. For internal use only. |
protected int |
mNumDisplayLines
Deprecated. For internal use only. |
| Constructor Summary | |
|---|---|
FolderView()
|
|
FolderView(int inLeft,
int inTop,
int inRight,
int inBottom)
|
|
FolderView(Rect inSize)
|
|
| Method Summary | |
|---|---|
Folder |
addFolder(Folder inFolder)
Add a folder. |
protected void |
adjustActionMenuState()
|
void |
adjustSelection()
|
protected boolean |
advanceHilite(int delta)
|
Folder |
createFolder(String inFolderName)
|
void |
drawBackground(Pen p,
Rect r)
|
void |
drawBackground(Pen p,
Rect r,
boolean more_above,
boolean more_below)
|
protected void |
drawEmptyList(Pen p)
|
protected void |
drawFolderLine(Pen p,
Object inEntry,
Rect r,
boolean inSelected)
|
protected void |
drawFolderLine(Pen p,
Object inEntry,
Rect r,
boolean inSelected,
Object above,
Object below)
|
protected void |
drawItemLine(Pen p,
Object inEntry,
Rect r,
boolean inSelected)
|
protected void |
drawItemLine(Pen p,
Object inEntry,
Rect r,
boolean inSelected,
Object above,
Object below)
|
boolean |
eventKeyDown(char inChar,
Event event)
This method is called when the user presses a key. |
boolean |
eventKeyRepeat(char inChar,
Event event)
This method is called when the user holds a key long enough for it to repeat. |
boolean |
eventKeyUp(char inChar,
Event event)
Standard UI method to handle the RETURN and DEL keys. |
boolean |
eventShortcut(char c,
Event e)
Handle a shortcut key. |
boolean |
eventWidgetDown(int inWhichWidget,
Event event)
Handle the pressing of a device widget |
boolean |
eventWidgetUp(int inWhichWidget,
Event event)
Handle the release of a device widget |
int |
folderCount()
|
int |
getContentWidth()
|
int |
getCurrentFolderIndex()
|
int |
getCurrentItemIndex()
|
protected int |
getEntryNumOfItem(int inFolderNum,
int inItemNum)
|
Folder |
getFolder(int inFolderNum)
|
Folder |
getFolder(String inFolderName)
|
int |
getFolderIndex(Folder inFolder)
|
int |
getFolderIndex(String inFolderName)
|
Vector |
getFolders()
|
boolean |
getHasBorder()
|
boolean |
getHasScrollbar()
|
CharSequence |
getItemTitle(Object item)
Get the title of the given item. |
Object |
getSelection()
|
CharSequence |
getToolTip(int inFolderIndex,
int inItemIndex)
|
protected int |
getVisibleItemCount()
|
protected void |
invalidateEntry(int inFolderNum,
int inItemNum)
|
void |
loseFocus()
This method is called when this view loses its previous status as the focused child of a container. |
protected int |
matchFolderItemPrefix(String inPrefix,
int currItem)
|
void |
onSelectionChanged()
|
void |
paint(Pen p)
Draw the contents of this View. |
protected void |
recalcMetrics()
|
protected void |
recordSelection()
|
void |
removeAll()
|
void |
removeAllFolderItems(String inFolderName)
|
Folder |
removeFolder(int inFolderNum)
|
Folder |
removeFolder(String inFolderName)
|
Object |
removeFolderItem(int inFolder,
int inItem)
|
Object |
removeFolderItem(String inFolderName,
int inItem)
|
Object |
removeFolderItem(String inFolderName,
Object inItem)
|
void |
renameFolder(String inOldName,
String inNewName)
|
protected void |
restoreSelection()
|
protected boolean |
reverseHilite(int delta)
|
protected void |
selectItem(Object inItem)
|
void |
setFolders(Vector folders)
Use the specified Vector of Folder objects. |
void |
setHasBorder(boolean inHasBorder)
|
void |
setHasScrollbar(boolean inHasScrollbar)
|
void |
setMaxToolTipLines(int maxLines)
Set the maximum number of lines to show in a tool tip. |
void |
setSelection(int inFolderNum,
int inItemNum)
|
void |
setSize(int inWidth,
int inHeight)
Simultaneously set the width and height of this View. |
void |
showToolTip()
This method should be implemented to actually display the tool tip, probably via a call to ToolTipWindow.showToolTip(danger.ui.MenuItem, int, int, int, danger.ui.Window). |
void |
sortAllFolderItems(Comparator inComparator)
|
void |
sortFolders(Comparator inComparator)
|
void |
takeFocus(boolean inFromAbove)
Focus this container. |
protected void |
toggleFolder(Folder inFolder)
|
| Methods inherited from class danger.app.Listener |
|---|
cancelEvents, childEventPump, childEventPumpDone, eventProblem, isDispatchingThread, sendEvent, sendEvent, sendEvent, sendEvent, sendEvent, sendLowPriorityEvent |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected Vector mFolders
setFolders(java.util.Vector) and addFolder(danger.util.Folder) instead.protected int mLineHeight
protected int mNumDisplayLines
protected boolean mHasBorder
setHasBorder(boolean) and getHasBorder() instead.public Font mFontPlain
public Font mFontBold
public int mAscent
protected int mCurrentFolder
protected int mCurrentItem
getSelection() instead.public static final int COLUMN_GAP
| Constructor Detail |
|---|
public FolderView()
public FolderView(Rect inSize)
public FolderView(int inLeft,
int inTop,
int inRight,
int inBottom)
| Method Detail |
|---|
public Folder createFolder(String inFolderName)
public Folder addFolder(Folder inFolder)
Add a folder.
This checks to see if you are adding a duplicate folder (one with
the same name). If so, this method does nothing. This check has
the downside of degrading performance. If you are adding many folders
at once, you may want to use the more efficient setFolders(java.util.Vector)
method instead.
public void removeAll()
public Folder removeFolder(String inFolderName)
public Folder removeFolder(int inFolderNum)
public Object removeFolderItem(int inFolder,
int inItem)
public Object removeFolderItem(String inFolderName,
Object inItem)
public Object removeFolderItem(String inFolderName,
int inItem)
public void removeAllFolderItems(String inFolderName)
public void sortFolders(Comparator inComparator)
public void sortAllFolderItems(Comparator inComparator)
public int folderCount()
public Folder getFolder(String inFolderName)
public Folder getFolder(int inFolderNum)
public int getFolderIndex(Folder inFolder)
public int getFolderIndex(String inFolderName)
public void setFolders(Vector folders)
Use the specified Vector of Folder objects.
This is more efficient than making many calls to addFolder(danger.util.Folder),
since {#link #addFolder} checks to see if you are adding a duplicate
folder.
public Vector getFolders()
public Object getSelection()
public void setSize(int inWidth,
int inHeight)
View
setSize in class Viewprotected void recalcMetrics()
public void setHasScrollbar(boolean inHasScrollbar)
public boolean getHasScrollbar()
public int getContentWidth()
public void paint(Pen p)
ViewThe implementation of this method in this class will merely call
clear() pen, if this View is opaque (not transparent),
and will do nothing otherwise. If you don't need this behavior, then
there is no point in calling super.paint() in an
overriding method.
paint in class Containerp - non-null; the pen to use for drawing operations
protected void drawFolderLine(Pen p,
Object inEntry,
Rect r,
boolean inSelected)
protected void drawFolderLine(Pen p,
Object inEntry,
Rect r,
boolean inSelected,
Object above,
Object below)
protected void drawItemLine(Pen p,
Object inEntry,
Rect r,
boolean inSelected)
protected void drawItemLine(Pen p,
Object inEntry,
Rect r,
boolean inSelected,
Object above,
Object below)
protected void drawEmptyList(Pen p)
public CharSequence getItemTitle(Object item)
drawItemLine(danger.ui.Pen, java.lang.Object, danger.ui.Rect, boolean) and
matchFolderItemPrefix(java.lang.String, int).
This default implementation returns the result of calling
toString on the object.
Override this method if necessary to provide information
used for prefix matching
in open folders.
item - the item to get the title of
protected void toggleFolder(Folder inFolder)
protected void selectItem(Object inItem)
public boolean eventWidgetDown(int inWhichWidget,
Event event)
Container
eventWidgetDown in class ContainerinWhichWidget - the widget that went up
public boolean eventWidgetUp(int inWhichWidget,
Event event)
Container
eventWidgetUp in class ContainerinWhichWidget - the widget that went down
public boolean eventShortcut(char c,
Event e)
ViewScreenWindow, DialogWindow,
BaseMenuWindow.
eventShortcut in class Containerc - the key that was pressede - the event associated with the key press
true if the shortcut was handled
public boolean eventKeyRepeat(char inChar,
Event event)
ViewView.setAtAndSpacePage(boolean).
eventKeyRepeat in class Container
public boolean eventKeyDown(char inChar,
Event event)
ViewView.setAtAndSpacePage(boolean).
eventKeyDown in class Container
public boolean eventKeyUp(char inChar,
Event event)
removeFolderItem(int, int)
on the currently-selected item, which in practice
no application really seems to want. If you do not
want the user to remove items from the folder directly,
you *must* override this method to catch DEL keyreleases.
eventKeyUp in class ContainerinChar - the character being released.
protected int matchFolderItemPrefix(String inPrefix,
int currItem)
protected boolean advanceHilite(int delta)
protected boolean reverseHilite(int delta)
public void onSelectionChanged()
public void setSelection(int inFolderNum,
int inItemNum)
public void takeFocus(boolean inFromAbove)
Container
takeFocus in class ContainerinFromAbove - whether the focus was entered into this view from abovepublic void loseFocus()
ViewThis method is called when this view loses its previous status as the focused child of a container.
You generally wouldn't call this method yourself, but instead would override it if you wanted to know when the view is losing focus.
If you don't want this view to have focus anymore, you should
use Container.setFocusedChild(View) or
Container.setFocusedDescendant(View).
loseFocus in class Container
protected void invalidateEntry(int inFolderNum,
int inItemNum)
public void adjustSelection()
protected int getEntryNumOfItem(int inFolderNum,
int inItemNum)
protected void adjustActionMenuState()
public void drawBackground(Pen p,
Rect r)
public void drawBackground(Pen p,
Rect r,
boolean more_above,
boolean more_below)
public void setHasBorder(boolean inHasBorder)
public boolean getHasBorder()
public int getCurrentFolderIndex()
public int getCurrentItemIndex()
public void renameFolder(String inOldName,
String inNewName)
protected final void recordSelection()
protected final void restoreSelection()
protected final int getVisibleItemCount()
public void showToolTip()
ToolTipOwnerToolTipWindow.showToolTip(danger.ui.MenuItem, int, int, int, danger.ui.Window).
showToolTip in interface ToolTipOwnerpublic void setMaxToolTipLines(int maxLines)
public CharSequence getToolTip(int inFolderIndex,
int inItemIndex)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||