1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
6 * Copyright 1995 Matthias Ettrich
7 * Copyright 1995-2000 The LyX Team.
9 * ====================================================== */
14 #pragma implementation
17 #include "inseterror.h"
19 #include "lyx_gui_misc.h" // CancelCloseBoxCB
25 /* Error, used for the LaTeX-Error Messages */
27 InsetError::InsetError()
33 InsetError::InsetError(string const & str)
40 InsetError::~InsetError()
50 int InsetError::ascent(Painter &, LyXFont const & font) const
53 efont.setSize(font.size()).decSize();
54 return lyxfont::maxAscent(efont) + 1;
58 int InsetError::descent(Painter &, LyXFont const & font) const
61 efont.setSize(font.size()).decSize();
62 return lyxfont::maxDescent(efont) + 1;
66 int InsetError::width(Painter &, LyXFont const & font) const
69 efont.setSize(font.size()).decSize();
70 return 6 + lyxfont::width(_("Error"), efont);
74 void InsetError::draw(Painter & pain, LyXFont const & font,
75 int baseline, float & x) const
78 efont.setSize(font.size()).decSize();
79 efont.setColor(LColor::error);
81 // Draw as "Error" in a framed box
83 pain.fillRectangle(int(x), baseline - ascent(pain, font) + 1,
84 width(pain, font) - 2,
85 ascent(pain, font) + descent(pain, font) - 2,
87 pain.rectangle(int(x), baseline - ascent(pain, font) + 1,
88 width(pain, font) - 2,
89 ascent(pain, font) + descent(pain, font) - 2,
91 pain.text(int(x + 2), baseline, _("Error"), efont);
93 x += width(pain, font) - 1;
97 void InsetError::Write(ostream &) const
102 void InsetError::Read(LyXLex &)
107 int InsetError::Latex(ostream &,
108 signed char /*fragile*/, bool /*fs*/) const
114 int InsetError::Linuxdoc(ostream &) const
120 int InsetError::DocBook(ostream &) const
126 bool InsetError::AutoDelete() const
132 Inset::EDITABLE InsetError::Editable() const
138 void InsetError::CloseErrorCB(FL_OBJECT * ob, long)
140 InsetError * inset = static_cast<InsetError*>(ob->u_vdata);
142 fl_hide_form(inset->form);
143 fl_free_form(inset->form);
150 extern "C" void C_InsetError_CloseErrorCB(FL_OBJECT * ob, long data)
152 InsetError::CloseErrorCB(ob , data);
156 char const * InsetError::EditMessage() const
158 return _("Opened error");
162 void InsetError::Edit(BufferView *, int, int, unsigned int)
164 static int ow = 400, oh = 240;
168 form = fl_bgn_form(FL_UP_BOX, ow, oh);
169 strobj = fl_add_box(FL_FRAME_BOX, 10, 10, 380, 180, "");
170 fl_set_object_color(strobj, FL_MCOL, FL_MCOL);
171 fl_set_object_gravity(strobj, FL_NorthWest, FL_SouthEast);
172 obj = fl_add_button(FL_RETURN_BUTTON, 140, 200, 120, 30,
174 fl_set_object_callback(obj, C_InsetError_CloseErrorCB, 0);
176 fl_set_object_gravity(obj, FL_SouthEast, FL_SouthEast);
177 fl_set_object_resize(obj, FL_RESIZE_NONE);
179 fl_set_form_atclose(form, CancelCloseBoxCB, 0);
181 fl_set_object_label(strobj, contents.c_str());
185 fl_show_form(form, FL_PLACE_MOUSE | FL_FREE_SIZE,
186 FL_FULLBORDER, _("LaTeX Error"));
187 fl_set_form_minsize(form, ow, oh);
192 Inset * InsetError::Clone() const
194 return new InsetError(contents);