OSDN Git Service

* libjava.lang/II.java: New file.
[pf3gnuchains/gcc-fork.git] / libjava / java / awt / Event.java
1 /* Copyright (C) 1999, 2000  Free Software Foundation
2
3    This file is part of libjava.
4
5 This software is copyrighted work licensed under the terms of the
6 Libjava License.  Please consult the file "LIBJAVA_LICENSE" for
7 details.  */
8
9 package java.awt;
10
11 /**
12  * Written using on-line Java Platform 1.2 API Specification, as well
13  * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
14  * Status:  Believed complete and correct.
15  */
16
17 public class Event implements java.io.Serializable
18 {
19   public static final int SHIFT_MASK = 1,
20                           CTRL_MASK = 2,
21                           META_MASK = 4,
22                           ALT_MASK = 8;
23
24   public static final int ACTION_EVENT = 1001,
25                           BACK_SPACE = 8,
26                           CAPS_LOCK = 1022,
27                           DELETE = 127,
28                           DOWN = 1005,
29                           END = 1001,
30                           ENTER = 10,
31                           ESCAPE = 27,
32                           F1 = 1008,
33                           F10 = 1017,
34                           F11 = 1018,
35                           F12 = 1019,
36                           F2 = 1009,
37                           F3 = 1010,
38                           F4 = 1011,
39                           F5 = 1012,
40                           F6 = 1013,
41                           F7 = 1014,
42                           F8 = 1015,
43                           F9 = 1016,
44                           GOT_FOCUS = 1004,
45                           HOME = 1000,
46                           INSERT = 1025,
47                           KEY_ACTION = 403,
48                           KEY_ACTION_RELEASE = 404,
49                           KEY_PRESS = 401,
50                           KEY_RELEASE = 402,
51                           LEFT = 1006,
52                           LIST_DESELECT = 702,
53                           LIST_SELECT = 701,
54                           LOAD_FILE = 1002,
55                           LOST_FOCUS = 1005,
56                           MOUSE_DOWN = 501,
57                           MOUSE_DRAG = 506,
58                           MOUSE_ENTER = 504,
59                           MOUSE_EXIT = 505,
60                           MOUSE_MOVE = 503,
61                           MOUSE_UP = 502,
62                           NUM_LOCK = 1023,
63                           PAUSE = 1024,
64                           PGDN = 1003,
65                           PGUP = 1002,
66                           PRINT_SCREEN = 1020,
67                           RIGHT = 1007,
68                           SAVE_FILE = 1003,
69                           SCROLL_ABSOLUTE = 605,
70                           SCROLL_BEGIN = 606,
71                           SCROLL_END = 607,
72                           SCROLL_LINE_DOWN = 602,
73                           SCROLL_LINE_UP = 601,
74                           SCROLL_LOCK = 1021,
75                           SCROLL_PAGE_DOWN = 604,
76                           SCROLL_PAGE_UP = 603,
77                           TAB = 9,
78                           UP = 1004,
79                           WINDOW_DEICONIFY = 204,
80                           WINDOW_DESTROY = 201,
81                           WINDOW_EXPOSE = 202,
82                           WINDOW_ICONIFY = 203,
83                           WINDOW_MOVED = 205;
84
85   public Object arg;
86   public int clickCount;
87   boolean consumed;             // Required by serialization spec.
88   public Event evt;
89   public int id;
90   public int key; 
91   public int modifiers;
92   public Object target;
93   public long when;
94   public int x;
95   public int y;
96
97   public Event (Object target, int id, Object arg)
98   {
99     this.id = id;
100     this.target = target;
101     this.arg = arg;
102   }
103   
104   public Event (Object target, long when, int id, int x, int y, int key, 
105                 int modifiers)
106   {
107     this.target = target;
108     this.when = when;
109     this.id = id;
110     this.x = x;
111     this.y = y;
112     this.key = key;
113     this.modifiers = modifiers;
114   }
115
116   public Event (Object target, long when, int id, int x, int y, int key, 
117                 int modifiers, Object arg) 
118   {
119     this (target, when, id, x, y, key, modifiers);
120     this.arg = arg;
121   }
122
123   public boolean controlDown ()
124   {
125     return ((modifiers & CTRL_MASK) == 0 ? false : true);
126   }
127
128   public boolean metaDown ()
129   {
130     return ((modifiers & META_MASK) == 0 ? false : true);
131   }
132
133   protected String paramString ()
134   {
135     return "id=" + id + ",x=" + x + ",y=" + y + "target=" + target;
136   }
137
138   public boolean shiftDown() 
139   {
140     return ((modifiers & SHIFT_MASK) == 0 ? false : true);
141   }
142
143   public String toString()
144   {
145     return getClass().getName() + "[" + paramString() + "]";
146   }
147
148   public void translate (int x, int y)
149   {
150     this.x += x;
151     this.y += y;
152   }
153 }