comparison dwt/internal/cocoa/NSMenuItem.d @ 45:d8635bb48c7c

Merge with SWT 3.5
author Jacob Carlborg <doob@me.com>
date Mon, 01 Dec 2008 17:07:00 +0100
parents 642f460a0908
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.NSMenuItem; 14 module dwt.internal.cocoa.NSMenuItem;
15 15
16 import dwt.dwthelper.utils; 16 import dwt.dwthelper.utils;
17 import dwt.internal.cocoa.id; 17 import cocoa = dwt.internal.cocoa.id;
18 import dwt.internal.cocoa.NSAttributedString;
19 import dwt.internal.cocoa.NSImage; 18 import dwt.internal.cocoa.NSImage;
20 import dwt.internal.cocoa.NSInteger;
21 import dwt.internal.cocoa.NSMenu; 19 import dwt.internal.cocoa.NSMenu;
22 import dwt.internal.cocoa.NSObject; 20 import dwt.internal.cocoa.NSObject;
23 import dwt.internal.cocoa.NSString; 21 import dwt.internal.cocoa.NSString;
24 import dwt.internal.cocoa.NSView;
25 import dwt.internal.cocoa.OS; 22 import dwt.internal.cocoa.OS;
23 import dwt.internal.objc.cocoa.Cocoa;
26 import objc = dwt.internal.objc.runtime; 24 import objc = dwt.internal.objc.runtime;
27 25
28 public class NSMenuItem : NSObject 26 public class NSMenuItem : NSObject {
29 {
30 27
31 public this () 28 public this() {
32 { 29 super();
33 super(); 30 }
34 }
35 31
36 public this (objc.id id) 32 public this(objc.id id) {
37 { 33 super(id);
38 super(id); 34 }
39 }
40 35
41 public objc.SEL action () 36 public this(cocoa.id id) {
42 { 37 super(id);
43 return cast(objc.SEL) OS.objc_msgSend(this.id_, OS.sel_action); 38 }
44 }
45 39
46 public NSAttributedString attributedTitle () 40 public NSMenuItem initWithTitle(NSString aString, objc.SEL aSelector, NSString charCode) {
47 { 41 objc.id result = OS.objc_msgSend(this.id, OS.sel_initWithTitle_action_keyEquivalent_, aString !is null ? aString.id : null, aSelector, charCode !is null ? charCode.id : null);
48 objc.id result = OS.objc_msgSend(this.id_, OS.sel_attributedTitle); 42 return result is this.id ? this : (result !is null ? new NSMenuItem(result) : null);
49 return result !is null ? new NSAttributedString(result) : null; 43 }
50 }
51 44
52 public bool hasSubmenu () 45 public bool isHidden() {
53 { 46 return OS.objc_msgSend_bool(this.id, OS.sel_isHidden);
54 return OS.objc_msgSend(this.id_, OS.sel_hasSubmenu) !is null; 47 }
55 }
56 48
57 public NSImage image () 49 public NSString keyEquivalent() {
58 { 50 objc.id result = OS.objc_msgSend(this.id, OS.sel_keyEquivalent);
59 objc.id result = OS.objc_msgSend(this.id_, OS.sel_image); 51 return result !is null ? new NSString(result) : null;
60 return result !is null ? new NSImage(result) : null; 52 }
61 }
62 53
63 public NSInteger indentationLevel () 54 public NSUInteger keyEquivalentModifierMask() {
64 { 55 return cast(NSUInteger) OS.objc_msgSend(this.id, OS.sel_keyEquivalentModifierMask);
65 return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_indentationLevel); 56 }
66 }
67 57
68 public NSMenuItem initWithTitle (NSString aString, objc.SEL aSelector, NSString charCode) 58 public static NSMenuItem separatorItem() {
69 { 59 objc.id result = OS.objc_msgSend(OS.class_NSMenuItem, OS.sel_separatorItem);
70 objc.id result = OS.objc_msgSend(this.id_, OS.sel_initWithTitle_1action_1keyEquivalent_1, aString !is null ? aString.id_ : null, aSelector, 60 return result !is null ? new NSMenuItem(result) : null;
71 charCode !is null ? charCode.id_ : null); 61 }
72 return result !is null ? this : null;
73 }
74 62
75 public bool isAlternate () 63 public void setAction(objc.SEL aSelector) {
76 { 64 OS.objc_msgSend(this.id, OS.sel_setAction_, aSelector);
77 return OS.objc_msgSend(this.id_, OS.sel_isAlternate) !is null; 65 }
78 }
79 66
80 public bool isEnabled () 67 public void setEnabled(bool flag) {
81 { 68 OS.objc_msgSend(this.id, OS.sel_setEnabled_, flag);
82 return OS.objc_msgSend(this.id_, OS.sel_isEnabled) !is null; 69 }
83 }
84 70
85 public bool isHidden () 71 public void setHidden(bool hidden) {
86 { 72 OS.objc_msgSend(this.id, OS.sel_setHidden_, hidden);
87 return OS.objc_msgSend(this.id_, OS.sel_isHidden) !is null; 73 }
88 }
89 74
90 public bool isHiddenOrHasHiddenAncestor () 75 public void setImage(NSImage menuImage) {
91 { 76 OS.objc_msgSend(this.id, OS.sel_setImage_, menuImage !is null ? menuImage.id : null);
92 return OS.objc_msgSend(this.id_, OS.sel_isHiddenOrHasHiddenAncestor) !is null; 77 }
93 }
94 78
95 public bool isHighlighted () 79 public void setKeyEquivalent(NSString aKeyEquivalent) {
96 { 80 OS.objc_msgSend(this.id, OS.sel_setKeyEquivalent_, aKeyEquivalent !is null ? aKeyEquivalent.id : null);
97 return OS.objc_msgSend(this.id_, OS.sel_isHighlighted) !is null; 81 }
98 }
99 82
100 public bool isSeparatorItem () 83 public void setKeyEquivalentModifierMask(NSUInteger mask) {
101 { 84 OS.objc_msgSend(this.id, OS.sel_setKeyEquivalentModifierMask_, mask);
102 return OS.objc_msgSend(this.id_, OS.sel_isSeparatorItem) !is null; 85 }
103 }
104 86
105 public NSString keyEquivalent () 87 public void setMenu(NSMenu menu) {
106 { 88 OS.objc_msgSend(this.id, OS.sel_setMenu_, menu !is null ? menu.id : null);
107 objc.id result = OS.objc_msgSend(this.id_, OS.sel_keyEquivalent); 89 }
108 return result !is null ? new NSString(result) : null;
109 }
110 90
111 public NSUInteger keyEquivalentModifierMask () 91 public void setState(NSInteger state) {
112 { 92 OS.objc_msgSend(this.id, OS.sel_setState_, state);
113 return cast(NSUInteger) OS.objc_msgSend(this.id_, OS.sel_keyEquivalentModifierMask); 93 }
114 }
115 94
116 public NSMenu menu () 95 public void setSubmenu(NSMenu submenu) {
117 { 96 OS.objc_msgSend(this.id, OS.sel_setSubmenu_, submenu !is null ? submenu.id : null);
118 objc.id result = OS.objc_msgSend(this.id_, OS.sel_menu); 97 }
119 return result !is null ? new NSMenu(result) : null;
120 }
121 98
122 public NSImage mixedStateImage () 99 public void setTarget(cocoa.id anObject) {
123 { 100 OS.objc_msgSend(this.id, OS.sel_setTarget_, anObject !is null ? anObject.id : null);
124 objc.id result = OS.objc_msgSend(this.id_, OS.sel_mixedStateImage); 101 }
125 return result !is null ? new NSImage(result) : null;
126 }
127 102
128 public NSString mnemonic () 103 public void setTitle(NSString aString) {
129 { 104 OS.objc_msgSend(this.id, OS.sel_setTitle_, aString !is null ? aString.id : null);
130 objc.id result = OS.objc_msgSend(this.id_, OS.sel_mnemonic); 105 }
131 return result !is null ? new NSString(result) : null;
132 }
133 106
134 public NSUInteger mnemonicLocation () 107 public NSInteger state() {
135 { 108 return cast(NSInteger) OS.objc_msgSend(this.id, OS.sel_state);
136 return cast(NSUInteger) OS.objc_msgSend(this.id_, OS.sel_mnemonicLocation); 109 }
137 }
138 110
139 public NSImage offStateImage () 111 public NSMenu submenu() {
140 { 112 objc.id result = OS.objc_msgSend(this.id, OS.sel_submenu);
141 objc.id result = OS.objc_msgSend(this.id_, OS.sel_offStateImage); 113 return result !is null ? new NSMenu(result) : null;
142 return result !is null ? new NSImage(result) : null; 114 }
143 }
144 115
145 public NSImage onStateImage () 116 public NSString title() {
146 { 117 objc.id result = OS.objc_msgSend(this.id, OS.sel_title);
147 objc.id result = OS.objc_msgSend(this.id_, OS.sel_onStateImage); 118 return result !is null ? new NSString(result) : null;
148 return result !is null ? new NSImage(result) : null; 119 }
149 }
150
151 public id representedObject ()
152 {
153 objc.id result = OS.objc_msgSend(this.id_, OS.sel_representedObject);
154 return result !is null ? new id(result) : null;
155 }
156
157 public static NSMenuItem separatorItem ()
158 {
159 objc.id result = OS.objc_msgSend(OS.class_NSMenuItem, OS.sel_separatorItem);
160 return result !is null ? new NSMenuItem(result) : null;
161 }
162
163 public void setAction (String aSelector)
164 {
165 OS.objc_msgSend(this.id_, OS.sel_setAction_1, aSelector.ptr);
166 }
167
168 public void setAlternate (bool isAlternate)
169 {
170 OS.objc_msgSend(this.id_, OS.sel_setAlternate_1, isAlternate);
171 }
172
173 public void setAttributedTitle (NSAttributedString string)
174 {
175 OS.objc_msgSend(this.id_, OS.sel_setAttributedTitle_1, string !is null ? string.id_ : null);
176 }
177
178 public void setEnabled (bool flag)
179 {
180 OS.objc_msgSend(this.id_, OS.sel_setEnabled_1, flag);
181 }
182
183 public void setHidden (bool hidden)
184 {
185 OS.objc_msgSend(this.id_, OS.sel_setHidden_1, hidden);
186 }
187
188 public void setImage (NSImage menuImage)
189 {
190 OS.objc_msgSend(this.id_, OS.sel_setImage_1, menuImage !is null ? menuImage.id_ : null);
191 }
192
193 public void setIndentationLevel (NSInteger indentationLevel)
194 {
195 OS.objc_msgSend(this.id_, OS.sel_setIndentationLevel_1, indentationLevel);
196 }
197
198 public void setKeyEquivalent (NSString aKeyEquivalent)
199 {
200 OS.objc_msgSend(this.id_, OS.sel_setKeyEquivalent_1, aKeyEquivalent !is null ? aKeyEquivalent.id_ : null);
201 }
202
203 public void setKeyEquivalentModifierMask (NSUInteger mask)
204 {
205 OS.objc_msgSend(this.id_, OS.sel_setKeyEquivalentModifierMask_1, mask);
206 }
207
208 public void setMenu (NSMenu menu)
209 {
210 OS.objc_msgSend(this.id_, OS.sel_setMenu_1, menu !is null ? menu.id_ : null);
211 }
212
213 public void setMixedStateImage (NSImage image)
214 {
215 OS.objc_msgSend(this.id_, OS.sel_setMixedStateImage_1, image !is null ? image.id_ : null);
216 }
217
218 public void setMnemonicLocation (NSUInteger location)
219 {
220 OS.objc_msgSend(this.id_, OS.sel_setMnemonicLocation_1, location);
221 }
222
223 public void setOffStateImage (NSImage image)
224 {
225 OS.objc_msgSend(this.id_, OS.sel_setOffStateImage_1, image !is null ? image.id_ : null);
226 }
227
228 public void setOnStateImage (NSImage image)
229 {
230 OS.objc_msgSend(this.id_, OS.sel_setOnStateImage_1, image !is null ? image.id_ : null);
231 }
232
233 public void setRepresentedObject (id anObject)
234 {
235 OS.objc_msgSend(this.id_, OS.sel_setRepresentedObject_1, anObject !is null ? anObject.id_ : null);
236 }
237
238 public void setState (NSInteger state)
239 {
240 OS.objc_msgSend(this.id_, OS.sel_setState_1, state);
241 }
242
243 public void setSubmenu (NSMenu submenu)
244 {
245 OS.objc_msgSend(this.id_, OS.sel_setSubmenu_1, submenu !is null ? submenu.id_ : null);
246 }
247
248 public void setTag (NSInteger anInt)
249 {
250 OS.objc_msgSend(this.id_, OS.sel_setTag_1, anInt);
251 }
252
253 public void setTarget (id anObject)
254 {
255 OS.objc_msgSend(this.id_, OS.sel_setTarget_1, anObject !is null ? anObject.id_ : null);
256 }
257
258 public void setTitle (NSString aString)
259 {
260 OS.objc_msgSend(this.id_, OS.sel_setTitle_1, aString !is null ? aString.id_ : null);
261 }
262
263 public void setTitleWithMnemonic (NSString stringWithAmpersand)
264 {
265 OS.objc_msgSend(this.id_, OS.sel_setTitleWithMnemonic_1, stringWithAmpersand !is null ? stringWithAmpersand.id_ : null);
266 }
267
268 public void setToolTip (NSString toolTip)
269 {
270 OS.objc_msgSend(this.id_, OS.sel_setToolTip_1, toolTip !is null ? toolTip.id_ : null);
271 }
272
273 public static void setUsesUserKeyEquivalents (bool flag)
274 {
275 OS.objc_msgSend(OS.class_NSMenuItem, OS.sel_setUsesUserKeyEquivalents_1, flag);
276 }
277
278 public void setView (NSView view)
279 {
280 OS.objc_msgSend(this.id_, OS.sel_setView_1, view !is null ? view.id_ : null);
281 }
282
283 public NSInteger state ()
284 {
285 return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_state);
286 }
287
288 public NSMenu submenu ()
289 {
290 objc.id result = OS.objc_msgSend(this.id_, OS.sel_submenu);
291 return result !is null ? new NSMenu(result) : null;
292 }
293
294 public NSInteger tag ()
295 {
296 return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_tag);
297 }
298
299 public id target ()
300 {
301 objc.id result = OS.objc_msgSend(this.id_, OS.sel_target);
302 return result !is null ? new id(result) : null;
303 }
304
305 public NSString title ()
306 {
307 objc.id result = OS.objc_msgSend(this.id_, OS.sel_title);
308 return result !is null ? new NSString(result) : null;
309 }
310
311 public NSString toolTip ()
312 {
313 objc.id result = OS.objc_msgSend(this.id_, OS.sel_toolTip);
314 return result !is null ? new NSString(result) : null;
315 }
316
317 public NSString userKeyEquivalent ()
318 {
319 objc.id result = OS.objc_msgSend(this.id_, OS.sel_userKeyEquivalent);
320 return result !is null ? new NSString(result) : null;
321 }
322
323 public static bool usesUserKeyEquivalents ()
324 {
325 return OS.objc_msgSend(OS.class_NSMenuItem, OS.sel_usesUserKeyEquivalents) !is null;
326 }
327
328 public NSView view ()
329 {
330 objc.id result = OS.objc_msgSend(this.id_, OS.sel_view);
331 return result !is null ? new NSView(result) : null;
332 }
333 120
334 } 121 }