]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insetlatex.C
clear()->erase() ; lots of using directives for cxx
[lyx.git] / src / insets / insetlatex.C
index f5232c1b4062d5a031bb3dcdefe2afcf64156c92..38175672a3d622c6d279a7d054c341b70cdfc86f 100644 (file)
@@ -1,12 +1,12 @@
 /* This file is part of
- * ======================================================
+ * ====================================================== 
  * 
  *           LyX, The Document Processor
  *      
- *         Copyright (C) 1995 Matthias Ettrich
- *          Copyright (C) 1995-1998 The LyX Team.
+ *         Copyright 1995 Matthias Ettrich
+ *          Copyright 1995-1999 The LyX Team.
  *
- *======================================================*/
+ * ====================================================== */
 
 #include <config.h>
 
 #pragma implementation
 #endif
 
-#include "definitions.h"
 #include "insetlatex.h"
 #include "lyxdraw.h"
 
-//     $Id: insetlatex.C,v 1.1 1999/09/27 18:44:39 larsbj Exp $        
-
-#if !defined(lint) && !defined(WITH_WARNINGS)
-static char vcid[] = "$Id: insetlatex.C,v 1.1 1999/09/27 18:44:39 larsbj Exp $";
-#endif /* lint */
-
 /* Latex. Used to insert Latex-Code automatically */
 
 
@@ -32,7 +25,7 @@ InsetLatex::InsetLatex()
 }
 
 
-InsetLatex::InsetLatex(LString const & string)
+InsetLatex::InsetLatex(string const & string)
        : contents(string)
 {
 }
@@ -43,26 +36,26 @@ InsetLatex::~InsetLatex()
 }
 
 
-int InsetLatex::Ascent(LyXFont const &font) const
+int InsetLatex::Ascent(LyXFont const & font) const
 {
        return font.maxAscent() + 1;
 }
 
 
-int InsetLatex::Descent(LyXFont const &font) const
+int InsetLatex::Descent(LyXFont const & font) const
 {
        return font.maxDescent() + 1;
 }
 
 
-int InsetLatex::Width(LyXFont const &font) const
+int InsetLatex::Width(LyXFont const & font) const
 {
        return 6 + font.stringWidth(contents);
 }
 
 
-void InsetLatex::Draw(LyXFont font, LyXScreen &scr,
-                     int baseline, float &x)
+void InsetLatex::Draw(LyXFont font, LyXScreen & scr,
+                     int baseline, float & x)
 {
        // Latex-insets are always LaTeX, so just correct the font */ 
        font.setLatex(LyXFont::ON);
@@ -70,16 +63,10 @@ void InsetLatex::Draw(LyXFont font, LyXScreen &scr,
        // Draw it as a box with the LaTeX text
        x += 1;
 
-       //scr.drawFilledRectangle(int(x), baseline - Ascent(font) + 1,
-       //           Width(font)-2, Ascent(font) + Descent(font)-2,
-       //           FL_GRAY80);
        scr.fillRectangle(gc_lighted, int(x), baseline - Ascent(font) +1 ,
                          Width(font) - 2, Ascent(font) + Descent(font) -2);
        
-       //scr.drawRectangle(int(x), baseline - Ascent(font) + 1,
-       //           Width(font)-2, Ascent(font)+Descent(font)-2,
-       //           FL_RED);
-       scr.drawRectangle(gc_foot,int(x), baseline - Ascent(font) + 1,
+       scr.drawRectangle(gc_foot, int(x), baseline - Ascent(font) + 1,
                          Width(font)-2, Ascent(font)+Descent(font)-2);
        
        scr.drawString(font, contents, baseline, int(x+2));
@@ -87,49 +74,53 @@ void InsetLatex::Draw(LyXFont font, LyXScreen &scr,
 }
 
 
-void InsetLatex::Write(FILE *file)
+void InsetLatex::Write(FILE * file)
 {
        fprintf(file, "Latex %s\n", contents.c_str());
 }
 
 
-void InsetLatex::Read(LyXLex &lex)
+void InsetLatex::Read(LyXLex & lex)
 {
-       FILE *file = lex.getFile();
-       int i = 0;
-       char c='\0';
-       char tmp[100];
+       FILE * file = lex.getFile();
+       char c = 0;
+       string tmp;
        while (!feof(file) && (c = fgetc(file)) != '\n') {
-               tmp[i]=c;
-               i++;
+               tmp += char(c);
        }
-       tmp[i]='\0';
        contents = tmp;
 }
 
 
-int InsetLatex::Latex(FILE *file, signed char /*fragile*/)
+int InsetLatex::Latex(FILE * file, signed char /*fragile*/, bool /*fs*/)
 {
        fprintf(file, "%s", contents.c_str());
        return 0;
 }
 
 
-int InsetLatex::Latex(LString &file, signed char /*fragile*/)
+int InsetLatex::Latex(string & file, signed char /*fragile*/, bool /*fs*/)
+{
+       file += contents;
+       return 0;
+}
+
+
+int InsetLatex::Ascii(string & file)
 {
        file += contents;
        return 0;
 }
 
 
-int InsetLatex::Linuxdoc(LString &file)
+int InsetLatex::Linuxdoc(string & file)
 {
        file += contents;
        return 0;
 }
 
 
-int InsetLatex::DocBook(LString &file)
+int InsetLatex::DocBook(string & file)
 {
        file += contents;
        return 0;
@@ -142,9 +133,9 @@ bool InsetLatex::Deletable() const
 }
 
 
-Inset* InsetLatex::Clone()
+InsetLatex * InsetLatex::Clone() const
 {
-       InsetLatex *result = new InsetLatex(contents);
+       InsetLatex * result = new InsetLatex(contents);
        return result;
 }