Mercurial > projects > dwt-linux
comparison dwt/custom/PopupList.d @ 238:380bad9f6852
reverted char[] to String
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Mon, 05 May 2008 00:42:55 +0200 |
parents | 0f12f6bb9739 |
children | 5a30aa9820f3 |
comparison
equal
deleted
inserted
replaced
237:98b80b00af79 | 238:380bad9f6852 |
---|---|
9 * IBM Corporation - initial API and implementation | 9 * IBM Corporation - initial API and implementation |
10 * Port to the D programming language: | 10 * Port to the D programming language: |
11 * Frank Benoit <benoit@tionex.de> | 11 * Frank Benoit <benoit@tionex.de> |
12 *******************************************************************************/ | 12 *******************************************************************************/ |
13 module dwt.custom.PopupList; | 13 module dwt.custom.PopupList; |
14 | |
15 import dwt.dwthelper.utils; | |
14 | 16 |
15 | 17 |
16 import dwt.DWT; | 18 import dwt.DWT; |
17 import dwt.DWTException; | 19 import dwt.DWTException; |
18 import dwt.events.ControlEvent; | 20 import dwt.events.ControlEvent; |
125 * @exception DWTException <ul> | 127 * @exception DWTException <ul> |
126 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | 128 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
127 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | 129 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> |
128 * </ul> | 130 * </ul> |
129 */ | 131 */ |
130 public char[][] getItems () { | 132 public String[] getItems () { |
131 return list.getItems(); | 133 return list.getItems(); |
132 } | 134 } |
133 /** | 135 /** |
134 * Gets the minimum width of the list. | 136 * Gets the minimum width of the list. |
135 * | 137 * |
144 * @param rect the initial size and location of the PopupList; the dialog will be | 146 * @param rect the initial size and location of the PopupList; the dialog will be |
145 * positioned so that it does not run off the screen and the largest number of items are visible | 147 * positioned so that it does not run off the screen and the largest number of items are visible |
146 * | 148 * |
147 * @return the text of the selected item or null if no item is selected | 149 * @return the text of the selected item or null if no item is selected |
148 */ | 150 */ |
149 public char[] open (Rectangle rect) { | 151 public String open (Rectangle rect) { |
150 | 152 |
151 Point listSize = list.computeSize (rect.width, DWT.DEFAULT, false); | 153 Point listSize = list.computeSize (rect.width, DWT.DEFAULT, false); |
152 Rectangle screenSize = shell.getDisplay().getBounds(); | 154 Rectangle screenSize = shell.getDisplay().getBounds(); |
153 | 155 |
154 // Position the dialog so that it does not run off the screen and the largest number of items are visible | 156 // Position the dialog so that it does not run off the screen and the largest number of items are visible |
192 Display display = shell.getDisplay(); | 194 Display display = shell.getDisplay(); |
193 while (!shell.isDisposed () && shell.isVisible ()) { | 195 while (!shell.isDisposed () && shell.isVisible ()) { |
194 if (!display.readAndDispatch()) display.sleep(); | 196 if (!display.readAndDispatch()) display.sleep(); |
195 } | 197 } |
196 | 198 |
197 char[] result = null; | 199 String result = null; |
198 if (!shell.isDisposed ()) { | 200 if (!shell.isDisposed ()) { |
199 char[] [] strings = list.getSelection (); | 201 String [] strings = list.getSelection (); |
200 shell.dispose(); | 202 shell.dispose(); |
201 if (strings.length !is 0) result = strings [0]; | 203 if (strings.length !is 0) result = strings [0]; |
202 } | 204 } |
203 return result; | 205 return result; |
204 } | 206 } |
205 /** | 207 /** |
206 * Selects an item with text that starts with specified char[]. | 208 * Selects an item with text that starts with specified String. |
207 * <p> | 209 * <p> |
208 * If the item is not currently selected, it is selected. | 210 * If the item is not currently selected, it is selected. |
209 * If the item at an index is selected, it remains selected. | 211 * If the item at an index is selected, it remains selected. |
210 * If the string is not matched, it is ignored. | 212 * If the string is not matched, it is ignored. |
211 * | 213 * |
214 * @exception DWTException <ul> | 216 * @exception DWTException <ul> |
215 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | 217 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
216 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | 218 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> |
217 * </ul> | 219 * </ul> |
218 */ | 220 */ |
219 public void select(char[] string) { | 221 public void select(String string) { |
220 char[][] items = list.getItems(); | 222 String[] items = list.getItems(); |
221 | 223 |
222 // find the first entry in the list that starts with the | 224 // find the first entry in the list that starts with the |
223 // specified string | 225 // specified string |
224 if (string !is null){ | 226 if (string !is null){ |
225 for (int i = 0; i < items.length; i++) { | 227 for (int i = 0; i < items.length; i++) { |
267 * @exception DWTException <ul> | 269 * @exception DWTException <ul> |
268 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | 270 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
269 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | 271 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> |
270 * </ul> | 272 * </ul> |
271 */ | 273 */ |
272 public void setItems (char[][] strings) { | 274 public void setItems (String[] strings) { |
273 list.setItems(strings); | 275 list.setItems(strings); |
274 } | 276 } |
275 /** | 277 /** |
276 * Sets the minimum width of the list. | 278 * Sets the minimum width of the list. |
277 * | 279 * |