view dwt/internal/cocoa/NSBox.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.NSBox;

import dwt.internal.cocoa.CGFloat;
import dwt.internal.cocoa.NSCell;
import dwt.internal.cocoa.NSColor;
import dwt.internal.cocoa.NSFont;
import dwt.internal.cocoa.NSInteger;
import dwt.internal.cocoa.NSRect;
import dwt.internal.cocoa.NSSize;
import dwt.internal.cocoa.NSString;
import dwt.internal.cocoa.NSView;
import dwt.internal.cocoa.OS;
import objc = dwt.internal.objc.runtime;

alias NSUInteger NSBoxType;

enum
{
    NSBoxPrimary = 0,
    NSBoxSecondary = 1,
    NSBoxSeparator = 2,
    NSBoxOldStyle = 3,
    NSBoxCustom = 4
}

enum NSTitlePosition
{
    NSNoTitle = 0,
    NSAboveTop = 1,
    NSAtTop = 2,
    NSBelowTop = 3,
    NSAboveBottom = 4,
    NSAtBottom = 5,
    NSBelowBottom = 6
}

public class NSBox : NSView
{
    public this ()
    {
        super();
    }

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

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

    public NSRect borderRect ()
    {
        NSRect result;
        OS.objc_msgSend_stret(&result, this.id_, OS.sel_borderRect);
        return result;
    }

    public NSBorderType borderType ()
    {
        return cast(NSBorderType) OS.objc_msgSend(this.id_, OS.sel_borderType);
    }

    public CGFloat borderWidth ()
    {
        return cast(CGFloat) OS.objc_msgSend_fpret(this.id_, OS.sel_borderWidth);
    }

    public NSBoxType boxType ()
    {
        return cast(NSBoxType) OS.objc_msgSend(this.id_, OS.sel_boxType);
    }

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

    public NSSize contentViewMargins ()
    {
        NSSize result;
        OS.objc_msgSend_stret(&result, this.id_, OS.sel_contentViewMargins);
        return result;
    }

    public CGFloat cornerRadius ()
    {
        return cast(CGFloat) OS.objc_msgSend_fpret(this.id_, OS.sel_cornerRadius);
    }

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

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

    public void setBorderColor (NSColor borderColor)
    {
        OS.objc_msgSend(this.id_, OS.sel_setBorderColor_1, borderColor !is null ? borderColor.id_ : null);
    }

    public void setBorderType (NSBorderType aType)
    {
        OS.objc_msgSend(this.id_, OS.sel_setBorderType_1, aType);
    }

    public void setBorderWidth (CGFloat borderWidth)
    {
        OS.objc_msgSend(this.id_, OS.sel_setBorderWidth_1, borderWidth);
    }

    public void setBoxType (NSBoxType boxType)
    {
        OS.objc_msgSend(this.id_, OS.sel_setBoxType_1, boxType);
    }

    public void setContentView (NSView aView)
    {
        OS.objc_msgSend(this.id_, OS.sel_setContentView_1, aView !is null ? aView.id_ : null);
    }

    public void setContentViewMargins (NSSize offsetSize)
    {
        OS.objc_msgSend(this.id_, OS.sel_setContentViewMargins_1, offsetSize);
    }

    public void setCornerRadius (CGFloat cornerRadius)
    {
        OS.objc_msgSend(this.id_, OS.sel_setCornerRadius_1, cornerRadius);
    }

    public void setFillColor (NSColor fillColor)
    {
        OS.objc_msgSend(this.id_, OS.sel_setFillColor_1, fillColor !is null ? fillColor.id_ : null);
    }

    public void setFrameFromContentFrame (NSRect contentFrame)
    {
        OS.objc_msgSend(this.id_, OS.sel_setFrameFromContentFrame_1, contentFrame);
    }

    public void setTitle (NSString aString)
    {
        OS.objc_msgSend(this.id_, OS.sel_setTitle_1, aString !is null ? aString.id_ : null);
    }

    public void setTitleFont (NSFont fontObj)
    {
        OS.objc_msgSend(this.id_, OS.sel_setTitleFont_1, fontObj !is null ? fontObj.id_ : null);
    }

    public void setTitlePosition (NSTitlePosition aPosition)
    {
        OS.objc_msgSend(this.id_, OS.sel_setTitlePosition_1, aPosition);
    }

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

    public void setTransparent (bool flag)
    {
        OS.objc_msgSend(this.id_, OS.sel_setTransparent_1, flag);
    }

    public void sizeToFit ()
    {
        OS.objc_msgSend(this.id_, OS.sel_sizeToFit);
    }

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

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

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

    public NSTitlePosition titlePosition ()
    {
        return cast(NSTitlePosition) OS.objc_msgSend(this.id_, OS.sel_titlePosition);
    }

    public NSRect titleRect ()
    {
        NSRect result;
        OS.objc_msgSend_stret(&result, this.id_, OS.sel_titleRect);
        return result;
    }
}