]> git.lyx.org Git - lyx.git/blob - src/insets/inseterror.C
reformatting and remove using delc
[lyx.git] / src / insets / inseterror.C
1 /* This file is part of
2  * ======================================================
3  * 
4  *           LyX, The Document Processor
5  *       
6  *          Copyright 1995 Matthias Ettrich
7  *          Copyright 1995-2000 The LyX Team.
8  *
9  * ====================================================== */
10
11 #include <config.h>
12
13 #ifdef __GNUG__
14 #pragma implementation
15 #endif
16
17 #include "BufferView.h"
18 #include "font.h"
19 #include "gettext.h"
20 #include "inseterror.h"
21 #include "LyXView.h"
22 #include "Painter.h"
23 #include "frontends/Dialogs.h"
24
25 using std::ostream;
26
27 /* Error, used for the LaTeX-Error Messages */
28
29 InsetError::InsetError(string const & str)
30         : contents(str)
31 {}
32
33
34 int InsetError::ascent(BufferView *, LyXFont const & font) const
35 {
36         LyXFont efont;
37         efont.setSize(font.size()).decSize();
38         return lyxfont::maxAscent(efont) + 1;
39 }
40
41
42 int InsetError::descent(BufferView *, LyXFont const & font) const
43 {
44         LyXFont efont;
45         efont.setSize(font.size()).decSize();
46         return lyxfont::maxDescent(efont) + 1;
47 }
48
49
50 int InsetError::width(BufferView *, LyXFont const & font) const
51 {
52         LyXFont efont;
53         efont.setSize(font.size()).decSize();
54         return 6 + lyxfont::width(_("Error"), efont);
55 }
56
57
58 void InsetError::draw(BufferView * bv, LyXFont const & font,
59                       int baseline, float & x, bool) const
60 {
61         Painter & pain = bv->painter();
62         LyXFont efont;
63         efont.setSize(font.size()).decSize();
64         efont.setColor(LColor::error);
65    
66         // Draw as "Error" in a framed box
67         x += 1;
68         pain.fillRectangle(int(x), baseline - ascent(bv, font) + 1,
69                           width(bv, font) - 2,
70                           ascent(bv, font) + descent(bv, font) - 2,
71                            LColor::insetbg);
72         pain.rectangle(int(x), baseline - ascent(bv, font) + 1,
73                        width(bv, font) - 2,
74                        ascent(bv, font) + descent(bv, font) - 2,
75                        LColor::error);
76         pain.text(int(x + 2), baseline, _("Error"), efont);
77
78         x +=  width(bv, font) - 1;
79 }
80
81
82 string const InsetError::EditMessage() const 
83 {
84         return _("Opened error");
85 }
86
87
88 void InsetError::Edit(BufferView * bv, int, int, unsigned int)
89 {
90         bv->owner()->getDialogs()->showError( this );
91 }