2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / libjava / javax / swing / text / DefaultCaret.java
blob7fa94a4615a92e4feda2eb53d4fa86374b29366a
1 /* DefaultCaret.java --
2 Copyright (C) 2002 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
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.
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.
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.
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.
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. */
38 package javax.swing.text;
40 import java.awt.*;
41 import java.util.*;
42 import java.awt.event.*;
43 import javax.swing.event.*;
46 public class DefaultCaret extends Rectangle implements Caret, FocusListener, MouseListener, MouseMotionListener
48 Color color = new Color(0,0,0);
49 JTextComponent parent;
51 public void mouseDragged(java.awt.event.MouseEvent evt)
55 public void mouseMoved(java.awt.event.MouseEvent evt)
59 public void mouseClicked(java.awt.event.MouseEvent evt)
63 public void mouseEntered(java.awt.event.MouseEvent evt)
67 public void mouseExited(java.awt.event.MouseEvent evt)
71 public void mousePressed(java.awt.event.MouseEvent evt)
75 public void mouseReleased(java.awt.event.MouseEvent evt)
79 public void focusGained(java.awt.event.FocusEvent evt)
83 public void focusLost(java.awt.event.FocusEvent evt)
87 // caret methods:
89 public void deinstall(JTextComponent c)
91 parent.removeFocusListener(this);
92 parent.removeMouseListener(this);
94 parent = null;
96 public void install(JTextComponent c)
98 parent.addFocusListener(this);
99 parent.addMouseListener(this);
100 parent = c;
101 repaint();
104 Point magic = null;
105 public void setMagicCaretPosition(Point p)
106 { magic = p; }
107 public Point getMagicCaretPosition()
108 { return magic; }
111 int mark = 0;
112 public int getMark()
113 { return mark; }
115 boolean vis_sel = true;
116 public void setSelectionVisible(boolean v)
117 { vis_sel = v; repaint(); }
118 public boolean isSelectionVisible()
119 { return vis_sel; }
121 private void repaint()
123 if (parent != null)
125 parent.repaint();
129 public void paint(Graphics g)
131 g.setColor(color);
132 g.drawLine(x,y,
133 x,y+height);
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); }
144 int blink = 500;
145 public int getBlinkRate()
146 { return blink; }
147 public void setBlinkRate(int rate)
148 { blink = rate; }
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)
157 this.dot = dot;
158 repaint();
161 boolean vis = true;
162 public boolean isVisible()
163 { return vis; }
164 public void setVisible(boolean v)
166 vis = v;
167 repaint();