Mercurial > projects > dwt-linux
comparison dwt/widgets/TreeItem.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 |
---|---|
25 import dwt.internal.gtk.OS; | 25 import dwt.internal.gtk.OS; |
26 import dwt.widgets.Item; | 26 import dwt.widgets.Item; |
27 import dwt.widgets.Tree; | 27 import dwt.widgets.Tree; |
28 import dwt.widgets.ImageList; | 28 import dwt.widgets.ImageList; |
29 | 29 |
30 static import tango.stdc.stringz; | |
31 import Math = tango.math.Math; | 30 import Math = tango.math.Math; |
32 | 31 |
33 /** | 32 /** |
34 * Instances of this class represent a selectable user interface object | 33 * Instances of this class represent a selectable user interface object |
35 * that represents a hierarchy of tree items in a tree widget. | 34 * that represents a hierarchy of tree items in a tree widget. |
287 if (0 > index || index > count - 1) return ""; | 286 if (0 > index || index > count - 1) return ""; |
288 void* ptr; | 287 void* ptr; |
289 int modelIndex = parent.columnCount is 0 ? Tree.FIRST_COLUMN : parent.columns [index].modelIndex; | 288 int modelIndex = parent.columnCount is 0 ? Tree.FIRST_COLUMN : parent.columns [index].modelIndex; |
290 OS.gtk_tree_model_get1 (parent.modelHandle, handle, modelIndex + Tree.CELL_TEXT, &ptr); | 289 OS.gtk_tree_model_get1 (parent.modelHandle, handle, modelIndex + Tree.CELL_TEXT, &ptr); |
291 if (ptr is null) return ""; //$NON-NLS-1$ | 290 if (ptr is null) return ""; //$NON-NLS-1$ |
292 char[] buffer = tango.stdc.stringz.fromStringz( cast(char*)ptr).dup; | 291 char[] buffer = fromStringz( cast(char*)ptr).dup; |
293 OS.g_free (ptr); | 292 OS.g_free (ptr); |
294 return buffer; | 293 return buffer; |
295 } | 294 } |
296 | 295 |
297 void clear () { | 296 void clear () { |
1655 * Sets the image for multiple columns in the tree. | 1654 * Sets the image for multiple columns in the tree. |
1656 * | 1655 * |
1657 * @param images the array of new images | 1656 * @param images the array of new images |
1658 * | 1657 * |
1659 * @exception IllegalArgumentException <ul> | 1658 * @exception IllegalArgumentException <ul> |
1660 * <li>ERROR_NULL_ARGUMENT - if the array of images is null</li> | |
1661 * <li>ERROR_INVALID_ARGUMENT - if one of the images has been disposed</li> | 1659 * <li>ERROR_INVALID_ARGUMENT - if one of the images has been disposed</li> |
1662 * </ul> | 1660 * </ul> |
1663 * @exception DWTException <ul> | 1661 * @exception DWTException <ul> |
1664 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | 1662 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
1665 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | 1663 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> |
1667 * | 1665 * |
1668 * @since 3.1 | 1666 * @since 3.1 |
1669 */ | 1667 */ |
1670 public void setImage (Image [] images) { | 1668 public void setImage (Image [] images) { |
1671 checkWidget (); | 1669 checkWidget (); |
1672 if (images is null) error (DWT.ERROR_NULL_ARGUMENT); | 1670 // DWT extension: allow null for zero length string |
1671 //if (images is null) error (DWT.ERROR_NULL_ARGUMENT); | |
1673 for (int i=0; i<images.length; i++) { | 1672 for (int i=0; i<images.length; i++) { |
1674 setImage (i, images [i]); | 1673 setImage (i, images [i]); |
1675 } | 1674 } |
1676 } | 1675 } |
1677 | 1676 |
1697 * Sets the receiver's text at a column | 1696 * Sets the receiver's text at a column |
1698 * | 1697 * |
1699 * @param index the column index | 1698 * @param index the column index |
1700 * @param string the new text | 1699 * @param string the new text |
1701 * | 1700 * |
1702 * @exception IllegalArgumentException <ul> | |
1703 * <li>ERROR_NULL_ARGUMENT - if the text is null</li> | |
1704 * </ul> | |
1705 * @exception DWTException <ul> | 1701 * @exception DWTException <ul> |
1706 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | 1702 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
1707 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | 1703 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> |
1708 * </ul> | 1704 * </ul> |
1709 * | 1705 * |
1710 * @since 3.1 | 1706 * @since 3.1 |
1711 */ | 1707 */ |
1712 public void setText (int index, String string) { | 1708 public void setText (int index, String string) { |
1713 checkWidget (); | 1709 checkWidget (); |
1714 if (string is null) error (DWT.ERROR_NULL_ARGUMENT); | 1710 // DWT extension: allow null for zero length string |
1711 //if (string is null) error (DWT.ERROR_NULL_ARGUMENT); | |
1715 if (_getText (index).equals (string)) return; | 1712 if (_getText (index).equals (string)) return; |
1716 int count = Math.max (1, parent.getColumnCount ()); | 1713 int count = Math.max (1, parent.getColumnCount ()); |
1717 if (0 > index || index > count - 1) return; | 1714 if (0 > index || index > count - 1) return; |
1718 char* buffer = tango.stdc.stringz.toStringz(string); | 1715 char* buffer = toStringz(string); |
1719 int modelIndex = parent.columnCount is 0 ? Tree.FIRST_COLUMN : parent.columns [index].modelIndex; | 1716 int modelIndex = parent.columnCount is 0 ? Tree.FIRST_COLUMN : parent.columns [index].modelIndex; |
1720 OS.gtk_tree_store_set1 (parent.modelHandle, cast(GtkTreeIter*)handle, modelIndex + Tree.CELL_TEXT, buffer); | 1717 OS.gtk_tree_store_set1 (parent.modelHandle, cast(GtkTreeIter*)handle, modelIndex + Tree.CELL_TEXT, buffer); |
1721 /* | 1718 /* |
1722 * Bug in GTK. When using fixed-height-mode, | 1719 * Bug in GTK. When using fixed-height-mode, |
1723 * row changes do not cause the row to be repainted. The fix is to | 1720 * row changes do not cause the row to be repainted. The fix is to |
1739 /** | 1736 /** |
1740 * Sets the text for multiple columns in the tree. | 1737 * Sets the text for multiple columns in the tree. |
1741 * | 1738 * |
1742 * @param strings the array of new strings | 1739 * @param strings the array of new strings |
1743 * | 1740 * |
1744 * @exception IllegalArgumentException <ul> | |
1745 * <li>ERROR_NULL_ARGUMENT - if the text is null</li> | |
1746 * </ul> | |
1747 * @exception DWTException <ul> | 1741 * @exception DWTException <ul> |
1748 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | 1742 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
1749 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | 1743 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> |
1750 * </ul> | 1744 * </ul> |
1751 * | 1745 * |
1752 * @since 3.1 | 1746 * @since 3.1 |
1753 */ | 1747 */ |
1754 public void setText (String [] strings) { | 1748 public void setText (String [] strings) { |
1755 checkWidget (); | 1749 checkWidget (); |
1756 if (strings is null) error (DWT.ERROR_NULL_ARGUMENT); | 1750 // DWT extension: allow null for zero length string |
1751 //if (strings is null) error (DWT.ERROR_NULL_ARGUMENT); | |
1757 for (int i=0; i<strings.length; i++) { | 1752 for (int i=0; i<strings.length; i++) { |
1758 String string = strings [i]; | 1753 String string = strings [i]; |
1759 if (string !is null) setText (i, string); | 1754 if (string !is null) setText (i, string); |
1760 } | 1755 } |
1761 } | 1756 } |