2 #ifndef MATH_PARINSET_H
3 #define MATH_PARINSET_H
5 #include "math_inset.h"
10 /** The math paragraph base class, base to all editable math objects */
11 class MathParInset: public MathedInset {
14 MathParInset(short st = LM_ST_TEXT, string const & nm = string(),
15 short ot = LM_OT_MIN);
18 MathParInset(MathParInset *);
20 virtual ~MathParInset();
22 virtual MathedInset * Clone();
23 /// Draw the object on a drawable
24 virtual void draw(Painter &, int x, int baseline);
26 virtual void Write(std::ostream &, bool fragile);
28 virtual void Metrics();
30 virtual void UserSetSize(short);
31 /// Data is stored in a LyXArray
32 virtual void SetData(MathedArray *);
34 virtual MathedArray * GetData() { return array; }
35 /// Paragraph position
36 virtual void GetXY(int &, int &) const;
38 virtual void setXY(int x, int y) { xo = x; yo = y; }
40 virtual void SetFocus(int, int) {}
42 virtual bool Inside(int, int);
43 // Tab stuff used by Matrix.
45 virtual void SetAlign(char, string const &) {}
47 virtual int GetColumns() const { return 1; }
49 virtual int GetRows() const { return 1; }
51 virtual bool isMatrix() const { return false; }
54 virtual bool setArgumentIdx(int i) { return (i == 0); }
56 virtual bool setNextArgIdx() { return false; }
58 virtual int getArgumentIdx() const { return 0; }
60 virtual int getMaxArgumentIdx() const { return 0; }
62 virtual void SetStyle(short);
64 virtual MathedRowSt * getRowSt() const;
66 virtual void setRowSt(MathedRowSt *) {}
68 virtual bool Permit(short f) const { return bool(f & flag); }
70 /// Paragraph data is stored here
72 /// Cursor start position
80 virtual void setFlag(MathedParFlag f) { flag |= f; }
82 friend class InsetFormula;
84 friend class MathedXIter;
86 friend class MathedCursor;
88 friend MathedArray * mathed_parse(unsigned flags = 0,
90 MathParInset ** p = 0);
95 bool MathParInset::Inside(int x, int y)
97 return (x >= xo && x <= xo + width && y <= yo + descent && y >= yo - ascent);
102 void MathParInset::GetXY(int & x, int & y) const
109 void MathParInset::UserSetSize(short sz)
113 flag = flag & ~LMPF_FIXED_SIZE;
119 void MathParInset::SetStyle(short sz)
121 if (Permit(LMPF_FIXED_SIZE)) {
122 if (Permit(LMPF_SCRIPT))
123 sz = (sz < LM_ST_SCRIPT) ? LM_ST_SCRIPT: LM_ST_SCRIPTSCRIPT;
124 if (Permit(LMPF_SMALLER) && sz < LM_ST_SCRIPTSCRIPT) {
127 MathedInset::SetStyle(sz);