001: /*******************************************************************************
002: * Copyright (c) 2000, 2007 IBM Corporation and others.
003: * All rights reserved. This program and the accompanying materials
004: * are made available under the terms of the Eclipse Public License v1.0
005: * which accompanies this distribution, and is available at
006: * http://www.eclipse.org/legal/epl-v10.html
007: *
008: * Contributors:
009: * IBM Corporation - initial API and implementation
010: *******************************************************************************/package org.eclipse.swt.events;
011:
012: import org.eclipse.swt.widgets.*;
013:
014: /**
015: * Instances of this class are sent as a result of
016: * widgets being selected.
017: * <p>
018: * Note: The fields that are filled in depend on the widget.
019: * </p>
020: *
021: * @see SelectionListener
022: */
023:
024: public class SelectionEvent extends TypedEvent {
025:
026: /**
027: * The item that was selected.
028: */
029: public Widget item;
030:
031: /**
032: * Extra detail information about the selection, depending on the widget.
033: *
034: * <p><b>Sash</b><ul>
035: * <li>{@link org.eclipse.swt.SWT#DRAG}</li>
036: * </ul></p><p><b>ScrollBar and Slider</b><ul>
037: * <li>{@link org.eclipse.swt.SWT#DRAG}</li>
038: * <li>{@link org.eclipse.swt.SWT#HOME}</li>
039: * <li>{@link org.eclipse.swt.SWT#END}</li>
040: * <li>{@link org.eclipse.swt.SWT#ARROW_DOWN}</li>
041: * <li>{@link org.eclipse.swt.SWT#ARROW_UP}</li>
042: * <li>{@link org.eclipse.swt.SWT#PAGE_DOWN}</li>
043: * <li>{@link org.eclipse.swt.SWT#PAGE_UP}</li>
044: * </ul></p><p><b>Table and Tree</b><ul>
045: * <li>{@link org.eclipse.swt.SWT#CHECK}</li>
046: * </ul></p><p><b>Text</b><ul>
047: * <li>{@link org.eclipse.swt.SWT#CANCEL}</li>
048: * </ul></p><p><b>CoolItem and ToolItem</b><ul>
049: * <li>{@link org.eclipse.swt.SWT#ARROW}</li>
050: * </ul></p>
051: */
052: public int detail;
053:
054: /**
055: * The x location of the selected area.
056: */
057: public int x;
058:
059: /**
060: * The y location of selected area.
061: */
062: public int y;
063:
064: /**
065: * The width of selected area.
066: */
067: public int width;
068:
069: /**
070: * The height of selected area.
071: */
072: public int height;
073:
074: /**
075: * The state of the keyboard modifier keys at the time
076: * the event was generated.
077: */
078: public int stateMask;
079:
080: /**
081: * The text of the hyperlink that was selected.
082: * This will be either the text of the hyperlink or the value of its HREF,
083: * if one was specified.
084: *
085: * @see org.eclipse.swt.widgets.Link#setText(String)
086: * @since 3.1
087: */
088: public String text;
089:
090: /**
091: * A flag indicating whether the operation should be allowed.
092: * Setting this field to <code>false</code> will cancel the
093: * operation, depending on the widget.
094: */
095: public boolean doit;
096:
097: static final long serialVersionUID = 3976735856884987953L;
098:
099: /**
100: * Constructs a new instance of this class based on the
101: * information in the given untyped event.
102: *
103: * @param e the untyped event containing the information
104: */
105: public SelectionEvent(Event e) {
106: super (e);
107: this .item = e.item;
108: this .x = e.x;
109: this .y = e.y;
110: this .width = e.width;
111: this .height = e.height;
112: this .detail = e.detail;
113: this .stateMask = e.stateMask;
114: this .text = e.text;
115: this .doit = e.doit;
116: }
117:
118: /**
119: * Returns a string containing a concise, human-readable
120: * description of the receiver.
121: *
122: * @return a string representation of the event
123: */
124: public String toString() {
125: String string = super .toString();
126: return string.substring(0, string.length() - 1) // remove trailing '}'
127: + " item=" + item + " detail=" + detail + " x="
128: + x
129: + " y=" + y + " width=" + width + " height="
130: + height
131: + " stateMask=" + stateMask + " text="
132: + text
133: + " doit=" + doit + "}";
134: }
135: }
|