Project

General

Profile

1811q_20150814.txt

Sergey Ivanovskiy, 08/14/2015 08:41 AM

Download (10.2 KB)

 
1
=== modified file 'src/com/goldencode/p2j/ui/client/driver/web/WebClientMessageTypes.java'
2
--- src/com/goldencode/p2j/ui/client/driver/web/WebClientMessageTypes.java	2015-08-13 13:39:26 +0000
3
+++ src/com/goldencode/p2j/ui/client/driver/web/WebClientMessageTypes.java	2015-08-14 12:21:36 +0000
4
@@ -115,4 +115,7 @@
5
    
6
    /** Ask the client to derive a font. */
7
    public static final byte MSG_DERIVE_FONT         = (byte) 0x93;
8
+   
9
+   /** Set the cursor style. */
10
+   public static final byte MSG_SET_CURSOR_STYLE    = (byte) 0x94;
11
 }
12

    
13
=== modified file 'src/com/goldencode/p2j/ui/client/driver/web/res/p2j.socket.js'
14
--- src/com/goldencode/p2j/ui/client/driver/web/res/p2j.socket.js	2015-08-13 13:39:26 +0000
15
+++ src/com/goldencode/p2j/ui/client/driver/web/res/p2j.socket.js	2015-08-14 12:21:36 +0000
16
@@ -388,7 +388,7 @@
17
 
18
                      // TODO: CA get paragraph height
19
 
20
-                     sendInt16BinaryMessage(0x06, pheight);
21
+                     me.sendInt16BinaryMessage(0x06, pheight);
22
                      break;
23
                   case 0x8E:
24
                      // text height
25
@@ -404,7 +404,7 @@
26
                      
27
                      var theight = p2j.fonts.getTextHeight(font, text);
28
 
29
-                     sendInt8BinaryMessage(0x07, theight);
30
+                     me.sendInt8BinaryMessage(0x07, theight);
31
                      break;
32
                   case 0x8F:
33
                      // text width
34
@@ -422,7 +422,7 @@
35
                      
36
                      var twidth = p2j.fonts.getTextWidth(font, text);
37
                      
38
-                     sendInt16BinaryMessage(0x08, twidth);
39
+                     me.sendInt16BinaryMessage(0x08, twidth);
40
                      break;
41
                   case 0x90:
42
                      // font height
43
@@ -434,7 +434,7 @@
44
                      
45
                      var fheight = p2j.fonts.getFontHeight(font);
46
                      
47
-                     sendInt8BinaryMessage(0x09, fheight);
48
+                     me.sendInt8BinaryMessage(0x09, fheight);
49
                      break;
50
                   case 0x91:
51
                      // font widths
52
@@ -446,7 +446,7 @@
53
                      
54
                      var fwidths = p2j.fonts.getFontWidths(font);
55
                      
56
-                     sendByteArrayBinaryMessage(0x0A, fwidths);
57
+                     me.sendByteArrayBinaryMessage(0x0A, fwidths);
58
                      break;
59
                   case 0x92:
60
                      // create font
61
@@ -475,7 +475,7 @@
62
                      
63
                      p2j.fonts.createFont(font, name, size, style);
64
                      
65
-                     sendNotification(0x0B);
66
+                     me.sendNotification(0x0B);
67
                      break;
68
                   case 0x93:
69
                      // derive font
70
@@ -488,7 +488,13 @@
71
 
72
                      p2j.fonts.deriveFont(font, size);
73
                       
74
-                     sendNotification(0x0C);
75
+                     me.sendNotification(0x0C);
76
+                     break;
77
+                  case 0x94:
78
+                     // set cursor style
79
+                     var styleId = me.readInt32BinaryMessage(message, 1);
80
+                     var wid = me.readInt32BinaryMessage(message, 5);
81
+                     p2j.screen.setCursorStyle(styleId, wid);
82
                      break;
83
                };
84
             }
85

    
86
=== modified file 'src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebEmulatedWindow.java'
87
--- src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebEmulatedWindow.java	2015-08-13 13:39:26 +0000
88
+++ src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebEmulatedWindow.java	2015-08-14 12:21:36 +0000
89
@@ -211,41 +211,7 @@
90
    @Override
