org.eclipse.swt.widgets.Combo Maven / Gradle / Ivy
Show all versions of org.eclipse.swt.macosx.x86_64 Show documentation
/******************************************************************************* * Copyright (c) 2000, 2015 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * IBM Corporation - initial API and implementation * Lars Vogel
if the receiver's list is visible, * and- Bug 483540 *******************************************************************************/ package org.eclipse.swt.widgets; import org.eclipse.swt.*; import org.eclipse.swt.events.*; import org.eclipse.swt.graphics.*; import org.eclipse.swt.internal.cocoa.*; /** * 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 selectionList
widget could * be used but space is limited. ACombo
takes * less space than aList
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()
anddeselectAll()
). * 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. **
*- Styles:
*- DROP_DOWN, READ_ONLY, SIMPLE
*- Events:
*- DefaultSelection, Modify, Selection, Verify, OrientationChange
** Note: Only one of the styles DROP_DOWN and SIMPLE may be specified. *
* IMPORTANT: This class is not intended to be subclassed. *
* * @see List * @see Combo snippets * @see SWT Example: ControlExample * @see Sample code and further information * @noextend This class is not intended to be subclassed by clients. */ public class Combo extends Composite { String text; int textLimit = LIMIT; boolean receivingFocus; boolean ignoreSetObject, ignoreSelection; NSRange selectionRange; boolean listVisible; static final int VISIBLE_COUNT = 5; /** * the operating system limit for the number of characters * that the text field in an instance of this class can hold */ public static final int LIMIT; /* * These values can be different on different platforms. * Therefore they are not initialized in the declaration * to stop the compiler from inlining. */ static { LIMIT = 0x7FFFFFFF; } /** * Constructs a new instance of this class given its parent * and a style value describing its behavior and appearance. ** The style value is either one of the style constants defined in * class
* * @param parent a composite control which will be the parent of the new instance (cannot be null) * @param style the style of control to construct * * @exception IllegalArgumentExceptionSWT
which is applicable to instances of this * class, or must be built by bitwise OR'ing together * (that is, using theint
"|" operator) two or more * of thoseSWT
style constants. The class description * lists the style constants that are applicable to the class. * Style bits are also inherited from superclasses. **
* @exception SWTException- ERROR_NULL_ARGUMENT - if the parent is null
**
* * @see SWT#DROP_DOWN * @see SWT#READ_ONLY * @see SWT#SIMPLE * @see Widget#checkSubclass * @see Widget#getStyle */ public Combo (Composite parent, int style) { super (parent, checkStyle (style)); } /** * Adds the argument to the end of the receiver's list. *- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent
*- ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass
** Note: If control characters like '\n', '\t' etc. are used * in the string, then the behavior is platform dependent. *
* @param string the new item * * @exception IllegalArgumentException*
* @exception SWTException- ERROR_NULL_ARGUMENT - if the string is null
**
* * @see #add(String,int) */ public void add (String string) { checkWidget (); if (string == null) error (SWT.ERROR_NULL_ARGUMENT); NSAttributedString str = createString(string); if ((style & SWT.READ_ONLY) != 0) { NSPopUpButton widget = (NSPopUpButton)view; long /*int*/ selection = widget.indexOfSelectedItem(); NSMenu nsMenu = widget.menu(); NSMenuItem nsItem = (NSMenuItem)new NSMenuItem().alloc(); NSString empty = NSString.string(); nsItem.initWithTitle(empty, 0, empty); nsItem.setAttributedTitle(str); nsMenu.addItem(nsItem); nsItem.release(); if (selection == -1) widget.selectItemAtIndex(-1); } else { ((NSComboBox)view).addItemWithObjectValue(str); } } /** * Adds the argument to the receiver's list at the given * zero-relative index. *- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
*- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
** Note: To add an item at the end of the list, use the * result of calling
getItemCount()
as the * index or useadd(String)
. ** Also note, if control characters like '\n', '\t' etc. are used * in the string, then the behavior is platform dependent. *
* * @param string the new item * @param index the index for the item * * @exception IllegalArgumentException*
* @exception SWTException- ERROR_NULL_ARGUMENT - if the string is null
*- ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list (inclusive)
**
* * @see #add(String) */ public void add (String string, int index) { checkWidget (); if (string == null) error (SWT.ERROR_NULL_ARGUMENT); int count = getItemCount (); if (0 > index || index > count) error (SWT.ERROR_INVALID_RANGE); NSAttributedString str = createString(string); if ((style & SWT.READ_ONLY) != 0) { NSPopUpButton widget = (NSPopUpButton)view; long /*int*/ selection = widget.indexOfSelectedItem(); NSMenu nsMenu = widget.menu(); NSMenuItem nsItem = (NSMenuItem)new NSMenuItem().alloc(); NSString empty = NSString.string(); nsItem.initWithTitle(empty, 0, empty); nsItem.setAttributedTitle(str); nsMenu.insertItem(nsItem, index); nsItem.release(); if (selection == -1) widget.selectItemAtIndex(-1); } else { ((NSComboBox)view).insertItemWithObjectValue(str, index); } } /** * 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- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
*- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
*ModifyListener
* interface. * * @param listener the listener which should be notified * * @exception IllegalArgumentException*
* @exception SWTException- ERROR_NULL_ARGUMENT - if the listener is null
**
* * @see ModifyListener * @see #removeModifyListener */ public void addModifyListener (ModifyListener listener) { checkWidget(); if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); TypedListener typedListener = new TypedListener (listener); addListener (SWT.Modify, typedListener); } /** * Adds a segment listener. *- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
*- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
** A
*SegmentEvent
is sent whenever text content is being modified or * a segment listener is added or removed. You can * customize the appearance of text by indicating certain characters to be inserted * at certain text offsets. This may be used for bidi purposes, e.g. when * adjacent segments of right-to-left text should not be reordered relative to * each other. * E.g., multiple Java string literals in a right-to-left language * should generally remain in logical order to each other, that is, the * way they are stored. ** Warning: This API is currently only implemented on Windows. *
* * @param listener the listener which should be notified * * @exception IllegalArgumentExceptionSegmentEvent
s won't be sent on GTK and Cocoa. **
* @exception SWTException- ERROR_NULL_ARGUMENT - if the listener is null
**
* * @see SegmentEvent * @see SegmentListener * @see #removeSegmentListener * * @since 3.103 */ public void addSegmentListener (SegmentListener listener) { checkWidget (); if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); addListener (SWT.Segments, new TypedListener (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- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
*- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
*SelectionListener
* interface. **
* * @param listener the listener which should be notified * * @exception IllegalArgumentExceptionwidgetSelected
is called when the user changes the combo's list selection. *widgetDefaultSelected
is typically called when ENTER is pressed the combo's text area. **
* @exception SWTException- ERROR_NULL_ARGUMENT - if the listener is null
**
* * @see SelectionListener * @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); } /** * Adds the listener to the collection of listeners who will * be notified when the receiver's text is verified, by sending * it one of the messages defined in the- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
*- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
*VerifyListener
* interface. * * @param listener the listener which should be notified * * @exception IllegalArgumentException*
* @exception SWTException- ERROR_NULL_ARGUMENT - if the listener is null
**
* * @see VerifyListener * @see #removeVerifyListener * * @since 3.1 */ public void addVerifyListener (VerifyListener listener) { checkWidget(); if (listener == null) error (SWT.ERROR_NULL_ARGUMENT); TypedListener typedListener = new TypedListener (listener); addListener (SWT.Verify, typedListener); } @Override boolean becomeFirstResponder (long /*int*/ id, long /*int*/ sel) { receivingFocus = true; boolean result = super.becomeFirstResponder (id, sel); receivingFocus = false; return result; } static int checkStyle (int style) { /* * Feature in Windows. It is not possible to create * a combo box that has a border using Windows style * bits. All combo boxes draw their own border and * do not use the standard Windows border styles. * Therefore, no matter what style bits are specified, * clear the BORDER bits so that the SWT style will * match the Windows widget. * * The Windows behavior is currently implemented on * all platforms. */ style &= ~SWT.BORDER; /* * Even though it is legal to create this widget * with scroll bars, they serve no useful purpose * because they do not automatically scroll the * widget's client area. The fix is to clear * the SWT style. */ style &= ~(SWT.H_SCROLL | SWT.V_SCROLL); style = checkBits (style, SWT.DROP_DOWN, SWT.SIMPLE, 0, 0, 0, 0); if ((style & SWT.SIMPLE) != 0) return style & ~SWT.READ_ONLY; return style; } @Override protected void checkSubclass () { if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS); } /** * Sets the selection in the receiver's text field to an empty * selection starting just before the first character. If the * text field is editable, this has the effect of placing the * i-beam at the start of the text. *- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
*- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
** Note: To clear the selected items in the receiver's list, * use
* * @exception SWTExceptiondeselectAll()
. **
* * @see #deselectAll */ public void clearSelection () { checkWidget(); if ((style & SWT.READ_ONLY) == 0) { Point selection = getSelection (); selection.y = selection.x; setSelection (selection); } } @Override void setObjectValue(long /*int*/ id, long /*int*/ sel, long /*int*/ arg0) { super.setObjectValue(id, sel, ignoreSetObject ? arg0 : createString(text).id); } @Override void comboBoxSelectionDidChange(long /*int*/ id, long /*int*/ sel, long /*int*/ notification) { NSComboBox widget = (NSComboBox)view; long /*int*/ tableSelection = widget.indexOfSelectedItem(); widget.selectItemAtIndex(tableSelection); NSAttributedString attStr = new NSAttributedString (widget.itemObjectValueAtIndex(tableSelection)); NSString nsString = attStr.string(); if (nsString != null) setText(nsString.getString(), true); if (!ignoreSelection) sendSelectionEvent (SWT.Selection, null, display.trackingControl != this); } @Override public Point computeSize (int wHint, int hHint, boolean changed) { checkWidget (); int width = 0, height = 0; NSControl widget = (NSControl)view; NSCell viewCell = widget.cell (); NSSize size = viewCell.cellSize (); width = (int)Math.ceil (size.width); height = (int)Math.ceil (size.height); if ((style & SWT.READ_ONLY) == 0) { ignoreSetObject = true; NSComboBoxCell cell = new NSComboBoxCell (viewCell.id); NSArray array = cell.objectValues (); int length = (int)/*64*/array.count (); if (length > 0) { cell = new NSComboBoxCell (cell.copy ()); for (int i = 0; i < length; i++) { NSAttributedString attStr = new NSAttributedString (array.objectAtIndex (i)); cell.setAttributedStringValue(attStr); size = cell.cellSize (); width = Math.max (width, (int)Math.ceil (size.width)); } cell.release (); } ignoreSetObject = false; /* * Attempting to create an NSComboBox with a height > 27 spews a * very long warning message to stdout and draws the combo incorrectly. * Limit height to frame height when combo has multiline text. */ NSString nsStr = widget.stringValue(); if (nsStr != null ){ String str = nsStr.getString(); if (str != null && (str.indexOf('\n') >= 0 || str.indexOf('\r') >= 0)){ int frameHeight = (int) view.frame().height; if (frameHeight > 0){ height = frameHeight; } } } } else { /* * In a SWT.READ_ONLY Combo with single item, but no selection, * the width of the cell returned by cellSize() is smaller than expected. * Get the correct width by setting and resetting the selected item. */ NSPopUpButton nsPopUpButton = (NSPopUpButton)view; if ((nsPopUpButton.numberOfItems () == 1) && (nsPopUpButton.indexOfSelectedItem () == -1)) { nsPopUpButton.selectItemAtIndex (0); size = viewCell.cellSize (); width = Math.max (width, (int)Math.ceil (size.width)); nsPopUpButton.selectItemAtIndex (-1); } } /* * Feature in Cocoa. Attempting to create an NSComboBox with a * height > 27 spews a very long warning message to stdout and * often draws the combo incorrectly. The workaround is to limit * the returned height of editable Combos to the height that is * required to display their text, even if a larger hHint is specified. */ if (hHint != SWT.DEFAULT) { if ((style & SWT.READ_ONLY) != 0 || hHint < height) height = hHint; } if (wHint != SWT.DEFAULT) width = wHint; return new Point (width, height); } /** * Copies the selected text. *- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
*- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
** The current selection is copied to the clipboard. *
* * @exception SWTException*
* * @since 2.1 */ public void copy () { checkWidget (); Point selection = getSelection (); if (selection.x == selection.y) return; copyToClipboard (getText (selection.x, selection.y)); } @Override void createHandle () { if ((style & SWT.READ_ONLY) != 0) { NSPopUpButton widget = (NSPopUpButton)new SWTPopUpButton().alloc(); widget.initWithFrame(new NSRect(), false); widget.menu().setAutoenablesItems(false); widget.setTarget(widget); widget.setAction(OS.sel_sendSelection); widget.menu().setDelegate(widget); view = widget; } else { NSComboBox widget = (NSComboBox)new SWTComboBox().alloc(); widget.init(); widget.setDelegate(widget); NSCell cell = widget.cell(); if (OS.VERSION >= 0x1060 && cell != null){ cell.setUsesSingleLineMode(true); } view = widget; } } NSAttributedString createString(String string) { NSAttributedString attribStr = createString(string, null, foreground, SWT.LEFT, false, true, false); attribStr.autorelease(); return attribStr; } @Override void createWidget() { text = ""; super.createWidget(); if ((style & SWT.READ_ONLY) == 0) { NSComboBox widget = (NSComboBox)view; NSScreen screen = widget.window().screen(); NSRect rect = screen != null ? screen.frame() : NSScreen.mainScreen().frame(); int visibleCount = Math.max(VISIBLE_COUNT, (int)(rect.height / 3 / widget.itemHeight())); widget.setNumberOfVisibleItems(visibleCount); } } @Override void comboBoxWillDismiss(long /*int*/ id, long /*int*/ sel, long /*int*/ notification) { display.currentCombo = null; listVisible = false; } @Override void comboBoxWillPopUp(long /*int*/ id, long /*int*/ sel, long /*int*/ notification) { display.currentCombo = this; listVisible = true; } /** * Cuts the selected text. *- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
*- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
** The current selection is first copied to the * clipboard and then deleted from the widget. *
* * @exception SWTException*
* * @since 2.1 */ public void cut () { checkWidget (); if ((style & SWT.READ_ONLY) != 0) return; Point selection = getSelection (); if (selection.x == selection.y) return; int start = selection.x, end = selection.y; String text = getText (); String leftText = text.substring (0, start); String rightText = text.substring (end, text.length ()); String oldText = text.substring (start, end); String newText = ""; if (hooks (SWT.Verify) || filters (SWT.Verify)) { newText = verifyText (newText, start, end, null); if (newText == null) return; } char [] buffer = new char [oldText.length ()]; oldText.getChars (0, buffer.length, buffer, 0); copyToClipboard (buffer); setText (leftText + newText + rightText, false); start += newText.length (); setSelection (new Point (start, start)); sendEvent (SWT.Modify); } @Override Color defaultBackground () { return display.getWidgetColor (SWT.COLOR_LIST_BACKGROUND); } @Override NSFont defaultNSFont() { if ((style & SWT.READ_ONLY) != 0) return display.popUpButtonFont; return display.comboBoxFont; } @Override Color defaultForeground () { return display.getWidgetColor (SWT.COLOR_LIST_FOREGROUND); } @Override void deregister() { super.deregister(); display.removeWidget(((NSControl)view).cell()); } /** * Deselects the item at the given zero-relative index in the receiver's * list. If the item at the index was already deselected, it remains * deselected. Indices that are out of range are ignored. * * @param index the index of the item to deselect * * @exception SWTException- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
*- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
**
*/ public void deselect (int index) { checkWidget (); if (index == -1) return; if (index == getSelectionIndex ()) { if ((style & SWT.READ_ONLY) != 0) { ((NSPopUpButton)view).selectItem(null); sendEvent (SWT.Modify); } else { ((NSComboBox)view).deselectItemAtIndex(index); } } } /** * Deselects all selected items in the receiver's list. *- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
*- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
** Note: To clear the selection in the receiver's text field, * use
* * @exception SWTExceptionclearSelection()
. **
* * @see #clearSelection */ public void deselectAll () { checkWidget (); if ((style & SWT.READ_ONLY) != 0) { ((NSPopUpButton)view).selectItem(null); sendEvent (SWT.Modify); } else { NSComboBox widget = (NSComboBox)view; long /*int*/ index = widget.indexOfSelectedItem(); if (index != -1) widget.deselectItemAtIndex(index); } } @Override boolean dragDetect(int x, int y, boolean filter, boolean[] consume) { if ((style & SWT.READ_ONLY) == 0) { NSText fieldEditor = ((NSControl)view).currentEditor(); if (fieldEditor != null) { NSRange selectedRange = fieldEditor.selectedRange(); if (selectedRange.length > 0) { NSTextView feAsTextView = new NSTextView(fieldEditor); NSPoint textViewMouse = new NSPoint(); textViewMouse.x = x; textViewMouse.y = y; long /*int*/ charPosition = feAsTextView.characterIndexForInsertionAtPoint(textViewMouse); if (charPosition != OS.NSNotFound && charPosition >= selectedRange.location && charPosition < (selectedRange.location + selectedRange.length)) { if (super.dragDetect(x, y, filter, consume)) { if (consume != null) consume[0] = true; return true; } } } } return false; } return super.dragDetect(x, y, filter, consume); } @Override Cursor findCursor () { Cursor cursor = super.findCursor (); return (cursor != null || (style & SWT.READ_ONLY) != 0) ? cursor : display.getSystemCursor (SWT.CURSOR_IBEAM); } @Override NSRect focusRingMaskBoundsForFrame (long /*int*/ id, long /*int*/ sel, NSRect cellFrame, long /*int*/ view) { return cellFrame; } /** * Returns the character position of the caret. *- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
*- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
** Indexing is zero based. *
* * @return the position of the caret * * @exception SWTException*
* * @since 3.8 */ public int getCaretPosition() { checkWidget(); return selectionRange != null ? (int)/*64*/selectionRange.location : 0; } /** * Returns a point describing the location of the caret relative * to the receiver. * * @return a point, the location of the caret * * @exception SWTException- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
*- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
**
* * @since 3.8 */ public Point getCaretLocation() { checkWidget(); NSTextView widget = null; if (this.hasFocus()) { widget = new NSTextView(view.window().fieldEditor(true, view)); } if (widget == null) return new Point (0, 0); NSLayoutManager layoutManager = widget.layoutManager(); NSTextContainer container = widget.textContainer(); NSRange range = widget.selectedRange(); long /*int*/ [] rectCount = new long /*int*/ [1]; long /*int*/ pArray = layoutManager.rectArrayForCharacterRange(range, range, container, rectCount); NSRect rect = new NSRect(); if (rectCount[0] > 0) OS.memmove(rect, pArray, NSRect.sizeof); NSPoint pt = new NSPoint(); pt.x = (int)rect.x; pt.y = (int)rect.y; pt = widget.convertPoint_toView_(pt, view); return new Point((int)pt.x, (int)pt.y); } int getCharCount() { NSString str; if ((style & SWT.READ_ONLY) != 0) { str = ((NSPopUpButton)view).titleOfSelectedItem(); } else { str = new NSCell(((NSComboBox)view).cell()).title(); } if (str == null) return 0; return (int)/*64*/str.length(); } /** * Returns the item at the given, zero-relative index in the * receiver's list. Throws an exception if the index is out * of range. * * @param index the index of the item to return * @return the item at the given index * * @exception IllegalArgumentException- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
*- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
**
* @exception SWTException- ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)
**
*/ public String getItem (int index) { checkWidget (); int count = getItemCount (); if (0 > index || index >= count) error (SWT.ERROR_INVALID_RANGE); NSString str = null; if ((style & SWT.READ_ONLY) != 0) { str = ((NSPopUpButton)view).itemTitleAtIndex(index); } else { NSAttributedString attString = new NSAttributedString(((NSComboBox)view).itemObjectValueAtIndex(index)); if (attString != null) str = attString.string(); } if (str == null) error(SWT.ERROR_CANNOT_GET_ITEM); return str.getString(); } /** * Returns the number of items contained in the receiver's list. * * @return the number of items * * @exception SWTException- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
*- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
**
*/ public int getItemCount () { checkWidget (); if ((style & SWT.READ_ONLY) != 0) { return (int)/*64*/((NSPopUpButton)view).numberOfItems(); } else { return (int)/*64*/((NSComboBox)view).numberOfItems(); } } /** * Returns the height of the area which would be used to * display one of the items in the receiver's list. * * @return the height of one item * * @exception SWTException- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
*- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
**
*/ public int getItemHeight () { checkWidget (); //TODO - not supported by the OS return 26; } /** * Returns a (possibly empty) array of- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
*- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
*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. *
* * @return the items in the receiver's list * * @exception SWTException*
*/ public String [] getItems () { checkWidget (); int count = getItemCount (); String [] result = new String [count]; for (int i=0; i- ERROR_WIDGET_DISPOSED - if the receiver has been disposed
*- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
*true false
otherwise. ** If one of the receiver's ancestors is not visible or some * other condition makes the receiver not visible, this method * may still indicate that it is considered visible even though * it may not actually be showing. *
* * @return the receiver's list's visibility state * * @exception SWTException
-
*
- ERROR_WIDGET_DISPOSED - if the receiver has been disposed *
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver *
-
*
- ERROR_WIDGET_DISPOSED - if the receiver has been disposed *
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver *
Point
whose x coordinate is the
* character position representing the start of the selection
* in the receiver's text field, and whose y coordinate is the
* character position representing the end of the selection.
* An "empty" selection is indicated by the x and y coordinates
* having the same value.
* * Indexing is zero based. The range of a selection is from * 0..N where N is the number of characters in the widget. *
* * @return a point representing the selection start and end * * @exception SWTException-
*
- ERROR_WIDGET_DISPOSED - if the receiver has been disposed *
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver *
-
*
- ERROR_WIDGET_DISPOSED - if the receiver has been disposed *
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver *
-
*
- ERROR_WIDGET_DISPOSED - if the receiver has been disposed *
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver *
-
*
- ERROR_WIDGET_DISPOSED - if the receiver has been disposed *
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver *
setTextLimit()
, it will be the constant
* Combo.LIMIT
.
*
* @return the text limit
*
* @exception SWTException -
*
- ERROR_WIDGET_DISPOSED - if the receiver has been disposed *
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver *
* Note: This operation is a hint and is not supported on * platforms that do not have this concept. *
* * @return the number of items that are visible * * @exception SWTException-
*
- ERROR_WIDGET_DISPOSED - if the receiver has been disposed *
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver *
-
*
- ERROR_NULL_ARGUMENT - if the string is null *
-
*
- ERROR_WIDGET_DISPOSED - if the receiver has been disposed *
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver *
-
*
- ERROR_NULL_ARGUMENT - if the string is null *
-
*
- ERROR_WIDGET_DISPOSED - if the receiver has been disposed *
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver *
-
*
- ERROR_WIDGET_DISPOSED - if the receiver has been disposed *
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver *
-
*
- ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive) *
-
*
- ERROR_WIDGET_DISPOSED - if the receiver has been disposed *
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver *
-
*
- ERROR_INVALID_RANGE - if either the start or end are not between 0 and the number of elements in the list minus 1 (inclusive) *
-
*
- ERROR_WIDGET_DISPOSED - if the receiver has been disposed *
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver *
-
*
- ERROR_NULL_ARGUMENT - if the string is null *
- ERROR_INVALID_ARGUMENT - if the string is not found in the list *
-
*
- ERROR_WIDGET_DISPOSED - if the receiver has been disposed *
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver *
* @exception SWTException
-
*
- ERROR_WIDGET_DISPOSED - if the receiver has been disposed *
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver *
-
*
- ERROR_NULL_ARGUMENT - if the listener is null *
-
*
- ERROR_WIDGET_DISPOSED - if the receiver has been disposed *
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver *
-
*
- ERROR_NULL_ARGUMENT - if the listener is null *
-
*
- ERROR_WIDGET_DISPOSED - if the receiver has been disposed *
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver *
-
*
- ERROR_NULL_ARGUMENT - if the listener is null *
-
*
- ERROR_WIDGET_DISPOSED - if the receiver has been disposed *
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver *
-
*
- ERROR_NULL_ARGUMENT - if the listener is null *
-
*
- ERROR_WIDGET_DISPOSED - if the receiver has been disposed *
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver *
-
*
- ERROR_WIDGET_DISPOSED - if the receiver has been disposed *
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver *
-
*
- ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive) *
- ERROR_NULL_ARGUMENT - if the string is null *
-
*
- ERROR_WIDGET_DISPOSED - if the receiver has been disposed *
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver *
-
*
- ERROR_NULL_ARGUMENT - if the items array is null *
- ERROR_INVALID_ARGUMENT - if an item in the items array is null *
-
*
- ERROR_WIDGET_DISPOSED - if the receiver has been disposed *
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver *
* If one of the receiver's ancestors is not visible or some * other condition makes the receiver not visible, marking * it visible may not actually cause it to be displayed. *
* * @param visible the new visibility state * * @exception SWTException-
*
- ERROR_WIDGET_DISPOSED - if the receiver has been disposed *
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver *
SWT.LEFT_TO_RIGHT
or SWT.RIGHT_TO_LEFT
.
* * * @param orientation new orientation style * * @exception SWTException
-
*
- ERROR_WIDGET_DISPOSED - if the receiver has been disposed *
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver *
-
*
- ERROR_NULL_ARGUMENT - if the point is null *
-
*
- ERROR_WIDGET_DISPOSED - if the receiver has been disposed *
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver *
* This call is ignored when the receiver is read only and * the given string is not in the receiver's list. *
*
* 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.
*
* Also note, if control characters like '\n', '\t' etc. are used * in the string, then the behavior is platform dependent. *
* * @param string the new text * * @exception IllegalArgumentException-
*
- ERROR_NULL_ARGUMENT - if the string is null *
-
*
- ERROR_WIDGET_DISPOSED - if the receiver has been disposed *
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver *
* To reset this value to the default, use setTextLimit(Combo.LIMIT)
.
* Specifying a limit value larger than Combo.LIMIT
sets the
* receiver's limit to Combo.LIMIT
.
*
-
*
- ERROR_CANNOT_BE_ZERO - if the limit is zero *
-
*
- ERROR_WIDGET_DISPOSED - if the receiver has been disposed *
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver *
* Note: This operation is a hint and is not supported on * platforms that do not have this concept. *
* * @param count the new number of items to be visible * * @exception SWTException-
*
- ERROR_WIDGET_DISPOSED - if the receiver has been disposed *
- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver *