=== modified file 'src/com/goldencode/p2j/ui/chui/ChuiWidgetFactory.java' --- src/com/goldencode/p2j/ui/chui/ChuiWidgetFactory.java 2016-03-23 18:33:05 +0000 +++ src/com/goldencode/p2j/ui/chui/ChuiWidgetFactory.java 2016-06-02 17:08:22 +0000 @@ -34,6 +34,7 @@ ** 018 HC 20150831 Scrolling support overhaul. ** 019 IAS 20160227 Added new createScrollPane method as a synonym for the existing one ** 010 IAS 20160315 Support for the DEBUG-ALERT attribute +** 011 SBI 20160512 Changed the scrollable list type. */ package com.goldencode.p2j.ui.chui; @@ -195,10 +196,12 @@ * @return instance of UI-specific implementation of {@link ScrollableList}. */ @Override - public ScrollableListImpl createScrollableList(ComboBox parent, - ListModel model) + public ScrollableList> createScrollableList( + ComboBox parent, + ListModel model) { - return new ScrollableListImpl(parent, parent.model()); + return parent.create(parent.model()); } /** === modified file 'src/com/goldencode/p2j/ui/chui/ComboBoxImpl.java' --- src/com/goldencode/p2j/ui/chui/ComboBoxImpl.java 2016-01-14 04:50:32 +0000 +++ src/com/goldencode/p2j/ui/chui/ComboBoxImpl.java 2016-06-02 17:08:22 +0000 @@ -2,7 +2,7 @@ ** Module : ComboBoxImpl.java ** Abstract : chui implementation of the combo-box ** -** Copyright (c) 2011-2015, Golden Code Development Corporation. +** Copyright (c) 2011-2016, Golden Code Development Corporation. ** ALL RIGHTS RESERVED. Use is subject to license terms. ** ** Golden Code Development Corporation @@ -27,6 +27,7 @@ ** 009 IAS 20150924 Added AUTO-RESIZE attribute support ** 010 EVL 20151217 Drop-down approach rework. Separation ChUI specific drop-down registration ** and focus gaining. +** 011 SBI 20160512 Implemented to create the scrollable list factory method. */ package com.goldencode.p2j.ui.chui; @@ -34,6 +35,7 @@ import com.goldencode.p2j.ui.*; import com.goldencode.p2j.ui.client.*; import com.goldencode.p2j.ui.client.chui.driver.*; +import com.goldencode.p2j.ui.client.model.*; import com.goldencode.p2j.ui.client.widget.*; import com.goldencode.util.*; @@ -158,6 +160,21 @@ } /** + * Creates the scrollable list for this combobox based on the provided list model. + * + * @param model + * The scrollable list model. + * + * @return The scrollable list. + */ + @Override + public ScrollableList> create( + ListModel model) + { + return new ScrollableListImpl(this, model); + } + + /** * Registers drop-down frame in current window system. ChUI specific version. */ @Override === modified file 'src/com/goldencode/p2j/ui/chui/ScrollableListImpl.java' --- src/com/goldencode/p2j/ui/chui/ScrollableListImpl.java 2015-09-16 16:53:54 +0000 +++ src/com/goldencode/p2j/ui/chui/ScrollableListImpl.java 2016-06-02 17:08:22 +0000 @@ -17,6 +17,7 @@ ** 006 CA 20150603 Removed requestSync from drawCaret. ** 007 EVL 20150517 Adding api to set up the top row index. ** 008 HC 20150913 Scrolling support overhaul. +** 009 SBI 20160512 Changed to provide the generic combobox parameter. */ package com.goldencode.p2j.ui.chui; @@ -31,7 +32,7 @@ * CHUI-specific portion of ScrollableList. */ public class ScrollableListImpl -extends ScrollableList +extends ScrollableList { /** * Create component using given configuration and data model. @@ -41,7 +42,7 @@ * @param model * The data model that represents the contents of the list. */ - ScrollableListImpl(ComboBox box, ListModel model) + ScrollableListImpl(ComboBoxImpl box, ListModel model) { super(box, model); } === modified file 'src/com/goldencode/p2j/ui/client/ComboBox.java' --- src/com/goldencode/p2j/ui/client/ComboBox.java 2016-05-13 18:02:49 +0000 +++ src/com/goldencode/p2j/ui/client/ComboBox.java 2016-06-02 17:08:22 +0000 @@ -202,6 +202,7 @@ ** 103 HC 20160406 Fixed COMBO-BOX drop-down resource cleanup. ** 104 HC 20160413 Comment fix. ** 105 HC 20160511 Fixed COMBO-BOX focusing issues and related changes. +** 106 SBI 20160512 Added the scrollable list factory method. */ package com.goldencode.p2j.ui.client; @@ -292,6 +293,16 @@ } /** + * Creates the scrollable list for this combobox based on the provided list model. + * + * @param model + * The scrollable list model. + * + * @return The scrollable list. + */ + public abstract ScrollableList> create(ListModel model); + + /** * Replacement API for the logic which should exist in the widget's c'tor, but the logic * can't be executed as it depends on the widget being registered into the official registry. *

=== modified file 'src/com/goldencode/p2j/ui/client/DropDown.java' --- src/com/goldencode/p2j/ui/client/DropDown.java 2016-04-06 15:37:34 +0000 +++ src/com/goldencode/p2j/ui/client/DropDown.java 2016-06-02 17:08:22 +0000 @@ -43,6 +43,7 @@ ** 019 EVL 20160224 Javadoc fixes to make compatible with Oracle Java 8 for Solaris 10. ** 020 IAS 20160229 Change scrollpane creation. ** 021 HC 20160406 Fixed COMBO-BOX drop-down resource cleanup. +** 022 SBI 20160512 Changed the scrollable list type. */ package com.goldencode.p2j.ui.client; @@ -61,7 +62,7 @@ extends OuterFrame { /** The list instance to represent the drop-down content. */ - protected final ScrollableList list; + protected final ScrollableList> list; /** Wraps the list of items and handles scrolling. */ protected ScrollPane scrollpane; @@ -147,7 +148,7 @@ * * @return See above. */ - public ScrollableList getList() + public ScrollableList> getList() { return list; } === modified file 'src/com/goldencode/p2j/ui/client/FontManager.java' --- src/com/goldencode/p2j/ui/client/FontManager.java 2016-04-19 19:24:50 +0000 +++ src/com/goldencode/p2j/ui/client/FontManager.java 2016-06-02 16:57:20 +0000 @@ -40,6 +40,7 @@ ** 020 SBI 20160110 Changed to install/upload binary fonts only if they are not detected. ** 021 EVL 20160415 Fix for system font index calculation. Adding separate font for stack trace ** window. +** 022 SBI 20160502 Extended parameter type to create GuiFontResolver for top level windows. */ package com.goldencode.p2j.ui.client; @@ -279,7 +280,7 @@ * * @return See above. */ - public static FontDetails resolveFont(Window window, int font, ScreenDriver driver) + public static FontDetails resolveFont(TopLevelWindow window, int font, ScreenDriver driver) { if (driver.isChui()) { === modified file 'src/com/goldencode/p2j/ui/client/ScrollPane.java' --- src/com/goldencode/p2j/ui/client/ScrollPane.java 2016-03-13 15:10:14 +0000 +++ src/com/goldencode/p2j/ui/client/ScrollPane.java 2016-06-02 17:08:22 +0000 @@ -97,6 +97,7 @@ ** duration of the drawing operation or other GUI API invocation which ** requires access to the underlying physical window. ** 050 HC 20160313 Fixed frame scroll layout calculation. +** 051 SBI 20160512 Changed the scrollable list type. */ package com.goldencode.p2j.ui.client; @@ -414,7 +415,7 @@ } else if (viewport().getScrollWidget() instanceof ScrollableList) { - offset = ((ScrollableList) viewport().getScrollWidget()).getCurrentRow() + 1; + offset = ((ScrollableList) viewport().getScrollWidget()).getCurrentRow() + 1; } if (offset <= 0) === modified file 'src/com/goldencode/p2j/ui/client/ScrollableList.java' --- src/com/goldencode/p2j/ui/client/ScrollableList.java 2016-04-20 12:23:53 +0000 +++ src/com/goldencode/p2j/ui/client/ScrollableList.java 2016-06-02 17:08:22 +0000 @@ -66,6 +66,7 @@ ** smaller than the parent's width. ** 20151110 GUI combo-box fixes. ** 032 VIG 20160420 Added isScrollPopupSupported implementation. +** 033 SBI 20160512 Changed to have a generic combobox parameter. */ package com.goldencode.p2j.ui.client; @@ -87,11 +88,11 @@ * "contents" inside the drop-down portion of a {@link ComboBox}. For the * general purpose selection list please use the {@link SelectionList} class. */ -public abstract class ScrollableList> +public abstract class ScrollableList, C extends ComboBox> extends DefaultList { /** ComboBox instance which this instance services. */ - protected ComboBox box = null; + protected C box = null; /** * Create component using given configuration and data model. @@ -101,7 +102,7 @@ * @param model * The data model that represents the contents of the list. */ - public ScrollableList(ComboBox box, ListModel model) + public ScrollableList(C box, ListModel model) { super(model); allowDeselect(false); @@ -281,7 +282,7 @@ * @return the {@link ComboBox} instance to which this drop-down * list is attached to. */ - public ComboBox getBox() + public C getBox() { return box; } === modified file 'src/com/goldencode/p2j/ui/client/driver/WidgetFactory.java' --- src/com/goldencode/p2j/ui/client/driver/WidgetFactory.java 2016-03-15 22:50:52 +0000 +++ src/com/goldencode/p2j/ui/client/driver/WidgetFactory.java 2016-06-02 17:08:22 +0000 @@ -32,6 +32,7 @@ ** 014 HC 20150831 Scrolling support overhaul. ** 015 IAS 20160217 Added new flavor for the createScrollPane method. ** 016 IAS 20160315 Support for the DEBUG-ALERT attribute +** 017 SBI 20160512 Changed the scrollable list type. */ package com.goldencode.p2j.ui.client.driver; @@ -134,7 +135,8 @@ * * @return instance of UI-specific implementation of {@link ScrollableList}. */ - ScrollableList createScrollableList(ComboBox parent, ListModel model); + ScrollableList> createScrollableList(ComboBox parent, + ListModel model); /** * Create UI-specific {@link DropDown} implementation. === modified file 'src/com/goldencode/p2j/ui/client/gui/ComboBoxGuiImpl.java' --- src/com/goldencode/p2j/ui/client/gui/ComboBoxGuiImpl.java 2016-05-13 10:56:49 +0000 +++ src/com/goldencode/p2j/ui/client/gui/ComboBoxGuiImpl.java 2016-06-02 17:08:22 +0000 @@ -61,6 +61,8 @@ ** 022 HC 20160413 Fixed COMBO-BOX focus management, this also resolves ENTER not confirming ** selected item in the drop-down. ** 023 HC 20160511 Fixed COMBO-BOX focusing issues and related changes. +** 024 SBI 20160502 Fixed the web combobox entry and drop down list items to be aligned within +** their boxes. */ package com.goldencode.p2j.ui.client.gui; @@ -78,6 +80,7 @@ import com.goldencode.p2j.ui.client.format.*; import com.goldencode.p2j.ui.client.gui.driver.*; import com.goldencode.p2j.ui.client.gui.GuiFontResolver.FontCache; +import com.goldencode.p2j.ui.client.model.*; import com.goldencode.p2j.ui.client.widget.*; import com.goldencode.p2j.ui.client.ScrollBar.Bars; import com.goldencode.p2j.util.*; @@ -1146,6 +1149,20 @@ } /** + * Creates the scrollable list for this combobox based on the provided list model. + * + * @param model + * The scrollable list model. + * + * @return The scrollable list. + */ + @Override + public ScrollableList> create(ListModel model) + { + return new ScrollableSelectionListGuiImpl(this, model); + } + + /** * Determine the mouse actions processed by this widget. * * @return See above. @@ -1285,7 +1302,9 @@ private void createSimpleList() { // create the drop-down box - simpleList = screen().getFactory().createScrollableList(this, this.model()); + // The direct cast is save due to the create factory method returns instances of this type + simpleList = (ScrollableSelectionListGuiImpl) screen().getFactory().createScrollableList( + this, this.model()); // register it as a new frame simpleListPane = screen().getFactory().createScrollPane(simpleList); @@ -1503,14 +1522,14 @@ { gd.setColor(gc.fgColor); } - gd.drawString(display, xt, yt); + gd.drawString(display, xt, yt, w, h, orig.x, orig.y); } else { gd.setColor(lightShadow); - gd.drawString(display, xt + 1, yt + 1); + gd.drawString(display, xt + 1, yt + 1, w, h, orig.x, orig.y); gd.setColor(darkShadow); - gd.drawString(display, xt, yt); + gd.drawString(display, xt, yt, w, h, orig.x, orig.y); } // draw dotted rectangle around focused item text === modified file 'src/com/goldencode/p2j/ui/client/gui/GuiFontResolver.java' --- src/com/goldencode/p2j/ui/client/gui/GuiFontResolver.java 2015-05-18 20:48:28 +0000 +++ src/com/goldencode/p2j/ui/client/gui/GuiFontResolver.java 2016-06-02 16:57:20 +0000 @@ -18,6 +18,7 @@ ** 005 CA 20150507 No need to re-scale the font, it gets scaled when it gets created - so all ** fonts are assumed to match the legacy metrics. ** 006 GES 20150425 Eliminated AWT dependencies. +** 007 SBI 20160502 Extended parameter type to create GuiFontResolver for top level windows. */ package com.goldencode.p2j.ui.client.gui; @@ -41,7 +42,7 @@ private Map fontCache = new HashMap<>(); /** Window instance. */ - private Window window; + private TopLevelWindow window; /** Screen driver. */ private GuiDriver gd; @@ -68,7 +69,7 @@ * @param config * Widget configuration. */ - public GuiFontResolver(Window window, GuiDriver gd, BaseConfig config) + public GuiFontResolver(TopLevelWindow window, GuiDriver gd, BaseConfig config) { this(window, gd, config, false); } @@ -86,7 +87,7 @@ * Flag identifying that the referenced font must default to the default fixed font, * if is not specified. */ - public GuiFontResolver(Window window, GuiDriver gd, BaseConfig config, boolean fixedFont) + public GuiFontResolver(TopLevelWindow window, GuiDriver gd, BaseConfig config, boolean fixedFont) { this.window = window; this.gd = gd; === modified file 'src/com/goldencode/p2j/ui/client/gui/GuiWidgetFactory.java' --- src/com/goldencode/p2j/ui/client/gui/GuiWidgetFactory.java 2016-03-15 22:50:52 +0000 +++ src/com/goldencode/p2j/ui/client/gui/GuiWidgetFactory.java 2016-06-02 17:08:22 +0000 @@ -44,6 +44,7 @@ ** 024 EVL 20160127 Adding support for slider widget creation. ** 025 IAS 20160217 Added new flavor for the createScrollPane method. ** 026 IAS 20160315 Support for the DEBUG-ALERT attribute +** 027 SBI 20160512 Changed the scrollable list type. */ package com.goldencode.p2j.ui.client.gui; @@ -212,10 +213,12 @@ * @return instance of UI-specific implementation of {@link ScrollableList}. */ @Override - public ScrollableSelectionListGuiImpl createScrollableList(ComboBox parent, - ListModel model) + public ScrollableList> createScrollableList( + ComboBox parent, + ListModel model) { - return new ScrollableSelectionListGuiImpl(parent, model); + return parent.create(model); } /** === modified file 'src/com/goldencode/p2j/ui/client/gui/ScrollableSelectionListGuiImpl.java' --- src/com/goldencode/p2j/ui/client/gui/ScrollableSelectionListGuiImpl.java 2016-05-11 12:40:05 +0000 +++ src/com/goldencode/p2j/ui/client/gui/ScrollableSelectionListGuiImpl.java 2016-06-02 17:08:22 +0000 @@ -47,6 +47,9 @@ ** 017 HC 20160413 Fixed COMBO-BOX focus management, this also resolves ENTER not confirming ** selected item in the drop-down. ** 018 HC 20160511 Fixed COMBO-BOX focusing issues and related changes. +** 019 SBI 20160502 Fixed the web combobox entry and drop down list items to be aligned within +** their boxes, fixed GuiFontResolver to have a correct top level window, changed +** to provide the generic combobox parameter. */ package com.goldencode.p2j.ui.client.gui; @@ -60,7 +63,6 @@ import com.goldencode.p2j.ui.chui.ThinClient; import com.goldencode.p2j.ui.client.*; import com.goldencode.p2j.ui.client.event.*; -import com.goldencode.p2j.ui.client.event.listener.*; import com.goldencode.p2j.ui.client.gui.GuiFontResolver.FontCache; import com.goldencode.p2j.ui.client.gui.driver.*; import com.goldencode.p2j.ui.client.model.*; @@ -72,7 +74,7 @@ */ @SuppressWarnings("unchecked") public class ScrollableSelectionListGuiImpl -extends ScrollableList +extends ScrollableList { /** Screen driver */ private GuiDriver gd; @@ -118,14 +120,12 @@ * @param model * The data model that represents the contents of the list. */ - ScrollableSelectionListGuiImpl(ComboBox box, ListModel model) + ScrollableSelectionListGuiImpl(ComboBoxGuiImpl box, ListModel model) { super(box, model); // initialize screen driver gd = (GuiDriver) OutputManager.getDriver(); - // and font resolver - gf = new GuiFontResolver(WindowManager.resolveWindow(this), gd, box.config(), false); // color initializing selectionBack = gd.getSysColor(SysColor.COLOR_HIGHLIGHT); selectionFore = gd.getSysColor(SysColor.COLOR_HIGHLIGHTTEXT); @@ -156,20 +156,26 @@ // get actual rows to view final int rowsVisible = visibleRows(); - + + if (gf == null) + { + // and font resolver + gf = new GuiFontResolver(topLevelWindow(), gd, box.config(), false); + } + // resolve font final FontCache fntCache = gf.font(); // get location and size NativePoint p = physicalLocation(); final NativeDimension d = physicalDimension(); - final int rowHeight = ((ComboBoxGuiImpl)box).getRowHeight(); + final int rowHeight = getBox().getRowHeight(); // TODO: remove this line and rely on the set size, modifying // the size here is very confusing and may lead // to unexpected results d.height = box.config().mode == ComboBoxConfig.Mode.SIMPLE - ? ((ComboBoxGuiImpl)box).getSimpleListVisibleHeight() + ? getBox().getSimpleListVisibleHeight() : rowsVisible * rowHeight; // set up clipping rectangle @@ -250,7 +256,7 @@ return; } - int rowHeight = ((ComboBoxGuiImpl)box).getRowHeight(); + int rowHeight = getBox().getRowHeight(); if (model().size() > 0) { @@ -286,7 +292,7 @@ return; } - int rowHeight = ((ComboBoxGuiImpl)box).getRowHeight(); + int rowHeight = getBox().getRowHeight(); synchronized (this) { @@ -331,7 +337,7 @@ @Override public void processKeyEvent(KeyInput kvt) { - ComboBoxGuiImpl cbbRef = (ComboBoxGuiImpl) getBox(); + ComboBoxGuiImpl cbbRef = getBox(); int key = kvt.actionCode(); // disable ENTER key itself as event generator to avoid value change duplication @@ -618,10 +624,12 @@ } // draw item text - gd.drawString(getItemText(number), + gd.drawString(getItemText(number), box != null && box.config().mode == ComboBoxConfig.Mode.SIMPLE ? x + ComboBoxGuiImpl.ENTRY_SHIFT : x + ComboBoxGuiImpl.TEXT_SHIFT, - y + 1 + (rh + fontSize)/2); + y + 1 + (rh + fontSize)/2, + rw - getBox().getDropDownScrollBarWidth() - ComboBoxGuiImpl.ENTRY_SHIFT, + rh, x, y); // draw the dotted line for selected item (not for SIMPLE mode of the combo-box) if (enabled && number == currentRow() && @@ -630,7 +638,7 @@ gd.setLineStroke(LineStroke.DOTTED_SMALL); gd.setColor(selectionDots); // take into account possible vertical scrollbar width - gd.drawRect(x, y, rw - 1 - ((ComboBoxGuiImpl)box).getDropDownScrollBarWidth(), rh - 1); + gd.drawRect(x, y, rw - 1 - getBox().getDropDownScrollBarWidth(), rh - 1); // restore default line style gd.setLineStroke(LineStroke.DEFAULT); } === modified file 'src/com/goldencode/p2j/ui/client/gui/driver/AbstractGuiDriver.java' --- src/com/goldencode/p2j/ui/client/gui/driver/AbstractGuiDriver.java 2016-05-11 12:40:05 +0000 +++ src/com/goldencode/p2j/ui/client/gui/driver/AbstractGuiDriver.java 2016-06-02 17:08:22 +0000 @@ -53,6 +53,8 @@ ** 018 HC 20160407 Overhaul of window-activation logic. Removed setOverlayWindowLocation(), the ** method was unnecessary and was causing the COMBO-BOX drop-down location ** incorrect. +** 019 SBI 20160502 Fixed the web combobox entry and drop down list items to be aligned within +** their boxes. */ package com.goldencode.p2j.ui.client.gui.driver; @@ -703,6 +705,45 @@ } /** + * Draw a string using the provided text box and text offset position. + * + * @param text + * text string to draw. + * @param x + * The left text position. + * @param y + * The top text position. + * @param boxWidth + * The text box width, which needs to be matched when drawing. + * @param boxHeight + * The text box height, which needs to be matched when drawing. + * @param xBoxCoord + * The horizontal box position. + * @param yBoxCoord + * The vertical box position. + */ + @Override + public void drawString(String text, int x, int y, int boxWidth, int boxHeight, + int xBoxCoord, int yBoxCoord) + { + if (isEmptyText(text)) + { + return; + } + + PaintStructure ps = new PaintStructure(PaintPrimitives.DRAW_STRING); + ps.text = text; + ps.x = x; + ps.y = y; + ps.width = boxWidth; + ps.height = boxHeight; + ps.xOffset = xBoxCoord; + ps.yOffset = yBoxCoord; + + ews.offer(ps); + } + + /** * The method performs a layout operation on the supplied text and * returns the resulting paragraph height while maintaining the * supplied maximum width. === modified file 'src/com/goldencode/p2j/ui/client/gui/driver/GuiDriver.java' --- src/com/goldencode/p2j/ui/client/gui/driver/GuiDriver.java 2016-04-21 08:31:31 +0000 +++ src/com/goldencode/p2j/ui/client/gui/driver/GuiDriver.java 2016-06-02 17:08:22 +0000 @@ -76,6 +76,8 @@ ** setDesktopBgColor(ColorRgb color). ** 042 HC 20160407 Removed setOverlayWindowLocation(), the method was unnecessary and was ** causing the COMBO-BOX drop-down location incorrect. +** 043 SBI 20160502 Fixed the web combobox entry and drop down list items to be aligned within +** their boxes. */ package com.goldencode.p2j.ui.client.gui.driver; @@ -176,6 +178,27 @@ public void drawStringCentered(String text, int legacyWidth, int legacyHeight, int x, int height); /** + * Draw a string using the provided text box and text offset position. + * + * @param text + * text string to draw. + * @param x + * The left text position. + * @param y + * The top text position. + * @param boxWidth + * The text box width, which needs to be matched when drawing. + * @param boxHeight + * The text box height, which needs to be matched when drawing. + * @param xBoxCoord + * The horizontal box position. + * @param yBoxCoord + * The vertical box position. + */ + public void drawString(String text, int x, int y, int boxWidth, int boxHeight, + int xBoxCoord, int yBoxCoord); + + /** * The method performs a layout operation on the supplied text and * returns the resulting paragraph height while maintaining the * supplied maximum width. === modified file 'src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebEmulatedWindow.java' --- src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebEmulatedWindow.java 2016-03-25 01:36:48 +0000 +++ src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebEmulatedWindow.java 2016-06-02 16:57:20 +0000 @@ -34,6 +34,8 @@ ** 012 CA 20160323 In getTextHeight(), return the font's height, as p2j.fonts.js computes the ** text's height in the same way. ** SBI 20160324 Implemented SET_DESKTOP_BGCOLOR. +** 013 SBI 20160502 Fixed the web combo box entry and drop down list items to be aligned within +** their boxes. */ package com.goldencode.p2j.ui.client.gui.driver.web; @@ -323,7 +325,8 @@ switch (ps.id) { case DRAW_STRING: - websock.drawString(ps.text, ps.centered, ps.x, ps.y); + websock.drawString(ps.text, ps.centered, ps.x, ps.y, ps.width, ps.height, + ps.xOffset, ps.yOffset); break; case DRAW_STRING_SCALED: websock.drawStringScaled(ps.text, ps.centered, ps.x, ps.y, ps.width, ps.height); === modified file 'src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebSocket.java' --- src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebSocket.java 2016-04-29 11:29:39 +0000 +++ src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebSocket.java 2016-06-02 17:08:22 +0000 @@ -52,6 +52,8 @@ ** SBI 20160422 The resize drawing operations must not be cached. ** 015 CA 20160429 Fix for H014/CA: do not consume QUIT, STOP or ERROR conditions, as the ** business logic might rely on them, if explicitly raised. +** 016 SBI 20160502 Fixed the web combobox entry and drop down list items to be aligned within +** their boxes. */ package com.goldencode.p2j.ui.client.gui.driver.web; @@ -2525,7 +2527,33 @@ */ public void drawString(String text, boolean centered, int x, int y) { - int length = 1 + 4 + text.length() * 2 + 4 + 4 + 4; + drawString(text, centered, x, y, 0, 0, 0, 0); + } + + /** + * Draw a string using the provided text box and text offset position. + * + * @param text + * text string to draw. + * @param centered + * Flag indicating if the text is centered vertically. + * @param x + * The left text position. + * @param y + * The top text position. + * @param boxWidth + * The text box width, which needs to be matched when drawing. + * @param boxHeight + * The text box height, which needs to be matched when drawing. + * @param xBoxCoord + * The horizontal box position. + * @param yBoxCoord + * The vertical box position. + */ + public void drawString(String text, boolean centered, int x, int y, int boxWidth, int boxHeight, + int xBoxCoord, int yBoxCoord) + { + int length = text.length() * 2 + 33; byte[] message = allocateDrawingOp(PaintPrimitives.DRAW_STRING, length); int offset = 1; @@ -2543,6 +2571,18 @@ writeMessageInt32(message, offset, y); offset += 4; + + writeMessageInt32(message, offset, boxWidth); + offset += 4; + + writeMessageInt32(message, offset, boxHeight); + offset += 4; + + writeMessageInt32(message, offset, xBoxCoord); + offset += 4; + + writeMessageInt32(message, offset, yBoxCoord); + offset += 4; } /** === modified file 'src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.canvas_renderer.js' --- src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.canvas_renderer.js 2016-04-15 07:35:01 +0000 +++ src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.canvas_renderer.js 2016-06-02 17:12:11 +0000 @@ -27,6 +27,8 @@ ** SBI 20160213 Reduced putImageData invocations for horizontal and vertical lines. ** SBI 20160322 Changed to work around if the window canvas has a zero width or height. ** 006 SBI 20160415 Replaced logFormatted(...) by log(...). +** 007 SBI 20160512 Fixed the web combobox entry and drop down list items to be aligned within +** their boxes, added drawTextWithinBox. */ "use strict"; @@ -1748,6 +1750,55 @@ } /** + * Draw a string within its box. + * + * @param {String} text + * The text to draw. + * @param {Number} x + * The left text position. + * @param {Number} y + * The top text position. + * @param {Number} boxWidth + * The text box width. + * @param {Number} boxHeight + * The text box height. + * @param {Number} xBoxCoord + * The horizontal box position. + * @param {Number} yBoxCoord + * The vertical box position. + */ +CanvasRenderer.prototype.drawTextWithinBox = function(text, x, y, boxWidth, boxHeight, + xBoxCoord, yBoxCoord) +{ + var currentFont = p2j.screen.getCurrentFont(); + if (currentFont) + { + var lwidth = boxWidth - x + xBoxCoord; + var textHeight = this.fontsManager.getTextHeight(currentFont, text); + var textWidth = this.fontsManager.getTextWidth(currentFont, text); + + var widthScale = lwidth / textWidth; + if (widthScale >= 1) + { + widthScale = 1; + } + // scale drawing context to computed width + // this scales the desired structure.x as well so it needs adjusting + this.ctx.save(); + + if (widthScale < 1) + { + this.ctx.scale(widthScale, 1); + } + + this.ctx.textBaseline = 'bottom'; + + this.ctx.fillText(text, x / widthScale, y); + this.ctx.restore(); + } +} + +/** * Draws a given text at the given (x,y) position fitted to the given text rectangle. * * @param {Number} currentFont === modified file 'src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.screen.js' --- src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.screen.js 2016-04-25 19:35:35 +0000 +++ src/com/goldencode/p2j/ui/client/gui/driver/web/res/p2j.screen.js 2016-06-02 17:16:30 +0000 @@ -47,6 +47,9 @@ ** 011 HC 20160406 Overhaul of window-activation logic. ** 012 SBI 20160414 Fixed doWindowActivationChange(...) and activateTopVisibleWindow(...). ** SBI 20160422 The resize drawing operations must not be cached. +** 013 SBI 20160506 Fixed to send the current window changes its minimized state. +** SBI 20160512 Fixed the web combobox entry and drop down list items to be aligned within +** their boxes, added drawTextWithinBox. */ "use strict"; @@ -1365,7 +1368,29 @@ y = p2j.socket.readInt32BinaryMessage(message, idx + offset); offset = offset + 4; - this.canvasRenderer.drawText(text, x, y, centered); + + var boxWidth = p2j.socket.readInt32BinaryMessage(message, idx + offset); + offset = offset + 4; + + var boxHeight = p2j.socket.readInt32BinaryMessage(message, idx + offset); + offset = offset + 4; + + var xBoxCoord = p2j.socket.readInt32BinaryMessage(message, idx + offset); + offset = offset + 4; + + var yBoxCoord = p2j.socket.readInt32BinaryMessage(message, idx + offset); + offset = offset + 4; + + if (boxWidth === 0 || boxHeight === 0) + { + this.canvasRenderer.drawText(text, x, y, centered); + } + else + { + this.canvasRenderer.drawTextWithinBox(text, x, y, boxWidth, boxHeight, + xBoxCoord, yBoxCoord); + } + extra = " text = " + text + "; x = " + x + "; y = " + y + "; centered = " + centered; break;