comparison dwt/custom/StyledText.d @ 255:5a30aa9820f3

removed tango.stdc.stringz imports and allow null for arrays and string arguments.
author Frank Benoit <benoit@tionex.de>
date Sun, 15 Jun 2008 22:32:20 +0200
parents ce446666f5a2
children c0d810de7093
comparison
equal deleted inserted replaced
254:8bca790583c3 255:5a30aa9820f3
1596 * @see #replaceTextRange(int,int,String) 1596 * @see #replaceTextRange(int,int,String)
1597 * @exception DWTException <ul> 1597 * @exception DWTException <ul>
1598 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> 1598 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
1599 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> 1599 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
1600 * </ul> 1600 * </ul>
1601 * @exception IllegalArgumentException <ul>
1602 * <li>ERROR_NULL_ARGUMENT when listener is null</li>
1603 * </ul>
1604 */ 1601 */
1605 public void append(String string) { 1602 public void append(String string) {
1606 checkWidget(); 1603 checkWidget();
1607 if (string is null) { 1604 // DWT extension: allow null for zero length string
1608 DWT.error(DWT.ERROR_NULL_ARGUMENT); 1605 // if (string is null) {
1609 } 1606 // DWT.error(DWT.ERROR_NULL_ARGUMENT);
1607 // }
1610 int lastChar = Math.max(getCharCount(), 0); 1608 int lastChar = Math.max(getCharCount(), 0);
1611 replaceTextRange(lastChar, 0, string); 1609 replaceTextRange(lastChar, 0, string);
1612 } 1610 }
1613 /** 1611 /**
1614 * Calculates the scroll bars 1612 * Calculates the scroll bars
4932 * @see #replaceTextRange(int,int,String) 4930 * @see #replaceTextRange(int,int,String)
4933 * @exception DWTException <ul> 4931 * @exception DWTException <ul>
4934 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> 4932 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
4935 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> 4933 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
4936 * </ul> 4934 * </ul>
4937 * @exception IllegalArgumentException <ul>
4938 * <li>ERROR_NULL_ARGUMENT when string is null</li>
4939 * </ul>
4940 */ 4935 */
4941 public void insert(String string) { 4936 public void insert(String string) {
4942 checkWidget(); 4937 checkWidget();
4943 if (string is null) { 4938 // DWT extension: allow null for zero length string
4944 DWT.error(DWT.ERROR_NULL_ARGUMENT); 4939 // if (string is null) {
4945 } 4940 // DWT.error(DWT.ERROR_NULL_ARGUMENT);
4941 // }
4946 Point sel = getSelectionRange(); 4942 Point sel = getSelectionRange();
4947 replaceTextRange(sel.x, sel.y, string); 4943 replaceTextRange(sel.x, sel.y, string);
4948 } 4944 }
4949 /** 4945 /**
4950 * Creates content change listeners and set the default content model. 4946 * Creates content change listeners and set the default content model.
6455 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> 6451 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
6456 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> 6452 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
6457 * </ul> 6453 * </ul>
6458 * @exception IllegalArgumentException <ul> 6454 * @exception IllegalArgumentException <ul>
6459 * <li>ERROR_INVALID_RANGE when either start or end is outside the valid range (0 <= offset <= getCharCount())</li> 6455 * <li>ERROR_INVALID_RANGE when either start or end is outside the valid range (0 <= offset <= getCharCount())</li>
6460 * <li>ERROR_NULL_ARGUMENT when ranges is null</li>
6461 * </ul> 6456 * </ul>
6462 * 6457 *
6463 * @since 2.0 6458 * @since 2.0
6464 * 6459 *
6465 * @see #setStyleRanges(int, int, int[], StyleRange[]) 6460 * @see #setStyleRanges(int, int, int[], StyleRange[])
6466 */ 6461 */
6467 public void replaceStyleRanges(int start, int length, StyleRange[] ranges) { 6462 public void replaceStyleRanges(int start, int length, StyleRange[] ranges) {
6468 checkWidget(); 6463 checkWidget();
6469 if (isListening(LineGetStyle)) return; 6464 if (isListening(LineGetStyle)) return;
6470 if (ranges is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); 6465 // DWT extension: allow null for zero length string
6466 //if (ranges is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
6471 setStyleRanges(start, length, null, ranges, false); 6467 setStyleRanges(start, length, null, ranges, false);
6472 } 6468 }
6473 /** 6469 /**
6474 * Replaces the given text range with new text. 6470 * Replaces the given text range with new text.
6475 * If the widget has the DWT.SINGLE style and "text" contains more than 6471 * If the widget has the DWT.SINGLE style and "text" contains more than
6498 * </ul> 6494 * </ul>
6499 * @exception IllegalArgumentException <ul> 6495 * @exception IllegalArgumentException <ul>
6500 * <li>ERROR_INVALID_RANGE when either start or end is outside the valid range (0 <= offset <= getCharCount())</li> 6496 * <li>ERROR_INVALID_RANGE when either start or end is outside the valid range (0 <= offset <= getCharCount())</li>
6501 * <li>ERROR_INVALID_ARGUMENT when either start or end is inside a multi byte line delimiter. 6497 * <li>ERROR_INVALID_ARGUMENT when either start or end is inside a multi byte line delimiter.
6502 * Splitting a line delimiter for example by inserting text in between the CR and LF and deleting part of a line delimiter is not supported</li> 6498 * Splitting a line delimiter for example by inserting text in between the CR and LF and deleting part of a line delimiter is not supported</li>
6503 * <li>ERROR_NULL_ARGUMENT when string is null</li>
6504 * </ul> 6499 * </ul>
6505 */ 6500 */
6506 public void replaceTextRange(int start, int length, String text) { 6501 public void replaceTextRange(int start, int length, String text) {
6507 checkWidget(); 6502 checkWidget();
6508 if (text is null) { 6503 // DWT extension: allow null for zero length string
6509 DWT.error(DWT.ERROR_NULL_ARGUMENT); 6504 // if (text is null) {
6510 } 6505 // DWT.error(DWT.ERROR_NULL_ARGUMENT);
6506 // }
6511 int contentLength = getCharCount(); 6507 int contentLength = getCharCount();
6512 int end = start + length; 6508 int end = start + length;
6513 if (start > end || start < 0 || end > contentLength) { 6509 if (start > end || start < 0 || end > contentLength) {
6514 DWT.error(DWT.ERROR_INVALID_RANGE); 6510 DWT.error(DWT.ERROR_INVALID_RANGE);
6515 } 6511 }
8093 * @exception DWTException <ul> 8089 * @exception DWTException <ul>
8094 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> 8090 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
8095 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> 8091 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
8096 * </ul> 8092 * </ul>
8097 * @exception IllegalArgumentException <ul> 8093 * @exception IllegalArgumentException <ul>
8098 * <li>ERROR_NULL_ARGUMENT when the list of ranges is null</li>
8099 * <li>ERROR_INVALID_RANGE when the last of the style ranges is outside the valid range (> getCharCount())</li> 8094 * <li>ERROR_INVALID_RANGE when the last of the style ranges is outside the valid range (> getCharCount())</li>
8100 * </ul> 8095 * </ul>
8101 * 8096 *
8102 * @see #setStyleRanges(int[], StyleRange[]) 8097 * @see #setStyleRanges(int[], StyleRange[])
8103 */ 8098 */
8104 public void setStyleRanges(StyleRange[] ranges) { 8099 public void setStyleRanges(StyleRange[] ranges) {
8105 checkWidget(); 8100 checkWidget();
8106 if (isListening(LineGetStyle)) return; 8101 if (isListening(LineGetStyle)) return;
8107 if (ranges is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); 8102 // DWT extension: allow null for zero length string
8103 //if (ranges is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
8108 setStyleRanges(0, 0, null, ranges, true); 8104 setStyleRanges(0, 0, null, ranges, true);
8109 } 8105 }
8110 /** 8106 /**
8111 * Sets the tab width. 8107 * Sets the tab width.
8112 * 8108 *
8140 * current selection is also discarded. 8136 * current selection is also discarded.
8141 * @exception DWTException <ul> 8137 * @exception DWTException <ul>
8142 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> 8138 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
8143 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> 8139 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
8144 * </ul> 8140 * </ul>
8145 * @exception IllegalArgumentException <ul>
8146 * <li>ERROR_NULL_ARGUMENT when string is null</li>
8147 * </ul>
8148 */ 8141 */
8149 public void setText(String text) { 8142 public void setText(String text) {
8150 checkWidget(); 8143 checkWidget();
8151 if (text is null) { 8144 // DWT extension: allow null for zero length string
8152 DWT.error(DWT.ERROR_NULL_ARGUMENT); 8145 // if (text is null) {
8153 } 8146 // DWT.error(DWT.ERROR_NULL_ARGUMENT);
8147 // }
8154 Event event = new Event(); 8148 Event event = new Event();
8155 event.start = 0; 8149 event.start = 0;
8156 event.end = getCharCount(); 8150 event.end = getCharCount();
8157 event.text = text; 8151 event.text = text;
8158 event.doit = true; 8152 event.doit = true;