Project

General

Profile

2923_3.txt

Sergey Ivanovskiy, 05/12/2016 11:51 AM

Download (14.1 KB)

 
1
=== modified file 'src/com/goldencode/p2j/ui/client/gui/ComboBoxGuiImpl.java'
2
--- src/com/goldencode/p2j/ui/client/gui/ComboBoxGuiImpl.java	2016-05-02 13:37:02 +0000
3
+++ src/com/goldencode/p2j/ui/client/gui/ComboBoxGuiImpl.java	2016-05-12 15:39:07 +0000
4
@@ -1499,7 +1499,6 @@
5
       int yt = orig.y + 1 + (dim.height + fnt.pointSize)/2;
6
       gd.setFontStyle(fnt.style);
7
       // enabled state controls text drawing
8
-      int boxWidth = dim.width - DROP_DOWN_BUTTON_SIZE;
9
       if (isEnabled())
10
       {
11
          if (focused)
12
@@ -1510,14 +1509,14 @@
13
          {
14
             gd.setColor(gc.fgColor);
15
          }
16
-         gd.drawString(display, boxWidth, dim.height, xt, yt, 0, 0);
17
+         gd.drawString(display, xt, yt, w, h, orig.x, orig.y);
18
       }
19
       else
20
       {
21
          gd.setColor(lightShadow);
22
-         gd.drawString(display, boxWidth, dim.height, xt + 1, yt + 1, 1, 1);
23
+         gd.drawString(display, xt + 1, yt + 1, w, h, orig.x, orig.y);
24
          gd.setColor(darkShadow);
25
-         gd.drawString(display, boxWidth, dim.height, xt, yt, 0, 0);
26
+         gd.drawString(display, xt, yt, w, h, orig.x, orig.y);
27
       }
28
 
29
       // draw dotted rectangle around focused item text
30

    
31
=== modified file 'src/com/goldencode/p2j/ui/client/gui/ScrollableSelectionListGuiImpl.java'
32
--- src/com/goldencode/p2j/ui/client/gui/ScrollableSelectionListGuiImpl.java	2016-05-02 13:37:02 +0000
33
+++ src/com/goldencode/p2j/ui/client/gui/ScrollableSelectionListGuiImpl.java	2016-05-12 15:35:04 +0000
34
@@ -699,11 +699,11 @@
35
       }
36
 
37
       // draw item text
38
-      gd.drawString(getItemText(number), rw - ((ComboBoxGuiImpl)box).getDropDownScrollBarWidth(),
39
-                    rh,
40
+      gd.drawString(getItemText(number), 
41
                     box != null && box.config().mode == ComboBoxConfig.Mode.SIMPLE
42
                        ? x + ComboBoxGuiImpl.ENTRY_SHIFT : x + ComboBoxGuiImpl.TEXT_SHIFT,
43
-                    y + 1 + (rh + fontSize)/2, 0, 0);
44
+                    y + 1 + (rh + fontSize)/2, rw - ((ComboBoxGuiImpl)box).getDropDownScrollBarWidth() - ComboBoxGuiImpl.ENTRY_SHIFT,
45
+                    rh, x, y);
46
       
47
       // draw the dotted line for selected item (not for SIMPLE mode of the combo-box)
48
       if (enabled && number == currentRow() &&
49

    
50
=== modified file 'src/com/goldencode/p2j/ui/client/gui/driver/AbstractGuiDriver.java'
51
--- src/com/goldencode/p2j/ui/client/gui/driver/AbstractGuiDriver.java	2016-05-06 16:14:46 +0000
52
+++ src/com/goldencode/p2j/ui/client/gui/driver/AbstractGuiDriver.java	2016-05-12 14:52:07 +0000
53
@@ -706,29 +706,26 @@
54
    }
55
    
