Skip to main content

MathFlow toolbar definition language

Language constructs

Overview, language constructs

The MathFlow toolbar configuration language is an XML vocabulary for describing the arrangement of templates, symbols, and pull-down palettes. The language is very simple, with just six tags and five attributes. However, there are several hundred keywords for pre-defined palettes, symbols and templates. Note in most cases the toolbar configuration language expects names of characters rather than true entity references, i.e., <btn>alpha</btn> instead of <btn>α</btn>. The following sections describe the tags, their attributes, and examples of their usage.

Toolbar definition language attributes

tb element

The tb element is the top-level wrapper for a complete toolbar description. Every configuration description consists of a single tb element.

Attributes

name

permitted values

size

[s | l | w | ws] (default l)

Specifying size=s indicates that all buttons on the toolbar and pull-down palettes should be the small size, unless otherwise indicated. Similarly, size=l (lowercase L) indicates buttons should be large, size=w should be wide, and size=ws should be wide and small.

Examples

<tb><btn>alpha</btn><incl name='#toolbox'/></tb>
<tb size='s'><btn>alpha</btn><incl name='#toolbox'/></tb>

row element

The row element is the top-level wrapper for a toolbar row description. Every row description consists of a single row element, which may be inferred if the toolbar has only 1 row. Each row element is a child only of the tb element.

Attributes

name

permitted values

size

[s | l | w | ws] (default l)

Specifying size=s indicates that all buttons on the toolbar and pull-down palettes should be the small size, unless otherwise indicated. Similarly, size=l (lowercase L) indicates buttons should be large, size=w should be wide, and size=ws should be wide and small.

btn element

The btn element is used to place a button on the toolbar. The contents of the element determine the image that will appear on the button and what it does. The contents of a btn element can be:

  1. Any single Unicode character supported by MathFlow e.g., A, b, 3, etc.

  2. Any single MathML character name supported by MathFlow e.g., alpha, otimes, infin, etc.

  3. A quote delimited run of Unicode characters supported by MathFlow e.g. "sin", "Airy", etc.

  4. Any predefined template name.

  5. Any predefined icon name.

  6. A valid MathML string.

Consult the tables of predefined Templates, Palettes, Palette Labels, and MathFlow characters for a complete listing.

When a character or character name is given as the content of the btn element, a button is created displaying that character. When clicked, the button inserts the same character at the current cursor location.

  • When a pre-defined template name is given, a button is created displaying a graphic representation of the template, and clicking inserts the corresponding template at the current cursor location.

  • When an icon name is given, a button is placed on the toolbar displaying the named image. In the case of toolbox icons, the button is associated with the corresponding editor action, i.e., cut, paste, etc. However, when a non-toolbox icon name is given, i.e., "TRIGPALETTE," a button without any default action is created. Normally, one only uses these icons when creating a button to open a pull-down palette using the sub element (see below).

  • When MathML is given, an image of the corresponding typeset mathematical expression is generated and placed on the button. Unless the optional insertas element is used, the same MathML is inserted into the editor.

  • If a button name is not recognized, the toolbar parser will indicate the problem by creating a button displaying a red "X".

When the imagesrc attribute is present, the image indicated will be used for the button face, regardless of the element's content. The action for the button is identical to what it would be without the attribute. The image will be scaled and centered on the button.

Attributes

name

permitted values

type

[mi | mn | mo]

cue

text string

imagesrc

a path relative to the CLASSPATH

When creating a button to insert a character, there is an issue of what MathML code to generate. Some characters can be used as identifiers, numbers or operators, and thus should be tagged with the MI, MN, and MO MathML elements respectively. MathFlow tries to guess according to the following rules:

  • If the character is in the MathFlow operator dictionary, it tags it as an MO.

  • If it is a digit, it tags it as an MN.

  • Otherwise, characters are treated as MI.

By specifying a type attribute on a btn element, you can override this default behavior, and specify which element you would like to have generated.

