comparison dwt/widgets/Widget.d @ 255:5a30aa9820f3

removed tango.stdc.stringz imports and allow null for arrays and string arguments.
author Frank Benoit <benoit@tionex.de>
date Sun, 15 Jun 2008 22:32:20 +0200
parents ce446666f5a2
children c0d810de7093
comparison
equal deleted inserted replaced
254:8bca790583c3 255:5a30aa9820f3
23 import dwt.widgets.Event; 23 import dwt.widgets.Event;
24 import dwt.widgets.EventTable; 24 import dwt.widgets.EventTable;
25 import dwt.widgets.Listener; 25 import dwt.widgets.Listener;
26 import dwt.widgets.TypedListener; 26 import dwt.widgets.TypedListener;
27 27
28 import tango.stdc.stringz;
29 import tango.stdc.string; 28 import tango.stdc.string;
30 import tango.core.Thread; 29 import tango.core.Thread;
31 30
32 //version=LOG; 31 //version=LOG;
33 version(LOG){ 32 version(LOG){
573 * </p> 572 * </p>
574 * 573 *
575 * @param key the name of the property 574 * @param key the name of the property
576 * @return the value of the property or null if it has not been set 575 * @return the value of the property or null if it has not been set
577 * 576 *
578 * @exception IllegalArgumentException <ul>
579 * <li>ERROR_NULL_ARGUMENT - if the key is null</li>
580 * </ul>
581 * @exception DWTException <ul> 577 * @exception DWTException <ul>
582 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> 578 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
583 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> 579 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
584 * </ul> 580 * </ul>
585 * 581 *
586 * @see #setData(String, Object) 582 * @see #setData(String, Object)
587 */ 583 */
588 public Object getData (String key) { 584 public Object getData (String key) {
589 checkWidget(); 585 checkWidget();
590 if (key is null) error (DWT.ERROR_NULL_ARGUMENT); 586 // DWT extension: allow null for zero length string
587 //if (key is null) error (DWT.ERROR_NULL_ARGUMENT);
591 if ((state & KEYED_DATA) !is 0) { 588 if ((state & KEYED_DATA) !is 0) {
592 Object[] table = (cast(ArrayWrapperObject) data).array; 589 Object[] table = (cast(ArrayWrapperObject) data).array;
593 for (int i=1; i<table.length; i+=2) { 590 for (int i=1; i<table.length; i+=2) {
594 String tablekey = (cast(ArrayWrapperString) table[i]).array; 591 String tablekey = (cast(ArrayWrapperString) table[i]).array;
595 if (key ==/*eq*/ tablekey ) return table [i+1]; 592 if (key ==/*eq*/ tablekey ) return table [i+1];
1421 * </p> 1418 * </p>
1422 * 1419 *
1423 * @param key the name of the property 1420 * @param key the name of the property
1424 * @param value the new value for the property 1421 * @param value the new value for the property
1425 * 1422 *
1426 * @exception IllegalArgumentException <ul>
1427 * <li>ERROR_NULL_ARGUMENT - if the key is null</li>
1428 * </ul>
1429 * @exception DWTException <ul> 1423 * @exception DWTException <ul>
1430 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> 1424 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
1431 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> 1425 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
1432 * </ul> 1426 * </ul>
1433 * 1427 *
1434 * @see #getData(String) 1428 * @see #getData(String)
1435 */ 1429 */
1436 public void setData (String key, Object value) { 1430 public void setData (String key, Object value) {
1437 checkWidget(); 1431 checkWidget();
1438 if (key.length is 0) error (DWT.ERROR_NULL_ARGUMENT); 1432 // DWT extension: allow null for zero length string
1433 //if (key is null) error (DWT.ERROR_NULL_ARGUMENT);
1439 int index = 1; 1434 int index = 1;
1440 Object [] table = null; 1435 Object [] table = null;
1441 if ((state & KEYED_DATA) !is 0) { 1436 if ((state & KEYED_DATA) !is 0) {
1442 table = (cast(ArrayWrapperObject) data).array; 1437 table = (cast(ArrayWrapperObject) data).array;
1443 while (index < table.length) { 1438 while (index < table.length) {
1444 String tablekey = (cast(ArrayWrapperString)table[index]).array; 1439 String tablekey = (cast(ArrayWrapperString)table[index]).array;
1445 if (key ==/*eq*/ tablekey ) break; 1440 if (key.equals (tablekey) ) break;
1446 index += 2; 1441 index += 2;
1447 } 1442 }
1448 } 1443 }
1449 if (value !is null) { 1444 if (value !is null) {
1450 if ((state & KEYED_DATA) !is 0) { 1445 if ((state & KEYED_DATA) !is 0) {