51 |
import java.beans.PropertyChangeListener; |
import java.beans.PropertyChangeListener; |
52 |
import java.util.EventListener; |
import java.util.EventListener; |
53 |
|
|
54 |
|
import javax.swing.JComponent; |
55 |
import javax.swing.SwingUtilities; |
import javax.swing.SwingUtilities; |
56 |
import javax.swing.Timer; |
import javax.swing.Timer; |
57 |
import javax.swing.event.ChangeEvent; |
import javax.swing.event.ChangeEvent; |
328 |
*/ |
*/ |
329 |
public void mouseDragged(MouseEvent event) |
public void mouseDragged(MouseEvent event) |
330 |
{ |
{ |
331 |
// FIXME: Implement this properly. |
moveCaret(event); |
332 |
} |
} |
333 |
|
|
334 |
/** |
/** |
358 |
*/ |
*/ |
359 |
public void mouseClicked(MouseEvent event) |
public void mouseClicked(MouseEvent event) |
360 |
{ |
{ |
361 |
// FIXME: Implement this properly. |
// TODO: Implement double- and triple-click behaviour here. |
362 |
} |
} |
363 |
|
|
364 |
/** |
/** |
380 |
*/ |
*/ |
381 |
public void mouseExited(MouseEvent event) |
public void mouseExited(MouseEvent event) |
382 |
{ |
{ |
383 |
// TODO: What to do here, if anything? |
// Nothing to do here. |
384 |
} |
} |
385 |
|
|
386 |
/** |
/** |
393 |
*/ |
*/ |
394 |
public void mousePressed(MouseEvent event) |
public void mousePressed(MouseEvent event) |
395 |
{ |
{ |
396 |
// FIXME: Implement this properly. |
positionCaret(event); |
|
if (!(event.getButton() == MouseEvent.BUTTON1)) |
|
|
return; |
|
|
setDot(textComponent.viewToModel(event.getPoint())); |
|
397 |
} |
} |
398 |
|
|
399 |
/** |
/** |
436 |
*/ |
*/ |
437 |
protected void moveCaret(MouseEvent event) |
protected void moveCaret(MouseEvent event) |
438 |
{ |
{ |
439 |
// FIXME: Implement this properly. |
int newDot = getComponent().viewToModel(event.getPoint()); |
440 |
|
moveDot(newDot); |
441 |
} |
} |
442 |
|
|
443 |
/** |
/** |
448 |
*/ |
*/ |
449 |
protected void positionCaret(MouseEvent event) |
protected void positionCaret(MouseEvent event) |
450 |
{ |
{ |
451 |
// FIXME: Implement this properly. |
int newDot = getComponent().viewToModel(event.getPoint()); |
452 |
|
moveDot(newDot); |
453 |
} |
} |
454 |
|
|
455 |
/** |
/** |
767 |
{ |
{ |
768 |
this.dot = dot; |
this.dot = dot; |
769 |
handleHighlight(); |
handleHighlight(); |
770 |
|
adjustVisibility(this); |
771 |
repaint(); |
repaint(); |
772 |
} |
} |
773 |
|
|
785 |
this.dot = dot; |
this.dot = dot; |
786 |
this.mark = dot; |
this.mark = dot; |
787 |
handleHighlight(); |
handleHighlight(); |
788 |
|
adjustVisibility(this); |
789 |
repaint(); |
repaint(); |
790 |
} |
} |
791 |
|
|
872 |
} |
} |
873 |
|
|
874 |
/** |
/** |
875 |
|
* Adjusts the text component so that the caret is visible. This default |
876 |
|
* implementation simply calls |
877 |
|
* {@link JComponent#scrollRectToVisible(Rectangle)} on the text component. |
878 |
|
* Subclasses may wish to change this. |
879 |
|
*/ |
880 |
|
protected void adjustVisibility(Rectangle rect) |
881 |
|
{ |
882 |
|
getComponent().scrollRectToVisible(rect); |
883 |
|
} |
884 |
|
|
885 |
|
/** |
886 |
* Initializes the blink timer. |
* Initializes the blink timer. |
887 |
*/ |
*/ |
888 |
private void initBlinkTimer() |
private void initBlinkTimer() |