]> git.lyx.org Git - features.git/blobdiff - src/mathed/math_inset.h
apply the ostream changes to mathed, some other small related things
[features.git] / src / mathed / math_inset.h
index 6497d698edd0bdf9e3feb42d9dd57eddccdc95ad..1deccae3228ad4873bc4d1175be7fa620c5c234a 100644 (file)
@@ -26,7 +26,6 @@
 #pragma interface
 #endif
 
-#include <stdio.h>
 #include "math_defs.h"
 #include "symbol_def.h"
 #include "LString.h"
 class MathFuncInset: public MathedInset  {
 public:
        ///
-   MathFuncInset(char const *nm, short ot= LM_OT_FUNC, short st= LM_ST_TEXT);
+       MathFuncInset(char const * nm,
+                     short ot = LM_OT_FUNC, short st = LM_ST_TEXT);
        ///
-   ~MathFuncInset();
+       ~MathFuncInset();
        ///
-   MathedInset *Clone();
+       MathedInset * Clone();
        ///
-   void Draw(int, int);
+       void draw(Painter &, int, int);
        ///
-   void Write(FILE *file);
+       void Write(ostream &);
+#ifndef USE_OSTREAM_ONLY
        ///
-   void Write(string &file);
+       void Write(string & file);
+#endif
        ///
-   void Metrics();
+       void Metrics();
        ///
-   inline bool GetLimits() const;
+       inline bool GetLimits() const;
 protected:
        ///
-   int ln;
+       int ln;
        ///
-   bool lims;
+       bool lims;
        ///
-   char *fname;
+       char * fname;
 };
 
 
 /// Accents
 class MathAccentInset: public MathedInset {
- public:
+public:
        ///
-   MathAccentInset(byte, MathedTextCodes, int, short st= LM_ST_TEXT);
+       MathAccentInset(byte, MathedTextCodes, int, short st = LM_ST_TEXT);
        ///
-   MathAccentInset(MathedInset *, int, short st= LM_ST_TEXT);
+       MathAccentInset(MathedInset *, int, short st = LM_ST_TEXT);
        ///
-   ~MathAccentInset();
+       ~MathAccentInset();
        ///
-   MathedInset *Clone();
+       MathedInset * Clone();
        ///
-   void Draw(int, int);
+       void draw(Painter &, int, int);
        ///
-   void Write(FILE *file);
+       void Write(ostream &);
+#ifndef USE_OSTREAM_ONLY
        ///
-   void Write(string &file);
+       void Write(string & file);
+#endif
        ///
-   void Metrics();
+       void Metrics();
        ///
-   int getAccentCode() const { return code; }
-
- protected:
+       int getAccentCode() const { return code; }
+       
+protected:
        ///
-   byte c;
+       byte c;
        ///
-   MathedTextCodes fn;
+       MathedTextCodes fn;
        ///
-   int code;
+       int code;
        ///
-   MathedInset *inset;
+       MathedInset * inset;
        ///
-   int dh, dy;
+       int dh, dy;
 };
 
 
 ///
 class MathDotsInset: public MathedInset {
- public:
-       ///
-   MathDotsInset(char const*, int, short st= LM_ST_TEXT);
+public:
        ///
-   ~MathDotsInset() { };
+       MathDotsInset(char const *, int, short st = LM_ST_TEXT);
        ///
-   MathedInset *Clone();
+       MathedInset * Clone();
        ///
-   void Draw(int, int);
+       void draw(Painter &, int, int);
        ///
-   void Write(FILE *file);
+       void Write(ostream &);
+#ifndef USE_OSTREAM_ONLY
        ///
-   void Write(string &file);
+       void Write(string & file);
+#endif
        ///
-   void Metrics();
- protected:
+       void Metrics();
+protected:
        ///
-   int dh, code;
+       int dh, code;
 };   
 
 
 /// Smart spaces
 class MathSpaceInset: public MathedInset  {
- public:
-       ///
-   MathSpaceInset(int sp, short ot= LM_OT_SPACE, short st= LM_ST_TEXT);
+public:
        ///
-   ~MathSpaceInset() { };
+       MathSpaceInset(int sp, short ot = LM_OT_SPACE, short st = LM_ST_TEXT);
        ///
-   MathedInset *Clone();
+       MathedInset * Clone();
        ///
-  void Draw(int, int);
+       void draw(Painter &, int, int);
        ///
-   void Write(FILE *file);
+       void Write(ostream &);
+#ifndef USE_OSTREAM_ONLY
        ///
-   void Write(string &file);
+       void Write(string & file);
+#endif
        ///
-   inline void Metrics();
+       inline void Metrics();
        ///
-   inline void SetSpace(int sp);
+       inline void SetSpace(int sp);
        ///
-   int GetSpace() { return space; }
- protected:
+       int GetSpace() { return space; }
+protected:
        ///
-   int space;
+       int space;
 };
 
 
 /// big operators
 class MathBigopInset: public MathedInset {
- public:
-       ///
-   MathBigopInset(char const*, int, short st= LM_ST_TEXT);
+public:
        ///
-   ~MathBigopInset() { };
+       MathBigopInset(char const *, int, short st = LM_ST_TEXT);
        ///
-   MathedInset *Clone();
+       MathedInset * Clone();
        ///
-   void Draw(int, int);
+       void draw(Painter &, int, int);
        ///
-   void Write(FILE *file);
+       void Write(ostream &);
+#ifndef USE_OSTREAM_ONLY
        ///
-   void Write(string &file);
+       void Write(string & file);
+#endif
        ///
-   void Metrics();
+       void Metrics();
        ///
-   inline bool GetLimits() const;
+       inline bool GetLimits() const;
        ///
-   inline void SetLimits(bool);
- protected:
+       inline void SetLimits(bool);
+protected:
        ///
-   int lims;
+       int lims;
        ///
-   int sym;   
+       int sym;   
 };
 
  
