126 * capacity |
127 * capacity |
127 * @throws IllegalArgumentException |
128 * @throws IllegalArgumentException |
128 * if the width or height is less than one pixel |
129 * if the width or height is less than one pixel |
129 */ |
130 */ |
130 TextEditorImpl(String aText, int aMaxSize, int aConstraints, int aWidth, |
131 TextEditorImpl(String aText, int aMaxSize, int aConstraints, int aWidth, |
131 int aHeight) { |
132 int aHeight) |
|
133 { |
132 super(aText, aMaxSize, aConstraints, aWidth, aHeight, false); |
134 super(aText, aMaxSize, aConstraints, aWidth, aHeight, false); |
133 } |
135 } |
134 |
136 |
135 /* |
137 /* |
136 * <P> |
138 * <P> |
169 * @throws IllegalArgumentException |
171 * @throws IllegalArgumentException |
170 * if the value of the constraints parameter is invalid |
172 * if the value of the constraints parameter is invalid |
171 * @throws IllegalArgumentException |
173 * @throws IllegalArgumentException |
172 * if the width is less than one pixel |
174 * if the width is less than one pixel |
173 */ |
175 */ |
174 TextEditorImpl(int aMaxSize, int aConstraints, int aWidth, int aRows) { |
176 TextEditorImpl(int aMaxSize, int aConstraints, int aWidth, int aRows) |
|
177 { |
175 super(null, aMaxSize, aConstraints, aWidth, aRows, true); |
178 super(null, aMaxSize, aConstraints, aWidth, aRows, true); |
176 } |
179 } |
177 |
180 |
178 /* |
181 /* |
179 * Set the parent object of this TextEditor. Typically in LCDUI the parent |
182 * Set the parent object of this TextEditor. Typically in LCDUI the parent |
180 * object would be Canvas or CustomItem. Setting the parameter to null |
183 * object would be Canvas or CustomItem. Setting the parameter to null |
181 * removes the association to the parent. |
184 * removes the association to the parent. |
182 * <p> |
185 * <p> |
184 * <p> |
187 * <p> |
185 * @throws IllegalArgumentException |
188 * @throws IllegalArgumentException |
186 * if <code>aParent</code> is not a valid object with which a |
189 * if <code>aParent</code> is not a valid object with which a |
187 * TextEditor can be associated |
190 * TextEditor can be associated |
188 */ |
191 */ |
189 public void setParent( Object aParent ) { |
192 public void setParent(Object aParent) |
190 super.setParent( aParent ); |
193 { |
|
194 super.setParent(aParent); |
191 // Update indicator location to their default position. |
195 // Update indicator location to their default position. |
192 if( aParent != null ) { |
196 if (aParent != null) |
|
197 { |
193 setDefaultIndicators(); |
198 setDefaultIndicators(); |
194 } |
199 } |
195 } |
200 } |
196 |
201 |
197 /* |
202 /* |
226 * the x coordinate of the anchor point, in pixels. |
231 * the x coordinate of the anchor point, in pixels. |
227 * @param y |
232 * @param y |
228 * the y coordinate of the anchor point, in pixels. |
233 * the y coordinate of the anchor point, in pixels. |
229 * |
234 * |
230 */ |
235 */ |
231 public void setIndicatorLocation(int x, int y) { |
236 public void setIndicatorLocation(int x, int y) |
232 synchronized (iToolkit) { |
237 { |
|
238 synchronized (iToolkit) |
|
239 { |
233 NativeError.check(_setIndicatorLocation(getToolkitHandle(), |
240 NativeError.check(_setIndicatorLocation(getToolkitHandle(), |
234 iHandle, x, y)); |
241 iHandle, x, y)); |
235 } |
242 } |
236 } |
243 } |
237 |
244 |
238 /* |
245 /* |
239 * <P> |
246 * <P> |
258 * |
265 * |
259 * @throws IllegalStateException |
266 * @throws IllegalStateException |
260 * If the <code>TextEditor</code> is not added to |
267 * If the <code>TextEditor</code> is not added to |
261 * <code>Canvas</code> |
268 * <code>Canvas</code> |
262 */ |
269 */ |
263 public void setDefaultIndicators() { |
270 public void setDefaultIndicators() |
264 synchronized (iToolkit) { |
271 { |
|
272 synchronized (iToolkit) |
|
273 { |
265 Object parent = getParent(); |
274 Object parent = getParent(); |
266 boolean fullScreen = false; |
275 boolean fullScreen = false; |
267 |
276 |
268 if (parent instanceof Canvas) { |
277 if (parent instanceof Canvas) |
|
278 { |
269 fullScreen = iLCDUIPackageInvoker.isFullScreen((Canvas) parent); |
279 fullScreen = iLCDUIPackageInvoker.isFullScreen((Canvas) parent); |
270 } |
280 } |
271 |
281 |
272 NativeError.check(_setDefaultIndicators(getToolkitHandle(), |
282 NativeError.check(_setDefaultIndicators(getToolkitHandle(), |
273 iHandle, fullScreen)); |
283 iHandle, fullScreen)); |
274 } |
284 } |
275 } |
285 } |
276 |
286 |
277 /* |
287 /* |
278 * <P> |
288 * <P> |
292 * controls indicator visibility state |
302 * controls indicator visibility state |
293 * |
303 * |
294 * @see #setIndicatorLocation(int, int) |
304 * @see #setIndicatorLocation(int, int) |
295 * @see #setDefaultIndicators() |
305 * @see #setDefaultIndicators() |
296 */ |
306 */ |
297 public void setIndicatorVisibility(boolean visible) { |
307 public void setIndicatorVisibility(boolean visible) |
298 synchronized (iToolkit) { |
308 { |
|
309 synchronized (iToolkit) |
|
310 { |
299 NativeError.check(_setIndicatorVisibility(getToolkitHandle(), |
311 NativeError.check(_setIndicatorVisibility(getToolkitHandle(), |
300 iHandle, visible)); |
312 iHandle, visible)); |
301 } |
313 } |
302 } |
314 } |
303 |
315 |
304 /* |
316 /* |
305 * Gets the size of the area needed for drawing the input indicators. |
317 * Gets the size of the area needed for drawing the input indicators. |
315 * <p> |
327 * <p> |
316 * |
328 * |
317 * @return the width and height of area needed for drawing input indicators |
329 * @return the width and height of area needed for drawing input indicators |
318 * @see #setDefaultIndicators() |
330 * @see #setDefaultIndicators() |
319 */ |
331 */ |
320 public int[] getIndicatorSize() { |
332 public int[] getIndicatorSize() |
|
333 { |
321 int[] size = new int[INDICATOR_SIZE_COUNT]; |
334 int[] size = new int[INDICATOR_SIZE_COUNT]; |
322 |
335 |
323 synchronized (iToolkit) { |
336 synchronized (iToolkit) |
|
337 { |
324 NativeError.check(_getIndicatorSize(getToolkitHandle(), iHandle, |
338 NativeError.check(_getIndicatorSize(getToolkitHandle(), iHandle, |
325 size)); |
339 size)); |
326 } |
340 } |
327 return size; |
341 return size; |
328 } |
342 } |
329 |
343 |
330 /* |
344 /* |
347 * if the given input modes are not valid. |
361 * if the given input modes are not valid. |
348 * <p> |
362 * <p> |
349 * @see #setPreferredTouchMode(int) |
363 * @see #setPreferredTouchMode(int) |
350 * @see #getDisabledTouchInputModes() |
364 * @see #getDisabledTouchInputModes() |
351 */ |
365 */ |
352 public void setDisabledTouchInputModes(int touchInputModes) { |
366 public void setDisabledTouchInputModes(int touchInputModes) |
|
367 { |
353 // Validate touch input modes. There must not be additional modes |
368 // Validate touch input modes. There must not be additional modes |
354 // 0 is valid. |
369 // 0 is valid. |
355 // See com.nokia.mid.ui.s60.TextEditor.TOUCH_INPUT_ALL_AVAILABLE. |
370 // See com.nokia.mid.ui.s60.TextEditor.TOUCH_INPUT_ALL_AVAILABLE. |
356 if ((touchInputModes & ~MASK) != 0) { |
371 if ((touchInputModes & ~MASK) != 0) |
|
372 { |
357 throw new IllegalArgumentException(); |
373 throw new IllegalArgumentException(); |
358 } |
374 } |
359 |
375 |
360 synchronized (iToolkit) { |
376 synchronized (iToolkit) |
|
377 { |
361 NativeError.check(_setDisabledTouchInputModes(getToolkitHandle(), |
378 NativeError.check(_setDisabledTouchInputModes(getToolkitHandle(), |
362 iHandle, touchInputModes)); |
379 iHandle, touchInputModes)); |
363 } |
380 } |
364 } |
381 } |
365 |
382 |
366 /* |
383 /* |
367 * By default all supported touch input modes are available. Returns the |
384 * By default all supported touch input modes are available. Returns the |
376 * |
393 * |
377 * @return The disabled touch input modes. |
394 * @return The disabled touch input modes. |
378 * @see #setDisabledTouchInputModes(int) |
395 * @see #setDisabledTouchInputModes(int) |
379 * @see #setPreferredTouchMode(int) |
396 * @see #setPreferredTouchMode(int) |
380 */ |
397 */ |
381 public int getDisabledTouchInputModes() { |
398 public int getDisabledTouchInputModes() |
|
399 { |
382 int disabled = 0; |
400 int disabled = 0; |
383 |
401 |
384 synchronized (iToolkit) { |
402 synchronized (iToolkit) |
|
403 { |
385 disabled = _getDisabledTouchInputModes(getToolkitHandle(), iHandle); |
404 disabled = _getDisabledTouchInputModes(getToolkitHandle(), iHandle); |
386 } |
405 } |
387 |
406 |
388 NativeError.check(disabled); |
407 NativeError.check(disabled); |
389 return disabled; |
408 return disabled; |
408 * input modes as bit mask. |
427 * input modes as bit mask. |
409 * @see #setDisabledTouchInputModes(int) |
428 * @see #setDisabledTouchInputModes(int) |
410 * @see #getPreferredTouchMode() |
429 * @see #getPreferredTouchMode() |
411 * |
430 * |
412 */ |
431 */ |
413 public void setPreferredTouchMode(int touchInputModes) { |
432 public void setPreferredTouchMode(int touchInputModes) |
|
433 { |
414 int mask = touchInputModes & MASK; |
434 int mask = touchInputModes & MASK; |
415 // Validate touch input mode. |
435 // Validate touch input mode. |
416 if (touchInputModes == 0 || (touchInputModes & ~MASK) != 0 |
436 if (touchInputModes == 0 || (touchInputModes & ~MASK) != 0 |
417 || (mask & (mask - 1)) != 0) { |
437 || (mask & (mask - 1)) != 0) |
|
438 { |
418 throw new IllegalArgumentException(); |
439 throw new IllegalArgumentException(); |
419 } |
440 } |
420 |
441 |
421 synchronized (iToolkit) { |
442 synchronized (iToolkit) |
|
443 { |
422 NativeError.check(_setPreferredTouchMode(getToolkitHandle(), |
444 NativeError.check(_setPreferredTouchMode(getToolkitHandle(), |
423 iHandle, touchInputModes)); |
445 iHandle, touchInputModes)); |
424 } |
446 } |
425 } |
447 } |
426 |
448 |
427 /* |
449 /* |
428 * Gets the preferred touch input mode. |
450 * Gets the preferred touch input mode. |
434 * @return The preferred touch input mode. |
456 * @return The preferred touch input mode. |
435 * <p> |
457 * <p> |
436 * @see #setPreferredTouchMode(int) |
458 * @see #setPreferredTouchMode(int) |
437 * @see #setDisabledTouchInputModes(int) |
459 * @see #setDisabledTouchInputModes(int) |
438 */ |
460 */ |
439 public int getPreferredTouchMode() { |
461 public int getPreferredTouchMode() |
|
462 { |
440 int preferredMode = 0; |
463 int preferredMode = 0; |
441 |
464 |
442 synchronized (iToolkit) { |
465 synchronized (iToolkit) |
|
466 { |
443 preferredMode = _getPreferredTouchMode(getToolkitHandle(), iHandle); |
467 preferredMode = _getPreferredTouchMode(getToolkitHandle(), iHandle); |
444 } |
468 } |
445 |
469 |
446 NativeError.check(preferredMode); |
470 NativeError.check(preferredMode); |
447 return preferredMode; |
471 return preferredMode; |
448 } |
472 } |
449 |
473 |
450 /* |
474 /* |
451 * Sets the caret in the Editor at x, y location. |
475 * Sets the caret in the Editor at x, y location. |
452 * |
476 * |
453 * @param x |
477 * @param x |
454 * The x coordinate of the wanted caret position. |
478 * The x coordinate of the wanted caret position. |
455 * |
479 * |
456 * @param y |
480 * @param y |
457 * The y coordinate of the wanted caret position. |
481 * The y coordinate of the wanted caret position. |
458 */ |
482 */ |
459 public void setCaretXY(int x, int y) { |
483 public void setCaretXY(int x, int y) |
460 synchronized (iToolkit) { |
484 { |
|
485 synchronized (iToolkit) |
|
486 { |
461 NativeError.check(_setCaretXY(getToolkitHandle(), |
487 NativeError.check(_setCaretXY(getToolkitHandle(), |
462 iHandle, x, y)); |
488 iHandle, x, y)); |
463 } |
489 } |
464 } |
490 } |
465 |
491 |
466 /* |
492 /* |
467 * Hidden default constructor. |
493 * Hidden default constructor. |
468 */ |
494 */ |
469 private TextEditorImpl() { |
495 private TextEditorImpl() |
|
496 { |
470 } |
497 } |
471 |
498 |
472 // Private methods. |
499 // Private methods. |
473 |
500 |
474 /* |
501 /* |