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 "definitions.h"
18 #include "inseterror.h"
21 #include "lyx_gui_misc.h" // CancelCloseBoxCB
23 /* Error, used for the LaTeX-Error Messages */
25 InsetError::InsetError()
30 InsetError::InsetError(string const & string)
37 InsetError::~InsetError()
47 int InsetError::Ascent(LyXFont const &font) const
50 efont.setSize(font.size()).decSize();
51 return efont.maxAscent()+1;
55 int InsetError::Descent(LyXFont const &font) const
58 efont.setSize(font.size()).decSize();
59 return efont.maxDescent()+1;
63 int InsetError::Width(LyXFont const &font) const
66 efont.setSize(font.size()).decSize();
67 return 6 + efont.textWidth(_("Error"), strlen(_("Error")));
71 void InsetError::Draw(LyXFont font, LyXScreen &scr,
72 int baseline, float &x)
75 efont.setSize(font.size()).decSize();
76 efont.setLatex(LyXFont::ON);
78 // Draw as "Error" in a framed box
80 //scr.drawFilledRectangle(int(x), baseline - Ascent(font)+1,
81 // Width(font)-2,Ascent(font)+ Descent(font)-2,
83 scr.fillRectangle(gc_lighted,
84 int(x), baseline - Ascent(font)+1,
85 Width(font)-2,Ascent(font)+ Descent(font)-2);
86 //scr.drawRectangle(int(x), baseline-Ascent(font)+1,
87 // Width(font)-2, Ascent(font)+Descent(font)-2,
89 scr.drawRectangle(gc_foot,
90 int(x), baseline-Ascent(font)+1,
91 Width(font)-2, Ascent(font)+Descent(font)-2);
92 scr.drawString(efont, _("Error"), baseline, int(x+2));
98 void InsetError::Write(FILE *)
102 void InsetError::Read(LyXLex &)
107 int InsetError::Latex(FILE *, signed char /*fragile*/)
113 int InsetError::Latex(string &, signed char /*fragile*/)
119 int InsetError::Linuxdoc(string &)
125 int InsetError::DocBook(string &)
131 bool InsetError::AutoDelete() const
137 unsigned char InsetError::Editable() const
143 void InsetError::CloseErrorCB(FL_OBJECT *, long data)
145 InsetError *inset = (InsetError*) data;
147 fl_hide_form(inset->form);
148 fl_free_form(inset->form);
154 extern "C" void C_InsetError_CloseErrorCB(FL_OBJECT *, long data)
156 InsetError::CloseErrorCB(0,data);
160 void InsetError::Edit(int, int)
164 form = fl_bgn_form(FL_UP_BOX,400,240);
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,_("Close"));
169 fl_set_object_callback(obj, C_InsetError_CloseErrorCB, (long)this);
170 fl_set_object_gravity(obj, FL_South, FL_South);
171 fl_set_object_resize(obj, FL_RESIZE_NONE);
173 fl_set_form_atclose(form, CancelCloseBoxCB, 0);
175 fl_set_object_label(strobj, contents.c_str());
179 fl_show_form(form,FL_PLACE_MOUSE | FL_FREE_SIZE, FL_FULLBORDER,
185 Inset* InsetError::Clone()
187 InsetError *result = new InsetError(contents);