Similarly, MathFlow displays a default status line message when a reader mouses over a button on the toolbar. For characters, this default message is just the character name. For other icons and templates, the default message varies. By giving a cue attribute, you can specify your own status line message to be displayed when mousing over the button.

Children

name

contents

insertas (optional)

MathML string

When using a MathML string for a button, you can differentiate the MathML used to display an image on the button from the MathML that is inserted into the editor. This allows you to "tweak" the MathML to appear correctly depending on where it is displayed. The content of the btn element indicates the MathML to be displayed on the button. The optional child element insertas indicates the MathML to be inserted into the editor.

Examples

<tb><btn>A</btn><btn>alpha</btn><btn>FRAC</btn><btn>CUT</btn></tb>
<tb><btn type='mn'>I</btn><btn type='mn'>V</btn>
    <btn type='mn'>X</btn><btn type='mn'>L</btn><btn type='mn'>C</btn></tb>
<tb><btn cue='force'>F</btn><btn cue='mass'>m</btn>
    <btn cue='velocity'>v</btn></tb>
<tb>
  <btn cue='Subscript (Ctrl+B)'>
    <math><msub><mi>&template;</mi><mi>&template;</mi></msub></math>
    <insertas>
      <math><msub><template/><template/></msub></math>
    </insertas>
  </btn>
</tb>

sub element

The sub element is used to create a pull-down palette. The sub tags enclose the buttons and sub-palettes which are to be placed on the palette.

The sub element binds the pull-down palette to the button immediately preceding it. Note that if there is no preceding button, the palette created won't be attached to anything and won't be accessible.

Attributes

name

permitted values

size

[s | w | ws]

cols

positive number

The sub element accepts the same size attribute as the tb element, with the same effect. Giving a value of "s" indicates that all the buttons on the pull-down palette should be small, "w" indicates they should all be wide, and "ws" indicates they should be wide and small.

Small buttons usually work well for symbol palettes, while wide buttons work better for templates. Note that all characters, templates and icons on a toolbar are drawn at a common scale. If you put a wide expression in a small button, the magnification factor will be so small that many of the other buttons images will be too small to read. Thus, it is usually best to try to pick appropriate button sizes for their contents.

The cols attribute specifies how many columns wide the created pull-down palette will be. MathFlow automatically places the buttons left to right and top to bottom on the palette regardless of the number of columns, and fills any empty space in the last row.

Examples

<tb><btn>A</btn><sub><btn>FRAC</btn></sub></tb>
<tb><btn>TRIGPALETTE</btn><sub size='w'><btn>COS</btn>
    <btn>SIN</btn><btn>theta</btn></sub></tb>
<tb><btn>TRIGPALETTE</btn><sub size='w' cols='2'><btn>COS</btn>
    <btn>SIN</btn><btn>theta</btn><btn>pi</btn></sub></tb>

sep element

The sep element is an empty element which creates a vertical separator on the toolbar or pull-down palette. This is useful for visually grouping similar items on a toolbar or palette.

Attributes

None.

Example

<tb><btn>FRAC</btn><btn>SUP</btn><btn>SQRT</btn><sep/>
    <btn>infin</btn><btn>angle</btn><btn>theta</btn></tb>

incl Element

The incl element inserts a pre-defined toolbar component at that location in the configuration description. In effect, this element works like a bare-bones macro capability, with a collection of pre-defined macros that expand before processing.

Consult the table of pre-defined Templates and Palettes for a complete listing of pre-defined components. Most of them are complete pre-defined pull-down palettes, such as a trig palette, Greek letter palettes, and so on. Several complete toolbars are also pre-defined.

Pre-defined component names all begin with a "#" character.

Attributes

name

permitted values

name

pre-defined label

The incl is an empty element; the pre-defined component to insert is specified by the name attribute. If the value is unrecognized, the include is ignored by MathFlow

Example

