more mathed cleanup

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1500 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Lars Gullik Bjønnes 2001-02-13 19:10:18 +00:00
parent 26428cdf19
commit 84b7ffa347
32 changed files with 431 additions and 255 deletions

View File

@ -1,5 +1,47 @@
2001-02-13 Lars Gullik Bjønnes <larsbj@lyx.org> 2001-02-13 Lars Gullik Bjønnes <larsbj@lyx.org>
* math_spaceinset.C (GetSpace): move here
* math_parinset.C: add debug.h, move several prev. inlined methods
here.
* math_macrotable.C math_xiter.C support.C: add debug.h
* math_macro.h: remove debug.h, remove typedefs
* math_macro.C: remove FORMS_H_LOCATION, and LString.h, remove
extern decls.
* math_hash.C: change some defines to int const. change use of
LM_TC_NORMAL to LM_TC_VAR
* math_draw.C: delete file
* math_defs.h (MATH_DEFS): dont define byte here, remove unneded
forward decls. remove LM_TC_NORMAL, move inline methods to
support.C (and support.h)
* math_cursor.C: move several previous inlined methods here
* math_bigopinset.h math_dotsinset.h math_funcinset.h
math_parinset.h math_spaceinset.h: add math_defs.h
* math_accentinset.h: add support.h and math_defs.h
* formulamacro.C math_cursor.C math_iter.h math_write.C: add support.h
* formula.h: remove unused func decl: OpenMathInset
* formula.C math_inset.h: get rid of math_defs.h
* array.h: switch to support.h instead of math_defs.h
* array.C: remove one include
* Makefile.am (libmathed_la_SOURCES): remove math_draw.C
* math_panel.C (deco_cb): move the sizeof/sizeof to a const int.
* math_parser.C: include macrotable and macrotemplate * math_parser.C: include macrotable and macrotemplate
* math_macrotemplate.[Ch]: new files * math_macrotemplate.[Ch]: new files

View File

@ -31,7 +31,6 @@ libmathed_la_SOURCES = \
math_deliminset.h \ math_deliminset.h \
math_dotsinset.C \ math_dotsinset.C \
math_dotsinset.h \ math_dotsinset.h \
math_draw.C \
math_forms.C \ math_forms.C \
math_forms.h \ math_forms.h \
math_fracinset.C \ math_fracinset.C \

View File

@ -6,8 +6,6 @@
#endif #endif
#include "array.h" #include "array.h"
#include "math_defs.h"
// Is this still needed? (Lgb) // Is this still needed? (Lgb)
static inline static inline

View File

@ -18,7 +18,7 @@
#include <vector> #include <vector>
#include "math_defs.h" #include "mathed/support.h"
class MathedInset; class MathedInset;

View File

@ -39,14 +39,13 @@
#include "font.h" #include "font.h"
#include "support/lyxlib.h" #include "support/lyxlib.h"
#include "lyxrc.h" #include "lyxrc.h"
#include "math_defs.h"
#include "math_inset.h" #include "math_inset.h"
#include "math_parinset.h" #include "math_parinset.h"
#include "math_matrixinset.h" #include "math_matrixinset.h"
#include "math_rowst.h" #include "math_rowst.h"
#include "math_spaceinset.h" #include "math_spaceinset.h"
#include "math_deliminset.h" #include "math_deliminset.h"
#include "support.h" #include "mathed/support.h"
using std::ostream; using std::ostream;
using std::istream; using std::istream;

View File

@ -128,10 +128,4 @@ private:
/// ///
string label; string label;
}; };
// If a mathinset exist at cursor pos, just lock it.
// Otherwise create a new one, and lock it.
bool OpenMathInset(Buffer *);
#endif #endif

View File

@ -33,6 +33,7 @@
#include "Painter.h" #include "Painter.h"
#include "font.h" #include "font.h"
#include "support/lyxlib.h" #include "support/lyxlib.h"
#include "mathed/support.h"
using std::ostream; using std::ostream;
using std::istream; using std::istream;

View File

