1:
37:
38: package ;
39:
40: import ;
41: import ;
42: import ;
43: import ;
44: import ;
45: import ;
46:
47: public class QtTextFieldPeer extends QtComponentPeer implements TextFieldPeer
48: {
49: public QtTextFieldPeer( QtToolkit kit, TextField owner )
50: {
51: super( kit, owner );
52: }
53:
54: protected native void init();
55:
56: protected void setup()
57: {
58: super.setup();
59: setText(((TextField)owner).getText());
60: setEditable(((TextField)owner).isEditable());
61: }
62:
63:
66: private void textChanged()
67: {
68: TextEvent e = new TextEvent(owner, TextEvent.TEXT_VALUE_CHANGED);
69: QtToolkit.eventQueue.postEvent(e);
70: }
71:
72:
75: private native int getSelection(boolean start);
76:
77: private native Dimension getMinimumSizeNative(int columns);
78:
79: private native Dimension getPreferredSizeNative(int columns);
80:
81:
82:
83: public long filterEvents(long e)
84: {
85: return e;
86: }
87:
88: public native int getCaretPosition();
89:
90: public Rectangle getCharacterBounds(int i)
91: {
92: return new Rectangle(0,0,0,0);
93: }
94:
95: public int getIndexAtPoint(int x, int y)
96: {
97:
98: return 0;
99: }
100:
101: public Dimension getMinimumSize(int columns)
102: {
103: Dimension d = getMinimumSizeNative( columns );
104: if ( d == null )
105: return new Dimension(10, 10);
106: return d;
107: }
108:
109: public Dimension getPreferredSize(int columns)
110: {
111: Dimension d = getPreferredSizeNative( columns );
112: if ( d == null )
113: return owner.getSize();
114: return d;
115: }
116:
117: public int getSelectionEnd()
118: {
119: return getSelection(false);
120: }
121:
122: public int getSelectionStart()
123: {
124: return getSelection(true);
125: }
126:
127: public native String getText();
128:
129: public Dimension minimumSize(int cols)
130: {
131: return getMinimumSize(cols);
132: }
133:
134: public Dimension preferredSize(int cols)
135: {
136: return getPreferredSize(cols);
137: }
138:
139: public native void select(int selStart, int selEnd);
140:
141: public native void setCaretPosition(int pos);
142:
143: public void setEchoCharacter(char c)
144: {
145: setEchoChar(c);
146: }
147:
148: public native void setEchoChar(char echoChar);
149:
150: public native void setEditable(boolean editable);
151:
152: public native void setText(String l);
153:
154: public InputMethodRequests getInputMethodRequests()
155: {
156:
157: return null;
158: }
159: }