]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_parinset.C
small cleanup, doxygen, formatting changes
[lyx.git] / src / mathed / math_parinset.C
index a676e9ebadd6114aff962705041d7fd4a3b3f172..4501f22ca25cc1a47418ed84634b4a54a829b2a5 100644 (file)
@@ -10,6 +10,7 @@
 #include "math_parser.h"
 #include "math_rowst.h"
 #include "math_parinset.h"
+#include "debug.h"
 
 using std::endl;
 
@@ -41,7 +42,7 @@ MathParInset::MathParInset(MathParInset * p)
        flag = p->flag;
        p->setArgumentIdx(0);
        MathedIter it(p->GetData());
-       SetData(it.Copy());
+       setData(it.Copy());
 }
 
 
@@ -61,7 +62,7 @@ MathedInset * MathParInset::Clone()
 }
 
 
-void MathParInset::SetData(MathedArray * a)
+void MathParInset::setData(MathedArray * a)
 {
        array = a;
        
@@ -84,10 +85,12 @@ MathParInset::draw(Painter & pain, int x, int y)
 {
        byte cxp = 0;
        int xp = 0;
-       int asc = df_asc, des = 0;
+       int asc = df_asc;
+       int des = 0;
        bool limits = false;
        
-       xo = x;  yo = y; 
+       xo_ = x;
+       yo_ = y; 
        if (!array || array->empty()) {
                if (array) {
                        MathedXIter data(this);
@@ -103,8 +106,8 @@ MathParInset::draw(Painter & pain, int x, int y)
                byte cx = data.GetChar();
                if (cx >= ' ') {
                        string s = data.GetString();
-                       drawStr(pain, data.FCode(), size, x, y, s);
-                       mathed_char_height(LM_TC_CONST, size, 'y', asc, des);
+                       drawStr(pain, data.FCode(), size(), x, y, s);
+                       mathed_char_height(LM_TC_CONST, size(), 'y', asc, des);
                        limits = false;
                }
                else {
@@ -194,15 +197,16 @@ MathParInset::Metrics()
                cx = data.GetChar();      
                if (cx >= ' ') {
                        string s = data.GetString();
-                       mathed_string_height(data.FCode(), size, s, asc, des);
+                       mathed_string_height(data.FCode(),
+                                            size(), s, asc, des);
                        if (asc > ascent) ascent = asc;
                        if (des > descent) descent = des;
                        limits = false;
-                       mathed_char_height(LM_TC_CONST, size, 'y', asc, des);
+                       mathed_char_height(LM_TC_CONST, size(), 'y', asc, des);
                } else
                        if (MathIsInset(cx)) {
                                MathedInset * p = data.GetInset();
-                               p->SetStyle(size);   
+                               p->SetStyle(size());   
                                p->Metrics();
                                if (cx == LM_TC_UP) {
                                        asc += (limits) ? p->Height() + 4: p->Ascent() + 
@@ -282,14 +286,14 @@ void MathParInset::Write(ostream & os, bool fragile)
 {
        if (!array) return;
        int brace = 0;
-       latexkeys * l;
+       latexkeys const * l;
        MathedIter data(array);
        // hack
        MathedRowSt const * crow = getRowSt();   
        data.Reset();
        
        if (!Permit(LMPF_FIXED_SIZE)) { 
-               l = lm_get_key_by_id(size, LM_TK_STY);
+               l = lm_get_key_by_id(size(), LM_TK_STY);
                if (l) {
                        os << '\\' << l->name << ' ';
                }
@@ -392,3 +396,58 @@ 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);
+    }
+}
+
+
+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;
+}