KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > lobobrowser > html > renderer > BaseInputControl


1 /*
2     GNU LESSER GENERAL PUBLIC LICENSE
3     Copyright (C) 2006 The Lobo Project
4
5     This library is free software; you can redistribute it and/or
6     modify it under the terms of the GNU Lesser General Public
7     License as published by the Free Software Foundation; either
8     version 2.1 of the License, or (at your option) any later version.
9
10     This library is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13     Lesser General Public License for more details.
14
15     You should have received a copy of the GNU Lesser General Public
16     License along with this library; if not, write to the Free Software
17     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
19     Contact info: xamjadmin@users.sourceforge.net
20 */

21 /*
22  * Created on Jan 15, 2006
23  */

24 package org.lobobrowser.html.renderer;
25
26 import java.awt.Graphics JavaDoc;
27 import java.io.File JavaDoc;
28
29 import org.lobobrowser.html.domimpl.*;
30
31 abstract class BaseInputControl extends BaseControl implements InputContext {
32     protected String JavaDoc value;
33
34     public BaseInputControl(HTMLBaseInputElement modelNode) {
35         super(modelNode);
36         this.setOpaque(false);
37     }
38     
39     public void reset(int availWidth, int availHeight) {
40         String JavaDoc sizeText = this.controlElement.getAttribute("size");
41         if(sizeText != null) {
42             try {
43                 this.size = Integer.parseInt(sizeText);
44             } catch(NumberFormatException JavaDoc nfe) {
45                 // ignore
46
}
47         }
48     }
49     
50     public int getVAlign() {
51         return RElement.VALIGN_ABSBOTTOM;
52     }
53
54     protected int size = -1;
55     
56     /* (non-Javadoc)
57      * @see org.xamjwg.html.domimpl.InputContext#blur()
58      */

59     public void blur() {
60     }
61
62     /* (non-Javadoc)
63      * @see org.xamjwg.html.domimpl.InputContext#click()
64      */

65     public void click() {
66     }
67
68     /* (non-Javadoc)
69      * @see org.xamjwg.html.domimpl.InputContext#focus()
70      */

71     public void focus() {
72         this.requestFocus();
73     }
74
75     /* (non-Javadoc)
76      * @see org.xamjwg.html.domimpl.InputContext#getChecked()
77      */

78     public boolean getChecked() {
79         return false;
80     }
81
82     /* (non-Javadoc)
83      * @see org.xamjwg.html.domimpl.InputContext#getDisabled()
84      */

85     public boolean getDisabled() {
86         return !this.isEnabled();
87     }
88
89     /* (non-Javadoc)
90      * @see org.xamjwg.html.domimpl.InputContext#getMaxLength()
91      */

92     public int getMaxLength() {
93         return 0;
94     }
95
96     /* (non-Javadoc)
97      * @see org.xamjwg.html.domimpl.InputContext#getReadOnly()
98      */

99     public boolean getReadOnly() {
100         return false;
101     }
102
103     /* (non-Javadoc)
104      * @see org.xamjwg.html.domimpl.InputContext#getTabIndex()
105      */

106     public int getTabIndex() {
107         return 0;
108     }
109
110     /* (non-Javadoc)
111      * @see org.xamjwg.html.domimpl.InputContext#getValue()
112      */

113     public String JavaDoc getValue() {
114         return this.value;
115     }
116
117     /* (non-Javadoc)
118      * @see org.xamjwg.html.domimpl.InputContext#select()
119      */

120     public void select() {
121     }
122
123     /* (non-Javadoc)
124      * @see org.xamjwg.html.domimpl.InputContext#setChecked(boolean)
125      */

126     public void setChecked(boolean checked) {
127     }
128
129     /* (non-Javadoc)
130      * @see org.xamjwg.html.domimpl.InputContext#setDisabled(boolean)
131      */

132     public void setDisabled(boolean disabled) {
133         this.setEnabled(!disabled);
134     }
135
136     /* (non-Javadoc)
137      * @see org.xamjwg.html.domimpl.InputContext#setMaxLength(int)
138      */

139     public void setMaxLength(int maxLength) {
140     }
141
142     /* (non-Javadoc)
143      * @see org.xamjwg.html.domimpl.InputContext#setReadOnly(boolean)
144      */

145     public void setReadOnly(boolean readOnly) {
146     }
147
148     /* (non-Javadoc)
149      * @see org.xamjwg.html.domimpl.InputContext#setSize(int)
150      */

151     public void setControlSize(int size) {
152         this.size = size;
153         this.invalidate();
154     }
155
156     /* (non-Javadoc)
157      * @see org.xamjwg.html.domimpl.InputContext#setTabIndex(int)
158      */

159     public void setTabIndex(int tabIndex) {
160     }
161
162     /* (non-Javadoc)
163      * @see org.xamjwg.html.domimpl.InputContext#setValue(java.lang.String)
164      */

165     public void setValue(String JavaDoc value) {
166         this.value = value;
167     }
168
169     /* (non-Javadoc)
170      * @see org.xamjwg.html.domimpl.InputContext#getTextSize()
171      */

172     public int getControlSize() {
173         return this.size;
174     }
175
176     /* (non-Javadoc)
177      * @see org.xamjwg.html.domimpl.InputContext#getCols()
178      */

179     public int getCols() {
180         return 0;
181     }
182
183     /* (non-Javadoc)
184      * @see org.xamjwg.html.domimpl.InputContext#getRows()
185      */

186     public int getRows() {
187         return 0;
188     }
189
190     /* (non-Javadoc)
191      * @see org.xamjwg.html.domimpl.InputContext#setCols(int)
192      */

193     public void setCols(int cols) {
194     }
195
196     /* (non-Javadoc)
197      * @see org.xamjwg.html.domimpl.InputContext#setRows(int)
198      */

199     public void setRows(int rows) {
200     }
201
202     /* (non-Javadoc)
203      * @see org.xamjwg.html.renderer.UIControl#paintSelection(java.awt.Graphics, boolean, org.xamjwg.html.renderer.RenderablePoint, org.xamjwg.html.renderer.RenderablePoint)
204      */

205     public boolean paintSelection(Graphics JavaDoc g, boolean inSelection, RenderableSpot startPoint, RenderableSpot endPoint) {
206         return inSelection;
207     }
208
209     public boolean getMultiple() {
210         // For selects
211
return false;
212     }
213
214     public int getSelectedIndex() {
215         // For selects
216
return -1;
217     }
218
219     public int getVisibleSize() {
220         // For selects
221
return 0;
222     }
223
224     public void setMultiple(boolean value) {
225         // For selects
226
}
227
228     public void setSelectedIndex(int value) {
229         // For selects
230
}
231
232     public void setVisibleSize(int value) {
233         // For selects
234
}
235
236     public File JavaDoc getFileValue() {
237         // For file inputs
238
return null;
239     }
240 }
241
Popular Tags