Mercurial > projects > dstep
comparison dstep/appkit/NSMatrix.d @ 16:19885b43130e
Huge update, the bridge actually works now
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Sun, 03 Jan 2010 22:06:11 +0100 |
parents | |
children | b9de51448c6b |
comparison
equal
deleted
inserted
replaced
15:7ff919f595d5 | 16:19885b43130e |
---|---|
1 /** | |
2 * Copyright: Copyright (c) 2009 Jacob Carlborg. | |
3 * Authors: Jacob Carlborg | |
4 * Version: Initial created: Sep 24, 2009 | |
5 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0) | |
6 */ | |
7 module dstep.appkit.NSMatrix; | |
8 | |
9 import dstep.appkit.NSCell; | |
10 import dstep.appkit.NSColor; | |
11 import dstep.appkit.NSControl; | |
12 import dstep.appkit.NSEvent; | |
13 import dstep.appkit.NSText; | |
14 import dstep.appkit.NSUserInterfaceValidation; | |
15 import dstep.foundation.NSArray; | |
16 import dstep.foundation.NSGeometry; | |
17 import dstep.foundation.NSNotification; | |
18 import dstep.foundation.NSObjCRuntime; | |
19 import dstep.foundation.NSObject; | |
20 import dstep.foundation.NSString; | |
21 import dstep.objc.bridge.Bridge; | |
22 import dstep.objc.objc; | |
23 | |
24 alias NSUInteger NSMatrixMode; | |
25 | |
26 private alias extern (C) NSInteger function (id, id, void *) Comperator; | |
27 | |
28 enum | |
29 { | |
30 NSRadioModeMatrix = 0, | |
31 NSHighlightModeMatrix = 1, | |
32 NSListModeMatrix = 2, | |
33 NSTrackModeMatrix = 3 | |
34 } | |
35 | |
36 struct _MFlags | |
37 { | |
38 uint reservedMatrix; | |
39 uint browserOptimizationsEnabled; | |
40 uint needsRedrawBeforeFirstLiveResizeCache; | |
41 uint tmpAllowNonVisibleCellsToBecomeFirstResponder; | |
42 uint subclassIsSafeForLiveResize; | |
43 uint hasCachedSubclassIsSafeForLiveResize; | |
44 uint liveResizeImageCacheingEnabled; | |
45 uint checkForSimpleTrackingMode; | |
46 uint useSimpleTrackingMode; | |
47 uint refusesFirstResponder; | |
48 uint dontScroll; | |
49 uint changingSelectionWithKeyboard; | |
50 uint onlySetKeyCell; | |
51 uint currentlySelectingCell; | |
52 uint allowsIncrementalSearching; | |
53 uint tabKeyTraversesCellsExplicitlySet; | |
54 uint tabKeyTraversesCells; | |
55 uint drawingAncestor; | |
56 uint autosizeCells; | |
57 uint drawsBackground; | |
58 uint drawsCellBackground; | |
59 uint selectionByRect; | |
60 uint autoscroll; | |
61 uint allowEmptySel; | |
62 uint listMode; | |
63 uint radioMode; | |
64 uint highlightMode; | |
65 } | |
66 | |
67 class NSMatrix : NSControl, INSUserInterfaceValidations | |
68 { | |
69 mixin (ObjcWrap); | |
70 | |
71 NSMatrix initWithFrame (NSRect frameRect) | |
72 { | |
73 id result = invokeObjcSelf!(id, "initWithFrame:", NSRect)(frameRect); | |
74 return result is this.objcObject ? this : (result !is null ? new NSMatrix(result) : null); | |
75 } | |
76 | |
77 this (NSRect frameRect) | |
78 { | |
79 super(NSMatrix.alloc.initWithFrame(frameRect).objcObject); | |
80 } | |
81 | |
82 NSMatrix initWithFrame (NSRect frameRect, uint aMode, NSCell aCell, NSInteger rowsHigh, NSInteger colsWide) | |
83 { | |
84 id result = invokeObjcSelf!(id, "initWithFrame:mode:prototype:numberOfRows:numberOfColumns:", NSRect, uint, NSCell, NSInteger, NSInteger)(frameRect, aMode, aCell, rowsHigh, colsWide); | |
85 return result is this.objcObject ? this : (result !is null ? new NSMatrix(result) : null); | |
86 } | |
87 | |
88 this (NSRect frameRect, uint aMode, NSCell aCell, NSInteger rowsHigh, NSInteger colsWide) | |
89 { | |
90 super(NSMatrix.alloc.initWithFrame(frameRect, aMode, aCell, rowsHigh, colsWide).objcObject); | |
91 } | |
92 | |
93 NSMatrix initWithFrame (NSRect frameRect, uint aMode, Class factoryId, NSInteger rowsHigh, NSInteger colsWide) | |
94 { | |
95 id result = invokeObjcSelf!(id, "initWithFrame:mode:cellClass:numberOfRows:numberOfColumns:", NSRect, uint, Class, NSInteger, NSInteger)(frameRect, aMode, factoryId, rowsHigh, colsWide); | |
96 return result is this.objcObject ? this : (result !is null ? new NSMatrix(result) : null); | |
97 } | |
98 | |
99 this (NSRect frameRect, uint aMode, Class factoryId, NSInteger rowsHigh, NSInteger colsWide) | |
100 { | |
101 super(NSMatrix.alloc.initWithFrame(frameRect, aMode, factoryId, rowsHigh, colsWide).objcObject); | |
102 } | |
103 | |
104 void setCellClass (Class factoryId) | |
105 { | |
106 return invokeObjcSelf!(void, "setCellClass:", Class)(factoryId); | |
107 } | |
108 | |
109 Class cellClass () | |
110 { | |
111 return invokeObjcSelf!(Class, "cellClass"); | |
112 } | |
113 | |
114 Object prototype () | |
115 { | |
116 return invokeObjcSelf!(Object, "prototype"); | |
117 } | |
118 | |
119 void setPrototype (NSCell aCell) | |
120 { | |
121 return invokeObjcSelf!(void, "setPrototype:", NSCell)(aCell); | |
122 } | |
123 | |
124 NSCell makeCellAtRow (NSInteger row, NSInteger col) | |
125 { | |
126 return invokeObjcSelf!(NSCell, "makeCellAtRow:column:", NSInteger, NSInteger)(row, col); | |
127 } | |
128 | |
129 uint mode () | |
130 { | |
131 return invokeObjcSelf!(uint, "mode"); | |
132 } | |
133 | |
134 void setMode (uint aMode) | |
135 { | |
136 return invokeObjcSelf!(void, "setMode:", uint)(aMode); | |
137 } | |
138 | |
139 void setAllowsEmptySelection (bool flag) | |
140 { | |
141 return invokeObjcSelf!(void, "setAllowsEmptySelection:", bool)(flag); | |
142 } | |
143 | |
144 bool allowsEmptySelection () | |
145 { | |
146 return invokeObjcSelf!(bool, "allowsEmptySelection"); | |
147 } | |
148 | |
149 void sendAction (SEL aSelector, Object anObject, bool flag) | |
150 { | |
151 return invokeObjcSelf!(void, "sendAction:to:forAllCells:", SEL, Object, bool)(aSelector, anObject, flag); | |
152 } | |
153 | |
154 NSArray cells () | |
155 { | |
156 return invokeObjcSelf!(NSArray, "cells"); | |
157 } | |
158 | |
159 void sortUsingSelector (SEL comparator) | |
160 { | |
161 return invokeObjcSelf!(void, "sortUsingSelector:", SEL)(comparator); | |
162 } | |
163 | |
164 void sortUsingFunction (Comperator compare, void* context) | |
165 { | |
166 return invokeObjcSelf!(void, "sortUsingFunction:context:", Comperator, void*)(compare, context); | |
167 } | |
168 | |
169 Object selectedCell () | |
170 { | |
171 return invokeObjcSelf!(Object, "selectedCell"); | |
172 } | |
173 | |
174 NSArray selectedCells () | |
175 { | |
176 return invokeObjcSelf!(NSArray, "selectedCells"); | |
177 } | |
178 | |
179 NSInteger selectedRow () | |
180 { | |
181 return invokeObjcSelf!(NSInteger, "selectedRow"); | |
182 } | |
183 | |
184 NSInteger selectedColumn () | |
185 { | |
186 return invokeObjcSelf!(NSInteger, "selectedColumn"); | |
187 } | |
188 | |
189 void setSelectionByRect (bool flag) | |
190 { | |
191 return invokeObjcSelf!(void, "setSelectionByRect:", bool)(flag); | |
192 } | |
193 | |
194 bool isSelectionByRect () | |
195 { | |
196 return invokeObjcSelf!(bool, "isSelectionByRect"); | |
197 } | |
198 | |
199 void setSelectionFrom (NSInteger startPos, NSInteger endPos, NSInteger anchorPos, bool lit) | |
200 { | |
201 return invokeObjcSelf!(void, "setSelectionFrom:to:anchor:highlight:", NSInteger, NSInteger, NSInteger, bool)(startPos, endPos, anchorPos, lit); | |
202 } | |
203 | |
204 void deselectSelectedCell () | |
205 { | |
206 return invokeObjcSelf!(void, "deselectSelectedCell"); | |
207 } | |
208 | |
209 void deselectAllCells () | |
210 { | |
211 return invokeObjcSelf!(void, "deselectAllCells"); | |
212 } | |
213 | |
214 void selectCellAtRow (NSInteger row, NSInteger col) | |
215 { | |
216 return invokeObjcSelf!(void, "selectCellAtRow:column:", NSInteger, NSInteger)(row, col); | |
217 } | |
218 | |
219 void selectAll (Object sender) | |
220 { | |
221 return invokeObjcSelf!(void, "selectAll:", Object)(sender); | |
222 } | |
223 | |
224 bool selectCellWithTag (NSInteger anInt) | |
225 { | |
226 return invokeObjcSelf!(bool, "selectCellWithTag:", NSInteger)(anInt); | |
227 } | |
228 | |
229 NSSize cellSize () | |
230 { | |
231 return invokeObjcSelf!(NSSize, "cellSize"); | |
232 } | |
233 | |
234 void setCellSize (NSSize aSize) | |
235 { | |
236 return invokeObjcSelf!(void, "setCellSize:", NSSize)(aSize); | |
237 } | |
238 | |
239 NSSize intercellSpacing () | |
240 { | |
241 return invokeObjcSelf!(NSSize, "intercellSpacing"); | |
242 } | |
243 | |
244 void setIntercellSpacing (NSSize aSize) | |
245 { | |
246 return invokeObjcSelf!(void, "setIntercellSpacing:", NSSize)(aSize); | |
247 } | |
248 | |
249 void setScrollable (bool flag) | |
250 { | |
251 return invokeObjcSelf!(void, "setScrollable:", bool)(flag); | |
252 } | |
253 | |
254 void setBackgroundColor (NSColor color) | |
255 { | |
256 return invokeObjcSelf!(void, "setBackgroundColor:", NSColor)(color); | |
257 } | |
258 | |
259 NSColor backgroundColor () | |
260 { | |
261 return invokeObjcSelf!(NSColor, "backgroundColor"); | |
262 } | |
263 | |
264 void setCellBackgroundColor (NSColor color) | |
265 { | |
266 return invokeObjcSelf!(void, "setCellBackgroundColor:", NSColor)(color); | |
267 } | |
268 | |
269 NSColor cellBackgroundColor () | |
270 { | |
271 return invokeObjcSelf!(NSColor, "cellBackgroundColor"); | |
272 } | |
273 | |
274 void setDrawsCellBackground (bool flag) | |
275 { | |
276 return invokeObjcSelf!(void, "setDrawsCellBackground:", bool)(flag); | |
277 } | |
278 | |
279 bool drawsCellBackground () | |
280 { | |
281 return invokeObjcSelf!(bool, "drawsCellBackground"); | |
282 } | |
283 | |
284 void setDrawsBackground (bool flag) | |
285 { | |
286 return invokeObjcSelf!(void, "setDrawsBackground:", bool)(flag); | |
287 } | |
288 | |
289 bool drawsBackground () | |
290 { | |
291 return invokeObjcSelf!(bool, "drawsBackground"); | |
292 } | |
293 | |
294 void setState (NSInteger value, NSInteger row, NSInteger col) | |
295 { | |
296 return invokeObjcSelf!(void, "setState:atRow:column:", NSInteger, NSInteger, NSInteger)(value, row, col); | |
297 } | |
298 | |
299 void getNumberOfRows (NSInteger* rowCount, NSInteger* colCount) | |
300 { | |
301 return invokeObjcSelf!(void, "getNumberOfRows:columns:", NSInteger*, NSInteger*)(rowCount, colCount); | |
302 } | |
303 | |
304 NSInteger numberOfRows () | |
305 { | |
306 return invokeObjcSelf!(NSInteger, "numberOfRows"); | |
307 } | |
308 | |
309 NSInteger numberOfColumns () | |
310 { | |
311 return invokeObjcSelf!(NSInteger, "numberOfColumns"); | |
312 } | |
313 | |
314 Object cellAtRow (NSInteger row, NSInteger col) | |
315 { | |
316 return invokeObjcSelf!(Object, "cellAtRow:column:", NSInteger, NSInteger)(row, col); | |
317 } | |
318 | |
319 NSRect cellFrameAtRow (NSInteger row, NSInteger col) | |
320 { | |
321 return invokeObjcSelf!(NSRect, "cellFrameAtRow:column:", NSInteger, NSInteger)(row, col); | |
322 } | |
323 | |
324 bool getRow (NSInteger* row, NSInteger* col, NSCell aCell) | |
325 { | |
326 return invokeObjcSelf!(bool, "getRow:column:ofCell:", NSInteger*, NSInteger*, NSCell)(row, col, aCell); | |
327 } | |
328 | |
329 bool getRow (NSInteger* row, NSInteger* col, NSPoint aPoint) | |
330 { | |
331 return invokeObjcSelf!(bool, "getRow:column:forPoint:", NSInteger*, NSInteger*, NSPoint)(row, col, aPoint); | |
332 } | |
333 | |
334 void renewRows (NSInteger newRows, NSInteger newCols) | |
335 { | |
336 return invokeObjcSelf!(void, "renewRows:columns:", NSInteger, NSInteger)(newRows, newCols); | |
337 } | |
338 | |
339 void putCell (NSCell newCell, NSInteger row, NSInteger col) | |
340 { | |
341 return invokeObjcSelf!(void, "putCell:atRow:column:", NSCell, NSInteger, NSInteger)(newCell, row, col); | |
342 } | |
343 | |
344 void addRow () | |
345 { | |
346 return invokeObjcSelf!(void, "addRow"); | |
347 } | |
348 | |
349 void addRowWithCells (NSArray newCells) | |
350 { | |
351 return invokeObjcSelf!(void, "addRowWithCells:", NSArray)(newCells); | |
352 } | |
353 | |
354 void insertRow (NSInteger row) | |
355 { | |
356 return invokeObjcSelf!(void, "insertRow:", NSInteger)(row); | |
357 } | |
358 | |
359 void insertRow (NSInteger row, NSArray newCells) | |
360 { | |
361 return invokeObjcSelf!(void, "insertRow:withCells:", NSInteger, NSArray)(row, newCells); | |
362 } | |
363 | |
364 void removeRow (NSInteger row) | |
365 { | |
366 return invokeObjcSelf!(void, "removeRow:", NSInteger)(row); | |
367 } | |
368 | |
369 void addColumn () | |
370 { | |
371 return invokeObjcSelf!(void, "addColumn"); | |
372 } | |
373 | |
374 void addColumnWithCells (NSArray newCells) | |
375 { | |
376 return invokeObjcSelf!(void, "addColumnWithCells:", NSArray)(newCells); | |
377 } | |
378 | |
379 void insertColumn (NSInteger column) | |
380 { | |
381 return invokeObjcSelf!(void, "insertColumn:", NSInteger)(column); | |
382 } | |
383 | |
384 void insertColumn (NSInteger column, NSArray newCells) | |
385 { | |
386 return invokeObjcSelf!(void, "insertColumn:withCells:", NSInteger, NSArray)(column, newCells); | |
387 } | |
388 | |
389 void removeColumn (NSInteger col) | |
390 { | |
391 return invokeObjcSelf!(void, "removeColumn:", NSInteger)(col); | |
392 } | |
393 | |
394 Object cellWithTag (NSInteger anInt) | |
395 { | |
396 return invokeObjcSelf!(Object, "cellWithTag:", NSInteger)(anInt); | |
397 } | |
398 | |
399 SEL doubleAction () | |
400 { | |
401 return invokeObjcSelf!(SEL, "doubleAction"); | |
402 } | |
403 | |
404 void setDoubleAction (SEL aSelector) | |
405 { | |
406 return invokeObjcSelf!(void, "setDoubleAction:", SEL)(aSelector); | |
407 } | |
408 | |
409 void setAutosizesCells (bool flag) | |
410 { | |
411 return invokeObjcSelf!(void, "setAutosizesCells:", bool)(flag); | |
412 } | |
413 | |
414 bool autosizesCells () | |
415 { | |
416 return invokeObjcSelf!(bool, "autosizesCells"); | |
417 } | |
418 | |
419 void sizeToCells () | |
420 { | |
421 return invokeObjcSelf!(void, "sizeToCells"); | |
422 } | |
423 | |
424 void setValidateSize (bool flag) | |
425 { | |
426 return invokeObjcSelf!(void, "setValidateSize:", bool)(flag); | |
427 } | |
428 | |
429 void drawCellAtRow (NSInteger row, NSInteger col) | |
430 { | |
431 return invokeObjcSelf!(void, "drawCellAtRow:column:", NSInteger, NSInteger)(row, col); | |
432 } | |
433 | |
434 void highlightCell (bool flag, NSInteger row, NSInteger col) | |
435 { | |
436 return invokeObjcSelf!(void, "highlightCell:atRow:column:", bool, NSInteger, NSInteger)(flag, row, col); | |
437 } | |
438 | |
439 void setAutoscroll (bool flag) | |
440 { | |
441 return invokeObjcSelf!(void, "setAutoscroll:", bool)(flag); | |
442 } | |
443 | |
444 bool isAutoscroll () | |
445 { | |
446 return invokeObjcSelf!(bool, "isAutoscroll"); | |
447 } | |
448 | |
449 void scrollCellToVisibleAtRow (NSInteger row, NSInteger col) | |
450 { | |
451 return invokeObjcSelf!(void, "scrollCellToVisibleAtRow:column:", NSInteger, NSInteger)(row, col); | |
452 } | |
453 | |
454 NSInteger mouseDownFlags () | |
455 { | |
456 return invokeObjcSelf!(NSInteger, "mouseDownFlags"); | |
457 } | |
458 | |
459 void mouseDown (NSEvent theEvent) | |
460 { | |
461 return invokeObjcSelf!(void, "mouseDown:", NSEvent)(theEvent); | |
462 } | |
463 | |
464 bool performKeyEquivalent (NSEvent theEvent) | |
465 { | |
466 return invokeObjcSelf!(bool, "performKeyEquivalent:", NSEvent)(theEvent); | |
467 } | |
468 | |
469 bool sendAction () | |
470 { | |
471 return invokeObjcSelf!(bool, "sendAction"); | |
472 } | |
473 | |
474 void sendDoubleAction () | |
475 { | |
476 return invokeObjcSelf!(void, "sendDoubleAction"); | |
477 } | |
478 | |
479 Object delegate_ () | |
480 { | |
481 return invokeObjcSelf!(Object, "delegate"); | |
482 } | |
483 | |
484 void setDelegate (Object anObject) | |
485 { | |
486 return invokeObjcSelf!(void, "setDelegate:", Object)(anObject); | |
487 } | |
488 | |
489 bool textShouldBeginEditing (NSText textObject) | |
490 { | |
491 return invokeObjcSelf!(bool, "textShouldBeginEditing:", NSText)(textObject); | |
492 } | |
493 | |
494 bool textShouldEndEditing (NSText textObject) | |
495 { | |
496 return invokeObjcSelf!(bool, "textShouldEndEditing:", NSText)(textObject); | |
497 } | |
498 | |
499 void textDidBeginEditing (NSNotification notification) | |
500 { | |
501 return invokeObjcSelf!(void, "textDidBeginEditing:", NSNotification)(notification); | |
502 } | |
503 | |
504 void textDidEndEditing (NSNotification notification) | |
505 { | |
506 return invokeObjcSelf!(void, "textDidEndEditing:", NSNotification)(notification); | |
507 } | |
508 | |
509 void textDidChange (NSNotification notification) | |
510 { | |
511 return invokeObjcSelf!(void, "textDidChange:", NSNotification)(notification); | |
512 } | |
513 | |
514 void selectText (Object sender) | |
515 { | |
516 return invokeObjcSelf!(void, "selectText:", Object)(sender); | |
517 } | |
518 | |
519 Object selectTextAtRow (NSInteger row, NSInteger col) | |
520 { | |
521 return invokeObjcSelf!(Object, "selectTextAtRow:column:", NSInteger, NSInteger)(row, col); | |
522 } | |
523 | |
524 bool acceptsFirstMouse (NSEvent theEvent) | |
525 { | |
526 return invokeObjcSelf!(bool, "acceptsFirstMouse:", NSEvent)(theEvent); | |
527 } | |
528 | |
529 void resetCursorRects () | |
530 { | |
531 return invokeObjcSelf!(void, "resetCursorRects"); | |
532 } | |
533 | |
534 void setToolTip (NSString toolTipString, NSCell cell) | |
535 { | |
536 return invokeObjcSelf!(void, "setToolTip:forCell:", NSString, NSCell)(toolTipString, cell); | |
537 } | |
538 | |
539 NSString toolTipForCell (NSCell cell) | |
540 { | |
541 return invokeObjcSelf!(NSString, "toolTipForCell:", NSCell)(cell); | |
542 } | |
543 | |
544 bool validateUserInterfaceItem (INSValidatedUserInterfaceItem anItem) | |
545 { | |
546 return invokeObjcSelf!(bool, "validateUserInterfaceItem:", INSValidatedUserInterfaceItem)(anItem); | |
547 } | |
548 } | |
549 |