1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
6 * Copyright 1995 Matthias Ettrich
7 * Copyright 1995-1999 The LyX Team.
9 * ====================================================== */
14 #pragma implementation
17 #include "inseterror.h"
19 #include "lyx_gui_misc.h" // CancelCloseBoxCB
22 /* Error, used for the LaTeX-Error Messages */
24 InsetError::InsetError()
30 InsetError::InsetError(string const & str)
37 InsetError::~InsetError()
47 int InsetError::ascent(Painter &, LyXFont const & font) const
50 efont.setSize(font.size()).decSize();
51 return efont.maxAscent() + 1;
55 int InsetError::descent(Painter &, LyXFont const & font) const
58 efont.setSize(font.size()).decSize();
59 return efont.maxDescent() + 1;
63 int InsetError::width(Painter &, LyXFont const & font) const
66 efont.setSize(font.size()).decSize();
67 return 6 + efont.textWidth(_("Error"), strlen(_("Error")));
71 void InsetError::draw(Painter & pain, LyXFont const & font,
72 int baseline, float & x) const
75 efont.setSize(font.size()).decSize();
76 efont.setColor(LColor::error);
78 // Draw as "Error" in a framed box
80 pain.fillRectangle(int(x), baseline - ascent(pain, font) + 1,
81 width(pain, font) - 2,
82 ascent(pain, font) + descent(pain, font) - 2,
84 pain.rectangle(int(x), baseline - ascent(pain, font) + 1,
85 width(pain, font) - 2,
86 ascent(pain, font) + descent(pain, font) - 2,
88 pain.text(int(x + 2), baseline, _("Error"), efont);
90 x += width(pain, font) - 1;
94 void InsetError::Write(ostream &) const
99 void InsetError::Read(LyXLex &)
104 int InsetError::Latex(ostream &, signed char /*fragile*/) const
110 int InsetError::Latex(string &, signed char /*fragile*/) const
116 int InsetError::Linuxdoc(string &) const
122 int InsetError::DocBook(string &) const
128 bool InsetError::AutoDelete() const
134 unsigned char InsetError::Editable() const
140 void InsetError::CloseErrorCB(FL_OBJECT * ob, long)
142 InsetError * inset = static_cast<InsetError*>(ob->u_vdata);
144 fl_hide_form(inset->form);
145 fl_free_form(inset->form);
152 extern "C" void C_InsetError_CloseErrorCB(FL_OBJECT * ob, long data)
154 InsetError::CloseErrorCB(ob , data);
158 void InsetError::Edit(BufferView *, int, int)
160 static int ow = 400, oh = 240;
164 form = fl_bgn_form(FL_UP_BOX, ow, oh);
165 strobj = fl_add_box(FL_FRAME_BOX, 10, 10, 380, 180, "");
166 fl_set_object_color(strobj, FL_MCOL, FL_MCOL);
167 fl_set_object_gravity(strobj, FL_NorthWest, FL_SouthEast);
168 obj = fl_add_button(FL_RETURN_BUTTON, 140, 200, 120, 30,
170 fl_set_object_callback(obj, C_InsetError_CloseErrorCB, 0);
172 fl_set_object_gravity(obj, FL_SouthEast, FL_SouthEast);
173 fl_set_object_resize(obj, FL_RESIZE_NONE);
175 fl_set_form_atclose(form, CancelCloseBoxCB, 0);
177 fl_set_object_label(strobj, contents.c_str());
181 fl_show_form(form, FL_PLACE_MOUSE | FL_FREE_SIZE,
182 FL_FULLBORDER, _("LaTeX Error"));
183 fl_set_form_minsize(form, ow, oh);
188 Inset * InsetError::Clone() const
190 return new InsetError(contents);