Check Box Component - Maple Help

DocumentTools[Components]

 CheckBox
 generate XML for a CheckBox Component

 Calling Sequence CheckBox(caption, opts)

Parameters

 caption - (optional) string:="CheckBox"; the caption on the check box opts - (optional) ; one or more keyword options as described below

Options

 • action : string:=""; A string which parses to one or more valid statements in 1-D Maple notation. These statements form the Value Changed Action Component Code that executes when the CheckBox value is manually adjusted. The default is the empty string (no action code).
 • enabled : truefalse; Indicates whether the component is enabled. The default is true. If enabled is false then the inserted component is grayed out and interaction with it cannot be initiated.
 • fillcolor : {list(nonnegint),symbol,string}:=[255,255,255] ; Specifies the background color of the component. The passed value can be either a named color or a list of three integers each between 0 and 255. A list of nonnegative integers is interpreted as RGB values in a 24bit 3-channel color space. The default value is [255,255,255] which corresponds to white.
 • fontcolor : {list(nonnegint),symbol,string}:=[0,0,0] ; Specifies the font color of the component. The passed value can be either a named color or a list of three integers each between 0 and 255. A list of nonnegative integers is interpreted as RGB values in a 24bit 3-channel color space. The default value is [0,0,0] which corresponds to black.
 • group : string:=""; The name of the group with which this component is associated. The default is the empty string (no group).
 • height : posint; The height in pixels, if custom selectedimage and unselectedimage options are specified.
 • identity : {name,string}; The reference name of the component.
 • selectedimage : {string,Matrix,Array}; A custom image that appears on the component when selected, specified as either the name of an external image file or a Matrix or Array as recognized by commands in the ImageTools package.
 • selected : truefalse; Indicates whether the component is initially selected (checked). The default is false (unchecked).
 • tooltip : string; The text that appears when the mouse pointer hovers over the component. The default is the empty string (no tooltip).
 • unselectedimage : {string,Matrix,Array}; A custom image to be displayed on the component when unselected, specified as either the name of an external image file or a Matrix or Array as recognized by commands in the ImageTools package.
 • visible : truefalse; Indicates whether the component is visible. The default is true.
 • width : posint; The width in pixels, if custom selectedimage and unselectedimage options are specified.

Description

 • The CheckBox command in the Component Constructors package returns an XML function call which represents a CheckBox Component.
 • The generated XML can be used with the results of commands in the Layout Constructors package to create an entire Worksheet or Document in XML form. Such a representation of a Worksheet or Document can be inserted into the current document using the InsertContent command.

Examples

 > $\mathrm{with}\left(\mathrm{DocumentTools}\right):$
 > $\mathrm{with}\left(\mathrm{DocumentTools}:-\mathrm{Components}\right):$
 > $\mathrm{with}\left(\mathrm{DocumentTools}:-\mathrm{Layout}\right):$

Executing the CheckBox command produces a function call.

 > $S≔\mathrm{CheckBox}\left(\mathrm{identity}="CheckBox0"\right)$
 ${S}{≔}{\mathrm{_XML_EC-CheckBox}}{}\left({"id"}{=}{"CheckBox0"}{,}{"caption"}{=}{"CheckBox"}{,}{"groupname"}{=}{""}{,}{"enabled"}{=}{"true"}{,}{"fillcolor"}{=}{"\left[255,255,255\right]"}{,}{"fontcolor"}{=}{"\left[0,0,0\right]"}{,}{"visible"}{=}{"true"}{,}{"user-size"}{=}{"false"}\right)$ (1)

By using commands from the Layout Constructors package a nested function call can be produced which represents a worksheet.

 > $\mathrm{xml}≔\mathrm{Worksheet}\left(\mathrm{Group}\left(\mathrm{Input}\left(\mathrm{Textfield}\left(S\right)\right)\right)\right):$

That XML representation of a worksheet can be inserted directly.

 > $\mathrm{InsertContent}\left(\mathrm{xml}\right):$

 > $\mathrm{codestring}≔"\ns := true;\n\nt := false;"$
 ${\mathrm{codestring}}{≔}{"s := true; t := false;"}$ (2)
 > $S≔\mathrm{CheckBox}\left(\mathrm{identity}="CheckBox0",\mathrm{selected}=\mathrm{true},\mathrm{tooltip}="My example check box",\mathrm{action}=\mathrm{codestring}\right):$
 > $\mathrm{xml}≔\mathrm{Worksheet}\left(\mathrm{Group}\left(\mathrm{Input}\left(\mathrm{Textfield}\left(S\right)\right)\right)\right):$

