Math Expression Component
insert a math expression region in a worksheet or document
Description
Component Palette Image
Mathematical Expression Properties
Making the Expression Read-only
Math Expression Component Example
The mathematical expression component displays 2-D math expressions passed from another embedded component. It also provides editing functionality for entering math expressions.
The math expression component returns the value of its contents as a string of MathML elements. To convert this into a Maple expression, use the MathML[ImportModified] command.
The mathematical expression component is customized by setting options in the Mathematical Expression context panel. To display the options in the context panel, select the embedded component. Actions are associated with components using routines in the DocumentTools package. For more information, see the Math Expression Component Example on this page.
The Name property is used to reference the math expression component when using the routines from the DocumentTools package.
The following table describes the control and use of the mathematical expression component options.
An x in the Get column indicates that the option can be read, that is, retrieved by using the DocumentTools[GetProperty] tool.
An x in the Set column indicates that the option can be written, that is, set by using the DocumentTools[SetProperty] tool.
Option
Get
Set
Option Type
autofit
x
true or false
editable
expression
fillcolor
color
minimumpixelheight
positive integer
minimumpixelwidth
pixelheight
pixelwidth
scrolldown
showborders
type
string
value
MathML
visible
Specifies whether to automatically resize the Math Expression component to fit its contents. By default, the value is false.
Specifies whether the mathematical expression component is editable. By default, the value is true.
The contents of the Math Expression component (MathContainer) as a Maple expression. The usual simplification rules are applied to the expression. For example, retrieving the expression from a MathContainer into which 3*4 has been entered will return 12. To obtain the contents exactly as they were entered, use InertForm[FromMathContainer] or the value property.
Specifies the background color of the component. The color can be given by RGB values (a list of three integers between 0 and 255) or a string representing a color name, for example, [255,0,0] or “Red”. The default value is [255,255,255] which corresponds to white.
The minimum height of the mathematical expression region in pixels. Used with autofit=true. By default, the value is 200.
The minimum width of the mathematical expression region in pixels. Used with autofit=true. By default, the value is 300.
The height of the mathematical expression region in pixels. By default, the value is 200.
The width of the mathematical expression region in pixels. By default, the value is 300.
Specifies whether to allow automatic scrolling to the bottom of the Math Expression window to make new results visible, when the window size is restricted and the scroll bar is visible.
Specifies if the border of the component is visible. By default, the value is true.
The type of the component. This returns "MathContainer".
The contents in the component in MathML. Note that since the content is in MathML, use of DocumentTools[Do] should either retrieve the value unparsed (i.e. %%ComponentName(value)) or use the expression property.
Specifies if the component is visible. By default, the value is true.
These properties can be accessed programmatically. You can access the contents of the MathContainer, for example, using expr:= DocumentTools:-GetProperty(ComponentName,expression); as demonstrated in the example.
The mathematical expression component can be made read-only (non-editable).
To make the mathematical expression component read-only:
Click the component.
In the Mathematical Expression context panel, clear the check box Editable.
The expression is no longer editable.
Note: To interact with the example provided below, open this help page as a worksheet, and then execute the worksheet.
This example uses a List Box component to display some expressions. Selecting an expression from the List Box displays the integrated expression in the Math Expression component.
To insert the label, list box, and mathematical expression components, and then configure the label component:
Insert a Label, ListBox and MathExpression component using the Components palette. For information on displaying the Maple palettes, see the Show Palettes help page.
Click the Label component to display the context panel.
In the Caption field, enter Select a function to integrate.
To add the expressions to the list box:
Click the List Box component to display the context panel.
Click the Edit button of the Item List field.
Double-click the first row and replace ListBox with sin(x)*2.
Click Add, double-click the new field, and then replace the default entry with exp(x)^2.
Repeat step 4 and add the following items to the list: cos(x)/2 and sin(x)^2-cos(2*x).
Click OK to close the List Editor.
To display the integral of the expression selected from the list box:
Click the List Box component, and then select Edit Select Code.
This launches the Code Editor dialog.
Before the end use; statement in the dialog, enter the following command:
SetProperty("MathContainer0", value, (Int(parse(GetProperty("ListBox0", value)), x) = int(parse(GetProperty("ListBox0", value)), x)));
Note: Ensure the names of the components are correct (that is, that they match the Name fields for their components).
Click or from the File menu, select Save Code to accept all changes.
From the File menu, select Close Code Editor.
When you select an item from the list box, the math expression component displays the integral for the expression.
sin(x)*2exp(x)^2cos(x)/2sin(x)^2-cos(2*x)
with(DocumentTools):
You can verify the syntax of the embedded component action by executing the command in the worksheet.
To display the contents of the Math Expression component, access the expression property or use the MathML[ImportModified] command on the value.
GetProperty("MathContainer0",expression);
∫12⁢cos⁡xⅆx=12⁢sin⁡x
MathML[ImportModified](GetProperty("MathContainer0",value));
∫sin⁡x2−cos⁡2⁢xⅆx=−12⁢sin⁡x⁢cos⁡x+12⁢x−12⁢sin⁡2⁢x
See Also
DocumentTools
DocumentTools[GetProperty]
DocumentTools[SetProperty]
EmbeddedComponents
InertForm[FromMathContainer]
MathML[ImportModified]
Maplets[Elements][MathMLViewer]
Download Help Document