annotate game/IDMButton.java @ 178:981a8e20b363

Implement alternative button graphics support.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 16 Mar 2017 10:45:39 +0200
parents 32b1c41e194a
children c9b743e32567
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
151
d6d92845d6a2 ISO-8859-1 -> UTF-8.
Matti Hamalainen <ccr@tnsp.org>
parents: 134
diff changeset
3 * (C) Copyright 2011 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;
50
496e616ff09d More work on IDMgui.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
106 xoffs = yoffs = 5;
49
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
107 }
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
108 else
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
109 {
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
110 xoffs = yoffs = 0;
169
32b1c41e194a Implement smooth scaling of buttons.
Matti Hamalainen <ccr@tnsp.org>
parents: 163
diff changeset
111 img = imgUnpressed;
49
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
112 }
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 if (metrics == null)
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
115 metrics = g.getFontMetrics(font);
134
4c0dec72e2f0 Whitespace cosmetic cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
116
49
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
117 int textWidth = metrics.stringWidth(text);
169
32b1c41e194a Implement smooth scaling of buttons.
Matti Hamalainen <ccr@tnsp.org>
parents: 163
diff changeset
118 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
119 g.setFont(font);
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
120 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
121 g.drawString(text,
75
b586ce4f6d97 Large GUI code cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 64
diff changeset
122 getScaledX() + xoffs + (getScaledWidth() - textWidth) / 2,
b586ce4f6d97 Large GUI code cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 64
diff changeset
123 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
124 }
134
4c0dec72e2f0 Whitespace cosmetic cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
125
4c0dec72e2f0 Whitespace cosmetic cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
126
75
b586ce4f6d97 Large GUI code cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 64
diff changeset
127 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
128 {
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
129 state = State.PRESSED;
50
496e616ff09d More work on IDMgui.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
130 active = true;
75
b586ce4f6d97 Large GUI code cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 64
diff changeset
131 return true;
49
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
132 }
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
133
75
b586ce4f6d97 Large GUI code cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 64
diff changeset
134 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
135 {
75
b586ce4f6d97 Large GUI code cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 64
diff changeset
136 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
137 super.mouseReleased(e);
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
138 state = State.NORMAL;
50
496e616ff09d More work on IDMgui.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
139 active = false;
75
b586ce4f6d97 Large GUI code cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 64
diff changeset
140 return oldActive;
49
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
141 }
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
142
75
b586ce4f6d97 Large GUI code cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 64
diff changeset
143 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
144 {
50
496e616ff09d More work on IDMgui.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
145 if (active)
75
b586ce4f6d97 Large GUI code cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 64
diff changeset
146 {
50
496e616ff09d More work on IDMgui.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
147 state = State.PRESSED;
75
b586ce4f6d97 Large GUI code cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 64
diff changeset
148 return true;
b586ce4f6d97 Large GUI code cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 64
diff changeset
149 }
b586ce4f6d97 Large GUI code cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 64
diff changeset
150 else
b586ce4f6d97 Large GUI code cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 64
diff changeset
151 return false;
50
496e616ff09d More work on IDMgui.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
152 }
496e616ff09d More work on IDMgui.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
153
75
b586ce4f6d97 Large GUI code cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 64
diff changeset
154 public boolean mouseExited(MouseEvent e)
50
496e616ff09d More work on IDMgui.
Matti Hamalainen <ccr@tnsp.org>
parents: 49
diff changeset
155 {
51
f81f76458b92 Work on widgets.
Matti Hamalainen <ccr@tnsp.org>
parents: 50
diff changeset
156 if (active)
75
b586ce4f6d97 Large GUI code cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 64
diff changeset
157 {
51
f81f76458b92 Work on widgets.
Matti Hamalainen <ccr@tnsp.org>
parents: 50
diff changeset
158 state = State.NORMAL;
75
b586ce4f6d97 Large GUI code cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 64
diff changeset
159 return true;
b586ce4f6d97 Large GUI code cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 64
diff changeset
160 }
b586ce4f6d97 Large GUI code cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 64
diff changeset
161 else
b586ce4f6d97 Large GUI code cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 64
diff changeset
162 return false;
49
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
163 }
e6da5c71be28 Add more code to IDM widgets, do preliminary work for integrating them.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
164 }