hluo at chc.ca wrote:
> 
> If I type in "color" or "bkcolor" values for an element on XML Mind
> Editor, how do I make these newly typed values show the corresponding
> colors immediately on the XML Mind Editor?
> 
> e.g.:
> 
> MyElement{
> 
>   display: block;
>   bkcolor: "take user input dynamiclly"; /* Can I do something here ? */
>   color:  "take user input dynamiclly";   /* Can I do something here ? */
> }
> 
> Or do I need to write code through your Java API?
> 

Let's suppose your element MyElement has two attributes:
* bkcolor which specifies the background color,
* color which specifies the foreground color.

--> If colors are specified using standard CSS syntax. e.g. red, black,
white, #FF0000, #000000, #FFFFFF, rgb(255,0,0), rgb(0,0,0),
rgb(255,255,255), then there is no need to write Java code:

* Specify the CSS as follows:

MyElement {
    display: block;
    background-color: concatenate(attr(bkcolor));
    color: concatenate(attr(color));
}

See
http://www.xmlmind.com/xmleditor/_distrib/doc/csssupport/simple_dynamic.html

* And tell your users to specify colors using the Attributes tool.



--> If colors are *not* specified using standard CSS syntax, you need to
write a CSS style sheet extension in Java. Example:

@extension "com.chc.xxe.MyExtension";

MyElement {
    display: block;
    background-color: invoke(method_name, parameter, ...., parameter);
    color: invoke(method_name, parameter, ...., parameter);
}

See http://www.xmlmind.com/xmleditor/_distrib/doc/csssupport/extend_css.html

See also
http://www.xmlmind.com/xmleditor/_distrib/doc/dev/styleext.html#solution1
(Please download the developer's documentation from
http://www.xmlmind.com/xmleditor/download.shtml)

* And tell your users to specify colors using the Attributes tool.



--> If you want to user to specify colors using a dialog box, then
* This feature is orthogonal what has been said above.
* You need to write a command in Java (see
http://www.xmlmind.com/xmleditor/_distrib/doc/dev/command.html).
* You need to bind this command to a keystroke, menu item or toolbar
button. This is specified in an XXE configuration which applies to your
document type.

This command displays a dialog which lets the user specify colors using
the Swing color chooser for example. These colors are then assigned to
the corresponding attributes and the CSS style sheet does the rendering.
That is, always change the content and let the CSS style sheet do the
proper rendering.

Reply via email to