/* This file is part of
* ======================================================
- *
+ *
* LyX, The Document Processor
- *
+ *
* Copyright 1998 The LyX Team.
*
*======================================================*/
font.setFamily(LyXFont::TYPEWRITER_FAMILY);
font.setColor(LColor::latex);
#endif
-
+
string::const_iterator cit = contents.begin();
string::const_iterator end = contents.end();
pos_type pos = 0;
if (token == "status") {
lex.next();
string const tmp_token = lex.getString();
-
+
if (tmp_token == "Inlined") {
status(0, Inlined);
} else if (tmp_token == "Collapsed") {
// leave this as default!
status(0, Open);
}
-
+
token_found = true;
} else {
lyxerr << "InsetERT::Read: Missing 'status'-tag!"
#ifdef SET_HARD_FONT
#ifndef INHERIT_LANG
LyXFont font(LyXFont::ALL_INHERIT, latex_language);
-#else
+#else
LyXFont font(LyXFont::ALL_INHERIT);
#endif
font.setFamily(LyXFont::TYPEWRITER_FAMILY);
par = par->next();
}
#endif
-
+
if (!token_found) {
if (collapsed_) {
status(0, Collapsed);
}
-void InsetERT::write(Buffer const * buf, ostream & os) const
+void InsetERT::write(Buffer const * buf, ostream & os) const
{
string st;
switch (status_) {
- case Open:
+ case Open:
st = "Open";
break;
case Collapsed:
}
-string const InsetERT::editMessage() const
+string const InsetERT::editMessage() const
{
return _("Opened ERT Inset");
}
// fontchange and this messages is not needed
if (!selectall)
Alert::alert(_("Impossible Operation!"),
- _("Not permitted to change font-types inside ERT-insets!"),
- _("Sorry."));
+ _("Not permitted to change font-types inside ERT-insets!"),
+ _("Sorry."));
}
}
}
-
+
void InsetERT::edit(BufferView * bv, int x, int y, unsigned int button)
{
if (button == 3)
void InsetERT::insetButtonPress(BufferView * bv,
- int x, int y, int button)
+ int x, int y, int button)
{
if (status_ == Inlined) {
inset.insetButtonPress(bv, x, y, button);
showInsetDialog(bv);
return true;
}
-
+
if (status_ != Inlined && (x >= 0) && (x < button_length) &&
(y >= button_top_y) && (y <= button_bottom_y)) {
updateStatus(bv, true);
} else {
LyXFont font(LyXFont::ALL_SANE);
int yy = ascent(bv, font) + y - inset.ascent(bv, font);
-
- // inlined is special - the text appears above
+
+ // inlined is special - the text appears above
// button_bottom_y
if (status_ == Inlined) {
inset.insetButtonRelease(bv, x, yy, button);
void InsetERT::insetMotionNotify(BufferView * bv,
- int x, int y, int state)
+ int x, int y, int state)
{
if (status_ == Inlined) {
inset.insetMotionNotify(bv, x, y, state);
lines += 2;
}
}
-
+
return lines;
}
int InsetERT::ascii(Buffer const *,
- ostream &, int /*linelen*/) const
+ ostream &, int /*linelen*/) const
{
return 0;
}
lines ++;
}
}
-
+
return lines;
}
lines ++;
}
}
-
+
return lines;
}
case LFUN_CUT:
set_latex_font(bv);
break;
-
+
default:
break;
}
#ifdef SET_HARD_FONT
#ifndef INHERIT_LANG
LyXFont f(LyXFont::ALL_INHERIT, latex_language);
-#else
+#else
LyXFont f(LyXFont::ALL_INHERIT);
#endif
font = f;
}
-void InsetERT::draw(BufferView * bv, LyXFont const & f,
- int baseline, float & x, bool cleared) const
+void InsetERT::draw(BufferView * bv, LyXFont const & f,
+ int baseline, float & x, bool cleared) const
{
Painter & pain = bv->painter();
x += static_cast<float>(scroll());
if (!cleared && (inset.need_update == InsetText::FULL ||
- inset.need_update == InsetText::INIT ||
- top_x != int(x) ||
- top_baseline != baseline))
+ inset.need_update == InsetText::INIT ||
+ top_x != int(x) ||
+ top_baseline != baseline))
{
// we don't need anymore to clear here we just have to tell
// the underlying LyXText that it should do the RowClear!
inset.draw(bv, f, baseline, x, cleared);
} else {
draw_collapsed(pain, bl, old_x);
- inset.draw(bv, f,
+ inset.draw(bv, f,
bl + descent_collapsed() + inset.ascent(bv, f),
x, cleared);
}
#ifdef SET_HARD_FONT
#ifndef INHERIT_LANG
LyXFont font(LyXFont::ALL_INHERIT, latex_language);
-#else
+#else
LyXFont font(LyXFont::ALL_INHERIT);
#endif
}
+// attention this function can be called with bv == 0
void InsetERT::status(BufferView * bv, ERTStatus const st) const
{
if (st != status_) {
need_update = FULL;
switch (st) {
case Inlined:
- inset.setUpdateStatus(bv, InsetText::INIT);
+ if (bv)
+ inset.setUpdateStatus(bv, InsetText::INIT);
break;
case Open:
collapsed_ = false;
void InsetERT::close(BufferView * bv) const
{
- if (collapsed_)
+ if (status_ == Collapsed || status_ == Inlined)
return;
+
status(bv, Collapsed);
}
-string const InsetERT::selectNextWordToSpellcheck(BufferView * bv,float &) const
+string const InsetERT::selectNextWordToSpellcheck(BufferView * bv,
+ float &) const
{
bv->unlockInset(const_cast<InsetERT *>(this));
return string();
}
+
void InsetERT::getDrawFont(LyXFont & font) const
{
#ifndef INHERIT_LANG
LyXFont f(LyXFont::ALL_INHERIT, latex_language);
-#else
+#else
LyXFont f(LyXFont::ALL_INHERIT);
#endif
font = f;
if (status_ != Inlined || w < 0)
return w;
LyXText * text = inset.getLyXText(bv);
- if (text->width < w && !text->firstRow()->next())
+ int rw = text->firstRow()->width();
+ if (!rw)
+ rw = w;
+ rw += 40;
+ if (!text->firstRow()->next() && rw < w)
return -1;
return w;
}