1 /* QtTextAreaPeer.java --
2 Copyright (C) 2005 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)
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
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
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 gnu.java.awt.peer.qt;
40 import java.awt.Dimension;
41 import java.awt.Rectangle;
42 import java.awt.TextArea;
43 import java.awt.event.TextEvent;
44 import java.awt.im.InputMethodRequests;
45 import java.awt.peer.TextAreaPeer;
47 public class QtTextAreaPeer extends QtComponentPeer implements TextAreaPeer
49 public QtTextAreaPeer( QtToolkit kit, TextArea owner )
54 protected native void init();
56 protected void setup()
59 setText(((TextArea)owner).getText());
60 setEditable(((TextArea)owner).isEditable());
64 * Returns the start (start = true) or end (start = false) of the selection.
66 private native int getSelection(boolean start);
69 * Called back on a text edit.
71 private void textChanged()
73 TextEvent e = new TextEvent(owner, TextEvent.TEXT_VALUE_CHANGED);
74 QtToolkit.eventQueue.postEvent(e);
77 // ************ Public methods *********************
79 public long filterEvents(long filter)
84 public native int getCaretPosition();
86 public Rectangle getCharacterBounds(int pos)
89 return new Rectangle(0,0,0,0);
93 * Implemented, but who uses it?
95 public native int getIndexAtPoint(int x, int y);
97 // public void reshape(int x, int y,
98 // int width, int height)
100 // if(width != 0 || height != 0)
101 // super.reshape(x, y, width, height);
103 // super.reshape(x, y, 10, 10);
106 public Dimension getMinimumSize(int rows, int cols)
109 return getMinimumSize();
112 public Dimension getPreferredSize(int rows, int cols)
115 return getPreferredSize();
118 public int getSelectionEnd()
120 return getSelection(false);
123 public int getSelectionStart()
125 return getSelection(true);
128 public native String getText();
130 public void insert(String text, int pos)
132 // Not very efficient, no.
133 String s = getText();
134 setText(s.substring(0, pos) + text + s.substring(pos));
137 public void insertText(String text, int pos)
142 public Dimension minimumSize(int rows, int cols)
144 return getMinimumSize(rows, cols);
147 public Dimension preferredSize(int rows, int cols)
149 return getPreferredSize(rows, cols);
152 public void replaceRange(String insert, int start_pos, int end_pos)
154 // Not very efficient, no.
155 String text = getText();
156 String right = text.substring(0, start_pos);
157 String left = text.substring(end_pos);
158 setText(right + insert + left);
161 public void replaceText(String text, int start_pos, int end_pos)
163 replaceRange(text, start_pos, end_pos);
166 public native void setText(String text);
168 public native void select(int start_pos, int end_pos);
170 public native void setEditable(boolean editable);
172 public native void setCaretPosition(int pos);
174 public InputMethodRequests getInputMethodRequests()
176 // TODO Auto-generated method stub