001 /* Copyright (C) 1999, 2000, 2002 Free Software Foundation 002 003 This file is part of GNU Classpath. 004 005 GNU Classpath is free software; you can redistribute it and/or modify 006 it under the terms of the GNU General Public License as published by 007 the Free Software Foundation; either version 2, or (at your option) 008 any later version. 009 010 GNU Classpath is distributed in the hope that it will be useful, but 011 WITHOUT ANY WARRANTY; without even the implied warranty of 012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 013 General Public License for more details. 014 015 You should have received a copy of the GNU General Public License 016 along with GNU Classpath; see the file COPYING. If not, write to the 017 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 018 02110-1301 USA. 019 020 Linking this library statically or dynamically with other modules is 021 making a combined work based on this library. Thus, the terms and 022 conditions of the GNU General Public License cover the whole 023 combination. 024 025 As a special exception, the copyright holders of this library give you 026 permission to link this library with independent modules to produce an 027 executable, regardless of the license terms of these independent 028 modules, and to copy and distribute the resulting executable under 029 terms of your choice, provided that you also meet, for each linked 030 independent module, the terms and conditions of the license of that 031 module. An independent module is a module which is not derived from 032 or based on this library. If you modify this library, you may extend 033 this exception to your version of the library, but you are not 034 obligated to do so. If you do not wish to do so, delete this 035 exception statement from your version. */ 036 037 038 package java.awt; 039 040 /** 041 * Written using on-line Java Platform 1.2 API Specification, as well 042 * as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998). 043 * Status: Believed complete and correct. 044 */ 045 046 public class Event implements java.io.Serializable 047 { 048 static final long serialVersionUID = 5488922509400504703L; 049 050 public static final int SHIFT_MASK = 1; 051 public static final int CTRL_MASK = 2; 052 public static final int META_MASK = 4; 053 public static final int ALT_MASK = 8; 054 055 public static final int ACTION_EVENT = 1001; 056 public static final int BACK_SPACE = 8; 057 public static final int CAPS_LOCK = 1022; 058 public static final int DELETE = 127; 059 public static final int DOWN = 1005; 060 public static final int END = 1001; 061 public static final int ENTER = 10; 062 public static final int ESCAPE = 27; 063 public static final int F1 = 1008; 064 public static final int F10 = 1017; 065 public static final int F11 = 1018; 066 public static final int F12 = 1019; 067 public static final int F2 = 1009; 068 public static final int F3 = 1010; 069 public static final int F4 = 1011; 070 public static final int F5 = 1012; 071 public static final int F6 = 1013; 072 public static final int F7 = 1014; 073 public static final int F8 = 1015; 074 public static final int F9 = 1016; 075 public static final int GOT_FOCUS = 1004; 076 public static final int HOME = 1000; 077 public static final int INSERT = 1025; 078 public static final int KEY_ACTION = 403; 079 public static final int KEY_ACTION_RELEASE = 404; 080 public static final int KEY_PRESS = 401; 081 public static final int KEY_RELEASE = 402; 082 public static final int LEFT = 1006; 083 public static final int LIST_DESELECT = 702; 084 public static final int LIST_SELECT = 701; 085 public static final int LOAD_FILE = 1002; 086 public static final int LOST_FOCUS = 1005; 087 public static final int MOUSE_DOWN = 501; 088 public static final int MOUSE_DRAG = 506; 089 public static final int MOUSE_ENTER = 504; 090 public static final int MOUSE_EXIT = 505; 091 public static final int MOUSE_MOVE = 503; 092 public static final int MOUSE_UP = 502; 093 public static final int NUM_LOCK = 1023; 094 public static final int PAUSE = 1024; 095 public static final int PGDN = 1003; 096 public static final int PGUP = 1002; 097 public static final int PRINT_SCREEN = 1020; 098 public static final int RIGHT = 1007; 099 public static final int SAVE_FILE = 1003; 100 public static final int SCROLL_ABSOLUTE = 605; 101 public static final int SCROLL_BEGIN = 606; 102 public static final int SCROLL_END = 607; 103 public static final int SCROLL_LINE_DOWN = 602; 104 public static final int SCROLL_LINE_UP = 601; 105 public static final int SCROLL_LOCK = 1021; 106 public static final int SCROLL_PAGE_DOWN = 604; 107 public static final int SCROLL_PAGE_UP = 603; 108 public static final int TAB = 9; 109 public static final int UP = 1004; 110 public static final int WINDOW_DEICONIFY = 204; 111 public static final int WINDOW_DESTROY = 201; 112 public static final int WINDOW_EXPOSE = 202; 113 public static final int WINDOW_ICONIFY = 203; 114 public static final int WINDOW_MOVED = 205; 115 116 public Object arg; 117 public int clickCount; 118 boolean consumed; // Required by serialization spec. 119 public Event evt; 120 public int id; 121 public int key; 122 public int modifiers; 123 public Object target; 124 public long when; 125 public int x; 126 public int y; 127 128 public Event (Object target, int id, Object arg) 129 { 130 this.id = id; 131 this.target = target; 132 this.arg = arg; 133 } 134 135 public Event (Object target, long when, int id, int x, int y, int key, 136 int modifiers) 137 { 138 this.target = target; 139 this.when = when; 140 this.id = id; 141 this.x = x; 142 this.y = y; 143 this.key = key; 144 this.modifiers = modifiers; 145 } 146 147 public Event (Object target, long when, int id, int x, int y, int key, 148 int modifiers, Object arg) 149 { 150 this (target, when, id, x, y, key, modifiers); 151 this.arg = arg; 152 } 153 154 public boolean controlDown () 155 { 156 return ((modifiers & CTRL_MASK) == 0 ? false : true); 157 } 158 159 public boolean metaDown () 160 { 161 return ((modifiers & META_MASK) == 0 ? false : true); 162 } 163 164 protected String paramString () 165 { 166 return "id=" + id + ",x=" + x + ",y=" + y 167 + ",target=" + target + ",arg=" + arg; 168 } 169 170 public boolean shiftDown() 171 { 172 return ((modifiers & SHIFT_MASK) == 0 ? false : true); 173 } 174 175 public String toString() 176 { 177 return getClass().getName() + "[" + paramString() + "]"; 178 } 179 180 public void translate (int x, int y) 181 { 182 this.x += x; 183 this.y += y; 184 } 185 }