1
|
=== modified file 'src/com/goldencode/p2j/ui/client/gui/driver/AbstractGuiDriver.java'
|
2
|
--- src/com/goldencode/p2j/ui/client/gui/driver/AbstractGuiDriver.java 2015-08-28 13:58:40 +0000
|
3
|
+++ src/com/goldencode/p2j/ui/client/gui/driver/AbstractGuiDriver.java 2015-09-01 12:37:18 +0000
|
4
|
@@ -24,6 +24,7 @@
|
5
|
** 007 GES 20150817 Removed isOnTop() since it is unnecessary. Added an abstract method for
|
6
|
** window restacking. Editable and Movable actions are moved at the driver level.
|
7
|
** deriveFont() now is driver specific - it scales the font depending on the DPI.
|
8
|
+** Implemented setIcon().
|
9
|
*/
|
10
|
|
11
|
package com.goldencode.p2j.ui.client.gui.driver;
|
12
|
@@ -1004,6 +1005,28 @@
|
13
|
}
|
14
|
|
15
|
/**
|
16
|
+ * Sets the image to the window to be displayed as the window icon representation
|
17
|
+ * for the system task bar, the title window panel or the system tray icons panel.
|
18
|
+ *
|
19
|
+ * @param icon
|
20
|
+ * The wrapped icon.
|
21
|
+ * @param width
|
22
|
+ * the icon width.
|
23
|
+ * @param height
|
24
|
+ * the icon height.
|
25
|
+ */
|
26
|
+ @Override
|
27
|
+ public void setIcon(ImageWrapper<BufferedImage> icon, int width, int height)
|
28
|
+ {
|
29
|
+ PaintStructure ps = new PaintStructure(PaintPrimitives.SET_ICON);
|
30
|
+ ps.img = icon;
|
31
|
+ ps.width = width;
|
32
|
+ ps.height = height;
|
33
|
+
|
34
|
+ ews.offer(ps);
|
35
|
+ }
|
36
|
+
|
37
|
+ /**
|
38
|
* Set current font used on draw operations.
|
39
|
*
|
40
|
* @param font
|
41
|
|
42
|
=== modified file 'src/com/goldencode/p2j/ui/client/gui/driver/GuiDriver.java'
|
43
|
--- src/com/goldencode/p2j/ui/client/gui/driver/GuiDriver.java 2015-08-26 22:14:27 +0000
|
44
|
+++ src/com/goldencode/p2j/ui/client/gui/driver/GuiDriver.java 2015-09-01 12:46:23 +0000
|
45
|
@@ -54,7 +54,7 @@
|
46
|
** 030 GES 20150730 Removed translatedOrigin() since it isn't actually used.translate() was
|
47
|
** converted to translatePush()/translatePop() to make it clear that they need
|
48
|
** to have matched pairs.
|
49
|
-** 031 GES 20150817 Removed isOnTop() since it is unnecessary.
|
50
|
+** 031 GES 20150817 Removed isOnTop() since it is unnecessary, added setIcon().
|
51
|
*/
|
52
|
|
53
|
package com.goldencode.p2j.ui.client.gui.driver;
|
54
|
@@ -957,4 +957,17 @@
|
55
|
* Register all the mouse-aware widgets (in all Windows) with the driver.
|
56
|
*/
|
57
|
public void registerMouseWidgets();
|
58
|
+
|
59
|
+ /**
|
60
|
+ * Sets the image to the window to be displayed as the window icon representation
|
61
|
+ * for the system task bar, the title window panel or the system tray icons panel.
|
62
|
+ *
|
63
|
+ * @param icon
|
64
|
+ * The wrapped icon.
|
65
|
+ * @param width
|
66
|
+ * the icon width.
|
67
|
+ * @param height
|
68
|
+ * the icon height.
|
69
|
+ */
|
70
|
+ public void setIcon(ImageWrapper<I> icon, int width, int height);
|
71
|
}
|
72
|
|
73
|
=== modified file 'src/com/goldencode/p2j/ui/client/gui/driver/PaintPrimitives.java'
|
74
|
--- src/com/goldencode/p2j/ui/client/gui/driver/PaintPrimitives.java 2015-08-26 22:14:27 +0000
|
75
|
+++ src/com/goldencode/p2j/ui/client/gui/driver/PaintPrimitives.java 2015-09-01 12:38:06 +0000
|
76
|
@@ -20,7 +20,7 @@
|
77
|
** 009 CA 20150408 Added SET_TITLE.
|
78
|
** 010 GES 20150422 Moved this class to a more generic location (not specific to Swing).
|
79
|
** 011 HC 20150612 Implemented support for paragraph layout.
|
80
|
-** 012 GES 20150720 Added a warning about future modifications.
|
81
|
+** 012 GES 20150720 Added a warning about future modifications, added SET_ICON.
|
82
|
*/
|
83
|
|
84
|
package com.goldencode.p2j.ui.client.gui.driver;
|
85
|
@@ -69,5 +69,6 @@
|
86
|
CLEAR_HIGHLIGHT,
|
87
|
START_BATCH,
|
88
|
END_BATCH,
|
89
|
- SET_TITLE;
|
90
|
+ SET_TITLE,
|
91
|
+ SET_ICON;
|
92
|
}
|
93
|
|
94
|
=== modified file 'src/com/goldencode/p2j/ui/client/gui/driver/swing/SwingEmulatedWindow.java'
|
95
|
--- src/com/goldencode/p2j/ui/client/gui/driver/swing/SwingEmulatedWindow.java 2015-08-31 20:45:55 +0000
|
96
|
+++ src/com/goldencode/p2j/ui/client/gui/driver/swing/SwingEmulatedWindow.java 2015-09-01 12:42:06 +0000
|
97
|
@@ -59,6 +59,7 @@
|
98
|
** 030 GES 20150817 Removed isOnTop() since it is unnecessary. The saveFocusListeners(),
|
99
|
** restoreFocusListeners() and moveToTop() are only needed for Swing usage and
|
100
|
** are now just local helper methods. Added custom Swing mouse handler.
|
101
|
+** Implemented SET_ICON drawing primitive.
|
102
|
*/
|
103
|
|
104
|
package com.goldencode.p2j.ui.client.gui.driver.swing;
|
105
|
@@ -831,6 +832,10 @@
|
106
|
{
|
107
|
((JDialog) window).setTitle(ps.title);
|
108
|
}
|
109
|
+ break;
|
110
|
+ case SET_ICON:
|
111
|
+ window.setIconImage(ps.img.getImage());
|
112
|
+ break;
|
113
|
default:
|
114
|
break;
|
115
|
}
|
116
|
|
117
|
=== modified file 'src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebEmulatedWindow.java'
|
118
|
--- src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebEmulatedWindow.java 2015-08-31 20:45:55 +0000
|
119
|
+++ src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebEmulatedWindow.java 2015-09-01 12:45:11 +0000
|
120
|
@@ -19,7 +19,8 @@
|
121
|
** restoreFocusListeners() and moveToTop() are only needed for Swing usage and
|
122
|
** have been removed from this class, added line strokes.
|
123
|
** Added captureMouseEvents to enable mouse support.
|
124
|
-** Improvements for mouse support: added dedicated mouse handler.
|
125
|
+** Improvements for mouse support: added dedicated mouse handler. Implemented
|
126
|
+** SET_ICON drawing primitive.
|
127
|
*/
|
128
|
|
129
|
package com.goldencode.p2j.ui.client.gui.driver.web;
|
130
|
@@ -313,25 +314,15 @@
|
131
|
websock.drawRoundRect(ps.x, ps.y, ps.width, ps.height, ps.arcDiameter);
|
132
|
break;
|
133
|
case DRAW_IMAGE:
|
134
|
- ImageWrapper wrappedImage = drawHelper.processImage(ps);
|
135
|
- VirtualScreen virtualScreen = webdriver.getVirtualScreen();
|
136
|
- int imageHash = wrappedImage.getImage().hashCode();
|
137
|
- ImageEncoding encoding;
|
138
|
- byte[] encodedImage;
|
139
|
- if (webdriver.addImageUsage(imageHash, windowId))
|
140
|
- {
|
141
|
- encoding = ImageEncoding.RAW;
|
142
|
- virtualScreen.drawImage(wrappedImage, ps.x, ps.y);
|
143
|
- encodedImage = new RawEncoder().packToBinaries(virtualScreen, ps.x, ps.y,
|
144
|
- wrappedImage.getWidth(), wrappedImage.getHeight());
|
145
|
- }
|
146
|
- else
|
147
|
- {
|
148
|
- encoding = ImageEncoding.HASH;
|
149
|
- encodedImage = null;
|
150
|
- }
|
151
|
- websock.drawImage(ps.x, ps.y, wrappedImage.getWidth(), wrappedImage.getHeight(),
|
152
|
- encoding, imageHash, encodedImage);
|
153
|
+ {
|
154
|
+ ImageWrapper wrappedImage = drawHelper.processImage(ps);
|
155
|
+ Object[] imageEncodedPacket = encodeImage(ps.x, ps.y, wrappedImage);
|
156
|
+ int imageHash = (Integer) imageEncodedPacket[0];
|
157
|
+ ImageEncoding encoding = (ImageEncoding) imageEncodedPacket[1];
|
158
|
+ byte[] encodedImage = (byte[]) imageEncodedPacket[2];
|
159
|
+ websock.drawImage(ps.x, ps.y, wrappedImage.getWidth(), wrappedImage.getHeight(),
|
160
|
+ encoding, imageHash, encodedImage);
|
161
|
+ }
|
162
|
break;
|
163
|
case FILL_RECT:
|
164
|
websock.fillRect(ps.x, ps.y, ps.width, ps.height);
|
165
|
@@ -409,12 +400,60 @@
|
166
|
websock.setWindowTitle(title);
|
167
|
}
|
168
|
break;
|
169
|
+ case SET_ICON:
|
170
|
+ {
|
171
|
+ ImageWrapper wrappedImage = ps.img;
|
172
|
+ Object[] imageEncodedPacket = encodeImage(0, 0, wrappedImage);
|
173
|
+ int imageHash = (Integer) imageEncodedPacket[0];
|
174
|
+ ImageEncoding encoding = (ImageEncoding) imageEncodedPacket[1];
|
175
|
+ byte[] encodedImage = (byte[]) imageEncodedPacket[2];
|
176
|
+ websock.setIconImage(ps.width, ps.height, encoding, imageHash, encodedImage);
|
177
|
+ }
|
178
|
+ break;
|
179
|
default:
|
180
|
break;
|
181
|
}
|
182
|
}
|
183
|
|
184
|
/**
|
185
|
+ * Encodes the image if it isn't already loaded and returns the 3-elements array that holds
|
186
|
+ * the image hash in its first element, the image encoding in its second element
|
187
|
+ * and the encoded image or null in its third element depending on its loaded state.
|
188
|
+ *
|
189
|
+ * @param x
|
190
|
+ * The x-coordinate of the target image position.
|
191
|
+ * @param y
|
192
|
+ * The y-coordinate of the target image position.
|
193
|
+ * @param wrappedImage
|
194
|
+ * The wrapped image.
|
195
|
+ *
|
196
|
+ * @return The 3-elements array that holds the image hash in its first element,
|
197
|
+ * the image encoding in its second element and the bytes array of the encoded image
|
198
|
+ * or null in its third element.
|
199
|
+ */
|
200
|
+ private final Object[] encodeImage(int x, int y, ImageWrapper wrappedImage)
|
201
|
+ {
|
202
|
+ VirtualScreen virtualScreen = webdriver.getVirtualScreen();
|
203
|
+ int imageHash = wrappedImage.getImage().hashCode();
|
204
|
+ ImageEncoding encoding;
|
205
|
+ byte[] encodedImage;
|
206
|
+ if (webdriver.addImageUsage(imageHash, windowId))
|
207
|
+ {
|
208
|
+ encoding = ImageEncoding.RAW;
|
209
|
+ virtualScreen.drawImage(wrappedImage, x, y);
|
210
|
+ encodedImage = new RawEncoder().packToBinaries(virtualScreen, x, y,
|
211
|
+ wrappedImage.getWidth(), wrappedImage.getHeight());
|
212
|
+ }
|
213
|
+ else
|
214
|
+ {
|
215
|
+ encoding = ImageEncoding.HASH;
|
216
|
+ encodedImage = null;
|
217
|
+ }
|
218
|
+
|
219
|
+ return new Object[] {imageHash, encoding, encodedImage};
|
220
|
+ }
|
221
|
+
|
222
|
+ /**
|
223
|
* Render the given paint operation. Any graphics context or other resources needed must
|
224
|
* have already been setup/stored by the caller.
|
225
|
*/
|
226
|
|
227
|
=== modified file 'src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebSocket.java'
|
228
|
--- src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebSocket.java 2015-08-31 20:45:55 +0000
|
229
|
+++ src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebSocket.java 2015-09-01 12:39:14 +0000
|
230
|
@@ -19,6 +19,7 @@
|
231
|
** specification, reuse the entry.
|
232
|
** Improvements for mouse support; added window activated.
|
233
|
** deriveFont() now is driver specific - it scales the font depending on the DPI.
|
234
|
+** Added setIconImage().
|
235
|
*/
|
236
|
|
237
|
package com.goldencode.p2j.ui.client.gui.driver.web;
|
238
|
@@ -679,6 +680,43 @@
|
239
|
}
|
240
|
|
241
|
/**
|
242
|
+ * Sets the window icon. If an image encoding is HASH, then the binary image isn't sent to
|
243
|
+ * the client.
|
244
|
+ *
|
245
|
+ * @param width
|
246
|
+ * The width of the image.
|
247
|
+ * @param height
|
248
|
+ * The height of the image.
|
249
|
+ * @param encoding
|
250
|
+ * The encoding id.
|
251
|
+ * @param imageHash
|
252
|
+ * The image hash code, its own id.
|
253
|
+ * @param encodedImage
|
254
|
+ * The encoded image represented by bytes.
|
255
|
+ */
|
256
|
+ public void setIconImage(int width, int height, ImageEncoding encoding, int imageHash, byte[] encodedImage)
|
257
|
+ {
|
258
|
+ int msgLen = 14;
|
259
|
+ if (encoding == ImageEncoding.RAW)
|
260
|
+ {
|
261
|
+ msgLen += encodedImage.length;
|
262
|
+ }
|
263
|
+
|
264
|
+ byte[] setIconMsg = new byte[msgLen];
|
265
|
+ setIconMsg[0] = (byte) (PaintPrimitives.SET_ICON.ordinal());
|
266
|
+ writeMessageInt32(setIconMsg, 1, width);
|
267
|
+ writeMessageInt32(setIconMsg, 5, height);
|
268
|
+ setIconMsg[9] = (byte) encoding.getValue();
|
269
|
+ writeMessageInt32(setIconMsg, 10, imageHash);
|
270
|
+ if (encoding == ImageEncoding.RAW)
|
271
|
+ {
|
272
|
+ System.arraycopy(encodedImage, 0, setIconMsg, 14, encodedImage.length);
|
273
|
+ }
|
274
|
+
|
275
|
+ addDrawingOp(setIconMsg);
|
276
|
+ }
|
277
|
+
|
278
|
+ /**
|
279
|
* Send all pending drawing operations to the javascript side and clear the list of pending
|
280
|
* operations.
|
281
|
*
|
282
|
|
283
|
=== modified file 'src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.screen.js'
|
284
|
--- src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.screen.js 2015-08-31 20:45:55 +0000
|
285
|
+++ src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.screen.js 2015-09-01 12:40:54 +0000
|
286
|
@@ -16,7 +16,7 @@
|
287
|
** 003 GES 20150720 Total rewrite to implement a first pass at GUI support,
|
288
|
** added a drawing image operation.
|
289
|
** 004 GES 20150818 Added more GUI support including fonts, cursors, z-order, mouse events.
|
290
|
-* Fixed many problems with the initial implementation.
|
291
|
+* Fixed many problems with the initial implementation. Implemented SET_ICON.
|
292
|
*/
|
293
|
|
294
|
"use strict";
|
295
|
@@ -86,6 +86,7 @@
|
296
|
START_BATCH : 27,
|
297
|
END_BATCH : 28,
|
298
|
SET_TITLE : 29,
|
299
|
+ SET_ICON : 30,
|
300
|
};
|
301
|
|
302
|
// reverse map the types to their property names
|
303
|
@@ -228,6 +229,21 @@
|
304
|
|
305
|
this.trans = 0;
|
306
|
this.clips = 0;
|
307
|
+
|
308
|
+ /**
|
309
|
+ * Defines the window icon id.
|
310
|
+ */
|
311
|
+ this.iconId = -1;
|
312
|
+
|
313
|
+ /**
|
314
|
+ * Defines the window icon's width.
|
315
|
+ */
|
316
|
+ this.iconWidth = 0;
|
317
|
+
|
318
|
+ /**
|
319
|
+ * Defines the window icon's height.
|
320
|
+ */
|
321
|
+ this.iconHeight = 0;
|
322
|
};
|
323
|
|
324
|
/**
|
325
|
@@ -1132,6 +1148,24 @@
|
326
|
this.title = title;
|
327
|
// TODO: force taskbar to repaint
|
328
|
break;
|
329
|
+ case ops.SET_ICON:
|
330
|
+ var iconWidth = p2j.socket.readInt32BinaryMessage(message, idx + 1);
|
331
|
+ var iconHeight = p2j.socket.readInt32BinaryMessage(message, idx + 5);
|
332
|
+ var encoding = message[idx + 9];
|
333
|
+ var key = p2j.socket.readInt32BinaryMessage(message, idx + 10);
|
334
|
+ var pixelsInBytes = iconWidth * iconHeight * 4;
|
335
|
+ var imgData;
|
336
|
+ var imgDataOffset;
|
337
|
+ if(!loadedImages.has(key))
|
338
|
+ {
|
339
|
+ imgData = message;
|
340
|
+ imgDataOffset = idx + 14;
|
341
|
+ loadedImages.set(key, message.subarray(imgDataOffset, imgDataOffset + pixelsInBytes));
|
342
|
+ this.iconId = key;
|
343
|
+ this.iconWidth = iconWidth;
|
344
|
+ this.iconHeight = iconHeight;
|
345
|
+ }
|
346
|
+ break;
|
347
|
default:
|
348
|
if (typeof type !== "undefined")
|
349
|
{
|
350
|
|