view dwt/internal/cocoa/NSTextField.d @ 13:f565d3a95c0a

Ported dwt.internal
author Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
date Fri, 22 Aug 2008 16:46:34 +0200
parents 8b48be5454ce
children d8635bb48c7c
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.internal.cocoa.NSTextField;

import dwt.internal.cocoa.id;
import dwt.internal.cocoa.NSColor;
import dwt.internal.cocoa.NSControl;
import dwt.internal.cocoa.NSNotification;
import dwt.internal.cocoa.NSString;
import dwt.internal.cocoa.NSText;
import dwt.internal.cocoa.NSTextFieldCell : NSTextFieldBezelStyle;
import dwt.internal.cocoa.OS;
import objc = dwt.internal.objc.runtime;

public class NSTextField : NSControl
{

    public this ()
    {
        super();
    }

    public this (objc.id id)
    {
        super(id);
    }

    public bool acceptsFirstResponder ()
    {
        return OS.objc_msgSend(this.id_, OS.sel_acceptsFirstResponder) !is null;
    }

    public bool allowsEditingTextAttributes ()
    {
        return OS.objc_msgSend(this.id_, OS.sel_allowsEditingTextAttributes) !is null;
    }

    public NSColor backgroundColor ()
    {
        objc.id result = OS.objc_msgSend(this.id_, OS.sel_backgroundColor);
        return result !is null ? new NSColor(result) : null;
    }

    public NSTextFieldBezelStyle bezelStyle ()
    {
        return cast(NSTextFieldBezelStyle) OS.objc_msgSend(this.id_, OS.sel_bezelStyle);
    }

    public id delegatee ()
    {
        objc.id result = OS.objc_msgSend(this.id_, OS.sel_delegate);
        return result !is null ? new id(result) : null;
    }

    public bool drawsBackground ()
    {
        return OS.objc_msgSend(this.id_, OS.sel_drawsBackground) !is null;
    }

    public bool importsGraphics ()
    {
        return OS.objc_msgSend(this.id_, OS.sel_importsGraphics) !is null;
    }

    public bool isBezeled ()
    {
        return OS.objc_msgSend(this.id_, OS.sel_isBezeled) !is null;
    }

    public bool isBordered ()
    {
        return OS.objc_msgSend(this.id_, OS.sel_isBordered) !is null;
    }

    public bool isEditable ()
    {
        return OS.objc_msgSend(this.id_, OS.sel_isEditable) !is null;
    }

    public bool isSelectable ()
    {
        return OS.objc_msgSend(this.id_, OS.sel_isSelectable) !is null;
    }

    public void selectText (id sender)
    {
        OS.objc_msgSend(this.id_, OS.sel_selectText_1, sender !is null ? sender.id_ : null);
    }

    public void setAllowsEditingTextAttributes (bool flag)
    {
        OS.objc_msgSend(this.id_, OS.sel_setAllowsEditingTextAttributes_1, flag);
    }

    public void setBackgroundColor (NSColor color)
    {
        OS.objc_msgSend(this.id_, OS.sel_setBackgroundColor_1, color !is null ? color.id_ : null);
    }

    public void setBezelStyle (NSTextFieldBezelStyle style)
    {
        OS.objc_msgSend(this.id_, OS.sel_setBezelStyle_1, style);
    }

    public void setBezeled (bool flag)
    {
        OS.objc_msgSend(this.id_, OS.sel_setBezeled_1, flag);
    }

    public void setBordered (bool flag)
    {
        OS.objc_msgSend(this.id_, OS.sel_setBordered_1, flag);
    }

    public void setDelegate (id anObject)
    {
        OS.objc_msgSend(this.id_, OS.sel_setDelegate_1, anObject !is null ? anObject.id_ : null);
    }

    public void setDrawsBackground (bool flag)
    {
        OS.objc_msgSend(this.id_, OS.sel_setDrawsBackground_1, flag);
    }

    public void setEditable (bool flag)
    {
        OS.objc_msgSend(this.id_, OS.sel_setEditable_1, flag);
    }

    public void setImportsGraphics (bool flag)
    {
        OS.objc_msgSend(this.id_, OS.sel_setImportsGraphics_1, flag);
    }

    public void setSelectable (bool flag)
    {
        OS.objc_msgSend(this.id_, OS.sel_setSelectable_1, flag);
    }

    public void setTextColor (NSColor color)
    {
        OS.objc_msgSend(this.id_, OS.sel_setTextColor_1, color !is null ? color.id_ : null);
    }

    public void setTitleWithMnemonic (NSString stringWithAmpersand)
    {
        OS.objc_msgSend(this.id_, OS.sel_setTitleWithMnemonic_1, stringWithAmpersand !is null ? stringWithAmpersand.id_ : null);
    }

    public NSColor textColor ()
    {
        objc.id result = OS.objc_msgSend(this.id_, OS.sel_textColor);
        return result !is null ? new NSColor(result) : null;
    }

    public void textDidBeginEditing (NSNotification notification)
    {
        OS.objc_msgSend(this.id_, OS.sel_textDidBeginEditing_1, notification !is null ? notification.id_ : null);
    }

    public void textDidChange (NSNotification notification)
    {
        OS.objc_msgSend(this.id_, OS.sel_textDidChange_1, notification !is null ? notification.id_ : null);
    }

    public void textDidEndEditing (NSNotification notification)
    {
        OS.objc_msgSend(this.id_, OS.sel_textDidEndEditing_1, notification !is null ? notification.id_ : null);
    }

    public bool textShouldBeginEditing (NSText textObject)
    {
        return OS.objc_msgSend(this.id_, OS.sel_textShouldBeginEditing_1, textObject !is null ? textObject.id_ : null) !is null;
    }

    public bool textShouldEndEditing (NSText textObject)
    {
        return OS.objc_msgSend(this.id_, OS.sel_textShouldEndEditing_1, textObject !is null ? textObject.id_ : null) !is null;
    }

}