OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libjava/] [classpath/] [java/] [awt/] [MenuShortcut.java] - Blame information for rev 771

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 771 jeremybenn
/* MenuShortcut.java -- A class for menu accelerators
2
   Copyright (C) 1999, 2002 Free Software Foundation, Inc.
3
 
4
This file is part of GNU Classpath.
5
 
6
GNU Classpath is free software; you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation; either version 2, or (at your option)
9
any later version.
10
 
11
GNU Classpath is distributed in the hope that it will be useful, but
12
WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
General Public License for more details.
15
 
16
You should have received a copy of the GNU General Public License
17
along with GNU Classpath; see the file COPYING.  If not, write to the
18
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19
02110-1301 USA.
20
 
21
Linking this library statically or dynamically with other modules is
22
making a combined work based on this library.  Thus, the terms and
23
conditions of the GNU General Public License cover the whole
24
combination.
25
 
26
As a special exception, the copyright holders of this library give you
27
permission to link this library with independent modules to produce an
28
executable, regardless of the license terms of these independent
29
modules, and to copy and distribute the resulting executable under
30
terms of your choice, provided that you also meet, for each linked
31
independent module, the terms and conditions of the license of that
32
module.  An independent module is a module which is not derived from
33
or based on this library.  If you modify this library, you may extend
34
this exception to your version of the library, but you are not
35
obligated to do so.  If you do not wish to do so, delete this
36
exception statement from your version. */
37
 
38
 
39
package java.awt;
40
 
41
/**
42
  * This class implements a keyboard accelerator for a menu item.
43
  *
44
  * @author Aaron M. Renn (arenn@urbanophile.com)
45
  */
