]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insetinfo.C
use the new sstream return non-pods as const, use string instead of char * in a lot...
[lyx.git] / src / insets / insetinfo.C
index 9499ec0de25fa74705dd9a005cce3008c7576fb6..55d6cf911193f9d45f20904afffebd8de59a0530 100644 (file)
@@ -4,7 +4,7 @@
  *           LyX, The Document Processor
  *      
  *         Copyright 1995 Matthias Ettrich
- *          Copyright 1995-1999 The LyX Team.
+ *          Copyright 1995-2000 The LyX Team.
  *
  * ====================================================== */
 
 #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 */
 
@@ -31,21 +35,24 @@ extern BufferView * current_view;
 
 
 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;
@@ -53,53 +60,57 @@ InsetInfo::~InsetInfo()
 }
 
 
-int InsetInfo::ascent(Painter &, LyXFont const & font) const
+int InsetInfo::ascent(BufferView *, LyXFont const &) const
 {
-       return font.maxAscent() + 1;
+       return lyxfont::maxAscent(labelfont) + 1;
 }
 
 
-int InsetInfo::descent(Painter &, LyXFont const & font) const
+int InsetInfo::descent(BufferView *, LyXFont const &) const
 {
-       return font.maxDescent() + 1;
+       return lyxfont::maxDescent(labelfont) + 1;
 }
 
 
-int InsetInfo::width(Painter &, LyXFont const & font) const
+int InsetInfo::width(BufferView *, LyXFont const &) const
 {
-       return 6 + font.textWidth(_("Note"), strlen(_("Note")));
+       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
 {
+       Painter & pain = bv->painter();
+#if 0
        LyXFont font(f);
        
-       /* Info-insets are never LaTeX, so just correct the font */
-       font.setLatex(LyXFont::OFF);
-
+       // Info-insets are never LaTeX, so just correct the font
+       font.setLatex(LyXFont::OFF).setColor(LColor::note);
+#endif
        // 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.rectangle(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(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")
@@ -126,35 +137,34 @@ void InsetInfo::Read(LyXLex & lex)
 }
       
 
-int InsetInfo::Latex(ostream &, signed char /*fragile*/) const
+int InsetInfo::Latex(Buffer const *, ostream &,
+                    bool /*fragile*/, bool /*free_spc*/) const
 {
        return 0;
 }
 
 
-#ifndef USE_OSTREAM_ONLY
-int InsetInfo::Latex(string &, signed char /*fragile*/) const
+int InsetInfo::Ascii(Buffer const *, ostream &) const
 {
        return 0;
 }
-#endif
 
 
-int InsetInfo::Linuxdoc(string &) const
+int InsetInfo::Linuxdoc(Buffer const *, ostream &) const
 {
        return 0;
 }
 
 
-int InsetInfo::DocBook(string &) const
+int InsetInfo::DocBook(Buffer const *, ostream &) const
 {
        return 0;
 }
 
 
-unsigned char InsetInfo::Editable() const
+Inset::EDITABLE InsetInfo::Editable() const
 {
-       return 1;
+       return IS_EDITABLE;
 }
 
 
@@ -176,12 +186,19 @@ void InsetInfo::CloseInfoCB(FL_OBJECT * ob, long)
 
 
 // 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);
 }
 
 
+string const InsetInfo::EditMessage() const 
+{
+       return _("Opened note");
+}
+
+
 void InsetInfo::Edit(BufferView *bv, int, int, unsigned int)
 {
        static int ow = -1, oh;