annotate dwt/events/SelectionListener.d @ 156:969e7de37c3d default tip

Fixes to get dwt to work with dmd and ldc
author Jacob Carlborg <doob@me.com>
date Wed, 08 Jul 2009 21:56:44 +0200
parents d8635bb48c7c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
45
d8635bb48c7c Merge with SWT 3.5
Jacob Carlborg <doob@me.com>
parents: 39
diff changeset
1 /*******************************************************************************
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
2 * Copyright (c) 2000, 2005 IBM Corporation and others.
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
3 * All rights reserved. This program and the accompanying materials
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
4 * are made available under the terms of the Eclipse Public License v1.0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
5 * which accompanies this distribution, and is available at
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
6 * http://www.eclipse.org/legal/epl-v10.html
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
7 *
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
8 * Contributors:
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
9 * IBM Corporation - initial API and implementation
34
5123b17c98ef Ported dwt.events.*, dwt.graphics.GC, Region, dwt.internal.image.*
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents: 3
diff changeset
10 * Port to the D programming language:
5123b17c98ef Ported dwt.events.*, dwt.graphics.GC, Region, dwt.internal.image.*
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents: 3
diff changeset
11 * Frank Benoit <benoit@tionex.de>
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
12 *******************************************************************************/
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
13 module dwt.events.SelectionListener;
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
14
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
15
34
5123b17c98ef Ported dwt.events.*, dwt.graphics.GC, Region, dwt.internal.image.*
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents: 3
diff changeset
16 public import dwt.internal.DWTEventListener;
5123b17c98ef Ported dwt.events.*, dwt.graphics.GC, Region, dwt.internal.image.*
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents: 3
diff changeset
17 public import dwt.events.SelectionEvent;
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
18
39
43be986a1372 Sync events with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 34
diff changeset
19 import tango.core.Traits;
43be986a1372 Sync events with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 34
diff changeset
20 import tango.core.Tuple;
43be986a1372 Sync events with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 34
diff changeset
21
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
22 /**
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
23 * Classes which implement this interface provide methods
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
24 * that deal with the events that are generated when selection
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
25 * occurs in a control.
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
26 * <p>
34
5123b17c98ef Ported dwt.events.*, dwt.graphics.GC, Region, dwt.internal.image.*
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents: 3
diff changeset
27 * After creating an instance of a class that :
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
28 * this interface it can be added to a control using the
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
29 * <code>addSelectionListener</code> method and removed using
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
30 * the <code>removeSelectionListener</code> method. When
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
31 * selection occurs in a control the appropriate method
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
32 * will be invoked.
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
33 * </p>
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
34 *
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
35 * @see SelectionAdapter
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
36 * @see SelectionEvent
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
37 */
3
649b8e223d5a fix extends
Frank Benoit <benoit@tionex.de>
parents: 0
diff changeset
38 public interface SelectionListener : DWTEventListener {
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
39
39
43be986a1372 Sync events with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 34
diff changeset
40 public enum {
43be986a1372 Sync events with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 34
diff changeset
41 SELECTION,
43be986a1372 Sync events with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 34
diff changeset
42 DEFAULTSELECTION
43be986a1372 Sync events with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 34
diff changeset
43 }
0
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
44 /**
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
45 * Sent when selection occurs in the control.
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
46 * <p>
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
47 * For example, selection occurs in a List when the user selects
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
48 * an item or items with the keyboard or mouse. On some platforms,
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
49 * the event occurs when a mouse button or key is pressed. On others,
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
50 * it happens when the mouse or key is released. The exact key or
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
51 * mouse gesture that causes this event is platform specific.
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
52 * </p>
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
53 *
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
54 * @param e an event containing information about the selection
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
55 */
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
56 public void widgetSelected(SelectionEvent e);
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
57
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
58 /**
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
59 * Sent when default selection occurs in the control.
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
60 * <p>
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
61 * For example, on some platforms default selection occurs in a List
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
62 * when the user double-clicks an item or types return in a Text.
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
63 * On some platforms, the event occurs when a mouse button or key is
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
64 * pressed. On others, it happens when the mouse or key is released.
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
65 * The exact key or mouse gesture that causes this event is platform
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
66 * specific.
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
67 * </p>
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
68 *
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
69 * @param e an event containing information about the default selection
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
70 */
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
71 public void widgetDefaultSelected(SelectionEvent e);
380af2bdd8e5 Upload of whole dwt tree
Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com>
parents:
diff changeset
72 }
39
43be986a1372 Sync events with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 34
diff changeset
73
43be986a1372 Sync events with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 34
diff changeset
74
43be986a1372 Sync events with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 34
diff changeset
75 /// DWT extension
43be986a1372 Sync events with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 34
diff changeset
76 private class _DgSelectionListenerT(Dg,T...) : SelectionListener {
43be986a1372 Sync events with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 34
diff changeset
77
43be986a1372 Sync events with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 34
diff changeset
78 alias ParameterTupleOf!(Dg) DgArgs;
43be986a1372 Sync events with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 34
diff changeset
79 static assert( is(DgArgs == Tuple!(SelectionEvent,T)),
43be986a1372 Sync events with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 34
diff changeset
80 "Delegate args not correct: "~DgArgs.stringof~" vs. (Event,"~T.stringof~")" );
43be986a1372 Sync events with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 34
diff changeset
81
43be986a1372 Sync events with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 34
diff changeset
82 Dg dg;
43be986a1372 Sync events with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 34
diff changeset
83 T t;
43be986a1372 Sync events with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 34
diff changeset
84 int type;
43be986a1372 Sync events with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 34
diff changeset
85
43be986a1372 Sync events with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 34
diff changeset
86 private this( int type, Dg dg, T t ){
43be986a1372 Sync events with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 34
diff changeset
87 this.type = type;
43be986a1372 Sync events with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 34
diff changeset
88 this.dg = dg;
43be986a1372 Sync events with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 34
diff changeset
89 static if( T.length > 0 ){
43be986a1372 Sync events with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 34
diff changeset
90 this.t = t;
43be986a1372 Sync events with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 34
diff changeset
91 }
43be986a1372 Sync events with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 34
diff changeset
92 }
43be986a1372 Sync events with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 34
diff changeset
93
43be986a1372 Sync events with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 34
diff changeset
94 public void widgetSelected(SelectionEvent e){
43be986a1372 Sync events with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 34
diff changeset
95 if( type is SelectionListener.SELECTION ){
43be986a1372 Sync events with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 34
diff changeset
96 dg(e,t);
43be986a1372 Sync events with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 34
diff changeset
97 }
43be986a1372 Sync events with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 34
diff changeset
98 }
43be986a1372 Sync events with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 34
diff changeset
99 public void widgetDefaultSelected(SelectionEvent e){
43be986a1372 Sync events with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 34
diff changeset
100 if( type is SelectionListener.DEFAULTSELECTION ){
43be986a1372 Sync events with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 34
diff changeset
101 dg(e,t);
43be986a1372 Sync events with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 34
diff changeset
102 }
43be986a1372 Sync events with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 34
diff changeset
103 }
43be986a1372 Sync events with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 34
diff changeset
104 }
43be986a1372 Sync events with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 34
diff changeset
105
43be986a1372 Sync events with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 34
diff changeset
106 SelectionListener dgSelectionListener( Dg, T... )( int type, Dg dg, T args ){
43be986a1372 Sync events with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 34
diff changeset
107 return new _DgSelectionListenerT!( Dg, T )( type, dg, args );
43be986a1372 Sync events with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 34
diff changeset
108 }
43be986a1372 Sync events with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 34
diff changeset
109
43be986a1372 Sync events with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 34
diff changeset
110 SelectionListener dgSelectionListenerWidgetSelected( Dg, T... )( Dg dg, T args ){
43be986a1372 Sync events with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 34
diff changeset
111 return dgSelectionListener( SelectionListener.SELECTION, dg, args );
43be986a1372 Sync events with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 34
diff changeset
112 }
43be986a1372 Sync events with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 34
diff changeset
113 SelectionListener dgSelectionListenerWidgetDefaultSelected( Dg, T... )( Dg dg, T args ){
43be986a1372 Sync events with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 34
diff changeset
114 return dgSelectionListener( SelectionListener.DEFAULTSELECTION, dg, args );
43be986a1372 Sync events with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 34
diff changeset
115 }
43be986a1372 Sync events with dwt-linux
Frank Benoit <benoit@tionex.de>
parents: 34
diff changeset
116