// -*- C++ -*- /* * File: math_defs.h * Purpose: Math editor definitions * Author: Alejandro Aguilar Sierra <asierra@servidor.unam.mx> * Created: January 1996 * Description: Math paragraph and objects for a WYSIWYG math editor. * * Dependencies: Xlib * * Copyright: (c) 1996, 1997 Alejandro Aguilar Sierra * * Version: 0.8beta, Mathed & Lyx project. * * You are free to use and modify this code under the terms of * the GNU General Public Licence version 2 or later. *
*/
/** The restrictions of a standard LaTeX math paragraph
allows to get a small number of text codes (<30) */ enum MathedTextCodes { /// This must be >= 0
LM_TC_MIN = 0, /// Open and Close group
LM_TC_OPEN, ///
LM_TC_CLOSE, /// Tabulator
LM_TC_TAB, /// New line
LM_TC_CR, /// Math Inset
LM_TC_INSET, /// Super and sub scripts
LM_TC_UP, ///
LM_TC_DOWN, /// Editable Math Inset
LM_TC_ACTIVE_INSET, /// Editable Text Inset
LM_TC_TEXT_INSET, ///
LM_FONT_BEGIN, /// Internal code for constants
LM_TC_CONST, /// Internal code for variables
LM_TC_VAR, ///
LM_TC_RM, ///
LM_TC_CAL, ///
LM_TC_BF, ///
LM_TC_SF, ///
LM_TC_TT, ///
LM_TC_IT, ///
LM_TC_TEXTRM, /// Math mode TeX characters ",;:{}"
LM_TC_TEX, /// Special characters "{}_%"
LM_TC_SPECIAL, /// Internal code for operators
LM_TC_BOP, /// Internal code for symbols
LM_TC_SYMB, ///
LM_TC_BOPS, ///
LM_TC_BSYM, ///
LM_FONT_END,
/// This must be < 32
LM_TC_MAX
};
/// #define LM_TC_NORMAL LM_TC_VAR
/// Types of lyx-math insets enum MathedInsetTypes { ///
LM_OT_MIN = 0, /// A simple paragraph
LM_OT_PAR, /// A simple numbered paragraph
LM_OT_PARN, /// A multiline paragraph
LM_OT_MPAR, /// A multiline numbered paragraph
LM_OT_MPARN, /// An array
LM_OT_MATRIX, /// A big operator
LM_OT_BIGOP, /// A LaTeX macro
LM_OT_UNDEF, ///
LM_OT_FUNC, ///
LM_OT_FUNCLIM, ///
LM_OT_SCRIPT, ///
LM_OT_SPACE, ///
LM_OT_DOTS, /// A fraction
LM_OT_FRAC, ///
LM_OT_ATOP, ///
LM_OT_STACKREL, /// A radical
LM_OT_SQRT, /// A delimiter
LM_OT_DELIM, /// A decoration
LM_OT_DECO, /// An accent
LM_OT_ACCENT, ///
LM_OT_MACRO, ///
LM_OT_MACRO_ARG, ///
LM_OT_MAX
};
class LString; class MathedInset; class MathParInset;
/** Abstract base class for all math objects. A math insets is for use of the math editor only, it isn't a general LyX inset. It's used to represent all the math objects. The formulaInset (a LyX inset) encapsulates a math inset.
*/ class MathedInset { public: /// A math inset has a name (usually its LaTeX name), type and font-size
MathedInset(charconst *nm, short ot, short st); ///
MathedInset(MathedInset*); /// virtual ~MathedInset() { };
/// Draw the object virtualvoid Draw(int x, int baseline)=0;
/// Write LaTeX and Lyx code virtualvoid Write(FILE *file)=0; /// Write LaTeX and Lyx code virtualvoid Write(LString &file)=0;
//Man: Avoid to use these functions if it's not strictly necessary /// virtualvoid SetType(short t) { objtype = t; } /// virtualvoid SetStyle(short st) { size = st; } // Metrics(); /// virtualvoid SetName(charconst* n) { name = n; } /// void setDrawable(longunsignedint d) { pm = d; }
protected: /// charconst *name; /// short objtype; /// int width; /// int ascent; /// int descent; /// short size; /// This works while only one process can draw unless /// the process have their own data staticlongunsignedint pm; /// Default metrics staticint df_asc, df_des, df_width;
/// In a near future maybe we use a better fonts renderer than X void drawStr(short, int, int, int, byte*, int); /// friendclass MathedCursor; /// friendvoid mathed_init_fonts();
};
struct MathedRowSt;
/// Paragraph permissions enum MathedParFlag {
LMPF_BASIC = 0, /// If false can use a non-standard size
LMPF_FIXED_SIZE = 1, /// If true can insert newlines
LMPF_ALLOW_CR = 2, /// If true can use tabs
LMPF_ALLOW_TAB = 4, /// If true can insert new columns
LMPF_ALLOW_NEW_COL = 8, /// Smaller than current size (frac)
LMPF_SMALLER = 16, /// Script size (subscript, stackrel)
LMPF_SCRIPT = 32
};
/** The math paragraph base class, base to all editable math objects */ class MathParInset: public MathedInset { public: ///
MathParInset(short st=LM_ST_TEXT, charconst *nm=NULL, short ot=LM_OT_MIN); ///
MathParInset(MathParInset*); /// virtual ~MathParInset(); /// virtual MathedInset *Clone();
/// Draw the object on a drawable virtualvoid Draw(int x, int baseline);
/** Multiline math paragraph base class. This is the base to all multiline editable math objects like array and eqnarray.
*/ class MathMatrixInset: public MathParInset { public: ///
MathMatrixInset(int m=1, int n=1, short st=LM_ST_TEXT); ///
MathMatrixInset(MathMatrixInset*); ///
MathedInset *Clone(); /// virtual ~MathMatrixInset(); /// void Draw(int, int); /// void Write(FILE *file); /// void Write(LString &file); /// void Metrics(); /// void SetData(LyxArrayBase *); /// void SetAlign(char, charconst*); /// char *GetAlign(char* vv) {
*vv = v_align; return h_align;
} // /// // int GetTab(int); /// int GetColumns() { return nc; } /// int GetRows() { return nr; } /// virtualbool isMatrix() { returntrue; }
/// Use this to manage the extra information independently of paragraph
MathedRowSt *getRowSt() const { return row; } /// void setRowSt(MathedRowSt* r) { row = r; }
protected: /// Number of columns & rows int nc, nr; /// tab sizes int *ws; /// char v_align; // add approp. signedness /// char* h_align; /// Vertical structure
MathedRowSt *row;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.