comparison dwt/internal/cocoa/NSButton.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 858e9a565d62
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.NSButton; 14 module dwt.internal.cocoa.NSButton;
15 15
16 import cocoa = dwt.internal.cocoa.id;
16 import dwt.internal.cocoa.NSAttributedString; 17 import dwt.internal.cocoa.NSAttributedString;
17 import dwt.internal.cocoa.NSButtonCell : NSBezelStyle, NSButtonType; 18 import dwt.internal.cocoa.NSButtonCell;
18 import dwt.internal.cocoa.NSCell; 19 import dwt.internal.cocoa.NSCell;
19 import dwt.internal.cocoa.NSControl; 20 import dwt.internal.cocoa.NSControl;
20 import dwt.internal.cocoa.NSEvent; 21 import dwt.internal.cocoa.NSEvent;
21 import dwt.internal.cocoa.NSImage; 22 import dwt.internal.cocoa.NSImage;
22 import dwt.internal.cocoa.NSInteger; 23 import dwt.internal.cocoa.NSInteger;
23 import dwt.internal.cocoa.NSSound; 24 import dwt.internal.cocoa.NSSound;
24 import dwt.internal.cocoa.NSString; 25 import dwt.internal.cocoa.NSString;
25 import dwt.internal.cocoa.OS; 26 import dwt.internal.cocoa.OS;
26 import objc = dwt.internal.objc.runtime; 27 import objc = dwt.internal.objc.runtime;
27 28
28 public class NSButton : NSControl 29 public class NSButton : NSControl {
29 {
30 30
31 public this () 31 public this() {
32 { 32 super();
33 super(); 33 }
34 }
35 34
36 public this (objc.id id) 35 public this(objc.id id) {
37 { 36 super(id);
38 super(id); 37 }
39 }
40 38
41 public bool allowsMixedState () 39 public this(cocoa.id id) {
42 { 40 super(id);
43 return OS.objc_msgSend(this.id_, OS.sel_allowsMixedState) !is null; 41 }
44 }
45 42
46 public NSImage alternateImage () 43 public void setAllowsMixedState(bool flag) {
47 { 44 OS.objc_msgSend(this.id, OS.sel_setAllowsMixedState_, flag);
48 objc.id result = OS.objc_msgSend(this.id_, OS.sel_alternateImage); 45 }
49 return result !is null ? new NSImage(result) : null;
50 }
51 46
52 public NSString alternateTitle () 47 public void setAttributedTitle(NSAttributedString aString) {
53 { 48 OS.objc_msgSend(this.id, OS.sel_setAttributedTitle_, aString !is null ? aString.id : null);
54 objc.id result = OS.objc_msgSend(this.id_, OS.sel_alternateTitle); 49 }
55 return result !is null ? new NSString(result) : null;
56 }
57 50
58 public NSAttributedString attributedAlternateTitle () 51 public void setBezelStyle(NSBezelStyle bezelStyle) {
59 { 52 OS.objc_msgSend(this.id, OS.sel_setBezelStyle_, bezelStyle);
60 objc.id result = OS.objc_msgSend(this.id_, OS.sel_attributedAlternateTitle); 53 }
61 return result !is null ? new NSAttributedString(result) : null;
62 }
63 54
64 public NSAttributedString attributedTitle () 55 public void setBordered(bool flag) {
65 { 56 OS.objc_msgSend(this.id, OS.sel_setBordered_, flag);
66 objc.id result = OS.objc_msgSend(this.id_, OS.sel_attributedTitle); 57 }
67 return result !is null ? new NSAttributedString(result) : null;
68 }
69 58
70 public objc.id bezelStyle () 59 public void setButtonType(NSButtonType aType) {
71 { 60 OS.objc_msgSend(this.id, OS.sel_setButtonType_, aType);
72 return OS.objc_msgSend(this.id_, OS.sel_bezelStyle); 61 }
73 }
74 62
75 public void getPeriodicDelay (float* delay, float* interval) 63 public void setImage(NSImage image) {
76 { 64 OS.objc_msgSend(this.id, OS.sel_setImage_, image !is null ? image.id : null);
77 OS.objc_msgSend(this.id_, OS.sel_getPeriodicDelay_1interval_1, delay, interval); 65 }
78 }
79 66
80 public void highlight (bool flag) 67 public void setImagePosition(NSCellImagePosition aPosition) {
81 { 68 OS.objc_msgSend(this.id, OS.sel_setImagePosition_, aPosition);
82 OS.objc_msgSend(this.id_, OS.sel_highlight_1, flag); 69 }
83 }
84 70
85 public NSImage image () 71 public void setState(NSInteger value) {
86 { 72 OS.objc_msgSend(this.id, OS.sel_setState_, value);
87 objc.id result = OS.objc_msgSend(this.id_, OS.sel_image); 73 }
88 return result !is null ? new NSImage(result) : null;
89 }
90 74
91 public objc.id imagePosition () 75 public void setTitle(NSString aString) {
92 { 76 OS.objc_msgSend(this.id, OS.sel_setTitle_, aString !is null ? aString.id : null);
93 return OS.objc_msgSend(this.id_, OS.sel_imagePosition); 77 }
94 }
95 78
96 public bool isBordered () 79 public NSInteger state() {
97 { 80 return OS.objc_msgSend(this.id, OS.sel_state);
98 return OS.objc_msgSend(this.id_, OS.sel_isBordered) !is null; 81 }
99 }
100 82
101 public bool isTransparent () 83 public static objc.Class cellClass() {
102 { 84 return cast(objc.Class) OS.objc_msgSend(OS.class_NSButton, OS.sel_cellClass);
103 return OS.objc_msgSend(this.id_, OS.sel_isTransparent) !is null; 85 }
104 }
105 86
106 public NSString keyEquivalent () 87 public static void setCellClass(objc.Class factoryId) {
107 { 88 OS.objc_msgSend(OS.class_NSButton, OS.sel_setCellClass_, factoryId);
108 objc.id result = OS.objc_msgSend(this.id_, OS.sel_keyEquivalent); 89 }
109 return result !is null ? new NSString(result) : null;
110 }
111
112 public NSUInteger keyEquivalentModifierMask ()
113 {
114 return cast(NSUInteger) OS.objc_msgSend(this.id_, OS.sel_keyEquivalentModifierMask);
115 }
116
117 public bool performKeyEquivalent (NSEvent key)
118 {
119 return OS.objc_msgSend(this.id_, OS.sel_performKeyEquivalent_1, key !is null ? key.id_ : null) !is null;
120 }
121
122 public void setAllowsMixedState (bool flag)
123 {
124 OS.objc_msgSend(this.id_, OS.sel_setAllowsMixedState_1, flag);
125 }
126
127 public void setAlternateImage (NSImage image)
128 {
129 OS.objc_msgSend(this.id_, OS.sel_setAlternateImage_1, image !is null ? image.id_ : null);
130 }
131
132 public void setAlternateTitle (NSString aString)
133 {
134 OS.objc_msgSend(this.id_, OS.sel_setAlternateTitle_1, aString !is null ? aString.id_ : null);
135 }
136
137 public void setAttributedAlternateTitle (NSAttributedString obj)
138 {
139 OS.objc_msgSend(this.id_, OS.sel_setAttributedAlternateTitle_1, obj !is null ? obj.id_ : null);
140 }
141
142 public void setAttributedTitle (NSAttributedString aString)
143 {
144 OS.objc_msgSend(this.id_, OS.sel_setAttributedTitle_1, aString !is null ? aString.id_ : null);
145 }
146
147 public void setBezelStyle (NSBezelStyle bezelStyle)
148 {
149 OS.objc_msgSend(this.id_, OS.sel_setBezelStyle_1, bezelStyle);
150 }
151
152 public void setBordered (bool flag)
153 {
154 OS.objc_msgSend(this.id_, OS.sel_setBordered_1, flag);
155 }
156
157 public void setButtonType (NSButtonType aType)
158 {
159 OS.objc_msgSend(this.id_, OS.sel_setButtonType_1, aType);
160 }
161
162 public void setImage (NSImage image)
163 {
164 OS.objc_msgSend(this.id_, OS.sel_setImage_1, image !is null ? image.id_ : null);
165 }
166
167 public void setImagePosition (NSCellImagePosition aPosition)
168 {
169 OS.objc_msgSend(this.id_, OS.sel_setImagePosition_1, aPosition);
170 }
171
172 public void setKeyEquivalent (NSString charCode)
173 {
174 OS.objc_msgSend(this.id_, OS.sel_setKeyEquivalent_1, charCode !is null ? charCode.id_ : null);
175 }
176
177 public void setKeyEquivalentModifierMask (NSUInteger mask)
178 {
179 OS.objc_msgSend(this.id_, OS.sel_setKeyEquivalentModifierMask_1, mask);
180 }
181
182 public void setNextState ()
183 {
184 OS.objc_msgSend(this.id_, OS.sel_setNextState);
185 }
186
187 public void setPeriodicDelay (float delay, float interval)
188 {
189 OS.objc_msgSend(this.id_, OS.sel_setPeriodicDelay_1interval_1, delay, interval);
190 }
191
192 public void setShowsBorderOnlyWhileMouseInside (bool show)
193 {
194 OS.objc_msgSend(this.id_, OS.sel_setShowsBorderOnlyWhileMouseInside_1, show);
195 }
196
197 public void setSound (NSSound aSound)
198 {
199 OS.objc_msgSend(this.id_, OS.sel_setSound_1, aSound !is null ? aSound.id_ : null);
200 }
201
202 public void setState (NSInteger value)
203 {
204 OS.objc_msgSend(this.id_, OS.sel_setState_1, value);
205 }
206
207 public void setTitle (NSString aString)
208 {
209 OS.objc_msgSend(this.id_, OS.sel_setTitle_1, aString !is null ? aString.id_ : null);
210 }
211
212 public void setTitleWithMnemonic (NSString StringWithAmpersand)
213 {
214 OS.objc_msgSend(this.id_, OS.sel_setTitleWithMnemonic_1, StringWithAmpersand !is null ? StringWithAmpersand.id_ : null);
215 }
216
217 public void setTransparent (bool flag)
218 {
219 OS.objc_msgSend(this.id_, OS.sel_setTransparent_1, flag);
220 }
221
222 public bool showsBorderOnlyWhileMouseInside ()
223 {
224 return OS.objc_msgSend(this.id_, OS.sel_showsBorderOnlyWhileMouseInside) !is null;
225 }
226
227 public NSSound sound ()
228 {
229 objc.id result = OS.objc_msgSend(this.id_, OS.sel_sound);
230 return result !is null ? new NSSound(result) : null;
231 }
232
233 public NSInteger state ()
234 {
235 return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_state);
236 }
237
238 public NSString title ()
239 {
240 objc.id result = OS.objc_msgSend(this.id_, OS.sel_title);
241 return result !is null ? new NSString(result) : null;
242 }
243 90
244 } 91 }