X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2Finsetinfo.C;h=3c58a89091a6712664fb6cd0b797b7019277fab9;hb=3c8aba3b556871fb1100a2f98cd93d5d4e3f70c9;hp=24cc383658b850f54c8fbafc9db55ccd99471fb5;hpb=5f3f9ad231bc0c24d34c00e3936e226d9834589a;p=lyx.git diff --git a/src/insets/insetinfo.C b/src/insets/insetinfo.C index 24cc383658..3c58a89091 100644 --- a/src/insets/insetinfo.C +++ b/src/insets/insetinfo.C @@ -4,7 +4,7 @@ * LyX, The Document Processor * * Copyright 1995 Matthias Ettrich - * Copyright 1995-1999 The LyX Team. + * Copyright 1995-2000 The LyX Team. * * ====================================================== */ @@ -19,11 +19,15 @@ #include "insetinfo.h" #include "lyxparagraph.h" #include "debug.h" -#include "lyxdraw.h" #include "gettext.h" #include "lyx_gui_misc.h" // CancelCloseBoxCB #include "buffer.h" #include "support/lstrings.h" +#include "Painter.h" +#include "font.h" + +using std::ostream; +using std::endl; /* Info, used for the Info boxes */ @@ -53,45 +57,49 @@ InsetInfo::~InsetInfo() } -int InsetInfo::Ascent(LyXFont const & font) const +int InsetInfo::ascent(Painter &, LyXFont const & font) const { - return font.maxAscent() + 1; + return lyxfont::maxAscent(font) + 1; } -int InsetInfo::Descent(LyXFont const & font) const +int InsetInfo::descent(Painter &, LyXFont const & font) const { - return font.maxDescent() + 1; + return lyxfont::maxDescent(font) + 1; } -int InsetInfo::Width(LyXFont const & font) const +int InsetInfo::width(Painter &, LyXFont const & font) const { - return 6 + font.textWidth(_("Note"), strlen(_("Note"))); + return 6 + lyxfont::width(_("Note"), font); } -void InsetInfo::Draw(LyXFont font, LyXScreen & scr, - int baseline, float & x) +void InsetInfo::draw(Painter & pain, LyXFont const & f, + int baseline, float & x) const { + LyXFont font(f); + /* Info-insets are never LaTeX, so just correct the font */ - font.setLatex(LyXFont::OFF); - + font.setLatex(LyXFont::OFF).setColor(LColor::note); + // Draw as "Note" in a yellow box x += 1; - scr.fillRectangle(gc_note, - int(x), baseline - Ascent(font)+1, - Width(font)-2, Ascent(font)+Descent(font)-2); - scr.drawRectangle(gc_note_frame, - int(x), baseline- Ascent(font)+1, - Width(font)-2, Ascent(font)+Descent(font)-2); + pain.fillRectangle(int(x), baseline - ascent(pain, font) + 1, + width(pain, font) - 2, + ascent(pain, font) + descent(pain, font) - 2, + LColor::notebg); + pain.rectangle(int(x), baseline - ascent(pain, font) + 1, + width(pain, font) - 2, + ascent(pain, font) + descent(pain, font) - 2, + LColor::noteframe); - scr.drawString(font, _("Note"), baseline, int(x+2)); - x += Width(font) - 1; + pain.text(int(x + 2), baseline, _("Note"), font); + x += width(pain, font) - 1; } -void InsetInfo::Write(ostream & os) +void InsetInfo::Write(ostream & os) const { os << "Info " << contents; } @@ -124,33 +132,34 @@ void InsetInfo::Read(LyXLex & lex) } -int InsetInfo::Latex(ostream &, signed char /*fragile*/) +int InsetInfo::Latex(ostream &, + bool /*fragile*/, bool /*free_spc*/) const { return 0; } -int InsetInfo::Latex(string &, signed char /*fragile*/) +int InsetInfo::Ascii(ostream &) const { return 0; } -int InsetInfo::Linuxdoc(string &) +int InsetInfo::Linuxdoc(ostream &) const { return 0; } -int InsetInfo::DocBook(string &) +int InsetInfo::DocBook(ostream &) const { return 0; } -unsigned char InsetInfo::Editable() const +Inset::EDITABLE InsetInfo::Editable() const { - return 1; + return IS_EDITABLE; } @@ -178,12 +187,18 @@ extern "C" void C_InsetInfo_CloseInfoCB(FL_OBJECT * ob, long data) } -void InsetInfo::Edit(int, int) +char const * InsetInfo::EditMessage() const +{ + return _("Opened note"); +} + + +void InsetInfo::Edit(BufferView *bv, int, int, unsigned int) { static int ow = -1, oh; - if(current_view->buffer()->isReadonly()) - WarnReadonly(current_view->buffer()->fileName()); + if(bv->buffer()->isReadonly()) + WarnReadonly(bv->buffer()->fileName()); if (!form) { FL_OBJECT *obj;