001: /*
002: * @(#)ToolkitEventHandler.java 1.17 06/10/10
003: *
004: * Copyright 1990-2006 Sun Microsystems, Inc. All Rights Reserved.
005: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
006: *
007: * This program is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU General Public License version
009: * 2 only, as published by the Free Software Foundation.
010: *
011: * This program is distributed in the hope that it will be useful, but
012: * WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * General Public License version 2 for more details (a copy is
015: * included at /legal/license.txt).
016: *
017: * You should have received a copy of the GNU General Public License
018: * version 2 along with this work; if not, write to the Free Software
019: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA
021: *
022: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
023: * Clara, CA 95054 or visit www.sun.com if you need additional
024: * information or have any questions.
025: *
026: */
027:
028: package sun.porting.toolkit;
029:
030: import sun.porting.windowsystem.Window;
031:
032: /**
033: * <code>ToolkitEventHandler</code>
034: * is the only interface that a toolkit presents to the underlying window
035: * system. It is the means for delivering events up into the toolkit.
036: * All of the other interactions between the window system and the toolkit are
037: * in the other direction, i.e. the toolkit issues a directive and the window
038: * system executes it.)
039: *
040: * @version 1.12, 08/19/02
041: */
042: public interface ToolkitEventHandler {
043: /**
044: * Delimiting number: a pointer event will be greater than POINTER_EVENT_START.
045: */
046: final int POINTER_EVENT_START = 0100;
047: /**
048: * Event ID for a pointer press (i.e. a press associated with position
049: * information, like a mouse click, touchscreen press, etc).
050: */
051: final int POINTER_PRESSED = 0101;
052: /**
053: * Event ID for a pointer release (i.e. a press associated with position
054: * information, like a mouse click, touchscreen press, etc). The window
055: * system must guarantee that the release is delivered to the same window
056: * that got the press, unless the focus was explicitly redirected by
057: * the toolkit.
058: */
059: final int POINTER_RELEASED = 0102;
060: /**
061: * Event ID for a drag, i.e. a position change that occurs between
062: * POINTER_PRESSED and POINTER_RELEASED. The window system is responsible
063: * for delivering all drags to the same window that got the press, unless
064: * the focus is explicitly redirected by the toolkit.
065: */
066: final int POINTER_DRAGGED = 0104;
067: /**
068: * Event ID for a position change. This ID is used when the pointer is
069: * being moved but no buttons (etc) are pressed, i.e. not a "drag" event.
070: */
071: final int POINTER_MOVED = 0103;
072: /**
073: * Delimiting number: a pointer event will be less than POINTER_EVENT_END.
074: * (Note that this must be updated if new pointer events are added.)
075: */
076: final int POINTER_EVENT_END = 0104;
077:
078: /**
079: * Called by the window system in order to deliver a pointer event.
080: * @param w The window in which the event occurred.
081: * @param when Time at which the event occurred, in milliseconds since
082: * 1/1/70 UTC.
083: * @param x x coordinate of position at which the event occurred.
084: * Coordinates are relative to the window.
085: * @param y y coordinate of position at which the event occurred.
086: * Coordinates are relative to the window.
087: * @param ID Type identifier indicating the kind of event
088: * @param number Used to distinguish among several buttons (etc) that
089: * could have been pressed or released.
090: * @see java.lang.System#currentTimeMillis
091: */
092: void pointerEventOccurred(Window w, long when, int x, int y,
093: int ID, int number);
094:
095: /**
096: * Delimiting number: a key event will be greater than KEY_EVENT_START.
097: */
098: final int KEY_EVENT_START = 0200;
099: /**
100: * Event ID for a key press corresponding to a typewriter-style keyboard.
101: */
102: final int KEY_PRESSED = 0201;
103: /**
104: * Event ID for a key press corresponding to a typewriter-style keyboard.
105: */
106: final int KEY_RELEASED = 0202;
107: /**
108: * Event ID for an event indicating that a character was typed. This
109: * event is only generated if the window system has taken responsiblity
110: * for translating KEY_PRESSED/KEY_RELEASED events into characters.
111: */
112: final int KEY_TYPED = 0203;
113: /**
114: * Event ID for a press of special "non-keyboard" keys, like
115: * a "GO" key on a remote control.
116: */
117: final int ACTION_PRESSED = 0204;
118: /**
119: * Event ID for a release of special "non-keyboard" keys, like
120: * a "GO" key on a remote control.
121: */
122: final int ACTION_RELEASED = 0205;
123: /**
124: * Delimiting number: a key event will be less than KEY_EVENT_END.
125: * (Note that this must be updated if new key events are added.)
126: */
127: final int KEY_EVENT_END = 0206;
128:
129: /**
130: * Called by the window system in order to deliver a keyboard event.
131: * Keyboard events are delivered to the window that currently has input
132: * focus; whether this is the window that contains the pointer depends on
133: * the focus policy implemented by the toolkit.
134: * @param win The window to which the event is directed (the focus window).
135: * @param when Time at which the event occurred, in milliseconds since
136: * 1/1/70 UTC.
137: * @param ID Type identifier indicating the kind of event
138: * @param keycode A code identifying which key was pressed.
139: * @param keychar Unicode character -- for KEY_TYPED only.
140: * @see java.awt.event.KeyEvent
141: * @see java.lang.System#currentTimeMillis
142: */
143: void keyboardEventOccurred(Window win, long when, int ID,
144: int keycode, char keychar);
145:
146: /**
147: * Delimiting number: a window event will be greater than WINDOW_EVENT_START.
148: */
149: final int WINDOW_EVENT_START = 0300;
150: /**
151: * Event ID for indicating that a window has been reshaped (moved and/or
152: * resized). For this event, {x, y, w, h} are DELTA VALUES, not absolute.
153: */
154: final int WINDOW_RESHAPED = 0301;
155: /**
156: * Event ID for indicating that a window has been assigned keyboard focus.
157: */
158: final int WINDOW_GOT_FOCUS = 0302;
159: /**
160: * Event ID for indicating that a window no longer has the keyboard focus.
161: */
162: final int WINDOW_LOST_FOCUS = 0303;
163: /**
164: * Event ID for indicating that a region of a window needs to be repainted.
165: */
166: final int WINDOW_DAMAGED = 0304;
167: /**
168: * Event ID for indicating that the pointing device has entered the window.
169: */
170: final int WINDOW_ENTERED = 0305;
171: /**
172: * Event ID for indicating that the pointing device has left the window.
173: */
174: final int WINDOW_EXITED = 0306;
175: /**
176: * Event ID for indicating that a window has been mapped (made visible).
177: * The toolkit is allowed to use this event for optimization
178: * purposes but must not depend on it, because it is optional.
179: */
180: final int WINDOW_MAPPED = 0307;
181: /**
182: * Event ID for indicating that a window has been unmapped (made invisible).
183: * The toolkit is allowed to use this event for optimization
184: * purposes but must not depend on it, because it is optional.
185: */
186: final int WINDOW_UNMAPPED = 0310;
187: /**
188: * Event ID for indicating that a mapped window has been clipped and/or
189: * completely covered by one or more other windows (this could include
190: * its children). When the window is no longer completely invisible,
191: * window system is expected to generate WINDOW_DAMAGED events for the
192: * newly-visible portions of the window.)
193: * WINDOW_INVISIBLE events must not be generated when the window is
194: * unmapped.
195: * The toolkit is allowed to use this event for optimization
196: * purposes but must not depend on it, because it is optional.
197: */
198: final int WINDOW_INVISIBLE = 0311;
199: /**
200: * Delimiting number: a window event will be less than WINDOW_EVENT_END.
201: * (Note that this must be updated if new window events are added.)
202: */
203: final int WINDOW_EVENT_END = 0312;
204:
205: /**
206: * Called by the window system in order to deliver a window event.
207: * @param win The window on which the event occurred.
208: * @param when Time at which the event occurred, in milliseconds since
209: * 1/1/70 UTC.
210: * @param x x coordinate of position at which the event occurred.
211: * @param y y coordinate of position at which the event occurred.
212: * Coordinates are relative
213: * to the window's parent for a reshape or map event, but relative
214: * to the window itself for other events (enter, exit, and damage).
215: * @param w Width of window (reshape or map event) or of the
216: * area to be repainted (damage event).
217: * @param h Width of window (reshape or map event) or of the
218: * area to be repainted (damage event).
219: * @param ID Type identifier indicating the kind of event
220: * @see java.awt.event.KeyEvent
221: * @see java.lang.System#currentTimeMillis
222: */
223: void windowEventOccurred(Window win, long when, int x, int y,
224: int w, int h, int ID);
225: }
|