comparison dwt/widgets/IME.d @ 0:380af2bdd8e5

Upload of whole dwt tree
author Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
date Sat, 09 Aug 2008 17:00:02 +0200
parents
children 649b8e223d5a
comparison
equal deleted inserted replaced
-1:000000000000 0:380af2bdd8e5
1 /*******************************************************************************
2 * Copyright (c) 2007 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors:
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 module dwt.widgets.IME;
12
13 import dwt.dwthelper.utils;
14
15
16 import dwt.DWT;
17 import dwt.graphics.TextStyle;
18
19 public class IME extends Widget {
20 Canvas parent;
21 int caretOffset;
22 int startOffset;
23 int commitCount;
24 String text;
25 int [] ranges;
26 TextStyle [] styles;
27
28 /**
29 * Prevents uninitialized instances from being created outside the package.
30 */
31 IME () {
32 }
33
34 /**
35 *
36 * @see DWT
37 */
38 public IME (Canvas parent, int style) {
39 super (parent, style);
40 this.parent = parent;
41 createWidget ();
42 }
43
44 void createWidget () {
45 text = "";
46 startOffset = -1;
47 if (parent.getIME () is null) {
48 parent.setIME (this);
49 }
50 }
51
52 public int getCaretOffset () {
53 checkWidget ();
54 return startOffset + caretOffset;
55 }
56
57 public int getCommitCount () {
58 checkWidget ();
59 return commitCount;
60 }
61
62 public int getCompositionOffset () {
63 checkWidget ();
64 return startOffset;
65 }
66
67 public int [] getRanges () {
68 checkWidget ();
69 return ranges !is null ? ranges : new int [0];
70 }
71
72 public TextStyle [] getStyles () {
73 checkWidget ();
74 return styles !is null ? styles : new TextStyle [0];
75 }
76
77 public String getText () {
78 checkWidget ();
79 return text;
80 }
81
82 public bool getWideCaret() {
83 return false;
84 }
85
86 void releaseParent () {
87 super.releaseParent ();
88 if (this is parent.getIME ()) parent.setIME (null);
89 }
90
91 void releaseWidget () {
92 super.releaseWidget ();
93 parent = null;
94 text = null;
95 styles = null;
96 ranges = null;
97 }
98
99 }