view dwt/internal/cocoa/NSPopUpButtonCell.d @ 1:8b48be5454ce

The internal cocoa classes compile now
author Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
date Tue, 19 Aug 2008 17:35:17 +0200
parents 380af2bdd8e5
children f565d3a95c0a
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.NSPopUpButtonCell;

import dwt.internal.cocoa.id;
import dwt.internal.cocoa.NSArray;
import dwt.internal.cocoa.NSInteger;
import dwt.internal.cocoa.NSMenu;
import dwt.internal.cocoa.NSMenuItem;
import dwt.internal.cocoa.NSMenuItemCell;
import dwt.internal.cocoa.NSRect;
import dwt.internal.cocoa.NSString;
import dwt.internal.cocoa.NSView;
import dwt.internal.cocoa.OS;
import objc = dwt.internal.objc.runtime;

enum NSPopUpArrowPosition
{
    NSPopUpNoArrow = 0,
    NSPopUpArrowAtCenter = 1,
    NSPopUpArrowAtBottom = 2
}

alias NSPopUpArrowPosition.NSPopUpNoArrow NSPopUpNoArrow;
alias NSPopUpArrowPosition.NSPopUpArrowAtCenter NSPopUpArrowAtCenter;
alias NSPopUpArrowPosition.NSPopUpArrowAtBottom NSPopUpArrowAtBottom;

public class NSPopUpButtonCell : NSMenuItemCell
{

    public this ()
    {
        super();
    }

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

    public void addItemWithTitle (NSString title)
    {
        OS.objc_msgSend(this.id_, OS.sel_addItemWithTitle_1, title !is null ? title.id_ : null);
    }

    public void addItemsWithTitles (NSArray itemTitles)
    {
        OS.objc_msgSend(this.id_, OS.sel_addItemsWithTitles_1, itemTitles !is null ? itemTitles.id_ : null);
    }

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

    public NSPopUpArrowPosition arrowPosition ()
    {
        return cast(NSPopUpArrowPosition) OS.objc_msgSend(this.id_, OS.sel_arrowPosition);
    }

    public void attachPopUpWithFrame (NSRect cellFrame, NSView controlView)
    {
        OS.objc_msgSend(this.id_, OS.sel_attachPopUpWithFrame_1inView_1, cellFrame, controlView !is null ? controlView.id_ : null);
    }

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

    public void dismissPopUp ()
    {
        OS.objc_msgSend(this.id_, OS.sel_dismissPopUp);
    }

    public NSInteger indexOfItem (NSMenuItem item)
    {
        return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_indexOfItem_1, item !is null ? item.id_ : null);
    }

    public NSInteger indexOfItemWithRepresentedObject (id obj)
    {
        return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_indexOfItemWithRepresentedObject_1, obj !is null ? obj.id_ : null);
    }

    public NSInteger indexOfItemWithTag (NSInteger tag)
    {
        return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_indexOfItemWithTag_1, tag);
    }

    public NSInteger indexOfItemWithTarget (id target, objc.SEL actionSelector)
    {
        return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_indexOfItemWithTarget_1andAction_1, target !is null ? target.id_ : null, actionSelector);
    }

    public NSInteger indexOfItemWithTitle (NSString title)
    {
        return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_indexOfItemWithTitle_1, title !is null ? title.id_ : null);
    }

    public NSInteger indexOfSelectedItem ()
    {
        return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_indexOfSelectedItem);
    }

    public NSPopUpButtonCell initTextCell (NSString stringValue, bool pullDown)
    {
        objc.id result = OS.objc_msgSend(this.id_, OS.sel_initTextCell_1pullsDown_1, stringValue !is null ? stringValue.id_ : null, pullDown);
        return result !is null ? this : null;
    }

    public void insertItemWithTitle (NSString title, NSInteger index)
    {
        OS.objc_msgSend(this.id_, OS.sel_insertItemWithTitle_1atIndex_1, title !is null ? title.id_ : null, index);
    }

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

    public NSMenuItem itemAtIndex (NSInteger index)
    {
        objc.id result = OS.objc_msgSend(this.id_, OS.sel_itemAtIndex_1, index);
        return result !is null ? new NSMenuItem(result) : null;
    }

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

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

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

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

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

    public NSInteger numberOfItems ()
    {
        return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_numberOfItems);
    }

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

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

    public NSRectEdge preferredEdge ()
    {
        return cast(NSRectEdge) OS.objc_msgSend(this.id_, OS.sel_preferredEdge);
    }

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

    public void removeAllItems ()
    {
        OS.objc_msgSend(this.id_, OS.sel_removeAllItems);
    }

    public void removeItemAtIndex (NSInteger index)
    {
        OS.objc_msgSend(this.id_, OS.sel_removeItemAtIndex_1, index);
    }

    public void removeItemWithTitle (NSString title)
    {
        OS.objc_msgSend(this.id_, OS.sel_removeItemWithTitle_1, title !is null ? title.id_ : null);
    }

    public void selectItem (NSMenuItem item)
    {
        OS.objc_msgSend(this.id_, OS.sel_selectItem_1, item !is null ? item.id_ : null);
    }

    public void selectItemAtIndex (NSInteger index)
    {
        OS.objc_msgSend(this.id_, OS.sel_selectItemAtIndex_1, index);
    }

    public bool selectItemWithTag (NSInteger tag)
    {
        return OS.objc_msgSend(this.id_, OS.sel_selectItemWithTag_1, tag) !is null;
    }

    public void selectItemWithTitle (NSString title)
    {
        OS.objc_msgSend(this.id_, OS.sel_selectItemWithTitle_1, title !is null ? title.id_ : null);
    }

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

    public void setAltersStateOfSelectedItem (bool flag)
    {
        OS.objc_msgSend(this.id_, OS.sel_setAltersStateOfSelectedItem_1, flag);
    }

    public void setArrowPosition (NSPopUpArrowPosition position)
    {
        OS.objc_msgSend(this.id_, OS.sel_setArrowPosition_1, position);
    }

    public void setAutoenablesItems (bool flag)
    {
        OS.objc_msgSend(this.id_, OS.sel_setAutoenablesItems_1, flag);
    }

    public void setMenu (NSMenu menu)
    {
        OS.objc_msgSend(this.id_, OS.sel_setMenu_1, menu !is null ? menu.id_ : null);
    }

    public void setObjectValue (id obj)
    {
        OS.objc_msgSend(this.id_, OS.sel_setObjectValue_1, obj !is null ? obj.id_ : null);
    }

    public void setPreferredEdge (NSRectEdge edge)
    {
        OS.objc_msgSend(this.id_, OS.sel_setPreferredEdge_1, edge);
    }

    public void setPullsDown (bool flag)
    {
        OS.objc_msgSend(this.id_, OS.sel_setPullsDown_1, flag);
    }

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

    public void setUsesItemFromMenu (bool flag)
    {
        OS.objc_msgSend(this.id_, OS.sel_setUsesItemFromMenu_1, flag);
    }

    public void synchronizeTitleAndSelectedItem ()
    {
        OS.objc_msgSend(this.id_, OS.sel_synchronizeTitleAndSelectedItem);
    }

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

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

}