DynamicApplicationSizer.lzx
<library>
<class name="DynamicApplicationSizer" extends="view" defaultplacement="content">
<attribute name="maxWidth" type="number" value="900
"/>
<attribute name="minWidth" type="number" value="800
"/>
<attribute name="maxHeight" type="number" value="726
"/>
<attribute name="minHeight" type="number" value="620
"/>
<handler name="onheight" reference="canvas">
var newHeight = canvas.height - 77;
if (newHeight <= this.maxHeight && newHeight >= minHeight) {
this.setAttribute('height', newHeight);
} else if (newHeight > this.maxHeight) {
this.setAttribute('height', this.maxHeight);
} else {
this.setAttribute('height', this.minHeight);
}
</handler>
<handler name="onwidth" reference="canvas">
var newWidth = canvas.width - 200;
if (newWidth <= this.maxWidth && newWidth >= minWidth) {
this.setAttribute('width', newWidth);
} else if (newWidth > this.maxWidth) {
this.setAttribute('width', this.maxWidth);
} else {
this.setAttribute('width', this.minWidth);
}
</handler>
<method name="init">
super.init();
// Trigger an event for canvas resize to adjust size at startup
canvas.onwidth.sendEvent();
canvas.onheight.sendEvent();
</method>
<view name="content" width="${classroot.width}" height="${classroot.height}" clip="true" bgcolor="${COLORS.APPLICATION_BG}"/>
</class>
</library>