1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
6 * Copyright 1998 The LyX Team.
8 *======================================================*/
13 #pragma implementation
20 #include "lyx_gui_misc.h"
23 InsetERT::InsetERT(Buffer * bf)
32 Inset * InsetERT::Clone() const
34 InsetERT * result = new InsetERT(buffer);
39 void InsetERT::Write(ostream & os) const
42 WriteParagraphData(os);
46 int InsetERT::ascent_closed(Painter & pain, LyXFont const & f) const
48 int width, ascent, descent;
49 LyXFont font(LyXFont::ALL_SANE);
50 font.setSize(f.size());
53 pain.buttonText(0, 0, _("ERT"), font, false, width, ascent, descent);
58 int InsetERT::descent_closed(Painter & pain, LyXFont const & f) const
60 int width, ascent, descent;
61 LyXFont font(LyXFont::ALL_SANE);
62 font.setSize(f.size());
65 pain.buttonText(0, 0, _("ERT"), font, false, width, ascent, descent);
70 int InsetERT::width_closed(Painter & pain, LyXFont const & f) const
72 int width, ascent, descent;
73 LyXFont font(LyXFont::ALL_SANE);
74 font.setSize(f.size());
77 pain.buttonText(TEXT_TO_INSET_OFFSET, 0, _("ERT"), font, false,
78 width, ascent, descent);
79 return width + (2*TEXT_TO_INSET_OFFSET);
83 int InsetERT::ascent(Painter & pain, LyXFont const & font) const
86 return ascent_closed(pain, font);
88 return InsetText::ascent(pain, font);
92 int InsetERT::descent(Painter & pain, LyXFont const & font) const
96 return descent_closed(pain, font);
98 return InsetText::descent(pain, font);
102 int InsetERT::width(Painter & pain, LyXFont const & font) const
105 return width_closed(pain, font);
107 return InsetText::width(pain, font);
111 void InsetERT::draw_closed(Painter & pain, LyXFont const & f,
112 int baseline, float & x) const
114 LyXFont font(LyXFont::ALL_SANE);
115 font.setSize(f.size());
118 font.setColor(LColor::ert);
120 pain.buttonText(int(x) + TEXT_TO_INSET_OFFSET, baseline,
121 _("ERT"), font, true, width);
122 x += width + (2 * TEXT_TO_INSET_OFFSET);
126 void InsetERT::draw(Painter & pain, LyXFont const & f,
127 int baseline, float & x) const
131 top_baseline = baseline;
132 draw_closed(pain, f, baseline, x);
134 InsetText::draw(pain, f, baseline, x);
140 void InsetERT::InsetButtonRelease(BufferView * bv, int x, int y, int button)
143 InsetText::InsetButtonRelease(bv, x, y, button);
147 void InsetERT::InsetButtonPress(BufferView * bv, int x, int y, int button)
150 InsetText::InsetButtonPress(bv, x, y, button);
154 void InsetERT::InsetMotionNotify(BufferView * bv, int x, int y, int button)
158 InsetText::InsetMotionNotify(bv, x, y, button);
162 void InsetERT::Edit(BufferView * bv, int x, int y, unsigned int button)
166 LyXFont font(LyXFont::ALL_SANE);
167 font.setLatex (LyXFont::ON);
168 InsetText::Edit(bv, (x > (width_closed(bv->getPainter(),font)-5) ?
169 width(bv->getPainter(), font) : 0), y, button);
170 real_current_font = current_font = font;
171 bv->updateInset(this, false);
175 void InsetERT::InsetUnlock(BufferView * bv)
178 InsetText::InsetUnlock(bv);
179 bv->updateInset(this, false);
183 bool InsetERT::InsertInset(Inset *)
189 void InsetERT::SetFont(LyXFont const &, bool)
191 WriteAlert(_("Impossible Operation!"),
192 _("Not permitted to change font-types inside ERT-insets!"),