view dwt/internal/cocoa/NSButtonCell.d @ 37:642f460a0908

Fixed a lot of compile errors, a "hello world" app compiles now
author Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
date Fri, 10 Oct 2008 12:29:48 +0200
parents f565d3a95c0a
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.NSButtonCell;

import dwt.internal.cocoa.CGFloat;
import dwt.internal.cocoa.id;
import dwt.internal.cocoa.NSActionCell;
import dwt.internal.cocoa.NSAttributedString;
import dwt.internal.cocoa.NSColor;
import dwt.internal.cocoa.NSEvent;
import dwt.internal.cocoa.NSFont;
import dwt.internal.cocoa.NSImage;
import dwt.internal.cocoa.NSInteger;
import dwt.internal.cocoa.NSRect;
import dwt.internal.cocoa.NSSound;
import dwt.internal.cocoa.NSString;
import dwt.internal.cocoa.NSView;
import dwt.internal.cocoa.OS;
import objc = dwt.internal.objc.runtime;

enum NSBezelStyle : NSUInteger
{
    NSRoundedBezelStyle           = 1,
    NSRegularSquareBezelStyle     = 2,
    NSThickSquareBezelStyle       = 3,
    NSThickerSquareBezelStyle     = 4,
    NSDisclosureBezelStyle        = 5,
    NSShadowlessSquareBezelStyle  = 6,
    NSCircularBezelStyle          = 7,
    NSTexturedSquareBezelStyle    = 8,
    NSHelpButtonBezelStyle        = 9,
    NSSmallSquareBezelStyle       = 10,
    NSTexturedRoundedBezelStyle   = 11,
    NSRoundRectBezelStyle         = 12,
    NSRecessedBezelStyle          = 13,
    NSRoundedDisclosureBezelStyle = 14,
}

alias NSBezelStyle.NSRoundedBezelStyle NSRoundedBezelStyle;
alias NSBezelStyle.NSRegularSquareBezelStyle NSRegularSquareBezelStyle;
alias NSBezelStyle.NSThickSquareBezelStyle NSThickSquareBezelStyle;
alias NSBezelStyle.NSThickerSquareBezelStyle NSThickerSquareBezelStyle;
alias NSBezelStyle.NSDisclosureBezelStyle NSDisclosureBezelStyle;
alias NSBezelStyle.NSShadowlessSquareBezelStyle NSShadowlessSquareBezelStyle;
alias NSBezelStyle.NSCircularBezelStyle NSCircularBezelStyle;
alias NSBezelStyle.NSTexturedSquareBezelStyle NSTexturedSquareBezelStyle;
alias NSBezelStyle.NSHelpButtonBezelStyle NSHelpButtonBezelStyle;
alias NSBezelStyle.NSSmallSquareBezelStyle NSSmallSquareBezelStyle;
alias NSBezelStyle.NSTexturedRoundedBezelStyle NSTexturedRoundedBezelStyle;
alias NSBezelStyle.NSRoundRectBezelStyle NSRoundRectBezelStyle;
alias NSBezelStyle.NSRecessedBezelStyle NSRecessedBezelStyle;
alias NSBezelStyle.NSRoundedDisclosureBezelStyle NSRoundedDisclosureBezelStyle;

enum NSButtonType : NSUInteger
{
    NSMomentaryLightButton = 0,
    NSPushOnPushOffButton = 1,
    NSToggleButton = 2,
    NSSwitchButton = 3,
    NSRadioButton = 4,
    NSMomentaryChangeButton = 5,
    NSOnOffButton = 6,
    NSMomentaryPushInButton = 7,
    NSMomentaryPushButton = 0,
    NSMomentaryLight = 7
}

alias NSButtonType.NSMomentaryLightButton NSMomentaryLightButton;
alias NSButtonType.NSPushOnPushOffButton NSPushOnPushOffButton;
alias NSButtonType.NSToggleButton NSToggleButton;
alias NSButtonType.NSSwitchButton NSSwitchButton;
alias NSButtonType.NSRadioButton NSRadioButton;
alias NSButtonType.NSMomentaryChangeButton NSMomentaryChangeButton;
alias NSButtonType.NSOnOffButton NSOnOffButton;
alias NSButtonType.NSMomentaryPushInButton NSMomentaryPushInButton;
alias NSButtonType.NSMomentaryPushButton NSMomentaryPushButton;
alias NSButtonType.NSMomentaryLight NSMomentaryLight;

public class NSButtonCell : NSActionCell
{

    public this ()
    {
        super();
    }

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

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

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

    public NSUInteger alternateMnemonicLocation ()
    {
        return cast(NSUInteger) OS.objc_msgSend(this.id_, OS.sel_alternateMnemonicLocation);
    }

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

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

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

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

    public objc.id bezelStyle ()
    {
        return OS.objc_msgSend(this.id_, OS.sel_bezelStyle);
    }

    public void drawBezelWithFrame (NSRect frame, NSView controlView)
    {
        OS.objc_msgSend(this.id_, OS.sel_drawBezelWithFrame_1inView_1, frame, controlView !is null ? controlView.id_ : null);
    }

    public void drawImage (NSImage image, NSRect frame, NSView controlView)
    {
        OS.objc_msgSend(this.id_, OS.sel_drawImage_1withFrame_1inView_1, image !is null ? image.id_ : null, frame,
                controlView !is null ? controlView.id_ : null);
    }