46
public class MenuShortcut implements java.io.Serializable
47
{
48
 
49
/*
50
 * Static Variables
51
 */
52
 
53
// Serialization Constant
54
private static final long serialVersionUID = 143448358473180225L;
55
 
56
/*************************************************************************/
57
 
58
/*
59
 * Instance Variables
60
 */
61
 
62
/**
63
  * @serial The virtual keycode for the shortcut.
64
  */
65
private int key;
66
 
67
/**
68
  * @serial <code>true</code> if the shift key was used with this shortcut,
69
  * or <code>false</code> otherwise.
70
  */
71
private boolean usesShift;
72
 
73
private String keyName;
74
 
75
/*************************************************************************/
76
 
77
/**
78
  * Initializes a new instance of <code>MenuShortcut</code> with the
79
  * specified virtual key value.
80
  *
81
  * @param key The virtual keycode for the shortcut.
82
  */
83
public
84
MenuShortcut(int key)
85
{
86
  this(key, false);
87
}
88
 
89
/*************************************************************************/
90
 
91
/**
92
  * Initializes a new instance of <code>MenuShortcut</code> with the
93
  * specified virtual key value and shift setting.
94
  *
95
  * @param key The virtual keycode for the shortcut.
96
  * @param usesShift <code>true</code> if the shift key was pressed,
97
  * <code>false</code> otherwise.
98
  */
99
public
100
MenuShortcut(int key, boolean usesShift)
101
{
102
  this.key = key;
103
  this.usesShift = usesShift;
104
  setKeyName(key);
105
}
106
 
107
/*************************************************************************/
108
 
109
/*
110
 * Instance Methods
111
 */
112
 
113
/**
114
  * Returns the virtual keycode for this shortcut.
115
  *
116
  * @return The virtual keycode for this shortcut.
117
  */
118
public int
119
getKey()
120
{
121
  return(key);
122
}
123
 
124
/*************************************************************************/
125
 
126
/**
127
  * Returns the shift setting for this shortcut.
128
  *
129
  * @return <code>true</code> if the shift key was pressed, <code>false</code>
130
  * otherwise.
131
  */
132
public boolean
133
usesShiftModifier()
134
{
135
  return(usesShift);
136
}
137
 
138
/*************************************************************************/
139
 
140
/**
141
  * Tests this object for equality against the specified object.  The two
142
  * objects will be considered equal if and only if the specified object
143
  * is an instance of <code>MenuShortcut</code> and has the same key value
144
  * and shift setting as this object.
145
  *
146
  * @param obj The object to test for equality against.
147
  *
148
  * @return <code>true</code> if the two objects are equal, <code>false</code>
149
  * otherwise.
150
  */
151
public boolean
152
equals(MenuShortcut obj)
153
{
154
  if (obj == null)
155
    return(false);
156
 
157
  if (obj.key != this.key)
158
    return(false);
159
 
160
  if (obj.usesShift != this.usesShift)
161
    return(false);
162
 
163
  return(true);
164
}
165
 
166
public boolean
167
equals(Object obj)
168
{
169
  if (obj instanceof MenuShortcut)
170
    {
171
      MenuShortcut ms = (MenuShortcut) obj;
172
      return (ms.key == key && ms.usesShift == usesShift);
173
    }
174
  return false;
175
}
176
 
177
/*************************************************************************/
178
 
179
/**
180
  * Returns a string representation of this shortcut.
181
  *
182
  * @return A string representation of this shortcut.
183
  */
184
public String
185
toString()
186
{
187
  String temp = "Ctrl+";
188
  if (usesShift)
189
    temp = temp + "Shift+";
190
  temp = temp + keyName;
191
  return temp;
192
}
193
 
194
public int
195
hashCode()
196
{
197
  // Arbitrary.
198
  return key + (usesShift ? 23 : 57);
199
}
200
 
201
/*************************************************************************/
202
 
203
/**
204
  * Returns a debugging string for this object.
205
  *
206
  * @return A debugging string for this object.
207
  */
208
protected String
209
paramString()
210
{
211
  return "key=" + key + ",usesShift=" + usesShift;
212
}
213
 
214
private void
215
setKeyName(int key)
216
{
217
  if (key == '\n')
218
    keyName = "Enter";
219
  else if (key == '\b')
220
    keyName = "Backspace";
221
  else if (key == '\t')
222
    keyName = "Tab";
223
  else if (key == ' ')
224
    keyName = "Space";
225
  else if (key == ',')
226
    keyName = "Comma";
227
  else if (key == '.')
228
    keyName = "Period";
229
  else if (key == '/')
230
    keyName = "Slash";
231
  else if (key == '\\')
232
    keyName = "Back Slash";
233
  else if (key == ';')
234
    keyName = "Semicolon";
235
  else if (key == '=')
236
    keyName = "Equals";
237
  else if (key == '[')
238
    keyName = "Open Bracket";
239
  else if (key == ']')
240
    keyName = "Close Bracket";
241
  else if (key == '0')
242
    keyName = "0";
243
  else if (key == '1')
244
    keyName = "1";
245
  else if (key == '2')
246
    keyName = "2";
247
  else if (key == '3')
248
    keyName = "3";
249
  else if (key == '4')
250
    keyName = "4";
251
  else if (key == '5')
252
    keyName = "5";
253
  else if (key == '6')
254
    keyName = "6";
255
  else if (key == '7')
256
    keyName = "7";
257
  else if (key == '8')
258
    keyName = "8";
259
  else if (key == '9')
260
    keyName = "9";
261
  else if (key == 'A')
262
    keyName = "A";
263
  else if (key == 'B')
264
    keyName = "B";
265
  else if (key == 'C')
266
    keyName = "C";
267
  else if (key == 'D')
268
    keyName = "D";
269
  else if (key == 'E')
270
    keyName = "E";
271
  else if (key == 'F')
272
    keyName = "F";
273
  else if (key == 'G')
274
    keyName = "G";
275
  else if (key == 'H')
276
    keyName = "H";
277
  else if (key == 'I')
278
    keyName = "I";
279
  else if (key == 'J')
280
    keyName = "J";
281
  else if (key == 'K')
282
    keyName = "K";
283
  else if (key == 'L')
284
    keyName = "L";
285
  else if (key == 'M')
286
    keyName = "M";
287
  else if (key == 'N')
288
    keyName = "N";
289
  else if (key == 'O')
290
    keyName = "O";
291
  else if (key == 'P')
292
    keyName = "P";
293
  else if (key == 'Q')
294
    keyName = "Q";
295
  else if (key == 'R')
296
    keyName = "R";
297
  else if (key == 'S')
298
    keyName = "S";
299
  else if (key == 'T')
300
    keyName = "T";
301
  else if (key == 'U')
302
    keyName = "U";
303
  else if (key == 'V')
304
    keyName = "V";
305
  else if (key == 'W')
306
    keyName = "W";
307
  else if (key == 'X')
308
    keyName = "X";
309
  else if (key == 'Y')
310
    keyName = "Y";
311
  else if (key == 'Z')
312
    keyName = "Z";
313
  else if (key == 3)
314
    keyName = "Cancel";
315
  else if (key == 12)
316
    keyName = "Clear";
317
  else if (key == 16)
318
    keyName = "Shift";
319
  else if (key == 17)
320
    keyName = "Ctrl";
321
  else if (key == 18)
322
    keyName = "Alt";
323
  else if (key == 19)
324
    keyName = "Pause";
325
  else if (key == 20)
326
    keyName = "Caps Lock";
327
  else if (key == 21)
328
    keyName = "Kana";
329
  else if (key == 24)
330
    keyName = "Final";
331
  else if (key == 25)
332
    keyName = "Kanji";
333
  else if (key == 27)
334
    keyName = "Escape";
335
  else if (key == 28)
336
    keyName = "Convert";
337
  else if (key == 29)
338
    keyName = "No Convert";
339
  else if (key == 30)
340
    keyName = "Accept";
341
  else if (key == 31)
342
    keyName = "Mode Change";
343
  else if (key == 33)
344
    keyName = "Page Up";
345
  else if (key == 34)
346
    keyName = "Page Down";
347
  else if (key == 35)
348
    keyName = "End";
349
  else if (key == 36)
350
    keyName = "Home";
351
  else if (key == 37)
352
    keyName = "Left";
353
  else if (key == 38)
354
    keyName = "Up";
355
  else if (key == 39)
356
    keyName = "Right";
357
  else if (key == 40)
358
    keyName = "Down";
359
  else if (key == 96)
360
    keyName = "NumPad-0";
361
  else if (key == 97)
362
    keyName = "NumPad-1";
363
  else if (key == 98)
364
    keyName = "NumPad-2";
365
  else if (key == 99)
366
    keyName = "NumPad-3";
367
  else if (key == 100)
368
    keyName = "NumPad-4";
369
  else if (key == 101)
370
    keyName = "NumPad-5";
371
  else if (key == 102)
372
    keyName = "NumPad-6";
373
  else if (key == 103)
374
    keyName = "NumPad-7";
375
  else if (key == 104)
376
    keyName = "NumPad-8";
377
  else if (key == 105)
378
    keyName = "NumPad-9";
379
  else if (key == 106)
380
    keyName = "NumPad *";
381
  else if (key == 107)
382
    keyName = "NumPad +";
383
  else if (key == 108)
384
    keyName = "NumPad ,";
385
  else if (key == 109)
386
    keyName = "NumPad -";
387
  else if (key == 110)
388
    keyName = "NumPad .";
389
  else if (key == 111)
390
    keyName = "NumPad /";
391
  else if (key == 112)
392
    keyName = "F1";
393
  else if (key == 113)
394
    keyName = "F2";
395
  else if (key == 114)
396
    keyName = "F3";
397
  else if (key == 115)
398
    keyName = "F4";
399
  else if (key == 116)
400
    keyName = "F5";
401
  else if (key == 117)
402
    keyName = "F6";
403
  else if (key == 118)
404
    keyName = "F7";
405
  else if (key == 119)
406
    keyName = "F8";
407
  else if (key == 120)
408
    keyName = "F9";
409
  else if (key == 121)
410
    keyName = "F10";
411
  else if (key == 122)
412
    keyName = "F11";
413
  else if (key == 123)
414
    keyName = "F12";
415
  else if (key == 127)
416
    keyName = "Delete";
417
  else if (key == 144)
418
    keyName = "Num Lock";
419
  else if (key == 145)
420
    keyName = "Scroll Lock";
421
  else if (key == 154)
422
    keyName = "Print Screen";
423
  else if (key == 155)
424
    keyName = "Insert";
425
  else if (key == 156)
426
    keyName = "Help";
427
  else if (key == 157)
428
    keyName = "Meta";
429
  else if (key == 192)
430
    keyName = "Back Quote";
431
  else if (key == 222)
432
    keyName = "Quote";
433
}
434
} // class MenuShortcut

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.