comparison dwt/widgets/Widget.d @ 37:642f460a0908

Fixed a lot of compile errors, a "hello world" app compiles now
author Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
date Fri, 10 Oct 2008 12:29:48 +0200
parents dfcc6c4c4317
children d8635bb48c7c
comparison
equal deleted inserted replaced
36:db5a898b2119 37:642f460a0908
144 checkParent (parent); 144 checkParent (parent);
145 this.style = style; 145 this.style = style;
146 display = parent.display; 146 display = parent.display;
147 } 147 }
148 148
149 void callSuper(objc.id id, int selector, int arg0) { 149 void callSuper(objc.id id, String selector, objc.id arg0) {
150 objc_super super_struct; 150 objc_super super_struct;
151 super_struct.receiver = id; 151 super_struct.receiver = id;
152 super_struct.cls = OS.objc_msgSend(id, OS.sel_superclass); 152 super_struct.cls = cast(objc.Class) OS.objc_msgSend(id, OS.sel_superclass);
153 OS.objc_msgSendSuper(super_struct, selector, arg0); 153 OS.objc_msgSendSuper(&super_struct, selector, arg0);
154 } 154 }
155 155
156 bool acceptsFirstResponder () { 156 bool acceptsFirstResponder () {
157 return false; 157 return false;
158 } 158 }
312 * @exception DWTException <ul> 312 * @exception DWTException <ul>
313 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> 313 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
314 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> 314 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
315 * </ul> 315 * </ul>
316 */ 316 */
317 protected void checkWidget () { 317 public void checkWidget () {
318 Display display = this.display; 318 Display display = this.display;
319 if (display is null) error (DWT.ERROR_WIDGET_DISPOSED); 319 if (display is null) error (DWT.ERROR_WIDGET_DISPOSED);
320 if (display.thread !is Thread.getThis ()) error (DWT.ERROR_THREAD_INVALID_ACCESS); 320 if (display.thread !is Thread.getThis ()) error (DWT.ERROR_THREAD_INVALID_ACCESS);
321 if ((state & DISPOSED) !is 0) error (DWT.ERROR_WIDGET_DISPOSED); 321 if ((state & DISPOSED) !is 0) error (DWT.ERROR_WIDGET_DISPOSED);
322 } 322 }
329 } 329 }
330 330
331 void createHandle () { 331 void createHandle () {
332 } 332 }
333 333
334 /*void createJNIRef () { 334 void createJNIRef () {
335 jniRef = OS.NewGlobalRef(this); 335 jniRef = OS.NewGlobalRef(this);
336 if (jniRef is 0) error (DWT.ERROR_NO_HANDLES); 336 if (jniRef is 0) error (DWT.ERROR_NO_HANDLES);
337 }*/ 337 }
338 338
339 void createWidget () { 339 void createWidget () {
340 //createJNIRef (); 340 createJNIRef ();
341 createHandle (); 341 createHandle ();
342 } 342 }
343 343
344 void destroyWidget () { 344 void destroyWidget () {
345 releaseHandle (); 345 releaseHandle ();
383 } 383 }
384 384
385 void drawRect(objc.id id, NSRect rect) { 385 void drawRect(objc.id id, NSRect rect) {
386 objc_super super_struct; 386 objc_super super_struct;
387 super_struct.receiver = id; 387 super_struct.receiver = id;
388 super_struct.cls = OS.objc_msgSend(id, OS.sel_superclass); 388 super_struct.cls = cast(objc.Class) OS.objc_msgSend(id, OS.sel_superclass);
389 OS.objc_msgSendSuper(super_struct, OS.sel_drawRect_1, rect); 389 OS.objc_msgSendSuper(&super_struct, OS.sel_drawRect_1, rect);
390 } 390 }
391 391
392 void drawWidget (int control, int context, int damageRgn, int visibleRgn, int theEvent) { 392 void drawWidget (int control, int context, int damageRgn, int visibleRgn, int theEvent) {
393 } 393 }
394 394
611 bool isTrimHandle (int trimHandle) { 611 bool isTrimHandle (int trimHandle) {
612 return false; 612 return false;
613 } 613 }
614 614
615 bool isValidSubclass () { 615 bool isValidSubclass () {
616 return Display.isValidClass (getClass ()); 616 return Display.isValidClass (this.classinfo);
617 } 617 }
618 618
619 bool isValidThread () { 619 bool isValidThread () {
620 return getDisplay ().isValidThread (); 620 return getDisplay ().isValidThread ();
621 } 621 }
749 } 749 }
750 750
751 void releaseHandle () { 751 void releaseHandle () {
752 state |= DISPOSED; 752 state |= DISPOSED;
753 display = null; 753 display = null;
754 //if (jniRef !is 0) OS.DeleteGlobalRef(jniRef); 754 if (jniRef !is 0) OS.DeleteGlobalRef(jniRef);
755 //jniRef = 0; 755 jniRef = 0;
756 } 756 }
757 757
758 void releaseParent () { 758 void releaseParent () {
759 /* Do nothing */ 759 /* Do nothing */
760 } 760 }
961 * 961 *
962 * @see #getData() 962 * @see #getData()
963 */ 963 */
964 public void setData (Object data) { 964 public void setData (Object data) {
965 checkWidget(); 965 checkWidget();
966 if (SAFARI_EVENTS_FIX_KEY.equals (data)) { 966 /*if (SAFARI_EVENTS_FIX_KEY.equals (data)) {
967 state |= SAFARI_EVENTS_FIX; 967 state |= SAFARI_EVENTS_FIX;
968 return; 968 return;
969 } 969 }*/
970 if ((state & KEYED_DATA) !is 0) { 970 if ((state & KEYED_DATA) !is 0) {
971 (cast(ArrayWrapperObject) this.data).array [0] = data; 971 (cast(ArrayWrapperObject) this.data).array [0] = data;
972 } else { 972 } else {
973 this.data = data; 973 this.data = data;
974 } 974 }
1004 int index = 1; 1004 int index = 1;
1005 Object [] table = null; 1005 Object [] table = null;
1006 if ((state & KEYED_DATA) !is 0) { 1006 if ((state & KEYED_DATA) !is 0) {
1007 table = (cast(ArrayWrapperObject) data).array; 1007 table = (cast(ArrayWrapperObject) data).array;
1008 while (index < table.length) { 1008 while (index < table.length) {
1009 if (key.equals (table [index])) break; 1009 String tablekey = (cast(ArrayWrapperString)table[index]).array;
1010 if (key.equals (tablekey)) break;
1010 index += 2; 1011 index += 2;
1011 } 1012 }
1012 } 1013 }
1013 if (value !is null) { 1014 if (value !is null) {
1014 if ((state & KEYED_DATA) !is 0) { 1015 if ((state & KEYED_DATA) !is 0) {
1015 if (index is table.length) { 1016 if (index is table.length) {
1016 Object [] newTable = new Object [table.length + 2]; 1017 Object [] newTable = new Object [table.length + 2];
1017 System.arraycopy (table, 0, newTable, 0, table.length); 1018 System.arraycopy (table, 0, newTable, 0, table.length);
1018 data = table = newTable; 1019 table = newTable;
1020 data = new ArrayWrapperObject( table );
1019 } 1021 }
1020 } else { 1022 } else {
1021 table = new Object [3]; 1023 table = new Object [3];
1022 table [0] = data; 1024 table [0] = data;
1023 data = table; 1025 data = new ArrayWrapperObject( table );
1024 state |= KEYED_DATA; 1026 state |= KEYED_DATA;
1025 } 1027 }
1026 table [index] = key; 1028 table [index] = new ArrayWrapperString( key );
1027 table [index + 1] = value; 1029 table [index + 1] = value;
1028 } else { 1030 } else {
1029 if ((state & KEYED_DATA) !is 0) { 1031 if ((state & KEYED_DATA) !is 0) {
1030 if (index !is table.length) { 1032 if (index !is table.length) {
1031 int length = table.length - 2; 1033 int length = table.length - 2;
1034 state &= ~KEYED_DATA; 1036 state &= ~KEYED_DATA;
1035 } else { 1037 } else {
1036 Object [] newTable = new Object [length]; 1038 Object [] newTable = new Object [length];
1037 System.arraycopy (table, 0, newTable, 0, index); 1039 System.arraycopy (table, 0, newTable, 0, index);
1038 System.arraycopy (table, index + 2, newTable, index, length - index); 1040 System.arraycopy (table, index + 2, newTable, index, length - index);
1039 data = newTable; 1041 data = new ArrayWrapperObject( newTable );
1040 } 1042 }
1041 } 1043 }
1042 } 1044 }
1043 } 1045 }
1044 } 1046 }
1249 String string = "*Disposed*"; 1251 String string = "*Disposed*";
1250 if (!isDisposed ()) { 1252 if (!isDisposed ()) {
1251 string = "*Wrong Thread*"; 1253 string = "*Wrong Thread*";
1252 if (isValidThread ()) string = getNameText (); 1254 if (isValidThread ()) string = getNameText ();
1253 } 1255 }
1254 return getName () + " {" + string + "}"; 1256 return getName () ~ " {" ~ string ~ "}";
1255 } 1257 }
1256 1258
1257 void willSelectTabViewItem(int tabView, int tabViewItem) { 1259 void willSelectTabViewItem(int tabView, int tabViewItem) {
1258 } 1260 }
1259 1261
1268 1270
1269 void windowDidBecomeKey(int notification) { 1271 void windowDidBecomeKey(int notification) {
1270 } 1272 }
1271 1273
1272 void windowSendEvent(objc.id id, objc.id event) { 1274 void windowSendEvent(objc.id id, objc.id event) {
1273 callSuper(objc.id, OS.sel_sendEvent_1, event); 1275 callSuper(id, OS.sel_sendEvent_1, event);
1274 } 1276 }
1275 1277
1276 bool windowShouldClose(int window) { 1278 bool windowShouldClose(int window) {
1277 return false; 1279 return false;
1278 } 1280 }