* LyX, The Document Processor
*
* Copyright 1995 Matthias Ettrich
- * Copyright 1995-1999 The LyX Team.
+ * Copyright 1995-2000 The LyX Team.
*
- * ======================================================*/
+ * ====================================================== */
#include <config.h>
#pragma implementation
#endif
-#include "definitions.h"
#include "inseterror.h"
-#include "lyxdraw.h"
#include "gettext.h"
#include "lyx_gui_misc.h" // CancelCloseBoxCB
+#include "Painter.h"
+#include "BufferView.h"
+#include "font.h"
+
+using std::ostream;
/* Error, used for the LaTeX-Error Messages */
+#if 0
InsetError::InsetError()
{
form = 0;
}
+#endif
-InsetError::InsetError(string const & string)
- : contents(string)
-{
- form = 0;
-}
+
+InsetError::InsetError(string const & str)
+ : contents(str), form(0)
+{}
InsetError::~InsetError()
}
-int InsetError::Ascent(LyXFont const &font) const
+int InsetError::ascent(BufferView *, 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(BufferView *, 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(BufferView *, 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(BufferView * bv, LyXFont const & font,
+ int baseline, float & x, bool) const
{
+ Painter & pain = bv->painter();
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.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,
- Width(font)-2, Ascent(font)+Descent(font)-2);
- scr.drawString(efont, _("Error"), baseline, int(x+2));
+ pain.fillRectangle(int(x), baseline - ascent(bv, font) + 1,
+ width(bv, font) - 2,
+ ascent(bv, font) + descent(bv, font) - 2,
+ LColor::insetbg);
+ pain.rectangle(int(x), baseline - ascent(bv, font) + 1,
+ width(bv, font) - 2,
+ ascent(bv, font) + descent(bv, font) - 2,
+ LColor::error);
+ pain.text(int(x + 2), baseline, _("Error"), efont);
- x += Width(font) - 1;
+ x += width(bv, font) - 1;
}
-void InsetError::Write(FILE *)
+void InsetError::Write(Buffer const *, ostream &) const
{
}
-void InsetError::Read(LyXLex &)
+
+void InsetError::Read(Buffer const *, LyXLex &)
{
}
-int InsetError::Latex(FILE *, signed char /*fragile*/)
+int InsetError::Latex(Buffer const *, ostream &,
+ bool /*fragile*/, bool /*fs*/) const
{
return 0;
}
-int InsetError::Latex(string &, signed char /*fragile*/)
+int InsetError::Ascii(Buffer const *, ostream &) const
{
return 0;
}
-int InsetError::Linuxdoc(string &)
+int InsetError::Linuxdoc(Buffer const *, ostream &) const
{
return 0;
}
-int InsetError::DocBook(string &)
+int InsetError::DocBook(Buffer const *, ostream &) const
{
return 0;
}
}
-unsigned char InsetError::Editable() const
+Inset::EDITABLE InsetError::Editable() const
{
- return 1;
+ return IS_EDITABLE;
}
-void InsetError::CloseErrorCB(FL_OBJECT *, long data)
+void InsetError::CloseErrorCB(FL_OBJECT * ob, long)
{
- InsetError *inset = (InsetError*) data;
+ InsetError * inset = static_cast<InsetError*>(ob->u_vdata);
if (inset->form) {
fl_hide_form(inset->form);
fl_free_form(inset->form);
}
}
+
// A C wrapper
-extern "C" void C_InsetError_CloseErrorCB(FL_OBJECT *, long data)
+extern "C"
+void C_InsetError_CloseErrorCB(FL_OBJECT * ob, long data)
+{
+ InsetError::CloseErrorCB(ob , data);
+}
+
+
+char const * InsetError::EditMessage() const
{
- InsetError::CloseErrorCB(0,data);
+ return _("Opened error");
}
-void InsetError::Edit(int, int)
+void InsetError::Edit(BufferView *, int, int, unsigned int)
{
+ static int ow = 400, oh = 240;
+
if (!form) {
- FL_OBJECT *obj;
- form = fl_bgn_form(FL_UP_BOX,400,240);
- strobj = fl_add_box(FL_FRAME_BOX,10,10,380,180,"");
- fl_set_object_color(strobj,FL_MCOL,FL_MCOL);
+ FL_OBJECT * obj;
+ form = fl_bgn_form(FL_UP_BOX, ow, oh);
+ strobj = fl_add_box(FL_FRAME_BOX, 10, 10, 380, 180, "");
+ fl_set_object_color(strobj, FL_MCOL, FL_MCOL);
fl_set_object_gravity(strobj, FL_NorthWest, FL_SouthEast);
- obj = fl_add_button(FL_RETURN_BUTTON,140,200,120,30,_("Close"));
- fl_set_object_callback(obj, C_InsetError_CloseErrorCB, (long)this);
- fl_set_object_gravity(obj, FL_South, FL_South);
+ obj = fl_add_button(FL_RETURN_BUTTON, 140, 200, 120, 30,
+ _("Close"));
+ fl_set_object_callback(obj, C_InsetError_CloseErrorCB, 0);
+ obj->u_vdata = this;
+ fl_set_object_gravity(obj, FL_SouthEast, FL_SouthEast);
fl_set_object_resize(obj, FL_RESIZE_NONE);
fl_end_form();
fl_set_form_atclose(form, CancelCloseBoxCB, 0);
if (form->visible) {
fl_raise_form(form);
} else {
- fl_show_form(form,FL_PLACE_MOUSE | FL_FREE_SIZE, FL_FULLBORDER,
- _("LaTeX Error"));
+ fl_show_form(form, FL_PLACE_MOUSE | FL_FREE_SIZE,
+ FL_FULLBORDER, _("LaTeX Error"));
+ fl_set_form_minsize(form, ow, oh);
}
}
-Inset* InsetError::Clone()
+Inset * InsetError::Clone() const
{
- InsetError *result = new InsetError(contents);
- return result;
+ return new InsetError(contents);
}