FSF GCC merge 02/23/03
[official-gcc.git] / libjava / javax / swing / text / JTextComponent.java
blob9a6d350f0485831f56c6b9481188abe95f322c0d
1 /* JTextComponent.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.AWTEvent;
41 import java.awt.Component;
42 import java.awt.Dimension;
43 import java.awt.Image;
44 import java.awt.Rectangle;
45 import java.awt.Point;
46 import javax.accessibility.*;
47 import javax.swing.Icon;
48 import javax.swing.JComponent;
49 import javax.swing.KeyStroke;
50 import javax.swing.Scrollable;
51 import javax.swing.UIManager;
52 import javax.swing.event.*;
53 import javax.swing.plaf.TextUI;
55 public abstract class JTextComponent extends JComponent
56 implements Scrollable, Accessible
58 // public class AccessibleJTextComponent extends AccessibleJComponent
59 // implements AccessibleText, CaretListener, DocumentListener,
60 // AccessibleAction, AccessibleEditableText
61 // {
62 // } // class AccessibleJTextComponent
64 /**
65 * AccessibleJTextComponent
67 public class AccessibleJTextComponent extends AccessibleJComponent
68 implements AccessibleText, CaretListener, DocumentListener {
70 //-------------------------------------------------------------
71 // Variables --------------------------------------------------
72 //-------------------------------------------------------------
74 /**
75 * caretPos
77 int caretPos;
80 //-------------------------------------------------------------
81 // Initialization ---------------------------------------------
82 //-------------------------------------------------------------
84 /**
85 * Constructor AccessibleJTextComponent
86 * @param component TODO
88 public AccessibleJTextComponent(JTextComponent component) {
89 super(component);
90 // TODO
91 } // AccessibleJTextComponent()
94 //-------------------------------------------------------------
95 // Methods ----------------------------------------------------
96 //-------------------------------------------------------------
98 /**
99 * getCaretPosition
100 * @returns int
102 public int getCaretPosition() {
103 return 0; // TODO
104 } // getCaretPosition()
107 * getSelectedText
108 * @returns String
110 public String getSelectedText() {
111 return null; // TODO
112 } // getSelectedText()
115 * getSelectionStart
116 * @returns int
118 public int getSelectionStart() {
119 return 0; // TODO
120 } // getSelectionStart()
123 * getSelectionEnd
124 * @returns int
126 public int getSelectionEnd() {
127 return 0; // TODO
128 } // getSelectionEnd()
131 * caretUpdate
132 * @param value0 TODO
134 public void caretUpdate(CaretEvent value0) {
135 // TODO
136 } // caretUpdate()
139 * getAccessibleStateSet
140 * @returns AccessibleStateSet
142 public AccessibleStateSet getAccessibleStateSet() {
143 return null; // TODO
144 } // getAccessibleStateSet()
147 * getAccessibleRole
148 * @returns AccessibleRole
150 public AccessibleRole getAccessibleRole() {
151 return null; // TODO
152 } // getAccessibleRole()
155 * getAccessibleText
156 * @returns AccessibleText
158 public AccessibleText getAccessibleText() {
159 return null; // TODO
160 } // getAccessibleText()
163 * insertUpdate
164 * @param value0 TODO
166 public void insertUpdate(DocumentEvent value0) {
167 // TODO
168 } // insertUpdate()
171 * removeUpdate
172 * @param value0 TODO
174 public void removeUpdate(DocumentEvent value0) {
175 // TODO
176 } // removeUpdate()
179 * changedUpdate
180 * @param value0 TODO
182 public void changedUpdate(DocumentEvent value0) {
183 // TODO
184 } // changedUpdate()
187 * getIndexAtPoint
188 * @param value0 TODO
189 * @returns int
191 public int getIndexAtPoint(Point value0) {
192 return 0; // TODO
193 } // getIndexAtPoint()
196 * getRootEditorRect
197 * @returns Rectangle
199 Rectangle getRootEditorRect() {
200 return null; // TODO
201 } // getRootEditorRect()
204 * getCharacterBounds
205 * @param value0 TODO
206 * @returns Rectangle
208 public Rectangle getCharacterBounds(int value0) {
209 return null; // TODO
210 } // getCharacterBounds()
213 * getCharCount
214 * @returns int
216 public int getCharCount() {
217 return 0; // TODO
218 } // getCharCount()
221 * getCharacterAttribute
222 * @param value0 TODO
223 * @returns AttributeSet
225 public AttributeSet getCharacterAttribute(int value0) {
226 return null; // TODO
227 } // getCharacterAttribute()
230 * getAtIndex
231 * @param value0 TODO
232 * @param value1 TODO
233 * @returns String
235 public String getAtIndex(int value0, int value1) {
236 return null; // TODO
237 } // getAtIndex()
240 * getAfterIndex
241 * @param value0 TODO
242 * @param value1 TODO
243 * @returns String
245 public String getAfterIndex(int value0, int value1) {
246 return null; // TODO
247 } // getAfterIndex()
250 * getBeforeIndex
251 * @param value0 TODO
252 * @param value1 TODO
253 * @returns String
255 public String getBeforeIndex(int value0, int value1) {
256 return null; // TODO
257 } // getBeforeIndex()
260 } // AccessibleJTextComponent
264 public static class KeyBinding
266 public KeyStroke key;
267 public String actionName;
268 public KeyBinding(KeyStroke key, String actionName)
270 this.key = key;
271 this.actionName = actionName;
273 } // class KeyBinding
275 int icon_gap;
276 Icon icon;
277 int align;
278 Document doc;
280 public JTextComponent()
282 this("", null, 0);
285 public JTextComponent(Icon image)
287 this("", image, 0);
290 public JTextComponent(Icon image, int horizontalAlignment)
292 this("", image, horizontalAlignment);
295 public JTextComponent(String text)
297 this(text, null, 0);
300 public JTextComponent(String text, int horizontalAlignment)
302 this(text, null, horizontalAlignment);
305 public JTextComponent(String text, Icon icon, int horizontalAlignment)
307 setDocument(new PlainDocument());
309 // do the work.....
310 setText(text);
311 this.icon = icon;
312 this.align = horizontalAlignment;
314 // its an editor, so:
315 enableEvents(AWTEvent.KEY_EVENT_MASK);
316 updateUI();
319 public void setDocument(Document s)
321 doc = s;
322 revalidate();
323 repaint();
326 public Document getDocument()
328 if (doc == null)
329 System.out.println("doc == null !!!");
330 return doc;
333 protected int checkHorizontalKey(int key, String message)
335 // Verify that key is a legal value for the horizontalAlignment properties.
336 return 0;
338 protected int checkVerticalKey(int key, String message)
340 // Verify that key is a legal value for the verticalAlignment or verticalTextPosition properties.
341 return 0;
343 public AccessibleContext getAccessibleContext()
345 // Get the AccessibleContext of this object
346 return null;
348 public Icon getDisabledIcon()
350 return null;
352 public int getDisplayedMnemonic()
354 // Return the keycode that indicates a mnemonic key.
355 return 0;
357 public int getHorizontalAlignment()
359 // Returns the alignment of the label's contents along the X axis.
360 return 0;
362 public int getHorizontalTextPosition()
364 // Returns the horizontal position of the label's text, relative to its image.
365 return 0;
368 public Icon getIcon()
369 { return icon; }
370 public int getIconTextGap()
371 { return icon_gap; }
374 Component getLabelFor()
376 // Get the component this is labelling.
377 return null;
380 public void setText(String text)
382 getDocument().remove(0,doc.getLength());
383 getDocument().insertString(0, text, null);
386 public String getText()
388 return getDocument().getText(0,
389 getDocument().getLength());
392 public String getUIClassID()
394 // Returns a string that specifies the name of the l&f class that renders this component.
395 return "JTextComponent";
397 public int getVerticalAlignment()
399 // Returns the alignment of the label's contents along the Y axis.
400 return 0;
402 public int getVerticalTextPosition()
404 // Returns the vertical position of the label's text, relative to its image.
405 return 0;
408 public boolean imageUpdate(Image img, int infoflags, int x, int y, int w, int h)
410 // This is overriden to return false if the current Icon's Image is not equal to the passed in Image img.
411 return (img == icon);
413 protected String paramString()
415 // Returns a string representation of this JTextComponent.
416 return "JTextComponent";
418 void setDisabledIcon(Icon disabledIcon)
420 // Set the icon to be displayed if this JTextComponent is "disabled" (JTextComponent.setEnabled(false)).
422 void setDisplayedMnemonic(char aChar)
424 // Specifies the displayedMnemonic as a char value.
426 void setDisplayedMnemonic(int key)
428 // Specify a keycode that indicates a mnemonic key.
430 void setHorizontalAlignment(int alignment)
432 // Sets the alignment of the label's contents along the X axis.
434 void setHorizontalTextPosition(int textPosition)
436 // Sets the horizontal position of the label's text, relative to its image.
438 void setIcon(Icon icon)
440 // Defines the icon this component will display.
442 public void setIconTextGap(int iconTextGap)
444 // If both the icon and text properties are set, this property defines the space between them.
447 public void setLabelFor(Component c)
449 // Set the component this is labelling.
452 public void setVerticalAlignment(int alignment)
454 // Sets the alignment of the label's contents along the Y axis.
456 public void setVerticalTextPosition(int textPosition)
458 // Sets the vertical position of the label's text, relative to its image.
461 public TextUI getUI()
462 { return (TextUI) ui;
465 public void updateUI()
467 TextUI b = (TextUI)UIManager.getUI(this);
468 setUI(b);
471 public Dimension getPreferredScrollableViewportSize()
473 return null;
475 public int getScrollableUnitIncrement(Rectangle visible, int orientation,
476 int direction)
478 return 0;
480 public int getScrollableBlockIncrement(Rectangle visible, int orientation,
481 int direction)
483 return 0;
485 } // class JTextComponent