General XMetaL Discussion

XMetaL Community Forum General XMetaL Discussion replacing the diamond icon used for empty elements

  • Di

    replacing the diamond icon used for empty elements

    Participants 1
    Replies 2
    Last Activity 12 years, 9 months ago

    Hi
    I'm using Xmetal Developer 4.0. have an element in my xsd called video which is an empty element (it only has attributes). When it's inserted I'd like to display a custom icon rather than the default blue diamond that appears.

    Does anyone know how I could do that please?

    Reply

    Derek Read

    Reply to: replacing the diamond icon used for empty elements

    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;
    dtd.addAttribute("elementName","iconPathAttrName","",0,3,"C:\icons\icon.png");

    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 20100107 as “Publication Date: January 07, 2010” in TagsOn and Normal views. The script that drives this behaviour is in the journalist.mcr file.

    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 Authorempty.gif. In some versions of XMetaL Author you can simply replace this image with another GIF (requires a restart). There is also an INI setting called empty_element_image that lets you point XMetaL to an alternative image (requires a restart as with any INI changes). Example: empty_element_image=C:myimage.gif. The result in both cases should be the same if the feature is supported by your release, which is the case for XMetaL Author Enterprise 6.0.0.079, our currently shipping version.

    Reply

    Su-Laine Yeo

    Reply to: replacing the diamond icon used for empty elements

    The procedure for adding a video icon, while keeping the blue diamond visible, is a lot simpler. If you don't mind having the blue diamond still be visible you can do this:

    Say the icon file is called “video_16x16.gif”. Put the icon file in the same folder as your css file, and add the following text to your css file:

    [code]
    video:before
    {
    content:url(video_16x16.gif);
    }
    [/code]

    Doing the above will cause the video icon to appear immediately before the blue diamond in all

    Reply

  • You must be logged in to reply to this topic.

Lost Your Password?

Products
Downloads
Support