56
    /**
57
-    * Draw a string which can be centered within its box and can have an offset along horizontal
58
-    * and/or vertical. If the box is provided width its nonzero width and height, then x and y
59
-    * coordinates don't take into account and the given text is centered within the provided box
60
-    * and shifted along horizontal and/or vertical. 
61
+    * Draw a string using the provided text box and text offset position. 
62
     * 
63
-    * @param   text
64
-    *          text string to draw.
65
-    * @param   boxWidth
66
-    *          The text box width, which needs to be matched when drawing.
67
-    * @param   boxHeight
68
-    *          The text box width, which needs to be matched when drawing.
69
-    * @param   x
70
-    *          The left position.
71
-    * @param   y
72
-    *          The top position.
73
-    * @param   xOffset
74
-    *          The horizontal text offset from its centered position.
75
-    * @param   yOffset
76
-    *          The vertical text offset from its centered position.
77
+    * @param    text
78
+    *           text string to draw.
79
+    * @param    x
80
+    *           The left text position.
81
+    * @param    y
82
+    *           The top text position.
83
+    * @param    boxWidth
84
+    *           The text box width, which needs to be matched when drawing.
85
+    * @param    boxHeight
86
+    *           The text box height, which needs to be matched when drawing.
87
+    * @param    xBoxOffset
88
+    *           The horizontal box position.
89
+    * @param    yBoxOffset
90
+    *           The vertical box position.
91
     */
92
    @Override
93
-   public void drawString(String text, int boxWidth, int boxHeight, int x, int y,
94
-                          int xOffset, int yOffset)
95
+   public void drawString(String text, int x, int y, int boxWidth, int boxHeight,
96
+                          int xBoxOffset, int yBoxOffset)
97
    {
98
       if (isEmptyText(text))
99
       {
100
@@ -741,8 +738,8 @@
101
       ps.y = y;
102
       ps.width = boxWidth;
103
       ps.height = boxHeight;
104
-      ps.xOffset = xOffset;
105
-      ps.yOffset = yOffset;
106
+      ps.xOffset = xBoxOffset;
107
+      ps.yOffset = yBoxOffset;
108
       
109
       ews.offer(ps);
110
    }
111

    
112
=== modified file 'src/com/goldencode/p2j/ui/client/gui/driver/GuiDriver.java'
113
--- src/com/goldencode/p2j/ui/client/gui/driver/GuiDriver.java	2016-05-02 13:05:43 +0000
114
+++ src/com/goldencode/p2j/ui/client/gui/driver/GuiDriver.java	2016-05-12 14:51:49 +0000
115
@@ -178,28 +178,25 @@
116
    public void drawStringCentered(String text, int legacyWidth, int legacyHeight, int x, int height);
117
    
118
    /**
119
-    * Draw a string which can be centered within its box and can have an offset along horizontal
120
-    * and/or vertical. If the box is provided width its nonzero width and height, then x and y
121
-    * coordinates don't take into account and the given text is centered within the provided box
122
-    * and shifted along horizontal and/or vertical. 
123
+    * Draw a string using the provided text box and text offset position. 
124
     * 
125
     * @param    text
126
     *           text string to draw.
127
+    * @param    x
128
+    *           The left text position.
129
+    * @param    y
130
+    *           The top text position.
131
     * @param    boxWidth
132
     *           The text box width, which needs to be matched when drawing.
133
     * @param    boxHeight
134
-    *           The text box width, which needs to be matched when drawing.
135
-    * @param    x
136
-    *           The left position.
137
-    * @param    y
138
-    *           The top position.
139
-    * @param    xOffset
140
-    *           The horizontal text offset from its centered position.
141
-    * @param    yOffset
142
-    *           The vertical text offset from its centered position.
143
+    *           The text box height, which needs to be matched when drawing.
144
+    * @param    xBoxOffset
145
+    *           The horizontal box position.
146
+    * @param    yBoxOffset
147
+    *           The vertical box position.
148
     */
149
-   public void drawString(String text, int boxWidth, int boxHeight, int x, int y,
150
-                          int xOffset, int yOffset);
151
+   public void drawString(String text, int x, int y, int boxWidth, int boxHeight,
152
+                          int xBoxOffset, int yBoxOffset);
153
    
154
    /**
155
     * The method performs a layout operation on the supplied text and 
156

    
157
=== modified file 'src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebSocket.java'
158
--- src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebSocket.java	2016-05-02 13:05:43 +0000
159
+++ src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebSocket.java	2016-05-12 14:52:31 +0000
160
@@ -2540,30 +2540,27 @@
161
    }
162
 
163
    /**
164
-    * Draw a string which can be centered within its box and can have an offset along horizontal
165
-    * and/or vertical. If the box is provided width its nonzero width and height, then x and y
166
-    * coordinates don't take into account and the given text is centered within the provided box
167
-    * and shifted along horizontal and/or vertical. 
168
+    * Draw a string using the provided text box and text offset position. 
169
     * 
170
     * @param    text
171
     *           text string to draw.
172
     * @param    centered
173
     *           Flag indicating if the text is centered vertically.
174
     * @param    x
175
-    *           The left position.
176
+    *           The left text position.
177
     * @param    y
178
-    *           The top position.
179
+    *           The top text position.
180
     * @param    boxWidth
181
     *           The text box width, which needs to be matched when drawing.
182
     * @param    boxHeight
183
-    *           The text box width, which needs to be matched when drawing.
184
-    * @param    xOffset
185
-    *           The horizontal text offset from its centered position.
186
-    * @param    yOffset
187
-    *           The vertical text offset from its centered position.
188
+    *           The text box height, which needs to be matched when drawing.
189
+    * @param    xBoxOffset
190
+    *           The horizontal box position.
191
+    * @param    yBoxOffset
192
+    *           The vertical box position.
193
     */
194
    public void drawString(String text, boolean centered, int x, int y, int boxWidth, int boxHeight,
195
-                          int xOffset, int yOffset)
196
+                          int xBoxOffset, int yBoxOffset)
197
    {
198
       int length = text.length() * 2 + 33; 
199
       byte[] message = allocateDrawingOp(PaintPrimitives.DRAW_STRING, length);
200
@@ -2590,10 +2587,10 @@
201
       writeMessageInt32(message, offset, boxHeight);
202
       offset += 4;
203
       
204
-      writeMessageInt32(message, offset, xOffset);
205
+      writeMessageInt32(message, offset, xBoxOffset);
206
       offset += 4;
207
       
208
-      writeMessageInt32(message, offset, yOffset);
209
+      writeMessageInt32(message, offset, yBoxOffset);
210
       offset += 4;
211
    }
