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"
20 #include "lyx_gui_misc.h" // CancelCloseBoxCB
22 /* Error, used for the LaTeX-Error Messages */
24 InsetError::InsetError()
29 InsetError::InsetError(string const & str)
36 InsetError::~InsetError()
46 int InsetError::Ascent(LyXFont const & font) const
49 efont.setSize(font.size()).decSize();
50 return efont.maxAscent()+1;
54 int InsetError::Descent(LyXFont const & font) const
57 efont.setSize(font.size()).decSize();
58 return efont.maxDescent()+1;
62 int InsetError::Width(LyXFont const & font) const
65 efont.setSize(font.size()).decSize();
66 return 6 + efont.textWidth(_("Error"), strlen(_("Error")));
70 void InsetError::Draw(LyXFont font, LyXScreen & scr,
71 int baseline, float & x)
74 efont.setSize(font.size()).decSize();
75 efont.setLatex(LyXFont::ON);
77 // Draw as "Error" in a framed box
79 scr.fillRectangle(gc_lighted,
80 int(x), baseline - Ascent(font)+1,
81 Width(font)-2, Ascent(font)+ Descent(font)-2);
82 scr.drawRectangle(gc_foot,
83 int(x), baseline-Ascent(font)+1,
84 Width(font)-2, Ascent(font)+Descent(font)-2);
85 scr.drawString(efont, _("Error"), baseline, int(x+2));
91 void InsetError::Write(FILE *)
95 void InsetError::Read(LyXLex &)
100 int InsetError::Latex(FILE *, signed char /*fragile*/)
106 int InsetError::Latex(string &, signed char /*fragile*/)
112 int InsetError::Linuxdoc(string &)
118 int InsetError::DocBook(string &)
124 bool InsetError::AutoDelete() const
130 unsigned char InsetError::Editable() const
136 void InsetError::CloseErrorCB(FL_OBJECT * ob, long)
138 InsetError * inset = static_cast<InsetError*>(ob->u_vdata);
140 fl_hide_form(inset->form);
141 fl_free_form(inset->form);
148 extern "C" void C_InsetError_CloseErrorCB(FL_OBJECT * ob, long data)
150 InsetError::CloseErrorCB(ob , data);
154 void InsetError::Edit(int, int)
156 static int ow = 400, oh = 240;
160 form = fl_bgn_form(FL_UP_BOX, ow, oh);
161 strobj = fl_add_box(FL_FRAME_BOX, 10, 10, 380, 180, "");
162 fl_set_object_color(strobj, FL_MCOL, FL_MCOL);
163 fl_set_object_gravity(strobj, FL_NorthWest, FL_SouthEast);
164 obj = fl_add_button(FL_RETURN_BUTTON, 140, 200, 120, 30,
166 fl_set_object_callback(obj, C_InsetError_CloseErrorCB, 0);
168 fl_set_object_gravity(obj, FL_SouthEast, FL_SouthEast);
169 fl_set_object_resize(obj, FL_RESIZE_NONE);
171 fl_set_form_atclose(form, CancelCloseBoxCB, 0);
173 fl_set_object_label(strobj, contents.c_str());
177 fl_show_form(form, FL_PLACE_MOUSE | FL_FREE_SIZE,
178 FL_FULLBORDER, _("LaTeX Error"));
179 fl_set_form_minsize(form, ow, oh);
184 Inset * InsetError::Clone() const
186 return new InsetError(contents);