|
Eclipse Platform Release 3.0 | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.swt.widgets.Widget
org.eclipse.swt.widgets.Control
org.eclipse.swt.widgets.Scrollable
org.eclipse.swt.widgets.Composite
org.eclipse.swt.widgets.Canvas
org.eclipse.ui.forms.widgets.FormText
This class is a read-only text control that is capable of rendering wrapped text. Text can be rendered as-is or by parsing the formatting XML tags. Independently, words that start with http:// can be converted into hyperlinks on the fly.
When configured to use formatting XML, the control requires the root element form to be used. The following tags can be children of the form element:
Text in paragraphs and list items will be wrapped according to the width of the control. The following tags can appear as children of either p or li elements:
None of the elements can nest. For example, you cannot have b inside a span . This was done to keep everything simple and transparent.
Care should be taken when using this control. Form text is not an HTML browser and should not be treated as such. If you need complex formatting capabilities, use Browser widget. If you need editing capabilities and font/color styles of text segments is all you need, use StyleText widget. Finally, if all you need is to wrap text, use SWT Label widget and create it with SWT.WRAP style.
You should be careful not to ask the control to render large quantities of text. It does not have advanced support for dirty regions and will repaint fully each time. Instead, combine the control in a composite with other controls and let SWT take care of the dirty regions.
Although the class is not marked final,
Field Summary | |
int | marginHeight
Value of hte horizontal margin (default is 1). |
int | marginWidth
Value of the horizontal margin (default is 0). |
static String | URL_HANDLER_ID
The object ID to be used when registering action to handle URL hyperlinks (those that should result in opening the web browser). |
Fields inherited from class org.eclipse.swt.widgets.Control |
handle |
Constructor Summary | |
FormText(Composite parent,
int style)
Contructs a new form text widget in the provided parent and using the styles. |
Method Summary | |
void | addHyperlinkListener(IHyperlinkListener listener)
Adds a listener that will handle hyperlink events. |
Point | computeSize(int wHint,
int hHint,
boolean changed)
Overrides the method by fully trusting the layout manager (computed width or height may be larger than the provider width or height hints). |
protected void | contextMenuAboutToShow(IMenuManager manager)
Context menu is about to show - override to add actions to the menu manager. |
boolean | getFocus()
Test for focus. |
HyperlinkSettings | getHyperlinkSettings()
Returns the hyperlink settings that are in effect for this control. |
String | getLoadingText()
Returns the text that will be shown in the control while the real content is loading. |
boolean | getParagraphsSeparated()
Tests if there is some inter-paragraph spacing. |
boolean | isLoading()
Test if the widget is currently processing the text it is about to render. |
boolean | isWhitespaceNormalized()
Tests whether whitespace inside paragraph and list item is normalized. |
void | removeHyperlinkListener(IHyperlinkListener listener)
Removes the hyperlink listener. |
void | setColor(String key,
Color color)
Registers the color referenced by the provided key. |
void | setContents(InputStream is,
boolean expandURLs)
Sets the contents of the stream. |
boolean | setFocus()
Sets the focus to the first hyperlink, or the widget itself if there are no hyperlinks. |
void | setFont(Font font)
Sets the font to use to render the default text (text that does not have special font property assigned). |
void | setFont(String key,
Font font)
Registers the font referenced by the provided key. |
void | setHyperlinkSettings(HyperlinkSettings settings)
Sets the hyperlink settings to be used for this control. |
void | setImage(String key,
Image image)
Registers the image referenced by the provided key. |
void | setLoadingText(String loadingText)
Sets the text that will be shown in the control while the real content is loading. |
void | setParagraphsSeparated(boolean value)
If paragraphs are separated, spacing will be added between them. |
void | setText(String text,
boolean parseTags,
boolean expandURLs)
Sets the provided text. |
void | setWhitespaceNormalized(boolean value)
Controls whether whitespace inside paragraph and list items is normalized. |
Methods inherited from class org.eclipse.swt.widgets.Canvas |
getCaret, scroll, setCaret |
Methods inherited from class org.eclipse.swt.widgets.Composite |
checkSubclass, getChildren, getLayout, getTabList, layout, layout, setLayout, setTabList |
Methods inherited from class org.eclipse.swt.widgets.Scrollable |
computeTrim, getClientArea, getHorizontalBar, getVerticalBar |
Methods inherited from class org.eclipse.swt.widgets.Widget |
addDisposeListener, addListener, checkWidget, dispose, getData, getData, getDisplay, getStyle, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, setData, setData, toString |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final String URL_HANDLER_ID
public int marginWidth
public int marginHeight
Constructor Detail |
public FormText(Composite parent, int style)
Method Detail |
public boolean getFocus()
public boolean isLoading()
public String getLoadingText()
public void setLoadingText(String loadingText)
public void setParagraphsSeparated(boolean value)
public boolean getParagraphsSeparated()
public void setImage(String key, Image image)
For img tags, an object of a type Image must be registered using the key equivalent to the value of the href attribute used in the tag.
public void setColor(String key, Color color)
For span tags, an object of a type Color must be registered using the key equivalent to the value of the color attribute.
public void setFont(String key, Font font)
For span tags, an object of a type Font must be registered using the key equivalent to the value of the font attribute.
public void setFont(Font font)
public void setText(String text, boolean parseTags, boolean expandURLs)
public void setContents(InputStream is, boolean expandURLs)
public void setWhitespaceNormalized(boolean value)
If normalized:
public boolean isWhitespaceNormalized()
public boolean setFocus()
public HyperlinkSettings getHyperlinkSettings()
public void setHyperlinkSettings(HyperlinkSettings settings)
public void addHyperlinkListener(IHyperlinkListener listener)
public void removeHyperlinkListener(IHyperlinkListener listener)
protected void contextMenuAboutToShow(IMenuManager manager)
public Point computeSize(int wHint, int hHint, boolean changed)
|
Eclipse Platform Release 3.0 | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Guidelines for using Eclipse APIs.
Copyright (c) IBM Corp. and others 2000, 2004. All rights reserved.