212
 
213

    
214
=== modified file 'src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.canvas_renderer.js'
215
--- src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.canvas_renderer.js	2016-05-05 16:12:00 +0000
216
+++ src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.canvas_renderer.js	2016-05-12 15:33:22 +0000
217
@@ -1778,63 +1778,47 @@
218
 }
219
 
220
 /**
221
- * Draw a string that can be centered within its box and can have an offset along horizontal
222
- * and/or vertical. If the box is provided width its nonzero width and height, then x and y
223
- * coordinates don't take into account and the given text is centered within the provided box
224
- * and shifted along horizontal and/or vertical. 
225
+ * Draw a string within its box. 
226
  * 
227
  * @param    {String} text
228
  *           The text to draw.
229
  * @param    {Number} x
230
- *           The left position.
231
+ *           The left text position.
232
  * @param    {Number} y
233
- *           The top position.
234
+ *           The top text position.
235
  * @param    {Number} boxWidth
236
  *           The text box width, which needs to be matched when drawing.
237
  * @param    {Number} boxHeight
238
  *           The text box width, which needs to be matched when drawing.
239
- * @param    {Number} xOffset
240
- *           The horizontal text offset from its centered position.
241
- * @param    {Number} yOffset
242
- *           The vertical text offset from its centered position.
243
+ * @param    {Number} xBoxOffset
244
+ *           The horizontal box position.
245
+ * @param    {Number} yBoxOffset
246
+ *           The vertical box position.
247
  */
