150 |
} |
} |
151 |
|
|
152 |
/** |
/** |
153 |
|
* Indicates that the preferences of one of the child view has changed. |
154 |
|
* This calls revalidate on the text component. |
155 |
|
* |
156 |
|
* @param view the child view which's preference has changed |
157 |
|
* @param width <code>true</code> if the width preference has changed |
158 |
|
* @param height <code>true</code> if the height preference has changed |
159 |
|
*/ |
160 |
|
public void preferenceChanged(View view, boolean width, boolean height) |
161 |
|
{ |
162 |
|
textComponent.revalidate(); |
163 |
|
} |
164 |
|
|
165 |
|
/** |
166 |
* Sets the real root view. |
* Sets the real root view. |
167 |
* |
* |
168 |
* @param v the root view to set |
* @param v the root view to set |
170 |
public void setView(View v) |
public void setView(View v) |
171 |
{ |
{ |
172 |
if (view != null) |
if (view != null) |
173 |
view.setParent(null); |
view.setParent(null); |
174 |
|
|
175 |
if (v != null) |
if (v != null) |
176 |
v.setParent(this); |
v.setParent(null); |
177 |
|
|
178 |
view = v; |
view = v; |
179 |
} |
} |
180 |
|
|
181 |
/** |
/** |
182 |
|
* Returns the real root view, regardless of the index. |
183 |
|
* |
184 |
|
* @param index not used here |
185 |
|
* |
186 |
|
* @return the real root view, regardless of the index. |
187 |
|
*/ |
188 |
|
public View getView(int index) |
189 |
|
{ |
190 |
|
return view; |
191 |
|
} |
192 |
|
|
193 |
|
/** |
194 |
|
* Returns <code>1</code> since the RootView always contains one |
195 |
|
* child, that is the real root of the View hierarchy. |
196 |
|
* |
197 |
|
* @return <code>1</code> since the RootView always contains one |
198 |
|
* child, that is the real root of the View hierarchy |
199 |
|
*/ |
200 |
|
public int getViewCount() |
201 |
|
{ |
202 |
|
if (view != null) |
203 |
|
return 1; |
204 |
|
else |
205 |
|
return 0; |
206 |
|
} |
207 |
|
|
208 |
|
/** |
209 |
* Returns the <code>Container</code> that contains this view. This |
* Returns the <code>Container</code> that contains this view. This |
210 |
* normally will be the text component that is managed by this TextUI. |
* normally will be the text component that is managed by this TextUI. |
211 |
* |
* |
284 |
* @return the position in the document that corresponds to the screen |
* @return the position in the document that corresponds to the screen |
285 |
* coordinates <code>x, y</code> |
* coordinates <code>x, y</code> |
286 |
*/ |
*/ |
287 |
public int viewToModel(float x, float y, Shape a, Position.Bias b) |
public int viewToModel(float x, float y, Shape a, Position.Bias[] b) |
288 |
{ |
{ |
289 |
return view.viewToModel(x, y, a, b); |
return view.viewToModel(x, y, a, b); |
290 |
} |
} |
366 |
{ |
{ |
367 |
Dimension size = textComponent.getSize(); |
Dimension size = textComponent.getSize(); |
368 |
rootView.changedUpdate(ev, new Rectangle(0, 0, size.width, size.height), |
rootView.changedUpdate(ev, new Rectangle(0, 0, size.width, size.height), |
369 |
BasicTextUI.this); |
rootView.getViewFactory()); |
370 |
} |
} |
371 |
|
|
372 |
/** |
/** |
378 |
{ |
{ |
379 |
Dimension size = textComponent.getSize(); |
Dimension size = textComponent.getSize(); |
380 |
rootView.insertUpdate(ev, new Rectangle(0, 0, size.width, size.height), |
rootView.insertUpdate(ev, new Rectangle(0, 0, size.width, size.height), |
381 |
BasicTextUI.this); |
rootView.getViewFactory()); |
382 |
int caretPos = textComponent.getCaretPosition(); |
int caretPos = textComponent.getCaretPosition(); |
383 |
if (caretPos >= ev.getOffset()) |
if (caretPos >= ev.getOffset()) |
384 |
textComponent.setCaretPosition(caretPos + ev.getLength()); |
textComponent.setCaretPosition(caretPos + ev.getLength()); |
393 |
{ |
{ |
394 |
Dimension size = textComponent.getSize(); |
Dimension size = textComponent.getSize(); |
395 |
rootView.removeUpdate(ev, new Rectangle(0, 0, size.width, size.height), |
rootView.removeUpdate(ev, new Rectangle(0, 0, size.width, size.height), |
396 |
BasicTextUI.this); |
rootView.getViewFactory()); |
397 |
int caretPos = textComponent.getCaretPosition(); |
int caretPos = textComponent.getCaretPosition(); |
398 |
if (caretPos >= ev.getOffset()) |
if (caretPos >= ev.getOffset()) |
399 |
textComponent.setCaretPosition(ev.getOffset()); |
textComponent.setCaretPosition(ev.getOffset()); |
1019 |
protected final void setView(View view) |
protected final void setView(View view) |
1020 |
{ |
{ |
1021 |
rootView.setView(view); |
rootView.setView(view); |
1022 |
|
view.setParent(rootView); |
1023 |
} |
} |
1024 |
|
|
1025 |
/** |
/** |
1040 |
Element elem = doc.getDefaultRootElement(); |
Element elem = doc.getDefaultRootElement(); |
1041 |
if (elem == null) |
if (elem == null) |
1042 |
return; |
return; |
1043 |
setView(factory.create(elem)); |
View view = factory.create(elem); |
1044 |
|
setView(view); |
1045 |
} |
} |
1046 |
} |
} |