annotate game/IDMButton.java @ 189:189cd8fe2304

Bump copyrights.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 20 Mar 2017 12:23:02 +0200
parents c9b743e32567
children 8dbaa093c562
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
49
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1 /*
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
2 * Ristipolku IDM button widget
189
189cd8fe2304 Bump copyrights.
Matti Hamalainen <ccr@tnsp.org>
parents: 187
diff changeset
3 * (C) Copyright 2011-2017 Matti 'ccr' Hämäläinen <ccr@tnsp.org>
49
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
4 */
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
5 package game;
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
6
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
7 import java.awt.*;
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
8 import java.awt.event.*;
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
9 import java.awt.image.*;
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
10 import java.awt.geom.*;
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
11 import javax.imageio.*;
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
12 import java.io.*;
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
13
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
14
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
15 public class IDMButton extends IDMWidget
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
16 {
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
17 enum State { FOCUSED, PRESSED, NORMAL }
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
18 State state;
178
981a8e20b363 Implement alternative button graphics support.
Matti Hamalainen <ccr@tnsp.org>
parents: 169
diff changeset
19 BufferedImage imgOrigUnpressed, imgOrigPressed;
981a8e20b363 Implement alternative button graphics support.
Matti Hamalainen <ccr@tnsp.org>
parents: 169
diff changeset
20 BufferedImage imgUnpressed, imgPressed;
49
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
21 Font font;
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
22 FontMetrics metrics;
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
23 String text;
50
496e616ff09d More work on IDMgui.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
24 boolean active;
134
4c0dec72e2f0 Whitespace cosmetic cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
25
178
981a8e20b363 Implement alternative button graphics support.
Matti Hamalainen <ccr@tnsp.org>
parents: 169
diff changeset
26 public IDMButton(IDMPoint pos, String prefix, int keyCode, Font font, String text)
49
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
27 {
75
b586ce4f6d97 Large GUI code cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 64
diff changeset
28 super(pos);
178
981a8e20b363 Implement alternative button graphics support.
Matti Hamalainen <ccr@tnsp.org>
parents: 169
diff changeset
29 loadImages(prefix);
169
32b1c41e194a Implement smooth scaling of buttons.
Matti Hamalainen <ccr@tnsp.org>
parents: 163
diff changeset
30 setSize(imgOrigUnpressed.getWidth(), imgOrigUnpressed.getHeight());
32b1c41e194a Implement smooth scaling of buttons.
Matti Hamalainen <ccr@tnsp.org>
parents: 163
diff changeset
31 setScale(1, 1);
75
b586ce4f6d97 Large GUI code cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 64
diff changeset
32
49
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
33 this.font = font;
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
34 this.keyCode = keyCode;
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
35 this.text = text;
75
b586ce4f6d97 Large GUI code cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 64
diff changeset
36
49
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
37 state = State.NORMAL;
50
496e616ff09d More work on IDMgui.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
38 active = false;
49
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
39 }
134
4c0dec72e2f0 Whitespace cosmetic cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
40
178
981a8e20b363 Implement alternative button graphics support.
Matti Hamalainen <ccr@tnsp.org>
parents: 169
diff changeset
41 public IDMButton(IDMPoint pos, int keyCode, Font font, String text)
981a8e20b363 Implement alternative button graphics support.
Matti Hamalainen <ccr@tnsp.org>
parents: 169
diff changeset
42 {
981a8e20b363 Implement alternative button graphics support.
Matti Hamalainen <ccr@tnsp.org>
parents: 169
diff changeset
43 this(pos, "button1", keyCode, font, text);
981a8e20b363 Implement alternative button graphics support.
Matti Hamalainen <ccr@tnsp.org>
parents: 169
diff changeset
44 }
981a8e20b363 Implement alternative button graphics support.
Matti Hamalainen <ccr@tnsp.org>
parents: 169
diff changeset
45
981a8e20b363 Implement alternative button graphics support.
Matti Hamalainen <ccr@tnsp.org>
parents: 169
diff changeset
46 public IDMButton(float x, float y, String prefix, int keyCode, Font font, String text)
981a8e20b363 Implement alternative button graphics support.
Matti Hamalainen <ccr@tnsp.org>
parents: 169
diff changeset
47 {
981a8e20b363 Implement alternative button graphics support.
Matti Hamalainen <ccr@tnsp.org>
parents: 169
diff changeset
48 this(new IDMPoint(x, y), prefix, keyCode, font, text);
981a8e20b363 Implement alternative button graphics support.
Matti Hamalainen <ccr@tnsp.org>
parents: 169
diff changeset
49 }
981a8e20b363 Implement alternative button graphics support.
Matti Hamalainen <ccr@tnsp.org>
parents: 169
diff changeset
50
51
f81f76458b92 Work on widgets.
Matti Hamalainen <ccr@tnsp.org>
parents: 50
diff changeset
51 public IDMButton(float x, float y, int keyCode, Font font, String text)
49
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
52 {
51
f81f76458b92 Work on widgets.
Matti Hamalainen <ccr@tnsp.org>
parents: 50
diff changeset
53 this(new IDMPoint(x, y), keyCode, font, text);
49
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
54 }
134
4c0dec72e2f0 Whitespace cosmetic cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
55
178
981a8e20b363 Implement alternative button graphics support.
Matti Hamalainen <ccr@tnsp.org>
parents: 169
diff changeset
56
981a8e20b363 Implement alternative button graphics support.
Matti Hamalainen <ccr@tnsp.org>
parents: 169
diff changeset
57 public void loadImages(String prefix)
49
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
58 {
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
59 try
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
60 {
178
981a8e20b363 Implement alternative button graphics support.
Matti Hamalainen <ccr@tnsp.org>
parents: 169
diff changeset
61 ResourceLoader res = new ResourceLoader("graphics/"+ prefix +"_up.png");
169
32b1c41e194a Implement smooth scaling of buttons.
Matti Hamalainen <ccr@tnsp.org>
parents: 163
diff changeset
62 imgOrigUnpressed = ImageIO.read(res.getStream());
49
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
63
178
981a8e20b363 Implement alternative button graphics support.
Matti Hamalainen <ccr@tnsp.org>
parents: 169
diff changeset
64 res = new ResourceLoader("graphics/"+ prefix +"_down.png");
169
32b1c41e194a Implement smooth scaling of buttons.
Matti Hamalainen <ccr@tnsp.org>
parents: 163
diff changeset
65 imgOrigPressed = ImageIO.read(res.getStream());
49
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
66 }
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
67 catch (IOException e)
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
68 {
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
69 System.out.print(e.getMessage());
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
70 }
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
71 }
133
881deac2daf8 Some more work on scaling widgets, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 75
diff changeset
72
169
32b1c41e194a Implement smooth scaling of buttons.
Matti Hamalainen <ccr@tnsp.org>
parents: 163
diff changeset
73 public BufferedImage scaleImage(BufferedImage src)
133
881deac2daf8 Some more work on scaling widgets, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 75
diff changeset
74 {
169
32b1c41e194a Implement smooth scaling of buttons.
Matti Hamalainen <ccr@tnsp.org>
parents: 163
diff changeset
75 BufferedImage dst = new BufferedImage(getScaledWidth(), getScaledHeight(), BufferedImage.TYPE_INT_ARGB);
32b1c41e194a Implement smooth scaling of buttons.
Matti Hamalainen <ccr@tnsp.org>
parents: 163
diff changeset
76 Graphics2D gimg = dst.createGraphics();
32b1c41e194a Implement smooth scaling of buttons.
Matti Hamalainen <ccr@tnsp.org>
parents: 163
diff changeset
77
32b1c41e194a Implement smooth scaling of buttons.
Matti Hamalainen <ccr@tnsp.org>
parents: 163
diff changeset
78 gimg.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
32b1c41e194a Implement smooth scaling of buttons.
Matti Hamalainen <ccr@tnsp.org>
parents: 163
diff changeset
79 RenderingHints.VALUE_INTERPOLATION_BICUBIC);
32b1c41e194a Implement smooth scaling of buttons.
Matti Hamalainen <ccr@tnsp.org>
parents: 163
diff changeset
80
32b1c41e194a Implement smooth scaling of buttons.
Matti Hamalainen <ccr@tnsp.org>
parents: 163
diff changeset
81 gimg.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
32b1c41e194a Implement smooth scaling of buttons.
Matti Hamalainen <ccr@tnsp.org>
parents: 163
diff changeset
82 RenderingHints.VALUE_ANTIALIAS_ON);
32b1c41e194a Implement smooth scaling of buttons.
Matti Hamalainen <ccr@tnsp.org>
parents: 163
diff changeset
83
32b1c41e194a Implement smooth scaling of buttons.
Matti Hamalainen <ccr@tnsp.org>
parents: 163
diff changeset
84 gimg.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
32b1c41e194a Implement smooth scaling of buttons.
Matti Hamalainen <ccr@tnsp.org>
parents: 163
diff changeset
85 RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
32b1c41e194a Implement smooth scaling of buttons.
Matti Hamalainen <ccr@tnsp.org>
parents: 163
diff changeset
86
32b1c41e194a Implement smooth scaling of buttons.
Matti Hamalainen <ccr@tnsp.org>
parents: 163
diff changeset
87 gimg.drawImage(src, 0, 0, getScaledWidth(), getScaledHeight(), null);
32b1c41e194a Implement smooth scaling of buttons.
Matti Hamalainen <ccr@tnsp.org>
parents: 163
diff changeset
88 return dst;
32b1c41e194a Implement smooth scaling of buttons.
Matti Hamalainen <ccr@tnsp.org>
parents: 163
diff changeset
89 }
32b1c41e194a Implement smooth scaling of buttons.
Matti Hamalainen <ccr@tnsp.org>
parents: 163
diff changeset
90
32b1c41e194a Implement smooth scaling of buttons.
Matti Hamalainen <ccr@tnsp.org>
parents: 163
diff changeset
91 public void setScale(IDMPoint scale)
32b1c41e194a Implement smooth scaling of buttons.
Matti Hamalainen <ccr@tnsp.org>
parents: 163
diff changeset
92 {
32b1c41e194a Implement smooth scaling of buttons.
Matti Hamalainen <ccr@tnsp.org>
parents: 163
diff changeset
93 super.setScale(scale);
32b1c41e194a Implement smooth scaling of buttons.
Matti Hamalainen <ccr@tnsp.org>
parents: 163
diff changeset
94 imgPressed = scaleImage(imgOrigPressed);
32b1c41e194a Implement smooth scaling of buttons.
Matti Hamalainen <ccr@tnsp.org>
parents: 163
diff changeset
95 imgUnpressed = scaleImage(imgOrigUnpressed);
133
881deac2daf8 Some more work on scaling widgets, etc.
Matti Hamalainen <ccr@tnsp.org>
parents: 75
diff changeset
96 }
134
4c0dec72e2f0 Whitespace cosmetic cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
97
49
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
98 public void paint(Graphics2D g)
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
99 {
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
100 BufferedImage img;
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
101 int xoffs, yoffs;
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
102
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
103 if (state == State.PRESSED)
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
104 {
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
105 img = imgPressed;
187
c9b743e32567 Improve IDMButton scaled click movement.
Matti Hamalainen <ccr@tnsp.org>
parents: 178
diff changeset
106 xoffs = (int) (3.5f * scale.x);
c9b743e32567 Improve IDMButton scaled click movement.
Matti Hamalainen <ccr@tnsp.org>
parents: 178
diff changeset
107 yoffs = (int) (3.5f * scale.y);
49
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
108 }
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
109 else
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
110 {
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
111 xoffs = yoffs = 0;
169
32b1c41e194a Implement smooth scaling of buttons.
Matti Hamalainen <ccr@tnsp.org>
parents: 163
diff changeset
112 img = imgUnpressed;
49
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
113 }
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
114
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
115 if (metrics == null)
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
116 metrics = g.getFontMetrics(font);
134
4c0dec72e2f0 Whitespace cosmetic cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
117
49
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
118 int textWidth = metrics.stringWidth(text);
169
32b1c41e194a Implement smooth scaling of buttons.
Matti Hamalainen <ccr@tnsp.org>
parents: 163
diff changeset
119 g.drawImage(img, getScaledX() + xoffs, getScaledY() + yoffs, null);
49
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
120 g.setFont(font);
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
121 g.setPaint(Color.black);
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
122 g.drawString(text,
75
b586ce4f6d97 Large GUI code cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 64
diff changeset
123 getScaledX() + xoffs + (getScaledWidth() - textWidth) / 2,
b586ce4f6d97 Large GUI code cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 64
diff changeset
124 getScaledY() + yoffs + getScaledHeight() / 2);
49
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
125 }
134
4c0dec72e2f0 Whitespace cosmetic cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
126
4c0dec72e2f0 Whitespace cosmetic cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
127
75
b586ce4f6d97 Large GUI code cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 64
diff changeset
128 public boolean mousePressed(MouseEvent e)
49
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
129 {
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
130 state = State.PRESSED;
50
496e616ff09d More work on IDMgui.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
131 active = true;
75
b586ce4f6d97 Large GUI code cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 64
diff changeset
132 return true;
49
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
133 }
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
134
75
b586ce4f6d97 Large GUI code cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 64
diff changeset
135 public boolean mouseReleased(MouseEvent e)
49
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
136 {
75
b586ce4f6d97 Large GUI code cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 64
diff changeset
137 boolean oldActive = active;
49
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
138 super.mouseReleased(e);
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
139 state = State.NORMAL;
50
496e616ff09d More work on IDMgui.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
140 active = false;
75
b586ce4f6d97 Large GUI code cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 64
diff changeset
141 return oldActive;
49
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
142 }
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
143
75
b586ce4f6d97 Large GUI code cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 64
diff changeset
144 public boolean mouseEntered(MouseEvent e)
49
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
145 {
50
496e616ff09d More work on IDMgui.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
146 if (active)
75
b586ce4f6d97 Large GUI code cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 64
diff changeset
147 {
50
496e616ff09d More work on IDMgui.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
148 state = State.PRESSED;
75
b586ce4f6d97 Large GUI code cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 64
diff changeset
149 return true;
b586ce4f6d97 Large GUI code cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 64
diff changeset
150 }
b586ce4f6d97 Large GUI code cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 64
diff changeset
151 else
b586ce4f6d97 Large GUI code cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 64
diff changeset
152 return false;
50
496e616ff09d More work on IDMgui.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
153 }
496e616ff09d More work on IDMgui.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
154
75
b586ce4f6d97 Large GUI code cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 64
diff changeset
155 public boolean mouseExited(MouseEvent e)
50
496e616ff09d More work on IDMgui.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
156 {
51
f81f76458b92 Work on widgets.
Matti Hamalainen <ccr@tnsp.org>
parents: 50
diff changeset
157 if (active)
75
b586ce4f6d97 Large GUI code cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 64
diff changeset
158 {
51
f81f76458b92 Work on widgets.
Matti Hamalainen <ccr@tnsp.org>
parents: 50
diff changeset
159 state = State.NORMAL;
75
b586ce4f6d97 Large GUI code cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 64
diff changeset
160 return true;
b586ce4f6d97 Large GUI code cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 64
diff changeset
161 }
b586ce4f6d97 Large GUI code cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 64
diff changeset
162 else
b586ce4f6d97 Large GUI code cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 64
diff changeset
163 return false;
49
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
164 }
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
165 }