]> git.lyx.org Git - lyx.git/blobdiff - src/insets/inseterror.C
clear()->erase() ; lots of using directives for cxx
[lyx.git] / src / insets / inseterror.C
index 61afb4717ab9fc27cf71cc58446d7d20332468c4..b1a879cfaa531a2959cc8b80029722a9af58f07a 100644 (file)
@@ -4,7 +4,7 @@
  *           LyX, The Document Processor
  *      
  *         Copyright 1995 Matthias Ettrich
- *          Copyright 1995-1999 The LyX Team.
+ *          Copyright 1995-2000 The LyX Team.
  *
  * ====================================================== */
 
 #endif
 
 #include "inseterror.h"
-#include "lyxdraw.h"
 #include "gettext.h"
 #include "lyx_gui_misc.h" // CancelCloseBoxCB
+#include "Painter.h"
+#include "font.h"
+
+using std::ostream;
 
 /* Error, used for the LaTeX-Error Messages */
 
@@ -26,6 +29,7 @@ InsetError::InsetError()
        form = 0;
 }
 
+
 InsetError::InsetError(string const & str)
        : contents(str)
 {
@@ -43,79 +47,83 @@ InsetError::~InsetError()
 }
 
 
-int InsetError::Ascent(LyXFont const & font) const
+int InsetError::ascent(Painter &, LyXFont const & font) const
 {
        LyXFont efont;
        efont.setSize(font.size()).decSize();
-       return efont.maxAscent()+1;
+       return lyxfont::maxAscent(efont) + 1;
 }
 
 
-int InsetError::Descent(LyXFont const & font) const
+int InsetError::descent(Painter &, LyXFont const & font) const
 {
        LyXFont efont;
        efont.setSize(font.size()).decSize();
-       return efont.maxDescent()+1;
+       return lyxfont::maxDescent(efont) + 1;
 }
 
 
-int InsetError::Width(LyXFont const & font) const
+int InsetError::width(Painter &, LyXFont const & font) const
 {
        LyXFont efont;
        efont.setSize(font.size()).decSize();
-       return 6 + efont.textWidth(_("Error"), strlen(_("Error")));
+       return 6 + lyxfont::width(_("Error"), efont);
 }
 
 
-void InsetError::Draw(LyXFont font, LyXScreen & scr,
-                     int baseline, float & x)
+void InsetError::draw(Painter & pain, LyXFont const & font,
+                     int baseline, float & x) const
 {
        LyXFont efont;
        efont.setSize(font.size()).decSize();
-       efont.setLatex(LyXFont::ON);
+       efont.setColor(LColor::error);
    
        // Draw as "Error" in a framed box
        x += 1;
-       scr.fillRectangle(gc_lighted,
-                         int(x), baseline - Ascent(font)+1,
-                         Width(font)-2, Ascent(font)+ Descent(font)-2);
-       scr.drawRectangle(gc_foot,
-                         int(x), baseline-Ascent(font)+1,
-                         Width(font)-2, Ascent(font)+Descent(font)-2); 
-       scr.drawString(efont, _("Error"), baseline, int(x+2));
+       pain.fillRectangle(int(x), baseline - ascent(pain, font) + 1,
+                         width(pain, font) - 2,
+                         ascent(pain, font) + descent(pain, font) - 2,
+                          LColor::insetbg);
+       pain.rectangle(int(x), baseline - ascent(pain, font) + 1,
+                      width(pain, font) - 2,
+                      ascent(pain, font) + descent(pain, font) - 2,
+                      LColor::error);
+       pain.text(int(x + 2), baseline, _("Error"), efont);
 
-       x +=  Width(font) - 1;
+       x +=  width(pain, font) - 1;
 }
 
 
-void InsetError::Write(FILE *)
+void InsetError::Write(ostream &) const
 {
 }
 
+
 void InsetError::Read(LyXLex &)
 {
 }
 
 
-int InsetError::Latex(FILE *, signed char /*fragile*/)
+int InsetError::Latex(ostream &,
+                     bool /*fragile*/, bool /*fs*/) const
 {
        return 0;
 }
 
 
-int InsetError::Latex(string &, signed char /*fragile*/)
+int InsetError::Ascii(ostream &) const
 {
        return 0;
 }
 
 
-int InsetError::Linuxdoc(string &)
+int InsetError::Linuxdoc(ostream &) const
 {
        return 0;
 }
 
 
-int InsetError::DocBook(string &)
+int InsetError::DocBook(ostream &) const
 {
        return 0;
 }
@@ -127,9 +135,9 @@ bool InsetError::AutoDelete() const
 }
 
 
-unsigned char InsetError::Editable() const
+Inset::EDITABLE InsetError::Editable() const
 {
-       return 1;
+       return IS_EDITABLE;
 }
 
 
@@ -151,7 +159,13 @@ extern "C" void C_InsetError_CloseErrorCB(FL_OBJECT * ob, long data)
 }
 
 
-void InsetError::Edit(int, int)
+char const * InsetError::EditMessage() const 
+{
+       return _("Opened error");
+}
+
+
+void InsetError::Edit(BufferView *, int, int, unsigned int)
 {
        static int ow = 400, oh = 240;
 
@@ -181,8 +195,7 @@ void InsetError::Edit(int, int)
 }
 
 
-Inset * InsetError::Clone()
+Inset * InsetError::Clone() const
 {
-       InsetError * result = new InsetError(contents);
-       return result;
+       return new InsetError(contents);
 }