1
|
=== modified file 'src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.virtual_desktop.js'
|
2
|
--- src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.virtual_desktop.js 2015-09-10 19:27:07 +0000
|
3
|
+++ src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.virtual_desktop.js 2015-09-11 12:06:53 +0000
|
4
|
@@ -1165,6 +1165,7 @@
|
5
|
ctx.font = fontsManager.getFontName(TASK_BAR_FONT_ID);
|
6
|
var xTextPos;
|
7
|
var yTextPos;
|
8
|
+ var text;
|
9
|
if (that.horizontalLayout)
|
10
|
{
|
11
|
var xShift = TEXT_MARGIN;
|
12
|
@@ -1172,7 +1173,17 @@
|
13
|
{
|
14
|
xShift += that.iconWidth + 2 * ICON_MARGIN;
|
15
|
}
|
16
|
- xTextPos = that.x + (that.width - TEXT_MARGIN - textWidth + xShift) / 2;
|
17
|
+ if (that.width - TEXT_MARGIN - xShift >= textWidth)
|
18
|
+ {
|
19
|
+ xTextPos = that.x + (that.width - TEXT_MARGIN - textWidth + xShift) / 2;
|
20
|
+ text = that.title;
|
21
|
+ }
|
22
|
+ else
|
23
|
+ {
|
24
|
+ xTextPos = that.x + xShift;
|
25
|
+ text = cutTextToFitWidth(that.title, textWidth, that.width - TEXT_MARGIN - xShift);
|
26
|
+ }
|
27
|
+
|
28
|
yTextPos = that.y + (that.height + textHeight) / 2;
|
29
|
}
|
30
|
else
|
31
|
@@ -1183,7 +1194,16 @@
|
32
|
yShift += that.iconHeight + 2 * ICON_MARGIN;
|
33
|
}
|
34
|
xTextPos = that.x + (that.width - textHeight) / 2;
|
35
|
- yTextPos = that.y + (that.height - TEXT_MARGIN - textWidth + yShift) / 2;
|
36
|
+ if (that.height - TEXT_MARGIN - yShift >= textWidth)
|
37
|
+ {
|
38
|
+ yTextPos = that.y + (that.height - TEXT_MARGIN - textWidth + yShift) / 2;
|
39
|
+ text = that.title;
|
40
|
+ }
|
41
|
+ else
|
42
|
+ {
|
43
|
+ yTextPos = that.y + yShift;
|
44
|
+ text = cutTextToFitWidth(that.title, textWidth, that.height - TEXT_MARGIN - yShift);
|
45
|
+ }
|
46
|
ctx.translate(xTextPos, yTextPos);
|
47
|
ctx.rotate(Math.PI / 2);
|
48
|
xTextPos = 0;
|
49
|
@@ -1201,12 +1221,42 @@
|
50
|
}
|
51
|
|
52
|
canvasRenderer.drawText(
|
53
|
- that.title,
|
54
|
+ text,
|
55
|
xTextPos,
|
56
|
yTextPos, false);
|
57
|
ctx.restore();
|
58
|
}
|
59
|
|
60
|
+ /**
|
61
|
+ * Cuts the given text to fit the given width.
|
62
|
+ *
|
63
|
+ * @param {String} text
|
64
|
+ * The text to draw
|
65
|
+ * @param {Number} textWidth
|
66
|
+ * The text width in the current device metric.
|
67
|
+ * @param {Number} widthToFit
|
68
|
+ * The target width to which the trancated text should fit.
|
69
|
+ *
|
70
|
+ * @return {String}
|
71
|
+ * The truncated text that must fit the given width.
|
72
|
+ */
|
73
|
+ function cutTextToFitWidth(text, textWidth, widthToFit)
|
74
|
+ {
|
75
|
+ var averageTextLen = Math.floor((widthToFit / (1.0 * textWidth)) * text.length);
|
76
|
+ if (averageTextLen > 3)
|
77
|
+ {
|
78
|
+ return text.substr(0, averageTextLen - 3) + "...";
|
79
|
+ }
|
80
|
+ else if (averageTextLen > 1)
|
81
|
+ {
|
82
|
+ return text.substr(0, averageTextLen - 1) + ".";
|
83
|
+ }
|
84
|
+ else
|
85
|
+ {
|
86
|
+ return ".";
|
87
|
+ }
|
88
|
+ }
|
89
|
+
|
90
|
this.testMousePointerInside = testMousePointerInside;
|
91
|
|
92
|
/**
|
93
|
|