1999-09-27 18:44:28 +00:00
|
|
|
// -*- 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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
1999-10-02 16:21:10 +00:00
|
|
|
#ifndef MATH_DEFS
|
|
|
|
#define MATH_DEFS
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma interface
|
|
|
|
#endif
|
|
|
|
|
2000-01-10 16:28:29 +00:00
|
|
|
#include "support/LIstream.h"
|
|
|
|
|
1999-10-02 16:21:10 +00:00
|
|
|
#include "LString.h"
|
1999-10-13 10:34:07 +00:00
|
|
|
#include "debug.h"
|
1999-10-02 16:21:10 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
#include "array.h"
|
|
|
|
|
2000-01-10 16:28:29 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-11-22 16:19:48 +00:00
|
|
|
enum math_align {
|
|
|
|
///
|
|
|
|
MATH_ALIGN_LEFT = 1,
|
|
|
|
///
|
|
|
|
MATH_ALIGN_RIGHT = 2,
|
|
|
|
///
|
|
|
|
MATH_ALIGN_BOTTOM = 4,
|
|
|
|
///
|
|
|
|
MATH_ALIGN_TOP = 8
|
|
|
|
};
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
|
|
|
#define MATH_COLSEP 8
|
|
|
|
///
|
|
|
|
#define MATH_ROWSEP 8
|
|
|
|
|
|
|
|
|
|
|
|
/// Standard Math Sizes (Math mode styles)
|
|
|
|
enum MathedStyles {
|
|
|
|
///
|
1999-12-07 00:44:53 +00:00
|
|
|
LM_ST_DISPLAY = 0,
|
|
|
|
///
|
|
|
|
LM_ST_TEXT,
|
|
|
|
///
|
|
|
|
LM_ST_SCRIPT,
|
|
|
|
///
|
|
|
|
LM_ST_SCRIPTSCRIPT
|
1999-09-27 18:44:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/// Standard LaTeX Math Environments
|
|
|
|
enum MathedEnvironment {
|
|
|
|
///
|
1999-12-07 00:44:53 +00:00
|
|
|
LM_EN_INTEXT = 0,
|
|
|
|
///
|
|
|
|
LM_EN_DISPLAY,
|
|
|
|
///
|
|
|
|
LM_EN_EQUATION,
|
|
|
|
///
|
|
|
|
LM_EN_EQNARRAYAST,
|
|
|
|
///
|
|
|
|
LM_EN_EQNARRAY,
|
|
|
|
///
|
|
|
|
LM_EN_ARRAY
|
1999-09-27 18:44:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/** The restrictions of a standard LaTeX math paragraph
|
|
|
|
allows to get a small number of text codes (<30) */
|
|
|
|
enum MathedTextCodes {
|
1999-12-07 00:44:53 +00:00
|
|
|
/// 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
|
1999-09-27 18:44:28 +00:00
|
|
|
};
|
|
|
|
|
1999-10-07 18:44:17 +00:00
|
|
|
ostream & operator<<(ostream &, MathedTextCodes mtc);
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
|
|
|
#define LM_TC_NORMAL LM_TC_VAR
|
|
|
|
|
|
|
|
|
|
|
|
/// Types of lyx-math insets
|
|
|
|
enum MathedInsetTypes {
|
1999-12-07 00:44:53 +00:00
|
|
|
///
|
|
|
|
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
|
1999-09-27 18:44:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
///
|
|
|
|
enum MathedBinaryTypes {
|
|
|
|
///
|
1999-12-07 00:44:53 +00:00
|
|
|
LMB_NONE = 0,
|
|
|
|
///
|
|
|
|
LMB_RELATION,
|
|
|
|
///
|
|
|
|
LMB_OPERATOR,
|
|
|
|
///
|
|
|
|
LMB_BOP = (LMB_RELATION | LMB_OPERATOR)
|
1999-09-27 18:44:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
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
|
1999-11-22 16:19:48 +00:00
|
|
|
MathedInset(char const * nm, short ot, short st);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-11-22 16:19:48 +00:00
|
|
|
MathedInset(MathedInset *);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-11-22 16:19:48 +00:00
|
|
|
virtual ~MathedInset() {}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
/// Draw the object
|
1999-11-22 16:19:48 +00:00
|
|
|
virtual void Draw(int x, int baseline) = 0;
|
1999-12-07 00:44:53 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
/// Write LaTeX and Lyx code
|
1999-12-07 00:44:53 +00:00
|
|
|
virtual void Write(ostream &) = 0;
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
/// Write LaTeX and Lyx code
|
1999-11-22 16:19:48 +00:00
|
|
|
virtual void Write(string & file) = 0;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
/// Reproduces itself
|
1999-11-22 16:19:48 +00:00
|
|
|
virtual MathedInset * Clone() = 0;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
/// Compute the size of the object
|
1999-11-22 16:19:48 +00:00
|
|
|
virtual void Metrics() = 0;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
|
|
|
virtual int Ascent() const { return ascent; }
|
|
|
|
///
|
|
|
|
virtual int Descent() const { return descent; }
|
|
|
|
///
|
|
|
|
virtual int Width() const { return width; }
|
|
|
|
///
|
|
|
|
virtual int Height() const { return ascent + descent; }
|
|
|
|
|
|
|
|
///
|
|
|
|
virtual bool GetLimits() const { return false; }
|
|
|
|
///
|
1999-11-22 16:19:48 +00:00
|
|
|
virtual void SetLimits(bool) {}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
///
|
1999-11-22 16:19:48 +00:00
|
|
|
char const * GetName() const { return name; }
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
|
|
|
short GetType() const { return objtype; }
|
|
|
|
///
|
|
|
|
short GetStyle() const { return size; }
|
|
|
|
|
|
|
|
//Man: Avoid to use these functions if it's not strictly necessary
|
|
|
|
///
|
|
|
|
virtual void SetType(short t) { objtype = t; }
|
|
|
|
///
|
|
|
|
virtual void SetStyle(short st) { size = st; } // Metrics();
|
|
|
|
///
|
1999-11-22 16:19:48 +00:00
|
|
|
virtual void SetName(char const * n) { name = n; }
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
|
|
|
void setDrawable(long unsigned int d) { pm = d; }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
///
|
1999-11-22 16:19:48 +00:00
|
|
|
char const * name;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
|
|
|
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
|
|
|
|
static long unsigned int pm;
|
|
|
|
/// Default metrics
|
|
|
|
static int df_asc, df_des, df_width;
|
|
|
|
|
|
|
|
/// In a near future maybe we use a better fonts renderer than X
|
1999-11-22 16:19:48 +00:00
|
|
|
void drawStr(short, int, int, int, byte *, int);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
|
|
|
friend class MathedCursor;
|
|
|
|
///
|
|
|
|
friend void mathed_init_fonts();
|
|
|
|
};
|
|
|
|
|
|
|
|
struct MathedRowSt;
|
|
|
|
|
|
|
|
|
|
|
|
/// Paragraph permissions
|
|
|
|
enum MathedParFlag {
|
1999-12-07 00:44:53 +00:00
|
|
|
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
|
1999-09-27 18:44:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/** The math paragraph base class, base to all editable math objects */
|
|
|
|
class MathParInset: public MathedInset {
|
|
|
|
public:
|
|
|
|
///
|
1999-12-07 00:44:53 +00:00
|
|
|
MathParInset(short st = LM_ST_TEXT, char const * nm = 0,
|
|
|
|
short ot = LM_OT_MIN);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-11-22 16:19:48 +00:00
|
|
|
MathParInset(MathParInset *);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
|
|
|
virtual ~MathParInset();
|
|
|
|
///
|
1999-11-24 22:14:46 +00:00
|
|
|
virtual MathedInset * Clone();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
/// Draw the object on a drawable
|
|
|
|
virtual void Draw(int x, int baseline);
|
1999-12-07 00:44:53 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
/// Write LaTeX code
|
1999-12-07 00:44:53 +00:00
|
|
|
virtual void Write(ostream &);
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
/// Write LaTeX code
|
1999-11-22 16:19:48 +00:00
|
|
|
virtual void Write(string & file);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
|
|
|
virtual void Metrics();
|
|
|
|
///
|
|
|
|
virtual void UserSetSize(short);
|
|
|
|
|
|
|
|
/// Data is stored in a LyXArray
|
|
|
|
virtual void SetData(LyxArrayBase *);
|
|
|
|
///
|
|
|
|
virtual LyxArrayBase * GetData() { return array; }
|
|
|
|
|
|
|
|
/// Paragraph position
|
1999-11-22 16:19:48 +00:00
|
|
|
virtual void GetXY(int &, int &) const;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-11-15 11:06:41 +00:00
|
|
|
virtual void setXY(int x, int y) { xo = x; yo = y; }
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-11-22 16:19:48 +00:00
|
|
|
virtual void SetFocus(int, int) {}
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
|
|
|
virtual bool Inside(int, int);
|
|
|
|
|
|
|
|
// Tab stuff used by Matrix.
|
|
|
|
///
|
1999-11-22 16:19:48 +00:00
|
|
|
virtual void SetAlign(char, char const *) {}
|
1999-09-27 18:44:28 +00:00
|
|
|
// ///
|
|
|
|
// virtual int GetTabPos() { return 0; }
|
|
|
|
// ///
|
|
|
|
// virtual int GetTab(int) { return 0; }
|
|
|
|
///
|
|
|
|
virtual int GetColumns() { return 1; }
|
|
|
|
///
|
|
|
|
virtual int GetRows() { return 1; }
|
|
|
|
///
|
|
|
|
virtual bool isMatrix() { return false; }
|
|
|
|
// /// These functions should report an error
|
|
|
|
// virtual char const* GetLabel() { return 0; }
|
|
|
|
// virtual char const* GetLabel(int) { return 0; }
|
|
|
|
|
|
|
|
// Vertical switching
|
|
|
|
///
|
1999-11-15 11:06:41 +00:00
|
|
|
virtual bool setArgumentIdx(int i) { return (i == 0); }
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
|
|
|
virtual bool setNextArgIdx() { return false; }
|
|
|
|
///
|
|
|
|
virtual int getArgumentIdx() { return 0; }
|
|
|
|
///
|
|
|
|
virtual int getMaxArgumentIdx() { return 0; }
|
|
|
|
// ///
|
1999-11-22 16:19:48 +00:00
|
|
|
// virtual void SetLabel(char const *) {}
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
|
|
|
virtual void SetStyle(short);
|
|
|
|
///
|
1999-11-22 16:19:48 +00:00
|
|
|
virtual MathedRowSt * getRowSt() const { return 0; }
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-11-22 16:19:48 +00:00
|
|
|
virtual void setRowSt(MathedRowSt *) {}
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-11-22 16:19:48 +00:00
|
|
|
virtual bool Permit(short f) { return bool(f & flag); }
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
/// Paragraph data is stored here
|
1999-11-22 16:19:48 +00:00
|
|
|
LyxArrayBase * array;
|
1999-09-27 18:44:28 +00:00
|
|
|
/// Cursor start position
|
|
|
|
int xo, yo;
|
|
|
|
///
|
|
|
|
short flag;
|
|
|
|
|
|
|
|
private:
|
|
|
|
///
|
|
|
|
virtual void setFlag(MathedParFlag f) { flag |= f; }
|
|
|
|
///
|
|
|
|
friend class InsetFormula;
|
|
|
|
///
|
|
|
|
friend class MathedXIter;
|
|
|
|
///
|
|
|
|
friend class MathedCursor;
|
|
|
|
///
|
1999-11-22 16:19:48 +00:00
|
|
|
friend LyxArrayBase * mathed_parse(unsigned flags = 0,
|
|
|
|
LyxArrayBase * a = 0,
|
|
|
|
MathParInset ** p = 0);
|
1999-09-27 18:44:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/* The physical structure of a row and aditional information is stored here.
|
|
|
|
It allows to manage the extra info independently of the paragraph data.
|
|
|
|
Only used for multiline paragraphs.
|
|
|
|
*/
|
|
|
|
struct MathedRowSt {
|
|
|
|
///
|
|
|
|
MathedRowSt(int n) {
|
1999-11-22 16:19:48 +00:00
|
|
|
w = new int[n + 1]; // this leaks
|
2000-01-05 13:09:19 +00:00
|
|
|
asc = desc = y = 0;
|
|
|
|
for (int i = 0 ; i < n + 1 ; ++i)
|
|
|
|
w[i] = 0;
|
1999-12-07 00:44:53 +00:00
|
|
|
next = 0;
|
|
|
|
label = 0;
|
|
|
|
numbered = true;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
///
|
|
|
|
~MathedRowSt() {
|
2000-02-04 09:38:32 +00:00
|
|
|
delete[] w;
|
|
|
|
delete[] label;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
/// Should be const but...
|
1999-11-22 16:19:48 +00:00
|
|
|
MathedRowSt * getNext() const { return next; }
|
1999-09-27 18:44:28 +00:00
|
|
|
/// ...we couldn't use this.
|
1999-11-22 16:19:48 +00:00
|
|
|
void setNext(MathedRowSt * n) { next = n; }
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-11-22 16:19:48 +00:00
|
|
|
char const * getLabel() const { return label; }
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
|
|
|
bool isNumbered() const { return numbered; }
|
|
|
|
///
|
|
|
|
int getBaseline() const { return y; }
|
|
|
|
///
|
|
|
|
int getTab(int i) { return w[i]; }
|
|
|
|
///
|
1999-11-22 16:19:48 +00:00
|
|
|
void setLabel(char * l) { label = l; }
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
|
|
|
void setNumbered(bool nf) { numbered = nf; }
|
|
|
|
///
|
|
|
|
void setTab(int i, int t) { w[i] = t; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
/// Vericals
|
|
|
|
int asc, desc, y;
|
|
|
|
/// widths
|
1999-11-22 16:19:48 +00:00
|
|
|
int * w;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-11-22 16:19:48 +00:00
|
|
|
char * label;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
|
|
|
bool numbered;
|
|
|
|
///
|
1999-11-22 16:19:48 +00:00
|
|
|
MathedRowSt * next;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
|
|
|
friend class MathMatrixInset;
|
|
|
|
///
|
|
|
|
friend class MathedXIter;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/** Multiline math paragraph base class.
|
|
|
|
This is the base to all multiline editable math objects
|
|
|
|
like array and eqnarray.
|
|
|
|
*/
|
|
|
|
class MathMatrixInset: public MathParInset {
|
|
|
|
public:
|
|
|
|
///
|
1999-11-22 16:19:48 +00:00
|
|
|
MathMatrixInset(int m = 1, int n = 1, short st = LM_ST_TEXT);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-11-22 16:19:48 +00:00
|
|
|
MathMatrixInset(MathMatrixInset *);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-11-24 22:14:46 +00:00
|
|
|
MathedInset * Clone();
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
|
|
|
virtual ~MathMatrixInset();
|
|
|
|
///
|
|
|
|
void Draw(int, int);
|
|
|
|
///
|
1999-12-07 00:44:53 +00:00
|
|
|
void Write(ostream &);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-11-22 16:19:48 +00:00
|
|
|
void Write(string & file);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
|
|
|
void Metrics();
|
|
|
|
///
|
|
|
|
void SetData(LyxArrayBase *);
|
|
|
|
///
|
1999-11-22 16:19:48 +00:00
|
|
|
void SetAlign(char, char const *);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-11-22 16:19:48 +00:00
|
|
|
char * GetAlign(char * vv) {
|
1999-09-27 18:44:28 +00:00
|
|
|
*vv = v_align;
|
|
|
|
return h_align;
|
|
|
|
}
|
|
|
|
// ///
|
|
|
|
// int GetTab(int);
|
|
|
|
///
|
|
|
|
int GetColumns() { return nc; }
|
|
|
|
///
|
|
|
|
int GetRows() { return nr; }
|
|
|
|
///
|
|
|
|
virtual bool isMatrix() { return true; }
|
|
|
|
|
|
|
|
/// Use this to manage the extra information independently of paragraph
|
1999-11-22 16:19:48 +00:00
|
|
|
MathedRowSt * getRowSt() const { return row; }
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-11-22 16:19:48 +00:00
|
|
|
void setRowSt(MathedRowSt * r) { row = r; }
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
/// Number of columns & rows
|
|
|
|
int nc, nr;
|
|
|
|
/// tab sizes
|
1999-11-22 16:19:48 +00:00
|
|
|
int * ws;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
|
|
|
char v_align; // add approp. signedness
|
|
|
|
///
|
1999-11-22 16:19:48 +00:00
|
|
|
char * h_align;
|
1999-09-27 18:44:28 +00:00
|
|
|
/// Vertical structure
|
1999-11-22 16:19:48 +00:00
|
|
|
MathedRowSt * row;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/************************* Prototypes **********************************/
|
|
|
|
///
|
1999-11-22 16:19:48 +00:00
|
|
|
LyxArrayBase * mathed_parse(unsigned flags, LyxArrayBase * data,
|
|
|
|
MathParInset ** mt);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-12-07 00:44:53 +00:00
|
|
|
void mathed_write(MathParInset *, ostream &, int *, char fragile,
|
1999-11-22 16:19:48 +00:00
|
|
|
char const * label = 0);
|
2000-01-06 02:44:26 +00:00
|
|
|
|
1999-12-07 00:44:53 +00:00
|
|
|
///
|
1999-11-22 16:19:48 +00:00
|
|
|
void mathed_write(MathParInset *, string &, int *, char fragile,
|
|
|
|
char const * label = 0);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2000-01-06 02:44:26 +00:00
|
|
|
void mathed_parser_file(istream &, int);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
|
|
|
int mathed_parser_lineno();
|
|
|
|
///
|
|
|
|
int MathedLookupBOP(short);
|
|
|
|
|
|
|
|
/************************ Inline functions ********************************/
|
|
|
|
///
|
1999-11-22 16:19:48 +00:00
|
|
|
inline bool MathIsInset(short x)
|
|
|
|
{
|
|
|
|
return LM_TC_INSET <= x && x <= LM_TC_ACTIVE_INSET;
|
|
|
|
}
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-11-22 16:19:48 +00:00
|
|
|
inline bool MathIsFont(short x)
|
|
|
|
{
|
|
|
|
return LM_TC_CONST <= x && x <= LM_TC_BSYM;
|
|
|
|
}
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-11-22 16:19:48 +00:00
|
|
|
inline bool MathIsAlphaFont(short x)
|
|
|
|
{
|
|
|
|
return LM_TC_VAR <= x && x <= LM_TC_TEXTRM;
|
|
|
|
}
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-11-22 16:19:48 +00:00
|
|
|
inline bool MathIsActive(short x)
|
|
|
|
{
|
|
|
|
return LM_TC_INSET < x && x <= LM_TC_ACTIVE_INSET;
|
|
|
|
}
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-11-22 16:19:48 +00:00
|
|
|
inline bool MathIsUp(short x)
|
|
|
|
{
|
|
|
|
return x == LM_TC_UP;
|
|
|
|
}
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-11-22 16:19:48 +00:00
|
|
|
inline bool MathIsDown(short x)
|
|
|
|
{
|
|
|
|
return x == LM_TC_DOWN;
|
|
|
|
}
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-11-22 16:19:48 +00:00
|
|
|
inline bool MathIsScript(short x)
|
|
|
|
{
|
|
|
|
return x == LM_TC_DOWN || x == LM_TC_UP;
|
|
|
|
}
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-11-22 16:19:48 +00:00
|
|
|
inline bool MathIsBOPS(short x)
|
|
|
|
{
|
|
|
|
return MathedLookupBOP(x) > LMB_NONE;
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
///
|
|
|
|
inline bool MathIsBinary(short x)
|
|
|
|
{
|
1999-11-22 16:19:48 +00:00
|
|
|
return x == LM_TC_BOP || x == LM_TC_BOPS;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
///
|
|
|
|
inline bool MathIsSymbol(short x) {
|
1999-11-22 16:19:48 +00:00
|
|
|
return LM_TC_SYMB <= x && x <= LM_TC_BSYM;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline
|
1999-11-22 16:19:48 +00:00
|
|
|
MathedInset::MathedInset(char const * nm, short ot, short st):
|
1999-09-27 18:44:28 +00:00
|
|
|
name(nm), objtype(ot), size(st)
|
|
|
|
{
|
|
|
|
width = ascent = descent = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline
|
|
|
|
bool MathParInset::Inside(int x, int y)
|
|
|
|
{
|
1999-11-22 16:19:48 +00:00
|
|
|
return (x >= xo && x <= xo + width && y <= yo + descent && y >= yo - ascent);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline
|
1999-11-22 16:19:48 +00:00
|
|
|
void MathParInset::GetXY(int & x, int & y) const
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
x = xo; y = yo;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline
|
|
|
|
void MathParInset::UserSetSize(short sz)
|
|
|
|
{
|
1999-11-22 16:19:48 +00:00
|
|
|
if (sz >= 0) {
|
1999-09-27 18:44:28 +00:00
|
|
|
size = sz;
|
|
|
|
flag = flag & ~LMPF_FIXED_SIZE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline
|
|
|
|
void MathParInset::SetStyle(short sz)
|
|
|
|
{
|
|
|
|
if (Permit(LMPF_FIXED_SIZE)) {
|
|
|
|
if (Permit(LMPF_SCRIPT))
|
1999-11-22 16:19:48 +00:00
|
|
|
sz = (sz < LM_ST_SCRIPT) ? LM_ST_SCRIPT: LM_ST_SCRIPTSCRIPT;
|
1999-09-27 18:44:28 +00:00
|
|
|
if (Permit(LMPF_SMALLER) && sz < LM_ST_SCRIPTSCRIPT) {
|
1999-11-22 16:19:48 +00:00
|
|
|
++sz;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
MathedInset::SetStyle(sz);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|