1
|
=== modified file 'src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.screen.js'
|
2
|
--- src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.screen.js 2015-09-08 22:00:49 +0000
|
3
|
+++ src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.screen.js 2015-09-09 15:24:41 +0000
|
4
|
@@ -798,6 +798,7 @@
|
5
|
text = p2j.socket.readStringBinaryMessageByLength(message, idx + 5, textLength);
|
6
|
extra = " title = " + text;
|
7
|
this.title = text;
|
8
|
+ taskBar.setTitleForTask(this.id, this.title);
|
9
|
taskBar.draw();
|
10
|
break;
|
11
|
case ops.SET_ICON:
|
12
|
@@ -818,7 +819,7 @@
|
13
|
this.iconWidth = iconWidth;
|
14
|
this.iconHeight = iconHeight;
|
15
|
}
|
16
|
- taskBar.setIconForTask(this.id, loadedImages.get(this.iconId));
|
17
|
+ taskBar.setIconForTask(this.id, loadedImages.get(this.iconId), this.iconWidth, this.iconHeight);
|
18
|
break;
|
19
|
default:
|
20
|
if (typeof type !== "undefined")
|
21
|
@@ -1337,7 +1338,7 @@
|
22
|
addZOrderEntry(wid, newwin);
|
23
|
|
24
|
// creates new task icon widget for new window
|
25
|
- taskBar.addTaskIcon(newwin);
|
26
|
+ taskBar.addTaskIcon(newwin.id);
|
27
|
|
28
|
return newwin;
|
29
|
};
|
30
|
@@ -1375,7 +1376,11 @@
|
31
|
|
32
|
newwin.owner = owner;
|
33
|
newwin.title = title || "";
|
34
|
-
|
35
|
+
|
36
|
+ // creates new task icon widget for new window
|
37
|
+ var taskIcon = taskBar.addTaskIcon(newwin.id);
|
38
|
+ taskIcon.title = newwin.title;
|
39
|
+
|
40
|
var parent = getWindow(owner);
|
41
|
|
42
|
// add to the owned window list
|
43
|
|
44
|
=== modified file 'src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.virtual_desktop.js'
|
45
|
--- src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.virtual_desktop.js 2015-09-08 16:51:50 +0000
|
46
|
+++ src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.virtual_desktop.js 2015-09-09 15:51:55 +0000
|
47
|
@@ -204,6 +204,8 @@
|
48
|
var DRAGGED_OPACITY = 0.3;
|
49
|
var TOP_PADDING = 2;
|
50
|
var LEFT_PADDING = 2;
|
51
|
+ var ICON_MARGIN = 1;
|
52
|
+ var TEXT_MARGIN = 1;
|
53
|
var TASK_BAR_TITLE = "Task Bar";
|
54
|
var TASK_ICON_WIDTH = 40;
|
55
|
var TASK_ICON_HEIGHT = 32;
|
56
|
@@ -221,14 +223,14 @@
|
57
|
|
58
|
peer.appendChild(canvas);
|
59
|
var ctx = canvas.getContext('2d', {alpha : true});
|
60
|
-// console.log("peer width = " + peer.offsetWidth);
|
61
|
-// console.log("peer height = " + peer.offsetHeight);
|
62
|
var strokesManager = new LineStrokes();
|
63
|
var canvasRenderer = new CanvasRenderer(canvas, ctx, strokesManager, fontsManager, logger);
|
64
|
|
65
|
var taskIcons = [];
|
66
|
|
67
|
var viewLogButton = createViewLogButton(logger);
|
68
|
+
|
69
|
+ var sysButtons = [viewLogButton];
|
70
|
|
71
|
var foreground = fg;
|
72
|
var background = bg;
|
73
|
@@ -236,7 +238,7 @@
|
74
|
|
75
|
if (peer)
|
76
|
{
|
77
|
- /** events fired on the draggable target */
|
78
|
+ // events fired on the draggable target
|
79
|
peer.addEventListener("dragstart", startDragging);
|
80
|
peer.addEventListener("dragend", dragEnded);
|
81
|
//peer.addEventListener("drag", drag);
|
82
|
@@ -274,19 +276,14 @@
|
83
|
*/
|
84
|
function createViewLogButton(logger)
|
85
|
{
|
86
|
- var taskIcon = new TaskIcon(
|
87
|
- {title : "View Log Output"},
|
88
|
- null, 3 * TASK_ICON_WIDTH, TASK_ICON_HEIGHT, fg);
|
89
|
+ var taskIcon = new TaskIcon(1, 3 * TASK_ICON_WIDTH, TASK_ICON_HEIGHT, fg,
|
90
|
+ "View Log Output", null, 0, 0);
|
91
|
taskIcon.setActive(false);
|
92
|
- /**
|
93
|
- * Opens new log window.
|
94
|
- */
|
95
|
+ // Opens new log window.
|
96
|
taskIcon.doClick = function()
|
97
|
{
|
98
|
logger.viewLog();
|
99
|
- /**
|
100
|
- * Change the view log button to inactive after 500 ms.
|
101
|
- */
|
102
|
+ // Change the view log button to inactive after 500 ms.
|
103
|
window.setTimeout(
|
104
|
function()
|
105
|
{
|
106
|
@@ -300,6 +297,10 @@
|
107
|
/**
|
108
|
* Layouts the view log button on the task bar.
|
109
|
*
|
110
|
+ * @param {Number} width
|
111
|
+ * The task bar width in pixels.
|
112
|
+ * @param {Number} height
|
113
|
+ * The task bar height in pixels.
|
114
|
* @param {Boolean} horizontalLayout
|
115
|
* Indicates the task bar layout, true if the task bar is along a horizontal line, otherwise,
|
116
|
* it is along a vertical line.
|
117
|
@@ -337,10 +338,9 @@
|
118
|
{
|
119
|
canvas.width = width;
|
120
|
canvas.height = height;
|
121
|
-// console.log("canvas width = " + canvas.width);
|
122
|
-// console.log("canvas height = " + canvas.height);
|
123
|
|
124
|
canvasRenderer.draw3DRect(ctx, 0, 0, width, height, background, true, true);
|
125
|
+
|
126
|
//check taskIcons is not empty
|
127
|
if (taskIcons.length === 0)
|
128
|
{
|
129
|
@@ -357,6 +357,10 @@
|
130
|
{
|
131
|
horizontalLayout = false;
|
132
|
}
|
133
|
+
|
134
|
+ var unified = calculateTaskIconWidth(width, height, horizontalLayout);
|
135
|
+ setUnifiedDimension(unified, TASK_ICON_HEIGHT, horizontalLayout);
|
136
|
+
|
137
|
var x;
|
138
|
var y;
|
139
|
|
140
|
@@ -388,8 +392,152 @@
|
141
|
}
|
142
|
}
|
143
|
doViewLogButtonLayout(width, height, horizontalLayout);
|
144
|
- }
|
145
|
-
|
146
|
+ };
|
147
|
+
|
148
|
+ /**
|
149
|
+ * Calculates the maximal pixel width of the task title for the current canvas font.
|
150
|
+ *
|
151
|
+ * @param {Array} widgets
|
152
|
+ * The array of TaskIcon widgets.
|
153
|
+ *
|
154
|
+ * @return {Number}
|
155
|
+ * The maximal pixel width of titles used for task widgets relative to the current
|
156
|
+ * canvas font.
|
157
|
+ */
|
158
|
+ function calculateMaximalTextWidth(widgets)
|
159
|
+ {
|
160
|
+ //check that it is not empty
|
161
|
+ if (widgets.length === 0)
|
162
|
+ {
|
163
|
+ return 0;
|
164
|
+ }
|
165
|
+ var initialValue = fontsManager.getTextWidth(TASK_BAR_FONT_ID, widgets[0].title);
|
166
|
+ return widgets.reduce(
|
167
|
+ function(previousValue, currentValue, index, array)
|
168
|
+ {
|
169
|
+ var textWidth = fontsManager.getTextWidth(TASK_BAR_FONT_ID, array[index].title);
|
170
|
+ return Math.max(previousValue, textWidth);
|
171
|
+ },
|
172
|
+ initialValue);
|
173
|
+ };
|
174
|
+
|
175
|
+ /**
|
176
|
+ * Calculates the maximal icon width from all icons for the task bar.
|
177
|
+ *
|
178
|
+ * @param {Array} widgets
|
179
|
+ * The array of TaskIcon widgets.
|
180
|
+ * @param {Boolean} horizontalLayout
|
181
|
+ * Indicates the task bar layout, true if the task bar is along a horizontal line, otherwise,
|
182
|
+ * it is along a vertical line.
|
183
|
+ *
|
184
|
+ * @return {Number}
|
185
|
+ * The maximal icon width from all icons for the task bar.
|
186
|
+ */
|
187
|
+ function calculateMaximalIconWidth(widgets, horizontalLayout)
|
188
|
+ {
|
189
|
+ //check that it is not empty
|
190
|
+ if (widgets.length === 0)
|
191
|
+ {
|
192
|
+ return 0;
|
193
|
+ }
|
194
|
+ var initialValue;
|
195
|
+ if (horizontalLayout)
|
196
|
+ {
|
197
|
+ initialValue = widgets[0].iconWidth;
|
198
|
+ }
|
199
|
+ else
|
200
|
+ {
|
201
|
+ initialValue = widgets[0].iconHeight;
|
202
|
+ }
|
203
|
+
|
204
|
+ return widgets.reduce(
|
205
|
+ function(previousValue, currentValue, index, array)
|
206
|
+ {
|
207
|
+ var width;
|
208
|
+ if (horizontalLayout)
|
209
|
+ {
|
210
|
+ width = array[index].iconWidth;
|
211
|
+ }
|
212
|
+ else
|
213
|
+ {
|
214
|
+ width = array[index].iconHeight;
|
215
|
+ }
|
216
|
+ return Math.max(previousValue, width);
|
217
|
+ },
|
218
|
+ initialValue);
|
219
|
+ };
|
220
|
+
|
221
|
+ /**
|
222
|
+ * Calculates the unified task icon width.
|
223
|
+ *
|
224
|
+ * @param {Number} width
|
225
|
+ * The task bar width in pixels.
|
226
|
+ * @param {Number} height
|
227
|
+ * The task bar height in pixels.
|
228
|
+ * @param {Boolean} horizontalLayout
|
229
|
+ * Indicates the task bar layout, true if the task bar is along a horizontal line, otherwise,
|
230
|
+ * it is along a vertical line.
|
231
|
+ *
|
232
|
+ * @return {Number}
|
233
|
+ * The unified task icon width.
|
234
|
+ */
|
235
|
+ function calculateTaskIconWidth(width, height, horizontalLayout)
|
236
|
+ {
|
237
|
+ var maxWidth;
|
238
|
+ if (horizontalLayout)
|
239
|
+ {
|
240
|
+ maxWidth = width / (taskIcons.length + sysButtons.length);
|
241
|
+ }
|
242
|
+ else
|
243
|
+ {
|
244
|
+ maxWidth = height / (taskIcons.length + sysButtons.length);
|
245
|
+ }
|
246
|
+ var taskIconsWidth = calculateMaximalIconWidth(taskIcons, horizontalLayout);
|
247
|
+ if (taskIconsWidth > 0)
|
248
|
+ {
|
249
|
+ taskIconsWidth += (2 * ICON_MARGIN);
|
250
|
+ }
|
251
|
+ taskIconsWidth += (calculateMaximalTextWidth(taskIcons) + (2 * TEXT_MARGIN));
|
252
|
+ var sysButtonsWidth = calculateMaximalIconWidth(sysButtons, horizontalLayout);
|
253
|
+ if (sysButtonsWidth > 0)
|
254
|
+ {
|
255
|
+ sysButtonsWidth += (2 * ICON_MARGIN);
|
256
|
+ }
|
257
|
+ sysButtonsWidth += (calculateMaximalTextWidth(sysButtons) + (2 * TEXT_MARGIN));
|
258
|
+ return Math.min(maxWidth, Math.max(taskIconsWidth, sysButtonsWidth));
|
259
|
+ };
|
260
|
+
|
261
|
+ /**
|
262
|
+ * Sets the unified dimension for all task bar widgets.
|
263
|
+ *
|
264
|
+ * @param {Number} unifiedWidth
|
265
|
+ * The widget width in pixels.
|
266
|
+ * @param {Number} unifiedHeight
|
267
|
+ * The widget height in pixels.
|
268
|
+ * @param {Boolean} horizontalLayout
|
269
|
+ * Indicates the task bar layout, true if the task bar is along a horizontal line, otherwise,
|
270
|
+ * it is along a vertical line.
|
271
|
+ */
|
272
|
+ function setUnifiedDimension(unifiedWidth, unifiedHeight, horizontalLayout)
|
273
|
+ {
|
274
|
+ function set(element, index, array)
|
275
|
+ {
|
276
|
+ if (horizontalLayout)
|
277
|
+ {
|
278
|
+ array[index].width = unifiedWidth;
|
279
|
+ array[index].height = unifiedHeight;
|
280
|
+ }
|
281
|
+ else
|
282
|
+ {
|
283
|
+ array[index].width = unifiedHeight;
|
284
|
+ array[index].height = unifiedWidth;
|
285
|
+ }
|
286
|
+ array[index].horizontalLayout = horizontalLayout;
|
287
|
+ };
|
288
|
+ taskIcons.forEach(set);
|
289
|
+ sysButtons.forEach(set);
|
290
|
+ };
|
291
|
+
|
292
|
/**
|
293
|
* Draws the task bar on the canvas.
|
294
|
*/
|
295
|
@@ -397,27 +545,28 @@
|
296
|
{
|
297
|
doLayout(peer.offsetWidth, peer.offsetHeight);
|
298
|
}
|
299
|
-
|
300
|
+
|
301
|
+ this.addTaskIcon = addTaskIcon;
|
302
|
+
|
303
|
/**
|
304
|
* Adds new task to the task bar.
|
305
|
*
|
306
|
- * @param {Window} win
|
307
|
- * The window to be represented by a task in the task bar.
|
308
|
+ * @param {Number} windowId
|
309
|
+ * The id of the window that needs to be represented by this task.
|
310
|
*
|
311
|
* @return {TaskIcon}
|
312
|
* The task icon that represents the target window.
|
313
|
*/
|
314
|
- function addTaskIcon(win)
|
315
|
+ function addTaskIcon(windowId)
|
316
|
{
|
317
|
- var taskIcon = new TaskIcon(win, null, TASK_ICON_WIDTH, TASK_ICON_HEIGHT, foreground);
|
318
|
+ var taskIcon = new TaskIcon(windowId, TASK_ICON_WIDTH, TASK_ICON_HEIGHT, foreground,
|
319
|
+ "", null, 0, 0);
|
320
|
taskIcons.push(taskIcon);
|
321
|
- /**
|
322
|
- * By default the task is active. Only one task can be active.
|
323
|
- */
|
324
|
+ // By default the task is active. Only one task can be active.
|
325
|
deactivateHead();
|
326
|
return taskIcon;
|
327
|
};
|
328
|
-
|
329
|
+
|
330
|
/**
|
331
|
* Deactivate the head tasks.
|
332
|
*/
|
333
|
@@ -428,7 +577,9 @@
|
334
|
taskIcons[i].setActive(false);
|
335
|
}
|
336
|
}
|
337
|
-
|
338
|
+
|
339
|
+ this.setIconForTask = setIconForTask;
|
340
|
+
|
341
|
/**
|
342
|
* Sets an icon for the task that represents the target window.
|
343
|
*
|
344
|
@@ -437,19 +588,43 @@
|
345
|
* @param {Array} iconData
|
346
|
* It is the binary icon to set. The pixels array with 4-bytes per a pixel that
|
347
|
* are red, green, blue and alpha bytes.
|
348
|
+ * @param {Number} iconWidth
|
349
|
+ * The icon width in pixels.
|
350
|
+ * @param {Number} iconHeight
|
351
|
+ * The icon height in pixels.
|
352
|
*
|
353
|
* @return {TaskIcon}
|
354
|
* The task that represents the target window.
|
355
|
*/
|
356
|
- function setIconForTask(windowId, iconData)
|
357
|
+ function setIconForTask(windowId, iconData, iconWidth, iconHeight)
|
358
|
{
|
359
|
var taskIcon = findTaskIcon(windowId);
|
360
|
taskIcon.iconData = iconData;
|
361
|
- return taskIcon;
|
362
|
- };
|
363
|
-
|
364
|
- this.addTaskIcon = addTaskIcon;
|
365
|
- this.setIconForTask = setIconForTask;
|
366
|
+ taskIcon.iconWidth = iconWidth;
|
367
|
+ taskIcon.iconHeight = iconHeight;
|
368
|
+ return taskIcon;
|
369
|
+ };
|
370
|
+
|
371
|
+ this.setTitleForTask = setTitleForTask;
|
372
|
+
|
373
|
+ /**
|
374
|
+ * Sets a title for the task that represents the target window.
|
375
|
+ *
|
376
|
+ * @param {Number} windowId
|
377
|
+ * The target window id.
|
378
|
+ * @param {String} title
|
379
|
+ * The title of the task icon for the given window.
|
380
|
+ *
|
381
|
+ * @return {TaskIcon}
|
382
|
+ * The task that represents the target window.
|
383
|
+ */
|
384
|
+ function setTitleForTask(windowId, title)
|
385
|
+ {
|
386
|
+ var taskIcon = findTaskIcon(windowId);
|
387
|
+ taskIcon.title = title;
|
388
|
+ return taskIcon;
|
389
|
+ };
|
390
|
+
|
391
|
this.setDefaultFont = setDefaultFont;
|
392
|
|
393
|
/**
|
394
|
@@ -474,7 +649,7 @@
|
395
|
for (var i = 0; i < taskIcons.length; i++)
|
396
|
{
|
397
|
var taskIcon = taskIcons[i];
|
398
|
- if (taskIcon.win.id === windowId)
|
399
|
+ if (taskIcon.id === windowId)
|
400
|
{
|
401
|
return taskIcon;
|
402
|
}
|
403
|
@@ -553,7 +728,9 @@
|
404
|
{
|
405
|
}
|
406
|
|
407
|
- /* events fired on the drop targets */
|
408
|
+ /**
|
409
|
+ * events fired on the drop targets
|
410
|
+ */
|
411
|
document.addEventListener("dragover", function(event) { event.preventDefault(); }, false);
|
412
|
|
413
|
/**
|
414
|
@@ -596,10 +773,12 @@
|
415
|
event.target.appendChild(dragged);
|
416
|
event.target.style.zIndex = MAX_Z_INDEX;
|
417
|
parent.style["background"] = getTransparentColor(background, 0.0);
|
418
|
+ parent.style.zIndex = MIN_Z_INDEX;
|
419
|
}
|
420
|
catch(e)
|
421
|
{
|
422
|
parent.addChild(dragged);
|
423
|
+ parent.style.zIndex = MAX_Z_INDEX;
|
424
|
}
|
425
|
doLayout(peer.offsetWidth, peer.offsetHeight);
|
426
|
}
|
427
|
@@ -629,7 +808,7 @@
|
428
|
taskIcon.setActive(true);
|
429
|
if (taskIconOnClickCallback)
|
430
|
{
|
431
|
- taskIconOnClickCallback(taskIcon.win.id);
|
432
|
+ taskIconOnClickCallback(taskIcon.id);
|
433
|
}
|
434
|
taskIcon.draw();
|
435
|
break;
|
436
|
@@ -649,7 +828,7 @@
|
437
|
//special view log use case.
|
438
|
if (viewLogButton.testMousePointerInside(event))
|
439
|
{
|
440
|
- peer.title = viewLogButton.win.title;
|
441
|
+ peer.title = viewLogButton.title;
|
442
|
return;
|
443
|
}
|
444
|
|
445
|
@@ -658,8 +837,8 @@
|
446
|
var taskIcon = taskIcons[i];
|
447
|
if (taskIcon.testMousePointerInside(event))
|
448
|
{
|
449
|
- peer.title = (taskIcon.win.title !== null && taskIcon.win.title !== undefined)
|
450
|
- ? taskIcon.win.title : " ";
|
451
|
+ peer.title = (taskIcon.title !== null && taskIcon.title !== undefined)
|
452
|
+ ? taskIcon.title : " ";
|
453
|
break;
|
454
|
}
|
455
|
|
456
|
@@ -674,7 +853,7 @@
|
457
|
* Returns rgba(r,g,b,a) string representation for the target color
|
458
|
* with the target transparency.
|
459
|
*
|
460
|
- * @param {Number[]} c
|
461
|
+ * @param {Array} c
|
462
|
* Array of 3 integer values between 0 and 255 inclusive, representing an RGB color.
|
463
|
* @param {Number} transparency
|
464
|
* The transparency from 0.0 to 1.0.
|
465
|
@@ -693,23 +872,32 @@
|
466
|
/**
|
467
|
* Creates the task icon widget that represents the target window on the task bar.
|
468
|
*
|
469
|
- * @param {Window} win
|
470
|
- * The window to be represented by a task in the task bar.
|
471
|
- * @param {Array} iconData
|
472
|
- * It is the binary icon to set. The pixels array with 4-bytes per a pixel that
|
473
|
- * are red, green, blue and alpha bytes.
|
474
|
+ * @param {Number} windowId
|
475
|
+ * The id of the window that needs to be represented by this task icon.
|
476
|
* @param {Number} w
|
477
|
- * The task icon widget width in pixels.
|
478
|
+ * The widget width in pixels.
|
479
|
* @param {Number} h
|
480
|
- * The task icon widget height in pixels.
|
481
|
- * @param {Number[]} c
|
482
|
+ * The widget height in pixels.
|
483
|
+ * @param {Array} c
|
484
|
* The task icon widget color. Array of 3 integer values between 0
|
485
|
* and 255 inclusive, representing an RGB color.
|
486
|
+ * @param {String} title
|
487
|
+ * The title of the task icon for the given window.
|
488
|
+ * @param {Array} iconData
|
489
|
+ * It is the binary icon to set. The pixels array with 4-bytes per a pixel that
|
490
|
+ * are red, green, blue and alpha bytes.
|
491
|
+ * @param {Number} iconWidth
|
492
|
+ * The icon width in pixels.
|
493
|
+ * @param {Number} iconHeight
|
494
|
+ * The icon height in pixels.
|
495
|
*/
|
496
|
- function TaskIcon(win, iconData, w, h, c)
|
497
|
+ function TaskIcon(windowId, w, h, c, title, iconData, iconWidth, iconHeight)
|
498
|
{
|
499
|
- this.win = win;
|
500
|
+ this.id = windowId;
|
501
|
this.iconData = iconData;
|
502
|
+ this.iconWidth = iconWidth;
|
503
|
+ this.iconHeight = iconHeight;
|
504
|
+ this.title = title;
|
505
|
this.width = w;
|
506
|
this.height = h;
|
507
|
this.color = c;
|
508
|
@@ -717,12 +905,12 @@
|
509
|
var active = true;
|
510
|
this.x = 0;
|
511
|
this.y = 0;
|
512
|
+ /**
|
513
|
+ * Defines the widget's title layout,
|
514
|
+ */
|
515
|
+ this.horizontalLayout = true;
|
516
|
|
517
|
this.setLocation = setLocation;
|
518
|
- this.setActive = setActive;
|
519
|
- this.isActive = isActive;
|
520
|
- this.draw = draw;
|
521
|
- this.testMousePointerInside = testMousePointerInside;
|
522
|
|
523
|
/**
|
524
|
* Sets the widget location.
|
525
|
@@ -732,7 +920,9 @@
|
526
|
this.x = x;
|
527
|
this.y = y;
|
528
|
};
|
529
|
-
|
530
|
+
|
531
|
+ this.setActive = setActive;
|
532
|
+
|
533
|
/**
|
534
|
* Sets an active state.
|
535
|
*/
|
536
|
@@ -740,7 +930,9 @@
|
537
|
{
|
538
|
active = value;
|
539
|
};
|
540
|
-
|
541
|
+
|
542
|
+ this.isActive = isActive;
|
543
|
+
|
544
|
/**
|
545
|
* Is active?
|
546
|
*/
|
547
|
@@ -748,7 +940,9 @@
|
548
|
{
|
549
|
return active;
|
550
|
};
|
551
|
-
|
552
|
+
|
553
|
+ this.draw = draw;
|
554
|
+
|
555
|
/**
|
556
|
* Draw the widget on the task bar canvas.
|
557
|
*/
|
558
|
@@ -766,25 +960,80 @@
|
559
|
canvasRenderer.draw3DRect(ctx, that.x, that.y, that.width, that.height, c, true, !active);
|
560
|
if (that.iconData)
|
561
|
{
|
562
|
- var iconWidth = that.win.iconWidth;
|
563
|
- var iconHeight = that.win.iconHeight;
|
564
|
- canvasRenderer.drawImage(ctx, that.x, that.y + (that.height - iconHeight) / 2,
|
565
|
- iconWidth, iconHeight, that.iconData, 0);
|
566
|
+ drawIcon();
|
567
|
+ }
|
568
|
+ drawTitle();
|
569
|
+ };
|
570
|
+
|
571
|
+ /**
|
572
|
+ * Draws the icon according to the icon margins and the widget's layout.
|
573
|
+ */
|
574
|
+ function drawIcon()
|
575
|
+ {
|
576
|
+ var xIconPos;
|
577
|
+ var yIconPos;
|
578
|
+ if (that.horizontalLayout)
|
579
|
+ {
|
580
|
+ xIconPos = that.x + ICON_MARGIN;
|
581
|
+ yIconPos = that.y + (that.height - that.iconHeight) / 2;
|
582
|
}
|
583
|
else
|
584
|
{
|
585
|
- var text = that.win.title;
|
586
|
- if (TASK_BAR_FONT_ID !== undefined)
|
587
|
- {
|
588
|
- var textWidth = fontsManager.getTextWidth(TASK_BAR_FONT_ID, text);
|
589
|
- var textHeight = fontsManager.getTextHeight(TASK_BAR_FONT_ID, text);
|
590
|
- ctx.font = fontsManager.getFontName(TASK_BAR_FONT_ID);
|
591
|
- canvasRenderer.drawText(that.win.title, that.x + (that.width - textWidth) / 2,
|
592
|
- that.y + (that.height + textHeight) / 2, false);
|
593
|
- }
|
594
|
- }
|
595
|
- };
|
596
|
-
|
597
|
+ xIconPos = that.x + (that.width - that.iconWidth) / 2;
|
598
|
+ yIconPos = that.y + ICON_MARGIN;
|
599
|
+ }
|
600
|
+ canvasRenderer.drawImage(ctx, xIconPos, yIconPos, that.iconWidth, that.iconHeight,
|
601
|
+ that.iconData, 0);
|
602
|
+ }
|
603
|
+
|
604
|
+ /**
|
605
|
+ * Draws the title according to the text and icon margins and the widget's layout
|
606
|
+ */
|
607
|
+ function drawTitle()
|
608
|
+ {
|
609
|
+ if (TASK_BAR_FONT_ID !== undefined)
|
610
|
+ {
|
611
|
+ ctx.save();
|
612
|
+ var textWidth = fontsManager.getTextWidth(TASK_BAR_FONT_ID, that.title);
|
613
|
+ var textHeight = fontsManager.getTextHeight(TASK_BAR_FONT_ID, that.title);
|
614
|
+ ctx.font = fontsManager.getFontName(TASK_BAR_FONT_ID);
|
615
|
+
|
616
|
+ var xTextPos;
|
617
|
+ var yTextPos;
|
618
|
+ if (that.horizontalLayout)
|
619
|
+ {
|
620
|
+ var xShift = 0;
|
621
|
+ if (that.iconWidth > 0)
|
622
|
+ {
|
623
|
+ xShift += that.iconWidth + 2 * ICON_MARGIN;
|
624
|
+ }
|
625
|
+ xTextPos = that.x + (that.width - textWidth + xShift) / 2;
|
626
|
+ yTextPos = that.y + (that.height + textHeight) / 2;
|
627
|
+ }
|
628
|
+ else
|
629
|
+ {
|
630
|
+ var yShift = 0;
|
631
|
+ if (that.iconHeight > 0)
|
632
|
+ {
|
633
|
+ yShift += that.iconHeight + 2 * ICON_MARGIN;
|
634
|
+ }
|
635
|
+ xTextPos = that.x + (that.width - textHeight) / 2;
|
636
|
+ yTextPos = that.y + (that.height - textWidth + yShift) / 2;
|
637
|
+ ctx.translate(xTextPos, yTextPos);
|
638
|
+ ctx.rotate(Math.PI / 2);
|
639
|
+ xTextPos = 0;
|
640
|
+ yTextPos = 0;
|
641
|
+ }
|
642
|
+ canvasRenderer.drawText(
|
643
|
+ that.title,
|
644
|
+ xTextPos,
|
645
|
+ yTextPos, false);
|
646
|
+ ctx.restore();
|
647
|
+ }
|
648
|
+ }
|
649
|
+
|
650
|
+ this.testMousePointerInside = testMousePointerInside;
|
651
|
+
|
652
|
/**
|
653
|
* Tests the mouse pointer inside the widgets bounds.
|
654
|
*/
|
655
|
|