@@ -182,131 +186,132 @@ class MathBigopInset: public MathedInset {
 
 ///
 class MathSqrtInset: public MathParInset {
- public:
-    ///
-    MathSqrtInset(short st= LM_ST_TEXT);
-    ///
-    ~MathSqrtInset() { };
-    ///
-    MathedInset *Clone();
-    ///
-    void Draw(int x, int baseline);
-    ///
-    void Write(FILE *file);
-    ///
-    void Write(string &file);
-    ///
-    void Metrics();
-    ///
-    bool Inside(int, int);
-    
- private:
-    ///
-   int hmax, wbody;
+public:
+       ///
+       MathSqrtInset(short st = LM_ST_TEXT);
+       ///
+       MathedInset * Clone();
+       ///
+       void draw(Painter &, int x, int baseline);
+       ///
+       void Write(ostream &);
+#ifndef USE_OSTREAM_ONLY
+       ///
+       void Write(string & file);
+#endif
+       ///
+       void Metrics();
+       ///
+       bool Inside(int, int);
+private:
+       ///
+       int hmax, wbody;
 };
 
 
 /// Fraction like objects (frac, stackrel, binom) 
 class MathFracInset: public MathParInset {
- public:
+public:
+       ///
+       MathFracInset(short ot = LM_OT_FRAC);
        ///
-    MathFracInset(short ot= LM_OT_FRAC);
+       ~MathFracInset();
        ///
-    ~MathFracInset();
+       MathedInset * Clone();
        ///
-    MathedInset *Clone();
+       void draw(Painter &, int x, int baseline);
        ///
-    void Draw(int x, int baseline);
+       void Write(ostream &);
+#ifndef USE_OSTREAM_ONLY
        ///
-    void Write(FILE *file);
+       void Write(string & file);
+#endif
        ///
-    void Write(string &file);
+       void Metrics();
+       
+       /** This does the same that SetData(LyxArrayBase*) but for both
+           numerator and denominator at once.
+       */
+       void SetData(LyxArrayBase *, LyxArrayBase *);
        ///
-    void Metrics();
-    /** This does the same that SetData(LyxArrayBase*) but for both
-         numerator and denominator at once.
-     */
-    void SetData(LyxArrayBase*, LyxArrayBase*);
+       void SetData(LyxArrayBase *);
+       ///
+       void GetXY(int & x, int & y) const;
+       ///
+       void SetFocus(int, int);
+       ///
+       bool Inside(int, int);
        ///
-    void SetData(LyxArrayBase*);
+       LyxArrayBase * GetData();
        ///
-    void GetXY(int& x, int& y) const;
+       bool setArgumentIdx(int i); // was bool Up/down(void);
        ///
-    void SetFocus(int, int);
-    ///
-    bool Inside(int, int);
-    ///
-    LyxArrayBase * GetData();
-    ///
-    bool setArgumentIdx(int i); // was bool Up/down(void);
-    ///
-    int  getArgumentIdx() { return (int)idx; }
-    ///
-    int  getMaxArgumentIdx() { return 1; }
+       int  getArgumentIdx() { return int(idx); }
        ///
-    void  SetStyle(short);
- protected:
+       int  getMaxArgumentIdx() { return 1; }
        ///
-    short idx;
+       void  SetStyle(short);
+protected:
+       ///
+       short idx;
        ///
-    MathParInset *den;
+       MathParInset * den;
        ///
-    int w0, w1, des0, dh;
+       int w0, w1, des0, dh;
 };
 
 
 /// A delimiter
 class MathDelimInset: public MathParInset {
- public:
-       ///
-   MathDelimInset(int, int, short st= LM_ST_TEXT);
+public:
        ///
-   ~MathDelimInset() { };
+       MathDelimInset(int, int, short st = LM_ST_TEXT);
        ///
-   MathedInset *Clone();
+       MathedInset * Clone();
        ///
-   void Draw(int, int);
+       void draw(Painter &, int, int);
        ///
-   void Write(FILE *file);
+       void Write(ostream &);
+#ifndef USE_OSTREAM_ONLY
        ///
-   void Write(string &file);
+       void Write(string & file);
+#endif
        ///
-   void Metrics();
- protected:
+       void Metrics();
+protected:
        ///
-   int left, right;
+       int left, right;
        ///
-   int dw, dh;
+       int dw, dh;
 };
 
 
 /// Decorations over (below) a math object
 class MathDecorationInset: public MathParInset {
- public:
-       ///
-   MathDecorationInset(int, short st= LM_ST_TEXT);
+public:
        ///
-   ~MathDecorationInset() { };
+       MathDecorationInset(int, short st = LM_ST_TEXT);
        ///
-   MathedInset *Clone();
+       MathedInset * Clone();
        ///
-   void Draw(int, int);
+       void draw(Painter &, int, int);
        ///
-   void Write(FILE *file);
+       void Write(ostream &);
+#ifndef USE_OSTREAM_ONLY
        ///
-   void Write(string &file);
+       void Write(string & file);
+#endif
        ///
-   void Metrics();
+       void Metrics();
        ///
-   inline bool GetLimits() const;
- protected:
+       inline bool GetLimits() const;
+protected:
        ///
-   int deco;
+       int deco;
        ///
-   bool upper;
+       bool upper;
        ///
-   int dw, dh, dy;
+       int dw, dh, dy;
 };
 
 
@@ -319,36 +324,43 @@ MathFuncInset::~MathFuncInset()
     if (fname && GetType() == LM_OT_UNDEF) delete[] fname;
 }
 
