source: trunk/gcc/libjava/javax/swing/text/DefaultCaret.java

Last change on this file was 1389, checked in by bird, 21 years ago

Initial revision

  • Property cvs2svn:cvs-rev set to 1.1
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 4.2 KB
Line 
1/* DefaultCaret.java --
2 Copyright (C) 2002 Free Software Foundation, Inc.
3
4This file is part of GNU Classpath.
5
6GNU Classpath is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2, or (at your option)
9any later version.
10
11GNU Classpath is distributed in the hope that it will be useful, but
12WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GNU Classpath; see the file COPYING. If not, write to the
18Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
1902111-1307 USA.
20
21Linking this library statically or dynamically with other modules is
22making a combined work based on this library. Thus, the terms and
23conditions of the GNU General Public License cover the whole
24combination.
25
26As a special exception, the copyright holders of this library give you
27permission to link this library with independent modules to produce an
28executable, regardless of the license terms of these independent
29modules, and to copy and distribute the resulting executable under
30terms of your choice, provided that you also meet, for each linked
31independent module, the terms and conditions of the license of that
32module. An independent module is a module which is not derived from
33or based on this library. If you modify this library, you may extend
34this exception to your version of the library, but you are not
35obligated to do so. If you do not wish to do so, delete this
36exception statement from your version. */
37
38package javax.swing.text;
39
40import java.awt.*;
41import java.util.*;
42import java.awt.event.*;
43import javax.swing.event.*;
44
45
46public 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
Note: See TracBrowser for help on using the repository browser.