]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_cursor.C
Hopefully fix the problem with stateText() in lyxfont.C
[lyx.git] / src / mathed / math_cursor.C
index 90c5beb193c46ba6639ae4aab0fee33c232326da..fe467c34458ed8e50291035bdf8079a923c18d43 100644 (file)
@@ -7,7 +7,7 @@
  *
  *  Dependencies: Xlib, XForms
  *
- *  Copyright: (c) 1996, Alejandro Aguilar Sierra
+ *  Copyright: 1996, Alejandro Aguilar Sierra
  *
  *   Version: 0.8beta, Mathed & Lyx project.
  *
 #include "LColor.h"
 #include "Painter.h"
 
-extern void mathed_set_font(short type, int style);
-
-extern GC canvasGC, mathGC, latexGC, cursorGC, mathFrameGC;
-
 static LyxArrayBase * selarray = 0;
 
-inline bool IsAlpha(char c)
+using std::endl;
+
+inline
+bool IsAlpha(char c)
 {
    return ('A' <= c  && c <= 'Z' || 'a' <= c  && c <= 'z');
 }
 
 // This was very smaller, I'll change it later 
-inline bool IsMacro(short tok, int id)
+inline
+bool IsMacro(short tok, int id)
 {
    return (tok != LM_TK_STACK && tok != LM_TK_FRAC && tok != LM_TK_SQRT
           && tok != LM_TK_WIDE
@@ -55,7 +55,8 @@ inline bool IsMacro(short tok, int id)
 
 
 // Yes, mathed isn't using string yet.
-inline char * strnew(char const * s)
+inline
+char * strnew(char const * s)
 {
     char * s1 = new char[strlen(s)+1];
     strcpy(s1, s);
@@ -151,7 +152,6 @@ void MathedCursor::SetPar(MathParInset * p)
 }
 
 
-#ifdef USE_PAINTER
 void MathedCursor::draw(Painter & pain, int x, int y)
 {
        //    lyxerr << "Cursor[" << x << " " << y << "] ";
@@ -162,34 +162,13 @@ void MathedCursor::draw(Painter & pain, int x, int y)
        int h = par->Height() + 1;
        if (par->GetType() > LM_OT_PAR) { a += 4;  h += 8; }
        
-       pain.rectangle(x - 1, y - a,
-                      x - 1 + w, y - a + h,
-                      LColor::mathframe);
+       pain.rectangle(x - 1, y - a, w, h, LColor::mathframe);
        
        par->draw(pain, x, y);
        cursor->Adjust();
 }
-#else
-void MathedCursor::Draw(long unsigned pm, int x, int y)
-{
-//    lyxerr << "Cursor[" << x << " " << y << "] ";
-    win = pm;    // win = (mathedCanvas) ? mathedCanvas: pm;
-    par->Metrics();
-    int w = par->Width()+2, a = par->Ascent()+1, h = par->Height()+1;
-    if (par->GetType() > LM_OT_PAR) { a += 4;  h += 8; }
-    
-   if (!canvasGC) mathed_set_font(LM_TC_VAR, 1);
-    //   XFillRectangle(fl_display, pm, canvasGC, x, y-a, w, h);
-    XDrawRectangle(fl_display, pm, mathFrameGC, x - 1, y - a, w, h);
-    XFlush(fl_display);
-    MathParInset::pm = pm;
-    par->Draw(x, y);
-    cursor->Adjust();
-}
-#endif
 
 
-#ifdef USE_PAINTER
 void MathedCursor::Redraw(Painter & pain)
 {  
        lyxerr[Debug::MATHED] << "Mathed: Redrawing!" << endl;
@@ -203,21 +182,6 @@ void MathedCursor::Redraw(Painter & pain)
                           LColor::mathbg);
        par->draw(pain, x, y);
 }
-#else
-void MathedCursor::Redraw()
-{  
-       lyxerr[Debug::MATHED] << "Mathed: Redrawing!" << endl;
-   par->Metrics();
-   int w = par->Width(), h = par->Height();
-   int x, y;
-   par->GetXY(x, y);
-   mathed_set_font(LM_TC_VAR, 1);
-   XFillRectangle(fl_display, win, canvasGC, x, y-par->Ascent(), w, h);
-   XFlush(fl_display);
-    MathParInset::pm = win;
-   par->Draw(x, y);
-}
-#endif
 
 
 bool MathedCursor::Left(bool sel)
@@ -958,16 +922,19 @@ void MathedCursor::SelBalance()
 } 
 
 
