Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/List.java')
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/List.java1180
1 files changed, 590 insertions, 590 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/List.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/List.java
index f0a4ad9438..a47e159cfe 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/List.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/List.java
@@ -1,18 +1,18 @@
-package org.eclipse.swt.widgets;
-
-/*
+package org.eclipse.swt.widgets;
+
+/*
* Copyright (c) 2000, 2002 IBM Corp. All rights reserved.
* This file is made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- */
-
-import org.eclipse.swt.internal.*;
-import org.eclipse.swt.internal.photon.*;
-import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.events.*;
-
+ * http://www.eclipse.org/legal/cpl-v10.html
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+
/**
* Instances of this class represent a selectable user interface
* object that displays a list of strings and issues notificiation
@@ -30,8 +30,8 @@ import org.eclipse.swt.events.*;
* IMPORTANT: This class is <em>not</em> intended to be subclassed.
* </p>
*/
-public class List extends Scrollable {
-
+public class List extends Scrollable {
+
/**
* Constructs a new instance of this class given its parent
* and a style value describing its behavior and appearance.
@@ -61,14 +61,14 @@ public class List extends Scrollable {
* @see Widget#checkSubclass
* @see Widget#getStyle
*/
-public List (Composite parent, int style) {
- super (parent, checkStyle (style));
-}
-
-static int checkStyle (int style) {
- return checkBits (style, SWT.SINGLE, SWT.MULTI, 0, 0, 0, 0);
-}
-
+public List (Composite parent, int style) {
+ super (parent, checkStyle (style));
+}
+
+static int checkStyle (int style) {
+ return checkBits (style, SWT.SINGLE, SWT.MULTI, 0, 0, 0, 0);
+}
+
/**
* Adds the argument to the end of the receiver's list.
*
@@ -87,16 +87,16 @@ static int checkStyle (int style) {
*
* @see #add(String,int)
*/
-public void add (String string) {
- checkWidget();
- if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
- byte [] buffer = Converter.wcsToMbcs (null, string, true);
- int ptr = OS.malloc (buffer.length);
- OS.memmove (ptr, buffer, buffer.length);
- OS.PtListAddItems (handle, new int [] {ptr}, 1, 0);
- OS.free (ptr);
-}
-
+public void add (String string) {
+ checkWidget();
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ byte [] buffer = Converter.wcsToMbcs (null, string, true);
+ int ptr = OS.malloc (buffer.length);
+ OS.memmove (ptr, buffer, buffer.length);
+ OS.PtListAddItems (handle, new int [] {ptr}, 1, 0);
+ OS.free (ptr);
+}
+
/**
* Adds the listener to the collection of listeners who will
* be notified when the receiver's selection changes, by sending
@@ -121,14 +121,14 @@ public void add (String string) {
* @see #removeSelectionListener
* @see SelectionEvent
*/
-public void addSelectionListener(SelectionListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- TypedListener typedListener = new TypedListener (listener);
- addListener (SWT.Selection,typedListener);
- addListener (SWT.DefaultSelection,typedListener);
-}
-
+public void addSelectionListener(SelectionListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Selection,typedListener);
+ addListener (SWT.DefaultSelection,typedListener);
+}
+
/**
* Adds the argument to the receiver's list at the given
* zero-relative index.
@@ -155,108 +155,108 @@ public void addSelectionListener(SelectionListener listener) {
*
* @see #add(String)
*/
-public void add (String string, int index) {
- checkWidget();
- if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (index == -1) error (SWT.ERROR_INVALID_RANGE);
- byte [] buffer = Converter.wcsToMbcs (null, string, true);
- int ptr = OS.malloc (buffer.length);
- OS.memmove (ptr, buffer, buffer.length);
- int result = OS.PtListAddItems (handle, new int [] {ptr}, 1, index + 1);
- OS.free (ptr);
- if (result != 0) {
- int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- if (0 <= index && index <= args [1]) error (SWT.ERROR_ITEM_NOT_ADDED);
- error (SWT.ERROR_INVALID_RANGE);
- }
-}
-
-public Point computeSize (int wHint, int hHint, boolean changed) {
- checkWidget();
-
- int [] args = new int [] {
- OS.Pt_ARG_WIDTH, 0, 0,
- OS.Pt_ARG_HEIGHT, 0, 0,
- OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0,
- };
- OS.PtGetResources (handle, args.length / 3, args);
- int resizeFlags = OS.Pt_RESIZE_X_ALWAYS | OS.Pt_RESIZE_Y_ALWAYS;
- OS.PtSetResource (handle, OS.Pt_ARG_RESIZE_FLAGS, resizeFlags, OS.Pt_RESIZE_XY_BITS);
- if (!OS.PtWidgetIsRealized (handle)) OS.PtExtentWidgetFamily (handle);
- PhDim_t dim = new PhDim_t ();
- OS.PtWidgetPreferredSize (handle, dim);
- int width = dim.w, height = dim.h;
- OS.PtSetResource (handle, OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS);
- OS.PtSetResources (handle, args.length / 3, args);
- if (args [7] <= 0) {
- width += DEFAULT_WIDTH;
- height += DEFAULT_HEIGHT;
- }
+public void add (String string, int index) {
+ checkWidget();
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (index == -1) error (SWT.ERROR_INVALID_RANGE);
+ byte [] buffer = Converter.wcsToMbcs (null, string, true);
+ int ptr = OS.malloc (buffer.length);
+ OS.memmove (ptr, buffer, buffer.length);
+ int result = OS.PtListAddItems (handle, new int [] {ptr}, 1, index + 1);
+ OS.free (ptr);
+ if (result != 0) {
+ int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ if (0 <= index && index <= args [1]) error (SWT.ERROR_ITEM_NOT_ADDED);
+ error (SWT.ERROR_INVALID_RANGE);
+ }
+}
+
+public Point computeSize (int wHint, int hHint, boolean changed) {
+ checkWidget();
+
+ int [] args = new int [] {
+ OS.Pt_ARG_WIDTH, 0, 0,
+ OS.Pt_ARG_HEIGHT, 0, 0,
+ OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0,
+ };
+ OS.PtGetResources (handle, args.length / 3, args);
+ int resizeFlags = OS.Pt_RESIZE_X_ALWAYS | OS.Pt_RESIZE_Y_ALWAYS;
+ OS.PtSetResource (handle, OS.Pt_ARG_RESIZE_FLAGS, resizeFlags, OS.Pt_RESIZE_XY_BITS);
+ if (!OS.PtWidgetIsRealized (handle)) OS.PtExtentWidgetFamily (handle);
+ PhDim_t dim = new PhDim_t ();
+ OS.PtWidgetPreferredSize (handle, dim);
+ int width = dim.w, height = dim.h;
+ OS.PtSetResource (handle, OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS);
+ OS.PtSetResources (handle, args.length / 3, args);
+ if (args [7] <= 0) {
+ width += DEFAULT_WIDTH;
+ height += DEFAULT_HEIGHT;
+ }
- if (wHint != SWT.DEFAULT || hHint != SWT.DEFAULT) {
- PhRect_t rect = new PhRect_t ();
- PhArea_t area = new PhArea_t ();
- rect.lr_x = (short) (wHint - 1);
- rect.lr_y = (short) (hHint - 1);
- OS.PtSetAreaFromWidgetCanvas (handle, rect, area);
- ScrollBar scroll;
- if (wHint != SWT.DEFAULT) {
- width = area.size_w;
- if ((scroll = getVerticalBar()) != null) width += scroll.getSize ().x;
- }
- if (hHint != SWT.DEFAULT) {
- height = area.size_h;
- if ((scroll = getHorizontalBar()) != null) height += scroll.getSize ().y;
- }
- }
- return new Point(width, height);
-}
-
-void createHandle (int index) {
- state |= HANDLE;
- Display display = getDisplay ();
- int clazz = display.PtList;
- int parentHandle = parent.parentingHandle ();
- int mode = OS.Pt_SELECTION_MODE_SINGLE | OS.Pt_SELECTION_MODE_AUTO;
- if ((style & SWT.MULTI) != 0) {
- if ((style & SWT.SIMPLE) != 0) {
- mode = OS.Pt_SELECTION_MODE_MULTIPLE | OS.Pt_SELECTION_MODE_NOCLEAR
- | OS.Pt_SELECTION_MODE_TOGGLE | OS.Pt_SELECTION_MODE_NOMOVE;
- } else {
- mode = OS.Pt_SELECTION_MODE_MULTIPLE | OS.Pt_SELECTION_MODE_AUTO;
- }
- }
- mode |= OS.Pt_SELECTION_MODE_NOFOCUS;
- boolean hasBorder = (style & SWT.BORDER) != 0;
- int listFlags = OS.Pt_LIST_SCROLLBAR_ALWAYS | OS.Pt_LIST_SCROLLBAR_AS_REQUIRED;
- int [] args = {
- OS.Pt_ARG_FLAGS, hasBorder ? OS.Pt_HIGHLIGHTED : 0, OS.Pt_HIGHLIGHTED,
- OS.Pt_ARG_SELECTION_MODE, mode, 0,
- OS.Pt_ARG_FLAGS, OS.Pt_SELECTABLE | OS.Pt_SELECT_NOREDRAW, OS.Pt_SELECTABLE | OS.Pt_SELECT_NOREDRAW,
- OS.Pt_ARG_LIST_FLAGS, (style & SWT.V_SCROLL) != 0 ? OS.Pt_LIST_SCROLLBAR_AS_REQUIRED : 0, listFlags,
- OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
- };
- handle = OS.PtCreateWidget (clazz, parentHandle, args.length / 3, args);
- if (handle == 0) error (SWT.ERROR_NO_HANDLES);
- createStandardScrollBars ();
-}
-
-int defaultBackground () {
- Display display = getDisplay ();
- return display.LIST_BACKGROUND;
-}
-
-byte [] defaultFont () {
- Display display = getDisplay ();
- return display.LIST_FONT;
-}
-
-int defaultForeground () {
- Display display = getDisplay ();
- return display.LIST_FOREGROUND;
-}
-
+ if (wHint != SWT.DEFAULT || hHint != SWT.DEFAULT) {
+ PhRect_t rect = new PhRect_t ();
+ PhArea_t area = new PhArea_t ();
+ rect.lr_x = (short) (wHint - 1);
+ rect.lr_y = (short) (hHint - 1);
+ OS.PtSetAreaFromWidgetCanvas (handle, rect, area);
+ ScrollBar scroll;
+ if (wHint != SWT.DEFAULT) {
+ width = area.size_w;
+ if ((scroll = getVerticalBar()) != null) width += scroll.getSize ().x;
+ }
+ if (hHint != SWT.DEFAULT) {
+ height = area.size_h;
+ if ((scroll = getHorizontalBar()) != null) height += scroll.getSize ().y;
+ }
+ }
+ return new Point(width, height);
+}
+
+void createHandle (int index) {
+ state |= HANDLE;
+ Display display = getDisplay ();
+ int clazz = display.PtList;
+ int parentHandle = parent.parentingHandle ();
+ int mode = OS.Pt_SELECTION_MODE_SINGLE | OS.Pt_SELECTION_MODE_AUTO;
+ if ((style & SWT.MULTI) != 0) {
+ if ((style & SWT.SIMPLE) != 0) {
+ mode = OS.Pt_SELECTION_MODE_MULTIPLE | OS.Pt_SELECTION_MODE_NOCLEAR
+ | OS.Pt_SELECTION_MODE_TOGGLE | OS.Pt_SELECTION_MODE_NOMOVE;
+ } else {
+ mode = OS.Pt_SELECTION_MODE_MULTIPLE | OS.Pt_SELECTION_MODE_AUTO;
+ }
+ }
+ mode |= OS.Pt_SELECTION_MODE_NOFOCUS;
+ boolean hasBorder = (style & SWT.BORDER) != 0;
+ int listFlags = OS.Pt_LIST_SCROLLBAR_ALWAYS | OS.Pt_LIST_SCROLLBAR_AS_REQUIRED;
+ int [] args = {
+ OS.Pt_ARG_FLAGS, hasBorder ? OS.Pt_HIGHLIGHTED : 0, OS.Pt_HIGHLIGHTED,
+ OS.Pt_ARG_SELECTION_MODE, mode, 0,
+ OS.Pt_ARG_FLAGS, OS.Pt_SELECTABLE | OS.Pt_SELECT_NOREDRAW, OS.Pt_SELECTABLE | OS.Pt_SELECT_NOREDRAW,
+ OS.Pt_ARG_LIST_FLAGS, (style & SWT.V_SCROLL) != 0 ? OS.Pt_LIST_SCROLLBAR_AS_REQUIRED : 0, listFlags,
+ OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
+ };
+ handle = OS.PtCreateWidget (clazz, parentHandle, args.length / 3, args);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+ createStandardScrollBars ();
+}
+
+int defaultBackground () {
+ Display display = getDisplay ();
+ return display.LIST_BACKGROUND;
+}
+
+byte [] defaultFont () {
+ Display display = getDisplay ();
+ return display.LIST_FONT;
+}
+
+int defaultForeground () {
+ Display display = getDisplay ();
+ return display.LIST_FOREGROUND;
+}
+
/**
* Deselects the item at the given zero-relative index in the receiver.
* If the item at the index was already deselected, it remains
@@ -269,12 +269,12 @@ int defaultForeground () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void deselect (int index) {
- checkWidget();
- if (index < 0) return;
- OS.PtListUnselectPos (handle, index + 1);
-}
-
+public void deselect (int index) {
+ checkWidget();
+ if (index < 0) return;
+ OS.PtListUnselectPos (handle, index + 1);
+}
+
/**
* Deselects the items at the given zero-relative indices in the receiver.
* If the item at the given zero-relative index in the receiver
@@ -290,22 +290,22 @@ public void deselect (int index) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void deselect (int start, int end) {
- checkWidget();
- if (start > end) return;
- if ((style & SWT.SINGLE) != 0) {
- int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- int count = args [1];
- int index = Math.min (count - 1, end);
- if (index >= start) deselect (index);
- return;
- }
- for (int i=start; i<=end; i++) {
- OS.PtListUnselectPos (handle, i + 1);
- }
-}
-
+public void deselect (int start, int end) {
+ checkWidget();
+ if (start > end) return;
+ if ((style & SWT.SINGLE) != 0) {
+ int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ int count = args [1];
+ int index = Math.min (count - 1, end);
+ if (index >= start) deselect (index);
+ return;
+ }
+ for (int i=start; i<=end; i++) {
+ OS.PtListUnselectPos (handle, i + 1);
+ }
+}
+
/**
* Deselects the items at the given zero-relative indices in the receiver.
* If the item at the given zero-relative index in the receiver
@@ -323,18 +323,18 @@ public void deselect (int start, int end) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void deselect (int [] indices) {
- checkWidget();
- if (indices == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (indices.length == 0) return;
- for (int i=0; i<indices.length; i++) {
- int index = indices [i];
- if (index != -1) {
- OS.PtListUnselectPos (handle, index + 1);
- }
- }
-}
-
+public void deselect (int [] indices) {
+ checkWidget();
+ if (indices == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (indices.length == 0) return;
+ for (int i=0; i<indices.length; i++) {
+ int index = indices [i];
+ if (index != -1) {
+ OS.PtListUnselectPos (handle, index + 1);
+ }
+ }
+}
+
/**
* Deselects all selected items in the receiver.
*
@@ -343,16 +343,16 @@ public void deselect (int [] indices) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void deselectAll () {
- checkWidget();
- int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- int count = args [1];
- for (int i=0; i<count; i++) {
- OS.PtListUnselectPos (handle, i + 1);
- }
-}
-
+public void deselectAll () {
+ checkWidget();
+ int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ int count = args [1];
+ for (int i=0; i<count; i++) {
+ OS.PtListUnselectPos (handle, i + 1);
+ }
+}
+
/**
* Returns the zero-relative index of the item which is currently
* has the focus in the receiver, or -1 if no item is has focus.
@@ -364,10 +364,10 @@ public void deselectAll () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getFocusIndex () {
- return getSelectionIndex ();
-}
-
+public int getFocusIndex () {
+ return getSelectionIndex ();
+}
+
/**
* Returns the item at the given, zero-relative index in the
* receiver. Throws an exception if the index is out of range.
@@ -386,25 +386,25 @@ public int getFocusIndex () {
* <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure</li>
* </ul>
*/
-public String getItem (int index) {
- checkWidget();
- int [] args = new int [] {
- OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0,
- OS.Pt_ARG_ITEMS, 0, 0,
- };
- OS.PtGetResources (handle, args.length / 3, args);
- if (!(0 <= index && index < args [1])) {
- error (SWT.ERROR_INVALID_RANGE);
- }
- int [] items = new int [1];
- OS.memmove (items, args [4] + (index * 4), 4);
- int length = OS.strlen (items [0]);
- byte [] buffer = new byte [length];
- OS.memmove (buffer, items [0], length);
- char [] unicode = Converter.mbcsToWcs (null, buffer);
- return new String (unicode);
-}
-
+public String getItem (int index) {
+ checkWidget();
+ int [] args = new int [] {
+ OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0,
+ OS.Pt_ARG_ITEMS, 0, 0,
+ };
+ OS.PtGetResources (handle, args.length / 3, args);
+ if (!(0 <= index && index < args [1])) {
+ error (SWT.ERROR_INVALID_RANGE);
+ }
+ int [] items = new int [1];
+ OS.memmove (items, args [4] + (index * 4), 4);
+ int length = OS.strlen (items [0]);
+ byte [] buffer = new byte [length];
+ OS.memmove (buffer, items [0], length);
+ char [] unicode = Converter.mbcsToWcs (null, buffer);
+ return new String (unicode);
+}
+
/**
* Returns the number of items contained in the receiver.
*
@@ -418,13 +418,13 @@ public String getItem (int index) {
* <li>ERROR_CANNOT_GET_COUNT - if the operation fails because of an operating system failure</li>
* </ul>
*/
-public int getItemCount () {
- checkWidget();
- int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- return args [1];
-}
-
+public int getItemCount () {
+ checkWidget();
+ int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
/**
* Returns the height of the area which would be used to
* display <em>one</em> of the items in the tree.
@@ -439,25 +439,25 @@ public int getItemCount () {
* <li>ERROR_CANNOT_GET_ITEM_HEIGHT - if the operation fails because of an operating system failure</li>
* </ul>
*/
-public int getItemHeight () {
- checkWidget();
- int [] args = new int [] {
- OS.Pt_ARG_LIST_TOTAL_HEIGHT, 0, 0,
- OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0,
- OS.Pt_ARG_LIST_FONT, 0, 0,
- };
- OS.PtGetResources (handle, args.length / 3, args);
- if (args [4] == 0) {
- int ptr = OS.malloc(1);
- PhRect_t rect = new PhRect_t ();
- OS.PfExtentText(rect, null, args [7], ptr, 1);
- OS.free(ptr);
- int inset = 4;
- return inset + (rect.lr_y - rect.ul_y + 1);
- }
- return args [1] / args [4];
-}
-
+public int getItemHeight () {
+ checkWidget();
+ int [] args = new int [] {
+ OS.Pt_ARG_LIST_TOTAL_HEIGHT, 0, 0,
+ OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0,
+ OS.Pt_ARG_LIST_FONT, 0, 0,
+ };
+ OS.PtGetResources (handle, args.length / 3, args);
+ if (args [4] == 0) {
+ int ptr = OS.malloc(1);
+ PhRect_t rect = new PhRect_t ();
+ OS.PfExtentText(rect, null, args [7], ptr, 1);
+ OS.free(ptr);
+ int inset = 4;
+ return inset + (rect.lr_y - rect.ul_y + 1);
+ }
+ return args [1] / args [4];
+}
+
/**
* Returns an array of <code>String</code>s which are the items
* in the receiver.
@@ -478,27 +478,27 @@ public int getItemHeight () {
* <li>ERROR_CANNOT_GET_COUNT - if the operation fails because of an operating system failure while getting the item count</li>
* </ul>
*/
-public String [] getItems () {
- checkWidget();
- int [] args = new int [] {
- OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0,
- OS.Pt_ARG_ITEMS, 0, 0,
- };
- OS.PtGetResources (handle, args.length / 3, args);
- int [] items = new int [args [1]];
- OS.memmove (items, args [4], args [1] * 4);
- String [] result = new String [args [1]];
- for (int i=0; i<args [1]; i++) {
- int length = OS.strlen (items [i]);
- byte [] buffer = new byte [length];
- OS.memmove (buffer, items [i], length);
- char [] unicode = Converter.mbcsToWcs (null, buffer);
- result [i] = new String (unicode);
- }
- return result;
-
-}
-
+public String [] getItems () {
+ checkWidget();
+ int [] args = new int [] {
+ OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0,
+ OS.Pt_ARG_ITEMS, 0, 0,
+ };
+ OS.PtGetResources (handle, args.length / 3, args);
+ int [] items = new int [args [1]];
+ OS.memmove (items, args [4], args [1] * 4);
+ String [] result = new String [args [1]];
+ for (int i=0; i<args [1]; i++) {
+ int length = OS.strlen (items [i]);
+ byte [] buffer = new byte [length];
+ OS.memmove (buffer, items [i], length);
+ char [] unicode = Converter.mbcsToWcs (null, buffer);
+ result [i] = new String (unicode);
+ }
+ return result;
+
+}
+
/**
* Returns an array of <code>String</code>s that are currently
* selected in the receiver. An empty array indicates that no
@@ -519,16 +519,16 @@ public String [] getItems () {
* <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure while getting an item</li>
* </ul>
*/
-public String [] getSelection () {
- checkWidget();
- int [] indices = getSelectionIndices ();
- String [] result = new String [indices.length];
- for (int i=0; i<indices.length; i++) {
- result [i] = getItem (indices [i]);
- }
- return result;
-}
-
+public String [] getSelection () {
+ checkWidget();
+ int [] indices = getSelectionIndices ();
+ String [] result = new String [indices.length];
+ for (int i=0; i<indices.length; i++) {
+ result [i] = getItem (indices [i]);
+ }
+ return result;
+}
+
/**
* Returns the number of selected items contained in the receiver.
*
@@ -542,13 +542,13 @@ public String [] getSelection () {
* <li>ERROR_CANNOT_GET_COUNT - if the operation fails because of an operating system failure</li>
* </ul>
*/
-public int getSelectionCount () {
- checkWidget();
- int [] args = new int [] {OS.Pt_ARG_LIST_SEL_COUNT, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- return args [1];
-}
-
+public int getSelectionCount () {
+ checkWidget();
+ int [] args = new int [] {OS.Pt_ARG_LIST_SEL_COUNT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
/**
* Returns the zero-relative index of the item which is currently
* selected in the receiver, or -1 if no item is selected.
@@ -563,19 +563,19 @@ public int getSelectionCount () {
* <li>ERROR_CANNOT_GET_SELECTION - if the operation fails because of an operating system failure</li>
* </ul>
*/
-public int getSelectionIndex () {
- checkWidget();
- int [] args = new int [] {
- OS.Pt_ARG_LIST_SEL_COUNT, 0, 0,
- OS.Pt_ARG_SELECTION_INDEXES, 0, 0,
- };
- OS.PtGetResources (handle, args.length / 3, args);
- if (args [1] == 0) return -1;
- short [] buffer = new short [1];
- OS.memmove (buffer, args [4], 2);
- return buffer [0] - 1;
-}
-
+public int getSelectionIndex () {
+ checkWidget();
+ int [] args = new int [] {
+ OS.Pt_ARG_LIST_SEL_COUNT, 0, 0,
+ OS.Pt_ARG_SELECTION_INDEXES, 0, 0,
+ };
+ OS.PtGetResources (handle, args.length / 3, args);
+ if (args [1] == 0) return -1;
+ short [] buffer = new short [1];
+ OS.memmove (buffer, args [4], 2);
+ return buffer [0] - 1;
+}
+
/**
* Returns the zero-relative indices of the items which are currently
* selected in the receiver. The array is empty if no items are selected.
@@ -594,22 +594,22 @@ public int getSelectionIndex () {
* <li>ERROR_CANNOT_GET_SELECTION - if the operation fails because of an operating system failure</li>
* </ul>
*/
-public int [] getSelectionIndices () {
- checkWidget();
- int [] args = new int [] {
- OS.Pt_ARG_LIST_SEL_COUNT, 0, 0,
- OS.Pt_ARG_SELECTION_INDEXES, 0, 0,
- };
- OS.PtGetResources (handle, args.length / 3, args);
- short [] indices = new short [args [1]];
- OS.memmove (indices, args [4], args [1] * 2);
- int [] result = new int [args [1]];
- for (int i=0; i<args [1]; i++) {
- result [i] = indices [i] - 1;
- }
- return result;
-}
-
+public int [] getSelectionIndices () {
+ checkWidget();
+ int [] args = new int [] {
+ OS.Pt_ARG_LIST_SEL_COUNT, 0, 0,
+ OS.Pt_ARG_SELECTION_INDEXES, 0, 0,
+ };
+ OS.PtGetResources (handle, args.length / 3, args);
+ short [] indices = new short [args [1]];
+ OS.memmove (indices, args [4], args [1] * 2);
+ int [] result = new int [args [1]];
+ for (int i=0; i<args [1]; i++) {
+ result [i] = indices [i] - 1;
+ }
+ return result;
+}
+
/**
* Returns the zero-relative index of the item which is currently
* at the top of the receiver. This index can change when items are
@@ -622,20 +622,20 @@ public int [] getSelectionIndices () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int getTopIndex () {
- checkWidget();
- int [] args = new int [] {OS.Pt_ARG_TOP_ITEM_POS, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- return args [1] - 1;
-}
-
-void hookEvents () {
- super.hookEvents ();
- int windowProc = getDisplay ().windowProc;
- OS.PtAddCallback (handle, OS.Pt_CB_SELECTION, windowProc, OS.Pt_CB_SELECTION);
- OS.PtAddCallback (handle, OS.Pt_CB_ACTIVATE, windowProc, OS.Pt_CB_ACTIVATE);
-}
-
+public int getTopIndex () {
+ checkWidget();
+ int [] args = new int [] {OS.Pt_ARG_TOP_ITEM_POS, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1] - 1;
+}
+
+void hookEvents () {
+ super.hookEvents ();
+ int windowProc = getDisplay ().windowProc;
+ OS.PtAddCallback (handle, OS.Pt_CB_SELECTION, windowProc, OS.Pt_CB_SELECTION);
+ OS.PtAddCallback (handle, OS.Pt_CB_ACTIVATE, windowProc, OS.Pt_CB_ACTIVATE);
+}
+
/**
* Gets the index of an item.
* <p>
@@ -655,12 +655,12 @@ void hookEvents () {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public int indexOf (String string) {
- checkWidget();
- byte [] buffer = Converter.wcsToMbcs (null, string, true);
- return OS.PtListItemPos (handle, buffer) - 1;
-}
-
+public int indexOf (String string) {
+ checkWidget();
+ byte [] buffer = Converter.wcsToMbcs (null, string, true);
+ return OS.PtListItemPos (handle, buffer) - 1;
+}
+
/**
* Searches the receiver's list starting at the given,
* zero-relative index until an item is found that is equal
@@ -683,28 +683,28 @@ public int indexOf (String string) {
* <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure while getting an item</li>
* </ul>
*/
-public int indexOf (String string, int start) {
- checkWidget();
- if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (start == 0) return indexOf(string);
- int [] args = new int [] {
- OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0,
- OS.Pt_ARG_ITEMS, 0, 0,
- };
- OS.PtGetResources (handle, args.length / 3, args);
- int count = args [1];
- if (!(0 <= start && start < count)) return -1;
- int [] item = new int [1];
- for (int index=start; index<count; index++) {
- OS.memmove (item, args [4] + (index * 4), 4);
- int length = OS.strlen (item [0]);
- byte [] buffer = new byte [length];
- OS.memmove (buffer, item [0], length);
- if (string.equals(new String (Converter.mbcsToWcs (null, buffer)))) return index;
- }
- return -1;
-}
-
+public int indexOf (String string, int start) {
+ checkWidget();
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (start == 0) return indexOf(string);
+ int [] args = new int [] {
+ OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0,
+ OS.Pt_ARG_ITEMS, 0, 0,
+ };
+ OS.PtGetResources (handle, args.length / 3, args);
+ int count = args [1];
+ if (!(0 <= start && start < count)) return -1;
+ int [] item = new int [1];
+ for (int index=start; index<count; index++) {
+ OS.memmove (item, args [4] + (index * 4), 4);
+ int length = OS.strlen (item [0]);
+ byte [] buffer = new byte [length];
+ OS.memmove (buffer, item [0], length);
+ if (string.equals(new String (Converter.mbcsToWcs (null, buffer)))) return index;
+ }
+ return -1;
+}
+
/**
* Returns <code>true</code> if the item is selected,
* and <code>false</code> otherwise. Indices out of
@@ -718,37 +718,37 @@ public int indexOf (String string, int start) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public boolean isSelected (int index) {
- checkWidget();
- int [] args = new int [] {
- OS.Pt_ARG_LIST_SEL_COUNT, 0, 0,
- OS.Pt_ARG_SELECTION_INDEXES, 0, 0,
- };
- OS.PtGetResources (handle, args.length / 3, args);
- short [] buffer = new short [1];
- for (int i=0; i<args [1]; i++) {
- OS.memmove (buffer, args [4] + (i * 2), 2);
- if (buffer [0] == index + 1) return true;
- }
- return false;
-}
-
-int Pt_CB_ACTIVATE (int widget, int info) {
- if (info == 0) return OS.Pt_END;
- PtCallbackInfo_t cbinfo = new PtCallbackInfo_t ();
- OS.memmove (cbinfo, info, PtCallbackInfo_t.sizeof);
- if (cbinfo.cbdata == 0) return OS.Pt_END;
- int[] click_count = new int [1];
- OS.memmove(click_count, cbinfo.cbdata, 4);
- if (click_count [0] > 1) postEvent (SWT.DefaultSelection);
- return OS.Pt_CONTINUE;
-}
-
-int Pt_CB_SELECTION (int widget, int info) {
- postEvent (SWT.Selection);
- return OS.Pt_CONTINUE;
-}
-
+public boolean isSelected (int index) {
+ checkWidget();
+ int [] args = new int [] {
+ OS.Pt_ARG_LIST_SEL_COUNT, 0, 0,
+ OS.Pt_ARG_SELECTION_INDEXES, 0, 0,
+ };
+ OS.PtGetResources (handle, args.length / 3, args);
+ short [] buffer = new short [1];
+ for (int i=0; i<args [1]; i++) {
+ OS.memmove (buffer, args [4] + (i * 2), 2);
+ if (buffer [0] == index + 1) return true;
+ }
+ return false;
+}
+
+int Pt_CB_ACTIVATE (int widget, int info) {
+ if (info == 0) return OS.Pt_END;
+ PtCallbackInfo_t cbinfo = new PtCallbackInfo_t ();
+ OS.memmove (cbinfo, info, PtCallbackInfo_t.sizeof);
+ if (cbinfo.cbdata == 0) return OS.Pt_END;
+ int[] click_count = new int [1];
+ OS.memmove(click_count, cbinfo.cbdata, 4);
+ if (click_count [0] > 1) postEvent (SWT.DefaultSelection);
+ return OS.Pt_CONTINUE;
+}
+
+int Pt_CB_SELECTION (int widget, int info) {
+ postEvent (SWT.Selection);
+ return OS.Pt_CONTINUE;
+}
+
/**
* Removes the item from the receiver at the given
* zero-relative index.
@@ -766,15 +766,15 @@ int Pt_CB_SELECTION (int widget, int info) {
* <li>ERROR_ITEM_NOT_REMOVED - if the operation fails because of an operating system failure</li>
* </ul>
*/
-public void remove (int index) {
- checkWidget();
- int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- if (!(0 <= index && index < args [1])) error (SWT.ERROR_INVALID_RANGE);
- int result = OS.PtListDeleteItemPos (handle, 1, index + 1);
- if (result != 0) error (SWT.ERROR_ITEM_NOT_REMOVED);
-}
-
+public void remove (int index) {
+ checkWidget();
+ int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ if (!(0 <= index && index < args [1])) error (SWT.ERROR_INVALID_RANGE);
+ int result = OS.PtListDeleteItemPos (handle, 1, index + 1);
+ if (result != 0) error (SWT.ERROR_ITEM_NOT_REMOVED);
+}
+
/**
* Searches the receiver's list starting at the first item
* until an item is found that is equal to the argument,
@@ -794,13 +794,13 @@ public void remove (int index) {
* <li>ERROR_ITEM_NOT_REMOVED - if the operation fails because of an operating system failure</li>
* </ul>
*/
-public void remove (String string) {
- checkWidget();
- int index = indexOf (string, 0);
- if (index == -1) error (SWT.ERROR_ITEM_NOT_REMOVED);
- remove (index);
-}
-
+public void remove (String string) {
+ checkWidget();
+ int index = indexOf (string, 0);
+ if (index == -1) error (SWT.ERROR_ITEM_NOT_REMOVED);
+ remove (index);
+}
+
/**
* Removes the items from the receiver at the given
* zero-relative indices.
@@ -818,23 +818,23 @@ public void remove (String string) {
* <li>ERROR_ITEM_NOT_REMOVED - if the operation fails because of an operating system failure</li>
* </ul>
*/
-public void remove (int [] indices) {
- checkWidget();
- if (indices == null) error (SWT.ERROR_NULL_ARGUMENT);
- int [] newIndices = new int [indices.length];
- System.arraycopy (indices, 0, newIndices, 0, indices.length);
- sort (newIndices);
- int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- int count = args [1];
- for (int i=0; i<newIndices.length; i++ ) {
- int index = newIndices [i];
- if (!(0 <= index && index < count)) error (SWT.ERROR_INVALID_RANGE);
- int result = OS.PtListDeleteItemPos (handle, 1, index + 1);
- if (result != 0) error (SWT.ERROR_ITEM_NOT_REMOVED);
- }
-}
-
+public void remove (int [] indices) {
+ checkWidget();
+ if (indices == null) error (SWT.ERROR_NULL_ARGUMENT);
+ int [] newIndices = new int [indices.length];
+ System.arraycopy (indices, 0, newIndices, 0, indices.length);
+ sort (newIndices);
+ int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ int count = args [1];
+ for (int i=0; i<newIndices.length; i++ ) {
+ int index = newIndices [i];
+ if (!(0 <= index && index < count)) error (SWT.ERROR_INVALID_RANGE);
+ int result = OS.PtListDeleteItemPos (handle, 1, index + 1);
+ if (result != 0) error (SWT.ERROR_ITEM_NOT_REMOVED);
+ }
+}
+
/**
* Removes the items from the receiver which are
* between the given zero-relative start and end
@@ -854,18 +854,18 @@ public void remove (int [] indices) {
* <li>ERROR_ITEM_NOT_REMOVED - if the operation fails because of an operating system failure</li>
* </ul>
*/
-public void remove (int start, int end) {
- checkWidget();
- int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- if (!(0 <= start && start <= end && end < args [1])) {
- error (SWT.ERROR_INVALID_RANGE);
- }
- int count = end - start + 1;
- int result = OS.PtListDeleteItemPos (handle, count, start + 1);
- if (result != 0) error (SWT.ERROR_ITEM_NOT_REMOVED);
-}
-
+public void remove (int start, int end) {
+ checkWidget();
+ int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ if (!(0 <= start && start <= end && end < args [1])) {
+ error (SWT.ERROR_INVALID_RANGE);
+ }
+ int count = end - start + 1;
+ int result = OS.PtListDeleteItemPos (handle, count, start + 1);
+ if (result != 0) error (SWT.ERROR_ITEM_NOT_REMOVED);
+}
+
/**
* Removes all of the items from the receiver.
* <p>
@@ -874,11 +874,11 @@ public void remove (int start, int end) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void removeAll () {
- checkWidget();
- OS.PtListDeleteAllItems (handle);
-}
-
+public void removeAll () {
+ checkWidget();
+ OS.PtListDeleteAllItems (handle);
+}
+
/**
* Removes the listener from the collection of listeners who will
* be notified when the receiver's selection changes.
@@ -896,14 +896,14 @@ public void removeAll () {
* @see SelectionListener
* @see #addSelectionListener
*/
-public void removeSelectionListener(SelectionListener listener) {
- checkWidget();
- if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (eventTable == null) return;
- eventTable.unhook (SWT.Selection, listener);
- eventTable.unhook (SWT.DefaultSelection,listener);
-}
-
+public void removeSelectionListener(SelectionListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Selection, listener);
+ eventTable.unhook (SWT.DefaultSelection,listener);
+}
+
/**
* Selects the items at the given zero-relative indices in the receiver.
* If the item at the index was already selected, it remains
@@ -918,27 +918,27 @@ public void removeSelectionListener(SelectionListener listener) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void select (int start, int end) {
- checkWidget();
- if (start > end) return;
- int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- int count = args [1];
- if ((style & SWT.SINGLE) != 0) {
- int index = Math.min (count - 1, end);
- if (index >= start) select (index);
- return;
- }
- int gotoIndex = -1;
- for (int index=end; index>=start; index--) {
- if (0 <= index && index < count) {
- gotoIndex = index;
- OS.PtListSelectPos (handle, index + 1);
- }
- }
- if (gotoIndex != -1) OS.PtListGotoPos (handle, gotoIndex + 1);
-}
-
+public void select (int start, int end) {
+ checkWidget();
+ if (start > end) return;
+ int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ int count = args [1];
+ if ((style & SWT.SINGLE) != 0) {
+ int index = Math.min (count - 1, end);
+ if (index >= start) select (index);
+ return;
+ }
+ int gotoIndex = -1;
+ for (int index=end; index>=start; index--) {
+ if (0 <= index && index < count) {
+ gotoIndex = index;
+ OS.PtListSelectPos (handle, index + 1);
+ }
+ }
+ if (gotoIndex != -1) OS.PtListGotoPos (handle, gotoIndex + 1);
+}
+
/**
* Selects the items at the given zero-relative indices in the receiver.
* If the item at the given zero-relative index in the receiver
@@ -956,24 +956,24 @@ public void select (int start, int end) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void select (int [] indices) {
- checkWidget();
- if (indices == null) error (SWT.ERROR_NULL_ARGUMENT);
- if (indices.length == 0) return;
- int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- int count = args [1];
- int gotoIndex = -1;
- for (int i=0; i<indices.length; i++) {
- int index = indices [i];
- if (0 <= index && index < count) {
- gotoIndex = index;
- OS.PtListSelectPos (handle, index + 1);
- }
- }
- if (gotoIndex != -1) OS.PtListGotoPos (handle, gotoIndex + 1);
-}
-
+public void select (int [] indices) {
+ checkWidget();
+ if (indices == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (indices.length == 0) return;
+ int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ int count = args [1];
+ int gotoIndex = -1;
+ for (int i=0; i<indices.length; i++) {
+ int index = indices [i];
+ if (0 <= index && index < count) {
+ gotoIndex = index;
+ OS.PtListSelectPos (handle, index + 1);
+ }
+ }
+ if (gotoIndex != -1) OS.PtListGotoPos (handle, gotoIndex + 1);
+}
+
/**
* Selects the item at the given zero-relative index in the receiver's
* list. If the item at the index was already selected, it remains
@@ -986,17 +986,17 @@ public void select (int [] indices) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void select (int index) {
- checkWidget();
- if (index < 0) return;
- int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- if (index < args [1]) {
- OS.PtListSelectPos (handle, index + 1);
- OS.PtListGotoPos (handle, index + 1);
- }
-}
-
+public void select (int index) {
+ checkWidget();
+ if (index < 0) return;
+ int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ if (index < args [1]) {
+ OS.PtListSelectPos (handle, index + 1);
+ OS.PtListGotoPos (handle, index + 1);
+ }
+}
+
/**
* Selects all the items in the receiver.
*
@@ -1005,17 +1005,17 @@ public void select (int index) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void selectAll () {
- checkWidget();
- if ((style & SWT.SINGLE) != 0) return;
- int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- int count = args [1];
- for (int i=0; i<count; i++) {
- OS.PtListSelectPos (handle, i + 1);
- }
-}
-
+public void selectAll () {
+ checkWidget();
+ if ((style & SWT.SINGLE) != 0) return;
+ int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ int count = args [1];
+ for (int i=0; i<count; i++) {
+ OS.PtListSelectPos (handle, i + 1);
+ }
+}
+
/**
* Sets the text of the item in the receiver's list at the given
* zero-relative index to the string argument. This is equivalent
@@ -1037,21 +1037,21 @@ public void selectAll () {
* <li>ERROR_ITEM_NOT_ADDED - if the add operation fails because of an operating system failure</li>
* </ul>
*/
-public void setItem (int index, String string) {
- checkWidget();
- if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
- int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
- OS.PtGetResources (handle, args.length / 3, args);
- if (!(0 <= index && index < args [1])) {
- error (SWT.ERROR_INVALID_RANGE);
- }
- byte [] buffer = Converter.wcsToMbcs (null, string, true);
- int ptr = OS.malloc (buffer.length);
- OS.memmove (ptr, buffer, buffer.length);
- OS.PtListReplaceItemPos (handle, new int [] {ptr}, 1, index + 1);
- OS.free (ptr);
-}
-
+public void setItem (int index, String string) {
+ checkWidget();
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ if (!(0 <= index && index < args [1])) {
+ error (SWT.ERROR_INVALID_RANGE);
+ }
+ byte [] buffer = Converter.wcsToMbcs (null, string, true);
+ int ptr = OS.malloc (buffer.length);
+ OS.memmove (ptr, buffer, buffer.length);
+ OS.PtListReplaceItemPos (handle, new int [] {ptr}, 1, index + 1);
+ OS.free (ptr);
+}
+
/**
* Sets the receiver's items to be the given array of items.
*
@@ -1065,23 +1065,23 @@ public void setItem (int index, String string) {
* <li>ERROR_ITEM_NOT_ADDED - if the operation fails because of an operating system failure</li>
* </ul>
*/
-public void setItems (String [] items) {
- checkWidget();
- if (items == null) error (SWT.ERROR_NULL_ARGUMENT);
- OS.PtListDeleteAllItems (handle);
- int[] itemsPtr = new int [items.length];
- for (int i=0; i<itemsPtr.length; i++) {
- byte [] buffer = Converter.wcsToMbcs (null, items [i], true);
- int ptr = OS.malloc (buffer.length);
- OS.memmove (ptr, buffer, buffer.length);
- itemsPtr [i] = ptr;
- }
- OS.PtListAddItems (handle, itemsPtr, itemsPtr.length, 0);
- for (int i=0; i<itemsPtr.length; i++) {
- OS.free (itemsPtr [i]);
- }
-}
-
+public void setItems (String [] items) {
+ checkWidget();
+ if (items == null) error (SWT.ERROR_NULL_ARGUMENT);
+ OS.PtListDeleteAllItems (handle);
+ int[] itemsPtr = new int [items.length];
+ for (int i=0; i<itemsPtr.length; i++) {
+ byte [] buffer = Converter.wcsToMbcs (null, items [i], true);
+ int ptr = OS.malloc (buffer.length);
+ OS.memmove (ptr, buffer, buffer.length);
+ itemsPtr [i] = ptr;
+ }
+ OS.PtListAddItems (handle, itemsPtr, itemsPtr.length, 0);
+ for (int i=0; i<itemsPtr.length; i++) {
+ OS.free (itemsPtr [i]);
+ }
+}
+
/**
* Selects the items at the given zero-relative indices in the receiver.
* The current selected if first cleared, then the new items are selected.
@@ -1097,11 +1097,11 @@ public void setItems (String [] items) {
* @see Table#deselectAll()
* @see Table#select(int,int)
*/
-public void setSelection (int start, int end) {
- if ((style & SWT.MULTI) != 0) deselectAll ();
- select (start, end);
-}
-
+public void setSelection (int start, int end) {
+ if ((style & SWT.MULTI) != 0) deselectAll ();
+ select (start, end);
+}
+
/**
* Selects the item at the given zero-relative index in the receiver.
* If the item at the index was already selected, it remains selected.
@@ -1117,11 +1117,11 @@ public void setSelection (int start, int end) {
* @see List#deselectAll()
* @see List#select(int)
*/
-public void setSelection (int index) {
- if ((style & SWT.MULTI) != 0) deselectAll ();
- select (index);
-}
-
+public void setSelection (int index) {
+ if ((style & SWT.MULTI) != 0) deselectAll ();
+ select (index);
+}
+
/**
* Selects the items at the given zero-relative indices in the receiver.
* The current selection is first cleared, then the new items are selected.
@@ -1139,11 +1139,11 @@ public void setSelection (int index) {
* @see List#deselectAll()
* @see List#select(int[])
*/
-public void setSelection(int[] indices) {
- deselectAll ();
- select (indices);
-}
-
+public void setSelection(int[] indices) {
+ deselectAll ();
+ select (indices);
+}
+
/**
* Sets the receiver's selection to be the given array of items.
* The current selected is first cleared, then the new items are
@@ -1162,24 +1162,24 @@ public void setSelection(int[] indices) {
* @see List#deselectAll()
* @see List#select(int)
*/
-public void setSelection (String [] items) {
- checkWidget();
- if (items == null) error (SWT.ERROR_NULL_ARGUMENT);
- if ((style & SWT.MULTI) != 0) deselectAll ();
- for (int i=items.length-1; i>=0; --i) {
- int index = 0;
- String string = items [i];
- if (string != null) {
- while ((index = indexOf (string, index)) != -1) {
- select (index);
- if (((style & SWT.SINGLE) != 0) && isSelected (index)) return;
- index++;
- }
- }
- }
- if ((style & SWT.SINGLE) != 0) deselectAll ();
-}
-
+public void setSelection (String [] items) {
+ checkWidget();
+ if (items == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if ((style & SWT.MULTI) != 0) deselectAll ();
+ for (int i=items.length-1; i>=0; --i) {
+ int index = 0;
+ String string = items [i];
+ if (string != null) {
+ while ((index = indexOf (string, index)) != -1) {
+ select (index);
+ if (((style & SWT.SINGLE) != 0) && isSelected (index)) return;
+ index++;
+ }
+ }
+ }
+ if ((style & SWT.SINGLE) != 0) deselectAll ();
+}
+
/**
* Sets the zero-relative index of the item which is currently
* at the top of the receiver. This index can change when items
@@ -1192,11 +1192,11 @@ public void setSelection (String [] items) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void setTopIndex (int index) {
- checkWidget();
- OS.PtSetResource (handle, OS.Pt_ARG_TOP_ITEM_POS, index + 1, 0);
-}
-
+public void setTopIndex (int index) {
+ checkWidget();
+ OS.PtSetResource (handle, OS.Pt_ARG_TOP_ITEM_POS, index + 1, 0);
+}
+
/**
* Shows the selection. If the selection is already showing in the receiver,
* this method simply returns. Otherwise, the items are scrolled until
@@ -1210,30 +1210,30 @@ public void setTopIndex (int index) {
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
-public void showSelection () {
- checkWidget();
- int [] args = new int [] {
- OS.Pt_ARG_LIST_SEL_COUNT, 0, 0,
- OS.Pt_ARG_SELECTION_INDEXES, 0, 0,
- OS.Pt_ARG_TOP_ITEM_POS, 0, 0,
- OS.Pt_ARG_VISIBLE_COUNT, 0, 0,
- OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0
- };
- OS.PtGetResources (handle, args.length / 3, args);
- if (args [1] == 0) return;
- short [] buffer = new short [1];
- OS.memmove (buffer, args [4], 2);
- int index = buffer [0] - 1;
- int topIndex = args [7] - 1, visibleCount = args [10], count = args [13];
- int bottomIndex = Math.min (topIndex + visibleCount - 1, count);
- if ((topIndex <= index) && (index <= bottomIndex)) return;
- int lastIndex = Math.max (1, count - visibleCount + 1);
- int newTop = Math.min (Math.max (index - (visibleCount / 2), 1), lastIndex);
- OS.PtSetResource (handle, OS.Pt_ARG_TOP_ITEM_POS, newTop, 0);
-}
-
-int widgetClass () {
- return OS.PtList ();
-}
-
-}
+public void showSelection () {
+ checkWidget();
+ int [] args = new int [] {
+ OS.Pt_ARG_LIST_SEL_COUNT, 0, 0,
+ OS.Pt_ARG_SELECTION_INDEXES, 0, 0,
+ OS.Pt_ARG_TOP_ITEM_POS, 0, 0,
+ OS.Pt_ARG_VISIBLE_COUNT, 0, 0,
+ OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0
+ };
+ OS.PtGetResources (handle, args.length / 3, args);
+ if (args [1] == 0) return;
+ short [] buffer = new short [1];
+ OS.memmove (buffer, args [4], 2);
+ int index = buffer [0] - 1;
+ int topIndex = args [7] - 1, visibleCount = args [10], count = args [13];
+ int bottomIndex = Math.min (topIndex + visibleCount - 1, count);
+ if ((topIndex <= index) && (index <= bottomIndex)) return;
+ int lastIndex = Math.max (1, count - visibleCount + 1);
+ int newTop = Math.min (Math.max (index - (visibleCount / 2), 1), lastIndex);
+ OS.PtSetResource (handle, OS.Pt_ARG_TOP_ITEM_POS, newTop, 0);
+}
+
+int widgetClass () {
+ return OS.PtList ();
+}
+
+}

Back to the top