comparison org.eclipse.swt.win32.win32.x86/src/org/eclipse/swt/widgets/Item.d @ 0:6dd524f61e62

add dwt win and basic java stuff
author Frank Benoit <benoit@tionex.de>
date Mon, 02 Mar 2009 14:44:16 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:6dd524f61e62
1 /*******************************************************************************
2 * Copyright (c) 2000, 2008 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
10 * Port to the D programming language:
11 * Frank Benoit <benoit@tionex.de>
12 *******************************************************************************/
13 module org.eclipse.swt.widgets.Item;
14
15
16 import org.eclipse.swt.widgets.Widget;
17 import org.eclipse.swt.SWT;
18 import org.eclipse.swt.graphics.Image;
19 import java.lang.all;
20
21 /**
22 * This class is the abstract superclass of all non-windowed
23 * user interface objects that occur within specific controls.
24 * For example, a tree will contain tree items.
25 * <dl>
26 * <dt><b>Styles:</b></dt>
27 * <dd>(none)</dd>
28 * <dt><b>Events:</b></dt>
29 * <dd>(none)</dd>
30 * </dl>
31 *
32 * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
33 */
34
35 public abstract class Item : Widget {
36 String text;
37 Image image;
38
39 /**
40 * Constructs a new instance of this class given its parent
41 * and a style value describing its behavior and appearance.
42 * The item is added to the end of the items maintained by its parent.
43 * <p>
44 * The style value is either one of the style constants defined in
45 * class <code>SWT</code> which is applicable to instances of this
46 * class, or must be built by <em>bitwise OR</em>'ing together
47 * (that is, using the <code>int</code> "|" operator) two or more
48 * of those <code>SWT</code> style constants. The class description
49 * lists the style constants that are applicable to the class.
50 * Style bits are also inherited from superclasses.
51 * </p>
52 *
53 * @param parent a widget which will be the parent of the new instance (cannot be null)
54 * @param style the style of item to construct
55 *
56 * @exception IllegalArgumentException <ul>
57 * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
58 * </ul>
59 * @exception SWTException <ul>
60 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
61 * </ul>
62 *
63 * @see SWT
64 * @see Widget#getStyle
65 */
66 public this (Widget parent, int style) {
67 super (parent, style);
68 text = "";
69 }
70
71 /**
72 * Constructs a new instance of this class given its parent
73 * and a style value describing its behavior and appearance,
74 * and the index at which to place it in the items maintained
75 * by its parent.
76 * <p>
77 * The style value is either one of the style constants defined in
78 * class <code>SWT</code> which is applicable to instances of this
79 * class, or must be built by <em>bitwise OR</em>'ing together
80 * (that is, using the <code>int</code> "|" operator) two or more
81 * of those <code>SWT</code> style constants. The class description
82 * lists the style constants that are applicable to the class.
83 * Style bits are also inherited from superclasses.
84 * </p>
85 *
86 * @param parent a widget which will be the parent of the new instance (cannot be null)
87 * @param style the style of item to construct
88 * @param index the zero-relative index at which to store the receiver in its parent
89 *
90 * @exception IllegalArgumentException <ul>
91 * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
92 * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the parent (inclusive)</li>
93 * </ul>
94 * @exception SWTException <ul>
95 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
96 * </ul>
97 *
98 * @see SWT
99 * @see Widget#getStyle
100 */
101 public this (Widget parent, int style, int index) {
102 this (parent, style);
103 }
104
105 override protected void checkSubclass () {
106 /* Do Nothing - Subclassing is allowed */
107 }
108
109 /**
110 * Returns the receiver's image if it has one, or null
111 * if it does not.
112 *
113 * @return the receiver's image
114 *
115 * @exception SWTException <ul>
116 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
117 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
118 * </ul>
119 */
120 public Image getImage () {
121 checkWidget ();
122 return image;
123 }
124
125 override String getNameText () {
126 return getText ();
127 }
128
129 /**
130 * Returns the receiver's text, which will be an empty
131 * string if it has never been set.
132 *
133 * @return the receiver's text
134 *
135 * @exception SWTException <ul>
136 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
137 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
138 * </ul>
139 */
140 public String getText () {
141 checkWidget();
142 return text;
143 }
144
145 override void releaseWidget () {
146 super.releaseWidget ();
147 text = null;
148 image = null;
149 }
150
151 /**
152 * Sets the receiver's image to the argument, which may be
153 * null indicating that no image should be displayed.
154 *
155 * @param image the image to display on the receiver (may be null)
156 *
157 * @exception IllegalArgumentException <ul>
158 * <li>ERROR_INVALID_ARGUMENT - if the image has been disposed</li>
159 * </ul>
160 * @exception SWTException <ul>
161 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
162 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
163 * </ul>
164 */
165 public void setImage (Image image) {
166 checkWidget ();
167 if (image !is null && image.isDisposed()) error(SWT.ERROR_INVALID_ARGUMENT);
168 this.image = image;
169 }
170
171 /**
172 * Sets the receiver's text.
173 *
174 * @param string the new text
175 *
176 * @exception SWTException <ul>
177 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
178 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
179 * </ul>
180 */
181 public void setText (String string) {
182 checkWidget ();
183 // SWT extension: allow null string
184 //if (string is null) error (SWT.ERROR_NULL_ARGUMENT);
185 text = string;
186 }
187
188 }