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)
31 InsetERT * InsetERT::Clone() const
33 InsetERT * result = new InsetERT(buffer);
38 void InsetERT::Write(ostream & os) const
41 WriteParagraphData(os);
45 int InsetERT::ascent_closed(Painter & pain, LyXFont const & f) const
47 int width, ascent, descent;
48 LyXFont font(LyXFont::ALL_SANE);
49 font.setSize(f.size());
52 pain.buttonText(0, 0, _("ERT"), font, false, width, ascent, descent);
57 int InsetERT::descent_closed(Painter & pain, LyXFont const & f) const
59 int width, ascent, descent;
60 LyXFont font(LyXFont::ALL_SANE);
61 font.setSize(f.size());
64 pain.buttonText(0, 0, _("ERT"), font, false, width, ascent, descent);
69 int InsetERT::width_closed(Painter & pain, LyXFont const & f) const
71 int width, ascent, descent;
72 LyXFont font(LyXFont::ALL_SANE);
73 font.setSize(f.size());
76 pain.buttonText(TEXT_TO_INSET_OFFSET, 0, _("ERT"), font, false,
77 width, ascent, descent);
78 return width + (2*TEXT_TO_INSET_OFFSET);
82 int InsetERT::ascent(Painter & pain, LyXFont const & font) const
85 return ascent_closed(pain, font);
87 return InsetText::ascent(pain, font);
91 int InsetERT::descent(Painter & pain, LyXFont const & font) const
95 return descent_closed(pain, font);
97 return InsetText::descent(pain, font);
101 int InsetERT::width(Painter & pain, LyXFont const & font) const
104 return width_closed(pain, font);
106 return InsetText::width(pain, font);
110 void InsetERT::draw_closed(Painter & pain, LyXFont const & f,
111 int baseline, float & x) const
113 LyXFont font(LyXFont::ALL_SANE);
114 font.setSize(f.size());
117 font.setColor(LColor::ert);
119 pain.buttonText(int(x)+TEXT_TO_INSET_OFFSET, baseline, _("ERT"), font,
121 x += width + (2*TEXT_TO_INSET_OFFSET);
125 void InsetERT::draw(Painter & pain, LyXFont const & f,
126 int baseline, float & x) const
130 top_baseline = baseline;
131 draw_closed(pain, f, baseline, x);
133 InsetText::draw(pain, f, baseline, x);
139 void InsetERT::InsetButtonRelease(BufferView * bv, int x, int y, int button)
142 InsetText::InsetButtonRelease(bv, x, y, button);
146 void InsetERT::InsetButtonPress(BufferView * bv, int x, int y, int button)
149 InsetText::InsetButtonPress(bv, x, y, button);
153 void InsetERT::InsetMotionNotify(BufferView * bv, int x, int y, int button)
157 InsetText::InsetMotionNotify(bv, x, y, button);
161 void InsetERT::Edit(BufferView * bv, int x, int y, unsigned int button)
165 LyXFont font(LyXFont::ALL_SANE);
166 font.setLatex (LyXFont::ON);
167 InsetText::Edit(bv, (x > (width_closed(bv->getPainter(),font)-5) ?
168 width(bv->getPainter(), font) : 0), y, button);
169 real_current_font = current_font = font;
170 bv->updateInset(this, false);
174 void InsetERT::InsetUnlock(BufferView * bv)
177 InsetText::InsetUnlock(bv);
178 bv->updateInset(this, false);
182 bool InsetERT::InsertInset(Inset *)
188 void InsetERT::SetFont(LyXFont const &, bool)
190 WriteAlert(_("Impossible Operation!"),
191 _("Not permitted to change font-types inside ERT-insets!"),