91
    public void setCursor(CursorType type)
92
    {
93
-      int curs = 0;
94
-      
95
-      // TODO: translate the types to something useful
96
-      switch (type)
97
-      {
98
-         case TEXT:
99
-            // curs = Cursor.TEXT_CURSOR;
100
-            break;
101
-         case N_RESIZE:
102
-            // curs = Cursor.N_RESIZE_CURSOR;
103
-            break;
104
-         case NE_RESIZE:
105
-            // curs = Cursor.NE_RESIZE_CURSOR;
106
-            break;
107
-         case E_RESIZE:
108
-            // curs = Cursor.E_RESIZE_CURSOR;
109
-            break;
110
-         case SE_RESIZE:
111
-            // curs = Cursor.SE_RESIZE_CURSOR;
112
-            break;
113
-         case S_RESIZE:
114
-            // curs = Cursor.S_RESIZE_CURSOR;
115
-            break;
116
-         case SW_RESIZE:
117
-            // curs = Cursor.SW_RESIZE_CURSOR;
118
-            break;
119
-         case W_RESIZE:
120
-            // curs = Cursor.W_RESIZE_CURSOR;
121
-            break;
122
-         case NW_RESIZE:
123
-            // curs = Cursor.NW_RESIZE_CURSOR;
124
-            break;
125
-      }
126
-      
127
-      // TODO: set it here
128
+      websock.setCursorStyle(type.ordinal(), getWindowId());
129
    }
130
 
131
    /**
132

    
133
=== modified file 'src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebSocket.java'
134
--- src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebSocket.java	2015-08-13 13:39:26 +0000
135
+++ src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebSocket.java	2015-08-14 12:21:36 +0000
136
@@ -19,6 +19,8 @@
137
 
138
 import java.util.*;
139
 
140
+import org.eclipse.jetty.websocket.api.annotations.WebSocket;
141
+
142
 import com.goldencode.p2j.ui.client.driver.web.*;
143
 import com.goldencode.p2j.ui.client.*;
144
 import com.goldencode.p2j.ui.client.gui.driver.*;
145
@@ -1165,6 +1167,26 @@
146
    }
147
 
148
    /**
149
+    * Sends MSG_SET_CURSOR_STYLE that the cursor style must be changed on the client side.
150
+    * 
151
+    * @param    cursorStyle
152
+    *           Denotes the cursor style id.
153
+    * @param    wid
154
+    *           The window id.
155
+    */
156
+   public void setCursorStyle(int cursorStyle, int wid)
157
+   {
158
+      byte[] message = new byte[9];
159
+
160
+      message[0] = WebClientMessageTypes.MSG_SET_CURSOR_STYLE;
161
+
162
+      writeMessageInt32(message, 1, cursorStyle);
163
+      writeMessageInt32(message, 5, wid);
164
+
165
+      sendBinaryMessage(message);
166
+   }
167
+
168
+   /**
169
     * Draw a string at the specified location.
170
     * 
171
     * @param    text
172

    
173
=== modified file 'src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.screen.js'
174
--- src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.screen.js	2015-08-12 18:07:06 +0000
175
+++ src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.screen.js	2015-08-14 12:21:36 +0000
176
@@ -117,7 +117,7 @@
177
       this.canvas = p2j.createCanvas(null, options);
178
       
179
       /** Canvas 2D graphics context. */
180
-      this.ctx = canvas.getContext('2d');
181
+      this.ctx = this.canvas.getContext('2d');
182
       
183
       /** List of owned windows. */
184
       this.children = new Array();
185
@@ -129,19 +129,19 @@
186
       this.rawColor = new Array(0, 0, 0);
187
       
188
       /** Common data structure used in direct drawing operations. */
189
-      this.pixel = ctx.createImageData(1, 1);
190
+      this.pixel = this.ctx.createImageData(1, 1);
191
       
192
       /** Internal portion of the pixel data structure used in direct drawing operations. */
193
-      this.pixData = pixel.data;
194
+      this.pixData = this.pixel.data;
195
       
