|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
MTextPanel is implemented by Components which provide selectable editable styled text.
Implementations of MTextPanel provide a simple, standard user interface for text editing. MTextPanel supplies scrollable display, typing, arrow-key support, character selection, word- and sentence-selection (by double-clicking and triple-clicking, respectively), text styles, clipboard operations (cut, copy and paste) and a log of changes for undo-redo.
MTextPanel implementations do not provide user interface elements such as an edit menu or style menu. This support is provided in different packages, and is implemented with MTextPanel's API. MTextPanel includes methods for setting selections and styles on text, and using the clipboard and command-log functionality. MTextPanel's API for selection and text handling is similar to that of java.awt.TextArea and java.awt.TextComponent.
MTextPanel supports bidirectional and complex text. In bidirectional text, offsets at direction boundaries have dual carets. Logical selection is used, so selections across run directions may not be contiguous in display.
Field Summary | |
static java.lang.String |
COPYRIGHT
|
static java.lang.Object |
MULTIPLE_VALUES
This value is returned from getCharacterStyleOverSelection and getParagraphStyleOverSelection to indicate that the selection range contains multiple values for a key. |
Method Summary | |
void |
addListener(TextPanelListener listener)
Add the given TextPanelListener to the listeners which will receive update notifications from this MTextPanel. |
void |
append(MConstText newText)
Append the given text to the end of the document. |
boolean |
canRedo()
Return true if there is a change which can be redone. |
boolean |
canUndo()
Return true if there is a change which can be undone. |
void |
clear()
Remove selected text from the document, without altering the clipboard. |
void |
clearCommandLog()
Remove all commands from the command log. |
boolean |
clipboardNotEmpty()
Return true if the clipboard contains contents which could be transfered into the text. |
void |
copy()
Place the selected text on the clipboard. |
void |
cut()
Remove the selected text from the document and place it on the clipboard. |
java.lang.Object |
getCharacterStyleOverSelection(java.lang.Object key)
This method inspects the character style runs in the selection range (or the typing style at the insertion point). |
int |
getCommandLogSize()
Return the number of commands the command log can hold. |
AttributeMap |
getDefaultValues()
Return an AttributeMap of keys with default values. |
int |
getFormatWidth()
Return the total format width, in pixels. |
KeyRemap |
getKeyRemap()
Return the KeyRemap used to process key events. |
java.lang.Object |
getParagraphStyleOverSelection(java.lang.Object key)
This method inspects the paragraph style runs in the selection range (or the typing style at the insertion point). |
int |
getSelectionEnd()
Return the offset of the end of the selection. |
int |
getSelectionStart()
Return the offset of the start of the selection. |
MConstText |
getText()
Return the text document in the MTextPanel. |
int |
getTextLength()
Return the length of the text document in the MTextPanel. |
void |
insert(MConstText newText,
int position)
Insert the given text into the document at the given position. |
boolean |
isModified()
Return the modification flag of the current text change. |
void |
modifyCharacterStyleOnSelection(StyleModifier modifier)
Modify the character styles on the selected characters. |
void |
modifyParagraphStyleOnSelection(StyleModifier modifier)
Modify the paragraph styles in paragraphs containing selected characters, or the paragraph containing the insertion point. |
boolean |
paragraphIsLeftToRight(int offset)
Return true if the paragraph at the given offset is left-to-right. |
void |
paste()
Replace the currently selected text with the text on the clipboard. |
void |
redo()
Redo the most recent text change. |
void |
removeListener(TextPanelListener listener)
Remove the given TextPanelListener from the listeners which will receive update notifications from this MTextPanel. |
void |
replaceRange(MConstText newText,
int start,
int end)
Replace the given range with newText. |
void |
select(int selectionStart,
int selectionEnd)
Set the selection range to the given range. |
void |
selectAll()
Select all of the text in the document. |
void |
setCaretPosition(int position)
Set the selection range to an insertion point at the given offset. |
void |
setCommandLogSize(int size)
Set the number of commands the command log can hold. |
void |
setKeyRemap(KeyRemap remap)
Use the given KeyRemap to map key events to characters. |
void |
setModified(boolean modified)
Set the modification flag of the current text change. |
void |
setSelectionEnd(int selectionEnd)
Set the end of the selection range. |
void |
setSelectionStart(int selectionStart)
Set the beginning of the selection range. |
void |
setText(MConstText newText)
Set the document to newText. |
void |
undo()
Undo the most recent text change. |
Field Detail |
public static final java.lang.String COPYRIGHT
public static final java.lang.Object MULTIPLE_VALUES
There is no reason for this Object ever to appear in an AttributeMap as a value. Obviously, if it does there will be no way to distinguish between multiple values across the selection and a consistent value of MULTIPLE_VALUES for the key.
getCharacterStyleOverSelection(java.lang.Object)
,
getParagraphStyleOverSelection(java.lang.Object)
Method Detail |
public void addListener(TextPanelListener listener)
listener
- the listener to addpublic void removeListener(TextPanelListener listener)
listener
- the listener to removepublic void setText(MConstText newText)
newText
- the text which will replace the current text.public void append(MConstText newText)
newText
- the text to append to the documentpublic void insert(MConstText newText, int position)
newText
- the text to insert into the document.position
- the position in the document where the
text will be insertedpublic void replaceRange(MConstText newText, int start, int end)
newText
- the text with which to replace the rangestart
- the beginning of the range to replaceend
- the end of the range to replacepublic int getTextLength()
public MConstText getText()
public int getSelectionStart()
public int getSelectionEnd()
public void setSelectionStart(int selectionStart)
selectionStart
- the start of the new selection rangepublic void setSelectionEnd(int selectionEnd)
selectionStart
- the start of the new selection rangepublic void setCaretPosition(int position)
position
- the offset of the new insertion pointpublic void select(int selectionStart, int selectionEnd)
selectionStart
- the beginning of the selection rangeselectionEnd
- the end of the selection rangepublic void selectAll()
public int getFormatWidth()
public boolean paragraphIsLeftToRight(int offset)
offset
- an offset in the textpublic boolean canUndo()
public boolean canRedo()
public boolean clipboardNotEmpty()
public AttributeMap getDefaultValues()
public java.lang.Object getCharacterStyleOverSelection(java.lang.Object key)
key
- the key used to retrieve values for comparisonMULTIPLE_VALUES
public java.lang.Object getParagraphStyleOverSelection(java.lang.Object key)
key
- the key used to retrieve values for comparisonMULTIPLE_VALUES
public void cut()
public void copy()
public void paste()
public void clear()
public void undo()
public void redo()
public int getCommandLogSize()
public void setCommandLogSize(int size)
size
- the number of commands kept in the command logpublic void clearCommandLog()
public void modifyCharacterStyleOnSelection(StyleModifier modifier)
modifier
- the StyleModifier with which to modify the stylespublic void modifyParagraphStyleOnSelection(StyleModifier modifier)
modifier
- the StyleModifier with which to modify the stylespublic KeyRemap getKeyRemap()
setKeyRemap(com.ibm.richtext.textpanel.KeyRemap)
public void setKeyRemap(KeyRemap remap)
Do not pass null to this method to leave key events unmapped. Instead, use KeyRemap.getIdentityRemap()
remap
- the KeyRemap to use for mapping key events to charactersjava.lang.NullPointerException
- if parameter is nullKeyRemap
public boolean isModified()
setModified(boolean)
public void setModified(boolean modified)
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |