changeset 241:b4846fd3437a

work on allow null strings and arrays
author Frank Benoit <benoit@tionex.de>
date Mon, 23 Jun 2008 01:45:58 +0200
parents c84e3d3feb3f
children 32a6819fef61
files dwt/widgets/Group.d dwt/widgets/Item.d dwt/widgets/Label.d dwt/widgets/Link.d dwt/widgets/List.d
diffstat 5 files changed, 35 insertions(+), 58 deletions(-) [+]
line wrap: on
line diff
--- a/dwt/widgets/Group.d	Sat Jun 21 02:24:49 2008 +0200
+++ b/dwt/widgets/Group.d	Mon Jun 23 01:45:58 2008 +0200
@@ -345,9 +345,6 @@
  * </p>
  * @param string the new text
  *
- * @exception IllegalArgumentException <ul>
- *    <li>ERROR_NULL_ARGUMENT - if the text 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>
@@ -355,7 +352,8 @@
  */
 public void setText (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);
     text = string;
     /*
     * Bug in Windows.  When a group control is right-to-left and
--- a/dwt/widgets/Item.d	Sat Jun 21 02:24:49 2008 +0200
+++ b/dwt/widgets/Item.d	Mon Jun 23 01:45:58 2008 +0200
@@ -171,9 +171,6 @@
  *
  * @param string the new text
  *
- * @exception IllegalArgumentException <ul>
- *    <li>ERROR_NULL_ARGUMENT - if the text 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>
@@ -181,7 +178,8 @@
  */
 public void setText (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);
     text = string;
 }
 
--- a/dwt/widgets/Label.d	Sat Jun 21 02:24:49 2008 +0200
+++ b/dwt/widgets/Label.d	Mon Jun 23 01:45:58 2008 +0200
@@ -391,9 +391,6 @@
  *
  * @param string the new text
  *
- * @exception IllegalArgumentException <ul>
- *    <li>ERROR_NULL_ARGUMENT - if the text 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>
@@ -401,9 +398,9 @@
  */
 public void setText (String string) {
     checkWidget ();
-    if (string is null) error (DWT.ERROR_NULL_ARGUMENT);
     // DWT extensions allow null argument
-    //if ((style & DWT.SEPARATOR) !is 0) return;
+    //if (string is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if ((style & DWT.SEPARATOR) !is 0) return;
     /*
     * Feature in Windows.  For some reason, SetWindowText() for
     * static controls redraws the control, even when the text has
--- a/dwt/widgets/Link.d	Sat Jun 21 02:24:49 2008 +0200
+++ b/dwt/widgets/Link.d	Mon Jun 23 01:45:58 2008 +0200
@@ -670,9 +670,6 @@
  *
  * @param string the new text
  *
- * @exception IllegalArgumentException <ul>
- *    <li>ERROR_NULL_ARGUMENT - if the text 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>
@@ -680,8 +677,9 @@
  */
 public void setText (String string) {
     checkWidget ();
-    if (string is null) error (DWT.ERROR_NULL_ARGUMENT);
-    if (string==/*eq*/text) return;
+    // DWT extension: allow null string
+    //if (string is null) error (DWT.ERROR_NULL_ARGUMENT);
+    if (string.equals (text)) return;
     text = string;
     if (OS.COMCTL32_MAJOR >= 6) {
         bool enabled = cast(bool) OS.IsWindowEnabled (handle);
--- a/dwt/widgets/List.d	Sat Jun 21 02:24:49 2008 +0200
+++ b/dwt/widgets/List.d	Mon Jun 23 01:45:58 2008 +0200
@@ -108,9 +108,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>
@@ -120,7 +117,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);
     TCHAR* buffer = StrToTCHARz ( getCodePage (), string);
     int result = OS.SendMessage (handle, OS.LB_ADDSTRING, 0, buffer);
     if (result is OS.LB_ERR) error (DWT.ERROR_ITEM_NOT_ADDED);
@@ -140,7 +138,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>
@@ -152,7 +149,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);
     if (index is -1) error (DWT.ERROR_INVALID_RANGE);
     TCHAR* buffer = StrToTCHARz(getCodePage (), string);
     int result = OS.SendMessage (handle, OS.LB_INSERTSTRING, index, buffer);
@@ -299,9 +297,6 @@
  *
  * @param indices the array of indices for the items to deselect
  *
- * @exception IllegalArgumentException <ul>
- *    <li>ERROR_NULL_ARGUMENT - if the set of indices 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>
@@ -309,7 +304,8 @@
  */
 public void deselect (int [] indices) {
     checkWidget ();
-    if (indices is null) error (DWT.ERROR_NULL_ARGUMENT);
+    // DWT extension: allow null array
+    //if (indices is null) error (DWT.ERROR_NULL_ARGUMENT);
     if (indices.length is 0) return;
     if ((style & DWT.SINGLE) !is 0) {
         int oldIndex = OS.SendMessage (handle, OS.LB_GETCURSEL, 0, 0);
@@ -656,9 +652,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>
@@ -679,9 +672,6 @@
  * @param start the zero-relative index at which to start 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>
@@ -689,7 +679,8 @@
  */
 public int indexOf (String string, int start) {
     checkWidget ();
-    if (string is null) error (DWT.ERROR_NULL_ARGUMENT);
+    // DWT extension: allow null string
+    //if (string is null) error (DWT.ERROR_NULL_ARGUMENT);
 
     /*
     * Bug in Windows.  For some reason, LB_FINDSTRINGEXACT
@@ -744,7 +735,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 indices array is null</li>
  * </ul>
  * @exception DWTException <ul>
  *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
@@ -753,7 +743,8 @@
  */
 public void remove (int [] indices) {
     checkWidget ();
-    if (indices is null) error (DWT.ERROR_NULL_ARGUMENT);
+    // DWT extension: allow null array
+    //if (indices is null) error (DWT.ERROR_NULL_ARGUMENT);
     if (indices.length is 0) return;
     int [] newIndices = new int [indices.length];
     System.arraycopy (indices, 0, newIndices, 0, indices.length);
@@ -934,7 +925,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>
@@ -944,7 +934,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);
@@ -1003,9 +994,6 @@
  *
  * @param indices the array of indices for the items to select
  *
- * @exception IllegalArgumentException <ul>
- *    <li>ERROR_NULL_ARGUMENT - if the array of indices 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>
@@ -1015,7 +1003,8 @@
  */
 public void select (int [] indices) {
     checkWidget ();
-    if (indices is null) error (DWT.ERROR_NULL_ARGUMENT);
+    // DWT extension: allow null array
+    //if (indices is null) error (DWT.ERROR_NULL_ARGUMENT);
     int length = indices.length;
     if (length is 0 || ((style & DWT.SINGLE) !is 0 && length > 1)) return;
     select (indices, false);
@@ -1187,7 +1176,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>
@@ -1196,7 +1184,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 topIndex = getTopIndex ();
     bool isSelected = isSelected (index);
     remove (index);
@@ -1211,7 +1200,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>
@@ -1221,10 +1209,12 @@
  */
 public void setItems (String [] items) {
     checkWidget ();
-    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);
-    }
+    // DWT extension: allow null array
+    //if (items is null) error (DWT.ERROR_NULL_ARGUMENT);
+    // DWT extension: allow null item strings
+    //for (int i=0; i<items.length; i++) {
+    //    if (items [i] is null) error (DWT.ERROR_INVALID_ARGUMENT);
+    //}
     int /*long*/ oldProc = OS.GetWindowLongPtr (handle, OS.GWLP_WNDPROC);
     OS.SetWindowLongPtr (handle, OS.GWLP_WNDPROC, cast(LONG_PTR) ListProc);
     bool redraw = drawCount is 0 && OS.IsWindowVisible (handle);
@@ -1342,9 +1332,6 @@
  *
  * @param indices the indices of the items to select
  *
- * @exception IllegalArgumentException <ul>
- *    <li>ERROR_NULL_ARGUMENT - if the array of indices 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>
@@ -1355,7 +1342,8 @@
  */
 public void setSelection(int [] indices) {
     checkWidget ();
-    if (indices is null) error (DWT.ERROR_NULL_ARGUMENT);
+    // DWT extension: allow null array
+    //if (indices is null) error (DWT.ERROR_NULL_ARGUMENT);
     deselectAll ();
     int length = indices.length;
     if (length is 0 || ((style & DWT.SINGLE) !is 0 && length > 1)) return;
@@ -1376,9 +1364,6 @@
  *
  * @param items the array of items
  *
- * @exception IllegalArgumentException <ul>
- *    <li>ERROR_NULL_ARGUMENT - if the array of items 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>
@@ -1390,7 +1375,8 @@
  */
 public void setSelection (String [] items) {
     checkWidget ();
-    if (items is null) error (DWT.ERROR_NULL_ARGUMENT);
+    // DWT extension: allow null array
+    //if (items is null) error (DWT.ERROR_NULL_ARGUMENT);
     deselectAll ();
     int length = items.length;
     if (length is 0 || ((style & DWT.SINGLE) !is 0 && length > 1)) return;