comparison game/IDMWidget.java @ 49:e6da5c71be28

Add more code to IDM widgets, do preliminary work for integrating them.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 22 Feb 2011 10:52:08 +0200
parents
children 496e616ff09d
comparison
equal deleted inserted replaced
48:f13bab4cccd3 49:e6da5c71be28
1 /*
2 * Ristipolku IDM base widget
3 * (C) Copyright 2011 Matti 'ccr' Hämäläinen <ccr@tnsp.org>
4 */
5 package game;
6
7 import java.awt.*;
8 import java.awt.event.*;
9
10
11 public class IDMWidget
12 {
13 int keyCode;
14
15 public IDMWidget()
16 {
17 keyCode = -1;
18 }
19
20 public void paint(Graphics2D g)
21 {
22 }
23
24 public boolean contains(Point pos)
25 {
26 return false;
27 }
28
29 public void mousePressed(MouseEvent e)
30 {
31 }
32
33 public void mouseReleased(MouseEvent e)
34 {
35 if (contains(e.getPoint()))
36 {
37 clicked();
38 }
39 }
40
41 // Generic key handler
42 public boolean keyPressed(KeyEvent e)
43 {
44 if (e.getKeyCode() == keyCode)
45 {
46 clicked();
47 return true;
48 }
49 else
50 return false;
51 }
52
53 public void clicked()
54 {
55 }
56 }