|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--net.rim.device.api.ui.Field
|
+--net.rim.device.api.ui.component.TextField
|
+--net.rim.device.api.ui.component.RichTextField
|
+--net.rim.device.api.ui.component.ActiveRichTextField
Field that uses a supplied set of string patterns to
scan through a simple text string and pick out "active" regions.
These active regions are highlighted with underlining and will supply additional menu verbs if the user clicks on them.
| Inner Class Summary |
| Field Summary | ||
protected long[] |
_cookieID
Array of cookie types, one for each region. |
|
protected static long |
INVALID_COOKIE_ID
Placeholder to flag invalid cookie regions. |
|
static int |
SCANFLAG_DISABLE_ALL_THREADING
Disable all threading when scanning. |
|
static int |
SCANFLAG_THREAD_ON_CREATE
Enable threads on creation. |
|
| Fields inherited from class net.rim.device.api.ui.component.RichTextField |
JUMP_FOCUS_AT_END, NO_COMPLEX_INPUT, NO_LEARNING, TEXT_ALIGN_HCENTER, TEXT_ALIGN_LEFT, TEXT_ALIGN_RIGHT, USE_TEXT_WIDTH |
| Fields inherited from class net.rim.device.api.ui.Field |
EDITABLE, EDITABLE_MASK, FIELD_BOTTOM, FIELD_HALIGN_MASK, FIELD_HCENTER, FIELD_LEFT, FIELD_RIGHT, FIELD_TOP, FIELD_VALIGN_MASK, FIELD_VCENTER, FOCUSABLE, FOCUSABLE_MASK, HIGHLIGHT_FOCUS, HIGHLIGHT_SELECT, NON_FOCUSABLE, READONLY, USE_ALL_HEIGHT, USE_ALL_WIDTH |
| Constructor Summary | ||
|
ActiveRichTextField(String text)
Creates a new ActiveRichTextField instance from provided string after scanning for active "links". |
|
|
ActiveRichTextField(String text,
int[] offsets,
byte[] attributes,
Font[] fonts,
int[] foregroundColors,
int[] backgroundColors,
long style)
Creates a new ActiveRichTextField instance from provided formatted string and style flags after scanning for active "links". |
|
|
ActiveRichTextField(String text,
long style)
Creates a new ActiveRichTextField instance from provided string and style flags after scanning for active "links". |
|
| Method Summary | ||
protected void |
drawFocus(Graphics graphics,
boolean on)
Draws the focus indicator for this field. |
|
protected int |
drawText(Graphics graphics,
String text,
int offset,
int len,
int x,
int y,
int flags,
int width)
Handles smileys, then hands off to RichTextField#drawText. |
|
protected void |
executeBackgroundScan()
Executes the string pattern scan on a background thread |
|
protected Object |
getContextMenuContext()
Retrieves the context object to be passed to net.rim.device.apps.api.ui.CookieProviderUtilities#getFocusVerbs
to fetch the context menu verbs. |
|
Object |
getCookieWithFocus()
Retrieves the cookie for the region currently with the focus. |
|
protected Manager |
getMainScreenManager()
Retrieves the current manager for the active screen. |
|
Object |
getRegionCookie()
Retrieves the cookie for the region under the current cursor position. |
|
|
Object |
getRegionCookie(int region)
Generates a cookie for the specified region. |
static int |
getScanFlags()
Retrieves flags that govern scanning functionality. |
|
String |
getText(int offset,
int length)
Retrieves text string from this field. |
|
|
protected boolean |
keyDown(int keycode,
int time)
Handles key down events. |
|
protected void |
makeContextMenu(ContextMenu contextMenu)
Builds this field's context menu. |
protected void |
paint(Graphics graphics)
Redraws this field. |
|
boolean |
regionHasCookie()
Determines if the cursor is on a cookie object. |
|
boolean |
regionHasCookie(int region)
Determine if provided region has an associated cookie. |
|
protected int |
scrollVertically(int amount)
Moves the cursor position vertically. |
|
void |
selectionCopy(Clipboard cb)
Copies the current selection to the clipboard. |
|
void |
setAttributes(int[] colorForeground,
int[] colorBackground)
Sets new colour attributes for this field. |
|
static void |
setScanFlags(int flags)
Sets flags that govern scanning functionality. |
|
void |
setText(String text)
Provides new text for this field to show. |
|
void |
setText(String text,
int[] offsets,
byte[] attributes,
Font[] fonts)
Provides new, formatted text for this field to show, with associated cookies. |
|
void |
setText(String text,
int[] offsets,
byte[] attributes,
Font[] fonts,
int[] foregroundColors,
int[] backgroundColors)
Provides new, formatted and coloured text for this field to show, with associated cookies. |
|
| Methods inherited from class net.rim.device.api.ui.component.RichTextField |
charAt, getAttributes, getBackgroundColors, getCursorPosition, getFocusRect, getFonts, getForegroundColors, getLabelLength, getOffsets, getRegion, getRegionFont, getRegionFont, getRegionText, getRegionText, getText, getTextLength, isPasteable, isSelectable, isSelecting, isSelectionCopyable, isSelectionDeleteable, keyChar, layout, moveFocus, moveFocus, onFocus, select, setCursorPosition, setCursorPosition, setFont, setText, toString |
| Methods inherited from class net.rim.device.api.ui.Field |
drawHighlightRegion, fieldChangeNotify, focusAdd, focusRemove, getChangeListener, getContextMenu, getCookie, getExtent, getExtent, getFieldStyle, getFocusListener, getFont, getHeight, getIndex, getLeafFieldWithFocus, getLeft, getManager, getOriginal, getPreferredHeight, getPreferredWidth, getScreen, getStyle, getTop, getWidth, invalidate, invalidate, isDirty, isEditable, isFocusable, isMuddy, isSelectionCutable, isStyle, isVisible, keyControl, keyRepeat, keyStatus, keyUp, onDisplay, onExposed, onMenuDismissed, onObscured, onUndisplay, onUnfocus, onVisibilityChange, paste, selectionCut, selectionDelete, setChangeListener, setCookie, setDirty, setEditable, setExtent, setFocus, setFocusListener, setMuddy, setPosition, trackwheelClick, trackwheelUnclick, updateLayout |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
public static final int SCANFLAG_DISABLE_ALL_THREADING
public static final int SCANFLAG_THREAD_ON_CREATE
protected static final long INVALID_COOKIE_ID
| Constructor Detail |
public ActiveRichTextField(String text)
text - String to scan and display.public ActiveRichTextField(String text, long style)
text - String to scan and display.style - Style flags for this field.public ActiveRichTextField(String text, int[] offsets, byte[] attributes, Font[] fonts, int[] foregroundColors, int[] backgroundColors, long style)
text - String to scan and display.offsets - List of character offsets that mark formatting changes.attributes - List that associates this field's formatting regions
with the font formats used.fonts - List of fonts formats for this field.foregroundColors - List of foreground colors for this field.backgroundColors - List of background colors for this field.style - Style flags for this field.| Method Detail |
protected void makeContextMenu(ContextMenu contextMenu)
Field.getContextMenu() invokes this method to construct this
field's context menu.
This method populates the context menu with cut, copy, and paste entries if appropriate. Inheriting classes should always invoke the parent class's version of this method, to ensure the full population of the context menu.
makeContextMenu in class FieldcontextMenu - Context menu to build.public Object getRegionCookie(int region)
getRegionCookie in class RichTextFieldregion - Region for which to generate a cookie.
protected boolean keyDown(int keycode,
int time)
Keypad.KEY_APPLICATION is pressed while the cursor is over an
active region, this method dispatches to the appropriate application key
verb for that region; otherwise, this method hands the event up to the
parent.keycode - Code of key pressed.time - Number of milliseconds since the device was turned on.protected Object getContextMenuContext()
net.rim.device.apps.api.ui.CookieProviderUtilities#getFocusVerbs
to fetch the context menu verbs.protected void executeBackgroundScan()
public static int getScanFlags()
public static void setScanFlags(int flags)
flags - New mask of scanning flags set/unset.public void setText(String text)
setText in class RichTextFieldtext - New text to show in this field; this text is re-parsed
against the original patterns array to determine whether the active
regions have changed.public void setText(String text, int[] offsets, byte[] attributes, Font[] fonts)
setText in class RichTextFieldtext - New text to show in this field; this text is re-parsed
against the original patterns array to determine whether the active
regions have changed.offsets - List of character offsets that mark formatting changes.attributes - List that associates this field's formatting regions
with the font formats used.fonts - List of fonts formats for this field.public void setText(String text, int[] offsets, byte[] attributes, Font[] fonts, int[] foregroundColors, int[] backgroundColors)
text - New text to show in this field; this text is re-parsed
against the original patterns array to determine whether the active
regions have changed.offsets - List of character offsets that mark formatting changes.attributes - List that associates this field's formatting regions
with the font formats used.fonts - List of fonts formats for this field.foregroundColors - List of foreground colors for this field.backgroundColors - List of background colors for this field.protected int scrollVertically(int amount)
This method moves the cursor position up and down lines within this field. If the cursor reaches the first line, or last line, in this field, it will not wrap around the entire field.
Just before the first vertical scroll, this method remembers the distance of the cursor from the left edge of the field (in pixels). When it scrolls, it places the cursor over the character on the new line that is as close as possible to the offset it remembers from its original position.
If there is another cookie within a line either way of the current position, this method jumps so that the current position is on top of the new cookie.
net.rim.device.api.ui.component.TextFieldamount - Amount by which to scroll (positive means down, negative
up).protected void drawFocus(Graphics graphics, boolean on)
This field's manager invokes this method after painting the field, in order to overpaint the focus indictor. By default, this method simply inverts the pixels in the focus's extent.
Note that if currently selecting more than one character in this field, then the focus region occupies the entire extent of the selected field.
This method also highlights current cookie regions as appropriate.
drawFocus in class net.rim.device.api.ui.component.TextFieldgraphics - Graphics context for drawing the focus.on - If true, focus is over an active region, and entire active text
gets highlighted and then cursor superimposed over that; otherwise focus
painting happens as normal.public void selectionCopy(Clipboard cb)
Note that this method always succeeds, even if zero characters are copied onto the clipboard. If at least one character exists in the selection to copy, then this method overwrites the clipboard's previous contents.
selectionCopy in class net.rim.device.api.ui.component.TextFieldcb - Clipboard to contain copied text.public Object getCookieWithFocus()
public Object getRegionCookie()
getRegionCookie in class RichTextFieldpublic boolean regionHasCookie()
public boolean regionHasCookie(int region)
region - Region to test.protected Manager getMainScreenManager()
Note: This generic implementation doesn't expect menus or popup screens to be active at this moment.
public void setAttributes(int[] colorForeground,
int[] colorBackground)
RichTextFieldcolorForeground - New foreground colour attributes.colorBackground - New background colour attributes.public String getText(int offset, int length)
If smileys exist in this field, this method first "decodes" them, and then returns the result.
getText in class RichTextFieldoffset - First character in field to retrieve.length - Number of characters to retrieve.protected int drawText(Graphics graphics, String text, int offset, int len, int x, int y, int flags, int width)
RichTextField#drawText.RichTextFieldprotected void paint(Graphics graphics)
This field's manager invokes this method during the repainting process to instruct this field to repaint itself.
paint in class RichTextFieldgraphics - Graphics context for repainting this field.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
Copyright 1999-2004 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.
Copyright 2002-2003 Nokia Corporation All Rights Reserved.
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.