Mercurial > projects > dwt-mac
comparison dwt/internal/cocoa/NSMenu.d @ 0:380af2bdd8e5
Upload of whole dwt tree
author | Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com> |
---|---|
date | Sat, 09 Aug 2008 17:00:02 +0200 |
parents | |
children | 8b48be5454ce |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:380af2bdd8e5 |
---|---|
1 /******************************************************************************* | |
2 * Copyright (c) 2007 IBM Corporation and others. | |
3 * All rights reserved. This program and the accompanying materials | |
4 * are made available under the terms of the Eclipse Public License v1.0 | |
5 * which accompanies this distribution, and is available at | |
6 * http://www.eclipse.org/legal/epl-v10.html | |
7 * | |
8 * Contributors: | |
9 * IBM Corporation - initial API and implementation | |
10 * | |
11 * Port to the D Programming language: | |
12 * Jacob Carlborg <jacob.carlborg@gmail.com> | |
13 *******************************************************************************/ | |
14 module dwt.internal.cocoa.NSMenu; | |
15 | |
16 import dwt.internal.cocoa.CGFloat; | |
17 import dwt.internal.cocoa.id; | |
18 import dwt.internal.cocoa.NSArray; | |
19 import dwt.internal.cocoa.NSEvent; | |
20 import dwt.internal.cocoa.NSFont; | |
21 import dwt.internal.cocoa.NSInteger; | |
22 import dwt.internal.cocoa.NSMenuItem; | |
23 import dwt.internal.cocoa.NSObject; | |
24 import dwt.internal.cocoa.NSPoint; | |
25 import dwt.internal.cocoa.NSString; | |
26 import dwt.internal.cocoa.NSView; | |
27 import dwt.internal.cocoa.NSZone; | |
28 import dwt.internal.cocoa.OS; | |
29 import objc = dwt.internal.objc.runtime; | |
30 | |
31 public class NSMenu : NSObject | |
32 { | |
33 | |
34 public this () | |
35 { | |
36 super(); | |
37 } | |
38 | |
39 public this (objc.id id) | |
40 { | |
41 super(id); | |
42 } | |
43 | |
44 public void addItem (NSMenuItem newItem) | |
45 { | |
46 OS.objc_msgSend(this.id, OS.sel_addItem_1, newItem !is null ? newItem.id : null); | |
47 } | |
48 | |
49 public NSMenuItem addItemWithTitle (NSString aString, objc.SEL aSelector, NSString charCode) | |
50 { | |
51 objc.id result = OS.objc_msgSend(this.id, OS.sel_addItemWithTitle_1action_1keyEquivalent_1, aString !is null ? aString.id : null, aSelector, | |
52 charCode !is null ? charCode.id : null); | |
53 return result !is null ? new NSMenuItem(result) : null; | |
54 } | |
55 | |
56 public NSMenu attachedMenu () | |
57 { | |
58 objc.id result = OS.objc_msgSend(this.id, OS.sel_attachedMenu); | |
59 return result is this.id ? this : (result !is null ? new NSMenu(result) : null); | |
60 } | |
61 | |
62 public bool autoenablesItems () | |
63 { | |
64 return OS.objc_msgSend(this.id, OS.sel_autoenablesItems) !is null; | |
65 } | |
66 | |
67 public void cancelTracking () | |
68 { | |
69 OS.objc_msgSend(this.id, OS.sel_cancelTracking); | |
70 } | |
71 | |
72 public id contextMenuRepresentation () | |
73 { | |
74 objc.id result = OS.objc_msgSend(this.id, OS.sel_contextMenuRepresentation); | |
75 return result !is null ? new id(result) : null; | |
76 } | |
77 | |
78 public id delegatee () | |
79 { | |
80 objc.id result = OS.objc_msgSend(this.id, OS.sel_delegate); | |
81 return result !is null ? new id(result) : null; | |
82 } | |
83 | |
84 public void helpRequested (NSEvent eventPtr) | |
85 { | |
86 OS.objc_msgSend(this.id, OS.sel_helpRequested_1, eventPtr !is null ? eventPtr.id : null); | |
87 } | |
88 | |
89 public NSMenuItem highlightedItem () | |
90 { | |
91 objc.id result = OS.objc_msgSend(this.id, OS.sel_highlightedItem); | |
92 return result !is null ? new NSMenuItem(result) : null; | |
93 } | |
94 | |
95 public NSInteger indexOfItem (NSMenuItem index) | |
96 { | |
97 return OS.objc_msgSend(this.id, OS.sel_indexOfItem_1, index !is null ? index.id : null); | |
98 } | |
99 | |
100 public NSInteger indexOfItemWithRepresentedObject (id object) | |
101 { | |
102 return OS.objc_msgSend(this.id, OS.sel_indexOfItemWithRepresentedObject_1, object !is null ? object.id : null); | |
103 } | |
104 | |
105 public NSInteger indexOfItemWithSubmenu (NSMenu submenu) | |
106 { | |
107 return OS.objc_msgSend(this.id, OS.sel_indexOfItemWithSubmenu_1, submenu !is null ? submenu.id : null); | |
108 } | |
109 | |
110 public NSInteger indexOfItemWithTag (NSInteger aTag) | |
111 { | |
112 return OS.objc_msgSend(this.id, OS.sel_indexOfItemWithTag_1, aTag); | |
113 } | |
114 | |
115 public NSInteger indexOfItemWithTarget (id target, objc.SEL actionSelector) | |
116 { | |
117 return OS.objc_msgSend(this.id, OS.sel_indexOfItemWithTarget_1andAction_1, target !is null ? target.id : null, actionSelector); | |
118 } | |
119 | |
120 public NSInteger indexOfItemWithTitle (NSString aTitle) | |
121 { | |
122 return OS.objc_msgSend(this.id, OS.sel_indexOfItemWithTitle_1, aTitle !is null ? aTitle.id : null); | |
123 } | |
124 | |
125 public NSMenu initWithTitle (NSString aTitle) | |
126 { | |
127 objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithTitle_1, aTitle !is null ? aTitle.id : null); | |
128 return result !is null ? this : null; | |
129 } | |
130 | |
131 public void insertItem (NSMenuItem newItem, NSInteger index) | |
132 { | |
133 OS.objc_msgSend(this.id, OS.sel_insertItem_1atIndex_1, newItem !is null ? newItem.id : null, index); | |
134 } | |
135 | |
136 public NSMenuItem insertItemWithTitle (NSString aString, objc.SEL aSelector, NSString charCode, NSInteger index) | |
137 { | |
138 objc.id result = OS.objc_msgSend(this.id, OS.sel_insertItemWithTitle_1action_1keyEquivalent_1atIndex_1, aString !is null ? aString.id : null, | |
139 aSelector, charCode !is null ? charCode.id : null, index); | |
140 return result !is null ? new NSMenuItem(result) : null; | |
141 } | |
142 | |
143 public bool isAttached () | |
144 { | |
145 return OS.objc_msgSend(this.id, OS.sel_isAttached) !is null; | |
146 } | |
147 | |
148 public bool isTornOff () | |
149 { | |
150 return OS.objc_msgSend(this.id, OS.sel_isTornOff) !is null; | |
151 } | |
152 | |
153 public NSArray itemArray () | |
154 { | |
155 objc.id result = OS.objc_msgSend(this.id, OS.sel_itemArray); | |
156 return result !is null ? new NSArray(result) : null; | |
157 } | |
158 | |
159 public NSMenuItem itemAtIndex (NSInteger index) | |
160 { | |
161 objc.id result = OS.objc_msgSend(this.id, OS.sel_itemAtIndex_1, index); | |
162 return result !is null ? new NSMenuItem(result) : null; | |
163 } | |
164 | |
165 public void itemChanged (NSMenuItem item) | |
166 { | |
167 OS.objc_msgSend(this.id, OS.sel_itemChanged_1, item !is null ? item.id : null); | |
168 } | |
169 | |
170 public NSMenuItem itemWithTag (NSInteger tag) | |
171 { | |
172 objc.id result = OS.objc_msgSend(this.id, OS.sel_itemWithTag_1, tag); | |
173 return result !is null ? new NSMenuItem(result) : null; | |
174 } | |
175 | |
176 public NSMenuItem itemWithTitle (NSString aTitle) | |
177 { | |
178 objc.id result = OS.objc_msgSend(this.id, OS.sel_itemWithTitle_1, aTitle !is null ? aTitle.id : null); | |
179 return result !is null ? new NSMenuItem(result) : null; | |
180 } | |
181 | |
182 public NSPoint locationForSubmenu (NSMenu aSubmenu) | |
183 { | |
184 NSPoint result; | |
185 OS.objc_msgSend_stret(result, this.id, OS.sel_locationForSubmenu_1, aSubmenu !is null ? aSubmenu.id : null); | |
186 return result; | |
187 } | |
188 | |
189 public CGFloat menuBarHeight () | |
190 { | |
191 return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_menuBarHeight); | |
192 } | |
193 | |
194 public static bool menuBarVisible () | |
195 { | |
196 return OS.objc_msgSend(OS.class_NSMenu, OS.sel_menuBarVisible) !is null; | |
197 } | |
198 | |
199 public bool menuChangedMessagesEnabled () | |
200 { | |
201 return OS.objc_msgSend(this.id, OS.sel_menuChangedMessagesEnabled) !is null; | |
202 } | |
203 | |
204 public id menuRepresentation () | |
205 { | |
206 objc.id result = OS.objc_msgSend(this.id, OS.sel_menuRepresentation); | |
207 return result !is null ? new id(result) : null; | |
208 } | |
209 | |
210 public static NSZone* menuZone () | |
211 { | |
212 return OS.objc_msgSend(OS.class_NSMenu, OS.sel_menuZone); | |
213 } | |
214 | |
215 public NSInteger numberOfItems () | |
216 { | |
217 return OS.objc_msgSend(this.id, OS.sel_numberOfItems); | |
218 } | |
219 | |
220 public void performActionForItemAtIndex (NSInteger index) | |
221 { | |
222 OS.objc_msgSend(this.id, OS.sel_performActionForItemAtIndex_1, index); | |
223 } | |
224 | |
225 public bool performKeyEquivalent (NSEvent theEvent) | |
226 { | |
227 return OS.objc_msgSend(this.id, OS.sel_performKeyEquivalent_1, theEvent !is null ? theEvent.id : null) !is null; | |
228 } | |
229 | |
230 public static void static_popUpContextMenu_withEvent_forView_ (NSMenu menu, NSEvent event, NSView view) | |
231 { | |
232 OS.objc_msgSend(OS.class_NSMenu, OS.sel_popUpContextMenu_1withEvent_1forView_1, menu !is null ? menu.id : null, | |
233 event !is null ? event.id : null, view !is null ? view.id : null); | |
234 } | |
235 | |
236 public static void static_popUpContextMenu_withEvent_forView_withFont_ (NSMenu menu, NSEvent event, NSView view, NSFont font) | |
237 { | |
238 OS.objc_msgSend(OS.class_NSMenu, OS.sel_popUpContextMenu_1withEvent_1forView_1withFont_1, menu !is null ? menu.id : null, | |
239 event !is null ? event.id : null, view !is null ? view.id : null, font !is null ? font.id : null); | |
240 } | |
241 | |
242 public void removeItem (NSMenuItem item) | |
243 { | |
244 OS.objc_msgSend(this.id, OS.sel_removeItem_1, item !is null ? item.id : null); | |
245 } | |
246 | |
247 public void removeItemAtIndex (NSInteger index) | |
248 { | |
249 OS.objc_msgSend(this.id, OS.sel_removeItemAtIndex_1, index); | |
250 } | |
251 | |
252 public void setAutoenablesItems (bool flag) | |
253 { | |
254 OS.objc_msgSend(this.id, OS.sel_setAutoenablesItems_1, flag); | |
255 } | |
256 | |
257 public void setContextMenuRepresentation (id menuRep) | |
258 { | |
259 OS.objc_msgSend(this.id, OS.sel_setContextMenuRepresentation_1, menuRep !is null ? menuRep.id : null); | |
260 } | |
261 | |
262 public void setDelegate (id anObject) | |
263 { | |
264 OS.objc_msgSend(this.id, OS.sel_setDelegate_1, anObject !is null ? anObject.id : null); | |
265 } | |
266 | |
267 public static void setMenuBarVisible (bool visible) | |
268 { | |
269 OS.objc_msgSend(OS.class_NSMenu, OS.sel_setMenuBarVisible_1, visible); | |
270 } | |
271 | |
272 public void setMenuChangedMessagesEnabled (bool flag) | |
273 { | |
274 OS.objc_msgSend(this.id, OS.sel_setMenuChangedMessagesEnabled_1, flag); | |
275 } | |
276 | |
277 public void setMenuRepresentation (id menuRep) | |
278 { | |
279 OS.objc_msgSend(this.id, OS.sel_setMenuRepresentation_1, menuRep !is null ? menuRep.id : null); | |
280 } | |
281 | |
282 public static void setMenuZone (NSZone* aZone) | |
283 { | |
284 OS.objc_msgSend(OS.class_NSMenu, OS.sel_setMenuZone_1, aZone); | |
285 } | |
286 | |
287 public void setShowsStateColumn (bool showsState) | |
288 { | |
289 OS.objc_msgSend(this.id, OS.sel_setShowsStateColumn_1, showsState); | |
290 } | |
291 | |
292 public void setSubmenu (NSMenu aMenu, NSMenuItem anItem) | |
293 { | |
294 OS.objc_msgSend(this.id, OS.sel_setSubmenu_1forItem_1, aMenu !is null ? aMenu.id : null, anItem !is null ? anItem.id : null); | |
295 } | |
296 | |
297 public void setSupermenu (NSMenu supermenu) | |
298 { | |
299 OS.objc_msgSend(this.id, OS.sel_setSupermenu_1, supermenu !is null ? supermenu.id : null); | |
300 } | |
301 | |
302 public void setTearOffMenuRepresentation (id menuRep) | |
303 { | |
304 OS.objc_msgSend(this.id, OS.sel_setTearOffMenuRepresentation_1, menuRep !is null ? menuRep.id : null); | |
305 } | |
306 | |
307 public void setTitle (NSString aString) | |
308 { | |
309 OS.objc_msgSend(this.id, OS.sel_setTitle_1, aString !is null ? aString.id : null); | |
310 } | |
311 | |
312 public bool showsStateColumn () | |
313 { | |
314 return OS.objc_msgSend(this.id, OS.sel_showsStateColumn) !is null; | |
315 } | |
316 | |
317 public void sizeToFit () | |
318 { | |
319 OS.objc_msgSend(this.id, OS.sel_sizeToFit); | |
320 } | |
321 | |
322 public void submenuAction (id sender) | |
323 { | |
324 OS.objc_msgSend(this.id, OS.sel_submenuAction_1, sender !is null ? sender.id : null); | |
325 } | |
326 | |
327 public NSMenu supermenu () | |
328 { | |
329 objc.id result = OS.objc_msgSend(this.id, OS.sel_supermenu); | |
330 return result is this.id ? this : (result !is null ? new NSMenu(result) : null); | |
331 } | |
332 | |
333 public id tearOffMenuRepresentation () | |
334 { | |
335 objc.id result = OS.objc_msgSend(this.id, OS.sel_tearOffMenuRepresentation); | |
336 return result !is null ? new id(result) : null; | |
337 } | |
338 | |
339 public NSString title () | |
340 { | |
341 objc.id result = OS.objc_msgSend(this.id, OS.sel_title); | |
342 return result !is null ? new NSString(result) : null; | |
343 } | |
344 | |
345 public void update () | |
346 { | |
347 OS.objc_msgSend(this.id, OS.sel_update); | |
348 } | |
349 | |
350 } |