<tb><btn>LCGREEKPALETTE</btn><sub size='s'><incl name='#greek'/></sub><sep/>
    <btn>TOOLBOX</btn><sub cols='3' size='s'><incl name='#toolbox'/></sub></tb>

Palettes and templates

In this section:

Complete toolbars

Use these keywords with the incl element to insert pre-defined components in a toolbar. For an explanation of how to use the incl element, see the documentation on the toolbar definition language constructs.

#standard

#extrasymbols

#basic

#websafe

Palettes

Use these keywords with the incl element to insert pre-defined components in a toolbar. For an explanation of how to use the incl element, see the documentation on the toolbar definition language constructs.

#layout

#accents

#combiningCommon

#combiningOther

#fences

#matrix

#trig

#calculus

#arrows

#operators

#relations

#settheory

#greek

#Greek

#logic

#dots

#variants

#exarr

#exrel

#equiv

#exop

#triangles

#boxes

#dashes

#basicops

#basicrelns

#mixedsym

#mixedops

#intcalc

#diffcalc

#veccalc

#invisiblechars

#toolbox

Palette labels

LAYOUTPALETTE

FENCEPALETTE

COMMONCOMBININGPALETTE

OTHERCOMBININGPALETTE

ACCENTPALETTE

TRIGPALETTE

MATRIXPALETTE

CALCPALETTE

DERIVATIVEPALETTE

INTEGRALPALETTE

VECTORCALCPALETTE

LOGICPALETTE

RELATIONPALETTE

OPERATORPALETTE

SYMBOLPALETTE

LCGREEKPALETTE

UCGREEKPALETTE

ARROWPALETTE

SETTHEORYPALETTE

DOTPALETTE

VARIANTPALETTE

EXARRPALETTE

EQUIVPALETTE

EXRELPALETTE

EXOPPALETTE

TRIANGLEPALETTE

BOXPALETTE

DASHPALETTE

INVISIBLECHARSPALETTE

Templates

FRAC

SQRT

ROOT

SUB

SUP

SUBSUP

PRESUB

PRESUP

PRESUBSUP

UNDER

OVER

UNDEROVER

MAKEMROW

MAKEMSTYLE

MAKEMTEXT

PARENS

BRACKETS

BRACES

ANGLES

ABSBARS

CEILS

FLOORS

NORMBARS

BAR

RAY

VEC

PRIME

DOT

DDOT

TILDE

HAT

LINE

CUB

CLB

UBAR

TBRK

BBRK

SIN

COS

TAN

SEC

CSC

COT

ARCCOS

ARCSIN

ARCTAN

LOGBASE

MATRIX1X2

MATRIX2X1

MATRIX2X2

MATRIX3X3

MATRIXNXM

DDX

DELDELX

INDEFINT

DEFINT

SUM

LOWSUM

PROD

LOWPROD

LIMIT

DIV

GRAD

CURL

THINSPACE

THINNEGSPACE

INVISIBLETIMES

APPLYFUNCTION

CUT

COPY

PASTE

UNDO

BIGGER

SMALLER

HELP

CHECKSYNTAX

TOOLBOX

Advanced toolbar configuration

Palettes toolbar

The Palettes toolbar has the following qualities:

  • Allows multiple toolbars with various button sizes, which can be configured with the configuration files.

  • A user can load a custom Palettes toolbar.

  • The Palettes toolbar can be hidden or shown via a View menu.

  • The top level <tb> element contains one or more <row> elements which define each row of the toolbar.

    • Vertical position is defined by the order of <row> elements.

    • If your toolbar has only one row, you can omit the <row> element since it is inferred.

Tabbed toolbar (Structure Editor only)

