| 1 |
/******************************************************************************* |
|---|
| 2 |
* Copyright (c) 2000, 2008 IBM Corporation and others. |
|---|
| 3 |
* All rights reserved. This program and the accompanying materials |
|---|
| 4 |
* are made available under the terms of the Eclipse Public License v1.0 |
|---|
| 5 |
* which accompanies this distribution, and is available at |
|---|
| 6 |
* http://www.eclipse.org/legal/epl-v10.html |
|---|
| 7 |
* |
|---|
| 8 |
* Contributors: |
|---|
| 9 |
* IBM Corporation - initial API and implementation |
|---|
| 10 |
* Port to the D programming language: |
|---|
| 11 |
* Frank Benoit <benoit@tionex.de> |
|---|
| 12 |
*******************************************************************************/ |
|---|
| 13 |
module dwt.events.SelectionEvent; |
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
import dwt.widgets.Event; |
|---|
| 17 |
import dwt.widgets.Widget; |
|---|
| 18 |
import dwt.events.TypedEvent; |
|---|
| 19 |
|
|---|
| 20 |
import tango.text.convert.Format; |
|---|
| 21 |
import dwt.dwthelper.utils; |
|---|
| 22 |
|
|---|
| 23 |
/** |
|---|
| 24 |
* Instances of this class are sent as a result of |
|---|
| 25 |
* widgets being selected. |
|---|
| 26 |
* <p> |
|---|
| 27 |
* Note: The fields that are filled in depend on the widget. |
|---|
| 28 |
* </p> |
|---|
| 29 |
* |
|---|
| 30 |
* @see SelectionListener |
|---|
| 31 |
* @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a> |
|---|
| 32 |
*/ |
|---|
| 33 |
|
|---|
| 34 |
public class SelectionEvent : TypedEvent { |
|---|
| 35 |
|
|---|
| 36 |
/** |
|---|
| 37 |
* The item that was selected. |
|---|
| 38 |
*/ |
|---|
| 39 |
public Widget item; |
|---|
| 40 |
|
|---|
| 41 |
/** |
|---|
| 42 |
* Extra detail information about the selection, depending on the widget. |
|---|
| 43 |
* |
|---|
| 44 |
* <p><b>Sash</b><ul> |
|---|
| 45 |
* <li>{@link dwt.DWT#DRAG}</li> |
|---|
| 46 |
* </ul></p><p><b>ScrollBar and Slider</b><ul> |
|---|
| 47 |
* <li>{@link dwt.DWT#DRAG}</li> |
|---|
| 48 |
* <li>{@link dwt.DWT#HOME}</li> |
|---|
| 49 |
* <li>{@link dwt.DWT#END}</li> |
|---|
| 50 |
* <li>{@link dwt.DWT#ARROW_DOWN}</li> |
|---|
| 51 |
* <li>{@link dwt.DWT#ARROW_UP}</li> |
|---|
| 52 |
* <li>{@link dwt.DWT#PAGE_DOWN}</li> |
|---|
| 53 |
* <li>{@link dwt.DWT#PAGE_UP}</li> |
|---|
| 54 |
* </ul></p><p><b>Table and Tree</b><ul> |
|---|
| 55 |
* <li>{@link dwt.DWT#CHECK}</li> |
|---|
| 56 |
* </ul></p><p><b>Text</b><ul> |
|---|
| 57 |
* <li>{@link dwt.DWT#CANCEL}</li> |
|---|
| 58 |
* </ul></p><p><b>CoolItem and ToolItem</b><ul> |
|---|
| 59 |
* <li>{@link dwt.DWT#ARROW}</li> |
|---|
| 60 |
* </ul></p> |
|---|
| 61 |
*/ |
|---|
| 62 |
public int detail; |
|---|
| 63 |
|
|---|
| 64 |
/** |
|---|
| 65 |
* The x location of the selected area. |
|---|
| 66 |
*/ |
|---|
| 67 |
public int x; |
|---|
| 68 |
|
|---|
| 69 |
/** |
|---|
| 70 |
* The y location of selected area. |
|---|
| 71 |
*/ |
|---|
| 72 |
public int y; |
|---|
| 73 |
|
|---|
| 74 |
/** |
|---|
| 75 |
* The width of selected area. |
|---|
| 76 |
*/ |
|---|
| 77 |
public int width; |
|---|
| 78 |
|
|---|
| 79 |
/** |
|---|
| 80 |
* The height of selected area. |
|---|
| 81 |
*/ |
|---|
| 82 |
public int height; |
|---|
| 83 |
|
|---|
| 84 |
/** |
|---|
| 85 |
* The state of the keyboard modifier keys at the time |
|---|
| 86 |
* the event was generated. |
|---|
| 87 |
*/ |
|---|
| 88 |
public int stateMask; |
|---|
| 89 |
|
|---|
| 90 |
/** |
|---|
| 91 |
* The text of the hyperlink that was selected. |
|---|
| 92 |
* This will be either the text of the hyperlink or the value of its HREF, |
|---|
| 93 |
* if one was specified. |
|---|
| 94 |
* |
|---|
| 95 |
* @see dwt.widgets.Link#setText(String) |
|---|
| 96 |
* @since 3.1 |
|---|
| 97 |
*/ |
|---|
| 98 |
public String text; |
|---|
| 99 |
|
|---|
| 100 |
/** |
|---|
| 101 |
* A flag indicating whether the operation should be allowed. |
|---|
| 102 |
* Setting this field to <code>false</code> will cancel the |
|---|
| 103 |
* operation, depending on the widget. |
|---|
| 104 |
*/ |
|---|
| 105 |
public bool doit; |
|---|
| 106 |
|
|---|
| 107 |
//static final long serialVersionUID = 3976735856884987953L; |
|---|
| 108 |
|
|---|
| 109 |
/** |
|---|
| 110 |
* Constructs a new instance of this class based on the |
|---|
| 111 |
* information in the given untyped event. |
|---|
| 112 |
* |
|---|
| 113 |
* @param e the untyped event containing the information |
|---|
| 114 |
*/ |
|---|
| 115 |
public this(Event e) { |
|---|
| 116 |
super(e); |
|---|
| 117 |
this.item = e.item; |
|---|
| 118 |
this.x = e.x; |
|---|
| 119 |
this.y = e.y; |
|---|
| 120 |
this.width = e.width; |
|---|
| 121 |
this.height = e.height; |
|---|
| 122 |
this.detail = e.detail; |
|---|
| 123 |
this.stateMask = e.stateMask; |
|---|
| 124 |
this.text = e.text; |
|---|
| 125 |
this.doit = e.doit; |
|---|
| 126 |
} |
|---|
| 127 |
|
|---|
| 128 |
/** |
|---|
| 129 |
* Returns a string containing a concise, human-readable |
|---|
| 130 |
* description of the receiver. |
|---|
| 131 |
* |
|---|
| 132 |
* @return a string representation of the event |
|---|
| 133 |
*/ |
|---|
| 134 |
public override String toString() { |
|---|
| 135 |
return Format( "{} item={} detail={} x={} y={} width={} height={} stateMask={} text={} doit={}}", |
|---|
| 136 |
super.toString[ 0 .. $-2 ], |
|---|
| 137 |
item, |
|---|
| 138 |
detail, |
|---|
| 139 |
x, |
|---|
| 140 |
y, |
|---|
| 141 |
width, |
|---|
| 142 |
height, |
|---|
| 143 |
stateMask, |
|---|
| 144 |
text, |
|---|
| 145 |
doit ); |
|---|
| 146 |
} |
|---|
| 147 |
} |
|---|