boxview.lzx
<library>
<class name="boxview" extends="view">
<attribute name="marginsize" type="number" value="0
"/>
<attribute name="bordersize" type="number" value="1
"/>
<attribute name="paddingsize" type="number" value="0
"/>
<attribute name="bordercolor" type="string" value="0x000000
"/>
<attribute name="contentbgcolor" type="string" value="
"/>
<attribute name="title" type="string" value="
"/>
<attribute name="clip" value="false
"/>
<attribute name="_usecontentwidth" value="true
"/>
<attribute name="_usecontentheight" value="true
"/>
<attribute name="defaultplacement" value="vContent
" type="string"/>
<method name="construct" args="p,args">
super.construct(p, args);
// need to set these attributes before subviews are created
// otherwise they will calculate width/height incorrectly
setAttribute('_usecontentwidth', !hassetwidth);
setAttribute('_usecontentheight', !hassetheight);
</method>
<view name="vMargin" layout="axis: y" x="${classroot.marginsize}" y="${classroot.marginsize}">
<state applied="${!classroot._usecontentwidth}">
<attribute name="width" value="${classroot.width - classroot.marginsize*2}"/>
</state>
<state applied="${!classroot._usecontentheight}">
<attribute name="height" value="${classroot.height - classroot.marginsize*2 - vTitle.height}"/>
</state>
<state applied="${classroot._usecontentwidth}">
<attribute name="width" value="${vMiddle.vPadding.vContent.width + classroot.marginsize + classroot.bordersize*2 + classroot.paddingsize*2}"/>
</state>
<state applied="${classroot._usecontentheight}">
<attribute name="height" value="${vMiddle.vPadding.vContent.height + classroot.marginsize + classroot.bordersize*2 + classroot.paddingsize*2 + vTitle.height}"/>
</state>
<view x="5" name="vTitle" clip="true" height="${classroot.title=='' ? 0 : 10}">
<statictext y="-4" resize="true" fontsize="9" fontstyle="italic" text="${classroot.title}"/>
</view>
<view name="vBorderTop" height="${classroot.bordersize}" width="${parent.vMiddle.width}" bgcolor="${classroot.bordercolor}"/>
<view name="vMiddle" layout="axis: x">
<view name="vBorderLeft" width="${classroot.bordersize}" height="${parent.vPadding.height}" bgcolor="${classroot.bordercolor}"/>
<view name="vPadding" bgcolor="${classroot.contentbgcolor ? classroot.contentbgcolor : null}">
<state applied="${!classroot._usecontentwidth}">
<attribute name="width" value="${classroot.width - classroot.marginsize*2 - classroot.bordersize*2}"/>
</state>
<state applied="${!classroot._usecontentheight}">
<attribute name="height" value="${classroot.height - classroot.marginsize*2 - classroot.bordersize*2 - parent.parent.vTitle.height}"/>
</state>
<state applied="${classroot._usecontentwidth}">
<attribute name="width" value="${vContent.width + classroot.paddingsize*2}"/>
</state>
<state applied="${classroot._usecontentheight}">
<attribute name="height" value="${vContent.height + classroot.paddingsize*2}"/>
</state>
<view name="vContent" x="${classroot.paddingsize}" y="${classroot.paddingsize}" clip="true">
<state applied="${!classroot._usecontentwidth}">
<attribute name="width" value="${classroot.width - classroot.marginsize*2 - classroot.bordersize*2 - classroot.paddingsize*2}"/>
</state>
<state applied="${!classroot._usecontentheight}">
<attribute name="height" value="${classroot.height - classroot.marginsize*2 - classroot.bordersize*2 - classroot.paddingsize*2}"/>
</state>
</view>
</view>
<view name="vBorderRight" width="${classroot.bordersize}" height="${parent.vPadding.height}" bgcolor="${classroot.bordercolor}"/>
</view>
<view name="vBorderBottom" height="${classroot.bordersize}" width="${parent.vMiddle.width}" bgcolor="${classroot.bordercolor}"/>
</view>
</class>
</library>
Cross References
Classes
- <class name="boxview" extends="view">