Project

General

Profile

2923_1.txt

Sergey Ivanovskiy, 05/02/2016 09:16 AM

Download (19 KB)

 
1
=== modified file 'src/com/goldencode/p2j/ui/client/FontManager.java'
2
--- src/com/goldencode/p2j/ui/client/FontManager.java	2016-04-19 19:24:50 +0000
3
+++ src/com/goldencode/p2j/ui/client/FontManager.java	2016-05-02 12:49:45 +0000
4
@@ -40,6 +40,7 @@
5
 ** 020 SBI 20160110 Changed to install/upload binary fonts only if they are not detected.
6
 ** 021 EVL 20160415 Fix for system font index calculation.  Adding separate font for stack trace
7
 **                  window.
8
+** 022 SBI 20160502 Extended parameter type to create GuiFontResolver for top level windows.
9
 */
10
 
11
 package com.goldencode.p2j.ui.client;
12
@@ -279,7 +280,7 @@
13
     *
14
     * @return   See above.
15
     */
16
-   public static FontDetails<?> resolveFont(Window<?> window, int font, ScreenDriver<?> driver)
17
+   public static FontDetails<?> resolveFont(TopLevelWindow<?> window, int font, ScreenDriver<?> driver)
18
    {
19
       if (driver.isChui())
20
       {
21

    
22
=== modified file 'src/com/goldencode/p2j/ui/client/gui/ComboBoxGuiImpl.java'
23
--- src/com/goldencode/p2j/ui/client/gui/ComboBoxGuiImpl.java	2016-04-13 19:52:18 +0000
24
+++ src/com/goldencode/p2j/ui/client/gui/ComboBoxGuiImpl.java	2016-05-02 12:50:56 +0000
25
@@ -60,6 +60,8 @@
26
 ** 021 HC  20160406 COMBO-BOX drop-down resources cleanup. Various drop-down related fixes.
27
 ** 022 HC  20160413 Fixed COMBO-BOX focus management, this also resolves ENTER not confirming
28
 **                  selected item in the drop-down.
29
+** 023 SBI 20160502 Fixed the web combobox entry and drop down list items to be aligned within
30
+**                  their boxes.
31
 */
32
 
33
 package com.goldencode.p2j.ui.client.gui;
34
@@ -1507,14 +1509,14 @@
35
          {
36
             gd.setColor(gc.fgColor);
37
          }
38
-         gd.drawString(display, xt, yt);
39
+         gd.drawString(display, dim.width, dim.height, xt, yt, 0, 0);
40
       }
41
       else
42
       {
43
          gd.setColor(lightShadow);
44
-         gd.drawString(display, xt + 1, yt + 1);
45
+         gd.drawString(display, dim.width, dim.height, xt + 1, yt + 1, 1, 1);
46
          gd.setColor(darkShadow);
47
-         gd.drawString(display, xt, yt);
48
+         gd.drawString(display, dim.width, dim.height, xt, yt, 0, 0);
49
       }
50
 
51
       // draw dotted rectangle around focused item text
52

    
53
=== modified file 'src/com/goldencode/p2j/ui/client/gui/GuiFontResolver.java'
54
--- src/com/goldencode/p2j/ui/client/gui/GuiFontResolver.java	2015-05-18 20:48:28 +0000
55
+++ src/com/goldencode/p2j/ui/client/gui/GuiFontResolver.java	2016-05-02 12:49:01 +0000
56
@@ -18,6 +18,7 @@
57
 ** 005 CA  20150507 No need to re-scale the font, it gets scaled when it gets created - so all 
58
 **                  fonts are assumed to match the legacy metrics.
59
 ** 006 GES 20150425 Eliminated AWT dependencies.
60
+** 007 SBI 20160502 Extended parameter type to create GuiFontResolver for top level windows.
61
 */
62
 
63
 package com.goldencode.p2j.ui.client.gui;
64
@@ -41,7 +42,7 @@
65
    private Map<Integer, FontCache> fontCache = new HashMap<>();
66
 
67
    /** Window instance. */
68
-   private Window<?> window;
69
+   private TopLevelWindow<?> window;
70
       
71
    /** Screen driver. */
72
    private GuiDriver gd;
73
@@ -68,7 +69,7 @@
74
     * @param    config
75
     *           Widget configuration.
76
     */
77
-   public GuiFontResolver(Window<?>  window, GuiDriver gd, BaseConfig config)
78
+   public GuiFontResolver(TopLevelWindow<?>  window, GuiDriver gd, BaseConfig config)
79
    {
80
       this(window, gd, config, false);
81
    }
82
@@ -86,7 +87,7 @@
83
     *           Flag identifying that the referenced font must default to the default fixed font, 
84
     *           if is not specified.
85
     */
86
-   public GuiFontResolver(Window<?> window, GuiDriver gd, BaseConfig config, boolean fixedFont)
87
+   public GuiFontResolver(TopLevelWindow<?> window, GuiDriver gd, BaseConfig config, boolean fixedFont)
88
    {
89
       this.window = window;
90
       this.gd = gd;
91

    
92
=== modified file 'src/com/goldencode/p2j/ui/client/gui/ScrollableSelectionListGuiImpl.java'
93
--- src/com/goldencode/p2j/ui/client/gui/ScrollableSelectionListGuiImpl.java	2016-04-13 19:52:18 +0000
94
+++ src/com/goldencode/p2j/ui/client/gui/ScrollableSelectionListGuiImpl.java	2016-05-02 13:02:14 +0000
95
@@ -46,6 +46,8 @@
96
 ** 016 HC  20160406 COMBO-BOX drop-down resources cleanup. Various drop-down related fixes.
97
 ** 017 HC  20160413 Fixed COMBO-BOX focus management, this also resolves ENTER not confirming
98
 **                  selected item in the drop-down.
99
+** 018 SBI 20160502 Fixed the web combobox entry and drop down list items to be aligned within
100
+**                  their boxes, fixed GuiFontResolver to have a correct top level window.
101
 */
102
 
103
 package com.goldencode.p2j.ui.client.gui;
104
@@ -59,7 +61,6 @@
105
 import com.goldencode.p2j.ui.chui.ThinClient;
106
 import com.goldencode.p2j.ui.client.*;
107
 import com.goldencode.p2j.ui.client.event.*;
108
-import com.goldencode.p2j.ui.client.event.listener.*;
109
 import com.goldencode.p2j.ui.client.gui.GuiFontResolver.FontCache;
110
 import com.goldencode.p2j.ui.client.gui.driver.*;
111
 import com.goldencode.p2j.ui.client.model.*;
112
@@ -123,8 +124,6 @@
113
 
114
       // initialize screen driver
115
       gd = (GuiDriver) OutputManager.getDriver();
116
-      // and font resolver
117
-      gf = new GuiFontResolver(WindowManager.resolveWindow(this), gd, box.config(), false);
118
       // color initializing
119
       selectionBack = gd.getSysColor(SysColor.COLOR_HIGHLIGHT);
120
       selectionFore = gd.getSysColor(SysColor.COLOR_HIGHLIGHTTEXT);
121
@@ -155,7 +154,13 @@
122
 
123
       // get actual rows to view
124
       final int rowsVisible = visibleRows();
125
-      
126
+
127
+      if (gf == null)
128
+      {
129
+         // and font resolver
130
+         gf = new GuiFontResolver(topLevelWindow(), gd, box.config(), false);
131
+      }
132
+
133
       // resolve font
134
       final FontCache fntCache = gf.font();
135
 
136
@@ -694,10 +699,10 @@
137
       }
138
 
139
       // draw item text
140
-      gd.drawString(getItemText(number),
141
+      gd.drawString(getItemText(number), rw, rh,
142
                     box != null && box.config().mode == ComboBoxConfig.Mode.SIMPLE
143
                        ? x + ComboBoxGuiImpl.ENTRY_SHIFT : x + ComboBoxGuiImpl.TEXT_SHIFT,
144
-                    y + 1 + (rh + fontSize)/2);
145
+                    y + 1 + (rh + fontSize)/2, 0, 0);
146
       
147
       // draw the dotted line for selected item (not for SIMPLE mode of the combo-box)
148
       if (enabled && number == currentRow() &&
149

    
150
=== modified file 'src/com/goldencode/p2j/ui/client/gui/driver/AbstractGuiDriver.java'
151
--- src/com/goldencode/p2j/ui/client/gui/driver/AbstractGuiDriver.java	2016-04-14 15:15:50 +0000
152
+++ src/com/goldencode/p2j/ui/client/gui/driver/AbstractGuiDriver.java	2016-05-02 13:00:34 +0000
153
@@ -53,6 +53,8 @@
154
 ** 018 HC  20160407 Overhaul of window-activation logic. Removed setOverlayWindowLocation(), the
155
 **                  method was unnecessary and was causing the COMBO-BOX drop-down location
156
 **                  incorrect.
157
+** 019 SBI 20160502 Fixed the web combobox entry and drop down list items to be aligned within
158
+**                  their boxes.
159
 */
160
 
161
 package com.goldencode.p2j.ui.client.gui.driver;
162
@@ -703,6 +705,48 @@
163
    }
164
    
165
    /**
166
+    * Draw a string which can be centered within its box and can have an offset along horizontal
167
+    * and/or vertical. If the box is provided width its nonzero width and height, then x and y
168
+    * coordinates don't take into account and the given text is centered within the provided box
169
+    * and shifted along horizontal and/or vertical. 
170
+    * 
171
+    * @param   text
172
+    *          text string to draw.
173
+    * @param   boxWidth
174
+    *          The text box width, which needs to be matched when drawing.
175
+    * @param   boxHeight
176
+    *          The text box width, which needs to be matched when drawing.
177
+    * @param   x
178
+    *          The left position.
179
+    * @param   y
180
+    *          The top position.
181
+    * @param   xOffset
182
+    *          The horizontal text offset from its centered position.
183
+    * @param   yOffset
184
+    *          The vertical text offset from its centered position.
185
+    */
186
+   @Override
187
+   public void drawString(String text, int boxWidth, int boxHeight, int x, int y,
188
+                          int xOffset, int yOffset)
189
+   {
190
+      if (isEmptyText(text))
191
+      {
192
+         return;
193
+      }
194
+
195
+      PaintStructure ps = new PaintStructure(PaintPrimitives.DRAW_STRING);
196
+      ps.text = text;
197
+      ps.x = x;
198
+      ps.y = y;
199
+      ps.width = boxWidth;
200
+      ps.height = boxHeight;
201
+      ps.xOffset = xOffset;
202
+      ps.yOffset = yOffset;
203
+      
204
+      ews.offer(ps);
205
+   }
206
+
207
+   /**
208
     * The method performs a layout operation on the supplied text and 
209
     * returns the resulting paragraph height while maintaining the
210
     * supplied maximum width.
211

    
212
=== modified file 'src/com/goldencode/p2j/ui/client/gui/driver/GuiDriver.java'
213
--- src/com/goldencode/p2j/ui/client/gui/driver/GuiDriver.java	2016-04-21 08:31:31 +0000
214
+++ src/com/goldencode/p2j/ui/client/gui/driver/GuiDriver.java	2016-05-02 12:58:52 +0000
215
@@ -76,6 +76,8 @@
216
 **                  setDesktopBgColor(ColorRgb color).
217
 ** 042 HC  20160407 Removed setOverlayWindowLocation(), the method was unnecessary and was
218
 **                  causing the COMBO-BOX drop-down location incorrect.
219
+** 043 SBI 20160502 Fixed the web combobox entry and drop down list items to be aligned within
220
+**                  their boxes.
221
 */
222
 
223
 package com.goldencode.p2j.ui.client.gui.driver;
224
@@ -176,6 +178,30 @@
225
    public void drawStringCentered(String text, int legacyWidth, int legacyHeight, int x, int height);
226
    
227
    /**
228
+    * Draw a string which can be centered within its box and can have an offset along horizontal
229
+    * and/or vertical. If the box is provided width its nonzero width and height, then x and y
230
+    * coordinates don't take into account and the given text is centered within the provided box
231
+    * and shifted along horizontal and/or vertical. 
232
+    * 
233
+    * @param    text
234
+    *           text string to draw.
235
+    * @param    boxWidth
236
+    *           The text box width, which needs to be matched when drawing.
237
+    * @param    boxHeight
238
+    *           The text box width, which needs to be matched when drawing.
239
+    * @param    x
240
+    *           The left position.
241
+    * @param    y
242
+    *           The top position.
243
+    * @param    xOffset
244
+    *           The horizontal text offset from its centered position.
245
+    * @param    yOffset
246
+    *           The vertical text offset from its centered position.
247
+    */
248
+   public void drawString(String text, int boxWidth, int boxHeight, int x, int y,
249
+                          int xOffset, int yOffset);
250
+   
251
+   /**
252
     * The method performs a layout operation on the supplied text and 
253
     * returns the resulting paragraph height while maintaining the
254
     * supplied maximum width.
255

    
256
=== modified file 'src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebEmulatedWindow.java'
257
--- src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebEmulatedWindow.java	2016-03-25 01:36:48 +0000
258
+++ src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebEmulatedWindow.java	2016-05-02 13:03:32 +0000
259
@@ -34,6 +34,8 @@
260
 ** 012 CA  20160323 In getTextHeight(), return the font's height, as p2j.fonts.js computes the 
261
 **                  text's height in the same way.
262
 **     SBI 20160324 Implemented SET_DESKTOP_BGCOLOR.
263
+** 013 SBI 20160502 Fixed the web combo box entry and drop down list items to be aligned within
264
+**                  their boxes.
265
 */
266
 
267
 package com.goldencode.p2j.ui.client.gui.driver.web;
268
@@ -323,7 +325,8 @@
269
       switch (ps.id)
270
       {
271
          case DRAW_STRING:
272
-            websock.drawString(ps.text, ps.centered, ps.x, ps.y);
273
+            websock.drawString(ps.text, ps.centered, ps.x, ps.y, ps.width, ps.height,
274
+                     ps.xOffset, ps.yOffset);
275
             break;
276
          case DRAW_STRING_SCALED:
277
             websock.drawStringScaled(ps.text, ps.centered, ps.x, ps.y, ps.width, ps.height);
278

    
279
=== modified file 'src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebSocket.java'
280
--- src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebSocket.java	2016-04-27 15:18:42 +0000
281
+++ src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebSocket.java	2016-05-02 13:01:20 +0000
282
@@ -51,6 +51,8 @@
283
 **                  customer-specific application.
284
 **     SBI 20160422 The resize drawing operations must not be cached.
285
 ** 015 SBI 20160427 Added graphicsCached parameter to turn off the graphics cache for testing.
286
+**     SBI 20160502 Fixed the web combobox entry and drop down list items to be aligned within
287
+**                  their boxes.
288
 */
289
 
290
 package com.goldencode.p2j.ui.client.gui.driver.web;
291
@@ -2512,7 +2514,36 @@
292
     */
293
    public void drawString(String text, boolean centered, int x, int y)
294
    {
295
-      int length = 1 + 4 + text.length() * 2 + 4 + 4 + 4; 
296
+      drawString(text, centered, x, y, 0, 0, 0, 0);
297
+   }
298
+
299
+   /**
300
+    * Draw a string which can be centered within its box and can have an offset along horizontal
301
+    * and/or vertical. If the box is provided width its nonzero width and height, then x and y
302
+    * coordinates don't take into account and the given text is centered within the provided box
303
+    * and shifted along horizontal and/or vertical. 
304
+    * 
305
+    * @param    text
306
+    *           text string to draw.
307
+    * @param    centered
308
+    *           Flag indicating if the text is centered vertically.
309
+    * @param    x
310
+    *           The left position.
311
+    * @param    y
312
+    *           The top position.
313
+    * @param    boxWidth
314
+    *           The text box width, which needs to be matched when drawing.
315
+    * @param    boxHeight
316
+    *           The text box width, which needs to be matched when drawing.
317
+    * @param    xOffset
318
+    *           The horizontal text offset from its centered position.
319
+    * @param    yOffset
320
+    *           The vertical text offset from its centered position.
321
+    */
322
+   public void drawString(String text, boolean centered, int x, int y, int boxWidth, int boxHeight,
323
+                          int xOffset, int yOffset)
324
+   {
325
+      int length = text.length() * 2 + 33; 
326
       byte[] message = allocateDrawingOp(PaintPrimitives.DRAW_STRING, length);
327
       
328
       int offset = 1;
329
@@ -2530,6 +2561,18 @@
330
       
331
       writeMessageInt32(message, offset, y);
332
       offset += 4;
333
+
334
+      writeMessageInt32(message, offset, boxWidth);
335
+      offset += 4;
336
+      
337
+      writeMessageInt32(message, offset, boxHeight);
338
+      offset += 4;
339
+      
340
+      writeMessageInt32(message, offset, xOffset);
341
+      offset += 4;
342
+      
343
+      writeMessageInt32(message, offset, yOffset);
344
+      offset += 4;
345
    }
346
 
347
    /**
348

    
349
=== modified file 'src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.canvas_renderer.js'
350
--- src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.canvas_renderer.js	2016-04-28 09:48:03 +0000
351
+++ src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.canvas_renderer.js	2016-05-02 12:59:36 +0000
352
@@ -27,6 +27,8 @@
353
 **     SBI 20160213 Reduced putImageData invocations for horizontal and vertical lines.
354
 **     SBI 20160322 Changed to work around if the window canvas has a zero width or height.
355
 ** 006 SBI 20160415 Replaced logFormatted(...) by log(...).
356
+** 007 SBI 20160502 Fixed the web combobox entry and drop down list items to be aligned within
357
+**                  their boxes, added drawTextBoxAlligned.
358
 */
359
 
360
 "use strict";
361
@@ -1776,6 +1778,64 @@
362
 }
363
 
364
 /**
365
+ * Draw a string that can be centered within its box and can have an offset along horizontal
366
+ * and/or vertical. If the box is provided width its nonzero width and height, then x and y
367
+ * coordinates don't take into account and the given text is centered within the provided box
368
+ * and shifted along horizontal and/or vertical. 
369
+ * 
370
+ * @param    {String} text
371
+ *           The text to draw.
372
+ * @param    {Number} x
373
+ *           The left position.
374
+ * @param    {Number} y
375
+ *           The top position.
376
+ * @param    {Number} boxWidth
377
+ *           The text box width, which needs to be matched when drawing.
378
+ * @param    {Number} boxHeight
379
+ *           The text box width, which needs to be matched when drawing.
380
+ * @param    {Number} xOffset
381
+ *           The horizontal text offset from its centered position.
382
+ * @param    {Number} yOffset
383
+ *           The vertical text offset from its centered position.
384
+ */
385
+CanvasRenderer.prototype.drawTextBoxAlligned = function(text, x, y, boxWidth, boxHeight,
386
+                                                        xOffset, yOffset)
387
+{
388
+   var origY = y;
389
+   
390
+   var textWidth;
391
+   var cfont = p2j.screen.getCurrentFont();
392
+   if (cfont)
393
+   {
394
+      textWidth = p2j.fonts.getTextWidth(cfont, text);
395
+      if (boxWidth > 0)
396
+      {
397
+         x = (boxWidth - textWidth - 16) / 2 + xOffset;
398
+      }
399
+   }
400
+
401
+   this.ctx.textBaseline = 'bottom';
402
+   
403
+   this.ctx.fillText(text, x, y);
404
+   
405
+   if (p2j.fonts.isUnderlined(cfont))
406
+   {
407
+      // if the style is underline, draw a line under the text
408
+      var txtHeight = p2j.fonts.getTextHeight(cfont, text);
409
+      if (textWidth === undefined)
410
+      {
411
+         textWidth = p2j.fonts.getTextWidth(cfont, text);
412
+      }
413
+      
414
+      var x1 = x;
415
+      var x2 = x + textWidth;
416
+      var y1 = origY;
417
+      var y2 = y1;
418
+      
419
+      this.strokeLineSegment(x1, y1, x2, y2, this.rawColor);
420
+   }
421
+}
422
+/**
423
  * Draws a given text at the given (x,y) position fitted to the given text rectangle.
424
  * 
425
  * @param    {Number} currentFont
426

    
427
=== modified file 'src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.screen.js'
428
--- src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.screen.js	2016-04-27 15:18:42 +0000
429
+++ src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.screen.js	2016-05-02 13:00:08 +0000
430
@@ -48,6 +48,8 @@
431
 ** 012 SBI 20160414 Fixed  doWindowActivationChange(...) and activateTopVisibleWindow(...).
432
 **     SBI 20160422 The resize drawing operations must not be cached.
433
 ** 013 SBI 20160427 Added graphicsCached parameter to turn off the graphics cache for testing.
434
+** 014 SBI 20160502 Fixed the web combobox entry and drop down list items to be aligned within
435
+**                  their boxes, added drawTextBoxAlligned.
436
 */
437
 
438
 "use strict";
439
@@ -1369,7 +1371,29 @@
440
 
441
                y = p2j.socket.readInt32BinaryMessage(message, idx + offset);
442
                offset = offset + 4;
443
-               this.canvasRenderer.drawText(text, x, y, centered);
444
+
445
+               var boxWidth = p2j.socket.readInt32BinaryMessage(message, idx + offset);
446
+               offset = offset + 4;
447
+
448
+               var boxHeight = p2j.socket.readInt32BinaryMessage(message, idx + offset);
449
+               offset = offset + 4;
450
+
451
+               var xOffset = p2j.socket.readInt32BinaryMessage(message, idx + offset);
452
+               offset = offset + 4;
453
+
454
+               var yOffset = p2j.socket.readInt32BinaryMessage(message, idx + offset);
455
+               offset = offset + 4;
456
+
457
+               if (boxWidth === 0 || boxHeight === 0)
458
+               {
459
+                  this.canvasRenderer.drawText(text, x, y, centered);
460
+               }
461
+               else
462
+               {
463
+                  this.canvasRenderer.drawTextBoxAlligned(text, x, y, boxWidth, boxHeight,
464
+                                                          xOffset, yOffset);
465
+               }
466
+
467
                extra = " text = " + text + "; x = " + x + "; y = " + y +
468
                        "; centered = " + centered;
469
                break;
470