Mercurial > projects > dwt-mac
comparison 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 |
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.NSPopUpButton; | 14 module dwt.internal.cocoa.NSPopUpButton; |
15 | 15 |
16 import dwt.internal.cocoa.id; | 16 import dwt.dwthelper.utils; |
17 import dwt.internal.cocoa.NSArray; | 17 import cocoa = dwt.internal.cocoa.id; |
18 import dwt.internal.cocoa.NSButton; | 18 import dwt.internal.cocoa.NSButton; |
19 import dwt.internal.cocoa.NSInteger; | |
20 import dwt.internal.cocoa.NSMenu; | 19 import dwt.internal.cocoa.NSMenu; |
21 import dwt.internal.cocoa.NSMenuItem; | 20 import dwt.internal.cocoa.NSMenuItem; |
22 import dwt.internal.cocoa.NSRect; | 21 import dwt.internal.cocoa.NSRect; |
23 import dwt.internal.cocoa.NSString; | 22 import dwt.internal.cocoa.NSString; |
24 import dwt.internal.cocoa.OS; | 23 import dwt.internal.cocoa.OS; |
24 import dwt.internal.objc.cocoa.Cocoa; | |
25 import objc = dwt.internal.objc.runtime; | 25 import objc = dwt.internal.objc.runtime; |
26 | 26 |
27 public class NSPopUpButton : NSButton | 27 public class NSPopUpButton : NSButton { |
28 { | |
29 | 28 |
30 public this () | 29 public this() { |
31 { | 30 super(); |
32 super(); | 31 } |
33 } | |
34 | 32 |
35 public this (objc.id id) | 33 public this(objc.id id) { |
36 { | 34 super(id); |
37 super(id); | 35 } |
38 } | |
39 | 36 |
40 public void addItemWithTitle (NSString title) | 37 public this(cocoa.id id) { |
41 { | 38 super(id); |
42 OS.objc_msgSend(this.id_, OS.sel_addItemWithTitle_1, title !is null ? title.id_ : null); | 39 } |
43 } | |
44 | 40 |
45 public void addItemsWithTitles (NSArray itemTitles) | 41 public NSInteger indexOfSelectedItem() { |
46 { | 42 return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_indexOfSelectedItem); |
47 OS.objc_msgSend(this.id_, OS.sel_addItemsWithTitles_1, itemTitles !is null ? itemTitles.id_ : null); | 43 } |
48 } | |
49 | 44 |
50 public bool autoenablesItems () | 45 public NSPopUpButton initWithFrame(NSRect buttonFrame, bool flag) { |
51 { | 46 objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithFrame_pullsDown_, buttonFrame, flag); |
52 return OS.objc_msgSend(this.id_, OS.sel_autoenablesItems) !is null; | 47 return result is this.id ? this : (result !is null ? new NSPopUpButton(result) : null); |
53 } | 48 } |
54 | 49 |
55 public NSInteger indexOfItem (NSMenuItem item) | 50 public NSMenuItem itemAtIndex(NSInteger index) { |
56 { | 51 objc.id result = OS.objc_msgSend(this.id, OS.sel_itemAtIndex_, index); |
57 return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_indexOfItem_1, item !is null ? item.id_ : null); | 52 return result !is null ? new NSMenuItem(result) : null; |
58 } | 53 } |
59 | 54 |
60 public NSInteger indexOfItemWithRepresentedObject (id obj) | 55 public NSString itemTitleAtIndex(NSInteger index) { |
61 { | 56 objc.id result = OS.objc_msgSend(this.id, OS.sel_itemTitleAtIndex_, index); |
62 return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_indexOfItemWithRepresentedObject_1, obj !is null ? obj.id_ : null); | 57 return result !is null ? new NSString(result) : null; |
63 } | 58 } |
64 | 59 |
65 public NSInteger indexOfItemWithTag (NSInteger tag) | 60 public NSMenu menu() { |
66 { | 61 objc.id result = OS.objc_msgSend(this.id, OS.sel_menu); |
67 return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_indexOfItemWithTag_1, tag); | 62 return result !is null ? new NSMenu(result) : null; |
68 } | 63 } |
69 | 64 |
70 public NSInteger indexOfItemWithTarget (id target, objc.SEL actionSelector) | 65 public NSInteger numberOfItems() { |
71 { | 66 return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_numberOfItems); |
72 return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_indexOfItemWithTarget_1andAction_1, target !is null ? target.id_ : null, actionSelector); | 67 } |
73 } | |
74 | 68 |
75 public NSInteger indexOfItemWithTitle (NSString title) | 69 public void removeAllItems() { |
76 { | 70 OS.objc_msgSend(this.id, OS.sel_removeAllItems); |
77 return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_indexOfItemWithTitle_1, title !is null ? title.id_ : null); | 71 } |
78 } | |
79 | 72 |
80 public NSInteger indexOfSelectedItem () | 73 public void removeItemAtIndex(NSInteger index) { |
81 { | 74 OS.objc_msgSend(this.id, OS.sel_removeItemAtIndex_, index); |
82 return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_indexOfSelectedItem); | 75 } |
83 } | |
84 | 76 |
85 public NSPopUpButton initWithFrame (NSRect buttonFrame, bool flag) | 77 public void selectItem(NSMenuItem item) { |
86 { | 78 OS.objc_msgSend(this.id, OS.sel_selectItem_, item !is null ? item.id : null); |
87 objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithFrame_1pullsDown_1, buttonFrame, flag); | 79 } |
88 return result !is null ? this : null; | |
89 } | |
90 | 80 |
91 public void insertItemWithTitle (NSString title, NSInteger index) | 81 public void selectItemAtIndex(NSInteger index) { |
92 { | 82 OS.objc_msgSend(this.id, OS.sel_selectItemAtIndex_, index); |
93 OS.objc_msgSend(this.id_, OS.sel_insertItemWithTitle_1atIndex_1, title !is null ? title.id_ : null, index); | 83 } |
94 } | |
95 | 84 |
96 public NSArray itemArray () | 85 public void setAutoenablesItems(bool flag) { |
97 { | 86 OS.objc_msgSend(this.id, OS.sel_setAutoenablesItems_, flag); |
98 objc.id result = OS.objc_msgSend(this.id_, OS.sel_itemArray); | 87 } |
99 return result !is null ? new NSArray(result) : null; | |
100 } | |
101 | 88 |
102 public NSMenuItem itemAtIndex (NSInteger index) | 89 public void setPullsDown(bool flag) { |
103 { | 90 OS.objc_msgSend(this.id, OS.sel_setPullsDown_, flag); |
104 objc.id result = OS.objc_msgSend(this.id_, OS.sel_itemAtIndex_1, index); | 91 } |
105 return result !is null ? new NSMenuItem(result) : null; | |
106 } | |
107 | 92 |
108 public NSString itemTitleAtIndex (NSInteger index) | 93 public NSString titleOfSelectedItem() { |
109 { | 94 objc.id result = OS.objc_msgSend(this.id, OS.sel_titleOfSelectedItem); |
110 objc.id result = OS.objc_msgSend(this.id_, OS.sel_itemTitleAtIndex_1, index); | 95 return result !is null ? new NSString(result) : null; |
111 return result !is null ? new NSString(result) : null; | 96 } |
112 } | |
113 | 97 |
114 public NSArray itemTitles () | 98 public static objc.Class cellClass() { |
115 { | 99 return cast(objc.Calss) OS.objc_msgSend(OS.class_NSPopUpButton, OS.sel_cellClass); |
116 objc.id result = OS.objc_msgSend(this.id_, OS.sel_itemTitles); | 100 } |
117 return result !is null ? new NSArray(result) : null; | |
118 } | |
119 | 101 |
120 public NSMenuItem itemWithTitle (NSString title) | 102 public static void setCellClass(objc.Class factoryId) { |
121 { | 103 OS.objc_msgSend(OS.class_NSPopUpButton, OS.sel_setCellClass_, factoryId); |
122 objc.id result = OS.objc_msgSend(this.id_, OS.sel_itemWithTitle_1, title !is null ? title.id_ : null); | 104 } |
123 return result !is null ? new NSMenuItem(result) : null; | |
124 } | |
125 | |
126 public NSMenuItem lastItem () | |
127 { | |
128 objc.id result = OS.objc_msgSend(this.id_, OS.sel_lastItem); | |
129 return result !is null ? new NSMenuItem(result) : null; | |
130 } | |
131 | |
132 public NSMenu menu () | |
133 { | |
134 objc.id result = OS.objc_msgSend(this.id_, OS.sel_menu); | |
135 return result !is null ? new NSMenu(result) : null; | |
136 } | |
137 | |
138 public NSInteger numberOfItems () | |
139 { | |
140 return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_numberOfItems); | |
141 } | |
142 | |
143 public NSRectEdge preferredEdge () | |
144 { | |
145 return cast(NSRectEdge) OS.objc_msgSend(this.id_, OS.sel_preferredEdge); | |
146 } | |
147 | |
148 public bool pullsDown () | |
149 { | |
150 return OS.objc_msgSend(this.id_, OS.sel_pullsDown) !is null; | |
151 } | |
152 | |
153 public void removeAllItems () | |
154 { | |
155 OS.objc_msgSend(this.id_, OS.sel_removeAllItems); | |
156 } | |
157 | |
158 public void removeItemAtIndex (NSInteger index) | |
159 { | |
160 OS.objc_msgSend(this.id_, OS.sel_removeItemAtIndex_1, index); | |
161 } | |
162 | |
163 public void removeItemWithTitle (NSString title) | |
164 { | |
165 OS.objc_msgSend(this.id_, OS.sel_removeItemWithTitle_1, title !is null ? title.id_ : null); | |
166 } | |
167 | |
168 public void selectItem (NSMenuItem item) | |
169 { | |
170 OS.objc_msgSend(this.id_, OS.sel_selectItem_1, item !is null ? item.id_ : null); | |
171 } | |
172 | |
173 public void selectItemAtIndex (NSInteger index) | |
174 { | |
175 OS.objc_msgSend(this.id_, OS.sel_selectItemAtIndex_1, index); | |
176 } | |
177 | |
178 public bool selectItemWithTag (NSInteger tag) | |
179 { | |
180 return OS.objc_msgSend(this.id_, OS.sel_selectItemWithTag_1, tag) !is null; | |
181 } | |
182 | |
183 public void selectItemWithTitle (NSString title) | |
184 { | |
185 OS.objc_msgSend(this.id_, OS.sel_selectItemWithTitle_1, title !is null ? title.id_ : null); | |
186 } | |
187 | |
188 public NSMenuItem selectedItem () | |
189 { | |
190 objc.id result = OS.objc_msgSend(this.id_, OS.sel_selectedItem); | |
191 return result !is null ? new NSMenuItem(result) : null; | |
192 } | |
193 | |
194 public void setAutoenablesItems (bool flag) | |
195 { | |
196 OS.objc_msgSend(this.id_, OS.sel_setAutoenablesItems_1, flag); | |
197 } | |
198 | |
199 public void setMenu (NSMenu menu) | |
200 { | |
201 OS.objc_msgSend(this.id_, OS.sel_setMenu_1, menu !is null ? menu.id_ : null); | |
202 } | |
203 | |
204 public void setPreferredEdge (NSRectEdge edge) | |
205 { | |
206 OS.objc_msgSend(this.id_, OS.sel_setPreferredEdge_1, edge); | |
207 } | |
208 | |
209 public void setPullsDown (bool flag) | |
210 { | |
211 OS.objc_msgSend(this.id_, OS.sel_setPullsDown_1, flag); | |
212 } | |
213 | |
214 public void setTitle (NSString aString) | |
215 { | |
216 OS.objc_msgSend(this.id_, OS.sel_setTitle_1, aString !is null ? aString.id_ : null); | |
217 } | |
218 | |
219 public void synchronizeTitleAndSelectedItem () | |
220 { | |
221 OS.objc_msgSend(this.id_, OS.sel_synchronizeTitleAndSelectedItem); | |
222 } | |
223 | |
224 public NSString titleOfSelectedItem () | |
225 { | |
226 objc.id result = OS.objc_msgSend(this.id_, OS.sel_titleOfSelectedItem); | |
227 return result !is null ? new NSString(result) : null; | |
228 } | |
229 | 105 |
230 } | 106 } |