248
-CanvasRenderer.prototype.drawTextBoxAlligned = function(text, x, y, boxWidth, boxHeight,
249
-                                                        xOffset, yOffset)
250
+CanvasRenderer.prototype.drawTextWithinBox = function(text, x, y, boxWidth, boxHeight,
251
+                                                        xBoxOffset, yBoxOffset)
252
 {
253
-   var origY = y;
254
-   
255
-   var textWidth;
256
-   var cfont = p2j.screen.getCurrentFont();
257
-   if (cfont)
258
+   var currentFont = p2j.screen.getCurrentFont();
259
+   if (currentFont)
260
    {
261
-      textWidth = p2j.fonts.getTextWidth(cfont, text);
262
-      if (boxWidth > 0 && textWidth > 0 && boxWidth - x - textWidth <= 1)
263
-      { // ignore x padding and draw text centered.
264
-         x = (boxWidth - textWidth) / 2 + xOffset;
265
-      }
266
-   }
267
+      var lwidth = boxWidth - x + xBoxOffset;
268
+      var textHeight = this.fontsManager.getTextHeight(currentFont, text);
269
+      var textWidth = this.fontsManager.getTextWidth(currentFont, text);
270
+      
271
+      var widthScale = lwidth / textWidth;
272
+      
273
+      // scale drawing context to computed width
274
+      // this scales the desired structure.x as well so it needs adjusting
275
+      this.ctx.save();
276
+      this.ctx.scale(widthScale, 1);
277
+      
278
+      this.ctx.textBaseline = 'bottom';
279
 
280
-   this.ctx.textBaseline = 'bottom';
281
-   
282
-   this.ctx.fillText(text, x, y);
283
-   
284
-   if (p2j.fonts.isUnderlined(cfont))
285
-   {
286
-      // if the style is underline, draw a line under the text
287
-      var txtHeight = p2j.fonts.getTextHeight(cfont, text);
288
-      if (textWidth === undefined)
289
-      {
290
-         textWidth = p2j.fonts.getTextWidth(cfont, text);
291
-      }
292
-      
293
-      var x1 = x;
294
-      var x2 = x + textWidth;
295
-      var y1 = origY;
296
-      var y2 = y1;
297
-      
298
-      this.strokeLineSegment(x1, y1, x2, y2, this.rawColor);
299
+      this.ctx.fillText(text, x / widthScale, y);
300
+      this.ctx.restore();
301
    }
302
 }
303
+
304
 /**
305
  * Draws a given text at the given (x,y) position fitted to the given text rectangle.
306
  * 
307

    
308
=== modified file 'src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.screen.js'
309
--- src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.screen.js	2016-05-06 16:14:46 +0000
310
+++ src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.screen.js	2016-05-12 14:59:34 +0000
311
@@ -1381,20 +1381,21 @@
312
                var boxHeight = p2j.socket.readInt32BinaryMessage(message, idx + offset);
313
                offset = offset + 4;
314
 
315
-               var xOffset = p2j.socket.readInt32BinaryMessage(message, idx + offset);
316
-               offset = offset + 4;
317
-
318
-               var yOffset = p2j.socket.readInt32BinaryMessage(message, idx + offset);
319
-               offset = offset + 4;
320
-
321
+               var xBoxOffset = p2j.socket.readInt32BinaryMessage(message, idx + offset);
322
+               offset = offset + 4;
323
+
324
+               var yBoxOffset = p2j.socket.readInt32BinaryMessage(message, idx + offset);
325
+               offset = offset + 4;
326
+
327
+               this.canvasRenderer.drawText(text, x, y, centered);
328
                if (boxWidth === 0 || boxHeight === 0)
329
                {
330
                   this.canvasRenderer.drawText(text, x, y, centered);
331
                }
332
                else
333
                {
334
-                  this.canvasRenderer.drawTextBoxAlligned(text, x, y, boxWidth, boxHeight,
335
-                                                          xOffset, yOffset);
336
+                  this.canvasRenderer.drawTextWithinBox(text, x, y, boxWidth, boxHeight,
337
+                                                          xBoxOffset, yBoxOffset);
338
                }
339
 
340
                extra = " text = " + text + "; x = " + x + "; y = " + y +
341