Module Mlpost.Box


module Box: sig .. end


Boxes
type t 
The abstract type of boxes

Creating boxes


val empty : ?name:string ->
?width:Num.t -> ?height:Num.t -> unit -> t
the empty box

type style =
| Rect
| Circle
| RoundRect
| Patatoid
| Ellipse
| Custom of (Num.t -> Num.t -> Num.t * Num.t * Path.t)

Styles


type 'a box_creator = ?dx:Num.t ->
?dy:Num.t ->
?name:string ->
?stroke:Color.t option ->
?pen:Pen.t -> ?fill:Color.t -> 'a -> t
All functions used to create boxes take the following optional parameters : dx (resp. dy) is the horizontal (resp. vertical) padding between the box border and its contents ; name, if present, is associated with the box and can be used to retrieve it using get ; stroke is the color used to draw the outline of the box ; when equal to None, the outline will not be drawn ; pen is the pen used to draw the box's outline, if absent Pen.default is used ; fill, if present, is the color used to fill the box.
val pic : ?style:style -> Picture.t box_creator
pic p creates a new box containing the picture p
val path : ?style:style -> Path.t box_creator
path p creates a new box containing the path p
val tex : ?style:style -> string box_creator
tex s creates a new box containing the LaTeX string s
val box : ?style:style -> t box_creator
box b creates a new box containing the box b
val circle : t box_creator
circle pic creates a circle box containing the picture pic. Optional padding is given by arguments dx and dy; default is 2bp.
val ellipse : t box_creator
ellipse p pic creates a elliptic box containing the picture pic. Optional padding is given by arguments dx and dy; default is 2bp
val rect : t box_creator
rect p pic creates a rectangular box containing the picture pic. Optional padding is given by arguments dx and dy; default is 2bp.
val round_rect : t box_creator
round_rect p pic creates a rectangular box containing the picture pic, with rounded corners. Optional padding is given by dx and dy; default is 2bp
val patatoid : t box_creator
patatoid p pic creates an undefined, vaguely rectangular box containing the picture pic. It may happen that the content overlaps with the box.
val bpath : t -> Path.t
Get the bounding path of a box

Special points on a box


val ctr : t -> Point.t
val north : t -> Point.t
val south : t -> Point.t
val west : t -> Point.t
val east : t -> Point.t
val north_west : t -> Point.t
val south_west : t -> Point.t
val north_east : t -> Point.t
val south_east : t -> Point.t

Operators


val ctr : t -> Point.t
return the center of the object
val height : t -> Num.t
return the height of the object
val width : t -> Num.t
return the width of the object
val shift : Point.t -> t -> t
shift pt x shifts the object x about the point pt
val center : Point.t -> t -> t
center pt x centers the object x at the point pt
val draw : ?debug:bool -> t -> Command.t
Draws a box
debug : if set to to true, the bounding path and the center of the box are drawn as well, default is false
val group : ?style:style -> t list box_creator
group bl groups a list of boxes bl into a single box

Boxes alignment


val hbox : ?padding:Num.t ->
?pos:Command.vposition ->
?style:style -> t list box_creator
aligns the given boxes horizontally and returns a box containing these boxes as sub-components. Leave the first box at its place.
padding : horizontal padding used to separate the boxes; defaults to 0
pos : used to determine the way boxes are aligned; defaults to `Center
val vbox : ?padding:Num.t ->
?pos:Command.hposition ->
?style:style -> t list box_creator
aligns the given boxes vertically and returns a box containing these boxes as sub-components. Leave the first box at its place.
padding : vertical padding used to separate the boxes
pos : used to determine the way boxes are aligned
val tabular : ?hpadding:Num.t ->
?vpadding:Num.t ->
?pos:Command.position -> t array array -> t
aligns the given boxes both vertically and horizontally and returns a box containing all these boxes (with rows as first sub-components, and then individual boxes as sub-components of each row). Columns (resp. rows) are separated by hpadding (resp. vpadding); both default to 0. Alignment within columns and rows is controlled using pos. The arrays for rows must have the same lengths; otherwise Invalid_argument is raised.
val tabularl : ?hpadding:Num.t ->
?vpadding:Num.t ->
?pos:Command.position -> t list list -> t
similar to tabular, but using lists instead of arrays
val tabulari : ?hpadding:Num.t ->
?vpadding:Num.t ->
?pos:Command.position ->
int -> int -> (int -> int -> t) -> t
similar to tabular, but using a matrix defined with a function
val hblock : ?pos:Command.vposition ->
?name:string ->
?min_width:Num.t ->
?same_width:bool -> t list -> t
hblock bl aligns the boxes of bl horizontally and surround them with new rectangular boxes of the same height; all these new boxes are packed together into the returned box.
min_width : minimum width of all boxes; default is zero
same_width : if true, all boxes are of same width, and at least of min_width; default is false
val vblock : ?pos:Command.hposition ->
?name:string ->
?min_height:Num.t ->
?same_height:bool -> t list -> t
similar to hblock, with vertical alignment.
min_height : minimum height of all boxes; default is zero
same_height : if true, all boxes are of same height, and at least of min_height; default is false
val grid : ?pos:Command.position -> t array array -> t
Aligns the given boxes in a way that is similar to hblock and vblock: boxes are aligned in a grid where all cells have the same size. Each one of these cells is a box containing the original corresponding box.
val gridl : ?pos:Command.position -> t list list -> t
similar to grid, but using lists instead of arrays
val gridi : ?pos:Command.position ->
int -> int -> (int -> int -> t) -> t
similar to gridi, but using a matrix defined with a function

Sub-boxes accessors


val nth : int -> t -> t
nth i b returns the i-th sub-box of b. The first sub-box has index 0. Raises Invalid_argument if there is no such sub-box.
val get : string -> t -> t
get n b returns the sub-box of b of name n, if any, and raises Invalid_argument otherwise. The behavior is not specified if b contains several sub-boxes with name n.
val elts : t -> t array
elts b returns the sub-boxes of b; returns the empty array for the empty box or a box containing a picture.

Box properties


val get_fill : t -> Color.t option
val set_fill : Color.t -> t -> t
val get_stroke : t -> Color.t option
val set_stroke : Color.t -> t -> t
val clear_stroke : t -> t
val get_name : t -> string option
val set_name : string -> t -> t
val get_pen : t -> Pen.t option
val set_pen : Pen.t -> t -> t

Misc.


val shadow : t -> t
val cpath : ?style:Path.joint ->
?outd:Path.direction ->
?ind:Path.direction -> t -> t -> Path.t
the path that connects 2 boxes and stops at the box boundaries