The Tabbed toolbar has the following qualities:

  • A user can select an expression and drag onto the current tabbed toolbar to add a new custom button. To delete a button, you can choose Delete from the contextual menu, or edit the toolbar configuration file.

  • To insert the button content at the insertion point, either click the button or right-click and choose Insert.

  • In order to save a toolbar on which you've added custom expressions, choose:

    <strong>Toolbar > Tabbed Toolbar > Save Current Toolbar As</strong>

    .

  • A user can save a Tabbed toolbar under a different name.

  • A user can load a custom Tabbed toolbar.

  • To return to factory default settings, choose

    <strong>Toolbar > Tabbed Toolbar > Standard</strong>

    .

  • To save a separate copy of the Standard toolbar, save a new copy of it:

    <strong>Toolbar > Tabbed Toolbar > Save Current Toolbar As</strong>

    .

  • The Tabbed toolbar can be hidden or shown via the View menu.

  • The toolbar Configuration Language has been extended to allow the definition of multiple tabs for the tabbed toolbar:

    • The top level element <tb> contains one or more <tab> elements.

    • Horizontal position is defined by the order of <tab> elements.

  • There are 7 pre-defined tabs and 2 undefined tabs, all of which can be customized:

    • Algebra

    • Derivs

    • Statistics

    • Matrices

    • Sets

    • Trig

    • Geometry

    • Tab8

    • Tab9

  • To change the tab names, first save the toolbar, then edit the toolbar configuration file.

Mini toolbar

The mini toolbar is combined on the same line as the MathML ancestry. Included on the mini toolbar are:

  • Style selector. Choose between MathFlow 12 pre-defined logical styles, such as sans-serif and script. If you're using Structure Editor and have defined a custom style, you may choose this style from the style selector as well. Default is inherited, which inherits the style from the parent node on the expression tree.

  • Nine "utility" command buttons. Included are:

    • Configure Styles (Structure Editor only)

    • Undo

    • Cut

    • Copy

    • Paste

    • Verify (check syntax)

    • Magnify (zoom in)

    • Shrink (zoom out)

    • Help

An extended example

Here's an extended example showing a toolbar customized for calculus…

Here's the configuration string for the toolbar:

<tb>
   <btn>LAYOUTPALETTE</btn>
   <sub>
      <btn>FRAC</btn>
      <btn>SUP</btn>
      <btn>SQRT</btn>
      <btn>ROOT</btn><btn>PARENS</btn><btn>ABSBARS</btn>
      <btn>NORMBARS</btn><btn>BAR</btn>
   </sub>
   <btn>SYMBOLPALETTE</btn>
   <sub><incl name="#mixedsym"/></sub>
   <btn>OPERATORPALETTE</btn>
   <sub cols=3>
      <btn>plus</btn><btn>minus</btn><btn>times</btn><btn>divide</btn>
      <btn>plusmn</btn><btn>lt</btn><btn>gt</btn><btn>leq</btn>
      <btn>geq</btn><btn>cup</btn><btn>cap</btn><btn>in</btn>
      <btn>rarr</btn><btn>subset</btn><btn>compfn</btn>
   </sub>
   <sep/>
   <btn>DERIVATIVEPALETTE</btn>
   <sub cols=3>
      <btn>DDX</btn><btn>DELDELX</btn><btn>LIMIT</btn>
      <btn>PRIME</btn><btn>DOT</btn><btn>DDOT</btn>
   </sub>
   <btn>INTEGRALPALETTE</btn>
   <sub cols="3">
      <btn>INDEFINT</btn><btn>DEFINT</btn><btn>SUM</btn>
      <btn>LOWSUM</btn><btn>PROD</btn><btn>LOWPROD</btn>
   </sub>
   <btn>VECTORCALCPALETTE</btn>
   <sub cols="3">
      <btn>VEC</btn><btn>times</btn><btn>middot</btn>
      <btn>DIV</btn><btn>GRAD</btn><btn>CURL</btn>
   </sub>
   <sep/>
   <btn>CUT</btn><btn>COPY</btn><btn>PASTE</btn>
   <btn>UNDO</btn><btn>BIGGER</btn><btn>SMALLER</btn>
   <sep/>
   <btn>HELP</btn>
</tb>