=== modified file 'rules/annotations/ocx_conversion.rules' --- rules/annotations/ocx_conversion.rules 2020-05-14 18:36:54 +0000 +++ rules/annotations/ocx_conversion.rules 2020-05-19 19:48:15 +0000 @@ -341,7 +341,7 @@ map6 = create("java.util.HashMap") map6.put("value" , "DateTimeValue") - map6.put("CheckBox" , "Checked") + map6.put("checkbox" , "Checked") map6.put("font" , "FontInfo") map6.put("format" , "FormatStyle") aliasMap.put("CALENDAR" , map6) @@ -352,6 +352,8 @@ mapRef.put("key", "NodeKey") mapRef.put("index", "TreeNodeIndex") mapRef.put("text", "NodeText") + mapRef.put("selectedimage", "ExpandNodeIcon") + mapRef.put("image", "NodeIcon") aliasMap.put("COM.GOLDENCODE.P2J.UI.TREENODEFACE", mapRef) @@ -405,8 +407,13 @@ + memberName != null + printfln("memberName = %s", memberName) + + memberName == null memberName = ref.text + printfln("memberName = ref.text = %s", ref.text) methodName = getMethodNoCase(javaClass, memberName) === modified file 'rules/convert/builtin_functions.rules' --- rules/convert/builtin_functions.rules 2020-05-03 20:30:03 +0000 +++ rules/convert/builtin_functions.rules 2020-05-20 06:59:23 +0000 @@ -621,6 +621,11 @@ methodType = java.static_method_call + ftype == prog.kw_load_pic + methodText = "com.goldencode.p2j.ui.ocx.ListImage.newInstance" + methodType = java.static_method_call + + ftype == prog.kw_dyn_enum methodText = "ObjectOps.newDynamicEnum" methodType = java.static_method_call === modified file 'rules/gaps/expressions.rules' --- rules/gaps/expressions.rules 2020-05-03 20:30:03 +0000 +++ rules/gaps/expressions.rules 2020-05-20 06:50:41 +0000 @@ -476,7 +476,7 @@ funcs.put(prog.kw_length , rw.cvt_lvl_full | rw.rt_lvl_full) funcs.put(prog.kw_lib , rw.cvt_lvl_none | rw.rt_lvl_none) funcs.put(prog.kw_line_cnt, rw.cvt_lvl_full | rw.rt_lvl_full) - funcs.put(prog.kw_load_pic, rw.cvt_lvl_none | rw.rt_lvl_none) + funcs.put(prog.kw_load_pic, rw.cvt_lvl_full | rw.rt_lvl_full) funcs.put(prog.kw_locked , rw.cvt_lvl_full | rw.rt_lvl_full) funcs.put(prog.kw_log , rw.cvt_lvl_full | rw.rt_lvl_full) funcs.put(prog.kw_logical , rw.cvt_lvl_full | rw.rt_lvl_full) === modified file 'src/com/goldencode/p2j/ui/ImageList.java' --- src/com/goldencode/p2j/ui/ImageList.java 2019-11-14 14:48:19 +0000 +++ src/com/goldencode/p2j/ui/ImageList.java 2020-05-20 08:14:37 +0000 @@ -63,12 +63,13 @@ package com.goldencode.p2j.ui; +import com.goldencode.p2j.ui.ocx.ListImages; import com.goldencode.p2j.util.*; /** * IMAGELIST resource interface. */ -public interface ImageList +public interface ImageList extends WrappedResource { /** * Adds an image to the list. @@ -172,8 +173,9 @@ * * @return ListImages COM interface. */ + @ResourceType(type = ListImages.class) @LegacyMethod(name = "IL-LIST-IMAGES") - public comhandle getListImages(); + public handle getListImages(); /** * Get a value which determine the color to be transparent in ImageList graphical operation. === modified file 'src/com/goldencode/p2j/ui/ImageListWidget.java' --- src/com/goldencode/p2j/ui/ImageListWidget.java 2019-12-09 12:20:19 +0000 +++ src/com/goldencode/p2j/ui/ImageListWidget.java 2020-05-19 08:36:26 +0000 @@ -80,7 +80,7 @@ private List imgIds = new ArrayList<>(); /** Handle to access internal ImageList COM Interfaces*/ - private comhandle listImages = ListImages.newInstance(this); + private handle listImages = ListImages.newInstance(this); /** * Default constructor. @@ -258,7 +258,7 @@ * {@inheritDoc} */ @Override - public comhandle getListImages() + public handle getListImages() { return listImages; } === modified file 'src/com/goldencode/p2j/ui/TreeFace.java' --- src/com/goldencode/p2j/ui/TreeFace.java 2020-03-17 02:40:10 +0000 +++ src/com/goldencode/p2j/ui/TreeFace.java 2020-05-19 17:31:29 +0000 @@ -1006,7 +1006,17 @@ */ @LegacyAttribute(name = "IMAGE-LIST", setter = true) void setImageList(handle imgList); - + + /** + * Assigns an imagelist resource to the tree. When an imagelist is assigned, all images set to the tree + * are taken from the imagelist. + * + * @param imgList + * The image list to assign. + */ + @LegacyAttribute(name = "IMAGE-LIST", setter = true) + void setImageList(ImageList imgList); + /** * Get the TreeView node under mouse cursor as a node handle. * If no node under cursor return unknown value. === modified file 'src/com/goldencode/p2j/ui/TreeNodeCollection.java' --- src/com/goldencode/p2j/ui/TreeNodeCollection.java 2020-05-02 18:57:16 +0000 +++ src/com/goldencode/p2j/ui/TreeNodeCollection.java 2020-05-19 08:55:43 +0000 @@ -204,6 +204,33 @@ handle add(NumberType anchorIndex, NumberType relationType, character key, character text); /** + * Adds a new tree node as a first, last, next, previous or child node relative to the anchor + * node given by its index. + * + * @param anchorIndex + * The anchor node index + * @param relationType + * The relation type: first(0), last(1), next(2), previous(3) and child(4) + * @param key + * The key of the new node + * @param text + * The label of the new node + * @param nodeIcon + * The node icon index within its tree images list + * @param expandNodeIcon + * The expand node icon index within its tree images list + * + * @return The handle to the new node. + */ + @ResourceType(type = TreeNodeFace.class) + handle add(NumberType anchorIndex, + NumberType relationType, + character key, + character text, + NumberType nodeIcon, + NumberType expandNodeIcon); + + /** * Adds a new tree node as a last node relative to the root tree node. This node has a default * " " value for NODE-VALUE (KEY) and TEXT attributes. * === modified file 'src/com/goldencode/p2j/ui/TreeNodeCollectionResource.java' --- src/com/goldencode/p2j/ui/TreeNodeCollectionResource.java 2020-05-02 18:57:16 +0000 +++ src/com/goldencode/p2j/ui/TreeNodeCollectionResource.java 2020-05-20 07:32:41 +0000 @@ -515,6 +515,47 @@ } /** + * Adds a new tree node as a first, last, next, previous or child node relative to the anchor + * node given by its index. + * + * @param anchorIndex + * The anchor node index + * @param relationType + * The relation type: first(0), last(1), next(2), previous(3) and child(4) + * @param key + * The key of the new node + * @param text + * The label of the new node + * @param nodeIcon + * The node icon index within its tree images list + * @param expandNodeIcon + * The expand node icon index within its tree images list + * + * @return The handle to the new node. + */ + @Override + public handle add(NumberType anchorIndex, + NumberType relationType, + character key, + character text, + NumberType nodeIcon, + NumberType expandNodeIcon) + { + handle hNode = add(anchorIndex, relationType, key, text); + + if (hNode._isValid()) + { + TreeNodeFace node = hNode.unwrapTreeNodeFace(); + + node.setNodeIcon(nodeIcon); + + node.setExpandNodeIcon(expandNodeIcon); + } + + return hNode; + } + + /** * Worker to be implemented by each resource. Called by {@link #delete()}. * * @return true if the resource was deleted. === modified file 'src/com/goldencode/p2j/ui/TreeWidgetBase.java' --- src/com/goldencode/p2j/ui/TreeWidgetBase.java 2020-05-14 18:36:54 +0000 +++ src/com/goldencode/p2j/ui/TreeWidgetBase.java 2020-05-20 08:16:36 +0000 @@ -1753,6 +1753,31 @@ } /** + * Assigns an imagelist resource to the tree. When an imagelist is assigned, all images set to the tree + * are taken from the imagelist. + * + * @param imgList + * The image list to assign. + */ + @Override + public void setImageList(ImageList imgList) + { + if (imgList != null && imgList.id() != null) + { + imageList = new handle(imgList); + + config.imageListId = imgList.id().intValue(); + } + else + { + imageList = null; + config.imageListId = -1; + } + + pushWidgetAttr("imageListId", config.imageListId); + } + + /** * Delete the resource. * * @return true if the resource was deleted. === modified file 'src/com/goldencode/p2j/ui/ocx/ComInterface.java' --- src/com/goldencode/p2j/ui/ocx/ComInterface.java 2019-11-06 16:02:21 +0000 +++ src/com/goldencode/p2j/ui/ocx/ComInterface.java 2020-05-20 05:29:40 +0000 @@ -112,7 +112,12 @@ @Override public boolean valid() { - return parent.valid(); + if (parent != null) + { + return parent.valid(); + } + + return false; } /** @@ -130,6 +135,11 @@ @Override public String getName() { - return parent.name().toStringMessage(); + if (parent != null) + { + return parent.name().toStringMessage(); + } + + return "?"; } } === modified file 'src/com/goldencode/p2j/ui/ocx/ListImage.java' --- src/com/goldencode/p2j/ui/ocx/ListImage.java 2019-11-07 15:56:38 +0000 +++ src/com/goldencode/p2j/ui/ocx/ListImage.java 2020-05-20 07:08:24 +0000 @@ -63,6 +63,8 @@ package com.goldencode.p2j.ui.ocx; +import java.util.function.Function; + import com.goldencode.p2j.comauto.*; import com.goldencode.p2j.ui.*; import com.goldencode.p2j.util.*; @@ -78,6 +80,12 @@ extends ComInterface implements IImage { + /** The unique image id */ + private integer index; + + /** The system file path to the binary image */ + private character key; + /** * Constructor. * @@ -88,6 +96,19 @@ { super(IImage.class.getName(), parent); } + + /** + * Create a detached instance of an image that can be attached to a widget later. + * + * @param pathToImage + * The file system path to the image file. + */ + private ListImage(character pathToImage) + { + super(IImage.class.getName(), null); + + key = pathToImage; + } /** * Factory method. @@ -103,6 +124,33 @@ } /** + * Creates a detached instance of an image + * + * @param pathToImage + * The file system path to the image file. + * + * @return a new instance wrapped in a comhandle. + */ + public static comhandle newInstance(String pathToImage) + { + return newInstance(new character(pathToImage)); + } + + /** + * Creates a detached instance of an image + * + * @param pathToImage + * The file system path to the image file. + * + * @return a new instance wrapped in a comhandle. + */ + public static comhandle newInstance(character pathToImage) + { + return new comhandle(new ListImage(pathToImage)); + } + + //public static comhandle newInstance + /** * {@inheritDoc} */ @ComMethod(name = "DRAW") @@ -135,7 +183,7 @@ @ComProperty(name = "INDEX") public void setIndex(integer index) { - // nop + this.index = index; } /** @@ -144,7 +192,7 @@ @ComProperty(name = "INDEX") public void setIndex(int index) { - // nop + this.index = new integer(index); } /** @@ -153,7 +201,12 @@ @ComProperty(name = "KEY") public character getKey() { - return new character(); + if (key == null) + { + return new character(); + } + + return key; } /** @@ -162,7 +215,7 @@ @ComProperty(name = "KEY") public void setKey(character key) { - // nop + this.key = key; } /** @@ -171,7 +224,7 @@ @ComProperty(name = "KEY") public void setKey(String key) { - // nop + this.key = new character(key); } /** @@ -209,4 +262,15 @@ { // nop } + + /** + * Attach this iamge to the parent widget. + * + * @param parent + * The parent widget + */ + public void setParent(GenericWidget parent) + { + this.parent = parent; + } } === modified file 'src/com/goldencode/p2j/ui/ocx/ListImages.java' --- src/com/goldencode/p2j/ui/ocx/ListImages.java 2019-11-07 15:56:38 +0000 +++ src/com/goldencode/p2j/ui/ocx/ListImages.java 2020-05-20 08:21:35 +0000 @@ -97,9 +97,9 @@ * * @return a new instance wrapped in a comhandle. */ - public static comhandle newInstance(GenericWidget parent) + public static handle newInstance(GenericWidget parent) { - return new comhandle(new ListImages(parent)); + return new handle(new ListImages(parent)); } /** @@ -108,8 +108,35 @@ @ComMethod(name = "ADD") public comhandle add(integer index, character key, comhandle picture) { + character pathToImage; + + IImage unwrappedImage; + + if (picture != null && picture.getResource() instanceof IImage) + { + unwrappedImage = (IImage) picture.getResource(); + pathToImage = unwrappedImage.getKey(); + } + else + { + unwrappedImage = null; + pathToImage = key; + } + ImageListWidget w = (ImageListWidget) parent; - w.addImage(key); + + integer imageId = w.addImage(pathToImage); + + if (unwrappedImage != null) + { + unwrappedImage.setIndex(imageId); + + if (unwrappedImage instanceof ListImage) + { + ((ListImage) unwrappedImage).setParent(parent); + } + } + return picture; } @@ -173,7 +200,9 @@ @ComProperty(name = "COUNT") public integer getCount() { - return new integer(0); + ImageListWidget w = (ImageListWidget) parent; + + return new integer(w.getImageIds().length); } /** @@ -211,4 +240,6 @@ { // nop } + + } === modified file 'src/com/goldencode/p2j/util/handle.java' --- src/com/goldencode/p2j/util/handle.java 2020-04-27 16:17:03 +0000 +++ src/com/goldencode/p2j/util/handle.java 2020-05-15 13:16:49 +0000 @@ -292,6 +292,7 @@ import com.goldencode.p2j.ui.*; /** Calendar must be imported explicitly */ import com.goldencode.p2j.ui.Calendar; +import com.goldencode.p2j.ui.ocx.ListImages; import com.goldencode.p2j.xml.*; import com.goldencode.proxy.*; @@ -1948,6 +1949,11 @@ return unwrapImpl(this, CommonLastEvent.class); } + public ListImages unwrapListImages() + { + return unwrapImpl(this, ListImages.class); + } + /** * Unwrap this handle to a {@link LegacyLogManager} instance. If the * handle is not the LOG-MANAGER or DSLOG-MANAGER handle or is invalid, an