view dwt/widgets/IME.d @ 3:649b8e223d5a

fix extends
author Frank Benoit <benoit@tionex.de>
date Wed, 27 Aug 2008 13:48:25 +0200
parents 380af2bdd8e5
children 1a8b3cb347e0
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
 *******************************************************************************/
module dwt.widgets.IME;

import dwt.dwthelper.utils;


import dwt.DWT;
import dwt.graphics.TextStyle;

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.
 */
IME () {
}

/**
 * 
 * @see DWT
 */
public IME (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;
}

}