net.rim.device.api.ui.component
Class ActiveRichTextField.RegionQueue

java.lang.Object
  |
  +--net.rim.device.api.ui.component.ActiveRichTextField.RegionQueue
Enclosing class:
ActiveRichTextField

protected static class ActiveRichTextField.RegionQueue
extends Object

Collects the arrays of regions and fonts common to rich-text fields.

Since:
JDE 4.0.0

Field Summary
 byte[] attributes
          Text attributes for regions.
 int[] backgroundColors
          Background colours for regions.
 long[] cookieID
          Cookie IDs for regions.
 Font[] fonts
          Text font faces for regions.
 int[] foregroundColors
          Foreground colours for regions.
 int[] offsets
          Text positioning offests.
 
Constructor Summary
ActiveRichTextField.RegionQueue(int initMaxRegions, int initMaxFonts)
          Creates a new RegionQueue instance for the specified string.
 
Method Summary
 byte appendFont(Font font)
          Adds a new font into the master table.
 byte appendFont(Font font, int foregroundColor, int backgroundColor)
          Adds a new font into the master table.
 boolean appendRegion(int offset, byte attribute, long id)
          Appends a region into the table set.
protected  void resizeBuffers(int newCapacity)
          Resizes all buffers to accomodate a new maximum size.
 void trim()
          Trims arrays in preparation for passing to a rich-text field
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

offsets

public int[] offsets
Text positioning offests.
Since:
JDE 4.0.0

attributes

public byte[] attributes
Text attributes for regions.
Since:
JDE 4.0.0

fonts

public Font[] fonts
Text font faces for regions.
Since:
JDE 4.0.0

cookieID

public long[] cookieID
Cookie IDs for regions.
Since:
JDE 4.0.0

foregroundColors

public int[] foregroundColors
Foreground colours for regions.
Since:
JDE 4.0.0

backgroundColors

public int[] backgroundColors
Background colours for regions.
Since:
JDE 4.0.0
Constructor Detail

ActiveRichTextField.RegionQueue

public ActiveRichTextField.RegionQueue(int initMaxRegions,
                                       int initMaxFonts)
Creates a new RegionQueue instance for the specified string.
Parameters:
initMaxRegions - Initial size of region array
initMaxFonts - Initial size of font array
Since:
JDE 4.0.0
Method Detail

trim

public final void trim()
Trims arrays in preparation for passing to a rich-text field
Since:
JDE 4.0.0

appendFont

public final byte appendFont(Font font)
Adds a new font into the master table.
Parameters:
font - Font to add; if null, add the system default font.
Returns:
Attribute ID for this font.
Since:
JDE 4.0.0

appendFont

public final byte appendFont(Font font,
                             int foregroundColor,
                             int backgroundColor)
Adds a new font into the master table.
Parameters:
font - Font add; if null, add the system default font.
foregroundColor - Color to use when drawing the foreground.
backgroundColor - Color to use when drawing the background.
Returns:
Attribute ID for this font.
Since:
JDE 4.0.0

resizeBuffers

protected void resizeBuffers(int newCapacity)
Resizes all buffers to accomodate a new maximum size.

This method is used to expand the buffers beyond current maximum, and also to trim the buffers down to the exact size utilized.

Subclasses that override this method must not set _maxregions.

Parameters:
newCapacity - New total number of regions allocated.
Since:
JDE 4.0.0

appendRegion

public boolean appendRegion(int offset,
                            byte attribute,
                            long id)
Appends a region into the table set.

If the offset parameter is not strictly greater than the previous region offset then the method call will have no effect.

Subclasses that overload this method must call this method first so that any region resizing can be achieved. On return from this method, the number of regions has been updated, so the calling methods must set their table information at an index equal to one less than the number of regions.

Parameters:
offset - The non-inclusive character offset marking the end of this region.
attribute - The font ID returned by appendFont(net.rim.device.api.ui.Font).
id - Optional cookie object associated with this region.
Returns:
True if the region was appended successfully; otherwise, false.
Since:
JDE 4.0.0


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.