Mercurial > projects > dwt-win
comparison dwt/widgets/List.d @ 212:ab60f3309436
reverted the char[] to String and use the an alias.
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Mon, 05 May 2008 00:12:38 +0200 |
parents | 6f75fdfa1bcd |
children | 36f5cb12e1a2 |
comparison
equal
deleted
inserted
replaced
211:ff59aeb96cac | 212:ab60f3309436 |
---|---|
116 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | 116 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> |
117 * </ul> | 117 * </ul> |
118 * | 118 * |
119 * @see #add(String,int) | 119 * @see #add(String,int) |
120 */ | 120 */ |
121 public void add (char[] string) { | 121 public void add (String string) { |
122 checkWidget (); | 122 checkWidget (); |
123 if (string is null) error (DWT.ERROR_NULL_ARGUMENT); | 123 if (string is null) error (DWT.ERROR_NULL_ARGUMENT); |
124 TCHAR* buffer = StrToTCHARz ( getCodePage (), string); | 124 TCHAR* buffer = StrToTCHARz ( getCodePage (), string); |
125 int result = OS.SendMessage (handle, OS.LB_ADDSTRING, 0, buffer); | 125 int result = OS.SendMessage (handle, OS.LB_ADDSTRING, 0, buffer); |
126 if (result is OS.LB_ERR) error (DWT.ERROR_ITEM_NOT_ADDED); | 126 if (result is OS.LB_ERR) error (DWT.ERROR_ITEM_NOT_ADDED); |
148 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | 148 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> |
149 * </ul> | 149 * </ul> |
150 * | 150 * |
151 * @see #add(String) | 151 * @see #add(String) |
152 */ | 152 */ |
153 public void add (char[] string, int index) { | 153 public void add (String string, int index) { |
154 checkWidget (); | 154 checkWidget (); |
155 if (string is null) error (DWT.ERROR_NULL_ARGUMENT); | 155 if (string is null) error (DWT.ERROR_NULL_ARGUMENT); |
156 if (index is -1) error (DWT.ERROR_INVALID_RANGE); | 156 if (index is -1) error (DWT.ERROR_INVALID_RANGE); |
157 TCHAR* buffer = StrToTCHARz(getCodePage (), string); | 157 TCHAR* buffer = StrToTCHARz(getCodePage (), string); |
158 int result = OS.SendMessage (handle, OS.LB_INSERTSTRING, index, buffer); | 158 int result = OS.SendMessage (handle, OS.LB_INSERTSTRING, index, buffer); |
423 * @exception DWTException <ul> | 423 * @exception DWTException <ul> |
424 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | 424 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
425 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | 425 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> |
426 * </ul> | 426 * </ul> |
427 */ | 427 */ |
428 public char[] getItem (int index) { | 428 public String getItem (int index) { |
429 checkWidget (); | 429 checkWidget (); |
430 int length_ = OS.SendMessage (handle, OS.LB_GETTEXTLEN, index, 0); | 430 int length_ = OS.SendMessage (handle, OS.LB_GETTEXTLEN, index, 0); |
431 if (length_ !is OS.LB_ERR) { | 431 if (length_ !is OS.LB_ERR) { |
432 TCHAR[] buffer = NewTCHARs (getCodePage (), length_ + 1); | 432 TCHAR[] buffer = NewTCHARs (getCodePage (), length_ + 1); |
433 int result = OS.SendMessage (handle, OS.LB_GETTEXT, index, buffer.ptr); | 433 int result = OS.SendMessage (handle, OS.LB_GETTEXT, index, buffer.ptr); |
488 * @exception DWTException <ul> | 488 * @exception DWTException <ul> |
489 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | 489 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
490 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | 490 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> |
491 * </ul> | 491 * </ul> |
492 */ | 492 */ |
493 public char[] [] getItems () { | 493 public String [] getItems () { |
494 checkWidget (); | 494 checkWidget (); |
495 int count = getItemCount (); | 495 int count = getItemCount (); |
496 char[] [] result = new char[] [count]; | 496 String [] result = new String [count]; |
497 for (int i=0; i<count; i++) result [i] = getItem (i); | 497 for (int i=0; i<count; i++) result [i] = getItem (i); |
498 return result; | 498 return result; |
499 } | 499 } |
500 | 500 |
501 /** | 501 /** |
512 * @exception DWTException <ul> | 512 * @exception DWTException <ul> |
513 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | 513 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
514 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | 514 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> |
515 * </ul> | 515 * </ul> |
516 */ | 516 */ |
517 public char[] [] getSelection () { | 517 public String [] getSelection () { |
518 checkWidget (); | 518 checkWidget (); |
519 int [] indices = getSelectionIndices (); | 519 int [] indices = getSelectionIndices (); |
520 char[] [] result = new char[] [indices.length]; | 520 String [] result = new String [indices.length]; |
521 for (int i=0; i<indices.length; i++) { | 521 for (int i=0; i<indices.length; i++) { |
522 result [i] = getItem (indices [i]); | 522 result [i] = getItem (indices [i]); |
523 } | 523 } |
524 return result; | 524 return result; |
525 } | 525 } |
640 * @exception DWTException <ul> | 640 * @exception DWTException <ul> |
641 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | 641 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
642 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | 642 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> |
643 * </ul> | 643 * </ul> |
644 */ | 644 */ |
645 public int indexOf (char[] string) { | 645 public int indexOf (String string) { |
646 return indexOf (string, 0); | 646 return indexOf (string, 0); |
647 } | 647 } |
648 | 648 |
649 /** | 649 /** |
650 * Searches the receiver's list starting at the given, | 650 * Searches the receiver's list starting at the given, |
663 * @exception DWTException <ul> | 663 * @exception DWTException <ul> |
664 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | 664 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
665 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | 665 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> |
666 * </ul> | 666 * </ul> |
667 */ | 667 */ |
668 public int indexOf (char[] string, int start) { | 668 public int indexOf (String string, int start) { |
669 checkWidget (); | 669 checkWidget (); |
670 if (string is null) error (DWT.ERROR_NULL_ARGUMENT); | 670 if (string is null) error (DWT.ERROR_NULL_ARGUMENT); |
671 | 671 |
672 /* | 672 /* |
673 * Bug in Windows. For some reason, LB_FINDSTRINGEXACT | 673 * Bug in Windows. For some reason, LB_FINDSTRINGEXACT |
918 * @exception DWTException <ul> | 918 * @exception DWTException <ul> |
919 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | 919 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
920 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | 920 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> |
921 * </ul> | 921 * </ul> |
922 */ | 922 */ |
923 public void remove (char[] string) { | 923 public void remove (String string) { |
924 checkWidget (); | 924 checkWidget (); |
925 if (string is null) error (DWT.ERROR_NULL_ARGUMENT); | 925 if (string is null) error (DWT.ERROR_NULL_ARGUMENT); |
926 int index = indexOf (string, 0); | 926 int index = indexOf (string, 0); |
927 if (index is -1) error (DWT.ERROR_INVALID_ARGUMENT); | 927 if (index is -1) error (DWT.ERROR_INVALID_ARGUMENT); |
928 remove (index); | 928 remove (index); |
1170 * @exception DWTException <ul> | 1170 * @exception DWTException <ul> |
1171 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | 1171 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
1172 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | 1172 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> |
1173 * </ul> | 1173 * </ul> |
1174 */ | 1174 */ |
1175 public void setItem (int index, char[] string) { | 1175 public void setItem (int index, String string) { |
1176 checkWidget (); | 1176 checkWidget (); |
1177 if (string is null) error (DWT.ERROR_NULL_ARGUMENT); | 1177 if (string is null) error (DWT.ERROR_NULL_ARGUMENT); |
1178 int topIndex = getTopIndex (); | 1178 int topIndex = getTopIndex (); |
1179 bool isSelected = isSelected (index); | 1179 bool isSelected = isSelected (index); |
1180 remove (index); | 1180 remove (index); |
1195 * @exception DWTException <ul> | 1195 * @exception DWTException <ul> |
1196 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | 1196 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
1197 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | 1197 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> |
1198 * </ul> | 1198 * </ul> |
1199 */ | 1199 */ |
1200 public void setItems (char[] [] items) { | 1200 public void setItems (String [] items) { |
1201 checkWidget (); | 1201 checkWidget (); |
1202 if (items is null) error (DWT.ERROR_NULL_ARGUMENT); | 1202 if (items is null) error (DWT.ERROR_NULL_ARGUMENT); |
1203 for (int i=0; i<items.length; i++) { | 1203 for (int i=0; i<items.length; i++) { |
1204 if (items [i] is null) error (DWT.ERROR_INVALID_ARGUMENT); | 1204 if (items [i] is null) error (DWT.ERROR_INVALID_ARGUMENT); |
1205 } | 1205 } |
1224 OS.SendMessage (handle, OS.LB_RESETCONTENT, 0, 0); | 1224 OS.SendMessage (handle, OS.LB_RESETCONTENT, 0, 0); |
1225 OS.SendMessage (handle, OS.LB_INITSTORAGE, length, length * 32); | 1225 OS.SendMessage (handle, OS.LB_INITSTORAGE, length, length * 32); |
1226 int index = 0; | 1226 int index = 0; |
1227 int cp = getCodePage (); | 1227 int cp = getCodePage (); |
1228 while (index < length) { | 1228 while (index < length) { |
1229 char[] string = items [index]; | 1229 String string = items [index]; |
1230 TCHAR* buffer = StrToTCHARz (cp, string); | 1230 TCHAR* buffer = StrToTCHARz (cp, string); |
1231 int result = OS.SendMessage (handle, OS.LB_ADDSTRING, 0, buffer); | 1231 int result = OS.SendMessage (handle, OS.LB_ADDSTRING, 0, buffer); |
1232 if (result is OS.LB_ERR || result is OS.LB_ERRSPACE) break; | 1232 if (result is OS.LB_ERR || result is OS.LB_ERRSPACE) break; |
1233 if ((style & DWT.H_SCROLL) !is 0) { | 1233 if ((style & DWT.H_SCROLL) !is 0) { |
1234 int flags = OS.DT_CALCRECT | OS.DT_SINGLELINE | OS.DT_NOPREFIX; | 1234 int flags = OS.DT_CALCRECT | OS.DT_SINGLELINE | OS.DT_NOPREFIX; |
1364 * | 1364 * |
1365 * @see List#deselectAll() | 1365 * @see List#deselectAll() |
1366 * @see List#select(int[]) | 1366 * @see List#select(int[]) |
1367 * @see List#setSelection(int[]) | 1367 * @see List#setSelection(int[]) |
1368 */ | 1368 */ |
1369 public void setSelection (char[] [] items) { | 1369 public void setSelection (String [] items) { |
1370 checkWidget (); | 1370 checkWidget (); |
1371 if (items is null) error (DWT.ERROR_NULL_ARGUMENT); | 1371 if (items is null) error (DWT.ERROR_NULL_ARGUMENT); |
1372 deselectAll (); | 1372 deselectAll (); |
1373 int length = items.length; | 1373 int length = items.length; |
1374 if (length is 0 || ((style & DWT.SINGLE) !is 0 && length > 1)) return; | 1374 if (length is 0 || ((style & DWT.SINGLE) !is 0 && length > 1)) return; |
1375 int focusIndex = -1; | 1375 int focusIndex = -1; |
1376 for (int i=length-1; i>=0; --i) { | 1376 for (int i=length-1; i>=0; --i) { |
1377 char[] string = items [i]; | 1377 String string = items [i]; |
1378 int index = 0; | 1378 int index = 0; |
1379 if (string !is null) { | 1379 if (string !is null) { |
1380 int localFocus = -1; | 1380 int localFocus = -1; |
1381 while ((index = indexOf (string, index)) !is -1) { | 1381 while ((index = indexOf (string, index)) !is -1) { |
1382 if (localFocus is -1) localFocus = index; | 1382 if (localFocus is -1) localFocus = index; |
1522 return bits | OS.LBS_EXTENDEDSEL; | 1522 return bits | OS.LBS_EXTENDEDSEL; |
1523 } | 1523 } |
1524 return bits; | 1524 return bits; |
1525 } | 1525 } |
1526 | 1526 |
1527 override char[] windowClass () { | 1527 override String windowClass () { |
1528 return TCHARsToStr( ListClass ); | 1528 return TCHARsToStr( ListClass ); |
1529 } | 1529 } |
1530 | 1530 |
1531 override int windowProc () { | 1531 override int windowProc () { |
1532 return cast(int) ListProc; | 1532 return cast(int) ListProc; |