1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
6 * Copyright (C) 1995 Matthias Ettrich
7 * Copyright (C) 1995-1998 The LyX Team.
9 *======================================================*/
14 #pragma implementation
18 #include "definitions.h"
19 #include "inseterror.h"
22 #include "lyx_gui_misc.h" // CancelCloseBoxCB
24 // $Id: inseterror.C,v 1.1 1999/09/27 18:44:39 larsbj Exp $
26 #if !defined(lint) && !defined(WITH_WARNINGS)
27 static char vcid[] = "$Id: inseterror.C,v 1.1 1999/09/27 18:44:39 larsbj Exp $";
30 /* Error, used for the LaTeX-Error Messages */
32 InsetError::InsetError()
37 InsetError::InsetError(LString const & string)
44 InsetError::~InsetError()
54 int InsetError::Ascent(LyXFont const &font) const
57 efont.setSize(font.size()).decSize();
58 return efont.maxAscent()+1;
62 int InsetError::Descent(LyXFont const &font) const
65 efont.setSize(font.size()).decSize();
66 return efont.maxDescent()+1;
70 int InsetError::Width(LyXFont const &font) const
73 efont.setSize(font.size()).decSize();
74 return 6 + efont.textWidth(_("Error"), strlen(_("Error")));
78 void InsetError::Draw(LyXFont font, LyXScreen &scr,
79 int baseline, float &x)
82 efont.setSize(font.size()).decSize();
83 efont.setLatex(LyXFont::ON);
85 // Draw as "Error" in a framed box
87 //scr.drawFilledRectangle(int(x), baseline - Ascent(font)+1,
88 // Width(font)-2,Ascent(font)+ Descent(font)-2,
90 scr.fillRectangle(gc_lighted,
91 int(x), baseline - Ascent(font)+1,
92 Width(font)-2,Ascent(font)+ Descent(font)-2);
93 //scr.drawRectangle(int(x), baseline-Ascent(font)+1,
94 // Width(font)-2, Ascent(font)+Descent(font)-2,
96 scr.drawRectangle(gc_foot,
97 int(x), baseline-Ascent(font)+1,
98 Width(font)-2, Ascent(font)+Descent(font)-2);
99 scr.drawString(efont, _("Error"), baseline, int(x+2));
101 x += Width(font) - 1;
105 void InsetError::Write(FILE *)
109 void InsetError::Read(LyXLex &)
114 int InsetError::Latex(FILE *, signed char /*fragile*/)
120 int InsetError::Latex(LString &, signed char /*fragile*/)
126 int InsetError::Linuxdoc(LString &)
132 int InsetError::DocBook(LString &)
138 bool InsetError::AutoDelete() const
144 unsigned char InsetError::Editable() const
150 void InsetError::CloseErrorCB(FL_OBJECT *, long data)
152 InsetError *inset = (InsetError*) data;
154 fl_hide_form(inset->form);
155 fl_free_form(inset->form);
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, 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, NULL);
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);