1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
6 * Copyright (C) 1998 The LyX Team.
8 *======================================================*/
13 #pragma implementation
20 #include "lyx_gui_misc.h"
23 InsetERT::InsetERT(Buffer * bf): InsetText(bf)
30 InsetERT * InsetERT::Clone() const
32 InsetERT * result = new InsetERT(buffer);
37 void InsetERT::Write(ostream & os) const
40 WriteParagraphData(os);
44 int InsetERT::ascent_closed(Painter & pain, LyXFont const & f) const
46 int width, ascent, descent;
47 LyXFont font(LyXFont::ALL_SANE);
48 font.setSize(f.size());
51 pain.buttonText(0, 0, _("ERT"), font, false, width, ascent, descent);
56 int InsetERT::descent_closed(Painter & pain, LyXFont const & f) const
58 int width, ascent, descent;
59 LyXFont font(LyXFont::ALL_SANE);
60 font.setSize(f.size());
63 pain.buttonText(0, 0, _("ERT"), font, false, width, ascent, descent);
68 int InsetERT::width_closed(Painter & pain, LyXFont const & f) const
70 int width, ascent, descent;
71 LyXFont font(LyXFont::ALL_SANE);
72 font.setSize(f.size());
75 pain.buttonText(TEXT_TO_INSET_OFFSET, 0, _("ERT"), font, false,
76 width, ascent, descent);
77 return width + (2*TEXT_TO_INSET_OFFSET);
81 int InsetERT::ascent(Painter & pain, LyXFont const & font) const
84 return ascent_closed(pain, font);
86 return InsetText::ascent(pain, font);
90 int InsetERT::descent(Painter & pain, LyXFont const & font) const
94 return descent_closed(pain, font);
96 return InsetText::descent(pain, font);
100 int InsetERT::width(Painter & pain, LyXFont const & font) const
103 return width_closed(pain, font);
105 return InsetText::width(pain, font);
109 void InsetERT::draw_closed(Painter & pain, LyXFont const & f,
110 int baseline, float & x) const
112 LyXFont font(LyXFont::ALL_SANE);
113 font.setSize(f.size());
116 font.setColor(LColor::ert);
118 pain.buttonText(int(x)+TEXT_TO_INSET_OFFSET, baseline, _("ERT"), font,
120 x += width + (2*TEXT_TO_INSET_OFFSET);
124 void InsetERT::draw(Painter & pain, LyXFont const & f, int baseline, float & x) const
128 top_baseline = baseline;
129 draw_closed(pain, f, baseline, x);
131 InsetText::draw(pain, f, baseline, x);
137 void InsetERT::InsetButtonRelease(BufferView * bv, int x, int y, int button)
140 InsetText::InsetButtonRelease(bv, x, y, button);
144 void InsetERT::InsetButtonPress(BufferView * bv, int x, int y, int button)
147 InsetText::InsetButtonPress(bv, x, y, button);
151 void InsetERT::InsetMotionNotify(BufferView * bv, int x, int y, int button)
155 InsetText::InsetMotionNotify(bv, x, y, button);
159 void InsetERT::Edit(BufferView * bv, int x, int y, unsigned int button)
163 LyXFont font(LyXFont::ALL_SANE);
164 font.setLatex (LyXFont::ON);
165 InsetText::Edit(bv, (x > (width_closed(bv->getPainter(),font)-5) ?
166 width(bv->getPainter(), font) : 0), y, button);
167 real_current_font = current_font = font;
168 bv->updateInset(this, false);
172 void InsetERT::InsetUnlock(BufferView * bv)
175 InsetText::InsetUnlock(bv);
176 bv->updateInset(this, false);
180 bool InsetERT::InsertInset(Inset *)
186 void InsetERT::SetFont(LyXFont const &, bool)
188 WriteAlert(_("Impossible Operation!"),
189 _("Not permitted to change font-types inside ERT-insets!"),