root/dwt/widgets/List.d

Revision 246:fd9c62a2998e, 62.0 kB (checked in by Frank Benoit <benoit@tionex.de>, 5 months ago)

Updater SWT 3.4M7 to 3.4

Line 
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 dwt.widgets.List;
14
15
16 import dwt.DWT;
17 import dwt.DWTException;
18 import dwt.events.SelectionEvent;
19 import dwt.events.SelectionListener;
20 import dwt.graphics.Font;
21 import dwt.graphics.Point;
22 import dwt.internal.win32.OS;
23
24 import dwt.widgets.Scrollable;
25 import dwt.widgets.Composite;
26 import dwt.widgets.TypedListener;
27
28 import dwt.dwthelper.utils;
29
30 /**
31  * Instances of this class represent a selectable user interface
32  * object that displays a list of strings and issues notification
33  * when a string is selected.  A list may be single or multi select.
34  * <p>
35  * <dl>
36  * <dt><b>Styles:</b></dt>
37  * <dd>SINGLE, MULTI</dd>
38  * <dt><b>Events:</b></dt>
39  * <dd>Selection, DefaultSelection</dd>
40  * </dl>
41  * <p>
42  * Note: Only one of SINGLE and MULTI may be specified.
43  * </p><p>
44  * IMPORTANT: This class is <em>not</em> intended to be subclassed.
45  * </p>
46  *
47  * @see <a href="http://www.eclipse.org/swt/snippets/#list">List snippets</a>
48  * @see <a href="http://www.eclipse.org/swt/examples.php">DWT Example: ControlExample</a>
49  * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
50  */
51
52 public class List : Scrollable {
53
54     alias Scrollable.computeSize computeSize;
55     alias Scrollable.windowProc windowProc;
56
57     static const int INSET = 3;
58     private static /+const+/ WNDPROC ListProc;
59     static const TCHAR[] ListClass = "LISTBOX";
60
61     private static bool static_this_completed = false;
62     private static void static_this() {
63         if( static_this_completed ){
64             return;
65         }
66         synchronized {
67             if( static_this_completed ){
68                 return;
69             }
70             WNDCLASS lpWndClass;
71             OS.GetClassInfo (null, ListClass.ptr, &lpWndClass);
72             ListProc = lpWndClass.lpfnWndProc;
73             static_this_completed = true;
74         }
75     }
76
77 /**
78  * Constructs a new instance of this class given its parent
79  * and a style value describing its behavior and appearance.
80  * <p>
81  * The style value is either one of the style constants defined in
82  * class <code>DWT</code> which is applicable to instances of this
83  * class, or must be built by <em>bitwise OR</em>'ing together
84  * (that is, using the <code>int</code> "|" operator) two or more
85  * of those <code>DWT</code> style constants. The class description
86  * lists the style constants that are applicable to the class.
87  * Style bits are also inherited from superclasses.
88  * </p>
89  *
90  * @param parent a composite control which will be the parent of the new instance (cannot be null)
91  * @param style the style of control to construct
92  *
93  * @exception IllegalArgumentException <ul>
94  *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
95  * </ul>
96  * @exception DWTException <ul>
97  *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
98  *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
99  * </ul>
100  *
101  * @see DWT#SINGLE
102  * @see DWT#MULTI
103  * @see Widget#checkSubclass
104  * @see Widget#getStyle
105  */
106 public this (Composite parent, int style) {
107     static_this();
108     super (parent, checkStyle (style));
109 }
110 /**
111  * Adds the argument to the end of the receiver's list.
112  *
113  * @param string the new item
114  *
115  * @exception DWTException <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  * @see #add(String,int)
121  */
122 public void add (String string) {
123     checkWidget ();
124     // DWT extension: allow null string
125     //if (string is null) error (DWT.ERROR_NULL_ARGUMENT);
126     TCHAR* buffer = StrToTCHARz ( getCodePage (), string);
127     int result = OS.SendMessage (handle, OS.LB_ADDSTRING, 0, buffer);
128     if (result is OS.LB_ERR) error (DWT.ERROR_ITEM_NOT_ADDED);
129     if (result is OS.LB_ERRSPACE) error (DWT.ERROR_ITEM_NOT_ADDED);
130     if ((style & DWT.H_SCROLL) !is 0) setScrollWidth (buffer, true);
131 }
132 /**
133  * Adds the argument to the receiver's list at the given
134  * zero-relative index.
135  * <p>
136  * Note: To add an item at the end of the list, use the
137  * result of calling <code>getItemCount()</code> as the
138  * index or use <code>add(String)</code>.
139  * </p>
140  *
141  * @param string the new item
142  * @param index the index for the item
143  *
144  * @exception IllegalArgumentException <ul>
145  *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list (inclusive)</li>
146  * </ul>
147  * @exception DWTException <ul>
148  *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
149  *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
150  * </ul>
151  *
152  * @see #add(String)
153  */
154 public void add (String string, int index) {
155     checkWidget ();
156     // DWT extension: allow null string
157     //if (string is null) error (DWT.ERROR_NULL_ARGUMENT);
158     if (index is -1) error (DWT.ERROR_INVALID_RANGE);
159     TCHAR* buffer = StrToTCHARz(getCodePage (), string);
160     int result = OS.SendMessage (handle, OS.LB_INSERTSTRING, index, buffer);
161     if (result is OS.LB_ERRSPACE) error (DWT.ERROR_ITEM_NOT_ADDED);
162     if (result is OS.LB_ERR) {
163         int count = OS.SendMessage (handle, OS.LB_GETCOUNT, 0, 0);
164         if (0 <= index && index <= count) {
165             error (DWT.ERROR_ITEM_NOT_ADDED);
166         } else {
167             error (DWT.ERROR_INVALID_RANGE);
168         }
169     }
170     if ((style & DWT.H_SCROLL) !is 0) setScrollWidth (buffer, true);
171 }
172
173 /**
174  * Adds the listener to the collection of listeners who will
175  * be notified when the user changes the receiver's selection, by sending
176  * it one of the messages defined in the <code>SelectionListener</code>
177  * interface.
178  * <p>
179  * <code>widgetSelected</code> is called when the selection changes.
180  * <code>widgetDefaultSelected</code> is typically called when an item is double-clicked.
181  * </p>
182  *
183  * @param listener the listener which should be notified when the user changes the receiver's selection
184  *
185  * @exception IllegalArgumentException <ul>
186  *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
187  * </ul>
188  * @exception DWTException <ul>
189  *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
190  *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
191  * </ul>
192  *
193  * @see SelectionListener
194  * @see #removeSelectionListener
195  * @see SelectionEvent
196  */
197 public void addSelectionListener(SelectionListener listener) {
198     checkWidget ();
199     if (listener is null) error (DWT.ERROR_NULL_ARGUMENT);
200     TypedListener typedListener = new TypedListener (listener);
201     addListener (DWT.Selection,typedListener);
202     addListener (DWT.DefaultSelection,typedListener);
203 }
204
205 override int callWindowProc (HWND hwnd, int msg, int wParam, int lParam) {
206     if (handle is null) return 0;
207     bool redraw = false;
208     switch (msg) {
209         case OS.WM_HSCROLL:
210         case OS.WM_VSCROLL: {
211             redraw = findImageControl () !is null && drawCount is 0 && OS.IsWindowVisible (handle);
212             if (redraw) OS.DefWindowProc (handle, OS.WM_SETREDRAW, 0, 0);
213             break;
214         }
215         default:
216     }
217     int /*long*/ code = OS.CallWindowProc (ListProc, hwnd, msg, wParam, lParam);
218     switch (msg) {
219         case OS.WM_HSCROLL:
220         case OS.WM_VSCROLL: {
221             if (redraw) {
222                 OS.DefWindowProc (handle, OS.WM_SETREDRAW, 1, 0);
223                 OS.InvalidateRect (handle, null, true);
224             }
225             break;
226         }
227         default:
228     }
229     return code;
230 }
231
232 static int checkStyle (int style) {
233     return checkBits (style, DWT.SINGLE, DWT.MULTI, 0, 0, 0, 0);
234 }
235
236 override public Point computeSize (int wHint, int hHint, bool changed) {
237     checkWidget ();
238     int width = 0, height = 0;
239     if (wHint is DWT.DEFAULT) {
240         if ((style & DWT.H_SCROLL) !is 0) {
241             width = OS.SendMessage (handle, OS.LB_GETHORIZONTALEXTENT, 0, 0);
242             width -= INSET;
243         } else {
244             int count = OS.SendMessage (handle, OS.LB_GETCOUNT, 0, 0);
245             HFONT newFont, oldFont;
246             auto hDC = OS.GetDC (handle);
247             newFont = cast(HFONT) OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
248             if (newFont !is null) oldFont = OS.SelectObject (hDC, newFont);
249             RECT rect;
250             int flags = OS.DT_CALCRECT | OS.DT_SINGLELINE | OS.DT_NOPREFIX;
251             int cp = getCodePage ();
252             TCHAR[] buffer = NewTCHARs (cp, 64 + 1);
253             for (int i=0; i<count; i++) {
254                 int length = OS.SendMessage (handle, OS.LB_GETTEXTLEN, i, 0);
255                 if (length !is OS.LB_ERR) {
256                     if (length + 1 > buffer.length) {
257                         buffer = NewTCHARs (cp, length + 1);
258                     }
259                     int result = OS.SendMessage (handle, OS.LB_GETTEXT, i, buffer.ptr);
260                     if (result !is OS.LB_ERR) {
261                         OS.DrawText (hDC, buffer.ptr, length, &rect, flags);
262                         width = Math.max (width, rect.right - rect.left);
263                     }
264                 }
265             }
266             if (newFont !is null) OS.SelectObject (hDC, oldFont);
267             OS.ReleaseDC (handle, hDC);
268         }
269     }
270     if (hHint is DWT.DEFAULT) {
271         int count = OS.SendMessage (handle, OS.LB_GETCOUNT, 0, 0);
272         int itemHeight = OS.SendMessage (handle, OS.LB_GETITEMHEIGHT, 0, 0);
273         height = count * itemHeight;
274     }
275     if (width is 0) width = DEFAULT_WIDTH;
276     if (height is 0) height = DEFAULT_HEIGHT;
277     if (wHint !is DWT.DEFAULT) width = wHint;
278     if (hHint !is DWT.DEFAULT) height = hHint;
279     int border = getBorderWidth ();
280     width += border * 2 + INSET;
281     height += border * 2;
282     if ((style & DWT.V_SCROLL) !is 0) {
283         width += OS.GetSystemMetrics (OS.SM_CXVSCROLL);
284     }
285     if ((style & DWT.H_SCROLL) !is 0) {
286         height += OS.GetSystemMetrics (OS.SM_CYHSCROLL);
287     }
288     return new Point (width, height);
289 }
290
291 override int defaultBackground () {
292     return OS.GetSysColor (OS.COLOR_WINDOW);
293 }
294
295 /**
296  * Deselects the items at the given zero-relative indices in the receiver.
297  * If the item at the given zero-relative index in the receiver
298  * is selected, it is deselected.  If the item at the index
299  * was not selected, it remains deselected. Indices that are out
300  * of range and duplicate indices are ignored.
301  *
302  * @param indices the array of indices for the items to deselect
303  *
304  * @exception DWTException <ul>
305  *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
306  *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
307  * </ul>
308  */
309 public void deselect (int [] indices) {
310     checkWidget ();
311     // DWT extension: allow null array
312     //if (indices is null) error (DWT.ERROR_NULL_ARGUMENT);
313     if (indices.length is 0) return;
314     if ((style & DWT.SINGLE) !is 0) {
315         int oldIndex = OS.SendMessage (handle, OS.LB_GETCURSEL, 0, 0);
316         if (oldIndex is OS.LB_ERR) return;
317         for (int i=0; i<indices.length; i++) {
318             if (oldIndex is indices [i]) {
319                 OS.SendMessage (handle, OS.LB_SETCURSEL, -1, 0);
320                 return;
321             }
322         }
323         return;
324     }
325     for (int i=0; i<indices.length; i++) {
326         int index = indices [i];
327         if (index !is -1) {
328             OS.SendMessage (handle, OS.LB_SETSEL, 0, index);
329         }
330     }
331 }
332
333 /**
334  * Deselects the item at the given zero-relative index in the receiver.
335  * If the item at the index was already deselected, it remains
336  * deselected. Indices that are out of range are ignored.
337  *
338  * @param index the index of the item to deselect
339  *
340  * @exception DWTException <ul>
341  *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
342  *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
343  * </ul>
344  */
345 public void deselect (int index) {
346     checkWidget ();
347     if (index is -1) return;
348     if ((style & DWT.SINGLE) !is 0) {
349         int oldIndex = OS.SendMessage (handle, OS.LB_GETCURSEL, 0, 0);
350         if (oldIndex is OS.LB_ERR) return;
351         if (oldIndex is index) OS.SendMessage (handle, OS.LB_SETCURSEL, -1, 0);
352         return;
353     }
354     OS.SendMessage (handle, OS.LB_SETSEL, 0, index);
355 }
356
357 /**
358  * Deselects the items at the given zero-relative indices in the receiver.
359  * If the item at the given zero-relative index in the receiver
360  * is selected, it is deselected.  If the item at the index
361  * was not selected, it remains deselected.  The range of the
362  * indices is inclusive. Indices that are out of range are ignored.
363  *
364  * @param start the start index of the items to deselect
365  * @param end the end index of the items to deselect
366  *
367  * @exception DWTException <ul>
368  *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
369  *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
370  * </ul>
371  */
372 public void deselect (int start, int end) {
373     checkWidget ();
374     if (start > end) return;
375     if ((style & DWT.SINGLE) !is 0) {
376         int oldIndex = OS.SendMessage (handle, OS.LB_GETCURSEL, 0, 0);
377         if (oldIndex is OS.LB_ERR) return;
378         if (start <= oldIndex && oldIndex <= end) {
379             OS.SendMessage (handle, OS.LB_SETCURSEL, -1, 0);
380         }
381         return;
382     }
383     /*
384     * Ensure that at least one item is contained in
385     * the range from start to end.  Note that when
386     * start = end, LB_SELITEMRANGEEX deselects the
387     * item.
388     */
389     int count = OS.SendMessage (handle, OS.LB_GETCOUNT, 0, 0);
390     if (start < 0 && end < 0) return;
391     if (start >= count && end >= count) return;
392     start = Math.min (count - 1, Math.max (0, start));
393     end = Math.min (count - 1, Math.max (0, end));
394     OS.SendMessage (handle, OS.LB_SELITEMRANGEEX, end, start);
395 }
396
397 /**
398  * Deselects all selected items in the receiver.
399  *
400  * @exception DWTException <ul>
401  *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
402  *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
403  * </ul>
404  */
405 public void deselectAll () {
406     checkWidget ();
407     if ((style & DWT.SINGLE) !is 0) {
408         OS.SendMessage (handle, OS.LB_SETCURSEL, -1, 0);
409     } else {
410         OS.SendMessage (handle, OS.LB_SETSEL, 0, -1);
411     }
412 }
413
414 /**
415  * Returns the zero-relative index of the item which currently
416  * has the focus in the receiver, or -1 if no item has focus.
417  *
418  * @return the index of the selected item
419  *
420  * @exception DWTException <ul>
421  *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
422  *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
423  * </ul>
424  */
425 public int getFocusIndex () {
426     checkWidget ();
427     int result = OS.SendMessage (handle, OS.LB_GETCARETINDEX, 0, 0);
428     if (result is 0) {
429         int count = OS.SendMessage (handle, OS.LB_GETCOUNT, 0, 0);
430         if (count is 0) return -1;
431     }
432     return result;
433 }
434
435 /**
436  * Returns the item at the given, zero-relative index in the
437  * receiver. Throws an exception if the index is out of range.
438  *
439  * @param index the index of the item to return
440  * @return the item at the given index
441  *
442  * @exception IllegalArgumentException <ul>
443  *    <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)</li>
444  * </ul>
445  * @exception DWTException <ul>
446  *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
447  *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
448  * </ul>
449  */
450 public String getItem (int index) {
451     checkWidget ();
452     int length_ = OS.SendMessage (handle, OS.LB_GETTEXTLEN, index, 0);
453     if (length_ !is OS.LB_ERR) {
454         TCHAR[] buffer = NewTCHARs (getCodePage (), length_ + 1);
455         int result = OS.SendMessage (handle, OS.LB_GETTEXT, index, buffer.ptr);
456         if (result !is OS.LB_ERR) return TCHARsToStr( buffer[0 .. length_] );
457     }
458     int count = OS.SendMessage (handle, OS.LB_GETCOUNT, 0, 0);
459     if (0 <= index && index < count) error (DWT.ERROR_CANNOT_GET_ITEM);
460     error (DWT.ERROR_INVALID_RANGE);
461     return "";
462 }
463
464 /**
465  * Returns the number of items contained in the receiver.
466  *
467  * @return the number of items
468  *
469  * @exception DWTException <ul>
470  *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
471  *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
472  * </ul>
473  */
474 public int getItemCount () {
475     checkWidget ();
476     int result = OS.SendMessage (handle, OS.LB_GETCOUNT, 0, 0);
477     if (result is OS.LB_ERR) error (DWT.ERROR_CANNOT_GET_COUNT);
478     return result;
479 }
480
481 /**
482  * Returns the height of the area which would be used to
483  * display <em>one</em> of the items in the list.
484  *
485  * @return the height of one item
486  *
487  * @exception DWTException <ul>
488  *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
489  *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
490  * </ul>
491  */
492 public int getItemHeight () {
493     checkWidget ();
494     int result = OS.SendMessage (handle, OS.LB_GETITEMHEIGHT, 0, 0);
495     if (result is OS.LB_ERR) error (DWT.ERROR_CANNOT_GET_ITEM_HEIGHT);
496     return result;
497 }
498
499 /**
500  * Returns a (possibly empty) array of <code>String</code>s which
501  * are the items in the receiver.
502  * <p>
503  * Note: This is not the actual structure used by the receiver
504  * to maintain its list of items, so modifying the array will
505  * not affect the receiver.
506  * </p>
507  *
508  * @return the items in the receiver's list
509  *
510  * @exception DWTException <ul>
511  *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
512  *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
513  * </ul>
514  */
515 public String [] getItems () {
516     checkWidget ();
517     int count = getItemCount ();
518     String [] result = new String [count];
519     for (int i=0; i<count; i++) result [i] = getItem (i);
520     return result;
521 }
522
523 /**
524  * Returns an array of <code>String</code>s that are currently
525  * selected in the receiver.  The order of the items is unspecified.
526  * An empty array indicates that no items are selected.
527  * <p>
528  * Note: This is not the actual structure used by the receiver
529  * to maintain its selection, so modifying the array will
530  * not affect the receiver.
531  * </p>
532  * @return an array representing the selection
533  *
534  * @exception DWTException <ul>
535  *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
536  *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
537  * </ul>
538  */
539 public String [] getSelection () {
540     checkWidget ();
541     int [] indices = getSelectionIndices ();
542     String [] result = new String [indices.length];
543     for (int i=0; i<indices.length; i++) {
544         result [i] = getItem (indices [i]);
545     }
546     return result;
547 }
548
549 /**
550  * Returns the number of selected items contained in the receiver.
551  *
552  * @return the number of selected items
553  *
554  * @exception DWTException <ul>
555  *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
556  *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
557  * </ul>
558  */
559 public int getSelectionCount () {
560     checkWidget ();
561     if ((style & DWT.SINGLE) !is 0) {
562         int result = OS.SendMessage (handle, OS.LB_GETCURSEL, 0, 0);
563         if (result is OS.LB_ERR) return 0;
564         return 1;
565     }
566     int result = OS.SendMessage (handle, OS.LB_GETSELCOUNT, 0, 0);
567     if (result is OS.LB_ERR) error (DWT.ERROR_CANNOT_GET_COUNT);
568     return result;
569 }
570
571 /**
572  * Returns the zero-relative index of the item which is currently
573  * selected in the receiver, or -1 if no item is selected.
574  *
575  * @return the index of the selected item or -1
576  *
577  * @exception DWTException <ul>
578  *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
579  *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
580  * </ul>
581  */
582 public int getSelectionIndex () {
583     checkWidget ();
584     if ((style & DWT.SINGLE) !is 0) {
585         return OS.SendMessage (handle, OS.LB_GETCURSEL, 0, 0);
586     }
587     int count = OS.SendMessage (handle, OS.LB_GETSELCOUNT, 0, 0);
588     if (count is OS.LB_ERR) error (DWT.ERROR_CANNOT_GET_SELECTION);
589     if (count is 0) return -1;
590     int index = OS.SendMessage (handle, OS.LB_GETCARETINDEX, 0, 0);
591     int result = OS.SendMessage (handle, OS.LB_GETSEL, index, 0);
592     if (result is OS.LB_ERR) error (DWT.ERROR_CANNOT_GET_SELECTION);
593     if (result !is 0) return index;
594     int buffer;
595     result = OS.SendMessage (handle, OS.LB_GETSELITEMS, 1, &buffer);
596     if (result !is 1) error (DWT.ERROR_CANNOT_GET_SELECTION);
597     return buffer;
598 }
599
600 /**
601  * Returns the zero-relative indices of the items which are currently
602  * selected in the receiver.  The order of the indices is unspecified.