comparison dwtx/draw2d/EventDispatcher.d @ 98:95307ad235d9

Added Draw2d code, still work in progress
author Frank Benoit <benoit@tionex.de>
date Sun, 03 Aug 2008 00:52:14 +0200
parents
children
comparison
equal deleted inserted replaced
96:b492ba44e44d 98:95307ad235d9
1 /*******************************************************************************
2 * Copyright (c) 2000, 2005 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 dwtx.draw2d.EventDispatcher;
14
15 import dwt.dwthelper.utils;
16
17 import dwt.accessibility.AccessibleControlEvent;
18 import dwt.accessibility.AccessibleControlListener;
19 import dwt.accessibility.AccessibleListener;
20 import dwt.events.FocusEvent;
21 import dwt.events.KeyEvent;
22 import dwt.events.MouseEvent;
23 import dwt.events.TraverseEvent;
24 import dwt.widgets.Control;
25 import dwt.widgets.Event;
26
27 import dwtx.draw2d.IFigure;
28
29 /**
30 * Listens to various DWT events and dispatches these events to interested Draw2d objects.
31 */
32 public abstract class EventDispatcher {
33
34 /**
35 * Combines {@link AccessibleControlListener} and {@link AccessibleListener}.
36 * Implements {@link AccessibleControlListener#getChild(AccessibleControlEvent)} to do
37 * nothing.
38 */
39 public abstract static class AccessibilityDispatcher
40 : AccessibleControlListener, AccessibleListener
41 {
42 /** @see AccessibleControlListener#getChild(AccessibleControlEvent) */
43 public void getChild(AccessibleControlEvent e) { }
44 }
45
46 /**
47 * Dispatches a focus gained event.
48 * @param e the event
49 */
50 public abstract void dispatchFocusGained(FocusEvent e);
51
52 /**
53 * Dispatches a focus lost event.
54 * @param e the event
55 */
56 public abstract void dispatchFocusLost(FocusEvent e);
57
58 /**
59 * Dispatches a key pressed event.
60 * @param e the event
61 */
62 public abstract void dispatchKeyPressed(KeyEvent e);
63
64 /**
65 * Dispatches a key released event.
66 * @param e the event
67 */
68 public abstract void dispatchKeyReleased(KeyEvent e);
69
70 /**
71 * Dispatches a key traversed event.
72 * @param e the event
73 */
74 public abstract void dispatchKeyTraversed(TraverseEvent e);
75
76 /**
77 * Dispatches a mouse double clicked event.
78 * @param me the event
79 */
80 public abstract void dispatchMouseDoubleClicked(MouseEvent me);
81
82 /**
83 * Dispatches a mouse entered event.
84 * @param e the event
85 */
86 public abstract void dispatchMouseEntered(MouseEvent e);
87
88 /**
89 * Dispatches a mouse exited event.
90 * @param e the event
91 */
92 public abstract void dispatchMouseExited(MouseEvent e);
93
94 /**
95 * Dispatches a mouse hover event.
96 * @param me the event
97 */
98 public abstract void dispatchMouseHover(MouseEvent me);
99
100 /**
101 * Dispatches a moved event event.
102 * @param me the event
103 */
104 public abstract void dispatchMouseMoved(MouseEvent me);
105
106 /**
107 * Dispatches a mouse pressed event.
108 * @param me the event
109 */
110 public abstract void dispatchMousePressed(MouseEvent me);
111
112 /**
113 * Dispatches a mouse released event.
114 * @param me the event
115 */
116 public abstract void dispatchMouseReleased(MouseEvent me);
117
118 /**
119 * Dispatches a MouseWheel event. Does nothing by default.
120 * @param event the DWT event
121 * @since 3.1
122 */
123 public void dispatchMouseWheelScrolled(Event event) { }
124
125 /**
126 * Returns the AccessibilityDispatcher.
127 * @return the AccessibilityDispatcher
128 */
129 protected abstract AccessibilityDispatcher getAccessibilityDispatcher();
130 package AccessibilityDispatcher getAccessibilityDispatcher_package(){
131 return getAccessibilityDispatcher();
132 }
133
134 /**
135 * @return the IFigure that currently has focus
136 */
137 /*package*/ abstract IFigure getFocusOwner();
138
139 /**
140 * @return whether events are captured by a figure
141 */
142 public abstract bool isCaptured();
143
144 /**
145 * Releases capture initiated by {@link #setCapture(IFigure)}.
146 */
147 protected abstract void releaseCapture();
148
149 /**
150 * Requests focus for the given figure.
151 * @param fig the figure requesting focus
152 */
153 public abstract void requestFocus(IFigure fig);
154
155 /**
156 * Requests focus to be removed from the given figure.
157 * @param fig the figure requesting focus be removed
158 */
159 public abstract void requestRemoveFocus(IFigure fig);
160
161 /**
162 * Sets capture to the given figure. All subsequent events will be sent to the given
163 * figure until {@link #releaseCapture()} is called.
164 *
165 * @param figure the figure capturing the events
166 */
167 protected abstract void setCapture(IFigure figure);
168
169 /**
170 * Sets the contol associated with this event dispatcher.
171 * @param control the control
172 */
173 public abstract void setControl(Control control);
174
175 /**
176 * Sets the root figure for this dispatcher.
177 * @param figure the root figure
178 */
179 public abstract void setRoot(IFigure figure);
180
181 /**
182 * Updates the cursor.
183 */
184 protected abstract void updateCursor();
185
186 package void updateCursor_package(){
187 updateCursor();
188 }
189
190 }