Class TextArea
java.lang.Object
|
+--waba.ui.Control
|
+--AdvControl
|
+--TextArea
- Direct Known Subclasses:
- ScrollableTextArea
- public class TextArea
- extends AdvControl
TextArea by Michael L Brereton, November 1999.
This code may be freely used, modified and redistributed, as long
as credit is given to the original author in any such modification
or distribution.
Fields inherited from class AdvControl |
AlwaysEnabled,
CapturesPen,
DidHoldDown,
Disabled,
dragResolution,
font,
GotPenDown,
Invisible,
modifiers,
name,
NoFocus,
NotAnEditor,
NotEditable,
PreferredSizeOnly,
startDragResolution,
text,
WantDrag,
WantHoldDown |
Fields inherited from class waba.ui.Control |
height,
next,
parent,
prev,
width,
x,
y |
Method Summary |
protected void |
checkScrolls()
|
protected void |
clearCursor()
|
void |
clearSelection()
|
boolean |
deleteSelection()
Delete the current selection. |
void |
doPaint(waba.fx.Graphics g,
waba.fx.Rect area)
|
void |
doPaintData(waba.fx.Graphics g)
|
void |
doPaintData(waba.fx.Graphics g,
waba.fx.Rect area)
|
void |
doScroll(int which,
int action,
int value)
This scrolls the display. |
void |
dragged(DragContext dc)
|
protected boolean |
fix()
|
protected void |
fixText()
|
protected boolean |
getCharRect(int ch,
int ln,
waba.fx.Rect dest)
|
protected int |
getItemHeight()
|
protected java.lang.String |
getLine()
|
protected java.lang.String |
getLine(int index)
|
int |
getNumLines()
|
protected Point |
getPenChar(Point onControl)
|
int |
getScreenRows()
Returns the number of complete rows displayable on the control. |
java.lang.String |
getText()
Returns the text of the control. |
protected int |
getTextWidth()
|
void |
gotFocus()
|
protected void |
insertLine(int index)
|
void |
lostFocus()
|
protected boolean |
newCursorPos(int ch,
int ln,
boolean takeSel)
|
protected void |
newText(java.lang.String txt,
int newCp,
boolean redoData)
|
void |
onControlEvent(waba.ui.ControlEvent ev)
|
void |
onKeyEvent(waba.ui.KeyEvent ev)
|
protected void |
paintCursor(waba.fx.Graphics gr)
|
protected void |
paintLastChar(waba.fx.Graphics g)
|
protected void |
paintLastChar(waba.fx.Graphics gr,
boolean eraseIt)
|
protected void |
paintLine(waba.fx.Graphics gr,
int index)
|
void |
penDoubleClicked(Point where)
|
void |
penPressed(Point where)
|
void |
selectAll()
|
void |
setText(java.lang.String what)
Sets the text for the control. |
protected java.lang.String[] |
split(java.lang.String what,
char separator)
|
protected void |
splitLines()
|
protected void |
updateScrolls()
|
Methods inherited from class AdvControl |
getFontMetrics,
hasModifier,
isOnMe,
modify,
onEvent,
onPaint,
onPenEvent,
onTimerEvent,
penClicked,
penHeld,
penReleased,
repaintDataNow,
repaintNow,
repaintNow,
startDragging,
stopDragging |
Methods inherited from class waba.ui.Control |
addTimer,
contains,
createGraphics,
getFontMetrics,
getNext,
getParent,
getRect,
postEvent,
removeTimer,
repaint,
setRect |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
lines
protected java.lang.String[] lines
spacing
public int spacing
- The space between the text and the border of the control.
minXScroll
public int minXScroll
- This is the minimum distance to scroll horizontally. It is a percent figure, defaults to 30%
minYScroll
public int minYScroll
- This is the minimum distance to scroll Vertically. It is a percent figure, defaults to 80%
homeCursorOnLostFocus
public boolean homeCursorOnLostFocus
- If the control should reset the cursor position to row 0 and column 0 when it loses focus.
itemBuffer
protected ImageBuffer itemBuffer
blockBuffer
protected ImageBuffer blockBuffer
blink
protected waba.ui.Timer blink
hasCursor
protected boolean hasCursor
cursorOn
protected boolean cursorOn
justGotFocus
protected boolean justGotFocus
curState
protected textAreaState curState
pressPoint
protected Point pressPoint
lastDrag
protected Point lastDrag
TextArea
public TextArea()
getItemHeight
protected int getItemHeight()
getTextWidth
protected int getTextWidth()
split
protected java.lang.String[] split(java.lang.String what,
char separator)
splitLines
protected void splitLines()
getNumLines
public int getNumLines()
insertLine
protected void insertLine(int index)
getCharRect
protected boolean getCharRect(int ch,
int ln,
waba.fx.Rect dest)
setText
public void setText(java.lang.String what)
- Sets the text for the control. Use a '\n' separates lines in the text.
getText
public java.lang.String getText()
- Returns the text of the control.
fixText
protected void fixText()
getScreenRows
public int getScreenRows()
- Returns the number of complete rows displayable on the control.
paintLastChar
protected void paintLastChar(waba.fx.Graphics g)
paintLastChar
protected void paintLastChar(waba.fx.Graphics gr,
boolean eraseIt)
deleteSelection
public boolean deleteSelection()
- Delete the current selection.
paintLine
protected void paintLine(waba.fx.Graphics gr,
int index)
doPaint
public void doPaint(waba.fx.Graphics g,
waba.fx.Rect area)
- Overrides:
- doPaint in class AdvControl
paintCursor
protected void paintCursor(waba.fx.Graphics gr)
doPaintData
public void doPaintData(waba.fx.Graphics g)
- Overrides:
- doPaintData in class AdvControl
doPaintData
public void doPaintData(waba.fx.Graphics g,
waba.fx.Rect area)
onControlEvent
public void onControlEvent(waba.ui.ControlEvent ev)
- Overrides:
- onControlEvent in class AdvControl
selectAll
public void selectAll()
checkScrolls
protected void checkScrolls()
updateScrolls
protected void updateScrolls()
gotFocus
public void gotFocus()
lostFocus
public void lostFocus()
fix
protected boolean fix()
newCursorPos
protected boolean newCursorPos(int ch,
int ln,
boolean takeSel)
newText
protected void newText(java.lang.String txt,
int newCp,
boolean redoData)
getPenChar
protected Point getPenChar(Point onControl)
clearCursor
protected void clearCursor()
getLine
protected java.lang.String getLine(int index)
getLine
protected java.lang.String getLine()
clearSelection
public void clearSelection()
penPressed
public void penPressed(Point where)
- Overrides:
- penPressed in class AdvControl
penDoubleClicked
public void penDoubleClicked(Point where)
- Overrides:
- penDoubleClicked in class AdvControl
dragged
public void dragged(DragContext dc)
- Overrides:
- dragged in class AdvControl
onKeyEvent
public void onKeyEvent(waba.ui.KeyEvent ev)
- Overrides:
- onKeyEvent in class AdvControl
doScroll
public void doScroll(int which,
int action,
int value)
- This scrolls the display.
"which" should be IScroll.Vertical or IScroll.Horizontal.
"action" should be IScroll.ScrollHigher, IScroll.ScrollLower, IScroll.PageHigher, IScroll.PageLower, IScroll.TrackTo
"value" is valid for only for action = IScroll.TrackTo and represents either the line to scroll vertically to
or the x coordinate (in pixels) to scroll horizontally to.