public class List extends Scrollable
Note: Only one of SINGLE and MULTI may be specified.
IMPORTANT: This class is not intended to be subclassed.
Modifier and Type | Field and Description |
---|---|
(package private) static int |
INSET |
(package private) static TCHAR |
ListClass |
(package private) static int |
ListProc |
horizontalBar, verticalBar
accessible, background, backgroundImage, cursor, drawCount, font, foreground, handle, layoutData, menu, parent, region, toolTipText
CANVAS, data, DEFAULT_HEIGHT, DEFAULT_WIDTH, DISABLED, display, DISPOSE_SENT, DISPOSED, DRAG_DETECT, DRAW_BACKGROUND, eventTable, FOREIGN_HANDLE, HIDDEN, IGNORE_WM_CHANGEUISTATE, KEYED_DATA, LAYOUT_CHANGED, LAYOUT_CHILD, LAYOUT_NEEDED, MAJOR, MINOR, MOVE_DEFERRED, MOVE_OCCURRED, PARENT_BACKGROUND, RELEASED, RESIZE_DEFERRED, RESIZE_OCCURRED, SKIN_NEEDED, state, style, THEME_BACKGROUND, TRACK_MOUSE
Constructor and Description |
---|
List(Composite parent,
int style)
Constructs a new instance of this class given its parent
and a style value describing its behavior and appearance.
|
Modifier and Type | Method and Description |
---|---|
void |
add(java.lang.String string)
Adds the argument to the end of the receiver's list.
|
void |
add(java.lang.String string,
int index)
Adds the argument to the receiver's list at the given
zero-relative index.
|
void |
addSelectionListener(SelectionListener listener)
Adds the listener to the collection of listeners who will
be notified when the user changes the receiver's selection, by sending
it one of the messages defined in the
SelectionListener
interface. |
(package private) int |
callWindowProc(int hwnd,
int msg,
int wParam,
int lParam) |
(package private) static int |
checkStyle(int style) |
Point |
computeSize(int wHint,
int hHint,
boolean changed)
Returns the preferred size of the receiver.
|
(package private) int |
defaultBackground() |
void |
deselect(int index)
Deselects the item at the given zero-relative index in the receiver.
|
void |
deselect(int[] indices)
Deselects the items at the given zero-relative indices in the receiver.
|
void |
deselect(int start,
int end)
Deselects the items at the given zero-relative indices in the receiver.
|
void |
deselectAll()
Deselects all selected items in the receiver.
|
int |
getFocusIndex()
Returns the zero-relative index of the item which currently
has the focus in the receiver, or -1 if no item has focus.
|
java.lang.String |
getItem(int index)
Returns the item at the given, zero-relative index in the
receiver.
|
int |
getItemCount()
Returns the number of items contained in the receiver.
|
int |
getItemHeight()
Returns the height of the area which would be used to
display one of the items in the list.
|
java.lang.String[] |
getItems()
Returns a (possibly empty) array of
String s which
are the items in the receiver. |
java.lang.String[] |
getSelection()
Returns an array of
String s that are currently
selected in the receiver. |
int |
getSelectionCount()
Returns the number of selected items contained in the receiver.
|
int |
getSelectionIndex()
Returns the zero-relative index of the item which is currently
selected in the receiver, or -1 if no item is selected.
|
int[] |
getSelectionIndices()
Returns the zero-relative indices of the items which are currently
selected in the receiver.
|
int |
getTopIndex()
Returns the zero-relative index of the item which is currently
at the top of the receiver.
|
int |
indexOf(java.lang.String string)
Gets the index of an item.
|
int |
indexOf(java.lang.String string,
int start)
Searches the receiver's list starting at the given,
zero-relative index until an item is found that is equal
to the argument, and returns the index of that item.
|
boolean |
isSelected(int index)
Returns
true if the item is selected,
and false otherwise. |
void |
remove(int index)
Removes the item from the receiver at the given
zero-relative index.
|
void |
remove(int[] indices)
Removes the items from the receiver at the given
zero-relative indices.
|
void |
remove(int start,
int end)
Removes the items from the receiver which are
between the given zero-relative start and end
indices (inclusive).
|
void |
remove(java.lang.String string)
Searches the receiver's list starting at the first item
until an item is found that is equal to the argument,
and removes that item from the list.
|
void |
removeAll()
Removes all of the items from the receiver.
|
void |
removeSelectionListener(SelectionListener listener)
Removes the listener from the collection of listeners who will
be notified when the user changes the receiver's selection.
|
void |
select(int index)
Selects the item at the given zero-relative index in the receiver's
list.
|
void |
select(int[] indices)
Selects the items at the given zero-relative indices in the receiver.
|
(package private) void |
select(int[] indices,
boolean scroll) |
(package private) void |
select(int index,
boolean scroll) |
void |
select(int start,
int end)
Selects the items in the range specified by the given zero-relative
indices in the receiver.
|
(package private) void |
select(int start,
int end,
boolean scroll) |
void |
selectAll()
Selects all of the items in the receiver.
|
(package private) void |
setFocusIndex(int index) |
void |
setFont(Font font)
Sets the font that the receiver will use to paint textual information
to the font specified by the argument, or to the default font for that
kind of control if the argument is null.
|
void |
setItem(int index,
java.lang.String string)
Sets the text of the item in the receiver's list at the given
zero-relative index to the string argument.
|
void |
setItems(java.lang.String[] items)
Sets the receiver's items to be the given array of items.
|
(package private) void |
setScrollWidth() |
(package private) void |
setScrollWidth(int newWidth,
boolean grow) |
(package private) void |
setScrollWidth(TCHAR buffer,
boolean grow) |
void |
setSelection(int index)
Selects the item at the given zero-relative index in the receiver.
|
void |
setSelection(int[] indices)
Selects the items at the given zero-relative indices in the receiver.
|
void |
setSelection(int start,
int end)
Selects the items in the range specified by the given zero-relative
indices in the receiver.
|
void |
setSelection(java.lang.String[] items)
Sets the receiver's selection to be the given array of items.
|
void |
setTopIndex(int index)
Sets the zero-relative index of the item which is currently
at the top of the receiver.
|
void |
showSelection()
Shows the selection.
|
(package private) void |
updateMenuLocation(Event event) |
(package private) int |
widgetStyle() |
(package private) TCHAR |
windowClass() |
(package private) int |
windowProc() |
(package private) LRESULT |
WM_CHAR(int wParam,
int lParam) |
(package private) LRESULT |
WM_KEYDOWN(int wParam,
int lParam) |
(package private) LRESULT |
WM_SETREDRAW(int wParam,
int lParam) |
(package private) LRESULT |
WM_SIZE(int wParam,
int lParam) |
(package private) LRESULT |
wmCommandChild(int wParam,
int lParam) |
computeTrim, createScrollBar, createWidget, destroyScrollBar, getClientArea, getHorizontalBar, getScrollbarsMode, getVerticalBar, releaseChildren, reskinChildren, scrolledHandle, widgetExtStyle, WM_HSCROLL, WM_MOUSEWHEEL, WM_VSCROLL, wmNCPaint, wmScroll, wmScrollWheel
addControlListener, addDragDetectListener, addFocusListener, addGestureListener, addHelpListener, addKeyListener, addMenuDetectListener, addMouseListener, addMouseMoveListener, addMouseTrackListener, addMouseWheelListener, addPaintListener, addTouchListener, addTraverseListener, binarySearch, borderHandle, checkBackground, checkBorder, checkBuffered, checkComposited, checkGesture, checkHandle, checkMirrored, computeSize, computeTabGroup, computeTabList, computeTabRoot, createHandle, defaultFont, defaultForeground, deregister, destroyWidget, dragDetect, dragDetect, dragDetect, drawBackground, drawBackground, drawBackground, drawImageBackground, drawThemeBackground, enableDrag, enableWidget, fillBackground, fillImageBackground, fillThemeBackground, findBackgroundControl, findBrush, findCursor, findImageControl, findMenus, findMnemonic, findThemeControl, fixChildren, fixFocus, forceFocus, forceResize, getAccessible, getBackground, getBackgroundImage, getBackgroundPixel, getBorderWidth, getBounds, getClipboardText, getCodePage, getCursor, getDragDetect, getDrawing, getEnabled, getFont, getForeground, getForegroundPixel, getLayoutData, getLocation, getMenu, getMonitor, getOrientation, getParent, getPath, getRegion, getShell, getSize, getToolTipText, getTouchEnabled, getVisible, hasCursor, hasFocus, internal_dispose_GC, internal_new_GC, isActive, isEnabled, isFocusAncestor, isFocusControl, isReparentable, isShowing, isTabGroup, isTabItem, isVisible, mapEvent, markLayout, menuShell, mnemonicHit, mnemonicMatch, moveAbove, moveBelow, new_Accessible, new_GC, pack, pack, print, printWidget, redraw, redraw, redraw, redrawChildren, register, releaseHandle, releaseParent, releaseWidget, removeControlListener, removeDragDetectListener, removeFocusListener, removeGestureListener, removeHelpListener, removeKeyListener, removeMenuDetectListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removeMouseWheelListener, removePaintListener, removeTouchListener, removeTraverseListener, sendFocusEvent, sendGestureEvent, sendMove, sendResize, sendTouchEvent, setBackground, setBackground, setBackgroundImage, setBackgroundImage, setBackgroundPixel, setBounds, setBounds, setBounds, setBounds, setCapture, setCursor, setCursor, setDefaultFont, setDragDetect, setEnabled, setFocus, setForeground, setForegroundPixel, setLayoutData, setLocation, setLocation, setMenu, setOrientation, setParent, setRadioFocus, setRadioSelection, setRedraw, setRegion, setSavedFocus, setSize, setSize, setTabItemFocus, setToolTipText, setToolTipText, setTouchEnabled, setVisible, showWidget, sort, subclass, toControl, toControl, toDisplay, toDisplay, topHandle, translateAccelerator, translateMnemonic, translateMnemonic, translateTraversal, traverse, traverse, traverse, traverse, traverse, traverseEscape, traverseGroup, traverseItem, traverseMnemonic, traversePage, traverseReturn, unsubclass, update, update, updateBackgroundColor, updateBackgroundImage, updateBackgroundMode, updateFont, updateImages, updateLayout, updateOrientation, widgetCreateStruct, widgetParent, windowProc, WM_ACTIVATE, WM_CAPTURECHANGED, WM_CHANGEUISTATE, WM_CLEAR, WM_CLOSE, WM_COMMAND, WM_CONTEXTMENU, WM_CTLCOLOR, WM_CUT, WM_DESTROY, WM_DRAWITEM, WM_ENDSESSION, WM_ENTERIDLE, WM_ERASEBKGND, WM_GESTURE, WM_GETDLGCODE, WM_GETFONT, WM_GETMINMAXINFO, WM_GETOBJECT, WM_HELP, WM_HOTKEY, WM_IME_CHAR, WM_IME_COMPOSITION_START, WM_IME_COMPOSITION, WM_IME_ENDCOMPOSITION, WM_INITMENUPOPUP, WM_INPUTLANGCHANGE, WM_KEYUP, WM_KILLFOCUS, WM_LBUTTONDBLCLK, WM_LBUTTONDOWN, WM_LBUTTONUP, WM_MBUTTONDBLCLK, WM_MBUTTONDOWN, WM_MBUTTONUP, WM_MEASUREITEM, WM_MENUCHAR, WM_MENUSELECT, WM_MOUSEACTIVATE, WM_MOUSEHOVER, WM_MOUSEHWHEEL, WM_MOUSELEAVE, WM_MOUSEMOVE, WM_MOVE, WM_NCACTIVATE, WM_NCCALCSIZE, WM_NCHITTEST, WM_NCLBUTTONDOWN, WM_NCPAINT, WM_NOTIFY, WM_PAINT, WM_PALETTECHANGED, WM_PARENTNOTIFY, WM_PASTE, WM_PRINT, WM_PRINTCLIENT, WM_QUERYENDSESSION, WM_QUERYNEWPALETTE, WM_QUERYOPEN, WM_RBUTTONDBLCLK, WM_RBUTTONDOWN, WM_RBUTTONUP, WM_SETCURSOR, WM_SETFOCUS, WM_SETFONT, WM_SETTINGCHANGE, WM_SHOWWINDOW, WM_SYSCHAR, WM_SYSCOLORCHANGE, WM_SYSCOMMAND, WM_SYSKEYDOWN, WM_SYSKEYUP, WM_TABLET_FLICK, WM_TIMER, WM_TOUCH, WM_UNDO, WM_UNINITMENUPOPUP, WM_UPDATEUISTATE, WM_WINDOWPOSCHANGED, WM_WINDOWPOSCHANGING, WM_XBUTTONDBLCLK, WM_XBUTTONDOWN, WM_XBUTTONUP, wmColorChild, wmDrawChild, wmMeasureChild, wmNotify, wmNotifyChild, wmScrollChild
_addListener, addDisposeListener, addListener, checkBits, checkOpened, checkOrientation, checkParent, checkSubclass, checkWidget, DeferWindowPos, dispose, dragDetect, error, filters, findItem, fixMnemonic, fixMnemonic, getData, getData, getDisplay, getListeners, getName, getNameText, getStyle, hooks, isDisposed, isListening, isValidSubclass, isValidThread, notifyListeners, postEvent, postEvent, release, removeDisposeListener, removeListener, removeListener, reskin, reskinWidget, sendDragEvent, sendDragEvent, sendEvent, sendEvent, sendEvent, sendEvent, sendKeyEvent, sendKeyEvent, sendMouseEvent, sendMouseEvent, sendMouseWheelEvent, sendSelectionEvent, sendSelectionEvent, setData, setData, setInputState, setKeyState, setLocationMask, setTabGroupFocus, SetWindowPos, showMenu, showMenu, toString, wmCaptureChanged, wmChar, wmContextMenu, wmIMEChar, wmKeyDown, wmKeyUp, wmKillFocus, wmLButtonDblClk, wmLButtonDown, wmLButtonUp, wmMButtonDblClk, wmMButtonDown, wmMButtonUp, wmMouseHover, wmMouseHWheel, wmMouseLeave, wmMouseMove, wmMouseWheel, wmPaint, wmPrint, wmRButtonDblClk, wmRButtonDown, wmRButtonUp, wmSetFocus, wmSysChar, wmSysKeyDown, wmSysKeyUp, wmXButtonDblClk, wmXButtonDown, wmXButtonUp
static final int INSET
static final int ListProc
static final TCHAR ListClass
public List(Composite parent, int style)
The style value is either one of the style constants defined in
class SWT
which is applicable to instances of this
class, or must be built by bitwise OR'ing together
(that is, using the int
"|" operator) two or more
of those SWT
style constants. The class description
lists the style constants that are applicable to the class.
Style bits are also inherited from superclasses.
parent
- a composite control which will be the parent of the new instance (cannot be null)style
- the style of control to constructjava.lang.IllegalArgumentException
- SWTException
- SWT.SINGLE
,
SWT.MULTI
,
Widget.checkSubclass()
,
Widget.getStyle()
public void add(java.lang.String string)
string
- the new itemjava.lang.IllegalArgumentException
- SWTException
- add(String,int)
public void add(java.lang.String string, int index)
Note: To add an item at the end of the list, use the
result of calling getItemCount()
as the
index or use add(String)
.
string
- the new itemindex
- the index for the itemjava.lang.IllegalArgumentException
- SWTException
- add(String)
public void addSelectionListener(SelectionListener listener)
SelectionListener
interface.
widgetSelected
is called when the selection changes.
widgetDefaultSelected
is typically called when an item is double-clicked.
listener
- the listener which should be notified when the user changes the receiver's selectionjava.lang.IllegalArgumentException
- SWTException
- SelectionListener
,
removeSelectionListener(org.eclipse.swt.events.SelectionListener)
,
SelectionEvent
int callWindowProc(int hwnd, int msg, int wParam, int lParam)
callWindowProc
in class Scrollable
static int checkStyle(int style)
public Point computeSize(int wHint, int hHint, boolean changed)
Control
The preferred size of a control is the size that it would
best be displayed at. The width hint and height hint arguments
allow the caller to ask a control questions such as "Given a particular
width, how high does the control need to be to show all of the contents?"
To indicate that the caller does not wish to constrain a particular
dimension, the constant SWT.DEFAULT
is passed for the hint.
If the changed flag is true
, it indicates that the receiver's
contents have changed, therefore any caches that a layout manager
containing the control may have been keeping need to be flushed. When the
control is resized, the changed flag will be false
, so layout
manager caches can be retained.
computeSize
in class Control
wHint
- the width hint (can be SWT.DEFAULT
)hHint
- the height hint (can be SWT.DEFAULT
)changed
- true
if the control's contents have changed, and false
otherwiseLayout
,
Control.getBorderWidth()
,
Control.getBounds()
,
Control.getSize()
,
Control.pack(boolean)
,
"computeTrim, getClientArea for controls that implement them"int defaultBackground()
defaultBackground
in class Control
public void deselect(int[] indices)
indices
- the array of indices for the items to deselectjava.lang.IllegalArgumentException
- SWTException
- public void deselect(int index)
index
- the index of the item to deselectSWTException
- public void deselect(int start, int end)
start
- the start index of the items to deselectend
- the end index of the items to deselectSWTException
- public void deselectAll()
SWTException
- public int getFocusIndex()
SWTException
- public java.lang.String getItem(int index)
index
- the index of the item to returnjava.lang.IllegalArgumentException
- SWTException
- public int getItemCount()
SWTException
- public int getItemHeight()
SWTException
- public java.lang.String[] getItems()
String
s which
are the items in the receiver.
Note: This is not the actual structure used by the receiver to maintain its list of items, so modifying the array will not affect the receiver.
SWTException
- public java.lang.String[] getSelection()
String
s that are currently
selected in the receiver. The order of the items is unspecified.
An empty array indicates that no items are selected.
Note: This is not the actual structure used by the receiver to maintain its selection, so modifying the array will not affect the receiver.
SWTException
- public int getSelectionCount()
SWTException
- public int getSelectionIndex()
SWTException
- public int[] getSelectionIndices()
Note: This is not the actual structure used by the receiver to maintain its selection, so modifying the array will not affect the receiver.
SWTException
- public int getTopIndex()
SWTException
- public int indexOf(java.lang.String string)
The list is searched starting at 0 until an item is found that is equal to the search item. If no item is found, -1 is returned. Indexing is zero based.
string
- the search itemjava.lang.IllegalArgumentException
- SWTException
- public int indexOf(java.lang.String string, int start)
string
- the search itemstart
- the zero-relative index at which to start the searchjava.lang.IllegalArgumentException
- SWTException
- public boolean isSelected(int index)
true
if the item is selected,
and false
otherwise. Indices out of
range are ignored.index
- the index of the itemSWTException
- public void remove(int[] indices)
indices
- the array of indices of the itemsjava.lang.IllegalArgumentException
- SWTException
- public void remove(int index)
index
- the index for the itemjava.lang.IllegalArgumentException
- SWTException
- public void remove(int start, int end)
start
- the start of the rangeend
- the end of the rangejava.lang.IllegalArgumentException
- SWTException
- public void remove(java.lang.String string)
string
- the item to removejava.lang.IllegalArgumentException
- SWTException
- public void removeAll()
SWTException
- public void removeSelectionListener(SelectionListener listener)
listener
- the listener which should no longer be notifiedjava.lang.IllegalArgumentException
- SWTException
- SelectionListener
,
addSelectionListener(org.eclipse.swt.events.SelectionListener)
public void select(int[] indices)
If the item at a given index is not selected, it is selected. If the item at a given index was already selected, it remains selected. Indices that are out of range and duplicate indices are ignored. If the receiver is single-select and multiple indices are specified, then all indices are ignored.
indices
- the array of indices for the items to selectjava.lang.IllegalArgumentException
- SWTException
- setSelection(int[])
void select(int[] indices, boolean scroll)
public void select(int index)
index
- the index of the item to selectSWTException
- void select(int index, boolean scroll)
public void select(int start, int end)
If an item in the given range is not selected, it is selected. If an item in the given range was already selected, it remains selected. Indices that are out of range are ignored and no items will be selected if start is greater than end. If the receiver is single-select and there is more than one item in the given range, then all indices are ignored.
start
- the start of the rangeend
- the end of the rangeSWTException
- setSelection(int,int)
void select(int start, int end, boolean scroll)
public void selectAll()
If the receiver is single-select, do nothing.
SWTException
- void setFocusIndex(int index)
public void setFont(Font font)
Control
public void setItem(int index, java.lang.String string)
index
- the index for the itemstring
- the new text for the itemjava.lang.IllegalArgumentException
- SWTException
- public void setItems(java.lang.String[] items)
items
- the array of itemsjava.lang.IllegalArgumentException
- SWTException
- void setScrollWidth()
void setScrollWidth(TCHAR buffer, boolean grow)
void setScrollWidth(int newWidth, boolean grow)
public void setSelection(int[] indices)
Indices that are out of range and duplicate indices are ignored. If the receiver is single-select and multiple indices are specified, then all indices are ignored.
indices
- the indices of the items to selectjava.lang.IllegalArgumentException
- SWTException
- deselectAll()
,
select(int[])
public void setSelection(java.lang.String[] items)
Items that are not in the receiver are ignored. If the receiver is single-select and multiple items are specified, then all items are ignored.
items
- the array of itemsjava.lang.IllegalArgumentException
- SWTException
- deselectAll()
,
select(int[])
,
setSelection(int[])
public void setSelection(int index)
index
- the index of the item to selectSWTException
- deselectAll()
,
select(int)
public void setSelection(int start, int end)
Indices that are out of range are ignored and no items will be selected if start is greater than end. If the receiver is single-select and there is more than one item in the given range, then all indices are ignored.
start
- the start index of the items to selectend
- the end index of the items to selectSWTException
- deselectAll()
,
select(int,int)
public void setTopIndex(int index)
index
- the index of the top itemSWTException
- public void showSelection()
SWTException
- void updateMenuLocation(Event event)
updateMenuLocation
in class Widget
int widgetStyle()
widgetStyle
in class Scrollable
TCHAR windowClass()
windowClass
in class Scrollable
int windowProc()
windowProc
in class Scrollable
LRESULT WM_KEYDOWN(int wParam, int lParam)
WM_KEYDOWN
in class Control
LRESULT WM_SETREDRAW(int wParam, int lParam)
WM_SETREDRAW
in class Control
LRESULT WM_SIZE(int wParam, int lParam)
WM_SIZE
in class Scrollable
LRESULT wmCommandChild(int wParam, int lParam)
wmCommandChild
in class Control