TeX/include/TeX/classes.h

66 lines
2.6 KiB
C
Raw Permalink Normal View History

2019-06-12 18:53:50 +02:00
//---
// class: Node classes
//---
#include <TeX/node.h>
/* TeX_Class
Essentially the prototype of a node class, which implements the layout and
rendering function of a fixed mathematical construct. */
struct TeX_Class
{
/* Most of the time this name appears in the formula using the "\name"
notation, but some classes (superscript, parentheses, matrices...)
have special syntax and their names are hardcoded. To avoid
conflicts, built-in class names start with a backslash. */
char const *name;
/* layout()
This function must calculate the width, height and base line of the
node and store the results in the structure fields. It is allowed to
access the .width, .height and .line fields of its children because
they will have had their size calculated beforehand.
This TeX module provides classes with a primitive function that
calculates the size of raw strings:
#include <TeX/interface.h>
void TeX_size(char const *str, int *width, int *height);
2019-06-19 17:52:09 +02:00
@node A node of the described class, for size calculation
@display Whether we use full-size display instead of inline mode */
void (*layout)(struct TeX_Node *node, int display);
2019-06-12 18:53:50 +02:00
/* render()
This function must render the given node at the provided (x, y)
coordinates. The (x, y) point is the top-left corner of the bounding
box of the expression and is inside the box (ie. it can be drawn
to). This function must honor the size estimates provided by
calculate_size() and not draw outside the bounding box.
This TeX module provides three primitive functions for rendering:
#include <TeX/interface.h>
void TeX_pixel(int x, int y, int color);
void TeX_line(int x1, int y1, int x2, int y2, int color);
void TeX_text(char const *str, int x, int y, int color);
@node A node of the described class, for rendering
@x Horizontal coordinate of the requested rendering position
@y Vertical coordinate of the requested rendering position
@color Requested rendering color */
void (*render)(struct TeX_Node const * node, int x, int y, int color);
/* Sub- and superscript mode, see <TeX/flow.h> for available modes */
int mode;
2019-06-12 18:53:50 +02:00
};
/* TeX_class_find(): Find a class using a command name
@name Command name
Returns a positive class id representing the requested TeX_Class object (if
a class with this name is found in the table, a negative number otherwise.
This function never returns 0, which is reserved for TEX_NODECLASS_TEXT. */
int TeX_class_find(char const *name);
/* TeX_class_of(): Get the class pointer of a node */
struct TeX_Class const *TeX_class_of(struct TeX_Node const * node);