Mercurial > projects > dwt-win
changeset 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 | efe25e7c8a96 |
children | c84e3d3feb3f |
files | dwt/graphics/GC.d dwt/program/Program.d dwt/widgets/Button.d dwt/widgets/Combo.d dwt/widgets/CoolBar.d dwt/widgets/Decorations.d dwt/widgets/Dialog.d dwt/widgets/DirectoryDialog.d dwt/widgets/Display.d |
diffstat | 9 files changed, 49 insertions(+), 92 deletions(-) [+] |
line wrap: on
line diff
--- a/dwt/graphics/GC.d Fri Jun 20 01:29:54 2008 +0200 +++ b/dwt/graphics/GC.d Fri Jun 20 16:27:36 2008 +0200 @@ -1798,16 +1798,14 @@ * * @param pointArray an array of alternating x and y values which are the vertices of the polygon * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT if pointArray is null</li> - * </ul> * @exception DWTException <ul> * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> * </ul> */ public void drawPolygon( int[] pointArray) { if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); - if (pointArray is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); + // DWT extension: allow null array + //if (pointArray is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); checkGC(DRAW); auto gdipGraphics = data.gdipGraphics; if (gdipGraphics !is null) { @@ -1843,16 +1841,14 @@ * * @param pointArray an array of alternating x and y values which are the corners of the polyline * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the point array is null</li> - * </ul> * @exception DWTException <ul> * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> * </ul> */ public void drawPolyline(int[] pointArray) { if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); - if (pointArray is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); + // DWT externsion: allow null array + //if (pointArray is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); checkGC(DRAW); auto gdipGraphics = data.gdipGraphics; if (gdipGraphics !is null) { @@ -2091,9 +2087,6 @@ * @param x the x coordinate of the top left corner of the rectangular area where the string is to be drawn * @param y the y coordinate of the top left corner of the rectangular area where the string is to be drawn * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the string is null</li> - * </ul> * @exception DWTException <ul> * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> * </ul> @@ -2115,16 +2108,14 @@ * @param y the y coordinate of the top left corner of the rectangular area where the string is to be drawn * @param isTransparent if <code>true</code> the background will be transparent, otherwise it will be opaque * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the string is null</li> - * </ul> * @exception DWTException <ul> * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> * </ul> */ public void drawString (String string, int x, int y, bool isTransparent) { if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); - if (string is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); + // DWT extension: allow null string + //if (string is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); // TCHAR buffer = new TCHAR (getCodePage(), string, false); wchar[] wstr = StrToWCHARs( string ); int length_ = wstr.length; @@ -2247,9 +2238,6 @@ * @param x the x coordinate of the top left corner of the rectangular area where the text is to be drawn * @param y the y coordinate of the top left corner of the rectangular area where the text is to be drawn * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the string is null</li> - * </ul> * @exception DWTException <ul> * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> * </ul> @@ -2271,9 +2259,6 @@ * @param y the y coordinate of the top left corner of the rectangular area where the text is to be drawn * @param isTransparent if <code>true</code> the background will be transparent, otherwise it will be opaque * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the string is null</li> - * </ul> * @exception DWTException <ul> * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> * </ul> @@ -2311,16 +2296,14 @@ * @param y the y coordinate of the top left corner of the rectangular area where the text is to be drawn * @param flags the flags specifying how to process the text * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the string is null</li> - * </ul> * @exception DWTException <ul> * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> * </ul> */ public void drawText (String string, int x, int y, int flags) { if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); - if (string is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); + // DWT extension: allow null string + //if (string is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); if (string.length is 0) return; auto gdipGraphics = data.gdipGraphics; if (gdipGraphics !is null) { @@ -2771,9 +2754,6 @@ * * @param pointArray an array of alternating x and y values which are the vertices of the polygon * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT if pointArray is null</li> - * </ul> * @exception DWTException <ul> * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> * </ul> @@ -2782,7 +2762,8 @@ */ public void fillPolygon(int[] pointArray) { if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); - if (pointArray is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); + // DWT externsion: allow null array + //if (pointArray is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); checkGC(FILL); if (data.gdipGraphics !is null) { int mode = OS.GetPolyFillMode(handle) is OS.WINDING ? Gdip.FillModeWinding : Gdip.FillModeAlternate; @@ -4736,16 +4717,14 @@ * @param string the string to measure * @return a point containing the extent of the string * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the string is null</li> - * </ul> * @exception DWTException <ul> * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> * </ul> */ public Point stringExtent(String string) { if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED); - if (string is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); + // DWT externsion: allow null string + //if (string is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); checkGC(FONT); int length_ = string.length; if (data.gdipGraphics !is null) {
--- a/dwt/program/Program.d Fri Jun 20 01:29:54 2008 +0200 +++ b/dwt/program/Program.d Fri Jun 20 16:27:36 2008 +0200 @@ -74,12 +74,10 @@ * @param extension the program extension * @return the program or <code>null</code> * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT when extension is null</li> - * </ul> */ public static Program findProgram (String extension) { - if (extension is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); + // DWT extension: allow null string + //if (extension is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); if (extension.length is 0) return null; if (extension.charAt (0) !is '.') extension = "." ~ extension; //$NON-NLS-1$ /* Use the character encoding for the default locale */
--- a/dwt/widgets/Button.d Fri Jun 20 01:29:54 2008 +0200 +++ b/dwt/widgets/Button.d Fri Jun 20 16:27:36 2008 +0200 @@ -1024,7 +1024,8 @@ */ /*public*/ void setMessage (String message) { checkWidget (); - if (message is null) error (DWT.ERROR_NULL_ARGUMENT); + // DWT externsion: allow null string + //if (message is null) error (DWT.ERROR_NULL_ARGUMENT); this.message = message; if (OS.COMCTL32_VERSION >= OS.VERSION (6, 1)) { if ((style & DWT.COMMAND) !is 0) { @@ -1109,9 +1110,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> @@ -1119,7 +1117,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.ARROW) !is 0) return; text = string; /* This code is intentionally commented */
--- 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);
--- a/dwt/widgets/CoolBar.d Fri Jun 20 01:29:54 2008 +0200 +++ b/dwt/widgets/CoolBar.d Fri Jun 20 16:27:36 2008 +0200 @@ -815,7 +815,6 @@ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if item order or sizes is null</li> * <li>ERROR_INVALID_ARGUMENT - if item order or sizes is not the same length as the number of items</li> * </ul> */ @@ -841,12 +840,12 @@ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the item order is null</li> * <li>ERROR_INVALID_ARGUMENT - if the item order is not the same length as the number of items</li> * </ul> */ void setItemOrder (int [] itemOrder) { - if (itemOrder is null) error (DWT.ERROR_NULL_ARGUMENT); + // DWT extension: allow null array + //if (itemOrder is null) error (DWT.ERROR_NULL_ARGUMENT); int itemCount = OS.SendMessage (handle, OS.RB_GETBANDCOUNT, 0, 0); if (itemOrder.length !is itemCount) error (DWT.ERROR_INVALID_ARGUMENT); @@ -905,7 +904,8 @@ * </ul> */ void setItemSizes (Point [] sizes) { - if (sizes is null) error (DWT.ERROR_NULL_ARGUMENT); + // DWT extension: allow null array + //if (sizes is null) error (DWT.ERROR_NULL_ARGUMENT); int count = OS.SendMessage (handle, OS.RB_GETBANDCOUNT, 0, 0); if (sizes.length !is count) error (DWT.ERROR_INVALID_ARGUMENT); REBARBANDINFO rbBand;
--- a/dwt/widgets/Decorations.d Fri Jun 20 01:29:54 2008 +0200 +++ b/dwt/widgets/Decorations.d Fri Jun 20 16:27:36 2008 +0200 @@ -1060,7 +1060,6 @@ * @param images the new image array * * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the array of images is null</li> * <li>ERROR_INVALID_ARGUMENT - if one of the images is null or has been disposed</li> * </ul> * @exception DWTException <ul> @@ -1072,7 +1071,8 @@ */ public void setImages (Image [] images) { checkWidget (); - if (images is null) error (DWT.ERROR_INVALID_ARGUMENT); + // DWT extension: allow null array + //if (images is null) error (DWT.ERROR_INVALID_ARGUMENT); for (int i = 0; i < images.length; i++) { if (images [i] is null || images [i].isDisposed ()) error (DWT.ERROR_INVALID_ARGUMENT); } @@ -1328,9 +1328,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> @@ -1338,7 +1335,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); /* Use the character encoding for the default locale */ TCHAR[] buffer = StrToTCHARs (string, true); /* Ensure that the title appears in the task bar.*/
--- a/dwt/widgets/Dialog.d Fri Jun 20 01:29:54 2008 +0200 +++ b/dwt/widgets/Dialog.d Fri Jun 20 16:27:36 2008 +0200 @@ -255,16 +255,14 @@ * * @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> * </ul> */ public void setText (String string) { - if (string is null) error (DWT.ERROR_NULL_ARGUMENT); + // DWT extension: allow null string + //if (string is null) error (DWT.ERROR_NULL_ARGUMENT); title = string; }
--- a/dwt/widgets/DirectoryDialog.d Fri Jun 20 01:29:54 2008 +0200 +++ b/dwt/widgets/DirectoryDialog.d Fri Jun 20 16:27:36 2008 +0200 @@ -308,12 +308,10 @@ * * @param string the message * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the string is null</li> - * </ul> */ public void setMessage (String string) { - if (string is null) error (DWT.ERROR_NULL_ARGUMENT); + // DWT extension: allow null string + //if (string is null) error (DWT.ERROR_NULL_ARGUMENT); message = string; }
--- a/dwt/widgets/Display.d Fri Jun 20 01:29:54 2008 +0200 +++ b/dwt/widgets/Display.d Fri Jun 20 16:27:36 2008 +0200 @@ -1626,9 +1626,6 @@ * @param key the name of the property * @return the value of the property or null if it has not been set * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the key is null</li> - * </ul> * @exception DWTException <ul> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> @@ -1639,7 +1636,8 @@ */ public Object getData (String key) { checkDevice (); - if (key is null) error (DWT.ERROR_NULL_ARGUMENT); + // DWT extension: allow null string + //if (key is null) error (DWT.ERROR_NULL_ARGUMENT); if (key ==/*eq*/RUN_MESSAGES_IN_IDLE_KEY) { return new ValueWrapperBool(runMessagesInIdle); } @@ -4081,9 +4079,6 @@ * @param key the name of the property * @param value the new value for the property * - * @exception IllegalArgumentException <ul> - * <li>ERROR_NULL_ARGUMENT - if the key is null</li> - * </ul> * @exception DWTException <ul> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li> @@ -4094,7 +4089,8 @@ */ public void setData (String key, Object value) { checkDevice (); - if (key is null) error (DWT.ERROR_NULL_ARGUMENT); + // DWT extension: allow null string + //if (key is null) error (DWT.ERROR_NULL_ARGUMENT); if (key ==/*eq*/RUN_MESSAGES_IN_IDLE_KEY) { auto data = cast(ValueWrapperBool) value;