Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.eclipse.swt.custom
Class StyledText.RTFWriter  view StyledText.RTFWriter download StyledText.RTFWriter.java

java.lang.Object
  extended byorg.eclipse.swt.custom.StyledText.TextWriter
      extended byorg.eclipse.swt.custom.StyledText.RTFWriter
Enclosing class:
StyledText

class StyledText.RTFWriter
extends StyledText.TextWriter

The RTFWriter class is used to write widget content as rich text. The implementation complies with the RTF specification version 1.5.

toString() is guaranteed to return a valid RTF string only after close() has been called.

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.


Field Summary
(package private)  java.util.Vector colorTable
           
(package private)  int DEFAULT_BACKGROUND
           
(package private)  int DEFAULT_FOREGROUND
           
(package private)  boolean WriteUnicode
           
 
Constructor Summary
StyledText.RTFWriter(int start, int length)
          Creates a RTF writer that writes content starting at offset "start" in the document.
 
Method Summary
 void close()
          Closes the RTF writer.
 int getCharCount()
          Returns the number of characters to write.
(package private)  int getColorIndex(org.eclipse.swt.graphics.Color color, int defaultIndex)
          Returns the index of the specified color in the RTF color table.
 int getStart()
          Returns the offset where writing starts.
 boolean isClosed()
          Returns whether the writer is closed.
(package private)  void setUnicode()
          Determines if Unicode RTF should be written.
 java.lang.String toString()
          Returns the string.
(package private)  void write(char i)
          Appends the given character to the data.
(package private)  void write(int i)
          Appends the given int to the data.
(package private)  void write(java.lang.String string)
          Appends the given string to the data.
(package private)  void write(java.lang.String string, int offset)
          Inserts the given string to the data at the specified offset.
(package private)  void write(java.lang.String string, int start, int end)
          Appends the specified segment of "string" to the RTF data.
(package private)  void writeHeader()
          Writes the RTF header including font table and color table.
 void writeLine(java.lang.String line, int lineOffset)
          Appends the specified line text to the RTF data.
 void writeLineDelimiter(java.lang.String lineDelimiter)
          Appends the specified line delmimiter to the RTF data.
(package private)  void writeStyledLine(java.lang.String line, int lineOffset, StyleRange[] styles, org.eclipse.swt.graphics.Color lineBackground)
          Appends the specified line text to the RTF data.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_FOREGROUND

final int DEFAULT_FOREGROUND
See Also:
Constant Field Values

DEFAULT_BACKGROUND

final int DEFAULT_BACKGROUND
See Also:
Constant Field Values

colorTable

java.util.Vector colorTable

WriteUnicode

boolean WriteUnicode
Constructor Detail

StyledText.RTFWriter

public StyledText.RTFWriter(int start,
                            int length)
Creates a RTF writer that writes content starting at offset "start" in the document. start and lengthcan be set to specify partial lines.

Method Detail

close

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

Overrides:
close in class StyledText.TextWriter

getColorIndex

int getColorIndex(org.eclipse.swt.graphics.Color color,
                  int defaultIndex)
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(java.lang.String string,
           int start,
           int end)
Appends the specified segment of "string" to the RTF data. Copy from start up to, but excluding, end.


writeHeader

void writeHeader()
Writes the RTF header including font table and color table.


writeLine

public void writeLine(java.lang.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.

Overrides:
writeLine in class StyledText.TextWriter

writeLineDelimiter

public void writeLineDelimiter(java.lang.String lineDelimiter)
Appends the specified line delmimiter to the RTF data.

Overrides:
writeLineDelimiter in class StyledText.TextWriter

writeStyledLine

void writeStyledLine(java.lang.String line,
                     int lineOffset,
                     StyleRange[] styles,
                     org.eclipse.swt.graphics.Color lineBackground)
Appends the specified line text to the RTF data. 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).


getCharCount

public int getCharCount()
Returns the number of characters to write.


getStart

public int getStart()
Returns the offset where writing starts. 0 based from the start of the widget text. Used to write partial lines.


isClosed

public boolean isClosed()
Returns whether the writer is closed.


toString

public java.lang.String toString()
Returns the string. close() must be called before toString() is guaranteed to return a valid string.


write

void write(java.lang.String string)
Appends the given string to the data.


write

void write(java.lang.String string,
           int offset)
Inserts the given string to the data at the specified offset. Do nothing if "offset" is < 0 or > getCharCount()


write

void write(int i)
Appends the given int to the data.


write

void write(char i)
Appends the given character to the data.