|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.rim.device.api.ui.Field
net.rim.device.api.ui.ScrollView
net.rim.device.api.ui.Manager
net.rim.device.api.ui.toolbar.ToolbarManager
public class ToolbarManager
Represents a horizontal manager to provide quick access to commonly performed actions.
The actions are defined by ToolbarButtonField
.
A ToolbarManager
can accept two types of fields:
ToolbarButtonField
, an atomic field that calls an ToolbarButtonField.invoke()
method to execute an action.ToolbarSetManager
, a group of ToolbarButtonField
objects.Fields in the toolbar are sorted based on their ordinals. Toolbar fields are sorted by their ordinals from low-to-high, left-to-right. Two or more fields can have the same ordinal, in which case the field that is added first is given higher priority. For example:
// initialize toolbar
...
toolbar.add( new MyToolbarButtonField( getImage("Foo"), 2 ) );
toolbar.add( new MyToolbarButtonField( getImage("Bar"), 3 ) );
toolbar.add( new MyToolbarButtonField( getImage("Cat"), 2 ) );
...
The toolbar will sort the buttons as: Foo, Cat, Bar.
This manager implements a valid return value for getPreferredHeight
and, during layout, will use
the minimum of the height provided and the value returned by getPreferredHeight. This manager also consumes all the width
it is provided during layout, and lays out its controlled fields by providing each an equal share of the provided
width.
Field Summary |
---|
Fields inherited from class net.rim.device.api.ui.Manager |
---|
BOTTOMMOST, DOWNWARD, HORIZONTAL_SCROLL, HORIZONTAL_SCROLLBAR, HORIZONTAL_SCROLLBAR_MASK, HORIZONTAL_SCROLL_MASK, LEAVE_BLANK_SPACE, LEFTMOST, LEFTWARD, NO_HORIZONTAL_SCROLL, NO_HORIZONTAL_SCROLLBAR, NO_SCROLL_RESET, NO_VERTICAL_SCROLL, NO_VERTICAL_SCROLLBAR, QUANTA_FONT, RIGHTMOST, RIGHTWARD, TOPMOST, UPWARD, VERTICAL_SCROLL, VERTICAL_SCROLLBAR, VERTICAL_SCROLLBAR_MASK, VERTICAL_SCROLL_MASK |
Constructor Summary | ||
---|---|---|
ToolbarManager()
Creates a ToolbarManager . |
||
ToolbarManager(long style)
Creates a code>ToolbarManager with the specified style. |
||
ToolbarManager(Field field)
Creates a toolbar with specified field. |
Method Summary | ||
---|---|---|
void |
add(Field field)
Adds a field to this manager based on the ordinal of the field. |
|
void |
addAll(Field[] fields)
Adds mutiple fields to the ToolbarManager by calling add(field) on each object in the specified array. |
|
void |
delete(Field field)
Deletes the specified field from this Manager. |
|
void |
deleteRange(int start,
int count)
Deletes each field in the given range. |
|
int |
getPreferredHeight()
Retrieves the preferred height of this ToolbarManager . |
|
int |
getPreferredWidth()
Retrieves the preferred width of this ToolbarManager . |
|
void |
insert(Field field,
int index)
This method is not supported by ToolbarManager . |
|
void |
insertAll(Field[] fields,
int index)
This method is not supported by ToolbarManager . |
|
static boolean |
isToolbarSupported()
Determines whether toolbar is supported on this device. |
|
void |
replace(Field oldField,
Field newField)
Replaces an existing field with a new field. |
|
void |
setVisible(boolean visible)
Sets the visibility of the toolbar. |
|
protected void |
sublayout(int width,
int height)
If the VirtualKeyBoard is visible, the toolbar is not laid out. |
|
protected boolean |
touchEvent(TouchEvent message)
Indicates a touch event. |
Methods inherited from class net.rim.device.api.ui.ScrollView |
---|
configurationChanged, getHorizontalAdjustment, getVerticalAdjustment, getVisibleHeight, getVisibleWidth, onDisplay, onUndisplay, setCurrentLocation, setExtent, setHorizontalAdjustment, setHorizontalScroll, setHorizontalScroll, setScrollListener, setVerticalAdjustment, setVerticalScroll, setVerticalScroll, valueChanged, waitForScrolling |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ToolbarManager()
ToolbarManager
.
public ToolbarManager(long style)
public ToolbarManager(Field field)
Creates a toolbar with specified field.
Equivalent to:
ToolbarManager toolbar = new ToolbarManager(); toolbar.add( field ); ...
field
- A field to add that is an instance of ToolbarButtonField
or ToolbarSetManager
Method Detail |
---|
public void add(Field field)
add
in class Manager
field
- A field of type ToolbarButtonField
or ToolbarSetManager
to add that is an instance .
IllegalArgumentException
- If field
is not an instance of ToolbarButtonField
or
ToolbarSetManager
.public void addAll(Field[] fields)
ToolbarManager
by calling add(field) on each object in the specified array.
addAll
in class Manager
fields
- Array of Field
objects to insert.
IllegalArgumentException
- If fields
is not an instance of ToolbarButtonField
or
ToolbarSetManager
.public void delete(Field field)
delete
in class Manager
field
- Field to delete from this manager.
IllegalArgumentException
- If field
is not an instance of ToolbarButtonField
or
ToolbarSetManager
.public void deleteRange(int start, int count)
deleteRange
in class Manager
start
- Field The index to begin deletion at.count
- The number of fields to delete.public void replace(Field oldField, Field newField)
replace
in class Manager
oldField
- A Field
to be replaced that is an instance of ToolbarButtonField
or ToolbarSetManager
.newField
- The Field
to replace oldField that is an instance of ToolbarButtonField
or ToolbarSetManager
.
IllegalArgumentException
- If oldField
or newField
is not an instance of ToolbarButtonField
or
ToolbarSetManager
IllegalArgumentException
- if oldField
ordinal does not match newField
ordinal.Manager.delete(Field)
,
Manager.insert(Field, int)
,
Field.getIndex()
,
Field.getManager()
,
Field.setFocus()
public int getPreferredWidth()
ToolbarManager
.
getPreferredWidth
in class Field
ToolbarManager
.public int getPreferredHeight()
ToolbarManager
.
getPreferredHeight
in class Field
ToolbarManager
.public void insert(Field field, int index)
ToolbarManager
. Please use ToolbarManager.add(net.rim.device.api.ui.Field)
to insert fields.
insert
in class Manager
field
- Field to insert.index
- Index to insert field at.
UnsupportedOperationException
- If this method is used.public void insertAll(Field[] fields, int index)
ToolbarManager
. Please use ToolbarManager.addAll(net.rim.device.api.ui.Field[])
to insert fields.
insertAll
in class Manager
field
- Fields to insert.index
- Index at which to begin inserting.
UnsupportedOperationException
- If this method is used.public static boolean isToolbarSupported()
true
if toolbar is supported; false
otherwise.public void setVisible(boolean visible)
If the toolbar was set specificially via setToolbar in MainScreen, the toolbar is not shown if the VirtualKeyboard is visible.
visible
- true
if the toolbar should be displayed; false
otherwise.MainScreen
protected void sublayout(int width, int height)
Typically, layout is done in such a manner that each controlled ToolbarButtonField
is provided enough width such that they all will have the same width. This is accomplished
by taking the total width available during layout, and dividing it by the number of
concrete ToolbarButtonField
object's controlled by this Manager (including those added to any
ToolbarSetManager
added to this Manager).
There are two situations where this is not true. The first is if any controlled Field
has the style USE_ALL_WIDTH
. In this case, that Field receives all the remaining width
during layout.
The second case is if a contained ToolbarButtonField
overrides getPreferredWidth
to return a non-zero value.
In this case, that Field will receive the minimum of the available width and the returned preferred width.
This Manager does not scroll, so it is possible for greedy Field objects to consume all the available width before all Field objects have had a chance to layout. In this case they are simply skipped.
This Manager will consume the minimum of the height and the return value of getPreferredHeight
.
sublayout
in class Manager
width
- Width available for this manager.height
- Height available for this manager.protected boolean touchEvent(TouchEvent message)
touchEvent
in class Manager
message
- TouchEvent
object containing various input parameters
including the event type and touch coordinates.
true
if this method consumed the event; otherwise, false
.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright 1999-2010 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Copyright 1993-2003 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. All Rights Reserved.
Copyright 2002-2003 Nokia Corporation All Rights Reserved.
Java is a trademark of Sun Microsystems, Inc.