196
       // force alpha to 100% opaque
197
-      pixData[3] = 0xFF;
198
+      this.pixData[3] = 0xFF;
199
       
200
       // force the line width default
201
-      ctx.lineWidth = 1;
202
+      this.ctx.lineWidth = 1;
203
       
204
       // eliminate anti-aliasing of images
205
-      ctx.imageSmoothingEnabled = false;
206
+      this.ctx.imageSmoothingEnabled = false;
207
       
208
       // force all drawing to be inside pixel "cells" instead of "stradling" between two cells
209
       // which is the default; this eliminates much of the worst of the anti-aliasing and
210
@@ -266,9 +266,9 @@
211
    {
212
       var cur = 
213
       {
214
-         lineWidth   = this.ctx.lineWidth,
215
-         fillstyle   = this.ctx.fillStyle,
216
-         strokeStyle = this.ctx.strokeStyle;
217
+         lineWidth   : this.ctx.lineWidth,
218
+         fillstyle   : this.ctx.fillStyle,
219
+         strokeStyle : this.ctx.strokeStyle
220
       };
221
       
222
       if (additional)
223
@@ -445,7 +445,18 @@
224
       // re-blit the previously drawn content
225
       ctx.putImageData(oldPixels, 0, 0);
226
    };   
227
-   
228
+
229
+   /**
230
+    * Sets the mouse cursor style.
231
+    * 
232
+    * @param    {String} style
233
+    *           Denotes the predefined cursor style.
234
+    */
235
+   Window.prototype.setCursorStyle = function(style)
236
+   {
237
+      this.canvas.style.cursor = style;
238
+   }
239
+
240
    /**
241
     * Draw the given list of operations in the canvas.
242
     *
243
@@ -1521,7 +1532,7 @@
244
       }
245
       */
246
       
247
-      Window defWin = me.createWindow(1);
248
+      var defWin = me.createWindow(1);
249
       
250
       font = cfg.font.size + 'px ' + cfg.font.name;
251
       bold = 'bold ' + font;
252
@@ -1544,6 +1555,63 @@
253
    };
254
 
255
    /**
256
+    * Set the mouse cursor to the given predifined cursor style. The cursor style id is mapped
257
+    * to the predefined cursors styles: auto | default | none | context-menu | help | pointer
258
+    *  | progress | wait | cell | crosshair | text | vertical-text | alias | copy | move | no-drop
259
+    *  | not-allowed | e-resize | n-resize | ne-resize | nw-resize | s-resize | se-resize
260
+    *  | sw-resize | w-resize | ew-resize | ns-resize | nesw-resize | nwse-resize | col-resize
261
+    *  | row-resize | all-scroll | zoom-in | zoom-out | grab | grabbing 
262
+    * 
263
+    * @param    {Number} cursorStyleId
264
+    *           Denotes the cursor style id.
265
+    * @param    {Number} wid
266
+    *           Denotes the active window id.
267
+    */
268
+   me.setCursorStyle = function(cursorStyleId, wid)
269
+   {
270
+      var style;
271
+      switch (cursorStyleId)
272
+      {
273
+         case 0:
274
+            style = "default";
275
+            break;
276
+         case 1:
277
+            style = "text";
278
+            break;
279
+         case 2:
280
+            style = "n-resize"
281
+            break;
282
+         case 3:
283
+            style = "ne-resize"
284
+            break;
285
+         case 4:
286
+            style = "e-resize"
287
+            break;
288
+         case 5:
289
+            style = "se-resize"
290
+            break;
291
+         case 6:
292
+            style = "s-resize"
293
+            break;
294
+         case 7:
295
+            style = "sw-resize"
296
+            break;
297
+         case 8:
298
+            style = "w-resize"
299
+            break;
300
+         case 9:
301
+            style = "nw-resize"
302
+            break;
303
+         default:
304
+            style = "default";
305
+      }
306
+
307
+      var win = getWindow(wid);
308
+
309
+      win.setCursorStyle(style);
310
+   };
311
+
312
+   /**
313
     * Clear the screen.
314
     */
315
    me.clear = function()
316