Home › Forums › General XMetaL Discussion › replacing the diamond icon used for empty elements › Reply To: replacing the diamond icon used for empty elements
Reply to: replacing the diamond icon used for empty elementsJanuary 7, 2010 at 10:43 pm
There are a few of options I can think of:
1. Display the element as an XFT form, then place your special “icon” image inside the form using the “Bitmap” control (if that's what you want). The form is created with the XMetaL Forms Toolkit (xflayout.exe) and telling XMetaL which form to use is done in settings in the CTM file.
2. Create an ActiveX control (3rd party software such as Visual Basic required). This control will do nothing but display your icon. Then configure the CTM file to tell XMetaL to render the element as an “OCX Replacement” using XMetaL Developer. Note that this is likely overkill unless you are handy with making ActiveX controls (such a control would be trivial for someone with that skill, but learning to create ActiveX controls with any particular tool can be daunting for people without this knowledge).
3. Represent the element as an image (also done in the CTM file settings). However, in order for your image to be rendered in this case you need to tell XMetaL which attribute on the element points to a physical (real) image file on disk. If your element has no such attribute (I assume so) and because you probably want to render the same icon for all such elements you could add a temporary attribute to the DTD at load. If you make this attribute #FIXED and set the value to point to your icon file, users will not be able to modify it in the Attribute Inspector but you will be able to configure the CTM to use that attribute and the value will be picked up and the graphic rendered for the element. Note that because the CTM file reads your actual DTD it will not know you are adding this attribute via script and as such you cannot use the CTM editor. Instead, configure the setting for another attribute that does exist on the element (this is done in “Treat As > Image” in XMetaL Developer's CTM editor) then modify the CTM source code to change the name to the one you create using script.
In the event On_DTD_Open_Complete include something like this:
// XMetaL Script Language JSCRIPT:
var dtd = ActiveDocument.doctype;
Note: If you will consistently have more than a few of these elements in a particular document then method 2 or 3 would be preferred over 1 because having a large number of XFT forms visible in your document (“embedded” vs “modal”) is memory intensive as each one loads its own Windows scripting engine instance whether it needs scripting or not (not needing one would be very unusual as with this usage for XFT which is normally used for gathering info from users).
4. There is a scripting method that lets you alter the content for a given node, but you cannot use this to display images, just textual content. The method that allows you to do this is called ActiveDocument.SetRenderedContent() and there is a demonstration of its usage in the Journalist demo customization included with XMetaL Author. The demo renders the content for
5. The image file that is used for the blue diamond icon is located here (in a default install on Windows XP) C:Program FilesXMetaL