mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-03 08:28:25 +00:00
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:
parent
26428cdf19
commit
84b7ffa347
@ -1,5 +1,47 @@
|
||||
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_macrotemplate.[Ch]: new files
|
||||
|
@ -31,7 +31,6 @@ libmathed_la_SOURCES = \
|
||||
math_deliminset.h \
|
||||
math_dotsinset.C \
|
||||
math_dotsinset.h \
|
||||
math_draw.C \
|
||||
math_forms.C \
|
||||
math_forms.h \
|
||||
math_fracinset.C \
|
||||
|
@ -6,8 +6,6 @@
|
||||
#endif
|
||||
|
||||
#include "array.h"
|
||||
#include "math_defs.h"
|
||||
|
||||
|
||||
// Is this still needed? (Lgb)
|
||||
static inline
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "math_defs.h"
|
||||
#include "mathed/support.h"
|
||||
|
||||
class MathedInset;
|
||||
|
||||
|
@ -39,14 +39,13 @@
|
||||
#include "font.h"
|
||||
#include "support/lyxlib.h"
|
||||
#include "lyxrc.h"
|
||||
#include "math_defs.h"
|
||||
#include "math_inset.h"
|
||||
#include "math_parinset.h"
|
||||
#include "math_matrixinset.h"
|
||||
#include "math_rowst.h"
|
||||
#include "math_spaceinset.h"
|
||||
#include "math_deliminset.h"
|
||||
#include "support.h"
|
||||
#include "mathed/support.h"
|
||||
|
||||
using std::ostream;
|
||||
using std::istream;
|
||||
|
@ -128,10 +128,4 @@ private:
|
||||
///
|
||||
string label;
|
||||
};
|
||||
|
||||
|
||||
// If a mathinset exist at cursor pos, just lock it.
|
||||
// Otherwise create a new one, and lock it.
|
||||
bool OpenMathInset(Buffer *);
|
||||
|
||||
#endif
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include "Painter.h"
|
||||
#include "font.h"
|
||||
#include "support/lyxlib.h"
|
||||
#include "mathed/support.h"
|
||||
|
||||
using std::ostream;
|
||||
using std::istream;
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "math_accentinset.h"
|
||||
#include "support.h"
|
||||
#include "mathed/support.h"
|
||||
#include "math_parser.h"
|
||||
|
||||
|
||||
|
@ -3,6 +3,8 @@
|
||||
#define MATH_ACCENTINSET_H
|
||||
|
||||
#include "math_inset.h"
|
||||
#include "mathed/support.h"
|
||||
#include "math_defs.h"
|
||||
|
||||
/// Accents
|
||||
class MathAccentInset: public MathedInset {
|
||||
|
@ -3,6 +3,7 @@
|
||||
#define MATH_BIGOPINSET_H
|
||||
|
||||
#include "math_inset.h"
|
||||
#include "math_defs.h"
|
||||
|
||||
/// big operators
|
||||
class MathBigopInset: public MathedInset {
|
||||
|
@ -40,6 +40,7 @@
|
||||
#include "math_decorationinset.h"
|
||||
#include "math_dotsinset.h"
|
||||
#include "math_accentinset.h"
|
||||
#include "mathed/support.h"
|
||||
|
||||
static MathedArray * selarray = 0;
|
||||
|
||||
@ -377,6 +378,7 @@ MathMatrixInset * create_multiline(short int type, int cols)
|
||||
return mt;
|
||||
}
|
||||
|
||||
|
||||
void MathedCursor::Insert(byte c, MathedTextCodes t)
|
||||
{
|
||||
if (selection) SelDel();
|
||||
@ -1100,3 +1102,69 @@ void MathedCursor::toggleLastCode(MathedTextCodes t)
|
||||
else
|
||||
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;
|
||||
}
|
||||
|
@ -23,11 +23,11 @@
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
#include "math_iter.h"
|
||||
//#include "math_inset.h"
|
||||
#include "math_xiter.h"
|
||||
|
||||
class MathFuncInset;
|
||||
class MathParInset;
|
||||
class Painter;
|
||||
|
||||
|
||||
/// This is the external interface of Mathed's subkernel
|
||||
@ -69,13 +69,13 @@ public:
|
||||
///
|
||||
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 *);
|
||||
///
|
||||
@ -87,9 +87,7 @@ public:
|
||||
///
|
||||
void setLabel(string const &);
|
||||
///
|
||||
string const & getLabel() const {
|
||||
return cursor->getLabel();
|
||||
}
|
||||
string const & getLabel() const;
|
||||
///
|
||||
bool Limits();
|
||||
/// Set accent: if argument = 0 it's considered consumed
|
||||
@ -97,18 +95,18 @@ public:
|
||||
/// Returns last accent
|
||||
int getAccent() const;
|
||||
///
|
||||
bool IsEnd() const { return !cursor->OK(); }
|
||||
bool IsEnd() const;
|
||||
// Macro mode methods
|
||||
///
|
||||
void MacroModeOpen();
|
||||
///
|
||||
void MacroModeClose();
|
||||
///
|
||||
bool InMacroMode() { return macro_mode; }
|
||||
bool InMacroMode();
|
||||
|
||||
// Local selection methods
|
||||
///
|
||||
bool Selection() { return selection; }
|
||||
bool Selection();
|
||||
///
|
||||
void SelCopy();
|
||||
///
|
||||
@ -126,13 +124,13 @@ public:
|
||||
///
|
||||
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);
|
||||
///
|
||||
MathedTextCodes getLastCode() const { return lastcode; }
|
||||
MathedTextCodes getLastCode() const;
|
||||
|
||||
protected:
|
||||
///
|
||||
|
@ -27,16 +27,6 @@
|
||||
#include <iosfwd>
|
||||
|
||||
#include "LString.h"
|
||||
#include "debug.h"
|
||||
|
||||
//#include "array.h"
|
||||
|
||||
class MathedArray;
|
||||
class Painter;
|
||||
|
||||
#ifndef byte
|
||||
#define byte unsigned char
|
||||
#endif
|
||||
|
||||
///
|
||||
enum math_align {
|
||||
@ -133,9 +123,6 @@ enum MathedTextCodes {
|
||||
///
|
||||
std::ostream & operator<<(std::ostream &, MathedTextCodes mtc);
|
||||
|
||||
///
|
||||
#define LM_TC_NORMAL LM_TC_VAR
|
||||
|
||||
|
||||
/// Types of lyx-math insets
|
||||
enum MathedInsetTypes {
|
||||
@ -200,6 +187,7 @@ enum MathedInsetTypes {
|
||||
LM_OT_MAX
|
||||
};
|
||||
|
||||
|
||||
///
|
||||
enum MathedBinaryTypes {
|
||||
///
|
||||
@ -212,8 +200,6 @@ enum MathedBinaryTypes {
|
||||
LMB_BOP = (LMB_RELATION | LMB_OPERATOR)
|
||||
};
|
||||
|
||||
class MathParInset;
|
||||
|
||||
|
||||
/// Paragraph permissions
|
||||
enum MathedParFlag {
|
||||
@ -232,146 +218,4 @@ enum MathedParFlag {
|
||||
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
|
||||
|
@ -2,6 +2,7 @@
|
||||
#define MATH_DOTSINSET_H
|
||||
|
||||
#include "math_inset.h"
|
||||
#include "math_defs.h"
|
||||
|
||||
///
|
||||
class MathDotsInset: public MathedInset {
|
||||
|
@ -25,11 +25,11 @@
|
||||
|
||||
using std::endl;
|
||||
|
||||
extern LyXFont const mathed_get_font(short type, int size);
|
||||
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_height(short, int, string const &, int &, int &);
|
||||
extern int mathed_char_height(short, int, byte, int &, int &);
|
||||
//extern LyXFont const mathed_get_font(short type, int size);
|
||||
//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_height(short, int, string const &, int &, int &);
|
||||
//extern int mathed_char_height(short, int, byte, int &, int &);
|
||||
|
||||
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
#define MATH_FUNCINSET_H
|
||||
|
||||
#include "math_inset.h"
|
||||
#include "math_defs.h"
|
||||
|
||||
/**
|
||||
Functions or LaTeX names for objects that I don't know how to draw.
|
||||
|
@ -7,13 +7,21 @@
|
||||
|
||||
#include "math_defs.h"
|
||||
#include "math_parser.h"
|
||||
//struct latexkeys { char* name; short token; int id; };
|
||||
|
||||
#if 0
|
||||
#define TOTAL_KEYWORDS 269
|
||||
#define MIN_WORD_LENGTH 2
|
||||
#define MAX_WORD_LENGTH 18
|
||||
#define MIN_HASH_VALUE 8
|
||||
#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 */
|
||||
|
||||
static
|
||||
@ -179,7 +187,7 @@ latexkeys wordlist[] =
|
||||
{"cap", LM_TK_SYM, LM_cap},
|
||||
{"cup", LM_TK_SYM, LM_cup},
|
||||
{"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},
|
||||
{"inf", LM_TK_FUNCLIM, 0},
|
||||
{"bigoplus", LM_TK_BIGSYM, LM_oplus},
|
||||
|
@ -27,9 +27,10 @@
|
||||
#endif
|
||||
|
||||
#include "LString.h"
|
||||
#include "math_defs.h"
|
||||
#include "symbol_def.h"
|
||||
|
||||
class Painter;
|
||||
|
||||
/** 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.
|
||||
|
@ -24,9 +24,12 @@
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
#include "mathed/support.h"
|
||||
#include "math_defs.h"
|
||||
|
||||
class MathedInset;
|
||||
class MathedArray;
|
||||
class MathParInset;
|
||||
|
||||
///
|
||||
enum mathIterFlags {
|
||||
|
@ -16,13 +16,11 @@
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include FORMS_H_LOCATION
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation
|
||||
#endif
|
||||
|
||||
#include "LString.h"
|
||||
#include "math_macro.h"
|
||||
#include "array.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):
|
||||
MathParInset(LM_ST_TEXT, "", LM_OT_MACRO), tmplate(t)
|
||||
{
|
||||
@ -80,6 +75,7 @@ MathMacro::MathMacro(MathMacro * m):
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
MathMacro::~MathMacro()
|
||||
{
|
||||
for (idx = 0; idx < nargs; ++idx) {
|
||||
@ -110,7 +106,8 @@ void MathMacro::Metrics()
|
||||
|
||||
void MathMacro::draw(Painter & pain, int x, int y)
|
||||
{
|
||||
xo = x; yo = y;
|
||||
xo = x;
|
||||
yo = y;
|
||||
Metrics();
|
||||
tmplate->update(this);
|
||||
tmplate->SetStyle(size);
|
||||
@ -157,7 +154,8 @@ int MathMacro::GetColumns() 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;
|
||||
}
|
||||
|
||||
|
||||
|
@ -22,9 +22,7 @@
|
||||
#endif
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "math_parinset.h"
|
||||
#include "debug.h"
|
||||
|
||||
class MathMacroTemplate;
|
||||
|
||||
@ -71,14 +69,15 @@ public:
|
||||
MathedTextCodes getTCode() const;
|
||||
///
|
||||
bool Permit(short) const;
|
||||
|
||||
private:
|
||||
///
|
||||
MathMacroTemplate * tmplate;
|
||||
///
|
||||
struct MacroArgumentBase {
|
||||
/// Position of the macro
|
||||
int x, y;
|
||||
int x;
|
||||
///
|
||||
int y;
|
||||
///
|
||||
MathedRowSt * row;
|
||||
///
|
||||
@ -96,10 +95,4 @@ private:
|
||||
///
|
||||
friend class MathMacroTemplate;
|
||||
};
|
||||
|
||||
///
|
||||
//typedef MathMacro * MathMacroP;
|
||||
///
|
||||
//typedef MathMacroTemplate * MathMacroTemplateP;
|
||||
|
||||
#endif
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "math_deliminset.h"
|
||||
#include "math_fracinset.h"
|
||||
#include "math_parinset.h"
|
||||
#include "debug.h"
|
||||
|
||||
|
||||
MathMacroTable MathMacroTable::mathMTable;
|
||||
|
@ -241,11 +241,12 @@ void deco_cb(FL_OBJECT *, long data)
|
||||
case MM_APPLY:
|
||||
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
|
||||
// greater than the maxitem of the bmtable, but I do not know
|
||||
// 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]);
|
||||
if (data == MM_APPLY) break;
|
||||
}
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "math_parser.h"
|
||||
#include "math_rowst.h"
|
||||
#include "math_parinset.h"
|
||||
#include "debug.h"
|
||||
|
||||
using std::endl;
|
||||
|
||||
@ -392,3 +393,64 @@ void MathParInset::Write(ostream & os, bool fragile)
|
||||
if (brace > 0)
|
||||
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;
|
||||
}
|
||||
|
@ -3,8 +3,10 @@
|
||||
#define MATH_PARINSET_H
|
||||
|
||||
#include "math_inset.h"
|
||||
#include "math_defs.h"
|
||||
|
||||
struct MathedRowSt;
|
||||
class MathedArray;
|
||||
|
||||
|
||||
/** 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
|
||||
virtual void SetData(MathedArray *);
|
||||
///
|
||||
virtual MathedArray * GetData() { return array; }
|
||||
virtual MathedArray * GetData();
|
||||
/// Paragraph position
|
||||
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) {}
|
||||
///
|
||||
@ -65,7 +67,7 @@ class MathParInset: public MathedInset {
|
||||
///
|
||||
virtual void setRowSt(MathedRowSt *) {}
|
||||
///
|
||||
virtual bool Permit(short f) const { return bool(f & flag); }
|
||||
virtual bool Permit(short f) const;
|
||||
protected:
|
||||
/// Paragraph data is stored here
|
||||
MathedArray * array;
|
||||
@ -77,7 +79,7 @@ class MathParInset: public MathedInset {
|
||||
short flag;
|
||||
private:
|
||||
///
|
||||
virtual void setFlag(MathedParFlag f) { flag |= f; }
|
||||
virtual void setFlag(MathedParFlag f);
|
||||
///
|
||||
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
|
||||
|
@ -61,3 +61,9 @@ MathSpaceInset::Write(ostream & os, bool /* fragile */)
|
||||
os << '\\' << latex_mathspace[space] << ' ';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int MathSpaceInset::GetSpace()
|
||||
{
|
||||
return space;
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
#define MATH_SPACEINSET_H
|
||||
|
||||
#include "math_inset.h"
|
||||
#include "math_defs.h"
|
||||
|
||||
/// Smart spaces
|
||||
class MathSpaceInset: public MathedInset {
|
||||
@ -19,7 +20,7 @@ public:
|
||||
///
|
||||
void SetSpace(int sp);
|
||||
///
|
||||
int GetSpace() { return space; }
|
||||
int GetSpace();
|
||||
protected:
|
||||
///
|
||||
int space;
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "math_iter.h"
|
||||
#include "math_parser.h"
|
||||
#include "math_parinset.h"
|
||||
#include "mathed/support.h"
|
||||
#include "support/lstrings.h"
|
||||
#include "debug.h"
|
||||
|
||||
@ -29,7 +30,6 @@ using std::ostream;
|
||||
using std::endl;
|
||||
|
||||
extern char const * latex_mathenv[];
|
||||
extern char * latex_mathspace[];
|
||||
|
||||
// quite a hack i know. Should be done with return values...
|
||||
int number_of_newlines = 0;
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "math_rowst.h"
|
||||
#include "array.h"
|
||||
#include "mathed/support.h"
|
||||
#include "debug.h"
|
||||
|
||||
using std::endl;
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "math_iter.h"
|
||||
|
||||
struct MathedRowSt;
|
||||
class MathParInset;
|
||||
|
||||
/**
|
||||
A graphic iterator (updates position.) Used for
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "Painter.h"
|
||||
#include "matriz.h"
|
||||
#include "symbol_def.h"
|
||||
#include "debug.h"
|
||||
|
||||
using std::sort;
|
||||
using std::lower_bound;
|
||||
@ -456,3 +457,112 @@ math_deco_struct const * search_deco(int code)
|
||||
return 0;
|
||||
}
|
||||
#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;
|
||||
}
|
||||
|
@ -10,6 +10,8 @@
|
||||
#endif
|
||||
|
||||
class Painter;
|
||||
class MathedArray;
|
||||
class MathParInset;
|
||||
|
||||
struct math_deco_struct {
|
||||
int code;
|
||||
@ -31,4 +33,78 @@ extern int mathed_string_height(short type, int size, string const & s,
|
||||
int & asc, int & des);
|
||||
extern int mathed_string_width(short type, int size, string const & s);
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user