2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / libjava / javax / swing / text / JTextComponent.java
blobe53b20f2f706351a26d6130a0363f37ea55c7f01
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.Insets;
45 import java.awt.Rectangle;
46 import java.awt.Point;
47 import javax.accessibility.Accessible;
48 import javax.accessibility.AccessibleContext;
49 import javax.accessibility.AccessibleRole;
50 import javax.accessibility.AccessibleStateSet;
51 import javax.accessibility.AccessibleText;
52 import javax.swing.Icon;
53 import javax.swing.JComponent;
54 import javax.swing.KeyStroke;
55 import javax.swing.Scrollable;
56 import javax.swing.UIManager;
57 import javax.swing.event.CaretEvent;
58 import javax.swing.event.CaretListener;
59 import javax.swing.event.DocumentEvent;
60 import javax.swing.event.DocumentListener;
61 import javax.swing.plaf.TextUI;
63 public abstract class JTextComponent extends JComponent
64 implements Scrollable, Accessible
66 // public class AccessibleJTextComponent extends AccessibleJComponent
67 // implements AccessibleText, CaretListener, DocumentListener,
68 // AccessibleAction, AccessibleEditableText
69 // {
70 // } // class AccessibleJTextComponent
72 /**
73 * AccessibleJTextComponent
75 public class AccessibleJTextComponent extends AccessibleJComponent
76 implements AccessibleText, CaretListener, DocumentListener {
78 //-------------------------------------------------------------
79 // Variables --------------------------------------------------
80 //-------------------------------------------------------------
82 /**
83 * caretPos
85 int caretPos;
88 //-------------------------------------------------------------
89 // Initialization ---------------------------------------------
90 //-------------------------------------------------------------
92 /**
93 * Constructor AccessibleJTextComponent
94 * @param component TODO
96 public AccessibleJTextComponent(JTextComponent component) {
97 super(component);
98 // TODO
99 } // AccessibleJTextComponent()
102 //-------------------------------------------------------------
103 // Methods ----------------------------------------------------
104 //-------------------------------------------------------------
107 * getCaretPosition
108 * @returns int
110 public int getCaretPosition() {
111 return 0; // TODO
112 } // getCaretPosition()
115 * getSelectedText
116 * @returns String
118 public String getSelectedText() {
119 return null; // TODO
120 } // getSelectedText()
123 * getSelectionStart
124 * @returns int
126 public int getSelectionStart() {
127 return 0; // TODO
128 } // getSelectionStart()
131 * getSelectionEnd
132 * @returns int
134 public int getSelectionEnd() {
135 return 0; // TODO
136 } // getSelectionEnd()
139 * caretUpdate
140 * @param value0 TODO
142 public void caretUpdate(CaretEvent value0) {
143 // TODO
144 } // caretUpdate()
147 * getAccessibleStateSet
148 * @returns AccessibleStateSet
150 public AccessibleStateSet getAccessibleStateSet() {
151 return null; // TODO
152 } // getAccessibleStateSet()
155 * getAccessibleRole
156 * @returns AccessibleRole
158 public AccessibleRole getAccessibleRole() {
159 return null; // TODO
160 } // getAccessibleRole()
163 * getAccessibleText
164 * @returns AccessibleText
166 public AccessibleText getAccessibleText() {
167 return null; // TODO
168 } // getAccessibleText()
171 * insertUpdate
172 * @param value0 TODO
174 public void insertUpdate(DocumentEvent value0) {
175 // TODO
176 } // insertUpdate()
179 * removeUpdate
180 * @param value0 TODO
182 public void removeUpdate(DocumentEvent value0) {
183 // TODO
184 } // removeUpdate()
187 * changedUpdate
188 * @param value0 TODO
190 public void changedUpdate(DocumentEvent value0) {
191 // TODO
192 } // changedUpdate()
195 * getIndexAtPoint
196 * @param value0 TODO
197 * @returns int
199 public int getIndexAtPoint(Point value0) {
200 return 0; // TODO
201 } // getIndexAtPoint()
204 * getRootEditorRect
205 * @returns Rectangle
207 Rectangle getRootEditorRect() {
208 return null; // TODO
209 } // getRootEditorRect()
212 * getCharacterBounds
213 * @param value0 TODO
214 * @returns Rectangle
216 public Rectangle getCharacterBounds(int value0) {
217 return null; // TODO
218 } // getCharacterBounds()
221 * getCharCount
222 * @returns int
224 public int getCharCount() {
225 return 0; // TODO
226 } // getCharCount()
229 * getCharacterAttribute
230 * @param value0 TODO
231 * @returns AttributeSet
233 public AttributeSet getCharacterAttribute(int value0) {
234 return null; // TODO
235 } // getCharacterAttribute()
238 * getAtIndex
239 * @param value0 TODO
240 * @param value1 TODO
241 * @returns String
243 public String getAtIndex(int value0, int value1) {
244 return null; // TODO
245 } // getAtIndex()
248 * getAfterIndex
249 * @param value0 TODO
250 * @param value1 TODO
251 * @returns String
253 public String getAfterIndex(int value0, int value1) {
254 return null; // TODO
255 } // getAfterIndex()
258 * getBeforeIndex
259 * @param value0 TODO
260 * @param value1 TODO
261 * @returns String
263 public String getBeforeIndex(int value0, int value1) {
264 return null; // TODO
265 } // getBeforeIndex()
268 } // AccessibleJTextComponent
272 public static class KeyBinding
274 public KeyStroke key;
275 public String actionName;
276 public KeyBinding(KeyStroke key, String actionName)
278 this.key = key;
279 this.actionName = actionName;
281 } // class KeyBinding
283 int icon_gap;
284 Icon icon;
285 int align;
286 Document doc;
288 public JTextComponent()
290 this("", null, 0);
293 public JTextComponent(Icon image)
295 this("", image, 0);
298 public JTextComponent(Icon image, int horizontalAlignment)
300 this("", image, horizontalAlignment);
303 public JTextComponent(String text)
305 this(text, null, 0);
308 public JTextComponent(String text, int horizontalAlignment)
310 this(text, null, horizontalAlignment);
313 public JTextComponent(String text, Icon icon, int horizontalAlignment)
315 setDocument(new PlainDocument());
317 // do the work.....
318 setText(text);
319 this.icon = icon;
320 this.align = horizontalAlignment;
322 // its an editor, so:
323 enableEvents(AWTEvent.KEY_EVENT_MASK);
324 updateUI();
327 public void setDocument(Document s)
329 doc = s;
330 revalidate();
331 repaint();
334 public Document getDocument()
336 if (doc == null)
337 System.out.println("doc == null !!!");
338 return doc;
341 protected int checkHorizontalKey(int key, String message)
343 // Verify that key is a legal value for the horizontalAlignment properties.
344 return 0;
346 protected int checkVerticalKey(int key, String message)
348 // Verify that key is a legal value for the verticalAlignment or verticalTextPosition properties.
349 return 0;
351 public AccessibleContext getAccessibleContext()
353 // Get the AccessibleContext of this object
354 return null;
356 public Icon getDisabledIcon()
358 return null;
360 public int getDisplayedMnemonic()
362 // Return the keycode that indicates a mnemonic key.
363 return 0;
365 public int getHorizontalAlignment()
367 // Returns the alignment of the label's contents along the X axis.
368 return 0;
370 public int getHorizontalTextPosition()
372 // Returns the horizontal position of the label's text, relative to its image.
373 return 0;
376 public Icon getIcon()
377 { return icon; }
378 public int getIconTextGap()
379 { return icon_gap; }
382 Component getLabelFor()
384 // Get the component this is labelling.
385 return null;
388 public Insets getMargin()
390 // FIXME: Not implemented.
391 return null;
394 public void setText(String text)
396 getDocument().remove(0,doc.getLength());
397 getDocument().insertString(0, text, null);
400 public String getText()
402 return getDocument().getText(0,
403 getDocument().getLength());
406 public String getUIClassID()
408 // Returns a string that specifies the name of the l&f class that renders this component.
409 return "JTextComponent";
411 public int getVerticalAlignment()
413 // Returns the alignment of the label's contents along the Y axis.
414 return 0;
416 public int getVerticalTextPosition()
418 // Returns the vertical position of the label's text, relative to its image.
419 return 0;
422 public boolean imageUpdate(Image img, int infoflags, int x, int y, int w, int h)
424 // This is overriden to return false if the current Icon's Image is not equal to the passed in Image img.
425 return (img == icon);
427 protected String paramString()
429 // Returns a string representation of this JTextComponent.
430 return "JTextComponent";
432 void setDisabledIcon(Icon disabledIcon)
434 // Set the icon to be displayed if this JTextComponent is "disabled" (JTextComponent.setEnabled(false)).
436 void setDisplayedMnemonic(char aChar)
438 // Specifies the displayedMnemonic as a char value.
440 void setDisplayedMnemonic(int key)
442 // Specify a keycode that indicates a mnemonic key.
444 void setHorizontalAlignment(int alignment)
446 // Sets the alignment of the label's contents along the X axis.
448 void setHorizontalTextPosition(int textPosition)
450 // Sets the horizontal position of the label's text, relative to its image.
452 void setIcon(Icon icon)
454 // Defines the icon this component will display.
456 public void setIconTextGap(int iconTextGap)
458 // If both the icon and text properties are set, this property defines the space between them.
461 public void setLabelFor(Component c)
463 // Set the component this is labelling.
466 public void setVerticalAlignment(int alignment)
468 // Sets the alignment of the label's contents along the Y axis.
470 public void setVerticalTextPosition(int textPosition)
472 // Sets the vertical position of the label's text, relative to its image.
475 public TextUI getUI()
476 { return (TextUI) ui;
479 public void updateUI()
481 TextUI b = (TextUI)UIManager.getUI(this);
482 setUI(b);
485 public Dimension getPreferredScrollableViewportSize()
487 return null;
489 public int getScrollableUnitIncrement(Rectangle visible, int orientation,
490 int direction)
492 return 0;
494 public int getScrollableBlockIncrement(Rectangle visible, int orientation,
495 int direction)
497 return 0;
499 } // class JTextComponent