]> git.lyx.org Git - features.git/blobdiff - src/mathed/math_defs.h
make doc++ able to generate the source documentation for lyx
[features.git] / src / mathed / math_defs.h
index 669de5783cbd51522475cbed51c14d1dfe34ca35..bebf604dafddadf50199ebf0953b803004ef3767 100644 (file)
@@ -8,7 +8,7 @@
  *
  *  Dependencies: Xlib
  *
- *  Copyright: (c) 1996, 1997 Alejandro Aguilar Sierra
+ *  Copyright: 1996, 1997 Alejandro Aguilar Sierra
  *
  *   Version: 0.8beta, Mathed & Lyx project.
  *
 #pragma interface
 #endif
 
-#include <cstdio>
+#include <iosfwd>
+
 #include "LString.h"
 #include "debug.h"
 
 #include "array.h"
 
+class Painter;
 
 ///
 enum math_align {
@@ -140,7 +142,8 @@ enum MathedTextCodes  {
        LM_TC_MAX
 };
 
-ostream & operator<<(ostream &, MathedTextCodes mtc);
+///
+std::ostream & operator<<(std::ostream &, MathedTextCodes mtc);
 
 ///
 #define LM_TC_NORMAL LM_TC_VAR
@@ -220,19 +223,17 @@ class MathedInset  {
     /// A math inset has a name (usually its LaTeX name), type and font-size
     MathedInset(char const * nm, short ot, short st);
     ///
+    explicit
     MathedInset(MathedInset *);
     ///
     virtual ~MathedInset() {}
-    
-    /// Draw the object 
-    virtual void Draw(int x, int baseline) = 0;
 
-    /// Write LaTeX and Lyx code
-    virtual void Write(ostream &) = 0;
+    /// Draw the object
+    virtual void draw(Painter &, int x, int baseline) = 0;     
 
     /// Write LaTeX and Lyx code
-    virtual void Write(string & file) = 0;
-   
+    virtual void Write(std::ostream &, bool fragile) = 0;
+
     /// Reproduces itself
     virtual MathedInset * Clone() = 0;
    
@@ -266,9 +267,6 @@ class MathedInset  {
     virtual void  SetStyle(short st) { size = st; } // Metrics();
     ///
     virtual void  SetName(char const * n) { name = n; }
-    /// 
-    void setDrawable(long unsigned int d) { pm = d; }
  protected:
     ///
     char const * name;
@@ -282,17 +280,17 @@ class MathedInset  {
     int descent;
     ///
     short size;
-    /// This works while only one process can draw unless
-    /// the process have their own data
-    static long unsigned int pm;
     /// Default metrics
-    static int df_asc, df_des, df_width;
-
+    static int df_asc;
+    ///
+    static int df_des;
+    ///
+    static int df_width;
     /// In a near future maybe we use a better fonts renderer than X
-    void drawStr(short, int, int, int, byte *, int);
-       ///
+    void drawStr(Painter &, short, int, int, int, byte const *, int);
+    ///
     friend class MathedCursor;
-       ///
+    ///
     friend void mathed_init_fonts();
 };
 
@@ -324,6 +322,7 @@ class MathParInset: public MathedInset  {
     MathParInset(short st = LM_ST_TEXT, char const * nm = 0,
                 short ot = LM_OT_MIN);
     ///
+    explicit
     MathParInset(MathParInset *);
     ///
     virtual ~MathParInset();
@@ -331,13 +330,11 @@ class MathParInset: public MathedInset  {
     virtual MathedInset * Clone();
 
     /// Draw the object on a drawable
-    virtual void Draw(int x, int baseline);
+    virtual void draw(Painter &, int x, int baseline);
 
     /// Write LaTeX code
-    virtual void Write(ostream &);
+    virtual void Write(std::ostream &, bool fragile);
 
-    /// Write LaTeX code
-    virtual void Write(string & file);
     ///
     virtual void Metrics();
     ///
@@ -387,43 +384,46 @@ class MathParInset: public MathedInset  {
 //    virtual void SetLabel(char const *) {}
     ///
     virtual void SetStyle(short);
-       ///
+    ///
     virtual MathedRowSt * getRowSt() const { return 0; }
-       ///
+    ///
     virtual void setRowSt(MathedRowSt *) {}
-       ///
+    ///
     virtual bool Permit(short f) { return bool(f & flag); }
     
  protected:
     /// Paragraph data is stored here
     LyxArrayBase * array;
     /// Cursor start position
-    int xo, yo;
+    int xo;
+    ///
+    int yo;
     /// 
     short flag;
 
  private:
     ///
     virtual void setFlag(MathedParFlag f) { flag |= f; }
-       ///
+    ///
     friend class InsetFormula;
-       ///
+    ///
     friend class MathedXIter;
-       ///
+    ///
     friend class MathedCursor;
-       ///
+    ///
     friend LyxArrayBase * mathed_parse(unsigned flags = 0,
                                       LyxArrayBase * a = 0,
                                       MathParInset ** p = 0);
 };
 
 
-/* The physical structure of a row and aditional information is stored here.
+/** The physical structure of a row and aditional information is stored here.
     It allows to manage the extra info independently of the paragraph data.  
     Only used for multiline paragraphs.
  */
 struct MathedRowSt {    
-    /// 
+    ///
+    explicit
     MathedRowSt(int n) {
            w = new int[n + 1]; // this leaks
            asc = desc = y = 0;
@@ -435,8 +435,8 @@ struct MathedRowSt {
     }
     ///
     ~MathedRowSt() {
-       delete[] w;
-       if (label) delete[] label;
+           delete[] w;
+           delete[] label;
     }
     /// Should be const but...
     MathedRowSt * getNext() const  { return next; }
@@ -468,9 +468,9 @@ struct MathedRowSt {
     bool numbered;
     ///
     MathedRowSt * next;
-       ///
+    ///
     friend class MathMatrixInset;
-       ///
+    ///
     friend class MathedXIter;
 };
 
@@ -482,19 +482,19 @@ struct MathedRowSt {
 class MathMatrixInset: public MathParInset {
  public: 
     ///
+    explicit
     MathMatrixInset(int m = 1, int n = 1, short st = LM_ST_TEXT);
     ///
+    explicit
     MathMatrixInset(MathMatrixInset *);
     ///
     MathedInset * Clone();
     ///
     virtual ~MathMatrixInset();
     ///
-    void Draw(int, int);
-    ///
-    void Write(ostream &);
+    void draw(Painter &, int, int);
     ///
-    void Write(string & file);
+    void Write(std::ostream &, bool fragile);
     ///
     void Metrics();
     ///
@@ -517,12 +517,14 @@ class MathMatrixInset: public MathParInset {
 
     /// Use this to manage the extra information independently of paragraph
     MathedRowSt * getRowSt() const { return row; }
-       ///
+    ///
     void setRowSt(MathedRowSt * r) { row = r; }
     
  protected:
     ///  Number of columns & rows
-    int nc, nr;
+    int nc;
+    ///
+    int nr;
     /// tab sizes
     int * ws;   
     /// 
@@ -541,90 +543,96 @@ class MathMatrixInset: public MathParInset {
 LyxArrayBase * mathed_parse(unsigned flags, LyxArrayBase * data,
                            MathParInset ** mt);
 ///
-void mathed_write(MathParInset *, ostream &, int *, char fragile,
-                 char const * label = 0);
-///
-//void mathed_write(MathParInset *, FILE *, int *, char fragile,
-//               char const * label = 0);
-///
-void mathed_write(MathParInset *, string &, int *, char fragile,
+void mathed_write(MathParInset *, std::ostream &, int *, bool fragile,
                  char const * label = 0);
+
 ///
-void mathed_parser_file(FILE *, int);
+void mathed_parser_file(std::istream &, int);
 ///
 int mathed_parser_lineno();
 ///
 int MathedLookupBOP(short);
 
 /************************ Inline functions ********************************/
+
 ///
-inline bool MathIsInset(short x)
+inline
+bool MathIsInset(short x)
 {
        return LM_TC_INSET <= x && x <= LM_TC_ACTIVE_INSET;
 }
 
 ///
-inline bool MathIsFont(short x)
+inline
+bool MathIsFont(short x)
 {
        return LM_TC_CONST <= x && x <= LM_TC_BSYM;
 }
 
 ///
-inline bool MathIsAlphaFont(short x)
+inline
+bool MathIsAlphaFont(short x)
 {
        return LM_TC_VAR <= x && x <= LM_TC_TEXTRM;
 }
 
 ///
-inline bool MathIsActive(short x)
+inline
+bool MathIsActive(short x)
 {
        return LM_TC_INSET < x && x <= LM_TC_ACTIVE_INSET;
 }
 
 ///
-inline bool MathIsUp(short x)
+inline
+bool MathIsUp(short x)
 {
        return x == LM_TC_UP;
 }
 
 ///
-inline bool MathIsDown(short x)
+inline
+bool MathIsDown(short x)
 {
        return x == LM_TC_DOWN;
 }
 
 ///
-inline bool MathIsScript(short x)
+inline
+bool MathIsScript(short x)
 {
        return x == LM_TC_DOWN || x == LM_TC_UP;
 }
 
 ///
-inline bool MathIsBOPS(short x)
+inline
+bool MathIsBOPS(short x)
 {
        return MathedLookupBOP(x) > LMB_NONE;
 }
 
-
 ///
-inline bool MathIsBinary(short x)
+inline
+bool MathIsBinary(short x)
 {
     return x == LM_TC_BOP || x == LM_TC_BOPS;
 }
 
 ///
-inline bool MathIsSymbol(short x) {
+inline
+bool MathIsSymbol(short x) {
     return LM_TC_SYMB <= x && x <= LM_TC_BSYM;
 }
      
 
-inline 
+inline
 MathedInset::MathedInset(char const * nm, short ot, short st):
   name(nm), objtype(ot), size(st) 
 {
    width = ascent = descent = 0;
 }
 
+
 inline
 bool MathParInset::Inside(int x, int y) 
 {