diff options
author | Felipe Heidrich <fheidric> | 2007-09-24 20:12:28 +0000 |
---|---|---|
committer | Felipe Heidrich <fheidric> | 2007-09-24 20:12:28 +0000 |
commit | 74dec4c6e93fae67d79d1cf47bde3968d76ad998 (patch) | |
tree | 13ab657ff6bdcd6b9f1d36258214fa1c83628248 | |
parent | 49a0d281d71c7b0b4f050c8585ea47184b029cc7 (diff) | |
download | eclipse.platform.swt-74dec4c6e93fae67d79d1cf47bde3968d76ad998.tar.gz eclipse.platform.swt-74dec4c6e93fae67d79d1cf47bde3968d76ad998.tar.xz eclipse.platform.swt-74dec4c6e93fae67d79d1cf47bde3968d76ad998.zip |
IME object added (emulated)
12 files changed, 179 insertions, 0 deletions
diff --git a/bundles/org.eclipse.swt/.classpath_motif b/bundles/org.eclipse.swt/.classpath_motif index b2e3ade545..db459dbb07 100755 --- a/bundles/org.eclipse.swt/.classpath_motif +++ b/bundles/org.eclipse.swt/.classpath_motif @@ -11,6 +11,7 @@ <classpathentry kind="src" path="Eclipse SWT/emulated/treetable"/> <classpathentry kind="src" path="Eclipse SWT/emulated/expand"/> <classpathentry kind="src" path="Eclipse SWT/emulated/tooltip"/> + <classpathentry kind="src" path="Eclipse SWT/emulated/ime"/> <classpathentry kind="src" path="Eclipse SWT/common"/> <classpathentry kind="src" path="Eclipse SWT/common_j2se"/> <classpathentry kind="src" path="Eclipse SWT PI/motif"> diff --git a/bundles/org.eclipse.swt/.classpath_motif_j2me b/bundles/org.eclipse.swt/.classpath_motif_j2me index 746b81f4f1..bb3e94ac63 100644 --- a/bundles/org.eclipse.swt/.classpath_motif_j2me +++ b/bundles/org.eclipse.swt/.classpath_motif_j2me @@ -10,6 +10,7 @@ <classpathentry kind="src" path="Eclipse SWT/emulated/treetable"/> <classpathentry kind="src" path="Eclipse SWT/emulated/expand"/> <classpathentry kind="src" path="Eclipse SWT/emulated/tooltip"/> + <classpathentry kind="src" path="Eclipse SWT/emulated/ime"/> <classpathentry kind="src" path="Eclipse SWT/common"/> <classpathentry kind="src" path="Eclipse SWT/common_j2me"/> <classpathentry kind="src" path="Eclipse SWT PI/common"/> diff --git a/bundles/org.eclipse.swt/.classpath_photon b/bundles/org.eclipse.swt/.classpath_photon index ec1cb5b8a7..4f3d4fa187 100755 --- a/bundles/org.eclipse.swt/.classpath_photon +++ b/bundles/org.eclipse.swt/.classpath_photon @@ -11,6 +11,7 @@ <classpathentry kind="src" path="Eclipse SWT/emulated/textlayout"/> <classpathentry kind="src" path="Eclipse SWT/emulated/expand"/> <classpathentry kind="src" path="Eclipse SWT/emulated/tooltip"/> + <classpathentry kind="src" path="Eclipse SWT/emulated/ime"/> <classpathentry kind="src" path="Eclipse SWT/common"/> <classpathentry kind="src" path="Eclipse SWT/common_j2se"/> <classpathentry kind="src" path="Eclipse SWT PI/common"/> diff --git a/bundles/org.eclipse.swt/.classpath_photon_j2me b/bundles/org.eclipse.swt/.classpath_photon_j2me index 0532d4d30c..4005c9a241 100644 --- a/bundles/org.eclipse.swt/.classpath_photon_j2me +++ b/bundles/org.eclipse.swt/.classpath_photon_j2me @@ -10,6 +10,7 @@ <classpathentry kind="src" path="Eclipse SWT/emulated/textlayout"/> <classpathentry kind="src" path="Eclipse SWT/emulated/expand"/> <classpathentry kind="src" path="Eclipse SWT/emulated/tooltip"/> + <classpathentry kind="src" path="Eclipse SWT/emulated/ime"/> <classpathentry kind="src" path="Eclipse SWT/common"/> <classpathentry kind="src" path="Eclipse SWT/common_j2me"/> <classpathentry kind="src" path="Eclipse SWT PI/common"/> diff --git a/bundles/org.eclipse.swt/.classpath_wpf b/bundles/org.eclipse.swt/.classpath_wpf index d1cf95611e..e53cfda71a 100644 --- a/bundles/org.eclipse.swt/.classpath_wpf +++ b/bundles/org.eclipse.swt/.classpath_wpf @@ -15,6 +15,7 @@ <classpathentry kind="src" path="Eclipse SWT/emulated/datetime"/> <classpathentry kind="src" path="Eclipse SWT/emulated/bidi"/> <classpathentry kind="src" path="Eclipse SWT/emulated/tooltip"/> + <classpathentry kind="src" path="Eclipse SWT/emulated/ime"/> <classpathentry kind="src" path="Eclipse SWT Accessibility/emulated"/> <classpathentry kind="src" path="Eclipse SWT Accessibility/common"/> <classpathentry kind="src" path="Eclipse SWT AWT/emulated"/> diff --git a/bundles/org.eclipse.swt/Eclipse SWT/emulated/ime/org/eclipse/swt/widgets/IME.java b/bundles/org.eclipse.swt/Eclipse SWT/emulated/ime/org/eclipse/swt/widgets/IME.java new file mode 100644 index 0000000000..be1e00122c --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT/emulated/ime/org/eclipse/swt/widgets/IME.java @@ -0,0 +1,97 @@ +/******************************************************************************* + * Copyright (c) 2007 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.swt.widgets; + + +import org.eclipse.swt.*; +import org.eclipse.swt.graphics.*; + +public class IME extends Widget { + Canvas parent; + int caretOffset; + int startOffset; + int commitCount; + String text; + int [] ranges; + TextStyle [] styles; + +/** + * Prevents uninitialized instances from being created outside the package. + */ +IME () { +} + +/** + * + * @see SWT + */ +public IME (Canvas parent, int style) { + super (parent, style); + this.parent = parent; + createWidget (); +} + +void createWidget () { + text = ""; + startOffset = -1; + if (parent.getIME () == null) { + parent.setIME (this); + } +} + +public int getCaretOffset () { + checkWidget (); + return startOffset + caretOffset; +} + +public int getCommitCount () { + checkWidget (); + return commitCount; +} + +public int getCompositionOffset () { + checkWidget (); + return startOffset; +} + +public int [] getRanges () { + checkWidget (); + return ranges != null ? ranges : new int [0]; +} + +public TextStyle [] getStyles () { + checkWidget (); + return styles != null ? styles : new TextStyle [0]; +} + +public String getText () { + checkWidget (); + return text; +} + +public boolean getWideCaret() { + return false; +} + +void releaseParent () { + super.releaseParent (); + if (this == parent.getIME ()) parent.setIME (null); +} + +void releaseWidget () { + super.releaseWidget (); + parent = null; + text = null; + styles = null; + ranges = null; +} + +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Canvas.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Canvas.java index 5a6cddb0c9..546669fec0 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Canvas.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Canvas.java @@ -36,6 +36,7 @@ import org.eclipse.swt.graphics.*; */ public class Canvas extends Composite { Caret caret; + IME ime; Canvas () { /* Do nothing */ @@ -119,6 +120,10 @@ public Caret getCaret () { checkWidget(); return caret; } +public IME getIME () { + checkWidget (); + return ime; +} Caret getIMCaret () { return caret; } @@ -134,6 +139,10 @@ void releaseChildren (boolean destroy) { caret.release (false); caret = null; } + if (ime != null) { + ime.release (false); + ime = null; + } super.releaseChildren (destroy); } @@ -265,6 +274,11 @@ public void setFont (Font font) { if (caret != null) caret.setFont (font); super.setFont (font); } +public void setIME (IME ime) { + checkWidget (); + if (ime != null && ime.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT); + this.ime = ime; +} int XExposure (int w, int client_data, int call_data, int continue_to_dispatch) { boolean isFocus = caret != null && caret.isFocusCaret (); if (isFocus) caret.killFocus (); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Caret.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Caret.java index db91b50e34..392e92a80c 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Caret.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Caret.java @@ -36,6 +36,7 @@ public class Caret extends Widget { int blinkRate; Image image; Font font; + int offset; /** * Constructs a new instance of this class given its parent * and a style value describing its behavior and appearance. @@ -179,6 +180,10 @@ public Point getLocation () { checkWidget(); return new Point (x, y); } +public int getOffset () { + checkWidget (); + return offset; +} /** * Returns the receiver's parent, which must be a <code>Canvas</code>. * @@ -407,6 +412,10 @@ public void setLocation (Point location) { if (location == null) error (SWT.ERROR_NULL_ARGUMENT); setLocation (location.x, location.y); } +public void setOffset (int offset) { + checkWidget (); + this.offset = Math.max (0, offset); +} /** * Sets the receiver's size to the point specified by the arguments. * diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Canvas.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Canvas.java index ca8ea676d2..1e83a97cd7 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Canvas.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Canvas.java @@ -35,6 +35,7 @@ import org.eclipse.swt.graphics.*; */ public class Canvas extends Composite { Caret caret; + IME ime; Canvas () { /* Do nothing */ @@ -94,6 +95,11 @@ public Caret getCaret () { return caret; } +public IME getIME () { + checkWidget (); + return ime; +} + int Pt_CB_GOT_FOCUS (int widget, int info) { int result = super.Pt_CB_GOT_FOCUS (widget, info); if (caret != null) caret.setFocus (); @@ -163,6 +169,10 @@ void releaseChildren (boolean destroy) { caret.release (false); caret = null; } + if (ime != null) { + ime.release (false); + ime = null; + } super.releaseChildren (destroy); } @@ -261,4 +271,10 @@ public void setFont (Font font) { if (caret != null) caret.setFont (font); super.setFont (font); } + +public void setIME (IME ime) { + checkWidget (); + if (ime != null && ime.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT); + this.ime = ime; +} } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Caret.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Caret.java index adb7f401ef..4b62d9d34f 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Caret.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Caret.java @@ -36,6 +36,7 @@ public class Caret extends Widget { int blinkRate = 0; Image image; Font font; + int offset; /** * Constructs a new instance of this class given its parent @@ -192,6 +193,11 @@ public Point getLocation () { return new Point (x, y); } +public int getOffset () { + checkWidget (); + return offset; +} + /** * Returns the receiver's parent, which must be a <code>Canvas</code>. * @@ -439,6 +445,11 @@ public void setLocation (Point location) { setLocation (location.x, location.y); } +public void setOffset (int offset) { + checkWidget (); + this.offset = Math.max (0, offset); +} + /** * Sets the receiver's size to the point specified by the arguments. * diff --git a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Canvas.java b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Canvas.java index a4ac8cb2cb..edda48e304 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Canvas.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Canvas.java @@ -37,6 +37,7 @@ import org.eclipse.swt.graphics.*; public class Canvas extends Composite { Caret caret; + IME ime; /** * Prevents uninitialized instances from being created outside the package. @@ -116,12 +117,21 @@ int getCaretHandle () { return 0; } +public IME getIME () { + checkWidget (); + return ime; +} + void releaseChildren (boolean destroy) { super.releaseChildren (destroy); if (caret != null) { caret.release (false); caret = null; } + if (ime != null) { + ime.release (false); + ime = null; + } } /** @@ -252,6 +262,12 @@ public void setFont (Font font) { super.setFont (font); } +public void setIME (IME ime) { + checkWidget (); + if (ime != null && ime.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT); + this.ime = ime; +} + void HandlePreviewGotKeyboardFocus (int sender, int e) { if (!checkEvent (e)) return; super.HandlePreviewGotKeyboardFocus (sender, e); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Caret.java b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Caret.java index fdd54d751c..3fa6bf2aa5 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Caret.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Caret.java @@ -37,6 +37,7 @@ public class Caret extends Widget { boolean isVisible; Image image; Font font; + int offset; /** * Constructs a new instance of this class given its parent @@ -197,6 +198,11 @@ public Point getLocation () { return new Point (x, y); } +public int getOffset () { + checkWidget (); + return offset; +} + /** * Returns the receiver's parent, which must be a <code>Canvas</code>. * @@ -461,6 +467,11 @@ public void setLocation (Point location) { setLocation (location.x, location.y); } +public void setOffset (int offset) { + checkWidget (); + this.offset = Math.max (0, offset); +} + /** * Sets the receiver's size to the point specified by the arguments. * |