Mercurial > projects > dwt-mac
view dwt/widgets/IME.d @ 24:d4399516bdc2
Ported dwt.widgets.IME
author | Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com> |
---|---|
date | Mon, 08 Sep 2008 17:41:09 +0200 |
parents | 1a8b3cb347e0 |
children | db5a898b2119 |
line wrap: on
line source
/******************************************************************************* * 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 * * Port to the D programming language: * Jacob Carlborg <jacob.carlborg@gmail.com> *******************************************************************************/ module dwt.widgets.IME; import dwt.DWT; import dwt.graphics.TextStyle; import dwt.dwthelper.utils; public class IME : Widget { Canvas parent; int caretOffset; int startOffset; int commitCount; String text; int [] ranges; TextStyle [] styles; /** * Prevents uninitialized instances from being created outside the package. */ this () { } /** * * @see DWT */ public this (Canvas parent, int style) { super (parent, style); this.parent = parent; createWidget (); } void createWidget () { text = ""; startOffset = -1; if (parent.getIME () is 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 !is null ? ranges : new int [0]; } public TextStyle [] getStyles () { checkWidget (); return styles !is null ? styles : new TextStyle [0]; } public String getText () { checkWidget (); return text; } public bool getWideCaret() { return false; } void releaseParent () { super.releaseParent (); if (this is parent.getIME ()) parent.setIME (null); } void releaseWidget () { super.releaseWidget (); parent = null; text = null; styles = null; ranges = null; } }