comparison dwt/internal/cocoa/NSComboBox.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
comparison
equal deleted inserted replaced
44:ca5e494f2bbf 45:d8635bb48c7c
1 /******************************************************************************* 1 /*******************************************************************************
2 * Copyright (c) 2007 IBM Corporation and others. 2 * Copyright (c) 2000, 2008 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials 3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0 4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at 5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html 6 * http://www.eclipse.org/legal/epl-v10.html
7 * 7 *
8 * Contributors: 8 * Contributors:
9 * IBM Corporation - initial API and implementation 9 * IBM Corporation - initial API and implementation
10 * 10 *
11 * Port to the D programming language: 11 * Port to the D programming language:
12 * Jacob Carlborg <jacob.carlborg@gmail.com> 12 * Jacob Carlborg <doob@me.com>
13 *******************************************************************************/ 13 *******************************************************************************/
14 module dwt.internal.cocoa.NSComboBox; 14 module dwt.internal.cocoa.NSComboBox;
15 15
16 import dwt.internal.cocoa.CGFloat; 16 import dwt.dwthelper.utils;
17 import dwt.internal.cocoa.id; 17 import cocoa = dwt.internal.cocoa.id;
18 import dwt.internal.cocoa.NSArray;
19 import dwt.internal.cocoa.NSInteger;
20 import dwt.internal.cocoa.NSSize;
21 import dwt.internal.cocoa.NSTextField; 18 import dwt.internal.cocoa.NSTextField;
22 import dwt.internal.cocoa.OS; 19 import dwt.internal.cocoa.OS;
20 import dwt.internal.objc.cocoa.Cocoa;
23 import objc = dwt.internal.objc.runtime; 21 import objc = dwt.internal.objc.runtime;
24 22
25 public class NSComboBox : NSTextField 23 public class NSComboBox : NSTextField {
26 {
27 24
28 public this () 25 public this() {
29 { 26 super();
30 super(); 27 }
31 }
32 28
33 public this (objc.id id) 29 public this(objc.id id) {
34 { 30 super(id);
35 super(id); 31 }
36 }
37 32
38 public void addItemWithObjectValue (id object) 33 public this(cocoa.id id) {
39 { 34 super(id);
40 OS.objc_msgSend(this.id_, OS.sel_addItemWithObjectValue_1, object !is null ? object.id_ : null); 35 }
41 }
42 36
43 public void addItemsWithObjectValues (NSArray objects) 37 public void addItemWithObjectValue(cocoa.id object) {
44 { 38 OS.objc_msgSend(this.id, OS.sel_addItemWithObjectValue_, object !is null ? object.id : null);
45 OS.objc_msgSend(this.id_, OS.sel_addItemsWithObjectValues_1, objects !is null ? objects.id_ : null); 39 }
46 }
47 40
48 public bool completes () 41 public void deselectItemAtIndex(NSInteger index) {
49 { 42 OS.objc_msgSend(this.id, OS.sel_deselectItemAtIndex_, index);
50 return OS.objc_msgSend(this.id_, OS.sel_completes) !is null; 43 }
51 }
52 44
53 public id dataSource () 45 public NSInteger indexOfSelectedItem() {
54 { 46 return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_indexOfSelectedItem);
55 objc.id result = OS.objc_msgSend(this.id_, OS.sel_dataSource); 47 }
56 return result !is null ? new id(result) : null;
57 }
58 48
59 public void deselectItemAtIndex (NSInteger index) 49 public void insertItemWithObjectValue(cocoa.id object, NSInteger index) {
60 { 50 OS.objc_msgSend(this.id, OS.sel_insertItemWithObjectValue_atIndex_, object !is null ? object.id : null, index);
61 OS.objc_msgSend(this.id_, OS.sel_deselectItemAtIndex_1, index); 51 }
62 }
63 52
64 public bool hasVerticalScroller () 53 public cocoa.id itemObjectValueAtIndex(NSInteger index) {
65 { 54 objc.id result = OS.objc_msgSend(this.id, OS.sel_itemObjectValueAtIndex_, index);
66 return OS.objc_msgSend(this.id_, OS.sel_hasVerticalScroller) !is null; 55 return result !is null ? new cocoa.id(result) : null;
67 } 56 }
68 57
69 public NSInteger indexOfItemWithObjectValue (id object) 58 public NSInteger numberOfItems() {
70 { 59 return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_numberOfItems);
71 return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_indexOfItemWithObjectValue_1, object !is null ? object.id_ : null); 60 }
72 }
73 61
74 public NSInteger indexOfSelectedItem () 62 public NSInteger numberOfVisibleItems() {
75 { 63 return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_numberOfVisibleItems);
76 return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_indexOfSelectedItem); 64 }
77 }
78 65
79 public void insertItemWithObjectValue (id object, NSInteger index) 66 public void removeAllItems() {
80 { 67 OS.objc_msgSend(this.id, OS.sel_removeAllItems);
81 OS.objc_msgSend(this.id_, OS.sel_insertItemWithObjectValue_1atIndex_1, object !is null ? object.id_ : null, index); 68 }
82 }
83 69
84 public NSSize intercellSpacing () 70 public void removeItemAtIndex(NSInteger index) {
85 { 71 OS.objc_msgSend(this.id, OS.sel_removeItemAtIndex_, index);
86 NSSize result; 72 }
87 OS.objc_msgSend_stret(&result, this.id_, OS.sel_intercellSpacing);
88 return result;
89 }
90 73
91 public bool isButtonBordered () 74 public void selectItemAtIndex(NSInteger index) {
92 { 75 OS.objc_msgSend(this.id, OS.sel_selectItemAtIndex_, index);
93 return OS.objc_msgSend(this.id_, OS.sel_isButtonBordered) !is null; 76 }
94 }
95 77
96 public CGFloat itemHeight () 78 public void setNumberOfVisibleItems(NSInteger visibleItems) {
97 { 79 OS.objc_msgSend(this.id, OS.sel_setNumberOfVisibleItems_, visibleItems);
98 return cast(CGFloat) OS.objc_msgSend_fpret(this.id_, OS.sel_itemHeight); 80 }
99 }
100 81
101 public objc.id itemObjectValueAtIndex (NSInteger index) 82 public static objc.Class cellClass() {
102 { 83 return cast(objc.Class) OS.objc_msgSend(OS.class_NSComboBox, OS.sel_cellClass);
103 objc.id result = OS.objc_msgSend(this.id_, OS.sel_itemObjectValueAtIndex_1, index); 84 }
104 return result !is null ? result : null;
105 }
106 85
107 public void noteNumberOfItemsChanged () 86 public static void setCellClass(objc.Class factoryId) {
108 { 87 OS.objc_msgSend(OS.class_NSComboBox, OS.sel_setCellClass_, factoryId);
109 OS.objc_msgSend(this.id_, OS.sel_noteNumberOfItemsChanged); 88 }
110 }
111
112 public NSInteger numberOfItems ()
113 {
114 return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_numberOfItems);
115 }
116
117 public NSInteger numberOfVisibleItems ()
118 {
119 return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_numberOfVisibleItems);
120 }
121
122 public id objectValueOfSelectedItem ()
123 {
124 objc.id result = OS.objc_msgSend(this.id_, OS.sel_objectValueOfSelectedItem);
125 return result !is null ? new id(result) : null;
126 }
127
128 public NSArray objectValues ()
129 {
130 objc.id result = OS.objc_msgSend(this.id_, OS.sel_objectValues);
131 return result !is null ? new NSArray(result) : null;
132 }
133
134 public void reloadData ()
135 {
136 OS.objc_msgSend(this.id_, OS.sel_reloadData);
137 }
138
139 public void removeAllItems ()
140 {
141 OS.objc_msgSend(this.id_, OS.sel_removeAllItems);
142 }
143
144 public void removeItemAtIndex (NSInteger index)
145 {
146 OS.objc_msgSend(this.id_, OS.sel_removeItemAtIndex_1, index);
147 }
148
149 public void removeItemWithObjectValue (id object)
150 {
151 OS.objc_msgSend(this.id_, OS.sel_removeItemWithObjectValue_1, object !is null ? object.id_ : null);
152 }
153
154 public void scrollItemAtIndexToTop (NSInteger index)
155 {
156 OS.objc_msgSend(this.id_, OS.sel_scrollItemAtIndexToTop_1, index);
157 }
158
159 public void scrollItemAtIndexToVisible (NSInteger index)
160 {
161 OS.objc_msgSend(this.id_, OS.sel_scrollItemAtIndexToVisible_1, index);
162 }
163
164 public void selectItemAtIndex (NSInteger index)
165 {
166 OS.objc_msgSend(this.id_, OS.sel_selectItemAtIndex_1, index);
167 }
168
169 public void selectItemWithObjectValue (id object)
170 {
171 OS.objc_msgSend(this.id_, OS.sel_selectItemWithObjectValue_1, object !is null ? object.id_ : null);
172 }
173
174 public void setButtonBordered (bool flag)
175 {
176 OS.objc_msgSend(this.id_, OS.sel_setButtonBordered_1, flag);
177 }
178
179 public void setCompletes (bool completes)
180 {
181 OS.objc_msgSend(this.id_, OS.sel_setCompletes_1, completes);
182 }
183
184 public void setDataSource (id aSource)
185 {
186 OS.objc_msgSend(this.id_, OS.sel_setDataSource_1, aSource !is null ? aSource.id_ : null);
187 }
188
189 public void setHasVerticalScroller (bool flag)
190 {
191 OS.objc_msgSend(this.id_, OS.sel_setHasVerticalScroller_1, flag);
192 }
193
194 public void setIntercellSpacing (NSSize aSize)
195 {
196 OS.objc_msgSend(this.id_, OS.sel_setIntercellSpacing_1, aSize);
197 }
198
199 public void setItemHeight (CGFloat itemHeight)
200 {
201 OS.objc_msgSend(this.id_, OS.sel_setItemHeight_1, itemHeight);
202 }
203
204 public void setNumberOfVisibleItems (NSInteger visibleItems)
205 {
206 OS.objc_msgSend(this.id_, OS.sel_setNumberOfVisibleItems_1, visibleItems);
207 }
208
209 public void setUsesDataSource (bool flag)
210 {
211 OS.objc_msgSend(this.id_, OS.sel_setUsesDataSource_1, flag);
212 }
213
214 public bool usesDataSource ()
215 {
216 return OS.objc_msgSend(this.id_, OS.sel_usesDataSource) !is null;
217 }
218 89
219 } 90 }