The previous example's call to the InsertContent command inserted a component with identity "CheckBox0", which still exists in this worksheet. Inserting additional content whose input contains another component with that same identity "CheckBox0" incurs a substitution of the input identity in order to avoid a conflict with the identity of the existing component.

The return value of the following call to InsertContent is a table which can be used to reference the substituted identity of the inserted component.

 > $\mathrm{lookup}≔\mathrm{InsertContent}\left(\mathrm{xml},\mathrm{output}=\mathrm{table}\right)$
 ${\mathrm{lookup}}{≔}{table}{}\left(\left[{"CheckBox0"}{=}{"CheckBox1"}\right]\right)$ (3)

 > $\mathrm{lookup}\left["CheckBox0"\right]$
 ${"CheckBox1"}$ (4)
 > $\mathrm{GetProperty}\left(\mathrm{lookup}\left["CheckBox0"\right],\mathrm{value}\right)$
 ${"true"}$ (5)

In the next example a plain green square image of 15-by-15 pixels is used as a custom selectedimage, while a grayscale image of the same size is used as the unselectedimage. Additionally, the size of the component is set to 75 pixels wide and 15 high.

 > $S≔\mathrm{CheckBox}\left(\mathrm{identity}="CheckBox0",\mathrm{width}=75,\mathrm{height}=15,\mathrm{selectedimage}=\mathrm{Array}\left(1..15,1..15,1..3,\left(i,j,k\right)↦\mathrm{if}\left(k=2,0.6,0\right),\mathrm{datatype}=\mathrm{float}\left[8\right]\right),\mathrm{unselectedimage}=\mathrm{Array}\left(1..15,1..15,0.6,\mathrm{datatype}=\mathrm{float}\left[8\right]\right)\right):$
 > $\mathrm{InsertContent}\left(\mathrm{Worksheet}\left(\mathrm{Group}\left(\mathrm{Input}\left(\mathrm{Textfield}\left(S\right)\right)\right)\right)\right):$

The next example makes use of action code for a Check Box. When the Check Box is manually selected or unselected the action code is executed.

The action code updates a PlotComponent with identity "Plot0", which will be an additional part of the inserted content. This component will be constructed using the Plot Component constructor.

 > $p≔\mathrm{plot}\left(\mathrm{sin}\left(x\right),x=-\mathrm{\pi }..\mathrm{\pi }\right):$
 > $P≔\mathrm{Components}:-\mathrm{Plot}\left(p,\mathrm{identity}="Plot0"\right):$
 > $\mathrm{actioncode}≔"DocumentTools:-SetProperty\left(\text{'}:-Plot0\text{'},value,\n plots:-display\left(p,scaling=if\left(DocumentTools:-GetProperty\left(\"CB0\",value\right)=\"true\",constrained,unconstrained\right)\right)\right);":$
 > $S≔\mathrm{CheckBox}\left("constrained",\mathrm{identity}="CB0",\mathrm{action}=\mathrm{actioncode},\mathrm{fillcolor}="LightBlue",\mathrm{fontcolor}="Blue"\right):$\mathrm{xml}≔\mathrm{Worksheet}\left(\mathrm{Table}\left(\mathrm{interior}=\mathrm{none},\mathrm{alignment}=\mathrm{center},\mathrm{width}=500,\mathrm{widthmode}=\mathrm{pixels},\mathrm{Column}\left(\right),\mathrm{Row}\left(\mathrm{Cell}\left(\mathrm{Textfield}\left(P\right),\mathrm{fillcolor}="LightBlue"\right)\right),\mathrm{Row}\left(\mathrm{Cell}\left(\mathrm{Textfield}\left(S\right),\mathrm{fillcolor}="LightBlue"\right)\right)\right)\right):
 > $\mathrm{InsertContent}\left(\mathrm{xml}\right):$

 > 

Compatibility

 • The DocumentTools:-Components:-CheckBox command was introduced in Maple 2015.