-#ifdef USE_PAINTER
-void MathedCursor::SelGetArea(int * xp, int * yp, int & np)
+void MathedCursor::SelGetArea(int ** xp, int ** yp, int & np)
 {   
+    static int xpoint[10];
+    static int ypoint[10];
+
     if (!selection) {
        np = 0;
+       xpoint[0] = 0;
+       ypoint[0] = 0;
+       *xp = &xpoint[0];
+       *yp = &ypoint[0];
        return;
     }
-
-    static int xpoint[10];
-    static int ypoint[10];
     
     // single row selection
     int i = 0, x, y, a, d, xo, yo, x1, y1, a1, d1;
@@ -1013,8 +980,8 @@ void MathedCursor::SelGetArea(int * xp, int * yp, int & np)
     xpoint[i] = xpoint[0];
     ypoint[i++] = ypoint[0];
 
-    xp = &xpoint[0];
-    yp = &ypoint[0];
+    *xp = &xpoint[0];
+    *yp = &ypoint[0];
     np = i;
 //    lyxerr << "AN[" << x << " " << y << " " << x1 << " " << y1 << "] ";
 //    lyxerr << "MT[" << a << " " << d << " " << a1 << " " << d1 << "] ";
@@ -1022,67 +989,6 @@ void MathedCursor::SelGetArea(int * xp, int * yp, int & np)
 //      lyxerr << "XY[" << point[i].x << " " << point[i].y << "] ";
     
 }
-#else
-XPoint * MathedCursor::SelGetArea(int & np)
-{   
-    if (!selection) {
-       np = 0;
-       return 0;
-    }
-    
-    static XPoint point[10];
-    
-    // single row selection
-    int i = 0, x, y, a, d, xo, yo, x1, y1, a1, d1; //, p1, p2;
-
-    // Balance anchor and cursor
-    SelBalance();
-    cursor->p->GetXY(xo, yo);
-    int w = cursor->p->Width();
-    cursor->GetPos(x1, y1);
-    cursor->getAD(a1, d1);
-    anchor->GetPos(x, y);
-    anchor->getAD(a, d);
-
-    point[i].x = x;
-    point[i++].y = y+d;
-    point[i].x = x;
-    point[i++].y = y-a;
-    
-    if (y != y1) {
-       point[i].x = xo + w;
-       point[i++].y = y - a;
-       if (x1 < xo + w) {
-           point[i].x = xo + w;
-           point[i++].y = y1 - a;
-       }
-    }
-       
-    point[i].x = x1;
-    point[i++].y = y1 - a;
-    point[i].x = x1;
-    point[i++].y = y1 + d;
-    
-    if (y != y1) {
-       point[i].x = xo;
-       point[i++].y = y1 + d;
-       if (x > xo) {
-           point[i].x = xo;
-           point[i++].y = y + d;
-       }
-    }
-    point[i].x = point[0].x;
-    point[i++].y = point[0].y;
-    np = i;
-//    lyxerr << "AN[" << x << " " << y << " " << x1 << " " << y1 << "] ";
-//    lyxerr << "MT[" << a << " " << d << " " << a1 << " " << d1 << "] ";
-//    for (i = 0; i < np; ++i)
-//      lyxerr << "XY[" << point[i].x << " " << point[i].y << "] ";
-    
-    return &point[0];
-}
-#endif
 
 
 void MathedCursor::setAccent(int ac)