StyledText.RTFWriter

The <code>RTFWriter</code> class is used to write widget content as rich text. The implementation complies with the RTF specification version 1.5. <p> toString() is guaranteed to return a valid RTF string only after close() has been called. </p><p> Whole and partial lines and line breaks can be written. Lines will be formatted using the styles queried from the LineStyleListener, if set, or those set directly in the widget. All styles are applied to the RTF stream like they are rendered by the widget. In addition, the widget font name and size is used for the whole text. </p>

Constructors

this
this(int start, int length)

Creates a RTF writer that writes content starting at offset "start" in the document. <code>start</code> and <code>length</code>can be set to specify partial lines.

Members

Functions

close
void close()

Closes the RTF writer. Once closed no more content can be written. <b>NOTE:</b> <code>toString()</code> does not return a valid RTF string until <code>close()</code> has been called.

getColorIndex
int getColorIndex(Color color, int defaultIndex)

Returns the index of the specified color in the RTF color table.

getFontIndex
int getFontIndex(Font font)

Returns the index of the specified color in the RTF color table.

setUnicode
void setUnicode()

Determines if Unicode RTF should be written. Don't write Unicode RTF on Windows 95/98/ME or NT.

write
void write(String string, int start, int end)

Appends the specified segment of "string" to the RTF data. Copy from <code>start</code> up to, but excluding, <code>end</code>.

writeHeader
void writeHeader()

Writes the RTF header including font table and color table.

writeLine
void writeLine(String line, int lineOffset)

Appends the specified line text to the RTF data. Lines will be formatted using the styles queried from the LineStyleListener, if set, or those set directly in the widget.

writeLineDelimiter
void writeLineDelimiter(String lineDelimiter)

Appends the specified line delimiter to the RTF data.

writeStyledLine
void writeStyledLine(String line, int lineOffset, int[] ranges, StyleRange[] styles, Color lineBackground, int indent, int alignment, bool justify)

Appends the specified line text to the RTF data. <p> Use the colors and font styles specified in "styles" and "lineBackground". Formatting is written to reflect the text rendering by the text widget. Style background colors take precedence over the line background color. Background colors are written using the \highlight tag (vs. the \cb tag). </p>

Inherited Members

From TextWriter

close
void close()

Closes the writer. Once closed no more content can be written. <b>NOTE:</b> <code>toString()</code> is not guaranteed to return a valid string unless the writer is closed.

getCharCount
int getCharCount()

Returns the number of characters to write. @return the integer number of characters to write

getStart
int getStart()

Returns the offset where writing starts. 0 based from the start of the widget text. Used to write partial lines. @return the integer offset where writing starts

isClosed
bool isClosed()

Returns whether the writer is closed. @return a bool specifying whether or not the writer is closed

toString
String toString()

Returns the string. <code>close()</code> must be called before <code>toString()</code> is guaranteed to return a valid string.

write
void write(String string)

Appends the given string to the data.

write
void write(String string, int offset)

Inserts the given string to the data at the specified offset. <p> Do nothing if "offset" is < 0 or > getCharCount() </p>

write
void write(int i)

Appends the given int to the data.

write
void write(char i)

Appends the given character to the data.

writeLine
void writeLine(String line, int lineOffset)

Appends the specified line text to the data.

writeLineDelimiter
void writeLineDelimiter(String lineDelimiter)

Appends the specified line delimiter to the data.

Meta