2 * Copyright (c) 2012, Intel Corporation.
4 * This program is licensed under the terms and conditions of the
5 * Apache License, version 2.0. The full text of the Apache License is at
6 * http://www.apache.org/licenses/LICENSE-2.0
9 var keyboardButtonTemplate = {"font" : "bold 20pt Arial", "lineWidth" : 0.5, "fillStyle" : "black", "textAlign" : "center","textBaseline" : "middle",
10 "shadowOffsetX" : 0, "shadowOffsetY" : 0, "shadowBlur" : 0, "shadowColor" : "black"};
17 this.topYLoc = screenHeight - (screenHeight / 3) - spacer;
23 chars : new Array('q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p'),
24 keycodes: new Array(81, 87, 69, 82, 84, 89, 85, 73, 79, 80),
25 size : new Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
30 chars : new Array('a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l'),
31 keycodes: new Array(65, 83, 68, 70, 71, 72, 74, 75, 76),
32 size : new Array(1, 1, 1, 1, 1, 1, 1, 1, 1),
37 chars : new Array('shift', 'z', 'x', 'c', 'v', 'b', 'n', 'm', 'bksp'),
38 keycodes: new Array(16, 90, 88, 67, 86, 66, 78, 77, 8),
39 size : new Array(1.5, 1, 1, 1, 1, 1, 1, 1, 1.5),
45 chars : new Array('123', ',', 'Space', '.', 'Enter'),
46 keycodes: new Array(-1, 188, 32, 190, 13),
47 size : new Array(2, 1, 3, 1, 2),
56 Keyboard.prototype.init = function()
59 this.topYLoc = screenHeight - (screenHeight / 3);
60 spacer = screenWidth * 0.01;
61 var minXSpace = screenWidth * 0.01;
62 var iconWidth = ((screenWidth - minXSpace * 2) / this.keysRow[0].chars.length) - spacer + (spacer / this.keysRow[0].chars.length);
63 var iconYPosition = screenHeight - (screenHeight / 3);
64 var iconHeight = (screenHeight - iconYPosition - (spacer * 3)) / (this.keysRow.length + 1);
65 var iconsPerRow, iconXPosition, firstIconXPosition;
67 for (var y = 0; y < this.keysRow.length; y++)
69 iconXPosition = ((screenWidth) - (this.keysRow[y].totalSize * (iconWidth + spacer)) ) / 2 > minXSpace ? ((screenWidth) - (this.keysRow[y].totalSize * (iconWidth + spacer)) ) / 2 : minXSpace;
70 firstIconXPosition = iconXPosition;
72 for (var i = 0; i < this.keysRow[y].chars.length; i++)
74 tmpObj = new ButtonObject(keyboardCtx,
76 "name" : this.keysRow[y].chars[i],
77 "name" : this.shift ? this.keysRow[y].chars[i].toUpperCase() : this.keysRow[y].chars[i],
78 "keycode" : this.keysRow[y].keycodes[i],
79 "image" : images.keyboardButton,
80 "xLoc" : iconXPosition,
81 "yLoc" : iconYPosition,
82 "width" : iconWidth * this.keysRow[y].size[i],
83 "height" : iconHeight,
84 "onClick" : function()
87 if (this.keycode != 16)
89 modifier = (virtualKeyboard.shift) ? 16 : -1;
93 "api_namespace" : "tizen.ivi.remotecontrol",
95 "command" : "key_press",
96 "key_id" : "dom_key_press",
97 "key_value" : this.keycode,
98 "key_modifier" : modifier
104 tmpObj.addText(this.shift ? this.keysRow[y].chars[i].toUpperCase() : this.keysRow[y].chars[i], keyboardButtonTemplate);
107 this.keys.push(tmpObj);
109 iconXPosition += iconWidth * this.keysRow[y].size[i] + spacer;
112 iconYPosition += (iconHeight + spacer);
115 tmpObj = new ButtonObject(keyboardCtx,
119 "image" : images.del,
121 "yLoc" : screenHeight - 30,
124 "onClick" : function()
126 virtualKeyboard.hide();
132 this.keys.push(tmpObj);
135 Keyboard.prototype.show = function()
138 keyboardCtx.clearRect(0, 0, screenWidth, screenHeight);
139 // keyboardCtx.fillStyle = "red";
140 buttonCtx.fillRect(0,0,0,0);
141 keyboardCtx.drawImage(images.chrome, 0, screenHeight - (screenHeight / 3) - spacer, screenWidth, screenHeight);
143 for (var canvObjIter = 0; canvObjIter < this.keys.length; canvObjIter++)
145 this.keys[canvObjIter].drawObj();
150 Keyboard.prototype.hide = function()
152 this.visible = false;
153 keyboardCtx.clearRect(0, 0, screenWidth, screenHeight);
156 Keyboard.prototype.handleClick = function(event)
159 for ( i = 0; i < this.keys.length; i++)
161 if (this.keys[i] != undefined)
163 currItem = this.keys[i];
164 if (event.clientX > currItem.xLoc && event.clientX < (currItem.xLoc + currItem.width))
166 if (event.clientY > currItem.yLoc && event.clientY < (currItem.yLoc + currItem.height))
170 if (currItem.name === "shift" || currItem.name === "SHIFT")
172 this.shift = !this.shift;
176 else if ( !(currItem.name === "Enter" || currItem.name === "ENTER") && !(currItem.name === "close" || currItem.name === "CLOSE"))