    public NSRect drawTitle (NSAttributedString title, NSRect frame, NSView controlView)
    {
        NSRect result;
        OS.objc_msgSend_stret(&result, this.id_, OS.sel_drawTitle_1withFrame_1inView_1, title !is null ? title.id_ : null, frame,
                controlView !is null ? controlView.id_ : null);
        return result;
    }

    public void getPeriodicDelay (float* delay, float* interval)
    {
        OS.objc_msgSend(this.id_, OS.sel_getPeriodicDelay_1interval_1, delay, interval);
    }

    public objc.id gradientType ()
    {
        return OS.objc_msgSend(this.id_, OS.sel_gradientType);
    }

    public NSInteger highlightsBy ()
    {
        return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_highlightsBy);
    }

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

    public objc.id imagePosition ()
    {
        return OS.objc_msgSend(this.id_, OS.sel_imagePosition);
    }

    public objc.id imageScaling ()
    {
        return OS.objc_msgSend(this.id_, OS.sel_imageScaling);
    }

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

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

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

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

    public NSUInteger keyEquivalentModifierMask ()
    {
        return cast(NSUInteger) OS.objc_msgSend(this.id_, OS.sel_keyEquivalentModifierMask);
    }

    public void mouseEntered (NSEvent event)
    {
        OS.objc_msgSend(this.id_, OS.sel_mouseEntered_1, event !is null ? event.id_ : null);
    }

    public void mouseExited (NSEvent event)
    {
        OS.objc_msgSend(this.id_, OS.sel_mouseExited_1, event !is null ? event.id_ : null);
    }

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

    public void setAlternateImage (NSImage image)
    {
        OS.objc_msgSend(this.id_, OS.sel_setAlternateImage_1, image !is null ? image.id_ : null);
    }

    public void setAlternateMnemonicLocation (NSUInteger location)
    {
        OS.objc_msgSend(this.id_, OS.sel_setAlternateMnemonicLocation_1, location);
    }

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

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

    public void setAttributedAlternateTitle (NSAttributedString obj)
    {
        OS.objc_msgSend(this.id_, OS.sel_setAttributedAlternateTitle_1, obj !is null ? obj.id_ : null);
    }

    public void setAttributedTitle (NSAttributedString obj)
    {
        OS.objc_msgSend(this.id_, OS.sel_setAttributedTitle_1, obj !is null ? obj.id_ : null);
    }

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

    public void setBezelStyle (objc.id bezelStyle)
    {
        OS.objc_msgSend(this.id_, OS.sel_setBezelStyle_1, bezelStyle);
    }

    public void setButtonType (objc.id aType)
    {
        OS.objc_msgSend(this.id_, OS.sel_setButtonType_1, aType);
    }

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

    public void setGradientType (objc.id type)
    {
        OS.objc_msgSend(this.id_, OS.sel_setGradientType_1, type);
    }

    public void setHighlightsBy (NSInteger aType)
    {
        OS.objc_msgSend(this.id_, OS.sel_setHighlightsBy_1, aType);
    }

    public void setImageDimsWhenDisabled (bool flag)
    {
        OS.objc_msgSend(this.id_, OS.sel_setImageDimsWhenDisabled_1, flag);
    }

    public void setImagePosition (objc.id aPosition)
    {
        OS.objc_msgSend(this.id_, OS.sel_setImagePosition_1, aPosition);
    }

    public void setImageScaling (objc.id scaling)
    {
        OS.objc_msgSend(this.id_, OS.sel_setImageScaling_1, scaling);
    }

    public void setKeyEquivalent (NSString aKeyEquivalent)
    {
        OS.objc_msgSend(this.id_, OS.sel_setKeyEquivalent_1, aKeyEquivalent !is null ? aKeyEquivalent.id_ : null);
    }

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

    public void setKeyEquivalentFont_size_ (NSString fontName, CGFloat fontSize)
    {
        OS.objc_msgSend(this.id_, OS.sel_setKeyEquivalentFont_1size_1, fontName !is null ? fontName.id_ : null, fontSize);
    }

    public void setKeyEquivalentModifierMask (NSUInteger mask)
    {
        OS.objc_msgSend(this.id_, OS.sel_setKeyEquivalentModifierMask_1, mask);
    }

    public void setPeriodicDelay (float delay, float interval)
    {
        OS.objc_msgSend(this.id_, OS.sel_setPeriodicDelay_1interval_1, delay, interval);
    }

    public void setShowsBorderOnlyWhileMouseInside (bool show)
    {
        OS.objc_msgSend(this.id_, OS.sel_setShowsBorderOnlyWhileMouseInside_1, show);
    }

    public void setShowsStateBy (NSInteger aType)
    {
        OS.objc_msgSend(this.id_, OS.sel_setShowsStateBy_1, aType);
    }

    public void setSound (NSSound aSound)
    {
        OS.objc_msgSend(this.id_, OS.sel_setSound_1, aSound !is null ? aSound.id_ : null);
    }

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

    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 bool showsBorderOnlyWhileMouseInside ()
    {
        return OS.objc_msgSend(this.id_, OS.sel_showsBorderOnlyWhileMouseInside) !is null;
    }

    public NSInteger showsStateBy ()
    {
        return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_showsStateBy);
    }

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

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

}