@ -1,7 +1,7 @@
#include <config.h> #include <config.h>
#include "math_accentinset.h" #include "math_accentinset.h"
#include "support.h" #include "mathed/support.h"
#include "math_parser.h" #include "math_parser.h"

View File

@ -3,6 +3,8 @@
#define MATH_ACCENTINSET_H #define MATH_ACCENTINSET_H
#include "math_inset.h" #include "math_inset.h"
#include "mathed/support.h"
#include "math_defs.h"
/// Accents /// Accents
class MathAccentInset: public MathedInset { class MathAccentInset: public MathedInset {

View File

@ -3,6 +3,7 @@
#define MATH_BIGOPINSET_H #define MATH_BIGOPINSET_H
#include "math_inset.h" #include "math_inset.h"
#include "math_defs.h"
/// big operators /// big operators
class MathBigopInset: public MathedInset { class MathBigopInset: public MathedInset {

View File

@ -40,6 +40,7 @@
#include "math_decorationinset.h" #include "math_decorationinset.h"
#include "math_dotsinset.h" #include "math_dotsinset.h"
#include "math_accentinset.h" #include "math_accentinset.h"
#include "mathed/support.h"
static MathedArray * selarray = 0; static MathedArray * selarray = 0;
@ -377,6 +378,7 @@ MathMatrixInset * create_multiline(short int type, int cols)
return mt; return mt;
} }
void MathedCursor::Insert(byte c, MathedTextCodes t) void MathedCursor::Insert(byte c, MathedTextCodes t)
{ {
if (selection) SelDel(); if (selection) SelDel();
@ -1100,3 +1102,69 @@ void MathedCursor::toggleLastCode(MathedTextCodes t)
else else
lastcode = t; lastcode = t;
} }
void MathedCursor::GetPos(int & x, int & y)
{
cursor->GetPos(x, y);
}
short MathedCursor::GetFCode()
{
return cursor->FCode();
}
MathParInset * MathedCursor::GetPar()
{
return par;
}
MathParInset * MathedCursor::getCurrentPar() const
{
return cursor->p;
}
string const & MathedCursor::getLabel() const
{
return cursor->getLabel();
}
bool MathedCursor::IsEnd() const
{
return !cursor->OK();
}
bool MathedCursor::InMacroMode()
{
return macro_mode;
}
bool MathedCursor::Selection()
{
return selection;
}
void MathedCursor::clearLastCode()
{
lastcode = LM_TC_MIN;
}
void MathedCursor::setLastCode(MathedTextCodes t)
{
lastcode = t;
}
MathedTextCodes MathedCursor::getLastCode() const
{
return lastcode;
}

View File

@ -23,11 +23,11 @@
#pragma interface #pragma interface
#endif #endif
#include "math_iter.h"
//#include "math_inset.h"
#include "math_xiter.h" #include "math_xiter.h"
class MathFuncInset; class MathFuncInset;
class MathParInset;
class Painter;
/// This is the external interface of Mathed's subkernel /// This is the external interface of Mathed's subkernel
@ -69,13 +69,13 @@ public:
/// ///
void SetPos(int, int); void SetPos(int, int);
/// ///
void GetPos(int & x, int & y) { cursor->GetPos(x, y); } void GetPos(int & x, int & y);
/// ///
short GetFCode() { return cursor->FCode(); } short GetFCode();
/// ///
MathParInset * GetPar() { return par; } MathParInset * GetPar();
/// ///
MathParInset * getCurrentPar() const { return cursor->p; } MathParInset * getCurrentPar() const;
/// ///
void SetPar(MathParInset *); void SetPar(MathParInset *);
/// ///
@ -87,9 +87,7 @@ public:
/// ///
void setLabel(string const &); void setLabel(string const &);
/// ///
string const & getLabel() const { string const & getLabel() const;
return cursor->getLabel();
}
/// ///
bool Limits(); bool Limits();
/// Set accent: if argument = 0 it's considered consumed /// Set accent: if argument = 0 it's considered consumed
@ -97,18 +95,18 @@ public:
/// Returns last accent /// Returns last accent
int getAccent() const; int getAccent() const;
/// ///
bool IsEnd() const { return !cursor->OK(); } bool IsEnd() const;
// Macro mode methods // Macro mode methods
/// ///
void MacroModeOpen(); void MacroModeOpen();
/// ///
void MacroModeClose(); void MacroModeClose();
/// ///
bool InMacroMode() { return macro_mode; } bool InMacroMode();
// Local selection methods // Local selection methods
/// ///
bool Selection() { return selection; } bool Selection();
/// ///
void SelCopy(); void SelCopy();
/// ///
@ -126,13 +124,13 @@ public:
/// ///
void SelGetArea(int ** xp, int ** yp, int & n); void SelGetArea(int ** xp, int ** yp, int & n);
/// ///
void clearLastCode() { lastcode = LM_TC_MIN; } void clearLastCode();
/// ///
void setLastCode(MathedTextCodes t) { lastcode = t; } void setLastCode(MathedTextCodes t);
/// ///
void toggleLastCode(MathedTextCodes t); void toggleLastCode(MathedTextCodes t);
/// ///
MathedTextCodes getLastCode() const { return lastcode; } MathedTextCodes getLastCode() const;
protected: protected:
/// ///

View File

@ -27,16 +27,6 @@
#include <iosfwd> #include <iosfwd>
#include "LString.h" #include "LString.h"
#include "debug.h"
//#include "array.h"
class MathedArray;
class Painter;
#ifndef byte
#define byte unsigned char
#endif
/// ///
enum math_align { enum math_align {
@ -133,10 +123,7 @@ enum MathedTextCodes {
/// ///
std::ostream & operator<<(std::ostream &, MathedTextCodes mtc); std::ostream & operator<<(std::ostream &, MathedTextCodes mtc);
///
#define LM_TC_NORMAL LM_TC_VAR
/// Types of lyx-math insets /// Types of lyx-math insets
enum MathedInsetTypes { enum MathedInsetTypes {
/// ///
@ -200,6 +187,7 @@ enum MathedInsetTypes {
LM_OT_MAX LM_OT_MAX
}; };
/// ///
enum MathedBinaryTypes { enum MathedBinaryTypes {
/// ///
@ -212,8 +200,6 @@ enum MathedBinaryTypes {
LMB_BOP = (LMB_RELATION | LMB_OPERATOR) LMB_BOP = (LMB_RELATION | LMB_OPERATOR)
}; };
class MathParInset;
/// Paragraph permissions /// Paragraph permissions
enum MathedParFlag { enum MathedParFlag {
@ -232,146 +218,4 @@ enum MathedParFlag {
LMPF_SCRIPT = 32 LMPF_SCRIPT = 32
}; };
/************************* Prototypes **********************************/
///
MathedArray * mathed_parse(unsigned flags, MathedArray * data,
MathParInset ** mt);
///
void mathed_write(MathParInset *, std::ostream &, int *, bool fragile,
string const & label = string());
///
void mathed_parser_file(std::istream &, int);
///
int mathed_parser_lineno();
///
int MathedLookupBOP(short);
/************************ Inline functions ********************************/
///
inline
bool MathIsInset(short x)
{
return LM_TC_INSET <= x && x <= LM_TC_ACTIVE_INSET;
}
///
inline
bool MathIsFont(short x)
{
return LM_TC_CONST <= x && x <= LM_TC_BSYM;
}
///
inline
bool MathIsAlphaFont(short x)
{
return LM_TC_VAR <= x && x <= LM_TC_TEXTRM;
}
///
inline
bool MathIsActive(short x)
{
return LM_TC_INSET < x && x <= LM_TC_ACTIVE_INSET;
}
///
inline
bool MathIsUp(short x)
{
return x == LM_TC_UP;
}
///
inline
bool MathIsDown(short x)
{
return x == LM_TC_DOWN;
}
///
inline
bool MathIsScript(short x)
{
return x == LM_TC_DOWN || x == LM_TC_UP;
}
///
inline
bool MathIsBOPS(short x)
{
return MathedLookupBOP(x) > LMB_NONE;
}
///
inline
bool MathIsBinary(short x)
{
return x == LM_TC_BOP || x == LM_TC_BOPS;
}
///
inline
bool MathIsSymbol(short x) {
return LM_TC_SYMB <= x && x <= LM_TC_BSYM;
}
inline
bool is_eqn_type(short int type)
{
return type >= LM_OT_MIN && type < LM_OT_MATRIX;
}
inline
bool is_matrix_type(short int type)
{
return type == LM_OT_MATRIX;
}
inline
bool is_multiline(short int type)
{
return type >= LM_OT_MPAR && type < LM_OT_MATRIX;
}
inline bool is_ams(short int type)
{
return type > LM_OT_MPARN && type < LM_OT_MATRIX;
}
inline
bool is_singlely_numbered(short int type)
{
return type == LM_OT_PARN || type == LM_OT_MULTLINEN;
}
inline
bool is_multi_numbered(short int type)
{
return type == LM_OT_MPARN || type == LM_OT_ALIGNN
|| type == LM_OT_ALIGNATN;
}
inline
bool is_numbered(short int type)
{
return is_singlely_numbered(type) || is_multi_numbered(type);
}
inline
bool is_multicolumn(short int type)
{
return type == LM_OT_ALIGN || type == LM_OT_ALIGNN
|| type == LM_OT_ALIGNAT || type == LM_OT_ALIGNATN;
}
#endif #endif

View File

@ -2,6 +2,7 @@
#define MATH_DOTSINSET_H #define MATH_DOTSINSET_H
#include "math_inset.h" #include "math_inset.h"
#include "math_defs.h"
/// ///
class MathDotsInset: public MathedInset { class MathDotsInset: public MathedInset {

View File

@ -25,11 +25,11 @@
using std::endl; using std::endl;
extern LyXFont const mathed_get_font(short type, int size); //extern LyXFont const mathed_get_font(short type, int size);
extern int mathed_char_width(short type, int style, byte c); //extern int mathed_char_width(short type, int style, byte c);
extern int mathed_string_width(short type, int style, string const &); //extern int mathed_string_width(short type, int style, string const &);
extern int mathed_string_height(short, int, string const &, int &, int &); //extern int mathed_string_height(short, int, string const &, int &, int &);
extern int mathed_char_height(short, int, byte, int &, int &); //extern int mathed_char_height(short, int, byte, int &, int &);

View File

@ -2,6 +2,7 @@
#define MATH_FUNCINSET_H #define MATH_FUNCINSET_H
#include "math_inset.h" #include "math_inset.h"
#include "math_defs.h"
/** /**
Functions or LaTeX names for objects that I don't know how to draw. Functions or LaTeX names for objects that I don't know how to draw.

View File

@ -7,13 +7,21 @@
#include "math_defs.h" #include "math_defs.h"
#include "math_parser.h" #include "math_parser.h"
//struct latexkeys { char* name; short token; int id; };
#if 0
#define TOTAL_KEYWORDS 269 #define TOTAL_KEYWORDS 269
#define MIN_WORD_LENGTH 2 #define MIN_WORD_LENGTH 2
#define MAX_WORD_LENGTH 18 #define MAX_WORD_LENGTH 18
#define MIN_HASH_VALUE 8 #define MIN_HASH_VALUE 8
#define MAX_HASH_VALUE 490 #define MAX_HASH_VALUE 490
#else
int const TOTAL_KEYWORDS = 269;
int const MIN_WORD_LENGTH = 2;
int const MAX_WORD_LENGTH = 18;
int const MIN_HASH_VALUE = 8;
int const MAX_HASH_VALUE = 490;
#endif
/* maximum key range = 483, duplicates = 40 */ /* maximum key range = 483, duplicates = 40 */
static static
@ -179,7 +187,7 @@ latexkeys wordlist[] =
{"cap", LM_TK_SYM, LM_cap}, {"cap", LM_TK_SYM, LM_cap},
{"cup", LM_TK_SYM, LM_cup}, {"cup", LM_TK_SYM, LM_cup},
{"prec", LM_TK_SYM, LM_prec}, {"prec", LM_TK_SYM, LM_prec},
{"mathnormal", LM_TK_FONT, LM_TC_NORMAL}, {"mathnormal", LM_TK_FONT, LM_TC_VAR},
{"wr", LM_TK_SYM, LM_wr}, {"wr", LM_TK_SYM, LM_wr},
{"inf", LM_TK_FUNCLIM, 0}, {"inf", LM_TK_FUNCLIM, 0},
{"bigoplus", LM_TK_BIGSYM, LM_oplus}, {"bigoplus", LM_TK_BIGSYM, LM_oplus},

View File

@ -27,9 +27,10 @@
#endif #endif
#include "LString.h" #include "LString.h"
#include "math_defs.h"
#include "symbol_def.h" #include "symbol_def.h"
class Painter;
/** Abstract base class for all math objects. /** Abstract base class for all math objects.
A math insets is for use of the math editor only, it isn't a 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. general LyX inset. It's used to represent all the math objects.

View File

@ -24,9 +24,12 @@
#pragma interface #pragma interface
#endif #endif
#include "mathed/support.h"
#include "math_defs.h" #include "math_defs.h"
class MathedInset; class MathedInset;
class MathedArray;
class MathParInset;
/// ///
enum mathIterFlags { enum mathIterFlags {

View File

@ -16,13 +16,11 @@
*/ */
#include <config.h> #include <config.h>
#include FORMS_H_LOCATION
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation #pragma implementation
#endif #endif
#include "LString.h"
#include "math_macro.h" #include "math_macro.h"
#include "array.h" #include "array.h"
#include "math_iter.h" #include "math_iter.h"
@ -46,9 +44,6 @@ ostream & operator<<(ostream & o, MathedTextCodes mtc)
} }
//extern int mathed_string_width(short type, int style, string const & s);
//extern int mathed_string_height(short, int, string const &, int &, int &);
MathMacro::MathMacro(MathMacroTemplate * t): MathMacro::MathMacro(MathMacroTemplate * t):
MathParInset(LM_ST_TEXT, "", LM_OT_MACRO), tmplate(t) MathParInset(LM_ST_TEXT, "", LM_OT_MACRO), tmplate(t)
{ {
@ -80,6 +75,7 @@ MathMacro::MathMacro(MathMacro * m):
} }
} }
MathMacro::~MathMacro() MathMacro::~MathMacro()
{ {
for (idx = 0; idx < nargs; ++idx) { for (idx = 0; idx < nargs; ++idx) {
@ -110,7 +106,8 @@ void MathMacro::Metrics()
void MathMacro::draw(Painter & pain, int x, int y) void MathMacro::draw(Painter & pain, int x, int y)
{ {
xo = x; yo = y; xo = x;
yo = y;
Metrics(); Metrics();
tmplate->update(this); tmplate->update(this);
tmplate->SetStyle(size); tmplate->SetStyle(size);
@ -157,7 +154,8 @@ int MathMacro::GetColumns() const
void MathMacro::GetXY(int & x, int & y) const void MathMacro::GetXY(int & x, int & y) const
{ {
x = args_[idx].x; y = args_[idx].y; x = args_[idx].x;
y = args_[idx].y;
} }

View File

@ -22,9 +22,7 @@
#endif #endif
#include <vector> #include <vector>
#include "math_parinset.h" #include "math_parinset.h"
#include "debug.h"
class MathMacroTemplate; class MathMacroTemplate;
@ -71,14 +69,15 @@ public:
MathedTextCodes getTCode() const; MathedTextCodes getTCode() const;
/// ///
bool Permit(short) const; bool Permit(short) const;
private: private:
/// ///
MathMacroTemplate * tmplate; MathMacroTemplate * tmplate;
/// ///
struct MacroArgumentBase { struct MacroArgumentBase {
/// Position of the macro /// Position of the macro
int x, y; int x;
///
int y;
/// ///
MathedRowSt * row; MathedRowSt * row;
/// ///
@ -96,10 +95,4 @@ private:
/// ///
friend class MathMacroTemplate; friend class MathMacroTemplate;
}; };
///
//typedef MathMacro * MathMacroP;
///
//typedef MathMacroTemplate * MathMacroTemplateP;
#endif #endif

View File

@ -9,6 +9,7 @@
#include "math_deliminset.h" #include "math_deliminset.h"
#include "math_fracinset.h" #include "math_fracinset.h"
#include "math_parinset.h" #include "math_parinset.h"
#include "debug.h"
MathMacroTable MathMacroTable::mathMTable; MathMacroTable MathMacroTable::mathMTable;

View File

@ -241,11 +241,12 @@ void deco_cb(FL_OBJECT *, long data)
case MM_APPLY: case MM_APPLY:
case MM_OK: case MM_OK:
{ {
int i = fl_get_bmtable(fd_deco->menu); int const i = fl_get_bmtable(fd_deco->menu);
int const l = sizeof(deco_code)/sizeof(deco_code[0]);
// ideally the callback should not be called if the index is // ideally the callback should not be called if the index is
// greater than the maxitem of the bmtable, but I do not know // greater than the maxitem of the bmtable, but I do not know
// how to enforce that (JMarc) // how to enforce that (JMarc)
if (i <= sizeof(deco_code)/sizeof(deco_code[0])) { if (i <= l) {
lyxfunc->Dispatch(LFUN_INSERT_MATH, deco_code[i]); lyxfunc->Dispatch(LFUN_INSERT_MATH, deco_code[i]);
if (data == MM_APPLY) break; if (data == MM_APPLY) break;
} }

View File

@ -10,6 +10,7 @@
#include "math_parser.h" #include "math_parser.h"
#include "math_rowst.h" #include "math_rowst.h"
#include "math_parinset.h" #include "math_parinset.h"
#include "debug.h"
using std::endl; using std::endl;
@ -392,3 +393,64 @@ void MathParInset::Write(ostream & os, bool fragile)
if (brace > 0) if (brace > 0)
os << string(brace, '}'); os << string(brace, '}');
} }
bool MathParInset::Inside(int x, int y)
{
return (x >= xo && x <= xo + width
&& y <= yo + descent && y >= yo - ascent);
}
void MathParInset::GetXY(int & x, int & y) const
{
x = xo;
y = yo;
}
void MathParInset::UserSetSize(short sz)
{
if (sz >= 0) {
size = sz;
flag = flag & ~LMPF_FIXED_SIZE;
}
}
void MathParInset::SetStyle(short sz)
{
if (Permit(LMPF_FIXED_SIZE)) {
if (Permit(LMPF_SCRIPT))
sz = (sz < LM_ST_SCRIPT) ? LM_ST_SCRIPT: LM_ST_SCRIPTSCRIPT;
if (Permit(LMPF_SMALLER) && sz < LM_ST_SCRIPTSCRIPT) {
++sz;
}
MathedInset::SetStyle(sz);
}
}
void MathParInset::setFlag(MathedParFlag f)
{
flag |= f;
}
bool MathParInset::Permit(short f) const
{
return bool(f & flag);
}
MathedArray * MathParInset::GetData()
{
return array;
}
void MathParInset::setXY(int x, int y)
{
xo = x;
yo = y;
}

View File

@ -3,8 +3,10 @@
#define MATH_PARINSET_H #define MATH_PARINSET_H
#include "math_inset.h" #include "math_inset.h"
#include "math_defs.h"
struct MathedRowSt; struct MathedRowSt;
class MathedArray;
/** The math paragraph base class, base to all editable math objects */ /** The math paragraph base class, base to all editable math objects */
@ -31,11 +33,11 @@ class MathParInset: public MathedInset {
/// Data is stored in a LyXArray /// Data is stored in a LyXArray
virtual void SetData(MathedArray *); virtual void SetData(MathedArray *);
/// ///
virtual MathedArray * GetData() { return array; } virtual MathedArray * GetData();
/// Paragraph position /// Paragraph position
virtual void GetXY(int &, int &) const; virtual void GetXY(int &, int &) const;
/// ///
virtual void setXY(int x, int y) { xo = x; yo = y; } virtual void setXY(int x, int y);
/// ///
virtual void SetFocus(int, int) {} virtual void SetFocus(int, int) {}
/// ///
@ -65,7 +67,7 @@ class MathParInset: public MathedInset {
/// ///
virtual void setRowSt(MathedRowSt *) {} virtual void setRowSt(MathedRowSt *) {}
/// ///
virtual bool Permit(short f) const { return bool(f & flag); } virtual bool Permit(short f) const;
protected: protected:
/// Paragraph data is stored here /// Paragraph data is stored here
MathedArray * array; MathedArray * array;
@ -77,7 +79,7 @@ class MathParInset: public MathedInset {
short flag; short flag;
private: private:
/// ///
virtual void setFlag(MathedParFlag f) { flag |= f; } virtual void setFlag(MathedParFlag f);
/// ///
friend class InsetFormula; friend class InsetFormula;
/// ///
@ -91,40 +93,4 @@ class MathParInset: public MathedInset {
}; };
inline
bool MathParInset::Inside(int x, int y)
{
return (x >= xo && x <= xo + width && y <= yo + descent && y >= yo - ascent);
}
inline
void MathParInset::GetXY(int & x, int & y) const
{
x = xo; y = yo;
}
inline
void MathParInset::UserSetSize(short sz)
{
if (sz >= 0) {
size = sz;
flag = flag & ~LMPF_FIXED_SIZE;
}
}
inline
void MathParInset::SetStyle(short sz)
{
if (Permit(LMPF_FIXED_SIZE)) {
if (Permit(LMPF_SCRIPT))
sz = (sz < LM_ST_SCRIPT) ? LM_ST_SCRIPT: LM_ST_SCRIPTSCRIPT;
if (Permit(LMPF_SMALLER) && sz < LM_ST_SCRIPTSCRIPT) {
++sz;
}
MathedInset::SetStyle(sz);
}
}
#endif #endif

View File

@ -61,3 +61,9 @@ MathSpaceInset::Write(ostream & os, bool /* fragile */)
os << '\\' << latex_mathspace[space] << ' '; os << '\\' << latex_mathspace[space] << ' ';
} }
} }
int MathSpaceInset::GetSpace()
{
return space;
}

View File

@ -2,6 +2,7 @@
#define MATH_SPACEINSET_H #define MATH_SPACEINSET_H
#include "math_inset.h" #include "math_inset.h"
#include "math_defs.h"
/// Smart spaces /// Smart spaces
class MathSpaceInset: public MathedInset { class MathSpaceInset: public MathedInset {
@ -19,7 +20,7 @@ public:
/// ///
void SetSpace(int sp); void SetSpace(int sp);
/// ///
int GetSpace() { return space; } int GetSpace();
protected: protected:
/// ///
int space; int space;

View File

@ -22,6 +22,7 @@
#include "math_iter.h" #include "math_iter.h"
#include "math_parser.h" #include "math_parser.h"
#include "math_parinset.h" #include "math_parinset.h"
#include "mathed/support.h"
#include "support/lstrings.h" #include "support/lstrings.h"
#include "debug.h" #include "debug.h"
@ -29,7 +30,6 @@ using std::ostream;
using std::endl; using std::endl;
extern char const * latex_mathenv[]; extern char const * latex_mathenv[];
extern char * latex_mathspace[];
// quite a hack i know. Should be done with return values... // quite a hack i know. Should be done with return values...
int number_of_newlines = 0; int number_of_newlines = 0;

View File

@ -5,6 +5,7 @@
#include "math_rowst.h" #include "math_rowst.h"
#include "array.h" #include "array.h"
#include "mathed/support.h" #include "mathed/support.h"
#include "debug.h"
using std::endl; using std::endl;

View File

@ -5,6 +5,7 @@
#include "math_iter.h" #include "math_iter.h"
struct MathedRowSt; struct MathedRowSt;
class MathParInset;
/** /**
A graphic iterator (updates position.) Used for A graphic iterator (updates position.) Used for

View File

@ -9,6 +9,7 @@
#include "Painter.h" #include "Painter.h"
#include "matriz.h" #include "matriz.h"
#include "symbol_def.h" #include "symbol_def.h"
#include "debug.h"
using std::sort; using std::sort;
using std::lower_bound; using std::lower_bound;
@ -456,3 +457,112 @@ math_deco_struct const * search_deco(int code)
return 0; return 0;
} }
#endif #endif
bool MathIsInset(short x)
{
return LM_TC_INSET <= x && x <= LM_TC_ACTIVE_INSET;
}
bool MathIsFont(short x)
{
return LM_TC_CONST <= x && x <= LM_TC_BSYM;
}
bool MathIsAlphaFont(short x)
{
return LM_TC_VAR <= x && x <= LM_TC_TEXTRM;
}
bool MathIsActive(short x)
{
return LM_TC_INSET < x && x <= LM_TC_ACTIVE_INSET;
}
bool MathIsUp(short x)
{
return x == LM_TC_UP;
}
bool MathIsDown(short x)
{
return x == LM_TC_DOWN;
}
bool MathIsScript(short x)
{
return x == LM_TC_DOWN || x == LM_TC_UP;
}
bool MathIsBOPS(short x)
{
return MathedLookupBOP(x) > LMB_NONE;
}
bool MathIsBinary(short x)
{
return x == LM_TC_BOP || x == LM_TC_BOPS;
}
bool MathIsSymbol(short x) {
return LM_TC_SYMB <= x && x <= LM_TC_BSYM;
}
bool is_eqn_type(short int type)
{
return type >= LM_OT_MIN && type < LM_OT_MATRIX;
}
bool is_matrix_type(short int type)
{
return type == LM_OT_MATRIX;
}
bool is_multiline(short int type)
{
return type >= LM_OT_MPAR && type < LM_OT_MATRIX;
}
bool is_ams(short int type)
{
return type > LM_OT_MPARN && type < LM_OT_MATRIX;
}
bool is_singlely_numbered(short int type)
{
return type == LM_OT_PARN || type == LM_OT_MULTLINEN;
}
bool is_multi_numbered(short int type)
{
return type == LM_OT_MPARN || type == LM_OT_ALIGNN
|| type == LM_OT_ALIGNATN;
}
bool is_numbered(short int type)
{
return is_singlely_numbered(type) || is_multi_numbered(type);
}
bool is_multicolumn(short int type)
{
return type == LM_OT_ALIGN || type == LM_OT_ALIGNN
|| type == LM_OT_ALIGNAT || type == LM_OT_ALIGNATN;
}

View File

@ -10,6 +10,8 @@
#endif #endif
class Painter; class Painter;
class MathedArray;
class MathParInset;
struct math_deco_struct { struct math_deco_struct {
int code; int code;
@ -31,4 +33,78 @@ extern int mathed_string_height(short type, int size, string const & s,
int & asc, int & des); int & asc, int & des);
extern int mathed_string_width(short type, int size, string const & s); extern int mathed_string_width(short type, int size, string const & s);
extern math_deco_struct const * search_deco(int code); extern math_deco_struct const * search_deco(int code);
/// math_parser.C
extern
MathedArray * mathed_parse(unsigned flags, MathedArray * data,
MathParInset ** mt);
/// math_write.C
extern
void mathed_write(MathParInset *, std::ostream &, int *, bool fragile,
string const & label = string());
/// math_parser.C
extern
void mathed_parser_file(std::istream &, int);
/// math_parser.C
extern
int mathed_parser_lineno();
/// math_utils.C
extern
int MathedLookupBOP(short);
extern
bool MathIsInset(short x);
extern
bool MathIsFont(short x);
extern
bool MathIsAlphaFont(short x);
extern
bool MathIsActive(short x);
extern
bool MathIsUp(short x);
extern
bool MathIsDown(short x);
extern
bool MathIsScript(short x);
extern
bool MathIsBOPS(short x);
extern
bool MathIsBinary(short x);
extern
bool MathIsSymbol(short x);
extern
bool is_eqn_type(short int type);
extern
bool is_matrix_type(short int type);
extern
bool is_multiline(short int type);
extern
bool is_ams(short int type);
extern
bool is_singlely_numbered(short int type);
extern
bool is_multi_numbered(short int type);
extern
bool is_numbered(short int type);
extern
bool is_multicolumn(short int type);
#endif #endif