InsetInfo::InsetInfo()
+ : form(0), labelfont(LyXFont::ALL_SANE)
{
- form = 0;
+ labelfont.decSize().decSize()
+ .setColor(LColor::note).setLatex(LyXFont::OFF);
}
-InsetInfo::InsetInfo(string const & string)
- : contents(string)
+InsetInfo::InsetInfo(string const & str)
+ : contents(str), form(0), labelfont(LyXFont::ALL_SANE)
{
- form = 0;
+ labelfont.decSize().decSize()
+ .setColor(LColor::note).setLatex(LyXFont::OFF);
}
InsetInfo::~InsetInfo()
{
- if (form){
+ if (form) {
fl_hide_form(form);
fl_free_form(form);
form = 0;
}
-int InsetInfo::ascent(Painter &, LyXFont const & font) const
+int InsetInfo::ascent(BufferView *, LyXFont const &) const
{
- return lyxfont::maxAscent(font) + 1;
+ return lyxfont::maxAscent(labelfont) + 1;
}
-int InsetInfo::descent(Painter &, LyXFont const & font) const
+int InsetInfo::descent(BufferView *, LyXFont const &) const
{
- return lyxfont::maxDescent(font) + 1;
+ return lyxfont::maxDescent(labelfont) + 1;
}
-int InsetInfo::width(Painter &, LyXFont const & font) const
+int InsetInfo::width(BufferView *, LyXFont const &) const
{
- return 6 + lyxfont::width(_("Note"), font);
+ return 6 + lyxfont::width(_("Note"), labelfont);
}
-void InsetInfo::draw(Painter & pain, LyXFont const & f,
- int baseline, float & x) const
+void InsetInfo::draw(BufferView * bv, LyXFont const &,
+ int baseline, float & x, bool) const
{
- LyXFont font(f);
-
- /* Info-insets are never LaTeX, so just correct the font */
- font.setLatex(LyXFont::OFF).setColor(LColor::note);
-
+ Painter & pain = bv->painter();
+
// Draw as "Note" in a yellow box
x += 1;
- pain.fillRectangle(int(x), baseline - ascent(pain, font) + 1,
- width(pain, font) - 2,
- ascent(pain, font) + descent(pain, font) - 2,
+ pain.fillRectangle(int(x), baseline - ascent(bv, labelfont),
+ width(bv, labelfont) - 2,
+ ascent(bv, labelfont) + descent(bv, labelfont) - 2,
LColor::notebg);
- pain.rectangle(int(x), baseline - ascent(pain, font) + 1,
- width(pain, font) - 2,
- ascent(pain, font) + descent(pain, font) - 2,
+ pain.rectangle(int(x), baseline - ascent(bv, labelfont),
+ width(bv, labelfont) - 2,
+ ascent(bv, labelfont) + descent(bv, labelfont) - 2,
LColor::noteframe);
- pain.text(int(x + 2), baseline, _("Note"), font);
- x += width(pain, font) - 1;
+ pain.text(int(x + 2), baseline, _("Note"), labelfont);
+ x += width(bv, labelfont) - 1;
}
-void InsetInfo::Write(ostream & os) const
+void InsetInfo::Write(Buffer const *, ostream & os) const
{
- os << "Info " << contents;
+ os << "Info\n" << contents;
}
-void InsetInfo::Read(LyXLex & lex)
+void InsetInfo::Read(Buffer const *, LyXLex & lex)
{
string tmp = lex.GetString(); // should be "Info"
if (tmp != "Info")
}
-int InsetInfo::Latex(ostream &,
+int InsetInfo::Latex(Buffer const *, ostream &,
bool /*fragile*/, bool /*free_spc*/) const
{
return 0;
}
-int InsetInfo::Ascii(ostream &) const
+int InsetInfo::Ascii(Buffer const *, ostream &, int) const
{
return 0;
}
-int InsetInfo::Linuxdoc(ostream &) const
+int InsetInfo::Linuxdoc(Buffer const *, ostream &) const
{
return 0;
}
-int InsetInfo::DocBook(ostream &) const
+int InsetInfo::DocBook(Buffer const *, ostream &) const
{
return 0;
}
InsetInfo * inset = static_cast<InsetInfo*>(ob->u_vdata);
string tmp = fl_get_input(inset->strobj);
Buffer * buffer = current_view->buffer();
- if(tmp != inset->contents && !(buffer->isReadonly()) ) {
+ if (tmp != inset->contents && !(buffer->isReadonly())) {
buffer->markDirty();
inset->contents = tmp;
}
// This is just a wrapper.
-extern "C" void C_InsetInfo_CloseInfoCB(FL_OBJECT * ob, long data)
+extern "C"
+void C_InsetInfo_CloseInfoCB(FL_OBJECT * ob, long data)
{
InsetInfo::CloseInfoCB(ob, data);
}
-char const * InsetInfo::EditMessage() const
+string const InsetInfo::EditMessage() const
{
return _("Opened note");
}
{
static int ow = -1, oh;
- if(bv->buffer()->isReadonly())
+ if (bv->buffer()->isReadonly())
WarnReadonly(bv->buffer()->fileName());
if (!form) {
if (form->visible) {
fl_raise_form(form);
} else {
- fl_show_form(form, FL_PLACE_MOUSE | FL_FREE_SIZE, FL_FULLBORDER,
+ fl_show_form(form,
+ FL_PLACE_MOUSE | FL_FREE_SIZE, FL_TRANSIENT,
_("Note"));
if (ow < 0) {
ow = form->w;
}
-Inset * InsetInfo::Clone() const
+Inset * InsetInfo::Clone(Buffer const &) const
{
return new InsetInfo(contents);
}