|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.eclipse.swt.widgets.Widget | +--org.eclipse.swt.widgets.Control | +--org.eclipse.swt.widgets.Scrollable | +--org.eclipse.swt.widgets.Composite | +--org.eclipse.swt.widgets.Combo
Safe: Instances of this class are controls that allow the user
to choose an item from a list of items, or optionally
enter a new value by typing it into an editable text
field. Often, Combo
s are used in the same place
where a single selection List
widget could
be used but space is limited. A Combo
takes
less space than a List
widget and shows
similar information.
Note: Since Combo
s can contain both a list
and an editable text field, it is possible to confuse methods
which access one versus the other (compare for example,
clearSelection()
and deselectAll()
).
The API documentation is careful to indicate either "the
receiver's list" or the "the receiver's text field" to
distinguish between the two cases.
Note that although this class is a subclass of Composite
,
it does not make sense to add children to it, or set a layout on it.
Note: Only one of the styles DROP_DOWN and SIMPLE may be specified.
IMPORTANT: This class is not intended to be subclassed.
List
Field Summary | |
(package private) static int |
CBID_EDIT
|
(package private) static int |
CBID_LIST
|
(package private) static org.eclipse.swt.internal.win32.TCHAR |
ComboClass
|
(package private) static int |
ComboProc
|
static int |
LIMIT
Enabled: the operating system limit for the number of characters that the text field in an instance of this class can hold |
(package private) boolean |
noSelection
|
Fields inherited from class org.eclipse.swt.widgets.Composite |
font, layout, lpwp, tabList |
Fields inherited from class org.eclipse.swt.widgets.Scrollable |
horizontalBar, verticalBar |
Fields inherited from class org.eclipse.swt.widgets.Control |
ACCENTS, accessible, background, drawCount, foreground, handle, hCursor, layoutData, menu, parent, toolTipText |
Fields inherited from class org.eclipse.swt.widgets.Widget |
CANVAS, COMCTL32_MAJOR, COMCTL32_MINOR, data, DEFAULT_HEIGHT, DEFAULT_WIDTH, DISABLED, DISPOSED, eventTable, HIDDEN, keys, MAJOR, MINOR, Mnemonic, state, style, values |
Constructor Summary | |
Combo(Composite parent,
int style)
Enabled: Constructs a new instance of this class given its parent and a style value describing its behavior and appearance. |
Method Summary | |
void |
add(String string)
Enabled: Adds the argument to the end of the receiver's list. |
void |
add(String string,
int index)
Enabled: Adds the argument to the receiver's list at the given zero-relative index. |
void |
addModifyListener(ModifyListener listener)
Enabled: Adds the listener to the collection of listeners who will be notified when the receiver's text is modified, by sending it one of the messages defined in the ModifyListener
interface. |
void |
addSelectionListener(SelectionListener listener)
Enabled: Adds the listener to the collection of listeners who will be notified when the receiver's selection changes, by sending it one of the messages defined in the SelectionListener
interface. |
(package private) int |
callWindowProc(int msg,
int wParam,
int lParam)
|
(package private) static int |
checkStyle(int style)
|
protected void |
checkSubclass()
Checks that this class can be subclassed. |
void |
clearSelection()
Enabled: Sets the selection in the receiver's text field to an empty selection starting just before the first character. |
Point |
computeSize(int wHint,
int hHint,
boolean changed)
Enabled: |
void |
copy()
Suppressed: Copies the selected text. |
(package private) void |
createHandle()
|
void |
cut()
Suppressed: Cuts the selected text. |
(package private) int |
defaultBackground()
|
void |
deselect(int index)
Enabled: Deselects the item at the given zero-relative index in the receiver's list. |
void |
deselectAll()
Enabled: Deselects all selected items in the receiver's list. |
(package private) boolean |
getEditable()
|
String |
getItem(int index)
Enabled: Returns the item at the given, zero-relative index in the receiver's list. |
int |
getItemCount()
Enabled: Returns the number of items contained in the receiver's list. |
int |
getItemHeight()
Enabled: Returns the height of the area which would be used to display one of the items in the receiver's list. |
String[] |
getItems()
Enabled: Returns an array of String s which are the items
in the receiver's list. |
(package private) String |
getNameText()
|
Point |
getSelection()
Enabled: Returns a Point whose x coordinate is the start
of the selection in the receiver's text field, and whose y
coordinate is the end of the selection. |
int |
getSelectionIndex()
Enabled: Returns the zero-relative index of the item which is currently selected in the receiver's list, or -1 if no item is selected. |
String |
getText()
Enabled: Returns a string containing a copy of the contents of the receiver's text field. |
(package private) String |
getText(int start,
int stop)
|
int |
getTextHeight()
Enabled: Returns the height of the receivers's text field. |
int |
getTextLimit()
Enabled: Returns the maximum number of characters that the receiver's text field is capable of holding. |
(package private) boolean |
hasFocus()
|
int |
indexOf(String string)
Enabled: Searches the receiver's list starting at the first item (index 0) until an item is found that is equal to the argument, and returns the index of that item. |
int |
indexOf(String string,
int start)
Enabled: 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. |
void |
paste()
Suppressed: Pastes text from clipboard. |
void |
remove(int index)
Enabled: Removes the item from the receiver's list at the given zero-relative index. |
void |
remove(int start,
int end)
Enabled: Removes the items from the receiver's list which are between the given zero-relative start and end indices (inclusive). |
void |
remove(String string)
Enabled: 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()
Enabled: Removes all of the items from the receiver's list. |
void |
removeModifyListener(ModifyListener listener)
Enabled: Removes the listener from the collection of listeners who will be notified when the receiver's text is modified. |
void |
removeSelectionListener(SelectionListener listener)
Enabled: Removes the listener from the collection of listeners who will be notified when the receiver's selection changes. |
void |
select(int index)
Enabled: Selects the item at the given zero-relative index in the receiver's list. |
(package private) void |
setBackgroundPixel(int pixel)
|
(package private) void |
setBounds(int x,
int y,
int width,
int height,
int flags)
|
(package private) void |
setEditable(boolean editable)
|
(package private) void |
setForegroundPixel(int pixel)
|
void |
setItem(int index,
String string)
Enabled: Sets the text of the item in the receiver's list at the given zero-relative index to the string argument. |
void |
setItems(String[] items)
Enabled: Sets the receiver's list to be the given array of items. |
void |
setSelection(Point selection)
Enabled: Sets the selection in the receiver's text field to the range specified by the argument whose x coordinate is the start of the selection and whose y coordinate is the end of the selection. |
void |
setText(String string)
Enabled: Sets the contents of the receiver's text field to the given string. |
void |
setTextLimit(int limit)
Enabled: Sets the maximum number of characters that the receiver's text field is capable of holding to be the argument. |
(package private) boolean |
translateAccelerator(org.eclipse.swt.internal.win32.MSG msg)
|
(package private) boolean |
translateTraversal(org.eclipse.swt.internal.win32.MSG msg)
|
(package private) boolean |
traverseEscape()
|
(package private) int |
widgetExtStyle()
|
(package private) int |
widgetStyle()
|
(package private) org.eclipse.swt.internal.win32.TCHAR |
windowClass()
|
(package private) int |
windowProc()
|
(package private) org.eclipse.swt.internal.win32.LRESULT |
WM_CHAR(int wParam,
int lParam)
|
(package private) org.eclipse.swt.internal.win32.LRESULT |
WM_CTLCOLOR(int wParam,
int lParam)
|
(package private) org.eclipse.swt.internal.win32.LRESULT |
WM_GETDLGCODE(int wParam,
int lParam)
|
(package private) org.eclipse.swt.internal.win32.LRESULT |
WM_KILLFOCUS(int wParam,
int lParam)
|
(package private) org.eclipse.swt.internal.win32.LRESULT |
WM_SETFOCUS(int wParam,
int lParam)
|
(package private) org.eclipse.swt.internal.win32.LRESULT |
WM_SIZE(int wParam,
int lParam)
|
(package private) org.eclipse.swt.internal.win32.LRESULT |
wmCommandChild(int wParam,
int lParam)
|
Methods inherited from class org.eclipse.swt.widgets.Composite |
_getChildren, _getTabList, computeTabList, getChildren, getChildrenCount, getLayout, getTabList, hooksKeys, layout, layout, minimumSize, moveAbove, moveBelow, releaseChildren, releaseWidget, resizeChildren, resizeChildren, setFocus, setLayout, setResizeChildren, setTabGroupFocus, setTabItemFocus, setTabList, toolTipText, translateMnemonic, updateFont, WM_ERASEBKGND, WM_GETFONT, WM_LBUTTONDOWN, WM_NOTIFY, WM_PAINT, WM_SETFONT, WM_SYSCOLORCHANGE, WM_SYSCOMMAND |
Methods inherited from class org.eclipse.swt.widgets.Scrollable |
computeTrim, createScrollBar, createWidget, getClientArea, getHorizontalBar, getVerticalBar, WM_HSCROLL, WM_MOUSEWHEEL, WM_VSCROLL, wmScroll |
Methods inherited from class org.eclipse.swt.widgets.Widget |
addDisposeListener, addListener, checkBits, checkParent, checkWidget, dispose, error, filters, getData, getData, getName, getStyle, hooks, isListening, isValidSubclass, isValidThread, mbcsToWcs, mbcsToWcs, notifyListeners, postEvent, postEvent, releaseChild, releaseResources, removeDisposeListener, removeListener, removeListener, sendEvent, sendEvent, sendEvent, sendEvent, setData, setData, setInputState, setKeyState, toString, wcsToMbcs, wcsToMbcs |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
boolean noSelection
public static final int LIMIT
static final int ComboProc
static final org.eclipse.swt.internal.win32.TCHAR ComboClass
static final int CBID_LIST
static final int CBID_EDIT
Constructor Detail |
public Combo(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 constructSWT.DROP_DOWN
,
SWT.READ_ONLY
,
SWT.SIMPLE
,
Widget.checkSubclass()
,
Widget.getStyle()
Method Detail |
public void add(String string)
string
- the new itemadd(String,int)
public void add(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 itemadd(String)
public void addModifyListener(ModifyListener listener)
ModifyListener
interface.
listener
- the listener which should be notifiedModifyListener
,
removeModifyListener(org.eclipse.swt.events.ModifyListener)
public void addSelectionListener(SelectionListener listener)
SelectionListener
interface.
widgetSelected
is called when the combo's list selection changes.
widgetDefaultSelected
is typically called when ENTER is pressed the combo's text area.
listener
- the listener which should be notifiedSelectionListener
,
removeSelectionListener(org.eclipse.swt.events.SelectionListener)
,
SelectionEvent
int callWindowProc(int msg, int wParam, int lParam)
callWindowProc
in class Scrollable
protected void checkSubclass()
Widget
The SWT class library is intended to be subclassed
only at specific, controlled points (most notably,
Composite
and Canvas
when
implementing new widgets). This method enforces this
rule unless it is overridden.
IMPORTANT: By providing an implementation of this method that allows a subclass of a class which does not normally allow subclassing to be created, the implementer agrees to be fully responsible for the fact that any such subclass will likely fail between SWT releases and will be strongly platform specific. No support is provided for user-written classes which are implemented in this fashion.
The ability to subclass outside of the allowed SWT classes is intended purely to enable those not on the SWT development team to implement patches in order to get around specific limitations in advance of when those limitations can be addressed by the team. Subclassing should not be attempted without an intimate and detailed understanding of the hierarchy.
checkSubclass
in class Composite
static int checkStyle(int style)
public void clearSelection()
Note: To clear the selected items in the receiver's list,
use deselectAll()
.
deselectAll()
public Point computeSize(int wHint, int hHint, boolean changed)
computeSize
in class Composite
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
otherwise
Layout
,
Control.getBorderWidth()
,
Control.getBounds()
,
Control.getSize()
,
Control.pack()
,
"computeTrim, getClientArea for controls that implement them"public void copy()
The current selection is copied to the clipboard.
void createHandle()
createHandle
in class Composite
public void cut()
The current selection is first copied to the clipboard and then deleted from the widget.
int defaultBackground()
defaultBackground
in class Control
public void deselect(int index)
index
- the index of the item to deselectpublic void deselectAll()
Note: To clear the selection in the receiver's text field,
use clearSelection()
.
clearSelection()
boolean getEditable()
public String getItem(int index)
index
- the index of the item to return
public int getItemCount()
public int getItemHeight()
public String[] getItems()
String
s which are the items
in the receiver's list.
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.
String getNameText()
getNameText
in class Widget
public Point getSelection()
Point
whose x coordinate is the start
of the selection in the receiver's text field, and whose y
coordinate is the end of the selection. The returned values
are zero-relative. An "empty" selection as indicated by
the the x and y coordinates having the same value.
public int getSelectionIndex()
public String getText()
String getText(int start, int stop)
public int getTextHeight()
public int getTextLimit()
setTextLimit()
, it will be the constant
Combo.LIMIT
.
boolean hasFocus()
hasFocus
in class Control
public int indexOf(String string)
string
- the search item
public int indexOf(String string, int start)
string
- the search item
public void paste()
The selected text is deleted from the widget and new text inserted from the clipboard.
public void remove(int index)
index
- the index for the itempublic void remove(int start, int end)
start
- the start of the rangeend
- the end of the rangepublic void remove(String string)
string
- the item to removepublic void removeAll()
public void removeModifyListener(ModifyListener listener)
listener
- the listener which should no longer be notifiedModifyListener
,
addModifyListener(org.eclipse.swt.events.ModifyListener)
public void removeSelectionListener(SelectionListener listener)
listener
- the listener which should no longer be notifiedSelectionListener
,
addSelectionListener(org.eclipse.swt.events.SelectionListener)
public void select(int index)
index
- the index of the item to selectvoid setBackgroundPixel(int pixel)
setBackgroundPixel
in class Control
void setBounds(int x, int y, int width, int height, int flags)
setBounds
in class Control
void setEditable(boolean editable)
void setForegroundPixel(int pixel)
setForegroundPixel
in class Control
public void setItem(int index, String string)
remove
'ing the old item at the index, and then
add
'ing the new item at that index.
index
- the index for the itemstring
- the new text for the itempublic void setItems(String[] items)
items
- the array of itemspublic void setSelection(Point selection)
public void setText(String string)
Note: The text field in a Combo
is typically
only capable of displaying a single line of text. Thus,
setting the text to a string containing line breaks or
other special characters will probably cause it to
display incorrectly.
public void setTextLimit(int limit)
limit
- new text limitboolean translateAccelerator(org.eclipse.swt.internal.win32.MSG msg)
translateAccelerator
in class Control
boolean translateTraversal(org.eclipse.swt.internal.win32.MSG msg)
translateTraversal
in class Control
boolean traverseEscape()
traverseEscape
in class Control
int widgetExtStyle()
widgetExtStyle
in class Scrollable
int widgetStyle()
widgetStyle
in class Composite
org.eclipse.swt.internal.win32.TCHAR windowClass()
windowClass
in class Scrollable
int windowProc()
windowProc
in class Scrollable
org.eclipse.swt.internal.win32.LRESULT WM_CHAR(int wParam, int lParam)
WM_CHAR
in class Control
org.eclipse.swt.internal.win32.LRESULT WM_CTLCOLOR(int wParam, int lParam)
WM_CTLCOLOR
in class Control
org.eclipse.swt.internal.win32.LRESULT WM_GETDLGCODE(int wParam, int lParam)
WM_GETDLGCODE
in class Composite
org.eclipse.swt.internal.win32.LRESULT WM_KILLFOCUS(int wParam, int lParam)
WM_KILLFOCUS
in class Control
org.eclipse.swt.internal.win32.LRESULT WM_SETFOCUS(int wParam, int lParam)
WM_SETFOCUS
in class Control
org.eclipse.swt.internal.win32.LRESULT WM_SIZE(int wParam, int lParam)
WM_SIZE
in class Composite
org.eclipse.swt.internal.win32.LRESULT wmCommandChild(int wParam, int lParam)
wmCommandChild
in class Control
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |