Dead
[official-gcc.git] / gomp-20050608-branch / libjava / classpath / javax / swing / plaf / TextUI.java
blob9f2737cc26f6d7b07025191d8240f00984772ed9
1 /* TextUI.java --
2 Copyright (C) 2002, 2003, 2004 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., 51 Franklin Street, Fifth Floor, Boston, MA
19 02110-1301 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. */
39 package javax.swing.plaf;
41 import java.awt.Point;
42 import java.awt.Rectangle;
43 import java.awt.Shape;
45 import javax.swing.text.BadLocationException;
46 import javax.swing.text.EditorKit;
47 import javax.swing.text.JTextComponent;
48 import javax.swing.text.Position;
49 import javax.swing.text.View;
51 /**
52 * An abstract base class for delegates that provide the user
53 * interface for text editors.
55 * @see javax.swing.text.JTextComponent
57 * @author Ronald Veldema (rveldema@cs.vu.nl)
58 * @author Sascha Brawer (brawer@dandelis.ch)
60 public abstract class TextUI extends ComponentUI
62 /**
63 * Constructs a new <code>TextUI</code>.
64 */
65 public TextUI()
67 // Nothing to do here.
71 /**
72 * Calculates the geometric extent of the character at the
73 * given offset.
75 * @param tc the <code>JTextComponent</code> for which this
76 * delegate object provides the user interface.
78 * @param pos the zero-based index of the character into the
79 * document model.
81 * @return the bounding box of the character at index
82 * <code>pos</code>, in view coordinates.
84 * @throws BadLocationException if <code>pos</code> does not
85 * designate a valid position in the document model.
87 * @see javax.swing.text.ComponentView#modelToView(int, Shape, Position.Bias)
89 public abstract Rectangle modelToView(JTextComponent tc, int pos)
90 throws BadLocationException;
93 /**
94 * Calculates the geometric extent of the character at the
95 * given offset.
97 * @param tc the <code>JTextComponent</code> for which this
98 * delegate object provides the user interface.
100 * @param pos the zero-based index of the character into the
101 * document model.
103 * @param bias whether to take the character before or after the
104 * caret position indicated by <code>pos</code>. The value
105 * must be either {@link
106 * javax.swing.text.Position.Bias#Backward} or {@link
107 * javax.swing.text.Position.Bias#Forward}.
109 * @return the bounding box of the character at index
110 * <code>pos</code>, in view coordinates.
112 * @throws BadLocationException if <code>pos</code> does not
113 * designate a valid position in the document model.
115 * @see javax.swing.text.ComponentView#modelToView(int, Shape, Position.Bias)
117 public abstract Rectangle modelToView(JTextComponent tc, int pos,
118 Position.Bias bias)
119 throws BadLocationException;
123 * Finds the caret position which is closest to the specified visual
124 * location.
126 * @param t the <code>JTextComponent</code> for which this
127 * delegate object provides the user interface.
129 * @param pt the position in view coordinates.
131 * @return the caret position which is closest to <code>loc</code>.
133 * @see #viewToModel(JTextComponent, Point, Position.Bias[])
135 public abstract int viewToModel(JTextComponent t, Point pt);
139 * Finds the caret position which is closest to the specified visual
140 * location.
142 * @param tc the <code>JTextComponent</code> for which this
143 * delegate object provides the user interface.
145 * @param loc the position in view coordinates.
147 * @param outBias an array whose size must be at least one.
148 * After the call, <code>outBias[0]</code> will indicate
149 * whether <code>loc</code> is in the glyph before
150 * (<code>Position.Bias.Backward</code>) or after
151 * (<code>Position.Bias.Forward</code>) the returned
152 * caret position.
154 * @return the caret position which is closest to <code>loc</code>.
156 public abstract int viewToModel(JTextComponent tc, Point loc,
157 Position.Bias[] outBias);
162 * Calculates the caret position that is visually next to the given
163 * position. This is useful to determine where to move the caret
164 * after the user has pressed an arrow key.
166 * @param tc the <code>JTextComponent</code> for which this
167 * delegate object provides the user interface.
169 * @param pos the current caret position, a zero-based index
170 * into the document model.
172 * @param bias whether to take the character before or after the
173 * caret position indicated by <code>pos</code>. The value
174 * must be either {@link
175 * javax.swing.text.Position.Bias#Backward} or {@link
176 * javax.swing.text.Position.Bias#Forward}.
178 * @param direction the visual direction. Pass
179 * {@link javax.swing.SwingConstants#WEST} for the left
180 * arrow key, {@link javax.swing.SwingConstants#EAST}
181 * for the right arrow key, {@link
182 * javax.swing.SwingConstants#NORTH} for the up arrow
183 * key, or {@link javax.swing.SwingConstants#SOUTH}
184 * for the down arrow key.
186 * @throws BadLocationException if <code>pos</code> does not
187 * designate a valid position in the document model.
189 * @throws IllegalArgumentException if <code>direction</code>
190 * is not one of <code>Position.Bias.Forward</code>
191 * or <code>Position.Bias.Backward</code>.
193 public abstract int getNextVisualPositionFrom(JTextComponent tc,
194 int pos,
195 Position.Bias bias,
196 int direction,
197 Position.Bias[] outBias)
198 throws BadLocationException;
202 * Repaints a range of characters.
204 * @param tc the <code>JTextComponent</code> for which this
205 * delegate object provides the user interface.
207 * @param start the first character in the range that needs
208 * painting, indicated as an index into the document model.
210 * @param end the last character in the range that needs
211 * painting, indicated as an index into the document model.
212 * <code>end</code> must be greater than or equal to
213 * <code>start</code>.
215 public abstract void damageRange(JTextComponent tc, int start, int end);
219 * Repaints a range of characters, also specifying the bias for the
220 * start and end of the range.
222 * @param tc the <code>JTextComponent</code> for which this
223 * delegate object provides the user interface.
225 * @param start the first character in the range that needs
226 * painting, indicated as an index into the document model.
228 * @param end the last character in the range that needs
229 * painting, indicated as an index into the document model.
230 * <code>end</code> must be greater than or equal to
231 * <code>start</code>.
233 public abstract void damageRange(JTextComponent tc,
234 int start, int end,
235 Position.Bias startBias,
236 Position.Bias endBias);
240 * Retrieves the <code>EditorKit</code> managing policies and
241 * persistent state.
243 * @param tc the <code>JTextComponent</code> for which this
244 * delegate object provides the user interface.
246 * @return the <code>EditorKit</code> used by <code>tc</code>.
248 public abstract EditorKit getEditorKit(JTextComponent tc);
252 * Retrieves the root of the view tree that visually presents
253 * the text.
255 * @param tc the <code>JTextComponent</code> for which this
256 * delegate object provides the user interface.
258 * @return the root <code>View</code> used by <code>tc</code>.
260 public abstract View getRootView(JTextComponent tc);
264 * Returns a String for presenting a tool tip at the specified
265 * location.
267 * @param tc the <code>JTextComponent</code> for which this
268 * delegate object provides the user interface.
270 * @param loc the location for which the tool tip is requested.
272 * @return the text for the tool tip, or <code>null</code> to
273 * display no tool tip.
275 * @since 1.4
277 public String getToolTipText(JTextComponent tc, Point loc)
279 return null;