1:
37:
38: package ;
39:
40: import ;
41: import ;
42: import ;
43: import ;
44: import ;
45: import ;
46:
47: public class QtTextAreaPeer extends QtComponentPeer implements TextAreaPeer
48: {
49: public QtTextAreaPeer( QtToolkit kit, TextArea owner )
50: {
51: super( kit, owner );
52: }
53:
54: protected native void init();
55:
56: protected void setup()
57: {
58: super.setup();
59: setText(((TextArea)owner).getText());
60: setEditable(((TextArea)owner).isEditable());
61: }
62:
63:
66: private native int getSelection(boolean start);
67:
68:
71: private void textChanged()
72: {
73: TextEvent e = new TextEvent(owner, TextEvent.TEXT_VALUE_CHANGED);
74: QtToolkit.eventQueue.postEvent(e);
75: }
76:
77:
78:
79: public long filterEvents(long filter)
80: {
81: return filter;
82: }
83:
84: public native int getCaretPosition();
85:
86: public Rectangle getCharacterBounds(int pos)
87: {
88:
89: return new Rectangle(0,0,0,0);
90: }
91:
92:
95: public native int getIndexAtPoint(int x, int y);
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106: public Dimension getMinimumSize(int rows, int cols)
107: {
108:
109: return getMinimumSize();
110: }
111:
112: public Dimension getPreferredSize(int rows, int cols)
113: {
114:
115: return getPreferredSize();
116: }
117:
118: public int getSelectionEnd()
119: {
120: return getSelection(false);
121: }
122:
123: public int getSelectionStart()
124: {
125: return getSelection(true);
126: }
127:
128: public native String getText();
129:
130: public void insert(String text, int pos)
131: {
132:
133: String s = getText();
134: setText(s.substring(0, pos) + text + s.substring(pos));
135: }
136:
137: public void insertText(String text, int pos)
138: {
139: insert(text, pos);
140: }
141:
142: public Dimension minimumSize(int rows, int cols)
143: {
144: return getMinimumSize(rows, cols);
145: }
146:
147: public Dimension preferredSize(int rows, int cols)
148: {
149: return getPreferredSize(rows, cols);
150: }
151:
152: public void replaceRange(String insert, int start_pos, int end_pos)
153: {
154:
155: String text = getText();
156: String right = text.substring(0, start_pos);
157: String left = text.substring(end_pos);
158: setText(right + insert + left);
159: }
160:
161: public void replaceText(String text, int start_pos, int end_pos)
162: {
163: replaceRange(text, start_pos, end_pos);
164: }
165:
166: public native void setText(String text);
167:
168: public native void select(int start_pos, int end_pos);
169:
170: public native void setEditable(boolean editable);
171:
172: public native void setCaretPosition(int pos);
173:
174: public InputMethodRequests getInputMethodRequests()
175: {
176:
177: return null;
178: }
179: }