The <boxmodel>
mixin adds CSS2 box model support to <view>
<boxmodel>
implements a subset of the CSS2 box model spec
http://www.w3.org/TR/CSS2/box.html
Example 32. Simple view with boxmodel
<canvas
height
="200
" bgcolor
="antiquewhite
">
<stylesheet
>
#thebox {
padding: 1 3 5 7;
border-width: 2 4 6 8;
border-color: cornflowerblue;
margin: 3 7 11 15;
}
text { color: navy; }
.margin { background-color: aliceblue; }
.borderwidth { color: white; background-color: cornflowerblue; }
.padding { background-color: skyblue; }
.content { background-color: white; }
colortext { border-width: 1; }
colortext.margin, colortext.borderwidth { border-bottom-width: 0 }
</stylesheet
>
<class
name
="colorview
" extends
="view
">
<attribute
name
="bgcolor
" style
="background-color
" value
="transparent
"/>
<attribute
name
="fgcolor
" style
="color
" value
="black
"/>
</class
>
<class
name
="colortext
" extends
="text
" with
="boxmodel
" width
="100%
" multiline
="true
">
<attribute
name
="bgcolor
" style
="background-color
" value
="transparent
"/>
<attribute
name
="fgcolor
" style
="color
" value
="black
"/>
</class
>
<colorview
styleclass
="margin
" x
="5
" y
="5
">
<colorview
id
="thebox
" with
="boxmodel
" styleclass
="padding
" width
="250
">
<colorview
styleclass
="content
" layout
="axis: y; spacing:0
" width
="100%
">
<text
>Click me to demonstrate updating:
</text
>
<text
name
="op
"/>
<colortext
styleclass
="margin
">
<handler
name
="onmargin
" reference
="thebox
" method
="display
"/>
<handler
name
="oninit
" method
="display
"/>
<method
name
="display
" args
="ignore
">
this.format("margin: %s", thebox.presentAttribute('margin'));
</method
>
</colortext
>
<colortext
styleclass
="borderwidth
">
<handler
name
="onborderwidth
" reference
="thebox
" method
="display
"/>
<handler
name
="oninit
" method
="display
"/>
<method
name
="display
" args
="ignore
">
this.format("borderwidth: %s", thebox.presentAttribute('borderwidth'));
</method
>
</colortext
>
<colortext
styleclass
="padding
">
<handler
name
="onpadding
" reference
="thebox
" method
="display
"/>
<handler
name
="oninit
" method
="display
"/>
<method
name
="display
" args
="ignore
">
this.format("padding: %s", thebox.presentAttribute('padding'));
</method
>
</colortext
>
<attribute
name
="attribute
" type
="string
"/>
<attribute
name
="amount
" type
="number
"/>
<handler
name
="onclick
" method
="doit
"/>
<handler
name
="oninit
" method
="doit
"/>
<method
name
="doit
" args
="ignore
">
if (this.attribute) {
thebox.setAttribute(this.attribute, thebox[this.attribute] + amount);
}
var r = Math.floor(Math.random()*3);
var prefix = ['margin', 'border', 'padding'][r];
var suffix = ['','width',''][r];
this.attribute = prefix+['top','right','bottom','left'][Math.floor(Math.random()*4)]+suffix;
this.amount = Math.round(Math.random()*10);
op.format("%s += %w", attribute, amount);
</method
>
</colorview
>
</colorview
>
</colorview
>
</canvas
>
boxmodel
is a mixin intended for use with <view>
and its subclasses.
Name (CSS property) | Type (tag) | Type (js) | Default | Category |
---|---|---|---|---|
borderbottomwidth
|
number | Number | 0 | read/write |
border-bottom-width | The bottom border width of the view, in pixels | |||
bordercolor
|
color | Color | black | read/write |
border-color | The bordercolor of the view | |||
borderleftwidth
|
number | Number | 0 | read/write |
border-left-width | The left border width of the view, in pixels | |||
borderrightwidth
|
number | Number | 0 | read/write |
border-right-width | The right border width of the view, in pixels | |||
bordertopwidth
|
number | Number | 0 | read/write |
border-top-width | The top border width of the view, in pixels | |||
borderwidth
|
boxsidedimensions | Boxsidedimensions | 0 | read/write |
border-width | The border width of the view, in pixels | |||
margin
|
boxsidedimensions | Boxsidedimensions | 0 | read/write |
margin | The margin of the view, in pixels | |||
marginbottom
|
number | Number | 0 | read/write |
margin-bottom | The bottom margin of the view, in pixels | |||
marginleft
|
number | Number | 0 | read/write |
margin-left | The left margin of the view, in pixels | |||
marginright
|
number | Number | 0 | read/write |
margin-right | The right margin of the view, in pixels | |||
margintop
|
number | Number | 0 | read/write |
margin-top | The top margin of the view, in pixels | |||
padding
|
boxsidedimensions | Boxsidedimensions | 0 | read/write |
padding | The padding of the view, in pixels | |||
paddingbottom
|
number | Number | 0 | read/write |
padding-bottom | The bottom padding of the view, in pixels | |||
paddingleft
|
number | Number | 0 | read/write |
padding-left | The left padding of the view, in pixels | |||
paddingright
|
number | Number | 0 | read/write |
padding-right | The right padding of the view, in pixels | |||
paddingtop
|
number | Number | 0 | read/write |
padding-top | The top padding of the view, in pixels |
Copyright © 2002-2010 Laszlo Systems, Inc. All Rights Reserved. Unauthorized use, duplication or distribution is strictly prohibited. This is the proprietary information of Laszlo Systems, Inc. Use is subject to license terms.