sk.uniba.euromath.editor.textEditor
Class CaretManager

java.lang.Object
  extended by sk.uniba.euromath.editor.textEditor.CaretManager

public class CaretManager
extends Object

Each TextEditor can have its own CaretManager. CaretManager holds an instance of Caret, shows it on Canvas and moves it. Caret is always placed in ITextPieceKeeper at character gap. Character gap is gap between characters, specialls are gaps at start and end of text. Are index from zero to length of text. First gap(index 0) is before first character(index 0), last gap(index length) is after last character(index length -1).

Author:
Martin Kollar 3.2.2006

Constructor Summary
CaretManager(Canvas canvas, XMLAccess xmlAccess)
          Constructor.
 
Method Summary
 void activateCaret(ITextPieceKeeper keeper, int gapIndex)
          Activates Caret and shows it in keeper at character gap gapIndex.
protected  boolean checkCaret()
          Checks if Caret is ready to use
 void deactivateCaret()
          Deactivates and hides Caret
static int directionToKeyCode(String direction)
          Converts direction string to key code.
 ITextPieceKeeper getActiveTextPieceKeeper()
          Returns text piece keeper where caret is.
 int getCaretOffset()
          Returns index of character gap, where caret is shown.
 DomPointer getDOMPointer()
           
 org.eclipse.draw2d.geometry.Point getLocation()
          see Caret.getLocation()
protected  void hideCaret()
           
 boolean isCaretActive()
          True if caret is active and visible.
 boolean moveCaret(Direction direction, int count)
          TODO GUI ctrl movement Moves Caret from the current position to one positions further in LEFT,RIGHT,UP,DOWN or to the end or start of the current line, if possible.
protected  void showCaret()
           
protected  void showCaretAtCharGap(ITextPieceKeeper keeper, int charGapIndex)
          Shows caret at character gap charGapIndex in keeper.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CaretManager

public CaretManager(Canvas canvas,
                    XMLAccess xmlAccess)
Constructor.

Parameters:
canvas - Canvas on that the Caret will be painted
xmlAccess - The source document accessor
Method Detail

directionToKeyCode

public static int directionToKeyCode(String direction)
Converts direction string to key code.

Parameters:
s - One of RequestConstants.LEFT[RIGHT,UP,DOWN,HOME,END]
Returns:
SWT key code of relevant key

getActiveTextPieceKeeper

public ITextPieceKeeper getActiveTextPieceKeeper()
Returns text piece keeper where caret is.

Returns:
TextPieceKeeper or null

getLocation

public org.eclipse.draw2d.geometry.Point getLocation()
see Caret.getLocation()

Returns:
Location of the Caret or null if it is not active

getDOMPointer

public DomPointer getDOMPointer()
Returns:
DOMPointer in that is Caret activated. If it is not active, then returns null

getCaretOffset

public int getCaretOffset()
Returns index of character gap, where caret is shown.

Returns:
chracter gap index

isCaretActive

public boolean isCaretActive()
True if caret is active and visible.


activateCaret

public void activateCaret(ITextPieceKeeper keeper,
                          int gapIndex)
Activates Caret and shows it in keeper at character gap gapIndex.

Parameters:
keeper - ITextPieceKeeper where Caret will be shown
gapIndex - character gap index, where to show caret
See Also:
javadoc to find out more about character gaps

deactivateCaret

public void deactivateCaret()
Deactivates and hides Caret


moveCaret

public boolean moveCaret(Direction direction,
                         int count)
TODO GUI ctrl movement Moves Caret from the current position to one positions further in LEFT,RIGHT,UP,DOWN or to the end or start of the current line, if possible.

Parameters:
direction - direction of movement
number - of chars to move
Returns:
true if caret was moved, false if caret wasn't moved because there is no place where to move caret in such direction

checkCaret

protected boolean checkCaret()
Checks if Caret is ready to use

Returns:
true if caret is not null and is not disposed

showCaret

protected void showCaret()

hideCaret

protected void hideCaret()

showCaretAtCharGap

protected void showCaretAtCharGap(ITextPieceKeeper keeper,
                                  int charGapIndex)
Shows caret at character gap charGapIndex in keeper.

Parameters:
charGapIndex - index of character gap where to show caret
keeper - ITextPieceKeeper where to show Caret


Copyright © 2003-2006 null. All Rights Reserved.