/******************************************************************************* * Copyright (c) 2000, 2013 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 *******************************************************************************/ package org.eclipse.swt.widgets; import org.eclipse.swt.SWT; import org.eclipse.swt.SWTException; import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.events.VerifyListener; /** * Instances of this class are selectable user interface objects that allow the * user to enter and modify numeric values. * <p> * Note that although this class is a subclass of <code>Composite</code>, it * does not make sense to add children to it, or set a layout on it. * </p> * <p> * <dl> * <dt><b>Styles:</b></dt> * <dd>READ_ONLY, WRAP</dd> * <dt><b>Events:</b></dt> * <dd>Selection, Modify, Verify</dd> * </dl> * </p> * <p> * IMPORTANT: This class is <em>not</em> intended to be subclassed. * </p> * * @see <a href="http://www.eclipse.org/swt/snippets/#spinner">Spinner * snippets</a> * @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: * ControlExample</a> * @see <a href="http://www.eclipse.org/swt/">Sample code and further * information</a> * * @since 3.1 * @noextend This class is not intended to be subclassed by clients. */ public class Spinner extends Composite { /** * the operating system limit for the number of characters that the text * field in an instance of this class can hold * * @since 3.4 */ public final static 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. * <p> * The style value is either one of the style constants defined in class * <code>SWT</code> which is applicable to instances of this class, or must * be built by <em>bitwise OR</em>'ing together (that is, using the * <code>int</code> "|" operator) two or more of those <code>SWT</code> * style constants. The class description lists the style constants that are * applicable to the class. Style bits are also inherited from superclasses. * </p> * * @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 IllegalArgumentException * <ul> * <li>ERROR_NULL_ARGUMENT - if the parent is null</li> * </ul> * @exception SWTException * <ul> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the * thread that created the parent</li> * <li>ERROR_INVALID_SUBCLASS - if this class is not an * allowed subclass</li> * </ul> * * @see SWT#READ_ONLY * @see SWT#WRAP * @see Widget#checkSubclass * @see Widget#getStyle */ public Spinner(Composite parent, int style) { super(parent, style); } /** * 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 <code>ModifyListener</code> interface. * * @param listener * the listener which should be notified * * @exception IllegalArgumentException * <ul> * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> * </ul> * @exception SWTException * <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been * disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the * thread that created the receiver</li> * </ul> * * @see ModifyListener * @see #removeModifyListener */ public void addModifyListener(ModifyListener listener) { // TODO } /** * Adds the listener to the collection of listeners who will be notified * when the control is selected by the user, by sending it one of the * messages defined in the <code>SelectionListener</code> interface. * <p> * <code>widgetSelected</code> is not called for texts. * <code>widgetDefaultSelected</code> is typically called when ENTER is * pressed in a single-line text. * </p> * * @param listener * the listener which should be notified when the control is * selected by the user * * @exception IllegalArgumentException * <ul> * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> * </ul> * @exception SWTException * <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been * disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the * thread that created the receiver</li> * </ul> * * @see SelectionListener * @see #removeSelectionListener * @see SelectionEvent */ public void addSelectionListener(SelectionListener listener) { // TODO } /** * 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 <code>VerifyListener</code> interface. * * @param listener * the listener which should be notified * * @exception IllegalArgumentException * <ul> * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> * </ul> * @exception SWTException * <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been * disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the * thread that created the receiver</li> * </ul> * * @see VerifyListener * @see #removeVerifyListener */ void addVerifyListener(VerifyListener listener) { // TODO } /** * Copies the selected text. * <p> * The current selection is copied to the clipboard. * </p> * * @exception SWTException * <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been * disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the * thread that created the receiver</li> * </ul> */ public void copy() { // TODO } /** * Cuts the selected text. * <p> * The current selection is first copied to the clipboard and then deleted * from the widget. * </p> * * @exception SWTException * <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been * disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the * thread that created the receiver</li> * </ul> */ public void cut() { // TODO } /** * Returns the amount that the receiver's value will be modified by when the * up/down arrows are pressed. * * @return the increment * * @exception SWTException * <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been * disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the * thread that created the receiver</li> * </ul> */ public int getIncrement() { // TODO return 0; } /** * Returns the maximum value which the receiver will allow. * * @return the maximum * * @exception SWTException * <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been * disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the * thread that created the receiver</li> * </ul> */ public int getMaximum() { // TODO return 0; } /** * Returns the minimum value which the receiver will allow. * * @return the minimum * * @exception SWTException * <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been * disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the * thread that created the receiver</li> * </ul> */ public int getMinimum() { // TODO return 0; } /** * Returns the amount that the receiver's position will be modified by when * the page up/down keys are pressed. * * @return the page increment * * @exception SWTException * <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been * disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the * thread that created the receiver</li> * </ul> */ public int getPageIncrement() { // TODO return 0; } /** * Returns the <em>selection</em>, which is the receiver's position. * * @return the selection * * @exception SWTException * <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been * disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the * thread that created the receiver</li> * </ul> */ public int getSelection() { // TODO return 0; } /** * Returns a string containing a copy of the contents of the receiver's text * field, or an empty string if there are no contents. * * @return the receiver's text * * @exception SWTException * <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been * disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the * thread that created the receiver</li> * </ul> * * @since 3.4 */ public String getText() { // TODO return null; } /** * Returns the maximum number of characters that the receiver's text field * is capable of holding. If this has not been changed by * <code>setTextLimit()</code>, it will be the constant * <code>Spinner.LIMIT</code>. * * @return the text limit * * @exception SWTException * <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been * disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the * thread that created the receiver</li> * </ul> * * @see #LIMIT * * @since 3.4 */ public int getTextLimit() { // TODO return 0; } /** * Returns the number of decimal places used by the receiver. * * @return the digits * * @exception SWTException * <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been * disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the * thread that created the receiver</li> * </ul> */ public int getDigits() { // TODO return 0; } /** * Pastes text from clipboard. * <p> * The selected text is deleted from the widget and new text inserted from * the clipboard. * </p> * * @exception SWTException * <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been * disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the * thread that created the receiver</li> * </ul> */ public void paste() { // TODO } /** * Removes the listener from the collection of listeners who will be * notified when the receiver's text is modified. * * @param listener * the listener which should no longer be notified * * @exception IllegalArgumentException * <ul> * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> * </ul> * @exception SWTException * <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been * disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the * thread that created the receiver</li> * </ul> * * @see ModifyListener * @see #addModifyListener */ public void removeModifyListener(ModifyListener listener) { // TODO } /** * Removes the listener from the collection of listeners who will be * notified when the control is selected by the user. * * @param listener * the listener which should no longer be notified * * @exception IllegalArgumentException * <ul> * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> * </ul> * @exception SWTException * <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been * disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the * thread that created the receiver</li> * </ul> * * @see SelectionListener * @see #addSelectionListener */ public void removeSelectionListener(SelectionListener listener) { // TODO } /** * Removes the listener from the collection of listeners who will be * notified when the control is verified. * * @param listener * the listener which should be notified * * @exception IllegalArgumentException * <ul> * <li>ERROR_NULL_ARGUMENT - if the listener is null</li> * </ul> * @exception SWTException * <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been * disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the * thread that created the receiver</li> * </ul> * * @see VerifyListener * @see #addVerifyListener */ void removeVerifyListener(VerifyListener listener) { // TODO } /** * Sets the amount that the receiver's value will be modified by when the * up/down arrows are pressed to the argument, which must be at least one. * * @param value * the new increment (must be greater than zero) * * @exception SWTException * <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been * disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the * thread that created the receiver</li> * </ul> */ public void setIncrement(int value) { // TODO } /** * Sets the maximum value that the receiver will allow. This new value will * be ignored if it is less than the receiver's current minimum value. If * the new maximum is applied then the receiver's selection value will be * adjusted if necessary to fall within its new range. * * @param value * the new maximum, which must be greater than or equal to the * current minimum * * @exception SWTException * <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been * disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the * thread that created the receiver</li> * </ul> */ public void setMaximum(int value) { // TODO } /** * Sets the minimum value that the receiver will allow. This new value will * be ignored if it is greater than the receiver's current maximum value. If * the new minimum is applied then the receiver's selection value will be * adjusted if necessary to fall within its new range. * * @param value * the new minimum, which must be less than or equal to the * current maximum * * @exception SWTException * <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been * disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the * thread that created the receiver</li> * </ul> */ public void setMinimum(int value) { // TODO } /** * Sets the amount that the receiver's position will be modified by when the * page up/down keys are pressed to the argument, which must be at least * one. * * @param value * the page increment (must be greater than zero) * * @exception SWTException * <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been * disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the * thread that created the receiver</li> * </ul> */ public void setPageIncrement(int value) { // TODO } /** * Sets the <em>selection</em>, which is the receiver's position, to the * argument. If the argument is not within the range specified by minimum * and maximum, it will be adjusted to fall within this range. * * @param value * the new selection (must be zero or greater) * * @exception SWTException * <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been * disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the * thread that created the receiver</li> * </ul> */ public void setSelection(int value) { // TODO } /** * Sets the maximum number of characters that the receiver's text field is * capable of holding to be the argument. * <p> * To reset this value to the default, use * <code>setTextLimit(Spinner.LIMIT)</code>. Specifying a limit value larger * than <code>Spinner.LIMIT</code> sets the receiver's limit to * <code>Spinner.LIMIT</code>. * </p> * * @param limit * new text limit * * @exception IllegalArgumentException * <ul> * <li>ERROR_CANNOT_BE_ZERO - if the limit is zero</li> * </ul> * @exception SWTException * <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been * disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the * thread that created the receiver</li> * </ul> * * @see #LIMIT * * @since 3.4 */ public void setTextLimit(int limit) { // TODO } /** * Sets the number of decimal places used by the receiver. * <p> * The digit setting is used to allow for floating point values in the * receiver. For example, to set the selection to a floating point value of * 1.37 call setDigits() with a value of 2 and setSelection() with a value * of 137. Similarly, if getDigits() has a value of 2 and getSelection() * returns 137 this should be interpreted as 1.37. This applies to all * numeric APIs. * </p> * * @param value * the new digits (must be greater than or equal to zero) * * @exception IllegalArgumentException * <ul> * <li>ERROR_INVALID_ARGUMENT - if the value is less than * zero</li> * </ul> * @exception SWTException * <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been * disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the * thread that created the receiver</li> * </ul> */ public void setDigits(int value) { // TODO } /** * Sets the receiver's selection, minimum value, maximum value, digits, * increment and page increment all at once. * <p> * Note: This is similar to setting the values individually using the * appropriate methods, but may be implemented in a more efficient fashion * on some platforms. * </p> * * @param selection * the new selection value * @param minimum * the new minimum value * @param maximum * the new maximum value * @param digits * the new digits value * @param increment * the new increment value * @param pageIncrement * the new pageIncrement value * * @exception SWTException * <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been * disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the * thread that created the receiver</li> * </ul> * * @since 3.2 */ public void setValues(int selection, int minimum, int maximum, int digits, int increment, int pageIncrement) { // TODO } }