summaryrefslogtreecommitdiff
path: root/libjava/java/awt/Event.java
blob: 359dc20115e838fbd3c41b4425573aadeaa7df8a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
/* Copyright (C) 1999, 2000, 2002  Free Software Foundation

This file is part of GNU Classpath.

GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.

GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
General Public License for more details.

You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING.  If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.

As a special exception, if you link this library with other files to
produce an executable, this library does not by itself cause the
resulting executable to be covered by the GNU General Public License.
This exception does not however invalidate any other reasons why the
executable file might be covered by the GNU General Public License. */


package java.awt;

/**
 * Written using on-line Java Platform 1.2 API Specification, as well
 * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
 * Status:  Believed complete and correct.
 */

public class Event implements java.io.Serializable
{
  public static final int SHIFT_MASK = 1,
			  CTRL_MASK = 2,
			  META_MASK = 4,
			  ALT_MASK = 8;

  public static final int ACTION_EVENT = 1001,
			  BACK_SPACE = 8,
			  CAPS_LOCK = 1022,
			  DELETE = 127,
			  DOWN = 1005,
			  END = 1001,
			  ENTER = 10,
			  ESCAPE = 27,
			  F1 = 1008,
			  F10 = 1017,
			  F11 = 1018,
			  F12 = 1019,
			  F2 = 1009,
			  F3 = 1010,
			  F4 = 1011,
			  F5 = 1012,
			  F6 = 1013,
			  F7 = 1014,
			  F8 = 1015,
			  F9 = 1016,
			  GOT_FOCUS = 1004,
			  HOME = 1000,
			  INSERT = 1025,
			  KEY_ACTION = 403,
			  KEY_ACTION_RELEASE = 404,
			  KEY_PRESS = 401,
			  KEY_RELEASE = 402,
			  LEFT = 1006,
			  LIST_DESELECT = 702,
			  LIST_SELECT = 701,
			  LOAD_FILE = 1002,
			  LOST_FOCUS = 1005,
			  MOUSE_DOWN = 501,
			  MOUSE_DRAG = 506,
			  MOUSE_ENTER = 504,
			  MOUSE_EXIT = 505,
			  MOUSE_MOVE = 503,
			  MOUSE_UP = 502,
			  NUM_LOCK = 1023,
			  PAUSE = 1024,
			  PGDN = 1003,
			  PGUP = 1002,
			  PRINT_SCREEN = 1020,
			  RIGHT = 1007,
			  SAVE_FILE = 1003,
			  SCROLL_ABSOLUTE = 605,
			  SCROLL_BEGIN = 606,
			  SCROLL_END = 607,
			  SCROLL_LINE_DOWN = 602,
			  SCROLL_LINE_UP = 601,
			  SCROLL_LOCK = 1021,
			  SCROLL_PAGE_DOWN = 604,
			  SCROLL_PAGE_UP = 603,
			  TAB = 9,
			  UP = 1004,
			  WINDOW_DEICONIFY = 204,
			  WINDOW_DESTROY = 201,
			  WINDOW_EXPOSE = 202,
			  WINDOW_ICONIFY = 203,
			  WINDOW_MOVED = 205;

  public Object arg;
  public int clickCount;
  boolean consumed;		// Required by serialization spec.
  public Event evt;
  public int id;
  public int key; 
  public int modifiers;
  public Object target;
  public long when;
  public int x;
  public int y;

  public Event (Object target, int id, Object arg)
  {
    this.id = id;
    this.target = target;
    this.arg = arg;
  }
  
  public Event (Object target, long when, int id, int x, int y, int key, 
		int modifiers)
  {
    this.target = target;
    this.when = when;
    this.id = id;
    this.x = x;
    this.y = y;
    this.key = key;
    this.modifiers = modifiers;
  }

  public Event (Object target, long when, int id, int x, int y, int key, 
	        int modifiers, Object arg) 
  {
    this (target, when, id, x, y, key, modifiers);
    this.arg = arg;
  }

  public boolean controlDown ()
  {
    return ((modifiers & CTRL_MASK) == 0 ? false : true);
  }

  public boolean metaDown ()
  {
    return ((modifiers & META_MASK) == 0 ? false : true);
  }

  protected String paramString ()
  {
    return "id=" + id + ",x=" + x + ",y=" + y + "target=" + target;
  }

  public boolean shiftDown() 
  {
    return ((modifiers & SHIFT_MASK) == 0 ? false : true);
  }

  public String toString()
  {
    return getClass().getName() + "[" + paramString() + "]";
  }

  public void translate (int x, int y)
  {
    this.x += x;
    this.y += y;
  }
}