Mercurial > projects > dwt-mac
diff dwt/internal/cocoa/NSPopUpButton.d @ 45:d8635bb48c7c
Merge with SWT 3.5
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Mon, 01 Dec 2008 17:07:00 +0100 |
parents | f565d3a95c0a |
children | 62202ce0039f |
line wrap: on
line diff
--- a/dwt/internal/cocoa/NSPopUpButton.d Tue Oct 21 15:20:04 2008 +0200 +++ b/dwt/internal/cocoa/NSPopUpButton.d Mon Dec 01 17:07:00 2008 +0100 @@ -1,230 +1,106 @@ /******************************************************************************* - * Copyright (c) 2007 IBM Corporation and others. + * Copyright (c) 2000, 2008 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 + * IBM Corporation - initial API and implementation * * Port to the D programming language: - * Jacob Carlborg <jacob.carlborg@gmail.com> + * Jacob Carlborg <doob@me.com> *******************************************************************************/ module dwt.internal.cocoa.NSPopUpButton; -import dwt.internal.cocoa.id; -import dwt.internal.cocoa.NSArray; +import dwt.dwthelper.utils; +import cocoa = dwt.internal.cocoa.id; import dwt.internal.cocoa.NSButton; -import dwt.internal.cocoa.NSInteger; import dwt.internal.cocoa.NSMenu; import dwt.internal.cocoa.NSMenuItem; import dwt.internal.cocoa.NSRect; import dwt.internal.cocoa.NSString; import dwt.internal.cocoa.OS; +import dwt.internal.objc.cocoa.Cocoa; import objc = dwt.internal.objc.runtime; -public class NSPopUpButton : NSButton -{ - - public this () - { - super(); - } +public class NSPopUpButton : NSButton { - 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 this() { + super(); +} - public bool autoenablesItems () - { - return OS.objc_msgSend(this.id_, OS.sel_autoenablesItems) !is null; - } - - public NSInteger indexOfItem (NSMenuItem item) - { - return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_indexOfItem_1, item !is null ? item.id_ : null); - } +public this(objc.id id) { + super(id); +} - public NSInteger indexOfItemWithRepresentedObject (id obj) - { - return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_indexOfItemWithRepresentedObject_1, obj !is null ? obj.id_ : null); - } +public this(cocoa.id id) { + super(id); +} - 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 indexOfSelectedItem() { + return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_indexOfSelectedItem); +} - 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 NSPopUpButton initWithFrame(NSRect buttonFrame, bool flag) { + objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithFrame_pullsDown_, buttonFrame, flag); + return result is this.id ? this : (result !is null ? new NSPopUpButton(result) : null); +} - public NSPopUpButton initWithFrame (NSRect buttonFrame, bool flag) - { - objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithFrame_1pullsDown_1, buttonFrame, flag); - 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 NSMenuItem itemAtIndex(NSInteger index) { + objc.id result = OS.objc_msgSend(this.id, OS.sel_itemAtIndex_, index); + return result !is null ? new NSMenuItem(result) : null; +} - 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_, index); + return result !is null ? new NSString(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 NSMenu menu() { + objc.id result = OS.objc_msgSend(this.id, OS.sel_menu); + return result !is null ? new NSMenu(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 NSInteger numberOfItems() { + return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_numberOfItems); +} - 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 NSRectEdge preferredEdge () - { - return cast(NSRectEdge) OS.objc_msgSend(this.id_, OS.sel_preferredEdge); - } +public void removeAllItems() { + OS.objc_msgSend(this.id, OS.sel_removeAllItems); +} - 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 removeItemAtIndex(NSInteger index) { + OS.objc_msgSend(this.id, OS.sel_removeItemAtIndex_, 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_, item !is null ? item.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 void selectItemAtIndex(NSInteger index) { + OS.objc_msgSend(this.id, OS.sel_selectItemAtIndex_, 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 void setAutoenablesItems(bool flag) { + OS.objc_msgSend(this.id, OS.sel_setAutoenablesItems_, flag); +} - public NSMenuItem selectedItem () - { - objc.id result = OS.objc_msgSend(this.id_, OS.sel_selectedItem); - return result !is null ? new NSMenuItem(result) : null; - } - - 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 setPullsDown(bool flag) { + OS.objc_msgSend(this.id, OS.sel_setPullsDown_, flag); +} - 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 NSString titleOfSelectedItem() { + objc.id result = OS.objc_msgSend(this.id, OS.sel_titleOfSelectedItem); + return result !is null ? new NSString(result) : null; +} - public void setTitle (NSString aString) - { - OS.objc_msgSend(this.id_, OS.sel_setTitle_1, aString !is null ? aString.id_ : null); - } +public static objc.Class cellClass() { + return cast(objc.Calss) OS.objc_msgSend(OS.class_NSPopUpButton, OS.sel_cellClass); +} - 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 static void setCellClass(objc.Class factoryId) { + OS.objc_msgSend(OS.class_NSPopUpButton, OS.sel_setCellClass_, factoryId); +} }