+
 inline
 bool MathFuncInset::GetLimits() const 
 {  
-   return (bool)(lims && (GetStyle() == LM_ST_DISPLAY)); 
+   return bool(lims && (GetStyle() == LM_ST_DISPLAY)); 
 } 
 
+
 inline
-void MathFuncInset::Write(FILE *file)
+void MathFuncInset::Write(ostream & os)
 {
-   fprintf(file, "\\%s ", name);
+       os << "\\" << name << ' ';
 }
 
+
+#ifndef USE_OSTREAM_ONLY
 inline
-void MathFuncInset::Write(string &file)
+void MathFuncInset::Write(string & file)
 {
    file += '\\';
    file += name;
    file += ' ';
 }
+#endif
+
 
 inline
 void MathSpaceInset::Metrics()
 {
-   width = (space) ? space*2: 2;
-   if (space>3) width *= 2;
+   width = space ? space * 2 : 2;
+   if (space > 3) width *= 2;
    if (space == 5) width *= 2;
    width += 4;
    ascent = 4; descent = 0;
 }
 
+
 inline
 void MathSpaceInset::SetSpace(int sp)
 { 
@@ -356,30 +368,31 @@ void MathSpaceInset::SetSpace(int sp)
    Metrics();
 }    
 
+
 inline
 bool MathBigopInset::GetLimits() const 
 {  
     // Default case
-    if (lims<0) {
-       return (bool)(sym!= LM_int && sym!= LM_oint && (GetStyle() == LM_ST_DISPLAY));
+    if (lims < 0) {
+       return sym != LM_int && sym != LM_oint && GetStyle() == LM_ST_DISPLAY;
     } 
     
     // Custom 
-    return (bool)(lims>0);
+    return lims > 0;
 } 
 
+
 inline
 void MathBigopInset::SetLimits(bool ls) 
 {  
-    lims = (ls) ? 1: 0; 
+    lims = ls ? 1 : 0; 
 } 
 
+
 inline
 bool MathDecorationInset::GetLimits() const
 { 
-   return (bool)(deco == LM_underbrace||deco == LM_overbrace);
+   return deco == LM_underbrace || deco == LM_overbrace;
 }    
 
-
 #endif
-