richtexttoolbar-class.lzx
<library>
<class name="richtexttoolbar" width="${parent.width}" onmouseover="this.onmouseover" y="4">
<attribute name="editor" value="${null}"/>
<attribute name="_fontmap" value="$once{ { 'Times New Roman' : 'Times', 'Courier New' : 'Courier' } }"/>
<attribute name="_passthruchanges" value="true
"/>
<attribute name="_atools" value="$once{new Array()}"/>
<attribute name="_debugformat" value="true
"/>
<simplelayout axis="x" spacing="5"/>
<view name="padding" width="2"/>
<method name="init">
super.init();
// Make the gui components match the editor's currentformat
// TODO: set up keyboard commands
</method>
<method name="construct" args="parent, args">
super.construct(parent,args);
</method>
<handler name="oneditor">
if(this['editor']){
this.oncurrentformat.reference = this.editor;
}
</handler>
<handler name="oncurrentformat" args="fmt">
this._passthruchanges = false;
this.matchformat(fmt);
this._passthruchanges = true;
</handler>
<method name="matchformat" args="spec">
var cfmt = spec;
var font;
if (cfmt.font != null) {
font = this._fontmap[cfmt.font];
if (font == null) font = cfmt.font;
}
// assign the mapped value back to the object so the loop below has the correct data
if (font) {
cfmt.font = font ;
} else {
cfmt.font = "- -";
}
// 'broadcast' out the setState call with the format value to the registered tools
for (var i=0;i < _atools.length;i++){
_atools[i].ref.setState(cfmt[_atools[i].fmt]);
}
</method>
<method name="matcheditorformat" args="ignore=null">
this._passthruchanges = false;
var cfmt = this.editor.currentformat;
this.matchformat(cfmt);
this._passthruchanges = true;
</method>
<method name="reset">
// 'broadcast' out the reset method call to all registered tools
for(var obj in _atools){
_atools[obj].ref.reset();
}
</method>
<method name="registerTool" args="myref,myfmt">
_atools.push({ref:myref,fmt:myfmt});
</method>
</class>
</library>