108
|
1 /*******************************************************************************
|
100
|
2 * Copyright (c) 2000, 2007 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
|
108
|
10 * Port to the D programming language:
|
|
11 * Frank Benoit <benoit@tionex.de>
|
100
|
12 *******************************************************************************/
|
|
13 module dwt.custom.CCombo;
|
|
14
|
|
15
|
|
16
|
|
17 import dwt.DWT;
|
|
18 import dwt.DWTException;
|
|
19 import dwt.accessibility.ACC;
|
|
20 import dwt.accessibility.AccessibleAdapter;
|
|
21 import dwt.accessibility.AccessibleControlAdapter;
|
|
22 import dwt.accessibility.AccessibleControlEvent;
|
|
23 import dwt.accessibility.AccessibleEvent;
|
|
24 import dwt.accessibility.AccessibleTextAdapter;
|
|
25 import dwt.accessibility.AccessibleTextEvent;
|
|
26 import dwt.events.ModifyListener;
|
|
27 import dwt.events.SelectionEvent;
|
|
28 import dwt.events.SelectionListener;
|
|
29 import dwt.events.VerifyListener;
|
|
30 import dwt.graphics.Color;
|
|
31 import dwt.graphics.Font;
|
|
32 import dwt.graphics.GC;
|
|
33 import dwt.graphics.Point;
|
|
34 import dwt.graphics.Rectangle;
|
|
35 import dwt.widgets.Button;
|
|
36 import dwt.widgets.Composite;
|
|
37 import dwt.widgets.Control;
|
|
38 import dwt.widgets.Display;
|
|
39 import dwt.widgets.Event;
|
|
40 import dwt.widgets.Label;
|
|
41 import dwt.widgets.Layout;
|
|
42 import dwt.widgets.List;
|
|
43 import dwt.widgets.Listener;
|
|
44 import dwt.widgets.Menu;
|
|
45 import dwt.widgets.Shell;
|
|
46 import dwt.widgets.Text;
|
|
47 import dwt.widgets.TypedListener;
|
|
48 import dwt.widgets.Widget;
|
|
49
|
|
50 static import tango.text.convert.Utf;
|
|
51 static import tango.text.Unicode;
|
|
52 static import tango.text.convert.Format;
|
|
53
|
|
54 /**
|
|
55 * The CCombo class represents a selectable user interface object
|
|
56 * that combines a text field and a list and issues notification
|
|
57 * when an item is selected from the list.
|
|
58 * <p>
|
|
59 * CCombo was written to work around certain limitations in the native
|
|
60 * combo box. Specifically, on win32, the height of a CCombo can be set;
|
|
61 * attempts to set the height of a Combo are ignored. CCombo can be used
|
|
62 * anywhere that having the increased flexibility is more important than
|
|
63 * getting native L&F, but the decision should not be taken lightly.
|
|
64 * There is no is no strict requirement that CCombo look or behave
|
|
65 * the same as the native combo box.
|
|
66 * </p>
|
|
67 * <p>
|
|
68 * Note that although this class is a subclass of <code>Composite</code>,
|
|
69 * it does not make sense to add children to it, or set a layout on it.
|
|
70 * </p>
|
|
71 * <dl>
|
|
72 * <dt><b>Styles:</b>
|
|
73 * <dd>BORDER, READ_ONLY, FLAT</dd>
|
|
74 * <dt><b>Events:</b>
|
|
75 * <dd>DefaultSelection, Modify, Selection, Verify</dd>
|
|
76 * </dl>
|
|
77 */
|
|
78 public final class CCombo : Composite {
|
|
79
|
|
80 Text text;
|
|
81 List list;
|
|
82 int visibleItemCount = 5;
|
|
83 Shell popup;
|
|
84 Button arrow;
|
|
85 bool hasFocus;
|
|
86 Listener listener, filter;
|
|
87 Color foreground, background;
|
|
88 Font font;
|
|
89
|
|
90 /**
|
|
91 * Constructs a new instance of this class given its parent
|
|
92 * and a style value describing its behavior and appearance.
|
|
93 * <p>
|
|
94 * The style value is either one of the style constants defined in
|
|
95 * class <code>DWT</code> which is applicable to instances of this
|
|
96 * class, or must be built by <em>bitwise OR</em>'ing together
|
|
97 * (that is, using the <code>int</code> "|" operator) two or more
|
|
98 * of those <code>DWT</code> style constants. The class description
|
|
99 * lists the style constants that are applicable to the class.
|
|
100 * Style bits are also inherited from superclasses.
|
|
101 * </p>
|
|
102 *
|
|
103 * @param parent a widget which will be the parent of the new instance (cannot be null)
|
|
104 * @param style the style of widget to construct
|
|
105 *
|
|
106 * @exception IllegalArgumentException <ul>
|
|
107 * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
|
|
108 * </ul>
|
|
109 * @exception DWTException <ul>
|
|
110 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
|
|
111 * </ul>
|
|
112 *
|
|
113 * @see DWT#BORDER
|
|
114 * @see DWT#READ_ONLY
|
|
115 * @see DWT#FLAT
|
|
116 * @see Widget#getStyle()
|
|
117 */
|
|
118 public this (Composite parent, int style) {
|
|
119 super (parent, style = checkStyle (style));
|
|
120
|
|
121 int textStyle = DWT.SINGLE;
|
|
122 if ((style & DWT.READ_ONLY) !is 0) textStyle |= DWT.READ_ONLY;
|
|
123 if ((style & DWT.FLAT) !is 0) textStyle |= DWT.FLAT;
|
|
124 text = new Text (this, textStyle);
|
|
125 int arrowStyle = DWT.ARROW | DWT.DOWN;
|
|
126 if ((style & DWT.FLAT) !is 0) arrowStyle |= DWT.FLAT;
|
|
127 arrow = new Button (this, arrowStyle);
|
|
128
|
|
129 listener = new class() Listener {
|
|
130 public void handleEvent (Event event) {
|
|
131 if (popup is event.widget) {
|
|
132 popupEvent (event);
|
|
133 return;
|
|
134 }
|
|
135 if (text is event.widget) {
|
|
136 textEvent (event);
|
|
137 return;
|
|
138 }
|
|
139 if (list is event.widget) {
|
|
140 listEvent (event);
|
|
141 return;
|
|
142 }
|
|
143 if (arrow is event.widget) {
|
|
144 arrowEvent (event);
|
|
145 return;
|
|
146 }
|
|
147 if (this.outer is event.widget) {
|
|
148 comboEvent (event);
|
|
149 return;
|
|
150 }
|
|
151 if (getShell () is event.widget) {
|
|
152 handleFocus (DWT.FocusOut);
|
|
153 }
|
|
154 }
|
|
155 };
|
|
156 filter = new class() Listener {
|
|
157 public void handleEvent(Event event) {
|
|
158 Shell shell = (cast(Control)event.widget).getShell ();
|
|
159 if (shell is this.outer.getShell ()) {
|
|
160 handleFocus (DWT.FocusOut);
|
|
161 }
|
|
162 }
|
|
163 };
|
|
164
|
|
165 int [] comboEvents = [DWT.Dispose, DWT.Move, DWT.Resize];
|
|
166 for (int i=0; i<comboEvents.length; i++) this.addListener (comboEvents [i], listener);
|
|
167
|
|
168 int [] textEvents = [DWT.KeyDown, DWT.KeyUp, DWT.MenuDetect, DWT.Modify, DWT.MouseDown, DWT.MouseUp, DWT.Traverse, DWT.FocusIn, DWT.Verify];
|
|
169 for (int i=0; i<textEvents.length; i++) text.addListener (textEvents [i], listener);
|
|
170
|
|
171 int [] arrowEvents = [DWT.Selection, DWT.FocusIn];
|
|
172 for (int i=0; i<arrowEvents.length; i++) arrow.addListener (arrowEvents [i], listener);
|
|
173
|
|
174 createPopup(null, -1);
|
|
175 initAccessible();
|
|
176 }
|
|
177 static int checkStyle (int style) {
|
|
178 int mask = DWT.BORDER | DWT.READ_ONLY | DWT.FLAT | DWT.LEFT_TO_RIGHT | DWT.RIGHT_TO_LEFT;
|
|
179 return style & mask;
|
|
180 }
|
|
181 /**
|
|
182 * Adds the argument to the end of the receiver's list.
|
|
183 *
|
|
184 * @param string the new item
|
|
185 *
|
|
186 * @exception IllegalArgumentException <ul>
|
|
187 * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
|
|
188 * </ul>
|
|
189 * @exception DWTException <ul>
|
|
190 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
|
|
191 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
|
|
192 * </ul>
|
|
193 *
|
|
194 * @see #add(String,int)
|
|
195 */
|
|
196 public void add (char[] string) {
|
|
197 checkWidget();
|
|
198 if (string is null) DWT.error (DWT.ERROR_NULL_ARGUMENT);
|
|
199 list.add (string);
|
|
200 }
|
|
201 /**
|
|
202 * Adds the argument to the receiver's list at the given
|
|
203 * zero-relative index.
|
|
204 * <p>
|
|
205 * Note: To add an item at the end of the list, use the
|
|
206 * result of calling <code>getItemCount()</code> as the
|
|
207 * index or use <code>add(String)</code>.
|
|
208 * </p>
|
|
209 *
|
|
210 * @param string the new item
|
|
211 * @param index the index for the item
|
|
212 *
|
|
213 * @exception IllegalArgumentException <ul>
|
|
214 * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
|
|
215 * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list (inclusive)</li>
|
|
216 * </ul>
|
|
217 * @exception DWTException <ul>
|
|
218 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
|
|
219 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
|
|
220 * </ul>
|
|
221 *
|
|
222 * @see #add(String)
|
|
223 */
|
|
224 public void add (char[] string, int index) {
|
|
225 checkWidget();
|
|
226 if (string is null) DWT.error (DWT.ERROR_NULL_ARGUMENT);
|
|
227 list.add (string, index);
|
|
228 }
|
|
229 /**
|
|
230 * Adds the listener to the collection of listeners who will
|
|
231 * be notified when the receiver's text is modified, by sending
|
|
232 * it one of the messages defined in the <code>ModifyListener</code>
|
|
233 * interface.
|
|
234 *
|
|
235 * @param listener the listener which should be notified
|
|
236 *
|
|
237 * @exception IllegalArgumentException <ul>
|
|
238 * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
|
|
239 * </ul>
|
|
240 * @exception DWTException <ul>
|
|
241 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
|
|
242 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
|
|
243 * </ul>
|
|
244 *
|
|
245 * @see ModifyListener
|
|
246 * @see #removeModifyListener
|
|
247 */
|
|
248 public void addModifyListener (ModifyListener listener) {
|
|
249 checkWidget();
|
|
250 if (listener is null) DWT.error (DWT.ERROR_NULL_ARGUMENT);
|
|
251 TypedListener typedListener = new TypedListener (listener);
|
|
252 addListener (DWT.Modify, typedListener);
|
|
253 }
|
|
254 /**
|
|
255 * Adds the listener to the collection of listeners who will
|
|
256 * be notified when the user changes the receiver's selection, by sending
|
|
257 * it one of the messages defined in the <code>SelectionListener</code>
|
|
258 * interface.
|
|
259 * <p>
|
|
260 * <code>widgetSelected</code> is called when the combo's list selection changes.
|
|
261 * <code>widgetDefaultSelected</code> is typically called when ENTER is pressed the combo's text area.
|
|
262 * </p>
|
|
263 *
|
|
264 * @param listener the listener which should be notified when the user changes the receiver's selection
|
|
265 *
|
|
266 * @exception IllegalArgumentException <ul>
|
|
267 * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
|
|
268 * </ul>
|
|
269 * @exception DWTException <ul>
|
|
270 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
|
|
271 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
|
|
272 * </ul>
|
|
273 *
|
|
274 * @see SelectionListener
|
|
275 * @see #removeSelectionListener
|
|
276 * @see SelectionEvent
|
|
277 */
|
|
278 public void addSelectionListener(SelectionListener listener) {
|
|
279 checkWidget();
|
|
280 if (listener is null) DWT.error (DWT.ERROR_NULL_ARGUMENT);
|
|
281 TypedListener typedListener = new TypedListener (listener);
|
|
282 addListener (DWT.Selection,typedListener);
|
|
283 addListener (DWT.DefaultSelection,typedListener);
|
|
284 }
|
|
285 /**
|
|
286 * Adds the listener to the collection of listeners who will
|
|
287 * be notified when the receiver's text is verified, by sending
|
|
288 * it one of the messages defined in the <code>VerifyListener</code>
|
|
289 * interface.
|
|
290 *
|
|
291 * @param listener the listener which should be notified
|
|
292 *
|
|
293 * @exception IllegalArgumentException <ul>
|
|
294 * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
|
|
295 * </ul>
|
|
296 * @exception DWTException <ul>
|
|
297 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
|
|
298 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
|
|
299 * </ul>
|
|
300 *
|
|
301 * @see VerifyListener
|
|
302 * @see #removeVerifyListener
|
|
303 *
|
|
304 * @since 3.3
|
|
305 */
|
|
306 public void addVerifyListener (VerifyListener listener) {
|
|
307 checkWidget();
|
|
308 if (listener is null) DWT.error (DWT.ERROR_NULL_ARGUMENT);
|
|
309 TypedListener typedListener = new TypedListener (listener);
|
|
310 addListener (DWT.Verify,typedListener);
|
|
311 }
|
|
312 void arrowEvent (Event event) {
|
|
313 switch (event.type) {
|
|
314 case DWT.FocusIn: {
|
|
315 handleFocus (DWT.FocusIn);
|
|
316 break;
|
|
317 }
|
|
318 case DWT.Selection: {
|
|
319 dropDown (!isDropped ());
|
|
320 break;
|
|
321 }
|
|
322 }
|
|
323 }
|
|
324 /**
|
|
325 * Sets the selection in the receiver's text field to an empty
|
|
326 * selection starting just before the first character. If the
|
|
327 * text field is editable, this has the effect of placing the
|
|
328 * i-beam at the start of the text.
|
|
329 * <p>
|
|
330 * Note: To clear the selected items in the receiver's list,
|
|
331 * use <code>deselectAll()</code>.
|
|
332 * </p>
|
|
333 *
|
|
334 * @exception DWTException <ul>
|
|
335 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
|
|
336 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
|
|
337 * </ul>
|
|
338 *
|
|
339 * @see #deselectAll
|
|
340 */
|
|
341 public void clearSelection () {
|
|
342 checkWidget ();
|
|
343 text.clearSelection ();
|
|
344 list.deselectAll ();
|
|
345 }
|
|
346 void comboEvent (Event event) {
|
|
347 switch (event.type) {
|
|
348 case DWT.Dispose:
|
|
349 if (popup !is null && !popup.isDisposed ()) {
|
|
350 list.removeListener (DWT.Dispose, listener);
|
|
351 popup.dispose ();
|
|
352 }
|
|
353 Shell shell = getShell ();
|
|
354 shell.removeListener (DWT.Deactivate, listener);
|
|
355 Display display = getDisplay ();
|
|
356 display.removeFilter (DWT.FocusIn, filter);
|
|
357 popup = null;
|
|
358 text = null;
|
|
359 list = null;
|
|
360 arrow = null;
|
|
361 break;
|
|
362 case DWT.Move:
|
|
363 dropDown (false);
|
|
364 break;
|
|
365 case DWT.Resize:
|
|
366 internalLayout (false);
|
|
367 break;
|
|
368 }
|
|
369 }
|
|
370
|
|
371 public Point computeSize (int wHint, int hHint, bool changed) {
|
|
372 checkWidget ();
|
|
373 int width = 0, height = 0;
|
|
374 char[][] items = list.getItems ();
|
|
375 GC gc = new GC (text);
|
|
376 int spacer = gc.stringExtent (" ").x; //$NON-NLS-1$
|
|
377 int textWidth = gc.stringExtent (text.getText ()).x;
|
|
378 for (int i = 0; i < items.length; i++) {
|
|
379 textWidth = Math.max (gc.stringExtent (items[i]).x, textWidth);
|
|
380 }
|
|
381 gc.dispose ();
|
|
382 Point textSize = text.computeSize (DWT.DEFAULT, DWT.DEFAULT, changed);
|
|
383 Point arrowSize = arrow.computeSize (DWT.DEFAULT, DWT.DEFAULT, changed);
|
|
384 Point listSize = list.computeSize (DWT.DEFAULT, DWT.DEFAULT, changed);
|
|
385 int borderWidth = getBorderWidth ();
|
|
386
|
|
387 height = Math.max (textSize.y, arrowSize.y);
|
|
388 width = Math.max (textWidth + 2*spacer + arrowSize.x + 2*borderWidth, listSize.x);
|
|
389 if (wHint !is DWT.DEFAULT) width = wHint;
|
|
390 if (hHint !is DWT.DEFAULT) height = hHint;
|
|
391 return new Point (width + 2*borderWidth, height + 2*borderWidth);
|
|
392 }
|
|
393 /**
|
|
394 * Copies the selected text.
|
|
395 * <p>
|
|
396 * The current selection is copied to the clipboard.
|
|
397 * </p>
|
|
398 *
|
|
399 * @exception DWTException <ul>
|
|
400 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
|
|
401 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
|
|
402 * </ul>
|
|
403 *
|
|
404 * @since 3.3
|
|
405 */
|
|
406 public void copy () {
|
|
407 checkWidget ();
|
|
408 text.copy ();
|
|
409 }
|
|
410 void createPopup(char[][] items, int selectionIndex) {
|
|
411 // create shell and list
|
|
412 popup = new Shell (getShell (), DWT.NO_TRIM | DWT.ON_TOP);
|
|
413 int style = getStyle ();
|
|
414 int listStyle = DWT.SINGLE | DWT.V_SCROLL;
|
|
415 if ((style & DWT.FLAT) !is 0) listStyle |= DWT.FLAT;
|
|
416 if ((style & DWT.RIGHT_TO_LEFT) !is 0) listStyle |= DWT.RIGHT_TO_LEFT;
|
|
417 if ((style & DWT.LEFT_TO_RIGHT) !is 0) listStyle |= DWT.LEFT_TO_RIGHT;
|
|
418 list = new List (popup, listStyle);
|
|
419 if (font !is null) list.setFont (font);
|
|
420 if (foreground !is null) list.setForeground (foreground);
|
|
421 if (background !is null) list.setBackground (background);
|
|
422
|
|
423 int [] popupEvents = [DWT.Close, DWT.Paint, DWT.Deactivate];
|
|
424 for (int i=0; i<popupEvents.length; i++) popup.addListener (popupEvents [i], listener);
|
|
425 int [] listEvents = [DWT.MouseUp, DWT.Selection, DWT.Traverse, DWT.KeyDown, DWT.KeyUp, DWT.FocusIn, DWT.Dispose];
|
|
426 for (int i=0; i<listEvents.length; i++) list.addListener (listEvents [i], listener);
|
|
427
|
|
428 if (items !is null) list.setItems (items);
|
|
429 if (selectionIndex !is -1) list.setSelection (selectionIndex);
|
|
430 }
|
|
431 /**
|
|
432 * Cuts the selected text.
|
|
433 * <p>
|
|
434 * The current selection is first copied to the
|
|
435 * clipboard and then deleted from the widget.
|
|
436 * </p>
|
|
437 *
|
|
438 * @exception DWTException <ul>
|
|
439 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
|
|
440 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
|
|
441 * </ul>
|
|
442 *
|
|
443 * @since 3.3
|
|
444 */
|
|
445 public void cut () {
|
|
446 checkWidget ();
|
|
447 text.cut ();
|
|
448 }
|
|
449 /**
|
|
450 * Deselects the item at the given zero-relative index in the receiver's
|
|
451 * list. If the item at the index was already deselected, it remains
|
|
452 * deselected. Indices that are out of range are ignored.
|
|
453 *
|
|
454 * @param index the index of the item to deselect
|
|
455 *
|
|
456 * @exception DWTException <ul>
|
|
457 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
|
|
458 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
|
|
459 * </ul>
|
|
460 */
|
|
461 public void deselect (int index) {
|
|
462 checkWidget ();
|
|
463 list.deselect (index);
|
|
464 }
|
|
465 /**
|
|
466 * Deselects all selected items in the receiver's list.
|
|
467 * <p>
|
|
468 * Note: To clear the selection in the receiver's text field,
|
|
469 * use <code>clearSelection()</code>.
|
|
470 * </p>
|
|
471 *
|
|
472 * @exception DWTException <ul>
|
|
473 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
|
|
474 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
|
|
475 * </ul>
|
|
476 *
|
|
477 * @see #clearSelection
|
|
478 */
|
|
479 public void deselectAll () {
|
|
480 checkWidget ();
|
|
481 list.deselectAll ();
|
|
482 }
|
|
483 void dropDown (bool drop) {
|
|
484 if (drop is isDropped ()) return;
|
|
485 if (!drop) {
|
|
486 popup.setVisible (false);
|
|
487 if (!isDisposed ()&& arrow.isFocusControl()) {
|
|
488 text.setFocus();
|
|
489 }
|
|
490 return;
|
|
491 }
|
|
492
|
|
493 if (getShell() !is popup.getParent ()) {
|
|
494 char[][] items = list.getItems ();
|
|
495 int selectionIndex = list.getSelectionIndex ();
|
|
496 list.removeListener (DWT.Dispose, listener);
|
|
497 popup.dispose();
|
|
498 popup = null;
|
|
499 list = null;
|
|
500 createPopup (items, selectionIndex);
|
|
501 }
|
|
502
|
|
503 Point size = getSize ();
|
|
504 int itemCount = list.getItemCount ();
|
|
505 itemCount = (itemCount is 0) ? visibleItemCount : Math.min(visibleItemCount, itemCount);
|
|
506 int itemHeight = list.getItemHeight () * itemCount;
|
|
507 Point listSize = list.computeSize (DWT.DEFAULT, itemHeight, false);
|
|
508 list.setBounds (1, 1, Math.max (size.x - 2, listSize.x), listSize.y);
|
|
509
|
|
510 int index = list.getSelectionIndex ();
|
|
511 if (index !is -1) list.setTopIndex (index);
|
|
512 Display display = getDisplay ();
|
|
513 Rectangle listRect = list.getBounds ();
|
|
514 Rectangle parentRect = display.map (getParent (), null, getBounds ());
|
|
515 Point comboSize = getSize ();
|
|
516 Rectangle displayRect = getMonitor ().getClientArea ();
|
|
517 int width = Math.max (comboSize.x, listRect.width + 2);
|
|
518 int height = listRect.height + 2;
|
|
519 int x = parentRect.x;
|
|
520 int y = parentRect.y + comboSize.y;
|
|
521 if (y + height > displayRect.y + displayRect.height) y = parentRect.y - height;
|
|
522 if (x + width > displayRect.x + displayRect.width) x = displayRect.x + displayRect.width - listRect.width;
|
|
523 popup.setBounds (x, y, width, height);
|
|
524 popup.setVisible (true);
|
|
525 list.setFocus ();
|
|
526 }
|
|
527 /*
|
|
528 * Return the lowercase of the first non-'&' character following
|
|
529 * an '&' character in the given string. If there are no '&'
|
|
530 * characters in the given string, return '\0'.
|
|
531 */
|
|
532 dchar _findMnemonic (char[] string) {
|
|
533 if (string is null) return '\0';
|
|
534 int index = 0;
|
|
535 int length = string.length;
|
|
536 do {
|
|
537 while (index < length && string[index] !is '&') index++;
|
|
538 if (++index >= length) return '\0';
|
|
539 if (string[index] !is '&') {
|
|
540 dchar[1] d; uint ate;
|
|
541 auto d2 = tango.text.convert.Utf.toString32( string[ index .. Math.min( index +4, string.length )], d, &ate );
|
|
542 auto d3 = tango.text.Unicode.toLower( d2, d2 );
|
|
543 return d3[0];
|
|
544 }
|
|
545 index++;
|
|
546 } while (index < length);
|
|
547 return '\0';
|
|
548 }
|
|
549 /*
|
|
550 * Return the Label immediately preceding the receiver in the z-order,
|
|
551 * or null if none.
|
|
552 */
|
|
553 Label getAssociatedLabel () {
|
|
554 Control[] siblings = getParent ().getChildren ();
|
|
555 for (int i = 0; i < siblings.length; i++) {
|
|
556 if (siblings [i] is this) {
|
|
557 if (i > 0 && ( null !is cast(Label)siblings [i-1] )) {
|
|
558 return cast(Label) siblings [i-1];
|
|
559 }
|
|
560 }
|
|
561 }
|
|
562 return null;
|
|
563 }
|
|
564 public Control [] getChildren () {
|
|
565 checkWidget();
|
|
566 return new Control [0];
|
|
567 }
|
|
568 /**
|
|
569 * Gets the editable state.
|
|
570 *
|
|
571 * @return whether or not the receiver is editable
|
|
572 *
|
|
573 * @exception DWTException <ul>
|
|
574 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
|
|
575 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
|
|
576 * </ul>
|
|
577 *
|
|
578 * @since 3.0
|
|
579 */
|
|
580 public bool getEditable () {
|
|
581 checkWidget ();
|
|
582 return text.getEditable();
|
|
583 }
|
|
584 /**
|
|
585 * Returns the item at the given, zero-relative index in the
|
|
586 * receiver's list. Throws an exception if the index is out
|
|
587 * of range.
|
|
588 *
|
|
589 * @param index the index of the item to return
|
|
590 * @return the item at the given index
|
|
591 *
|
|
592 * @exception IllegalArgumentException <ul>
|
|
593 * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
|
|
594 * </ul>
|
|
595 * @exception DWTException <ul>
|
|
596 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
|
|
597 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
|
|
598 * </ul>
|
|
599 */
|
|
600 public char[] getItem (int index) {
|
|
601 checkWidget();
|
|
602 return list.getItem (index);
|
|
603 }
|
|
604 /**
|
|
605 * Returns the number of items contained in the receiver's list.
|
|
606 *
|
|
607 * @return the number of items
|
|
608 *
|
|
609 * @exception DWTException <ul>
|
|
610 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
|
|
611 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
|
|
612 * </ul>
|
|
613 */
|
|
614 public int getItemCount () {
|
|
615 checkWidget ();
|
|
616 return list.getItemCount ();
|
|
617 }
|
|
618 /**
|
|
619 * Returns the height of the area which would be used to
|
|
620 * display <em>one</em> of the items in the receiver's list.
|
|
621 *
|
|
622 * @return the height of one item
|
|
623 *
|
|
624 * @exception DWTException <ul>
|
|
625 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
|
|
626 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
|
|
627 * </ul>
|
|
628 */
|
|
629 public int getItemHeight () {
|
|
630 checkWidget ();
|
|
631 return list.getItemHeight ();
|
|
632 }
|
|
633 /**
|
|
634 * Returns an array of <code>String</code>s which are the items
|
|
635 * in the receiver's list.
|
|
636 * <p>
|
|
637 * Note: This is not the actual structure used by the receiver
|
|
638 * to maintain its list of items, so modifying the array will
|
|
639 * not affect the receiver.
|
|
640 * </p>
|
|
641 *
|
|
642 * @return the items in the receiver's list
|
|
643 *
|
|
644 * @exception DWTException <ul>
|
|
645 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
|
|
646 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
|
|
647 * </ul>
|
|
648 */
|
|
649 public char[] [] getItems () {
|
|
650 checkWidget ();
|
|
651 return list.getItems ();
|
|
652 }
|
|
653 public Menu getMenu() {
|
|
654 return text.getMenu();
|
|
655 }
|
|
656 /**
|
|
657 * Returns a <code>Point</code> whose x coordinate is the start
|
|
658 * of the selection in the receiver's text field, and whose y
|
|
659 * coordinate is the end of the selection. The returned values
|
|
660 * are zero-relative. An "empty" selection as indicated by
|
|
661 * the the x and y coordinates having the same value.
|
|
662 *
|
|
663 * @return a point representing the selection start and end
|
|
664 *
|
|
665 * @exception DWTException <ul>
|
|
666 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
|
|
667 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
|
|
668 * </ul>
|
|
669 */
|
|
670 public Point getSelection () {
|
|
671 checkWidget ();
|
|
672 return text.getSelection ();
|
|
673 }
|
|
674 /**
|
|
675 * Returns the zero-relative index of the item which is currently
|
|
676 * selected in the receiver's list, or -1 if no item is selected.
|
|
677 *
|
|
678 * @return the index of the selected item
|
|
679 *
|
|
680 * @exception DWTException <ul>
|
|
681 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
|
|
682 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
|
|
683 * </ul>
|
|
684 */
|
|
685 public int getSelectionIndex () {
|
|
686 checkWidget ();
|
|
687 return list.getSelectionIndex ();
|
|
688 }
|
|
689 public int getStyle () {
|
|
690 int style = super.getStyle ();
|
|
691 style &= ~DWT.READ_ONLY;
|
|
692 if (!text.getEditable()) style |= DWT.READ_ONLY;
|
|
693 return style;
|
|
694 }
|
|
695 /**
|
|
696 * Returns a string containing a copy of the contents of the
|
|
697 * receiver's text field.
|
|
698 *
|
|
699 * @return the receiver's text
|
|
700 *
|
|
701 * @exception DWTException <ul>
|
|
702 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
|
|
703 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
|
|
704 * </ul>
|
|
705 */
|
|
706 public char[] getText () {
|
|
707 checkWidget ();
|
|
708 return text.getText ();
|
|
709 }
|
|
710 /**
|
|
711 * Returns the height of the receivers's text field.
|
|
712 *
|
|
713 * @return the text height
|
|
714 *
|
|
715 * @exception DWTException <ul>
|
|
716 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
|
|
717 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
|
|
718 * </ul>
|
|
719 */
|
|
720 public int getTextHeight () {
|
|
721 checkWidget ();
|
|
722 return text.getLineHeight ();
|
|
723 }
|
|
724 /**
|
|
725 * Returns the maximum number of characters that the receiver's
|
|
726 * text field is capable of holding. If this has not been changed
|
|
727 * by <code>setTextLimit()</code>, it will be the constant
|
|
728 * <code>Combo.LIMIT</code>.
|
|
729 *
|
|
730 * @return the text limit
|
|
731 *
|
|
732 * @exception DWTException <ul>
|
|
733 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
|
|
734 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
|
|
735 * </ul>
|
|
736 */
|
|
737 public int getTextLimit () {
|
|
738 checkWidget ();
|
|
739 return text.getTextLimit ();
|
|
740 }
|
|
741 /**
|
|
742 * Gets the number of items that are visible in the drop
|
|
743 * down portion of the receiver's list.
|
|
744 *
|
|
745 * @return the number of items that are visible
|
|
746 *
|
|
747 * @exception DWTException <ul>
|
|
748 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
|
|
749 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
|
|
750 * </ul>
|
|
751 *
|
|
752 * @since 3.0
|
|
753 */
|
|
754 public int getVisibleItemCount () {
|
|
755 checkWidget ();
|
|
756 return visibleItemCount;
|
|
757 }
|
|
758 void handleFocus (int type) {
|
|
759 if (isDisposed ()) return;
|
|
760 switch (type) {
|
|
761 case DWT.FocusIn: {
|
|
762 if (hasFocus) return;
|
|
763 if (getEditable ()) text.selectAll ();
|
|
764 hasFocus = true;
|
|
765 Shell shell = getShell ();
|
|
766 shell.removeListener (DWT.Deactivate, listener);
|
|
767 shell.addListener (DWT.Deactivate, listener);
|
|
768 Display display = getDisplay ();
|
|
769 display.removeFilter (DWT.FocusIn, filter);
|
|
770 display.addFilter (DWT.FocusIn, filter);
|
|
771 Event e = new Event ();
|
|
772 notifyListeners (DWT.FocusIn, e);
|
|
773 break;
|
|
774 }
|
|
775 case DWT.FocusOut: {
|
|
776 if (!hasFocus) return;
|
|
777 Control focusControl = getDisplay ().getFocusControl ();
|
|
778 if (focusControl is arrow || focusControl is list || focusControl is text) return;
|
|
779 hasFocus = false;
|
|
780 Shell shell = getShell ();
|
|
781 shell.removeListener(DWT.Deactivate, listener);
|
|
782 Display display = getDisplay ();
|
|
783 display.removeFilter (DWT.FocusIn, filter);
|
|
784 Event e = new Event ();
|
|
785 notifyListeners (DWT.FocusOut, e);
|
|
786 break;
|
|
787 }
|
|
788 }
|
|
789 }
|
|
790 /**
|
|
791 * Searches the receiver's list starting at the first item
|
|
792 * (index 0) until an item is found that is equal to the
|
|
793 * argument, and returns the index of that item. If no item
|
|
794 * is found, returns -1.
|
|
795 *
|
|
796 * @param string the search item
|
|
797 * @return the index of the item
|
|
798 *
|
|
799 * @exception IllegalArgumentException <ul>
|
|
800 * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
|
|
801 * </ul>
|
|
802 * @exception DWTException <ul>
|
|
803 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
|
|
804 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
|
|
805 * </ul>
|
|
806 */
|
|
807 public int indexOf (char[] string) {
|
|
808 checkWidget ();
|
|
809 if (string is null) DWT.error (DWT.ERROR_NULL_ARGUMENT);
|
|
810 return list.indexOf (string);
|
|
811 }
|
|
812 /**
|
|
813 * Searches the receiver's list starting at the given,
|
|
814 * zero-relative index until an item is found that is equal
|
|
815 * to the argument, and returns the index of that item. If
|
|
816 * no item is found or the starting index is out of range,
|
|
817 * returns -1.
|
|
818 *
|
|
819 * @param string the search item
|
|
820 * @param start the zero-relative index at which to begin the search
|
|
821 * @return the index of the item
|
|
822 *
|
|
823 * @exception IllegalArgumentException <ul>
|
|
824 * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
|
|
825 * </ul>
|
|
826 * @exception DWTException <ul>
|
|
827 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
|
|
828 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
|
|
829 * </ul>
|
|
830 */
|
|
831 public int indexOf (char[] string, int start) {
|
|
832 checkWidget ();
|
|
833 if (string is null) DWT.error (DWT.ERROR_NULL_ARGUMENT);
|
|
834 return list.indexOf (string, start);
|
|
835 }
|
|
836
|
|
837 void initAccessible() {
|
|
838 AccessibleAdapter accessibleAdapter = new class() AccessibleAdapter {
|
|
839 public void getName (AccessibleEvent e) {
|
|
840 char[] name = null;
|
|
841 Label label = getAssociatedLabel ();
|
|
842 if (label !is null) {
|
|
843 name = stripMnemonic (label.getText());
|
|
844 }
|
|
845 e.result = name;
|
|
846 }
|
|
847 public void getKeyboardShortcut(AccessibleEvent e) {
|
|
848 char[] shortcut = null;
|
|
849 Label label = getAssociatedLabel ();
|
|
850 if (label !is null) {
|
|
851 char[] text = label.getText ();
|
|
852 if (text !is null) {
|
|
853 dchar mnemonic = _findMnemonic (text);
|
|
854 if (mnemonic !is '\0') {
|
|
855 shortcut = tango.text.convert.Format.Format( "Alt+{}", mnemonic ); //$NON-NLS-1$
|
|
856 }
|
|
857 }
|
|
858 }
|
|
859 e.result = shortcut;
|
|
860 }
|
|
861 public void getHelp (AccessibleEvent e) {
|
|
862 e.result = getToolTipText ();
|
|
863 }
|
|
864 };
|
|
865 getAccessible ().addAccessibleListener (accessibleAdapter);
|
|
866 text.getAccessible ().addAccessibleListener (accessibleAdapter);
|
|
867 list.getAccessible ().addAccessibleListener (accessibleAdapter);
|
|
868
|
|
869 arrow.getAccessible ().addAccessibleListener (new class() AccessibleAdapter {
|
|
870 public void getName (AccessibleEvent e) {
|
|
871 e.result = isDropped () ? DWT.getMessage ("SWT_Close") : DWT.getMessage ("SWT_Open"); //$NON-NLS-1$ //$NON-NLS-2$
|
|
872 }
|
|
873 public void getKeyboardShortcut (AccessibleEvent e) {
|
|
874 e.result = "Alt+Down Arrow"; //$NON-NLS-1$
|
|
875 }
|
|
876 public void getHelp (AccessibleEvent e) {
|
|
877 e.result = getToolTipText ();
|
|
878 }
|
|
879 });
|
|
880
|
|
881 getAccessible().addAccessibleTextListener (new class() AccessibleTextAdapter {
|
|
882 public void getCaretOffset (AccessibleTextEvent e) {
|
|
883 e.offset = text.getCaretPosition ();
|
|
884 }
|
|
885 public void getSelectionRange(AccessibleTextEvent e) {
|
|
886 Point sel = text.getSelection();
|
|
887 e.offset = sel.x;
|
|
888 e.length = sel.y - sel.x;
|
|
889 }
|
|
890 });
|
|
891
|
|
892 getAccessible().addAccessibleControlListener (new class() AccessibleControlAdapter {
|
|
893 public void getChildAtPoint (AccessibleControlEvent e) {
|
|
894 Point testPoint = toControl (e.x, e.y);
|
|
895 if (getBounds ().contains (testPoint)) {
|
|
896 e.childID = ACC.CHILDID_SELF;
|
|
897 }
|
|
898 }
|
|
899
|
|
900 public void getLocation (AccessibleControlEvent e) {
|
|
901 Rectangle location = getBounds ();
|
|
902 Point pt = toDisplay (location.x, location.y);
|
|
903 e.x = pt.x;
|
|
904 e.y = pt.y;
|
|
905 e.width = location.width;
|
|
906 e.height = location.height;
|
|
907 }
|
|
908
|
|
909 public void getChildCount (AccessibleControlEvent e) {
|
|
910 e.detail = 0;
|
|
911 }
|
|
912
|
|
913 public void getRole (AccessibleControlEvent e) {
|
|
914 e.detail = ACC.ROLE_COMBOBOX;
|
|
915 }
|
|
916
|
|
917 public void getState (AccessibleControlEvent e) {
|
|
918 e.detail = ACC.STATE_NORMAL;
|
|
919 }
|
|
920
|
|
921 public void getValue (AccessibleControlEvent e) {
|
|
922 e.result = getText ();
|
|
923 }
|
|
924 });
|
|
925
|
|
926 text.getAccessible ().addAccessibleControlListener (new class() AccessibleControlAdapter {
|
|
927 public void getRole (AccessibleControlEvent e) {
|
|
928 e.detail = text.getEditable () ? ACC.ROLE_TEXT : ACC.ROLE_LABEL;
|
|
929 }
|
|
930 });
|
|
931
|
|
932 arrow.getAccessible ().addAccessibleControlListener (new class() AccessibleControlAdapter {
|
|
933 public void getDefaultAction (AccessibleControlEvent e) {
|
|
934 e.result = isDropped () ? DWT.getMessage ("SWT_Close") : DWT.getMessage ("SWT_Open"); //$NON-NLS-1$ //$NON-NLS-2$
|
|
935 }
|
|
936 });
|
|
937 }
|
|
938 bool isDropped () {
|
|
939 return popup.getVisible ();
|
|
940 }
|
|
941 public bool isFocusControl () {
|
|
942 checkWidget();
|
|
943 if (text.isFocusControl () || arrow.isFocusControl () || list.isFocusControl () || popup.isFocusControl ()) {
|
|
944 return true;
|
|
945 }
|
|
946 return super.isFocusControl ();
|
|
947 }
|
|
948 void internalLayout (bool changed) {
|
|
949 if (isDropped ()) dropDown (false);
|
|
950 Rectangle rect = getClientArea ();
|
|
951 int width = rect.width;
|
|
952 int height = rect.height;
|
|
953 Point arrowSize = arrow.computeSize (DWT.DEFAULT, height, changed);
|
|
954 text.setBounds (0, 0, width - arrowSize.x, height);
|
|
955 arrow.setBounds (width - arrowSize.x, 0, arrowSize.x, arrowSize.y);
|
|
956 }
|
|
957 void listEvent (Event event) {
|
|
958 switch (event.type) {
|
|
959 case DWT.Dispose:
|
|
960 if (getShell () !is popup.getParent ()) {
|
|
961 char[][] items = list.getItems ();
|
|
962 int selectionIndex = list.getSelectionIndex ();
|
|
963 popup = null;
|
|
964 list = null;
|
|
965 createPopup (items, selectionIndex);
|
|
966 }
|
|
967 break;
|
|
968 case DWT.FocusIn: {
|
|
969 handleFocus (DWT.FocusIn);
|
|
970 break;
|
|
971 }
|
|
972 case DWT.MouseUp: {
|
|
973 if (event.button !is 1) return;
|
|
974 dropDown (false);
|
|
975 break;
|
|
976 }
|
|
977 case DWT.Selection: {
|
|
978 int index = list.getSelectionIndex ();
|
|
979 if (index is -1) return;
|
|
980 text.setText (list.getItem (index));
|
|
981 text.selectAll ();
|
|
982 list.setSelection (index);
|
|
983 Event e = new Event ();
|
|
984 e.time = event.time;
|
|
985 e.stateMask = event.stateMask;
|
|
986 e.doit = event.doit;
|
|
987 notifyListeners (DWT.Selection, e);
|
|
988 event.doit = e.doit;
|
|
989 break;
|
|
990 }
|
|
991 case DWT.Traverse: {
|
|
992 switch (event.detail) {
|
|
993 case DWT.TRAVERSE_RETURN:
|
|
994 case DWT.TRAVERSE_ESCAPE:
|
|
995 case DWT.TRAVERSE_ARROW_PREVIOUS:
|
|
996 case DWT.TRAVERSE_ARROW_NEXT:
|
|
997 event.doit = false;
|
|
998 break;
|
|
999 }
|
|
1000 Event e = new Event ();
|
|
1001 e.time = event.time;
|
|
1002 e.detail = event.detail;
|
|
1003 e.doit = event.doit;
|
|
1004 e.character = event.character;
|
|
1005 e.keyCode = event.keyCode;
|
|
1006 notifyListeners (DWT.Traverse, e);
|
|
1007 event.doit = e.doit;
|
|
1008 event.detail = e.detail;
|
|
1009 break;
|
|
1010 }
|
|
1011 case DWT.KeyUp: {
|
|
1012 Event e = new Event ();
|
|
1013 e.time = event.time;
|
|
1014 e.character = event.character;
|
|
1015 e.keyCode = event.keyCode;
|
|
1016 e.stateMask = event.stateMask;
|
|
1017 notifyListeners (DWT.KeyUp, e);
|
|
1018 break;
|
|
1019 }
|
|
1020 case DWT.KeyDown: {
|
|
1021 if (event.character is DWT.ESC) {
|
|
1022 // Escape key cancels popup list
|
|
1023 dropDown (false);
|
|
1024 }
|
|
1025 if ((event.stateMask & DWT.ALT) !is 0 && (event.keyCode is DWT.ARROW_UP || event.keyCode is DWT.ARROW_DOWN)) {
|
|
1026 dropDown (false);
|
|
1027 }
|
|
1028 if (event.character is DWT.CR) {
|
|
1029 // Enter causes default selection
|
|
1030 dropDown (false);
|
|
1031 Event e = new Event ();
|
|
1032 e.time = event.time;
|
|
1033 e.stateMask = event.stateMask;
|
|
1034 notifyListeners (DWT.DefaultSelection, e);
|
|
1035 }
|
|
1036 // At this point the widget may have been disposed.
|
|
1037 // If so, do not continue.
|
|
1038 if (isDisposed ()) break;
|
|
1039 Event e = new Event();
|
|
1040 e.time = event.time;
|
|
1041 e.character = event.character;
|
|
1042 e.keyCode = event.keyCode;
|
|
1043 e.stateMask = event.stateMask;
|
|
1044 notifyListeners(DWT.KeyDown, e);
|
|
1045 break;
|
|
1046
|
|
1047 }
|
|
1048 }
|
|
1049 }
|
|
1050 /**
|
|
1051 * Pastes text from clipboard.
|
|
1052 * <p>
|
|
1053 * The selected text is deleted from the widget
|
|
1054 * and new text inserted from the clipboard.
|
|
1055 * </p>
|
|
1056 *
|
|
1057 * @exception DWTException <ul>
|
|
1058 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
|
|
1059 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
|
|
1060 * </ul>
|
|
1061 *
|
|
1062 * @since 3.3
|
|
1063 */
|
|
1064 public void paste () {
|
|
1065 checkWidget ();
|
|
1066 text.paste ();
|
|
1067 }
|
|
1068 void popupEvent(Event event) {
|
|
1069 switch (event.type) {
|
|
1070 case DWT.Paint:
|
|
1071 // draw black rectangle around list
|
|
1072 Rectangle listRect = list.getBounds();
|
|
1073 Color black = getDisplay().getSystemColor(DWT.COLOR_BLACK);
|
|
1074 event.gc.setForeground(black);
|
|
1075 event.gc.drawRectangle(0, 0, listRect.width + 1, listRect.height + 1);
|
|
1076 break;
|
|
1077 case DWT.Close:
|
|
1078 event.doit = false;
|
|
1079 dropDown (false);
|
|
1080 break;
|
|
1081 case DWT.Deactivate:
|
|
1082 dropDown (false);
|
|
1083 break;
|
|
1084 }
|
|
1085 }
|
|
1086 public void redraw () {
|
|
1087 super.redraw();
|
|
1088 text.redraw();
|
|
1089 arrow.redraw();
|
|
1090 if (popup.isVisible()) list.redraw();
|
|
1091 }
|
|
1092 public void redraw (int x, int y, int width, int height, bool all) {
|
|
1093 super.redraw(x, y, width, height, true);
|
|
1094 }
|
|
1095
|
|
1096 /**
|
|
1097 * Removes the item from the receiver's list at the given
|
|
1098 * zero-relative index.
|
|
1099 *
|
|
1100 * @param index the index for the item
|
|
1101 *
|
|
1102 * @exception IllegalArgumentException <ul>
|
|
1103 * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
|
|
1104 * </ul>
|
|
1105 * @exception DWTException <ul>
|
|
1106 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
|
|
1107 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
|
|
1108 * </ul>
|
|
1109 */
|
|
1110 public void remove (int index) {
|
|
1111 checkWidget();
|
|
1112 list.remove (index);
|
|
1113 }
|
|
1114 /**
|
|
1115 * Removes the items from the receiver's list which are
|
|
1116 * between the given zero-relative start and end
|
|
1117 * indices (inclusive).
|
|
1118 *
|
|
1119 * @param start the start of the range
|
|
1120 * @param end the end of the range
|
|
1121 *
|
|
1122 * @exception IllegalArgumentException <ul>
|
|
1123 * <li>ERROR_INVALID_RANGE - if either the start or end are not between 0 and the number of elements in the list minus 1 (inclusive)</li>
|
|
1124 * </ul>
|
|
1125 * @exception DWTException <ul>
|
|
1126 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
|
|
1127 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
|
|
1128 * </ul>
|
|
1129 */
|
|
1130 public void remove (int start, int end) {
|
|
1131 checkWidget();
|
|
1132 list.remove (start, end);
|
|
1133 }
|
|
1134 /**
|
|
1135 * Searches the receiver's list starting at the first item
|
|
1136 * until an item is found that is equal to the argument,
|
|
1137 * and removes that item from the list.
|
|
1138 *
|
|
1139 * @param string the item to remove
|
|
1140 *
|
|
1141 * @exception IllegalArgumentException <ul>
|
|
1142 * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
|
|
1143 * <li>ERROR_INVALID_ARGUMENT - if the string is not found in the list</li>
|
|
1144 * </ul>
|
|
1145 * @exception DWTException <ul>
|
|
1146 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
|
|
1147 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
|
|
1148 * </ul>
|
|
1149 */
|
|
1150 public void remove (char[] string) {
|
|
1151 checkWidget();
|
|
1152 if (string is null) DWT.error (DWT.ERROR_NULL_ARGUMENT);
|
|
1153 list.remove (string);
|
|
1154 }
|
|
1155 /**
|
|
1156 * Removes all of the items from the receiver's list and clear the
|
|
1157 * contents of receiver's text field.
|
|
1158 * <p>
|
|
1159 * @exception DWTException <ul>
|
|
1160 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
|
|
1161 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
|
|
1162 * </ul>
|
|
1163 */
|
|
1164 public void removeAll () {
|
|
1165 checkWidget();
|
|
1166 text.setText (""); //$NON-NLS-1$
|
|
1167 list.removeAll ();
|
|
1168 }
|
|
1169 /**
|
|
1170 * Removes the listener from the collection of listeners who will
|
|
1171 * be notified when the receiver's text is modified.
|
|
1172 *
|
|
1173 * @param listener the listener which should no longer be notified
|
|
1174 *
|
|
1175 * @exception IllegalArgumentException <ul>
|
|
1176 * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
|
|
1177 * </ul>
|
|
1178 * @exception DWTException <ul>
|
|
1179 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
|
|
1180 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
|
|
1181 * </ul>
|
|
1182 *
|
|
1183 * @see ModifyListener
|
|
1184 * @see #addModifyListener
|
|
1185 */
|
|
1186 public void removeModifyListener (ModifyListener listener) {
|
|
1187 checkWidget();
|
|
1188 if (listener is null) DWT.error (DWT.ERROR_NULL_ARGUMENT);
|
|
1189 removeListener(DWT.Modify, listener);
|
|
1190 }
|
|
1191 /**
|
|
1192 * Removes the listener from the collection of listeners who will
|
|
1193 * be notified when the user changes the receiver's selection.
|
|
1194 *
|
|
1195 * @param listener the listener which should no longer be notified
|
|
1196 *
|
|
1197 * @exception IllegalArgumentException <ul>
|
|
1198 * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
|
|
1199 * </ul>
|
|
1200 * @exception DWTException <ul>
|
|
1201 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
|
|
1202 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
|
|
1203 * </ul>
|
|
1204 *
|
|
1205 * @see SelectionListener
|
|
1206 * @see #addSelectionListener
|
|
1207 */
|
|
1208 public void removeSelectionListener (SelectionListener listener) {
|
|
1209 checkWidget();
|
|
1210 if (listener is null) DWT.error (DWT.ERROR_NULL_ARGUMENT);
|
|
1211 removeListener(DWT.Selection, listener);
|
|
1212 removeListener(DWT.DefaultSelection,listener);
|
|
1213 }
|
|
1214 /**
|
|
1215 * Removes the listener from the collection of listeners who will
|
|
1216 * be notified when the control is verified.
|
|
1217 *
|
|
1218 * @param listener the listener which should no longer be notified
|
|
1219 *
|
|
1220 * @exception IllegalArgumentException <ul>
|
|
1221 * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
|
|
1222 * </ul>
|
|
1223 * @exception DWTException <ul>
|
|
1224 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
|
|
1225 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
|
|
1226 * </ul>
|
|
1227 *
|
|
1228 * @see VerifyListener
|
|
1229 * @see #addVerifyListener
|
|
1230 *
|
|
1231 * @since 3.3
|
|
1232 */
|
|
1233 public void removeVerifyListener (VerifyListener listener) {
|
|
1234 checkWidget();
|
|
1235 if (listener is null) DWT.error (DWT.ERROR_NULL_ARGUMENT);
|
|
1236 removeListener(DWT.Verify, listener);
|
|
1237 }
|
|
1238 /**
|
|
1239 * Selects the item at the given zero-relative index in the receiver's
|
|
1240 * list. If the item at the index was already selected, it remains
|
|
1241 * selected. Indices that are out of range are ignored.
|
|
1242 *
|
|
1243 * @param index the index of the item to select
|
|
1244 *
|
|
1245 * @exception DWTException <ul>
|
|
1246 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
|
|
1247 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
|
|
1248 * </ul>
|
|
1249 */
|
|
1250 public void select (int index) {
|
|
1251 checkWidget();
|
|
1252 if (index is -1) {
|
|
1253 list.deselectAll ();
|
|
1254 text.setText (""); //$NON-NLS-1$
|
|
1255 return;
|
|
1256 }
|
|
1257 if (0 <= index && index < list.getItemCount()) {
|
|
1258 if (index !is getSelectionIndex()) {
|
|
1259 text.setText (list.getItem (index));
|
|
1260 text.selectAll ();
|
|
1261 list.select (index);
|
|
1262 list.showSelection ();
|
|
1263 }
|
|
1264 }
|
|
1265 }
|
|
1266 public void setBackground (Color color) {
|
|
1267 super.setBackground(color);
|
|
1268 background = color;
|
|
1269 if (text !is null) text.setBackground(color);
|
|
1270 if (list !is null) list.setBackground(color);
|
|
1271 if (arrow !is null) arrow.setBackground(color);
|
|
1272 }
|
|
1273 /**
|
|
1274 * Sets the editable state.
|
|
1275 *
|
|
1276 * @param editable the new editable state
|
|
1277 *
|
|
1278 * @exception DWTException <ul>
|
|
1279 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
|
|
1280 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
|
|
1281 * </ul>
|
|
1282 *
|
|
1283 * @since 3.0
|
|
1284 */
|
|
1285 public void setEditable (bool editable) {
|
|
1286 checkWidget ();
|
|
1287 text.setEditable(editable);
|
|
1288 }
|
|
1289 public void setEnabled (bool enabled) {
|
|
1290 super.setEnabled(enabled);
|
|
1291 if (popup !is null) popup.setVisible (false);
|
|
1292 if (text !is null) text.setEnabled(enabled);
|
|
1293 if (arrow !is null) arrow.setEnabled(enabled);
|
|
1294 }
|
|
1295 public bool setFocus () {
|
|
1296 checkWidget();
|
|
1297 if (isFocusControl ()) return true;
|
|
1298 return text.setFocus ();
|
|
1299 }
|
|
1300 public void setFont (Font font) {
|
|
1301 super.setFont (font);
|
|
1302 this.font = font;
|
|
1303 text.setFont (font);
|
|
1304 list.setFont (font);
|
|
1305 internalLayout (true);
|
|
1306 }
|
|
1307 public void setForeground (Color color) {
|
|
1308 super.setForeground(color);
|
|
1309 foreground = color;
|
|
1310 if (text !is null) text.setForeground(color);
|
|
1311 if (list !is null) list.setForeground(color);
|
|
1312 if (arrow !is null) arrow.setForeground(color);
|
|
1313 }
|
|
1314 /**
|
|
1315 * Sets the text of the item in the receiver's list at the given
|
|
1316 * zero-relative index to the string argument. This is equivalent
|
|
1317 * to <code>remove</code>'ing the old item at the index, and then
|
|
1318 * <code>add</code>'ing the new item at that index.
|
|
1319 *
|
|
1320 * @param index the index for the item
|
|
1321 * @param string the new text for the item
|
|
1322 *
|
|
1323 * @exception IllegalArgumentException <ul>
|
|
1324 * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
|
|
1325 * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
|
|
1326 * </ul>
|
|
1327 * @exception DWTException <ul>
|
|
1328 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
|
|
1329 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
|
|
1330 * </ul>
|
|
1331 */
|
|
1332 public void setItem (int index, char[] string) {
|
|
1333 checkWidget();
|
|
1334 list.setItem (index, string);
|
|
1335 }
|
|
1336 /**
|
|
1337 * Sets the receiver's list to be the given array of items.
|
|
1338 *
|
|
1339 * @param items the array of items
|
|
1340 *
|
|
1341 * @exception IllegalArgumentException <ul>
|
|
1342 * <li>ERROR_NULL_ARGUMENT - if the items array is null</li>
|
|
1343 * <li>ERROR_INVALID_ARGUMENT - if an item in the items array is null</li>
|
|
1344 * </ul>
|
|
1345 * @exception DWTException <ul>
|
|
1346 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
|
|
1347 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
|
|
1348 * </ul>
|
|
1349 */
|
|
1350 public void setItems (char[] [] items) {
|
|
1351 checkWidget ();
|
|
1352 list.setItems (items);
|
|
1353 if (!text.getEditable ()) text.setText (""); //$NON-NLS-1$
|
|
1354 }
|
|
1355 /**
|
|
1356 * Sets the layout which is associated with the receiver to be
|
|
1357 * the argument which may be null.
|
|
1358 * <p>
|
|
1359 * Note: No Layout can be set on this Control because it already
|
|
1360 * manages the size and position of its children.
|
|
1361 * </p>
|
|
1362 *
|
|
1363 * @param layout the receiver's new layout or null
|
|
1364 *
|
|
1365 * @exception DWTException <ul>
|
|
1366 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
|
|
1367 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
|
|
1368 * </ul>
|
|
1369 */
|
|
1370 public void setLayout (Layout layout) {
|
|
1371 checkWidget ();
|
|
1372 return;
|
|
1373 }
|
|
1374 public void setMenu(Menu menu) {
|
|
1375 text.setMenu(menu);
|
|
1376 }
|
|
1377 /**
|
|
1378 * Sets the selection in the receiver's text field to the
|
|
1379 * range specified by the argument whose x coordinate is the
|
|
1380 * start of the selection and whose y coordinate is the end
|
|
1381 * of the selection.
|
|
1382 *
|
|
1383 * @param selection a point representing the new selection start and end
|
|
1384 *
|
|
1385 * @exception IllegalArgumentException <ul>
|
|
1386 * <li>ERROR_NULL_ARGUMENT - if the point is null</li>
|
|
1387 * </ul>
|
|
1388 * @exception DWTException <ul>
|
|
1389 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
|
|
1390 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
|
|
1391 * </ul>
|
|
1392 */
|
|
1393 public void setSelection (Point selection) {
|
|
1394 checkWidget();
|
|
1395 if (selection is null) DWT.error (DWT.ERROR_NULL_ARGUMENT);
|
|
1396 text.setSelection (selection.x, selection.y);
|
|
1397 }
|
|
1398
|
|
1399 /**
|
|
1400 * Sets the contents of the receiver's text field to the
|
|
1401 * given string.
|
|
1402 * <p>
|
|
1403 * Note: The text field in a <code>Combo</code> is typically
|
|
1404 * only capable of displaying a single line of text. Thus,
|
|
1405 * setting the text to a string containing line breaks or
|
|
1406 * other special characters will probably cause it to
|
|
1407 * display incorrectly.
|
|
1408 * </p>
|
|
1409 *
|
|
1410 * @param string the new text
|
|
1411 *
|
|
1412 * @exception IllegalArgumentException <ul>
|
|
1413 * <li>ERROR_NULL_ARGUMENT - if the string is null</li>
|
|
1414 * </ul>
|
|
1415 * @exception DWTException <ul>
|
|
1416 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
|
|
1417 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
|
|
1418 * </ul>
|
|
1419 */
|
|
1420 public void setText (char[] string) {
|
|
1421 checkWidget();
|
|
1422 if (string is null) DWT.error (DWT.ERROR_NULL_ARGUMENT);
|
|
1423 int index = list.indexOf (string);
|
|
1424 if (index is -1) {
|
|
1425 list.deselectAll ();
|
|
1426 text.setText (string);
|
|
1427 return;
|
|
1428 }
|
|
1429 text.setText (string);
|
|
1430 text.selectAll ();
|
|
1431 list.setSelection (index);
|
|
1432 list.showSelection ();
|
|
1433 }
|
|
1434 /**
|
|
1435 * Sets the maximum number of characters that the receiver's
|
|
1436 * text field is capable of holding to be the argument.
|
|
1437 *
|
|
1438 * @param limit new text limit
|
|
1439 *
|
|
1440 * @exception IllegalArgumentException <ul>
|
|
1441 * <li>ERROR_CANNOT_BE_ZERO - if the limit is zero</li>
|
|
1442 * </ul>
|
|
1443 * @exception DWTException <ul>
|
|
1444 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
|
|
1445 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
|
|
1446 * </ul>
|
|
1447 */
|
|
1448 public void setTextLimit (int limit) {
|
|
1449 checkWidget();
|
|
1450 text.setTextLimit (limit);
|
|
1451 }
|
|
1452
|
|
1453 public void setToolTipText (char[] string) {
|
|
1454 checkWidget();
|
|
1455 super.setToolTipText(string);
|
|
1456 arrow.setToolTipText (string);
|
|
1457 text.setToolTipText (string);
|
|
1458 }
|
|
1459
|
|
1460 public void setVisible (bool visible) {
|
|
1461 super.setVisible(visible);
|
|
1462 /*
|
|
1463 * At this point the widget may have been disposed in a FocusOut event.
|
|
1464 * If so then do not continue.
|
|
1465 */
|
|
1466 if (isDisposed ()) return;
|
|
1467 if (!visible) popup.setVisible(false);
|
|
1468 }
|
|
1469 /**
|
|
1470 * Sets the number of items that are visible in the drop
|
|
1471 * down portion of the receiver's list.
|
|
1472 *
|
|
1473 * @param count the new number of items to be visible
|
|
1474 *
|
|
1475 * @exception DWTException <ul>
|
|
1476 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
|
|
1477 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
|
|
1478 * </ul>
|
|
1479 *
|
|
1480 * @since 3.0
|
|
1481 */
|
|
1482 public void setVisibleItemCount (int count) {
|
|
1483 checkWidget ();
|
|
1484 if (count < 0) return;
|
|
1485 visibleItemCount = count;
|
|
1486 }
|
|
1487 char[] stripMnemonic (char[] string) {
|
|
1488 int index = 0;
|
|
1489 int length_ = string.length;
|
|
1490 do {
|
|
1491 while ((index < length_) && (string[index] !is '&')) index++;
|
|
1492 if (++index >= length_) return string;
|
|
1493 if (string[index] !is '&') {
|
|
1494 return string[0 .. index-1] ~ string[index .. length_];
|
|
1495 }
|
|
1496 index++;
|
|
1497 } while (index < length_);
|
|
1498 return string;
|
|
1499 }
|
|
1500 void textEvent (Event event) {
|
|
1501 switch (event.type) {
|
|
1502 case DWT.FocusIn: {
|
|
1503 handleFocus (DWT.FocusIn);
|
|
1504 break;
|
|
1505 }
|
|
1506 case DWT.KeyDown: {
|
|
1507 Event keyEvent = new Event ();
|
|
1508 keyEvent.time = event.time;
|
|
1509 keyEvent.character = event.character;
|
|
1510 keyEvent.keyCode = event.keyCode;
|
|
1511 keyEvent.stateMask = event.stateMask;
|
|
1512 notifyListeners (DWT.KeyDown, keyEvent);
|
|
1513 if (isDisposed ()) break;
|
|
1514 event.doit = keyEvent.doit;
|
|
1515 if (!event.doit) break;
|
|
1516
|
|
1517 if (event.character is DWT.CR) {
|
|
1518 dropDown (false);
|
|
1519 Event selectionEvent = new Event ();
|
|
1520 selectionEvent.time = event.time;
|
|
1521 selectionEvent.stateMask = event.stateMask;
|
|
1522 notifyListeners (DWT.DefaultSelection, selectionEvent);
|
|
1523 if (isDisposed ()) break;
|
|
1524 }
|
|
1525
|
|
1526 if (event.keyCode is DWT.ARROW_UP || event.keyCode is DWT.ARROW_DOWN) {
|
|
1527 event.doit = false;
|
|
1528 if ((event.stateMask & DWT.ALT) !is 0) {
|
|
1529 bool dropped = isDropped ();
|
|
1530 text.selectAll ();
|
|
1531 if (!dropped) setFocus ();
|
|
1532 dropDown (!dropped);
|
|
1533 break;
|
|
1534 }
|
|
1535
|
|
1536 int oldIndex = getSelectionIndex ();
|
|
1537 if (event.keyCode is DWT.ARROW_UP) {
|
|
1538 select (Math.max (oldIndex - 1, 0));
|
|
1539 } else {
|
|
1540 select (Math.min (oldIndex + 1, getItemCount () - 1));
|
|
1541 }
|
|
1542 if (oldIndex !is getSelectionIndex ()) {
|
|
1543 Event e = new Event();
|
|
1544 e.time = event.time;
|
|
1545 e.stateMask = event.stateMask;
|
|
1546 notifyListeners (DWT.Selection, e);
|
|
1547 }
|
|
1548 if (isDisposed ()) break;
|
|
1549 }
|
|
1550
|
|
1551 // Further work : Need to add support for incremental search in
|
|
1552 // pop up list as characters typed in text widget
|
|
1553 break;
|
|
1554 }
|
|
1555 case DWT.KeyUp: {
|
|
1556 Event e = new Event ();
|
|
1557 e.time = event.time;
|
|
1558 e.character = event.character;
|
|
1559 e.keyCode = event.keyCode;
|
|
1560 e.stateMask = event.stateMask;
|
|
1561 notifyListeners (DWT.KeyUp, e);
|
|
1562 event.doit = e.doit;
|
|
1563 break;
|
|
1564 }
|
|
1565 case DWT.MenuDetect: {
|
|
1566 Event e = new Event ();
|
|
1567 e.time = event.time;
|
|
1568 notifyListeners (DWT.MenuDetect, e);
|
|
1569 break;
|
|
1570 }
|
|
1571 case DWT.Modify: {
|
|
1572 list.deselectAll ();
|
|
1573 Event e = new Event ();
|
|
1574 e.time = event.time;
|
|
1575 notifyListeners (DWT.Modify, e);
|
|
1576 break;
|
|
1577 }
|
|
1578 case DWT.MouseDown: {
|
|
1579 if (event.button !is 1) return;
|
|
1580 if (text.getEditable ()) return;
|
|
1581 bool dropped = isDropped ();
|
|
1582 text.selectAll ();
|
|
1583 if (!dropped) setFocus ();
|
|
1584 dropDown (!dropped);
|
|
1585 break;
|
|
1586 }
|
|
1587 case DWT.MouseUp: {
|
|
1588 if (event.button !is 1) return;
|
|
1589 if (text.getEditable ()) return;
|
|
1590 text.selectAll ();
|
|
1591 break;
|
|
1592 }
|
|
1593 case DWT.Traverse: {
|
|
1594 switch (event.detail) {
|
|
1595 case DWT.TRAVERSE_RETURN:
|
|
1596 case DWT.TRAVERSE_ARROW_PREVIOUS:
|
|
1597 case DWT.TRAVERSE_ARROW_NEXT:
|
|
1598 // The enter causes default selection and
|
|
1599 // the arrow keys are used to manipulate the list contents so
|
|
1600 // do not use them for traversal.
|
|
1601 event.doit = false;
|
|
1602 break;
|
|
1603 }
|
|
1604
|
|
1605 Event e = new Event ();
|
|
1606 e.time = event.time;
|
|
1607 e.detail = event.detail;
|
|
1608 e.doit = event.doit;
|
|
1609 e.character = event.character;
|
|
1610 e.keyCode = event.keyCode;
|
|
1611 notifyListeners (DWT.Traverse, e);
|
|
1612 event.doit = e.doit;
|
|
1613 event.detail = e.detail;
|
|
1614 break;
|
|
1615 }
|
|
1616 case DWT.Verify: {
|
|
1617 Event e = new Event ();
|
|
1618 e.text = event.text;
|
|
1619 e.start = event.start;
|
|
1620 e.end = event.end;
|
|
1621 e.character = event.character;
|
|
1622 e.keyCode = event.keyCode;
|
|
1623 e.stateMask = event.stateMask;
|
|
1624 notifyListeners (DWT.Verify, e);
|
|
1625 event.doit = e.doit;
|
|
1626 break;
|
|
1627 }
|
|
1628 default:
|
|
1629 }
|
|
1630 }
|
|
1631 }
|