=== modified file 'src/com/goldencode/p2j/ui/client/driver/web/WebClientMessageTypes.java' --- src/com/goldencode/p2j/ui/client/driver/web/WebClientMessageTypes.java 2015-08-13 13:39:26 +0000 +++ src/com/goldencode/p2j/ui/client/driver/web/WebClientMessageTypes.java 2015-08-13 18:50:25 +0000 @@ -115,4 +115,7 @@ /** Ask the client to derive a font. */ public static final byte MSG_DERIVE_FONT = (byte) 0x93; + + /** Set the cursor style. */ + public static final byte MSG_SET_CURSOR_STYLE = (byte) 0x94; } === modified file 'src/com/goldencode/p2j/ui/client/driver/web/res/p2j.socket.js' --- src/com/goldencode/p2j/ui/client/driver/web/res/p2j.socket.js 2015-08-13 13:39:26 +0000 +++ src/com/goldencode/p2j/ui/client/driver/web/res/p2j.socket.js 2015-08-13 20:29:57 +0000 @@ -388,7 +388,7 @@ // TODO: CA get paragraph height - sendInt16BinaryMessage(0x06, pheight); + me.sendInt16BinaryMessage(0x06, pheight); break; case 0x8E: // text height @@ -404,7 +404,7 @@ var theight = p2j.fonts.getTextHeight(font, text); - sendInt8BinaryMessage(0x07, theight); + me.sendInt8BinaryMessage(0x07, theight); break; case 0x8F: // text width @@ -422,7 +422,7 @@ var twidth = p2j.fonts.getTextWidth(font, text); - sendInt16BinaryMessage(0x08, twidth); + me.sendInt16BinaryMessage(0x08, twidth); break; case 0x90: // font height @@ -434,7 +434,7 @@ var fheight = p2j.fonts.getFontHeight(font); - sendInt8BinaryMessage(0x09, fheight); + me.sendInt8BinaryMessage(0x09, fheight); break; case 0x91: // font widths @@ -446,7 +446,7 @@ var fwidths = p2j.fonts.getFontWidths(font); - sendByteArrayBinaryMessage(0x0A, fwidths); + me.sendByteArrayBinaryMessage(0x0A, fwidths); break; case 0x92: // create font @@ -475,7 +475,7 @@ p2j.fonts.createFont(font, name, size, style); - sendNotification(0x0B); + me.sendNotification(0x0B); break; case 0x93: // derive font @@ -488,7 +488,13 @@ p2j.fonts.deriveFont(font, size); - sendNotification(0x0C); + me.sendNotification(0x0C); + break; + case 0x94: + // set cursor style + var styleId = me.readInt32BinaryMessage(message, 1); + var wid = me.readInt32BinaryMessage(message, 5); + p2j.screen.setCursorStyle(styleId, wid); break; }; } === modified file 'src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebEmulatedWindow.java' --- src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebEmulatedWindow.java 2015-08-13 13:39:26 +0000 +++ src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebEmulatedWindow.java 2015-08-13 19:33:11 +0000 @@ -211,41 +211,7 @@ @Override public void setCursor(CursorType type) { - int curs = 0; - - // TODO: translate the types to something useful - switch (type) - { - case TEXT: - // curs = Cursor.TEXT_CURSOR; - break; - case N_RESIZE: - // curs = Cursor.N_RESIZE_CURSOR; - break; - case NE_RESIZE: - // curs = Cursor.NE_RESIZE_CURSOR; - break; - case E_RESIZE: - // curs = Cursor.E_RESIZE_CURSOR; - break; - case SE_RESIZE: - // curs = Cursor.SE_RESIZE_CURSOR; - break; - case S_RESIZE: - // curs = Cursor.S_RESIZE_CURSOR; - break; - case SW_RESIZE: - // curs = Cursor.SW_RESIZE_CURSOR; - break; - case W_RESIZE: - // curs = Cursor.W_RESIZE_CURSOR; - break; - case NW_RESIZE: - // curs = Cursor.NW_RESIZE_CURSOR; - break; - } - - // TODO: set it here + websock.setCursorStyle(type.ordinal(), getWindowId()); } /** === modified file 'src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebSocket.java' --- src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebSocket.java 2015-08-13 13:39:26 +0000 +++ src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebSocket.java 2015-08-13 20:36:58 +0000 @@ -19,6 +19,8 @@ import java.util.*; +import org.eclipse.jetty.websocket.api.annotations.WebSocket; + import com.goldencode.p2j.ui.client.driver.web.*; import com.goldencode.p2j.ui.client.*; import com.goldencode.p2j.ui.client.gui.driver.*; @@ -1165,6 +1167,26 @@ } /** + * Sends MSG_SET_CURSOR_STYLE that the cursor style must be changed on the client side. + * + * @param cursorStyle + * Denotes the cursor style id. + * @param wid + * The window id. + */ + public void setCursorStyle(int cursorStyle, int wid) + { + byte[] message = new byte[9]; + + message[0] = WebClientMessageTypes.MSG_SET_CURSOR_STYLE; + + writeMessageInt32(message, 1, cursorStyle); + writeMessageInt32(message, 5, wid); + + sendBinaryMessage(message); + } + + /** * Draw a string at the specified location. * * @param text === modified file 'src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.screen.js' --- src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.screen.js 2015-08-12 18:07:06 +0000 +++ src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.screen.js 2015-08-13 20:21:46 +0000 @@ -117,7 +117,7 @@ this.canvas = p2j.createCanvas(null, options); /** Canvas 2D graphics context. */ - this.ctx = canvas.getContext('2d'); + this.ctx = this.canvas.getContext('2d'); /** List of owned windows. */ this.children = new Array(); @@ -129,19 +129,19 @@ this.rawColor = new Array(0, 0, 0); /** Common data structure used in direct drawing operations. */ - this.pixel = ctx.createImageData(1, 1); + this.pixel = this.ctx.createImageData(1, 1); /** Internal portion of the pixel data structure used in direct drawing operations. */ - this.pixData = pixel.data; + this.pixData = this.pixel.data; // force alpha to 100% opaque - pixData[3] = 0xFF; + this.pixData[3] = 0xFF; // force the line width default - ctx.lineWidth = 1; + this.ctx.lineWidth = 1; // eliminate anti-aliasing of images - ctx.imageSmoothingEnabled = false; + this.ctx.imageSmoothingEnabled = false; // force all drawing to be inside pixel "cells" instead of "stradling" between two cells // which is the default; this eliminates much of the worst of the anti-aliasing and @@ -266,9 +266,9 @@ { var cur = { - lineWidth = this.ctx.lineWidth, - fillstyle = this.ctx.fillStyle, - strokeStyle = this.ctx.strokeStyle; + lineWidth : this.ctx.lineWidth, + fillstyle : this.ctx.fillStyle, + strokeStyle : this.ctx.strokeStyle }; if (additional) @@ -445,7 +445,18 @@ // re-blit the previously drawn content ctx.putImageData(oldPixels, 0, 0); }; - + + /** + * Sets the mouse cursor style. + * + * @param {String} style + * Denotes the predefined cursor style. + */ + Window.prototype.setCursorStyle = function(style) + { + this.canvas.style.cursor = style; + } + /** * Draw the given list of operations in the canvas. * @@ -1521,7 +1532,7 @@ } */ - Window defWin = me.createWindow(1); + var defWin = me.createWindow(1); font = cfg.font.size + 'px ' + cfg.font.name; bold = 'bold ' + font; @@ -1544,6 +1555,63 @@ }; /** + * Set the mouse cursor to the given predifined cursor style. The cursor style id is mapped + * to the predefined cursors styles: auto | default | none | context-menu | help | pointer + * | progress | wait | cell | crosshair | text | vertical-text | alias | copy | move | no-drop + * | not-allowed | e-resize | n-resize | ne-resize | nw-resize | s-resize | se-resize + * | sw-resize | w-resize | ew-resize | ns-resize | nesw-resize | nwse-resize | col-resize + * | row-resize | all-scroll | zoom-in | zoom-out | grab | grabbing + * + * @param {Number} cursorStyleId + * Denotes the cursor style id. + * @param {Number} wid + * Denotes the active window id. + */ + me.setCursorStyle = function(cursorStyleId, wid) + { + var style; + switch (cursorStyleId) + { + case 0: + style = "default"; + break; + case 1: + style = "text"; + break; + case 2: + style = "n-resize" + break; + case 3: + style = "ne-resize" + break; + case 4: + style = "e-resize" + break; + case 5: + style = "se-resize" + break; + case 6: + style = "s-resize" + break; + case 7: + style = "sw-resize" + break; + case 8: + style = "w-resize" + break; + case 9: + style = "nw-resize" + break; + default: + style = "default"; + } + + var win = getWindow(wid); + + win.setCursorStyle(style); + }; + + /** * Clear the screen. */ me.clear = function()