changeset 180:772f75da6a52

Allow null argument for Label.setText
author Frank Benoit <benoit@tionex.de>
date Sun, 09 Mar 2008 11:03:57 +0100
parents 69c0e2fa46b9
children 811e926196d6
files dwt/dwthelper/utils.d dwt/widgets/Label.d
diffstat 2 files changed, 14 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/dwt/dwthelper/utils.d	Sat Mar 08 14:00:55 2008 +0100
+++ b/dwt/dwthelper/utils.d	Sun Mar 09 11:03:57 2008 +0100
@@ -320,6 +320,16 @@
     return typeid(char[]).getHash(&src);
 }
 
+public char* toStringzValidPtr( char[] src ){
+    if( src ){
+        return src.toStringz();
+    }
+    else{
+        static const char[] nullPtr = "\0";
+        return nullPtr.ptr;
+    }
+}
+
 static char[] toHex(uint value, bool prefix = true, int radix = 8){
     return tango.text.convert.Integer.toString(
             value,
--- a/dwt/widgets/Label.d	Sat Mar 08 14:00:55 2008 +0100
+++ b/dwt/widgets/Label.d	Sun Mar 09 11:03:57 2008 +0100
@@ -394,7 +394,8 @@
  */
 public void setText (char[] string) {
     checkWidget ();
-    if (string is null) error (DWT.ERROR_NULL_ARGUMENT);
+    // DWT extension: allow null for zero length string
+    //if (string is null) error (DWT.ERROR_NULL_ARGUMENT);
     if ((style & DWT.SEPARATOR) !is 0) return;
     /*
     * Feature in Windows.  For some reason, SetWindowText() for
@@ -402,7 +403,7 @@
     * has not changed.  The fix is to check for this case and do
     * nothing.
     */
-    if (string==/*eq*/text) return;
+    if (string.equals(text)) return;
     text = string;
     if (image is null || !IMAGE_AND_TEXT) {
         int oldBits = OS.GetWindowLong (handle, OS.GWL_STYLE), newBits = oldBits;
@@ -419,7 +420,7 @@
         if (oldBits !is newBits) OS.SetWindowLong (handle, OS.GWL_STYLE, newBits);
     }
     string = Display.withCrLf (string);
-    TCHAR* buffer = StrToTCHARz (/+getCodePage (),+/ string);
+    TCHAR* buffer = StrToTCHARz ( getCodePage (), string);
     OS.SetWindowText (handle, buffer);
     /*
     * Bug in Windows.  For some reason, the HBRUSH that