Mercurial > projects > dwt-mac
comparison dwt/internal/cocoa/NSMenuView.d @ 1:8b48be5454ce
The internal cocoa classes compile now
author | Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com> |
---|---|
date | Tue, 19 Aug 2008 17:35:17 +0200 |
parents | 380af2bdd8e5 |
children | f565d3a95c0a |
comparison
equal
deleted
inserted
replaced
0:380af2bdd8e5 | 1:8b48be5454ce |
---|---|
11 * Port to the D Programming language: | 11 * Port to the D Programming language: |
12 * Jacob Carlborg <jacob.carlborg@gmail.com> | 12 * Jacob Carlborg <jacob.carlborg@gmail.com> |
13 *******************************************************************************/ | 13 *******************************************************************************/ |
14 module dwt.internal.cocoa.NSMenuView; | 14 module dwt.internal.cocoa.NSMenuView; |
15 | 15 |
16 import dwt.internal.cocoa.CGFloat; | |
17 import dwt.internal.cocoa.NSEvent; | |
18 import dwt.internal.cocoa.NSFont; | |
16 import dwt.internal.cocoa.NSInteger; | 19 import dwt.internal.cocoa.NSInteger; |
17 import dwt.internal.cocoa.NSRect : NSRectEdge; | 20 import dwt.internal.cocoa.NSMenu; |
21 import dwt.internal.cocoa.NSMenuItemCell; | |
22 import dwt.internal.cocoa.NSNotification; | |
23 import dwt.internal.cocoa.NSPoint; | |
24 import dwt.internal.cocoa.NSRect; | |
25 import dwt.internal.cocoa.NSScreen; | |
18 import dwt.internal.cocoa.NSView; | 26 import dwt.internal.cocoa.NSView; |
19 import dwt.internal.cocoa.OS; | 27 import dwt.internal.cocoa.OS; |
20 import objc = dwt.internal.objc.runtime; | 28 import objc = dwt.internal.objc.runtime; |
21 | 29 |
22 public class NSMenuView : NSView | 30 public class NSMenuView : NSView |
32 super(id); | 40 super(id); |
33 } | 41 } |
34 | 42 |
35 public void attachSubmenuForItemAtIndex (NSInteger index) | 43 public void attachSubmenuForItemAtIndex (NSInteger index) |
36 { | 44 { |
37 OS.objc_msgSend(this.id, OS.sel_attachSubmenuForItemAtIndex_1, index); | 45 OS.objc_msgSend(this.id_, OS.sel_attachSubmenuForItemAtIndex_1, index); |
38 } | 46 } |
39 | 47 |
40 public NSMenu attachedMenu () | 48 public NSMenu attachedMenu () |
41 { | 49 { |
42 objc.id result = OS.objc_msgSend(this.id, OS.sel_attachedMenu); | 50 objc.id result = OS.objc_msgSend(this.id_, OS.sel_attachedMenu); |
43 return result !is null ? new NSMenu(result) : null; | 51 return result !is null ? new NSMenu(result) : null; |
44 } | 52 } |
45 | 53 |
46 public NSMenuView attachedMenuView () | 54 public NSMenuView attachedMenuView () |
47 { | 55 { |
48 objc.id result = OS.objc_msgSend(this.id, OS.sel_attachedMenuView); | 56 objc.id result = OS.objc_msgSend(this.id_, OS.sel_attachedMenuView); |
49 return result is this.id ? this : (result !is null ? new NSMenuView(result) : null); | 57 return result is this.id_ ? this : (result !is null ? new NSMenuView(result) : null); |
50 } | 58 } |
51 | 59 |
52 public void detachSubmenu () | 60 public void detachSubmenu () |
53 { | 61 { |
54 OS.objc_msgSend(this.id, OS.sel_detachSubmenu); | 62 OS.objc_msgSend(this.id_, OS.sel_detachSubmenu); |
55 } | 63 } |
56 | 64 |
57 public NSFont font () | 65 public NSFont font () |
58 { | 66 { |
59 objc.id result = OS.objc_msgSend(this.id, OS.sel_font); | 67 objc.id result = OS.objc_msgSend(this.id_, OS.sel_font); |
60 return result !is null ? new NSFont(result) : null; | 68 return result !is null ? new NSFont(result) : null; |
61 } | 69 } |
62 | 70 |
63 public NSInteger highlightedItemIndex () | 71 public NSInteger highlightedItemIndex () |
64 { | 72 { |
65 return OS.objc_msgSend(this.id, OS.sel_highlightedItemIndex); | 73 return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_highlightedItemIndex); |
66 } | 74 } |
67 | 75 |
68 public CGFloat horizontalEdgePadding () | 76 public CGFloat horizontalEdgePadding () |
69 { | 77 { |
70 return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_horizontalEdgePadding); | 78 return cast(CGFloat) OS.objc_msgSend_fpret(this.id_, OS.sel_horizontalEdgePadding); |
71 } | 79 } |
72 | 80 |
73 public CGFloat imageAndTitleOffset () | 81 public CGFloat imageAndTitleOffset () |
74 { | 82 { |
75 return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_imageAndTitleOffset); | 83 return cast(CGFloat) OS.objc_msgSend_fpret(this.id_, OS.sel_imageAndTitleOffset); |
76 } | 84 } |
77 | 85 |
78 public CGFloat imageAndTitleWidth () | 86 public CGFloat imageAndTitleWidth () |
79 { | 87 { |
80 return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_imageAndTitleWidth); | 88 return cast(CGFloat) OS.objc_msgSend_fpret(this.id_, OS.sel_imageAndTitleWidth); |
81 } | 89 } |
82 | 90 |
83 public NSInteger indexOfItemAtPoint (NSPoint point) | 91 public NSInteger indexOfItemAtPoint (NSPoint point) |
84 { | 92 { |
85 return OS.objc_msgSend(this.id, OS.sel_indexOfItemAtPoint_1, point); | 93 return cast(NSInteger) OS.objc_msgSend(this.id_, OS.sel_indexOfItemAtPoint_1, point); |
86 } | 94 } |
87 | 95 |
88 public NSMenuView initAsTearOff () | 96 public NSMenuView initAsTearOff () |
89 { | 97 { |
90 objc.id result = OS.objc_msgSend(this.id, OS.sel_initAsTearOff); | 98 objc.id result = OS.objc_msgSend(this.id_, OS.sel_initAsTearOff); |
91 return result !is null ? this : null; | 99 return result !is null ? this : null; |
92 } | 100 } |
93 | 101 |
94 public NSRect innerRect () | 102 public NSRect innerRect () |
95 { | 103 { |
96 NSRect result; | 104 NSRect result; |
97 OS.objc_msgSend_stret(result, this.id, OS.sel_innerRect); | 105 OS.objc_msgSend_stret(&result, this.id_, OS.sel_innerRect); |
98 return result; | 106 return result; |
99 } | 107 } |
100 | 108 |
101 public bool isAttached () | 109 public bool isAttached () |
102 { | 110 { |
103 return OS.objc_msgSend(this.id, OS.sel_isAttached) !is null; | 111 return OS.objc_msgSend(this.id_, OS.sel_isAttached) !is null; |
104 } | 112 } |
105 | 113 |
106 public bool isHorizontal () | 114 public bool isHorizontal () |
107 { | 115 { |
108 return OS.objc_msgSend(this.id, OS.sel_isHorizontal) !is null; | 116 return OS.objc_msgSend(this.id_, OS.sel_isHorizontal) !is null; |
109 } | 117 } |
110 | 118 |
111 public bool isTornOff () | 119 public bool isTornOff () |
112 { | 120 { |
113 return OS.objc_msgSend(this.id, OS.sel_isTornOff) !is null; | 121 return OS.objc_msgSend(this.id_, OS.sel_isTornOff) !is null; |
114 } | 122 } |
115 | 123 |
116 public void itemAdded (NSNotification notification) | 124 public void itemAdded (NSNotification notification) |
117 { | 125 { |
118 OS.objc_msgSend(this.id, OS.sel_itemAdded_1, notification !is null ? notification.id : null); | 126 OS.objc_msgSend(this.id_, OS.sel_itemAdded_1, notification !is null ? notification.id_ : null); |
119 } | 127 } |
120 | 128 |
121 public void itemChanged (NSNotification notification) | 129 public void itemChanged (NSNotification notification) |
122 { | 130 { |
123 OS.objc_msgSend(this.id, OS.sel_itemChanged_1, notification !is null ? notification.id : null); | 131 OS.objc_msgSend(this.id_, OS.sel_itemChanged_1, notification !is null ? notification.id_ : null); |
124 } | 132 } |
125 | 133 |
126 public void itemRemoved (NSNotification notification) | 134 public void itemRemoved (NSNotification notification) |
127 { | 135 { |
128 OS.objc_msgSend(this.id, OS.sel_itemRemoved_1, notification !is null ? notification.id : null); | 136 OS.objc_msgSend(this.id_, OS.sel_itemRemoved_1, notification !is null ? notification.id_ : null); |
129 } | 137 } |
130 | 138 |
131 public CGFloat keyEquivalentOffset () | 139 public CGFloat keyEquivalentOffset () |
132 { | 140 { |
133 return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_keyEquivalentOffset); | 141 return cast(CGFloat) OS.objc_msgSend_fpret(this.id_, OS.sel_keyEquivalentOffset); |
134 } | 142 } |
135 | 143 |
136 public CGFloat keyEquivalentWidth () | 144 public CGFloat keyEquivalentWidth () |
137 { | 145 { |
138 return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_keyEquivalentWidth); | 146 return cast(CGFloat) OS.objc_msgSend_fpret(this.id_, OS.sel_keyEquivalentWidth); |
139 } | 147 } |
140 | 148 |
141 public NSPoint locationForSubmenu (NSMenu aSubmenu) | 149 public NSPoint locationForSubmenu (NSMenu aSubmenu) |
142 { | 150 { |
143 NSPoint result; | 151 NSPoint result; |
144 OS.objc_msgSend_stret(result, this.id, OS.sel_locationForSubmenu_1, aSubmenu !is null ? aSubmenu.id : null); | 152 OS.objc_msgSend_stret(&result, this.id_, OS.sel_locationForSubmenu_1, aSubmenu !is null ? aSubmenu.id_ : null); |
145 return result; | 153 return result; |
146 } | 154 } |
147 | 155 |
148 public NSMenu menu () | 156 public NSMenu menu () |
149 { | 157 { |
150 objc.id result = OS.objc_msgSend(this.id, OS.sel_menu); | 158 objc.id result = OS.objc_msgSend(this.id_, OS.sel_menu); |
151 return result !is null ? new NSMenu(result) : null; | 159 return result !is null ? new NSMenu(result) : null; |
152 } | 160 } |
153 | 161 |
154 public static CGFloat menuBarHeight () | 162 public static CGFloat menuBarHeight () |
155 { | 163 { |
156 return cast(CGFloat) OS.objc_msgSend_fpret(OS.class_NSMenuView, OS.sel_menuBarHeight); | 164 return cast(CGFloat) OS.objc_msgSend_fpret(OS.class_NSMenuView, OS.sel_menuBarHeight); |
157 } | 165 } |
158 | 166 |
159 public NSMenuItemCell menuItemCellForItemAtIndex (NSInteger index) | 167 public NSMenuItemCell menuItemCellForItemAtIndex (NSInteger index) |
160 { | 168 { |
161 objc.id result = OS.objc_msgSend(this.id, OS.sel_menuItemCellForItemAtIndex_1, index); | 169 objc.id result = OS.objc_msgSend(this.id_, OS.sel_menuItemCellForItemAtIndex_1, index); |
162 return result !is null ? new NSMenuItemCell(result) : null; | 170 return result !is null ? new NSMenuItemCell(result) : null; |
163 } | 171 } |
164 | 172 |
165 public bool needsSizing () | 173 public bool needsSizing () |
166 { | 174 { |
167 return OS.objc_msgSend(this.id, OS.sel_needsSizing) !is null; | 175 return OS.objc_msgSend(this.id_, OS.sel_needsSizing) !is null; |
168 } | 176 } |
169 | 177 |
170 public void performActionWithHighlightingForItemAtIndex (NSInteger index) | 178 public void performActionWithHighlightingForItemAtIndex (NSInteger index) |
171 { | 179 { |
172 OS.objc_msgSend(this.id, OS.sel_performActionWithHighlightingForItemAtIndex_1, index); | 180 OS.objc_msgSend(this.id_, OS.sel_performActionWithHighlightingForItemAtIndex_1, index); |
173 } | 181 } |
174 | 182 |
175 public NSRect rectOfItemAtIndex (NSInteger) | 183 public NSRect rectOfItemAtIndex (NSInteger index) |
176 { | 184 { |
177 NSRect result; | 185 NSRect result; |
178 OS.objc_msgSend_stret(result, this.id, OS.sel_rectOfItemAtIndex_1, index); | 186 OS.objc_msgSend_stret(&result, this.id_, OS.sel_rectOfItemAtIndex_1, index); |
179 return result; | 187 return result; |
180 } | 188 } |
181 | 189 |
182 public void setFont (NSFont font) | 190 public void setFont (NSFont font) |
183 { | 191 { |
184 OS.objc_msgSend(this.id, OS.sel_setFont_1, font !is null ? font.id : null); | 192 OS.objc_msgSend(this.id_, OS.sel_setFont_1, font !is null ? font.id_ : null); |
185 } | 193 } |
186 | 194 |
187 public void setHighlightedItemIndex (NSInteger index) | 195 public void setHighlightedItemIndex (NSInteger index) |
188 { | 196 { |
189 OS.objc_msgSend(this.id, OS.sel_setHighlightedItemIndex_1, index); | 197 OS.objc_msgSend(this.id_, OS.sel_setHighlightedItemIndex_1, index); |
190 } | 198 } |
191 | 199 |
192 public void setHorizontal (bool flag) | 200 public void setHorizontal (bool flag) |
193 { | 201 { |
194 OS.objc_msgSend(this.id, OS.sel_setHorizontal_1, flag); | 202 OS.objc_msgSend(this.id_, OS.sel_setHorizontal_1, flag); |
195 } | 203 } |
196 | 204 |
197 public void setHorizontalEdgePadding (CGFloat pad) | 205 public void setHorizontalEdgePadding (CGFloat pad) |
198 { | 206 { |
199 OS.objc_msgSend(this.id, OS.sel_setHorizontalEdgePadding_1, pad); | 207 OS.objc_msgSend(this.id_, OS.sel_setHorizontalEdgePadding_1, pad); |
200 } | 208 } |
201 | 209 |
202 public void setMenu (NSMenu menu) | 210 public void setMenu (NSMenu menu) |
203 { | 211 { |
204 OS.objc_msgSend(this.id, OS.sel_setMenu_1, menu !is null ? menu.id : null); | 212 OS.objc_msgSend(this.id_, OS.sel_setMenu_1, menu !is null ? menu.id_ : null); |
205 } | 213 } |
206 | 214 |
207 public void setMenuItemCell (NSMenuItemCell cell, NSInteger index) | 215 public void setMenuItemCell (NSMenuItemCell cell, NSInteger index) |
208 { | 216 { |
209 OS.objc_msgSend(this.id, OS.sel_setMenuItemCell_1forItemAtIndex_1, cell !is null ? cell.id : null, index); | 217 OS.objc_msgSend(this.id_, OS.sel_setMenuItemCell_1forItemAtIndex_1, cell !is null ? cell.id_ : null, index); |
210 } | 218 } |
211 | 219 |
212 public void setNeedsDisplayForItemAtIndex (NSInteger index) | 220 public void setNeedsDisplayForItemAtIndex (NSInteger index) |
213 { | 221 { |
214 OS.objc_msgSend(this.id, OS.sel_setNeedsDisplayForItemAtIndex_1, index); | 222 OS.objc_msgSend(this.id_, OS.sel_setNeedsDisplayForItemAtIndex_1, index); |
215 } | 223 } |
216 | 224 |
217 public void setNeedsSizing (bool flag) | 225 public void setNeedsSizing (bool flag) |
218 { | 226 { |
219 OS.objc_msgSend(this.id, OS.sel_setNeedsSizing_1, flag); | 227 OS.objc_msgSend(this.id_, OS.sel_setNeedsSizing_1, flag); |
220 } | 228 } |
221 | 229 |
222 public void setWindowFrameForAttachingToRect (NSRect screenRect, NSScreen screen, NSRectEdge edge, NSInteger selectedItemIndex) | 230 public void setWindowFrameForAttachingToRect (NSRect screenRect, NSScreen screen, NSRectEdge edge, NSInteger selectedItemIndex) |
223 { | 231 { |
224 OS.objc_msgSend(this.id, OS.sel_setWindowFrameForAttachingToRect_1onScreen_1preferredEdge_1popUpSelectedItem_1, screenRect, | 232 OS.objc_msgSend(this.id_, OS.sel_setWindowFrameForAttachingToRect_1onScreen_1preferredEdge_1popUpSelectedItem_1, screenRect, |
225 screen !is null ? screen.id : null, edge, selectedItemIndex); | 233 screen !is null ? screen.id_ : null, edge, selectedItemIndex); |
226 } | 234 } |
227 | 235 |
228 public void sizeToFit () | 236 public void sizeToFit () |
229 { | 237 { |
230 OS.objc_msgSend(this.id, OS.sel_sizeToFit); | 238 OS.objc_msgSend(this.id_, OS.sel_sizeToFit); |
231 } | 239 } |
232 | 240 |
233 public CGFloat stateImageOffset () | 241 public CGFloat stateImageOffset () |
234 { | 242 { |
235 return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_stateImageOffset); | 243 return cast(CGFloat) OS.objc_msgSend_fpret(this.id_, OS.sel_stateImageOffset); |
236 } | 244 } |
237 | 245 |
238 public CGFloat stateImageWidth () | 246 public CGFloat stateImageWidth () |
239 { | 247 { |
240 return cast(CGFloat) OS.objc_msgSend_fpret(this.id, OS.sel_stateImageWidth); | 248 return cast(CGFloat) OS.objc_msgSend_fpret(this.id_, OS.sel_stateImageWidth); |
241 } | 249 } |
242 | 250 |
243 public bool trackWithEvent (NSEvent event) | 251 public bool trackWithEvent (NSEvent event) |
244 { | 252 { |
245 return OS.objc_msgSend(this.id, OS.sel_trackWithEvent_1, event !is null ? event.id : null) !is null; | 253 return OS.objc_msgSend(this.id_, OS.sel_trackWithEvent_1, event !is null ? event.id_ : null) !is null; |
246 } | 254 } |
247 | 255 |
248 public void update () | 256 public void update () |
249 { | 257 { |
250 OS.objc_msgSend(this.id, OS.sel_update); | 258 OS.objc_msgSend(this.id_, OS.sel_update); |
251 } | 259 } |
252 | 260 |
253 } | 261 } |