You can allow the user to change dynamically the CSS stylesheet used to render the source code. This is done by enabling the generation of a "dynamic styling box" which is nothing more than a simple combobox containing a list of available stylesheets. When rendered with the default appearance, the box looks like this:
To enable the generation of this box, you must set the generateSkinBox property to true.
| HTMLConverter | boolean getGenerateSkinBox() void setGenerateSkinBox( boolean onoff) |
|
| Code2Web | code2web ... --generateSkinBox = true | false... | |
| <c2w:convert> | <c2w:convert ... GenerateSkinBox="true|false" ... > |
The style of the skin box is controlled by the skinBoxStyle property, which has a default value of "skin-box":
| HTMLConverter | String getSkinBoxStyle() void setSkinBoxStyle( String style ) |
|
| Code2Web | code2web ... --skinBoxStyle = xxxxx ... | |
| <c2w:convert> | <c2w:convert ... skinBoxStyle="style" ... > |
Also, the message that appears in the box can be modified by changing the skinBoxMessage property, which defaults to "Coloring style: "
| HTMLConverter | String getSkinBoxMessage() void setSkinBoxMessage( String message ) |
|
| Code2Web | code2web ... --skinBoxMessage = xxxxx ... | |
| <c2w:convert> | <c2w:convert ... skinBoxMessage="message" ... > |
Of course, the most important part of this feature is specifying the available stylesheets. If you are programming directly the HTMLConverter, just call the addSkin() method. Actually, you MUST call this method at least once in order to provide a default stylesheet, regardless of whether the user can later change it or not. The method takes to parameters : the title of that CSS (as it is presented to the user) and the location of the css file. For example:
conv.addSkin("Eclipse","styles/eclipse.css");
You may call this method as many times as needed in order to add more skins.
If you are using the code2web program or the JSP tag, you must set all the skins at once using the skins option, which takes a set of comma-separated pairs of values, the first one being the title and the second one - the location:
code2web ... --skins="Eclipse,styles/eclipse.css,Netbeans,styles/beans.css