1 | /* DefaultCaret.java --
|
---|
2 | Copyright (C) 2002 Free Software Foundation, Inc.
|
---|
3 |
|
---|
4 | This file is part of GNU Classpath.
|
---|
5 |
|
---|
6 | GNU Classpath is free software; you can redistribute it and/or modify
|
---|
7 | it under the terms of the GNU General Public License as published by
|
---|
8 | the Free Software Foundation; either version 2, or (at your option)
|
---|
9 | any later version.
|
---|
10 |
|
---|
11 | GNU Classpath is distributed in the hope that it will be useful, but
|
---|
12 | WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
14 | General Public License for more details.
|
---|
15 |
|
---|
16 | You should have received a copy of the GNU General Public License
|
---|
17 | along with GNU Classpath; see the file COPYING. If not, write to the
|
---|
18 | Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
---|
19 | 02111-1307 USA.
|
---|
20 |
|
---|
21 | Linking this library statically or dynamically with other modules is
|
---|
22 | making a combined work based on this library. Thus, the terms and
|
---|
23 | conditions of the GNU General Public License cover the whole
|
---|
24 | combination.
|
---|
25 |
|
---|
26 | As a special exception, the copyright holders of this library give you
|
---|
27 | permission to link this library with independent modules to produce an
|
---|
28 | executable, regardless of the license terms of these independent
|
---|
29 | modules, and to copy and distribute the resulting executable under
|
---|
30 | terms of your choice, provided that you also meet, for each linked
|
---|
31 | independent module, the terms and conditions of the license of that
|
---|
32 | module. An independent module is a module which is not derived from
|
---|
33 | or based on this library. If you modify this library, you may extend
|
---|
34 | this exception to your version of the library, but you are not
|
---|
35 | obligated to do so. If you do not wish to do so, delete this
|
---|
36 | exception statement from your version. */
|
---|
37 |
|
---|
38 | package javax.swing.text;
|
---|
39 |
|
---|
40 | import java.awt.*;
|
---|
41 | import java.util.*;
|
---|
42 | import java.awt.event.*;
|
---|
43 | import javax.swing.event.*;
|
---|
44 |
|
---|
45 |
|
---|
46 | public class DefaultCaret extends Rectangle implements Caret, FocusListener, MouseListener, MouseMotionListener
|
---|
47 | {
|
---|
48 | Color color = new Color(0,0,0);
|
---|
49 | JTextComponent parent;
|
---|
50 |
|
---|
51 | public void mouseDragged(java.awt.event.MouseEvent evt)
|
---|
52 | {
|
---|
53 | }
|
---|
54 |
|
---|
55 | public void mouseMoved(java.awt.event.MouseEvent evt)
|
---|
56 | {
|
---|
57 | }
|
---|
58 |
|
---|
59 | public void mouseClicked(java.awt.event.MouseEvent evt)
|
---|
60 | {
|
---|
61 | }
|
---|
62 |
|
---|
63 | public void mouseEntered(java.awt.event.MouseEvent evt)
|
---|
64 | {
|
---|
65 | }
|
---|
66 |
|
---|
67 | public void mouseExited(java.awt.event.MouseEvent evt)
|
---|
68 | {
|
---|
69 | }
|
---|
70 |
|
---|
71 | public void mousePressed(java.awt.event.MouseEvent evt)
|
---|
72 | {
|
---|
73 | }
|
---|
74 |
|
---|
75 | public void mouseReleased(java.awt.event.MouseEvent evt)
|
---|
76 | {
|
---|
77 | }
|
---|
78 |
|
---|
79 | public void focusGained(java.awt.event.FocusEvent evt)
|
---|
80 | {
|
---|
81 | }
|
---|
82 |
|
---|
83 | public void focusLost(java.awt.event.FocusEvent evt)
|
---|
84 | {
|
---|
85 | }
|
---|
86 |
|
---|
87 | // caret methods:
|
---|
88 |
|
---|
89 | public void deinstall(JTextComponent c)
|
---|
90 | {
|
---|
91 | parent.removeFocusListener(this);
|
---|
92 | parent.removeMouseListener(this);
|
---|
93 |
|
---|
94 | parent = null;
|
---|
95 | }
|
---|
96 | public void install(JTextComponent c)
|
---|
97 | {
|
---|
98 | parent.addFocusListener(this);
|
---|
99 | parent.addMouseListener(this);
|
---|
100 | parent = c;
|
---|
101 | repaint();
|
---|
102 | }
|
---|
103 |
|
---|
104 | Point magic = null;
|
---|
105 | public void setMagicCaretPosition(Point p)
|
---|
106 | { magic = p; }
|
---|
107 | public Point getMagicaretPosition()
|
---|
108 | { return magic; }
|
---|
109 |
|
---|
110 |
|
---|
111 | int mark = 0;
|
---|
112 | public int getMark()
|
---|
113 | { return mark; }
|
---|
114 |
|
---|
115 | boolean vis_sel = true;
|
---|
116 | public void setSelectionVisible(boolean v)
|
---|
117 | { vis_sel = v; repaint(); }
|
---|
118 | public boolean isSelectionVisible()
|
---|
119 | { return vis_sel; }
|
---|
120 |
|
---|
121 | private void repaint()
|
---|
122 | {
|
---|
123 | if (parent != null)
|
---|
124 | {
|
---|
125 | parent.repaint();
|
---|
126 | }
|
---|
127 | }
|
---|
128 |
|
---|
129 | public void paint(Graphics g)
|
---|
130 | {
|
---|
131 | g.setColor(color);
|
---|
132 | g.drawLine(x,y,
|
---|
133 | x,y+height);
|
---|
134 | }
|
---|
135 |
|
---|
136 |
|
---|
137 | Vector changes = new Vector();
|
---|
138 | public void addChangeListener(ChangeListener l)
|
---|
139 | { changes.addElement(l); }
|
---|
140 | public void removeChangeListener(ChangeListener l)
|
---|
141 | { changes.removeElement(l); }
|
---|
142 |
|
---|
143 |
|
---|
144 | int blink = 500;
|
---|
145 | public int getBlinkRate()
|
---|
146 | { return blink; }
|
---|
147 | public void setBlinkRate(int rate)
|
---|
148 | { blink = rate; }
|
---|
149 |
|
---|
150 | int dot = 0;
|
---|
151 | public int getDot()
|
---|
152 | { return dot; }
|
---|
153 | public void moveDot(int dot)
|
---|
154 | { setDot(dot); }
|
---|
155 | public void setDot(int dot)
|
---|
156 | {
|
---|
157 | this.dot = dot;
|
---|
158 | repaint();
|
---|
159 | }
|
---|
160 |
|
---|
161 | boolean vis = true;
|
---|
162 | public boolean isVisible()
|
---|
163 | { return vis; }
|
---|
164 | public void setVisible(boolean v)
|
---|
165 | {
|
---|
166 | vis = v;
|
---|
167 | repaint();
|
---|
168 | }
|
---|
169 | }
|
---|
170 |
|
---|
171 |
|
---|
172 |
|
---|