Changeset 255:5a30aa9820f3
- Timestamp:
- 06/15/08 16:32:20
(3 months ago)
- Author:
- Frank Benoit <benoit@tionex.de>
- branch:
- default
- Message:
removed tango.stdc.stringz imports and allow null for arrays and string arguments.
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r238 |
r255 |
|
| 26 | 26 | import dwt.DWT; |
|---|
| 27 | 27 | |
|---|
| 28 | | import tango.stdc.stringz; |
|---|
| 29 | 28 | import tango.io.Stdout; |
|---|
| 30 | 29 | |
|---|
| r240 |
r255 |
|
| 27 | 27 | import dwt.dwthelper.utils; |
|---|
| 28 | 28 | import tango.io.Stdout; |
|---|
| 29 | | import tango.stdc.stringz; |
|---|
| 30 | 29 | import tango.text.Util; |
|---|
| 31 | 30 | import Math = tango.math.Math; |
|---|
| r240 |
r255 |
|
| 193 | 193 | * @param string the new item |
|---|
| 194 | 194 | * |
|---|
| 195 | | * @exception IllegalArgumentException <ul> |
|---|
| 196 | | * <li>ERROR_NULL_ARGUMENT - if the string is null</li> |
|---|
| 197 | | * </ul> |
|---|
| 198 | 195 | * @exception DWTException <ul> |
|---|
| 199 | 196 | * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
|---|
| … | … | |
| 205 | 202 | public void add (String string) { |
|---|
| 206 | 203 | checkWidget(); |
|---|
| 207 | | if (string is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); |
|---|
| | 204 | // DWT extension: allow null for zero length string |
|---|
| | 205 | //if (string is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); |
|---|
| 208 | 206 | list.add (string); |
|---|
| 209 | 207 | } |
|---|
| … | … | |
| 221 | 219 | * |
|---|
| 222 | 220 | * @exception IllegalArgumentException <ul> |
|---|
| 223 | | * <li>ERROR_NULL_ARGUMENT - if the string is null</li> |
|---|
| 224 | 221 | * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list (inclusive)</li> |
|---|
| 225 | 222 | * </ul> |
|---|
| … | … | |
| 233 | 230 | public void add (String string, int index) { |
|---|
| 234 | 231 | checkWidget(); |
|---|
| 235 | | if (string is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); |
|---|
| | 232 | // DWT extension: allow null for zero length string |
|---|
| | 233 | //if (string is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); |
|---|
| 236 | 234 | list.add (string, index); |
|---|
| 237 | 235 | } |
|---|
| … | … | |
| 870 | 868 | * @return the index of the item |
|---|
| 871 | 869 | * |
|---|
| 872 | | * @exception IllegalArgumentException <ul> |
|---|
| 873 | | * <li>ERROR_NULL_ARGUMENT - if the string is null</li> |
|---|
| 874 | | * </ul> |
|---|
| 875 | 870 | * @exception DWTException <ul> |
|---|
| 876 | 871 | * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
|---|
| … | … | |
| 880 | 875 | public int indexOf (String string) { |
|---|
| 881 | 876 | checkWidget (); |
|---|
| 882 | | if (string is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); |
|---|
| | 877 | // DWT extension: allow null for zero length string |
|---|
| | 878 | //if (string is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); |
|---|
| 883 | 879 | return list.indexOf (string); |
|---|
| 884 | 880 | } |
|---|
| … | … | |
| 894 | 890 | * @return the index of the item |
|---|
| 895 | 891 | * |
|---|
| 896 | | * @exception IllegalArgumentException <ul> |
|---|
| 897 | | * <li>ERROR_NULL_ARGUMENT - if the string is null</li> |
|---|
| 898 | | * </ul> |
|---|
| 899 | 892 | * @exception DWTException <ul> |
|---|
| 900 | 893 | * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
|---|
| … | … | |
| 904 | 897 | public int indexOf (String string, int start) { |
|---|
| 905 | 898 | checkWidget (); |
|---|
| 906 | | if (string is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); |
|---|
| | 899 | // DWT extension: allow null for zero length string |
|---|
| | 900 | //if (string is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); |
|---|
| 907 | 901 | return list.indexOf (string, start); |
|---|
| 908 | 902 | } |
|---|
| … | … | |
| 1238 | 1232 | * |
|---|
| 1239 | 1233 | * @exception IllegalArgumentException <ul> |
|---|
| 1240 | | * <li>ERROR_NULL_ARGUMENT - if the string is null</li> |
|---|
| 1241 | 1234 | * <li>ERROR_INVALID_ARGUMENT - if the string is not found in the list</li> |
|---|
| 1242 | 1235 | * </ul> |
|---|
| … | … | |
| 1248 | 1241 | public void remove (String string) { |
|---|
| 1249 | 1242 | checkWidget(); |
|---|
| 1250 | | if (string is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); |
|---|
| | 1243 | // DWT extension: allow null for zero length string |
|---|
| | 1244 | //if (string is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); |
|---|
| 1251 | 1245 | list.remove (string); |
|---|
| 1252 | 1246 | } |
|---|
| … | … | |
| 1422 | 1416 | * @exception IllegalArgumentException <ul> |
|---|
| 1423 | 1417 | * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li> |
|---|
| 1424 | | * <li>ERROR_NULL_ARGUMENT - if the string is null</li> |
|---|
| 1425 | 1418 | * </ul> |
|---|
| 1426 | 1419 | * @exception DWTException <ul> |
|---|
| … | … | |
| 1439 | 1432 | * |
|---|
| 1440 | 1433 | * @exception IllegalArgumentException <ul> |
|---|
| 1441 | | * <li>ERROR_NULL_ARGUMENT - if the items array is null</li> |
|---|
| 1442 | 1434 | * <li>ERROR_INVALID_ARGUMENT - if an item in the items array is null</li> |
|---|
| 1443 | 1435 | * </ul> |
|---|
| … | … | |
| 1531 | 1523 | * @param string the new text |
|---|
| 1532 | 1524 | * |
|---|
| 1533 | | * @exception IllegalArgumentException <ul> |
|---|
| 1534 | | * <li>ERROR_NULL_ARGUMENT - if the string is null</li> |
|---|
| 1535 | | * </ul> |
|---|
| 1536 | 1525 | * @exception DWTException <ul> |
|---|
| 1537 | 1526 | * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
|---|
| … | … | |
| 1541 | 1530 | public void setText (String string) { |
|---|
| 1542 | 1531 | checkWidget(); |
|---|
| 1543 | | if (string is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); |
|---|
| | 1532 | // DWT extension: allow null for zero length string |
|---|
| | 1533 | //if (string is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); |
|---|
| 1544 | 1534 | int index = list.indexOf (string); |
|---|
| 1545 | 1535 | if (index is -1) { |
|---|
| r240 |
r255 |
|
| 773 | 773 | * Otherwise return <code>false</code>. The initial value is defined by the style (DWT.CLOSE) |
|---|
| 774 | 774 | * that was used to create the receiver. |
|---|
| 775 | | * |
|---|
| | 775 | * |
|---|
| 776 | 776 | * @return <code>true</code> if the close button should be shown |
|---|
| 777 | 777 | * |
|---|
| … | … | |
| 780 | 780 | * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> |
|---|
| 781 | 781 | * </ul> |
|---|
| 782 | | * |
|---|
| | 782 | * |
|---|
| 783 | 783 | * @since 3.4 |
|---|
| 784 | 784 | */ |
|---|
| … | … | |
| 1022 | 1022 | * If the parent (CTabFolder) was created with DWT.CLOSE style, changing this value has |
|---|
| 1023 | 1023 | * no effect. |
|---|
| 1024 | | * |
|---|
| | 1024 | * |
|---|
| 1025 | 1025 | * @param close the new state of the close button |
|---|
| 1026 | 1026 | * |
|---|
| … | … | |
| 1029 | 1029 | * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> |
|---|
| 1030 | 1030 | * </ul> |
|---|
| 1031 | | * |
|---|
| | 1031 | * |
|---|
| 1032 | 1032 | * @since 3.4 |
|---|
| 1033 | 1033 | */ |
|---|
| … | … | |
| 1041 | 1041 | public override void setText (String string) { |
|---|
| 1042 | 1042 | checkWidget(); |
|---|
| 1043 | | if (string is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); |
|---|
| 1044 | | if (string==getText()) return; |
|---|
| | 1043 | // DWT extension: allow null for zero length string |
|---|
| | 1044 | //if (string is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); |
|---|
| | 1045 | if (string.equals (getText())) return; |
|---|
| 1045 | 1046 | super.setText(string); |
|---|
| 1046 | 1047 | shortenedText = null; |
|---|
| r238 |
r255 |
|
| 1 | | /******************************************************************************* |
|---|
| | 1 | /******************************************************************************* |
|---|
| 2 | 2 | * Copyright (c) 2000, 2007 IBM Corporation and others. |
|---|
| 3 | 3 | * All rights reserved. This program and the accompanying materials |
|---|
| … | … | |
| 264 | 264 | * |
|---|
| 265 | 265 | * @exception IllegalArgumentException <ul> |
|---|
| 266 | | * <li>ERROR_NULL_ARGUMENT - if the items array is null</li> |
|---|
| 267 | 266 | * <li>ERROR_INVALID_ARGUMENT - if an item in the items array is null</li> |
|---|
| 268 | 267 | * </ul> |
|---|
| r240 |
r255 |
|
| 1599 | 1599 | * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> |
|---|
| 1600 | 1600 | * </ul> |
|---|
| 1601 | | * @exception IllegalArgumentException <ul> |
|---|
| 1602 | | * <li>ERROR_NULL_ARGUMENT when listener is null</li> |
|---|
| 1603 | | * </ul> |
|---|
| 1604 | 1601 | */ |
|---|
| 1605 | 1602 | public void append(String string) { |
|---|
| 1606 | 1603 | checkWidget(); |
|---|
| 1607 | | if (string is null) { |
|---|
| 1608 | | DWT.error(DWT.ERROR_NULL_ARGUMENT); |
|---|
| 1609 | | } |
|---|
| | 1604 | // DWT extension: allow null for zero length string |
|---|
| | 1605 | // if (string is null) { |
|---|
| | 1606 | // DWT.error(DWT.ERROR_NULL_ARGUMENT); |
|---|
| | 1607 | // } |
|---|
| 1610 | 1608 | int lastChar = Math.max(getCharCount(), 0); |
|---|
| 1611 | 1609 | replaceTextRange(lastChar, 0, string); |
|---|
| … | … | |
| 4935 | 4933 | * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> |
|---|
| 4936 | 4934 | * </ul> |
|---|
| 4937 | | * @exception IllegalArgumentException <ul> |
|---|
| 4938 | | * <li>ERROR_NULL_ARGUMENT when string is null</li> |
|---|
| 4939 | | * </ul> |
|---|
| 4940 | 4935 | */ |
|---|
| 4941 | 4936 | public void insert(String string) { |
|---|
| 4942 | 4937 | checkWidget(); |
|---|
| 4943 | | if (string is null) { |
|---|
| 4944 | | DWT.error(DWT.ERROR_NULL_ARGUMENT); |
|---|
| 4945 | | } |
|---|
| | 4938 | // DWT extension: allow null for zero length string |
|---|
| | 4939 | // if (string is null) { |
|---|
| | 4940 | // DWT.error(DWT.ERROR_NULL_ARGUMENT); |
|---|
| | 4941 | // } |
|---|
| 4946 | 4942 | Point sel = getSelectionRange(); |
|---|
| 4947 | 4943 | replaceTextRange(sel.x, sel.y, string); |
|---|
| … | … | |
| 6458 | 6454 | * @exception IllegalArgumentException <ul> |
|---|
| 6459 | 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 | 6456 | * </ul> |
|---|
| 6462 | 6457 | * |
|---|
| … | … | |
| 6468 | 6463 | checkWidget(); |
|---|
| 6469 | 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 | 6467 | setStyleRanges(start, length, null, ranges, false); |
|---|
| 6472 | 6468 | } |
|---|
| … | … | |
| 6501 | 6497 | * <li>ERROR_INVALID_ARGUMENT when either start or end is inside a multi byte line delimiter. |
|---|
| 6502 | 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 | 6499 | * </ul> |
|---|
| 6505 | 6500 | */ |
|---|
| 6506 | 6501 | public void replaceTextRange(int start, int length, String text) { |
|---|
| 6507 | 6502 | checkWidget(); |
|---|
| 6508 | | if (text is null) { |
|---|
| 6509 | | DWT.error(DWT.ERROR_NULL_ARGUMENT); |
|---|
| 6510 | | } |
|---|
| | 6503 | // DWT extension: allow null for zero length string |
|---|
| | 6504 | // if (text is null) { |
|---|
| | 6505 | // DWT.error(DWT.ERROR_NULL_ARGUMENT); |
|---|
| | 6506 | // } |
|---|
| 6511 | 6507 | int contentLength = getCharCount(); |
|---|
| 6512 | 6508 | int end = start + length; |
|---|
| … | … | |
| 8096 | 8092 | * </ul> |
|---|
| 8097 | 8093 | * @exception IllegalArgumentException <ul> |
|---|
| 8098 | | * <li>ERROR_NULL_ARGUMENT when the list of ranges is null</li> |
|---|
| 8099 | 8094 | * <li>ERROR_INVALID_RANGE when the last of the style ranges is outside the valid range (> getCharCount())</li> |
|---|
| 8100 | 8095 | * </ul> |
|---|
| … | … | |
| 8105 | 8100 | checkWidget(); |
|---|
| 8106 | 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 | 8104 | setStyleRanges(0, 0, null, ranges, true); |
|---|
| 8109 | 8105 | } |
|---|
| … | … | |
| 8143 | 8139 | * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> |
|---|
| 8144 | 8140 | * </ul> |
|---|
| 8145 | | * @exception IllegalArgumentException <ul> |
|---|
| 8146 | | * <li>ERROR_NULL_ARGUMENT when string is null</li> |
|---|
| 8147 | | * </ul> |
|---|
| 8148 | 8141 | */ |
|---|
| 8149 | 8142 | public void setText(String text) { |
|---|
| 8150 | 8143 | checkWidget(); |
|---|
| 8151 | | if (text is null) { |
|---|
| 8152 | | DWT.error(DWT.ERROR_NULL_ARGUMENT); |
|---|
| 8153 | | } |
|---|
| | 8144 | // DWT extension: allow null for zero length string |
|---|
| | 8145 | // if (text is null) { |
|---|
| | 8146 | // DWT.error(DWT.ERROR_NULL_ARGUMENT); |
|---|
| | 8147 | // } |
|---|
| 8154 | 8148 | Event event = new Event(); |
|---|
| 8155 | 8149 | event.start = 0; |
|---|
| r238 |
r255 |
|
| 765 | 765 | * |
|---|
| 766 | 766 | * @exception IllegalArgumentException <ul> |
|---|
| 767 | | * <li>ERROR_NULL_ARGUMENT - if the array of items is null</li> |
|---|
| | 767 | * <li>ERROR_NULL_ARGUMENT - if one of the items is null</li> |
|---|
| 768 | 768 | * <li>ERROR_INVALID_ARGUMENT - if one of the item has been disposed</li> |
|---|
| 769 | 769 | * </ul> |
|---|
| … | … | |
| 777 | 777 | public void setSelection (TableTreeItem[] items) { |
|---|
| 778 | 778 | checkWidget (); |
|---|
| 779 | | if (items is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); |
|---|
| | 779 | // DWT extension: allow null for zero length string |
|---|
| | 780 | //if (items is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); |
|---|
| 780 | 781 | int length = items.length; |
|---|
| 781 | 782 | if (length is 0 || ((table.getStyle() & DWT.SINGLE) !is 0 && length > 1)) { |
|---|
| r240 |
r255 |
|
| 820 | 820 | * @param text the new text |
|---|
| 821 | 821 | * |
|---|
| 822 | | * @exception IllegalArgumentException <ul> |
|---|
| 823 | | * <li>ERROR_NULL_ARGUMENT - if the text is null</li> |
|---|
| 824 | | * </ul> |
|---|
| 825 | 822 | * @exception DWTException <ul> |
|---|
| 826 | 823 | * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li> |
|---|
| … | … | |
| 830 | 827 | public void setText(int index, String text) { |
|---|
| 831 | 828 | checkWidget(); |
|---|
| 832 | | if (text is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); |
|---|
| | 829 | // DWT extension: allow null for zero length string |
|---|
| | 830 | //if (text is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); |
|---|
| 833 | 831 | int columnCount = Math.max(parent.getTable().getColumnCount(), 1); |
|---|
| 834 | 832 | if (index < 0 || index >= columnCount) return; |
|---|
| r238 |
r255 |
|
| 29 | 29 | |
|---|
| 30 | 30 | import tango.core.Thread; |
|---|
| 31 | | static import tango.stdc.stringz; |
|---|
| 32 | 31 | static import tango.stdc.string; |
|---|
| 33 | 32 | |
|---|
| … | … | |
| 564 | 563 | continue; |
|---|
| 565 | 564 | } |
|---|
| 566 | | String buffer = tango.stdc.stringz.fromStringz( pName ).dup; |
|---|
| | 565 | String buffer = fromStringz( pName ).dup; |
|---|
| 567 | 566 | OS.g_free (pName); |
|---|
| 568 | 567 | result[count++] = "GTKCLIPBOARD "~buffer; |
|---|
| … | … | |
| 573 | 572 | continue; |
|---|
| 574 | 573 | } |
|---|
| 575 | | String buffer = tango.stdc.stringz.fromStringz( pName ).dup; |
|---|
| | 574 | String buffer = fromStringz( pName ).dup; |
|---|
| 576 | 575 | OS.g_free (pName); |
|---|
| 577 | 576 | result[count++] = "GTKPRIMARYCLIPBOARD "~buffer; |
|---|
| r240 |
r255 |
|
| 90 | 90 | OS.g_free(localePtr); |
|---|
| 91 | 91 | if (error !is null || uriPtr is null) continue; |
|---|
| 92 | | String temp = tango.stdc.stringz.fromStringz( uriPtr ).dup; |
|---|
| | 92 | String temp = fromStringz( uriPtr ).dup; |
|---|
| 93 | 93 | OS.g_free(uriPtr); |
|---|
| 94 | 94 | int newLength = (i > 0) ? buffer.length+separator.length+temp.length : temp.length; |
|---|
| … | … | |
| 163 | 163 | OS.g_free(localePtr); |
|---|
| 164 | 164 | if (error !is null || utf8Ptr is null) continue; |
|---|
| 165 | | String buffer = tango.stdc.stringz.fromStringz( utf8Ptr ).dup; |
|---|
| | 165 | String buffer = fromStringz( utf8Ptr ).dup; |
|---|
| 166 | 166 | OS.g_free(utf8Ptr); |
|---|
| 167 | 167 | String name = buffer; |
|---|
| r238 |
r255 |
|
| 20 | 20 | import dwt.dnd.DND; |
|---|
| 21 | 21 | |
|---|
| 22 | | |
|---|
| 23 | | static import tango.stdc.stringz; |
|---|
| 24 | 22 | |
|---|
| 25 | 23 | /** |
|---|
| … | … | |
| 81 | 79 | } |
|---|
| 82 | 80 | String string = (cast(ArrayWrapperString)object).array; |
|---|
| 83 | | char* utf8 = tango.stdc.stringz.toStringz(string); |
|---|
| | 81 | char* utf8 = toStringz(string); |
|---|
| 84 | 82 | if (transferData.type is cast(void*) COMPOUND_TEXT_ID) { |
|---|
| 85 | 83 | void* encoding; |
|---|
| … | … | |
| 131 | 129 | int count = OS.gdk_text_property_to_utf8_list(transferData.type, transferData.format, transferData.pValue, transferData.length, &list); |
|---|
| 132 | 130 | if (count is 0) return null; |
|---|
| 133 | | String utf8 = tango.stdc.stringz.fromStringz( list[0] ).dup; |
|---|
| | 131 | String utf8 = fromStringz( list[0] ).dup; |
|---|
| 134 | 132 | OS.g_strfreev(list); |
|---|
| 135 | 133 | return new ArrayWrapperString( utf8 ); |
|---|
| r238 |
r255 |
|
| 1 | | /******************************************************************************* |
|---|
| | 1 | /******************************************************************************* |
|---|
| 2 | 2 | * Copyright (c) 2000, 2007 IBM Corporation and others. |
|---|
| 3 | 3 | * All rights reserved. This program and the accompanying materials |
|---|
| … | … | |
| 20 | 20 | import dwt.dnd.TransferData; |
|---|
| 21 | 21 | |
|---|
| 22 | | static import tango.stdc.stringz; |
|---|
| 23 | 22 | |
|---|
| 24 | 23 | /** |
|---|
| … | … | |
| 140 | 139 | public static int registerType(String formatName){ |
|---|
| 141 | 140 | if (formatName is null) return OS.GDK_NONE; |
|---|
| 142 | | char* buffer = tango.stdc.stringz.toStringz( formatName ); |
|---|
| | 141 | char* buffer = toStringz( formatName ); |
|---|
| 143 | 142 | return cast(int)/*64*/OS.gdk_atom_intern(buffer, false); |
|---|
| 144 | 143 | } |
|---|
| r240 |
r255 |
|
| 97 | 97 | int size = (transferData.format * transferData.length / 8); |
|---|
| 98 | 98 | if (size <= 0) return null; |
|---|
| 99 | | String string = tango.stdc.stringz.fromStringz(cast(char*)transferData.pValue).dup; |
|---|
| | 99 | String string = fromStringz(cast(char*)transferData.pValue).dup; |
|---|
| 100 | 100 | int end = string.indexOf('\0'); |
|---|
| 101 | 101 | return new ArrayWrapperString((end is -1) ? string : string.substring(0, end)); |
|---|
| r254 |
r255 |
|
| 11 | 11 | import tango.io.Stdout; |
|---|
| 12 | 12 | import tango.io.Print; |
|---|
| 13 | | import tango.stdc.stringz; |
|---|
| | 13 | static import tango.stdc.stringz; |
|---|
| 14 | 14 | static import tango.text.Util; |
|---|
| 15 | 15 | static import tango.text.Text; |
|---|
| … | … | |
| 630 | 630 | } |
|---|
| 631 | 631 | |
|---|
| | 632 | public alias tango.stdc.stringz.toStringz toStringz; |
|---|
| | 633 | public alias tango.stdc.stringz.toString16z toString16z; |
|---|
| | 634 | public alias tango.stdc.stringz.fromStringz fromStringz; |
|---|
| | 635 | public alias tango.stdc.stringz.fromString16z fromString16z; |
|---|
| | 636 | |
|---|
| 632 | 637 | static String toHex(uint value, bool prefix = true, int radix = 8){ |
|---|
| 633 | 638 | return tango.text.convert.Integer.toString( |
|---|
| r240 |
r255 |
|
| 29 | 29 | |
|---|
| 30 | 30 | import tango.core.Exception; |
|---|
| 31 | | import tango.stdc.stringz; |
|---|
| 32 | 31 | import tango.io.Stdout; |
|---|
| 33 | 32 | |
|---|
| … | … | |
| 591 | 590 | int flags = OS.G_LOG_LEVEL_MASK | OS.G_LOG_FLAG_FATAL | OS.G_LOG_FLAG_RECURSION; |
|---|
| 592 | 591 | for (int i=0; i<log_domains.length; i++) { |
|---|
| 593 | | handler_ids [i] = OS.g_log_set_handler (toStringz(log_domains [i]), flags, & logFunction, cast(void*)this); |
|---|
| | 592 | handler_ids [i] = OS.g_log_set_handler (log_domains [i].toStringzValidPtr(), flags, & logFunction, cast(void*)this); |
|---|
| 594 | 593 | } |
|---|
| 595 | 594 | } |
|---|
| … | … | |
| 691 | 690 | checkDevice(); |
|---|
| 692 | 691 | if (path is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); |
|---|
| 693 | | return cast(bool) OS.FcConfigAppFontAddFile (null, toStringz(path)); |
|---|
| | 692 | return cast(bool) OS.FcConfigAppFontAddFile (null, path.toStringzValidPtr()); |
|---|
| 694 | 693 | } |
|---|
| 695 | 694 | |
|---|
| … | … | |
| 792 | 791 | for (int i=0; i<handler_ids.length; i++) { |
|---|
| 793 | 792 | if (handler_ids [i] !is 0 ) { |
|---|
| 794 | | OS.g_log_remove_handler (toStringz(log_domains [i]), handler_ids [i]); |
|---|
| | 793 | OS.g_log_remove_handler (log_domains [i].toStringzValidPtr(), handler_ids [i]); |
|---|
| 795 | 794 | handler_ids [i] = 0; |
|---|
| 796 | 795 | } |
|---|
| … | … | |
| 821 | 820 | for (int i=0; i<handler_ids.length; i++) { |
|---|
| 822 | 821 | if (handler_ids [i] !is 0) { |
|---|
| 823 | | OS.g_log_remove_handler (toStringz(log_domains [i]), handler_ids [i]); |
|---|
| | 822 | OS.g_log_remove_handler (log_domains [i].toStringzValidPtr(), handler_ids [i]); |
|---|
| 824 | 823 | handler_ids [i] = 0; |
|---|
| 825 | 824 | } |
|---|
| … | … | |
| 831 | 830 | int flags = OS.G_LOG_LEVEL_MASK | OS.G_LOG_FLAG_FATAL | OS.G_LOG_FLAG_RECURSION; |
|---|
| 832 | 831 | for (int i=0; i<log_domains.length; i++) { |
|---|
| 833 | | handler_ids [i] = OS.g_log_set_handler (toStringz(log_domains [i]), flags, & logFunction, cast(void*)this ); |
|---|
| | 832 | handler_ids [i] = OS.g_log_set_handler (log_domains [i].toStringzValidPtr(), flags, & logFunction, cast(void*)this ); |
|---|
| 834 | 833 | } |
|---|
| 835 | 834 | } |
|---|
| r240 |
r255 |
|
| 24 | 24 | |
|---|
| 25 | 25 | import tango.text.convert.Format; |
|---|
| 26 | | import tango.stdc.stringz; |
|---|
| 27 | 26 | |
|---|
| 28 | 27 | /** |
|---|
| r242 |
r255 |
|
| 46 | 46 | import tango.text.convert.Format; |
|---|
| 47 | 47 | import tango.stdc.string; |
|---|
| 48 | | import tango.stdc.stringz; |
|---|
| 49 | 48 | |
|---|
| 50 | 49 | |
|---|
| r240 |
r255 |
|
| 34 | 34 | import tango.text.convert.Format; |
|---|
| 35 | 35 | import tango.stdc.string; |
|---|
| 36 | | import tango.stdc.stringz; |
|---|
| 37 | 36 | |
|---|
| 38 | 37 | /** |
|---|
| r240 |
r255 |
|
| 445 | 445 | int bytesPerLine = (((width * depth + 7) / 8) + (scanlinePad - 1)) |
|---|
| 446 | 446 | / scanlinePad * scanlinePad; |
|---|
| 447 | | |
|---|
| | 447 | |
|---|
| 448 | 448 | /* |
|---|
| 449 | 449 | * When the image is being loaded from a PNG, we need to use the theoretical minimum |
|---|
| r246 |
r255 |
|
| 33 | 33 | |
|---|
| 34 | 34 | import tango.text.convert.Format; |
|---|
| 35 | | import tango.stdc.stringz; |
|---|
| 36 | 35 | import tango.stdc.string; |
|---|
| 37 | 36 | import tango.text.convert.Utf; |
|---|
| r238 |
r255 |
|
| 1 | | /******************************************************************************* |
|---|
| | 1 | /******************************************************************************* |
|---|
| 2 | 2 | * Copyright (c) 2000, 2004 IBM Corporation and others. |
|---|
| 3 | 3 | * All rights reserved. This program and the accompanying materials |
|---|
| … | … | |
| 14 | 14 | |
|---|
| 15 | 15 | import dwt.dwthelper.utils; |
|---|
| 16 | | |
|---|
| 17 | | |
|---|
| 18 | | //import dwt.internal.gtk.OS; |
|---|
| 19 | | import tango.stdc.stringz; |
|---|
| 20 | 16 | |
|---|
| 21 | 17 | extern(C) { |
|---|
| r240 |
r255 |
|
| 29 | 29 | import tango.util.Convert; |
|---|
| 30 | 30 | import Math = tango.math.Math; |
|---|
| 31 | | static import tango.stdc.stringz; |
|---|
| 32 | 31 | |
|---|
| 33 | 32 | /** |
|---|
| … | … | |
| 285 | 284 | return Printer.getDefaultPrinterData(); |
|---|
| 286 | 285 | } else { |
|---|
| 287 | | char* titleBytes = tango.stdc.stringz.toStringz( getText() ); |
|---|
| | 286 | char* titleBytes = toStringz( getText() ); |
|---|
| 288 | 287 | auto topHandle = getParent().handle; |
|---|
| 289 | 288 | while (topHandle !is null && !OS.GTK_IS_WINDOW(topHandle)) { |
|---|
| … | … | |
| 310 | 309 | //TODO: Should we look at printToFile, or driver/name for "Print to File", or both? (see gtk bug 345590) |
|---|
| 311 | 310 | if (printerData.printToFile) { |
|---|
| 312 | | char* buffer = tango.stdc.stringz.toStringz(printerData.fileName); |
|---|
| | 311 | char* buffer = toStringz(printerData.fileName); |
|---|
| 313 | 312 | OS.gtk_print_settings_set(settings, OS.GTK_PRINT_SETTINGS_OUTPUT_URI.ptr, buffer); |
|---|
| 314 | 313 | } |
|---|
| 315 | 314 | if (printerData.driver.equals("GtkPrintBackendFile") && printerData.name.equals("Print to File")) { //$NON-NLS-1$ //$NON-NLS-2$ |
|---|
| 316 | | char* buffer = tango.stdc.stringz.toStringz(printerData.fileName); |
|---|
| | 315 | char* buffer = toStringz(printerData.fileName); |
|---|
| 317 | 316 | OS.gtk_print_settings_set(settings, OS.GTK_PRINT_SETTINGS_OUTPUT_URI.ptr, buffer); |
|---|
| 318 | 317 | } |
|---|
| … | … | |
| 324 | 323 | |
|---|
| 325 | 324 | if (printToFile) { |
|---|
| 326 | | char* buffer = tango.stdc.stringz.toStringz( "Print to File" ); //$NON-NLS-1$ |
|---|
| | 325 | char* buffer = toStringz( "Print to File" ); //$NON-NLS-1$ |
|---|
| 327 | 326 | OS.gtk_print_settings_set_printer(settings, buffer); |
|---|
| 328 | 327 | } |
|---|
| … | … | |
| 393 | 392 | if (printToFile) { |
|---|
| 394 | 393 | auto address = OS.gtk_print_settings_get(settings, OS.GTK_PRINT_SETTINGS_OUTPUT_URI.ptr); |
|---|
| 395 | | data.fileName = tango.stdc.stringz.fromStringz( address).dup; |
|---|
| | 394 | data.fileName = fromStringz( address).dup; |
|---|
| 396 | 395 | } |
|---|
| 397 | 396 | |
|---|
| … | … | |
| 440 | 439 | |
|---|
| 441 | 440 | void GtkPrintSettingsMeth (char* key, char* value) { |
|---|
| 442 | | store( tango.stdc.stringz.fromStringz(key).dup, tango.stdc.stringz.fromStringz(value).dup ); |
|---|
| | 441 | store( fromStringz(key).dup, fromStringz(value).dup ); |
|---|
| 443 | 442 | } |
|---|
| 444 | 443 | |
|---|
| … | … | |
| 456 | 455 | |
|---|
| 457 | 456 | void storeBytes(String key, char* value) { |
|---|
| 458 | | store(key, tango.stdc.stringz.fromStringz(value).dup ); |
|---|
| | 457 | store(key, fromStringz(value).dup ); |
|---|
| 459 | 458 | } |
|---|
| 460 | 459 | |
|---|
| r240 |
r255 |
|
| 29 | 29 | import dwt.dwthelper.utils; |
|---|
| 30 | 30 | |
|---|
| 31 | | static import tango.stdc.stringz; |
|---|
| 32 | 31 | import tango.io.Stdout; |
|---|
| 33 | 32 | import tango.util.Convert; |
|---|
| … | … | |
| 179 | 178 | auto backend = OS.gtk_printer_get_backend(printer); |
|---|
| 180 | 179 | auto address = OS.G_OBJECT_TYPE_NAME(backend); |
|---|
| 181 | | String backendType =tango.stdc.stringz.fromStringz( address ).dup; |
|---|
| | 180 | String backendType = fromStringz( address ).dup; |
|---|
| 182 | 181 | |
|---|
| 183 | 182 | address = OS.gtk_printer_get_name (printer); |
|---|
| 184 | | String name =tango.stdc.stringz.fromStringz( address ).dup; |
|---|
| | 183 | String name = fromStringz( address ).dup; |
|---|
| 185 | 184 | |
|---|
| 186 | 185 | return new PrinterData (backendType, name); |
|---|
| … | … | |
| 469 | 468 | public bool startJob(String jobName) { |
|---|
| 470 | 469 | checkDevice(); |
|---|
| 471 | | char* buffer = tango.stdc.stringz.toStringz(jobName); |
|---|
| | 470 | char* buffer = toStringz(jobName); |
|---|
| 472 | 471 | printJob = OS.gtk_print_job_new (buffer, printer, settings, pageSetup); |
|---|
| 473 | 472 | if (printJob is null) return false; |
|---|
| … | … | |
| 737 | 736 | //TODO: Should we look at printToFile, or driver/name for "Print to File", or both? (see gtk bug 345590) |
|---|
| 738 | 737 | if (data.printToFile) { |
|---|
| 739 | | char* buffer = tango.stdc.stringz.toStringz( data.fileName ); |
|---|
| | 738 | char* buffer = toStringz( data.fileName ); |
|---|
| 740 | 739 | OS.gtk_print_settings_set(settings, OS.GTK_PRINT_SETTINGS_OUTPUT_URI.ptr, buffer); |
|---|
| 741 | 740 | } |
|---|
| 742 | 741 | if (data.driver.equals("GtkPrintBackendFile") && data.name.equals("Print to File")) { //$NON-NLS-1$ //$NON-NLS-2$ |
|---|
| 743 | | char* buffer = tango.stdc.stringz.toStringz( data.fileName ); |
|---|
| | 742 | char* buffer = toStringz( data.fileName ); |
|---|
| 744 | 743 | OS.gtk_print_settings_set(settings, OS.GTK_PRINT_SETTINGS_OUTPUT_URI.ptr, buffer); |
|---|
| 745 | 744 | } |
|---|
| r240 |
r255 |
|
| 25 | 25 | |
|---|
| 26 | 26 | import tango.sys.SharedLib; |
|---|
| 27 | | import tango.stdc.stringz; |
|---|
| 28 | 27 | import tango.core.Exception; |
|---|
| 29 | 28 | import tango.core.Array; |
|---|
| … | … | |
| 706 | 705 | * @return the program or <code>null</code> |
|---|
| 707 | 706 | * |
|---|
| 708 | | * @exception IllegalArgumentException <ul> |
|---|
| 709 | | * <li>ERROR_NULL_ARGUMENT when extension is null</li> |
|---|
| 710 | | * </ul> |
|---|
| 711 | 707 | */ |
|---|
| 712 | 708 | public static Program findProgram(String extension) { |
|---|
| … | … | |
| 719 | 715 | */ |
|---|
| 720 | 716 | static Program findProgram(Display display, String extension) { |
|---|
| 721 | | if (extension is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); |
|---|
| | 717 | // DWT extension: allow null for zero length string |
|---|
| | 718 | //if (extension is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); |
|---|
| 722 | 719 | if (extension.length is 0) return null; |
|---|
| 723 | 720 | if (extension.charAt(0) !is '.') extension = "." ~ extension; |
|---|
| r248 |
r255 |
|
| 27 | 27 | import dwt.widgets.Decorations; |
|---|
| 28 | 28 | |
|---|
| 29 | | import tango.stdc.stringz; |
|---|
| 30 | 29 | import tango.io.Stdout; |
|---|
| 31 | 30 | |
|---|
| … | … | |
| 783 | 782 | * @param string the new text |
|---|
| 784 | 783 | * |
|---|
| 785 | | * @exception IllegalArgumentException <ul> |
|---|
| 786 | | * <li>ERROR_NULL_ARGUMENT - if the text is null</li> |
|---|
| 787 | | * </ul> |
|---|
| 788 | 784 | * @exception DWTException <ul> |
|---|
| 789 | 785 | * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
|---|
| … | … | |
| 793 | 789 | public void setText (String string) { |
|---|
| 794 | 790 | checkWidget (); |
|---|
| 795 | | if (string is null) error (DWT.ERROR_NULL_ARGUMENT); |
|---|
| | 791 | // DWT extension: allow null for zero length string |
|---|
| | 792 | //if (string is null) error (DWT.ERROR_NULL_ARGUMENT); |
|---|
| 796 | 793 | if ((style & DWT.ARROW) !is 0) return; |
|---|
| 797 | 794 | text = string; |
|---|
| r240 |
r255 |
|
| 13 | 13 | module dwt.widgets.ColorDialog; |
|---|
| 14 | 14 | |
|---|
| 15 | | |
|---|
| 16 | | |
|---|
| 17 | 15 | import dwt.DWT; |
|---|
| 18 | 16 | import dwt.DWTException; |
|---|
| … | … | |
| 24 | 22 | import dwt.widgets.Display; |
|---|
| 25 | 23 | |
|---|
| 26 | | import tango.stdc.stringz; |
|---|
| | 24 | import dwt.dwthelper.utils; |
|---|
| 27 | 25 | |
|---|
| 28 | 26 | /** |
|---|
| r241 |
r255 |
|
| 27 | 27 | |
|---|
| 28 | 28 | import dwt.dwthelper.utils; |
|---|
| 29 | | import tango.stdc.stringz; |
|---|
| 30 | 29 | import Math = tango.math.Math; |
|---|
| 31 | 30 | |
|---|
| … | … | |
| 139 | 138 | * @param string the new item |
|---|
| 140 | 139 | * |
|---|
| 141 | | * @exception IllegalArgumentException <ul> |
|---|
| 142 | | * <li>ERROR_NULL_ARGUMENT - if the string is null</li> |
|---|
| 143 | | * </ul> |
|---|
| 144 | 140 | * @exception DWTException <ul> |
|---|
| 145 | 141 | * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
|---|
| … | … | |
| 151 | 147 | public void add (String string) { |
|---|
| 152 | 148 | checkWidget(); |
|---|
| 153 | | if (string is null) error (DWT.ERROR_NULL_ARGUMENT); |
|---|
| | 149 | // DWT extension: allow null for zero length string |
|---|
| | 150 | //if (string is null) error (DWT.ERROR_NULL_ARGUMENT); |
|---|
| 154 | 151 | add (string, items.length); |
|---|
| 155 | 152 | } |
|---|
| … | … | |
| 168 | 165 | * |
|---|
| 169 | 166 | * @exception IllegalArgumentException <ul> |
|---|
| 170 | | * <li>ERROR_NULL_ARGUMENT - if the string is null</li> |
|---|
| 171 | 167 | * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list (inclusive)</li> |
|---|
| 172 | 168 | * </ul> |
|---|
| … | … | |
| 180 | 176 | public void add (String string, int index) { |
|---|
| 181 | 177 | checkWidget(); |
|---|
| 182 | | if (string is null) error (DWT.ERROR_NULL_ARGUMENT); |
|---|
| | 178 | // DWT extension: allow null for zero length string |
|---|
| | 179 | //if (string is null) error (DWT.ERROR_NULL_ARGUMENT); |
|---|
| 183 | 180 | if (!(0 <= index && index <= items.length)) { |
|---|
| 184 | 181 | error (DWT.ERROR_INVALID_RANGE); |
|---|
| … | … | |
| 189 | 186 | System.arraycopy (items, index, newIte |
|---|