diff dwt/widgets/Combo.d @ 239:43b41c7fe84a

work on allow null strings and arrays
author Frank Benoit <benoit@tionex.de>
date Fri, 20 Jun 2008 16:27:36 +0200
parents e2affbeb686d
children fd9c62a2998e
line wrap: on
line diff
--- a/dwt/widgets/Combo.d	Fri Jun 20 01:29:54 2008 +0200
+++ b/dwt/widgets/Combo.d	Fri Jun 20 16:27:36 2008 +0200
@@ -174,9 +174,6 @@
  *
  * @param string the new item
  *
- * @exception IllegalArgumentException <ul>
- *    <li>ERROR_NULL_ARGUMENT - if the string is null</li>
- * </ul>
  * @exception DWTException <ul>
  *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
  *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
@@ -186,7 +183,8 @@
  */
 public void add (String string) {
     checkWidget ();
-    if (string is null) error (DWT.ERROR_NULL_ARGUMENT);
+    // DWT extension: allow null string
+    //if (string is null) error (DWT.ERROR_NULL_ARGUMENT);
     auto buffer = StrToTCHARs( getCodePage(), string, true );
     int result = OS.SendMessage (handle, OS.CB_ADDSTRING, 0, buffer.ptr );
     if (result is OS.CB_ERR) error (DWT.ERROR_ITEM_NOT_ADDED);
@@ -207,7 +205,6 @@
  * @param index the index for the item
  *
  * @exception IllegalArgumentException <ul>
- *    <li>ERROR_NULL_ARGUMENT - if the string is null</li>
  *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list (inclusive)</li>
  * </ul>
  * @exception DWTException <ul>
@@ -219,7 +216,8 @@
  */
 public void add (String string, int index) {
     checkWidget ();
-    if (string is null) error (DWT.ERROR_NULL_ARGUMENT);
+    // DWT extension: allow null string
+    //if (string is null) error (DWT.ERROR_NULL_ARGUMENT);
     int count = OS.SendMessage (handle, OS.CB_GETCOUNT, 0, 0);
     if (!(0 <= index && index <= count)) {
         error (DWT.ERROR_INVALID_RANGE);
@@ -979,9 +977,6 @@
  * @param string the search item
  * @return the index of the item
  *
- * @exception IllegalArgumentException <ul>
- *    <li>ERROR_NULL_ARGUMENT - if the string is null</li>
- * </ul>
  * @exception DWTException <ul>
  *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
  *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
@@ -1002,9 +997,6 @@
  * @param start the zero-relative index at which to begin the search
  * @return the index of the item
  *
- * @exception IllegalArgumentException <ul>
- *    <li>ERROR_NULL_ARGUMENT - if the string is null</li>
- * </ul>
  * @exception DWTException <ul>
  *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
  *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
@@ -1012,7 +1004,8 @@
  */
 public int indexOf (String string, int start) {
     checkWidget ();
-    if (string is null) error (DWT.ERROR_NULL_ARGUMENT);
+    // DWT externsion: allow null string
+    //if (string is null) error (DWT.ERROR_NULL_ARGUMENT);
 
     /*
     * Bug in Windows.  For some reason, CB_FINDSTRINGEXACT
@@ -1023,7 +1016,7 @@
     if (string.length  is 0) {
         int count = getItemCount ();
         for (int i=start; i<count; i++) {
-            if (string==/*eq*/getItem (i)) return i;
+            if (string.equals (getItem (i))) return i;
         }
         return -1;
     }
@@ -1225,7 +1218,6 @@
  * @param string the item to remove
  *
  * @exception IllegalArgumentException <ul>
- *    <li>ERROR_NULL_ARGUMENT - if the string is null</li>
  *    <li>ERROR_INVALID_ARGUMENT - if the string is not found in the list</li>
  * </ul>
  * @exception DWTException <ul>
@@ -1235,7 +1227,8 @@
  */
 public void remove (String string) {
     checkWidget ();
-    if (string is null) error (DWT.ERROR_NULL_ARGUMENT);
+    // DWT extension: allow null string
+    //if (string is null) error (DWT.ERROR_NULL_ARGUMENT);
     int index = indexOf (string, 0);
     if (index is -1) error (DWT.ERROR_INVALID_ARGUMENT);
     remove (index);
@@ -1530,7 +1523,6 @@
  *
  * @exception IllegalArgumentException <ul>
  *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
- *    <li>ERROR_NULL_ARGUMENT - if the string is null</li>
  * </ul>
  * @exception DWTException <ul>
  *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
@@ -1539,7 +1531,8 @@
  */
 public void setItem (int index, String string) {
     checkWidget ();
-    if (string is null) error (DWT.ERROR_NULL_ARGUMENT);
+    // DWT extension: allow null string
+    //if (string is null) error (DWT.ERROR_NULL_ARGUMENT);
     int selection = getSelectionIndex ();
     remove (index, false);
     if (isDisposed ()) return;
@@ -1553,7 +1546,6 @@
  * @param items the array of items
  *
  * @exception IllegalArgumentException <ul>
- *    <li>ERROR_NULL_ARGUMENT - if the items array is null</li>
  *    <li>ERROR_INVALID_ARGUMENT - if an item in the items array is null</li>
  * </ul>
  * @exception DWTException <ul>
@@ -1563,7 +1555,8 @@
  */
 public void setItems (String [] items) {
     checkWidget ();
-    if (items is null) error (DWT.ERROR_NULL_ARGUMENT);
+    // DWT extension: allow null string
+    //if (items is null) error (DWT.ERROR_NULL_ARGUMENT);
     for (int i=0; i<items.length; i++) {
         if (items [i] is null) error (DWT.ERROR_INVALID_ARGUMENT);
     }
@@ -1804,9 +1797,6 @@
  *
  * @param string the new text
  *
- * @exception IllegalArgumentException <ul>
- *    <li>ERROR_NULL_ARGUMENT - if the string is null</li>
- * </ul>
  * @exception DWTException <ul>
  *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
  *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
@@ -1814,7 +1804,8 @@
  */
 public void setText (String string) {
     checkWidget ();
-    if (string is null) error (DWT.ERROR_NULL_ARGUMENT);
+    // DWT externsion: allow null string
+    //if (string is null) error (DWT.ERROR_NULL_ARGUMENT);
     if ((style & DWT.READ_ONLY) !is 0) {
         int index = indexOf (string);
         if (index !is -1) select (index);