Mercurial > projects > dwt-linux
annotate dwt/widgets/Item.d @ 238:380bad9f6852
reverted char[] to String
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Mon, 05 May 2008 00:42:55 +0200 |
parents | de2578a843a7 |
children | 5a30aa9820f3 |
rev | line source |
---|---|
72 | 1 /******************************************************************************* |
47 | 2 * Copyright (c) 2000, 2006 IBM Corporation and others. |
3 * All rights reserved. This program and the accompanying materials | |
4 * are made available under the terms of the Eclipse Public License v1.0 | |
5 * which accompanies this distribution, and is available at | |
6 * http://www.eclipse.org/legal/epl-v10.html | |
7 * | |
8 * Contributors: | |
9 * IBM Corporation - initial API and implementation | |
72 | 10 * Port to the D programming language: |
11 * Frank Benoit <benoit@tionex.de> | |
47 | 12 *******************************************************************************/ |
13 module dwt.widgets.Item; | |
14 | |
238 | 15 import dwt.dwthelper.utils; |
16 | |
47 | 17 |
18 import dwt.widgets.Widget; | |
71 | 19 import dwt.DWT; |
47 | 20 import dwt.graphics.Image; |
21 | |
22 /** | |
23 * This class is the abstract superclass of all non-windowed | |
24 * user interface objects that occur within specific controls. | |
25 * For example, a tree will contain tree items. | |
26 * <dl> | |
27 * <dt><b>Styles:</b></dt> | |
28 * <dd>(none)</dd> | |
29 * <dt><b>Events:</b></dt> | |
30 * <dd>(none)</dd> | |
31 * </dl> | |
32 */ | |
33 | |
34 public abstract class Item : Widget { | |
238 | 35 String text; |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
47
diff
changeset
|
36 Image image; |
47 | 37 |
38 /** | |
39 * Constructs a new instance of this class given its parent | |
40 * and a style value describing its behavior and appearance. | |
41 * The item is added to the end of the items maintained by its parent. | |
42 * <p> | |
43 * The style value is either one of the style constants defined in | |
71 | 44 * class <code>DWT</code> which is applicable to instances of this |
47 | 45 * class, or must be built by <em>bitwise OR</em>'ing together |
46 * (that is, using the <code>int</code> "|" operator) two or more | |
71 | 47 * of those <code>DWT</code> style constants. The class description |
47 | 48 * lists the style constants that are applicable to the class. |
49 * Style bits are also inherited from superclasses. | |
50 * </p> | |
51 * | |
52 * @param parent a widget which will be the parent of the new instance (cannot be null) | |
53 * @param style the style of item to construct | |
54 * | |
55 * @exception IllegalArgumentException <ul> | |
56 * <li>ERROR_NULL_ARGUMENT - if the parent is null</li> | |
57 * </ul> | |
71 | 58 * @exception DWTException <ul> |
47 | 59 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li> |
60 * </ul> | |
61 * | |
71 | 62 * @see DWT |
47 | 63 * @see Widget#getStyle |
64 */ | |
65 public this (Widget parent, int style) { | |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
47
diff
changeset
|
66 super (parent, style); |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
47
diff
changeset
|
67 text = ""; |
47 | 68 } |
69 | |
70 /** | |
71 * Constructs a new instance of this class given its parent | |
72 * and a style value describing its behavior and appearance, | |
73 * and the index at which to place it in the items maintained | |
74 * by its parent. | |
75 * <p> | |
76 * The style value is either one of the style constants defined in | |
71 | 77 * class <code>DWT</code> which is applicable to instances of this |
47 | 78 * class, or must be built by <em>bitwise OR</em>'ing together |
79 * (that is, using the <code>int</code> "|" operator) two or more | |
71 | 80 * of those <code>DWT</code> style constants. The class description |
47 | 81 * lists the style constants that are applicable to the class. |
82 * Style bits are also inherited from superclasses. | |
83 * </p> | |
84 * | |
85 * @param parent a widget which will be the parent of the new instance (cannot be null) | |
86 * @param style the style of item to construct | |
87 * @param index the zero-relative index at which to store the receiver in its parent | |
88 * | |
89 * @exception IllegalArgumentException <ul> | |
90 * <li>ERROR_NULL_ARGUMENT - if the parent is null</li> | |
91 * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the parent (inclusive)</li> | |
92 * </ul> | |
71 | 93 * @exception DWTException <ul> |
47 | 94 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li> |
95 * </ul> | |
96 * | |
71 | 97 * @see DWT |
47 | 98 * @see Widget#getStyle |
99 */ | |
100 public this (Widget parent, int style, int index) { | |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
47
diff
changeset
|
101 this (parent, style); |
47 | 102 } |
103 | |
152
17f8449522fd
overloads second walkthrough
Frank Benoit <benoit@tionex.de>
parents:
72
diff
changeset
|
104 protected override void checkSubclass () { |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
47
diff
changeset
|
105 /* Do Nothing - Subclassing is allowed */ |
47 | 106 } |
107 | |
108 /** | |
109 * Returns the receiver's image if it has one, or null | |
110 * if it does not. | |
111 * | |
112 * @return the receiver's image | |
113 * | |
71 | 114 * @exception DWTException <ul> |
47 | 115 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
116 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
117 * </ul> | |
118 */ | |
119 public Image getImage () { | |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
47
diff
changeset
|
120 checkWidget (); |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
47
diff
changeset
|
121 return image; |
47 | 122 } |
123 | |
238 | 124 override String getNameText () { |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
47
diff
changeset
|
125 return getText (); |
47 | 126 } |
127 | |
128 /** | |
129 * Returns the receiver's text, which will be an empty | |
130 * string if it has never been set. | |
131 * | |
132 * @return the receiver's text | |
133 * | |
71 | 134 * @exception DWTException <ul> |
47 | 135 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
136 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
137 * </ul> | |
138 */ | |
238 | 139 public String getText () { |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
47
diff
changeset
|
140 checkWidget(); |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
47
diff
changeset
|
141 return text; |
47 | 142 } |
143 | |
152
17f8449522fd
overloads second walkthrough
Frank Benoit <benoit@tionex.de>
parents:
72
diff
changeset
|
144 override void releaseWidget () { |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
47
diff
changeset
|
145 super.releaseWidget (); |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
47
diff
changeset
|
146 text = null; |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
47
diff
changeset
|
147 image = null; |
47 | 148 } |
149 | |
150 /** | |
151 * Sets the receiver's image to the argument, which may be | |
152 * null indicating that no image should be displayed. | |
153 * | |
154 * @param image the image to display on the receiver (may be null) | |
155 * | |
156 * @exception IllegalArgumentException <ul> | |
157 * <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li> | |
158 * </ul> | |
71 | 159 * @exception DWTException <ul> |
47 | 160 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
161 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
162 * </ul> | |
163 */ | |
164 public void setImage (Image image) { | |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
47
diff
changeset
|
165 checkWidget (); |
71 | 166 if (image !is null && image.isDisposed()) error(DWT.ERROR_INVALID_ARGUMENT); |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
47
diff
changeset
|
167 this.image = image; |
47 | 168 } |
169 | |
170 /** | |
171 * Sets the receiver's text. | |
172 * | |
173 * @param string the new text | |
174 * | |
175 * @exception IllegalArgumentException <ul> | |
176 * <li>ERROR_NULL_ARGUMENT - if the text is null</li> | |
177 * </ul> | |
71 | 178 * @exception DWTException <ul> |
47 | 179 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
180 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | |
181 * </ul> | |
182 */ | |
238 | 183 public void setText (String string) { |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
47
diff
changeset
|
184 checkWidget (); |
71 | 185 if (string is null) error (DWT.ERROR_NULL_ARGUMENT); |
158
de2578a843a7
Tango update to rev 3158, TracedException>Exception, fromUtf8z>fromStringz,Fix Bug in MenuItem Thanx to nascent for the report.
Frank Benoit <benoit@tionex.de>
parents:
152
diff
changeset
|
186 text = string.dup; |
47 | 187 } |
188 | |
189 } |