On Thu, Aug 21, 2003 at 01:45:56PM +0100, John Levon spake thusly:
> 
> On Thu, Aug 21, 2003 at 09:56:44AM +0300, Martin Vermeer wrote:
> 
> > The attached patch is rough-and-ready -- lots of stuff just
> 
> Hey, this looks pretty good ! Nice work. I haven't tried it.
> 
> > > metrics() (I tried it) 
> > 
> > What was the problem? And when was that? For me it just seems to work
> > (but with above caveat)
> 
> You may have done it differently since you have specific checks, but I
> found that if you have a footnote taking up a full row, but with only
> one par, then clicking on the remaining space inside the inset does noot
> place the cursor at the end. Additionally there were lots of weird
> drawing problems.

You may want to try the attached, which is only the changes to the
insets (i.e. they don't use needFullRow/display). I would be interested 
if it works without these artefacts etc.  for you.

> >     /// rebreaks the given par
> > -   void redoParagraph(ParagraphList::iterator pit);
> > +   unsigned int redoParagraph(ParagraphList::iterator pit);
> 
> please doc the return  value meaning
> 
> > @@ -758,14 +762,14 @@ pos_type LyXText::rowBreakPoint(Paragrap
> 
> this cleanup is soooo nice.
> 
> > -           tmprow->fill(fill(pit, tmprow, workWidth()));
> > +           int f = fill(pit, tmprow, workWidth());
> > +           tmprow->fill(f);
> > +           unsigned int w = workWidth() - f;
> > +           if (w > ret)
> > +                   ret = w;
> > +           tmprow->width(w);
> 
> I want to see workWidth() die at some point in favour of .textwidth from
> metrics(), but this is a good start.
> 
> > +   unsigned int i = 0;
> > +   unsigned int j = 0;
> 
> Readable names please: width, maxwidth, or whatever
> 
> > +           if (i > j)
> > +                   j = i; // MV
> 
> don't add author comments like this... the header is where authors go :)

Bad habit. Just a tag for myself
 
> > +   if (ownerParagraphs().size() == 1
> > +                   && ownerParagraphs().begin()->rows.size() == 1)
> > +           // single line, single paragraph, no "filling"
> > +           dim.wid = int(width);
> 
> comment above the if, something like "Return the actual width if we're
> snug" or something.
> 
> This is the bit that I don't see where footnote will work ...
> 
> Maybe things have changed.
> 
> regards
> john
> 

- Martin

Index: insetbibtex.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetbibtex.C,v
retrieving revision 1.18
diff -u -p -r1.18 insetbibtex.C
--- insetbibtex.C       28 Jul 2003 23:53:36 -0000      1.18
+++ insetbibtex.C       21 Aug 2003 14:33:51 -0000
@@ -11,6 +11,7 @@
 #include <config.h>
 
 #include "insetbibtex.h"
+#include "metricsinfo.h"
 #include "buffer.h"
 #include "BufferView.h"
 #include "debug.h"
@@ -52,6 +53,22 @@ std::auto_ptr<InsetBase> InsetBibtex::cl
 {
        return std::auto_ptr<InsetBase>(new InsetBibtex(*this));
 }
+
+void InsetBibtex::metrics(MetricsInfo & mi, Dimension & dim) const
+{
+       InsetCommand::metrics(mi, dim);
+       center_indent_ = (mi.base.textwidth - dim.wid) / 2;
+       dim.wid = mi.base.textwidth;
+       dim_ = dim;
+}
+
+
+void InsetBibtex::draw(PainterInfo & pi, int x, int y) const
+{
+       InsetCommand::draw(pi, x + center_indent_, y);
+}
+
+
 
 
 dispatch_result InsetBibtex::localDispatch(FuncRequest const & cmd)
Index: insetbibtex.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetbibtex.h,v
retrieving revision 1.17
diff -u -p -r1.17 insetbibtex.h
--- insetbibtex.h       28 Jul 2003 23:53:36 -0000      1.17
+++ insetbibtex.h       21 Aug 2003 14:33:51 -0000
@@ -26,6 +26,10 @@ public:
        ~InsetBibtex();
        ///
        std::auto_ptr<InsetBase> clone() const;
+       ///
+       void metrics(MetricsInfo &, Dimension &) const;
+       ///
+       void draw(PainterInfo & pi, int x, int y) const;
        /// small wrapper for the time being
        virtual dispatch_result localDispatch(FuncRequest const & cmd);
        ///
@@ -47,7 +51,10 @@ public:
        ///
        bool delDatabase(string const &);
        ///
-       bool display() const { return true; }
+       //bool display() const { return true; }
+
+private:
+       mutable unsigned int center_indent_;
 };
 
 #endif // INSET_BIBTEX_H
Index: insetbranch.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetbranch.C,v
retrieving revision 1.1
diff -u -p -r1.1 insetbranch.C
--- insetbranch.C       17 Aug 2003 11:28:23 -0000      1.1
+++ insetbranch.C       21 Aug 2003 14:33:51 -0000
@@ -109,19 +109,6 @@ void InsetBranch::setButtonLabel()
 }
 
 
-void InsetBranch::metrics(MetricsInfo & mi, Dimension & dim) const
-{
-       InsetCollapsable::metrics(mi, dim);
-       dim_ = dim;
-}
-
-
-void InsetBranch::draw(PainterInfo & pi, int x, int y) const
-{
-       InsetCollapsable::draw(pi, x, y);
-}
-
-
 bool InsetBranch::showInsetDialog(BufferView * bv) const
 {
        InsetBranchMailer("branch", const_cast<InsetBranch &>(*this)).showDialog(bv);
@@ -145,6 +132,7 @@ dispatch_result InsetBranch::localDispat
        case LFUN_INSET_EDIT:
                if (cmd.button() != mouse_button::button3) 
                        return InsetCollapsable::localDispatch(cmd);
+               
                return UNDISPATCHED;
        case LFUN_INSET_DIALOG_UPDATE:
                InsetBranchMailer("branch", *this).updateDialog(bv);
Index: insetbranch.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetbranch.h,v
retrieving revision 1.1
diff -u -p -r1.1 insetbranch.h
--- insetbranch.h       17 Aug 2003 11:28:23 -0000      1.1
+++ insetbranch.h       21 Aug 2003 14:33:51 -0000
@@ -54,10 +54,6 @@ public:
        ///
        void setButtonLabel();
        ///
-       void metrics(MetricsInfo & mi, Dimension & dim) const;
-       ///
-       void draw(PainterInfo & pi, int x, int y) const;
-       ///
        bool showInsetDialog(BufferView *) const;
        ///
        dispatch_result localDispatch(FuncRequest const &);
Index: insetcollapsable.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetcollapsable.C,v
retrieving revision 1.164
diff -u -p -r1.164 insetcollapsable.C
--- insetcollapsable.C  11 Aug 2003 09:08:59 -0000      1.164
+++ insetcollapsable.C  21 Aug 2003 14:33:51 -0000
@@ -243,7 +243,6 @@ void InsetCollapsable::lfunMouseRelease(
                }
                bv->updateInset();
                bv->buffer()->markDirty();
-               lyxerr << "InsetCollapsable::lfunMouseRelease\n";
        } else if (!collapsed_ && cmd.y > button_dim.y2) {
                ret = inset.localDispatch(adjustCommand(cmd)) == DISPATCHED;
        }
Index: insetcollapsable.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetcollapsable.h,v
retrieving revision 1.118
diff -u -p -r1.118 insetcollapsable.h
--- insetcollapsable.h  11 Aug 2003 09:08:59 -0000      1.118
+++ insetcollapsable.h  21 Aug 2003 14:33:51 -0000
@@ -66,7 +66,7 @@ public:
        ///
        void insetUnlock(BufferView *);
        ///
-       bool needFullRow() const { return isOpen(); }
+       //bool needFullRow() const { return isOpen(); }
        ///
        bool lockInsetInInset(BufferView *, UpdatableInset *);
        ///
Index: insetert.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetert.C,v
retrieving revision 1.147
diff -u -p -r1.147 insetert.C
--- insetert.C  5 Aug 2003 08:07:02 -0000       1.147
+++ insetert.C  21 Aug 2003 14:33:51 -0000
@@ -12,6 +12,7 @@
 
 #include "insetert.h"
 #include "insettext.h"
+#include "metricsinfo.h"
 
 #include "buffer.h"
 #include "BufferView.h"
@@ -555,6 +556,10 @@ void InsetERT::metrics(MetricsInfo & mi,
                inset.metrics(mi, dim);
        else
                InsetCollapsable::metrics(mi, dim);
+       // Make it stand out on its own as it is code, not part of running
+       // text:
+       if (isOpen() && !inlined())
+               dim.wid = mi.base.textwidth;
        dim_ = dim;
 }
 
Index: insetert.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetert.h,v
retrieving revision 1.81
diff -u -p -r1.81 insetert.h
--- insetert.h  25 Jul 2003 21:20:19 -0000      1.81
+++ insetert.h  21 Aug 2003 14:33:51 -0000
@@ -82,7 +82,7 @@ public:
        ///
        // this are needed here because of the label/inlined functionallity
        ///
-       bool needFullRow() const { return status_ == Open; }
+       //bool needFullRow() const { return status_ == Open; }
        ///
        bool isOpen() const { return status_ == Open || status_ == Inlined; }
        ///
Index: insetfloatlist.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetfloatlist.C,v
retrieving revision 1.36
diff -u -p -r1.36 insetfloatlist.C
--- insetfloatlist.C    27 Jul 2003 13:18:55 -0000      1.36
+++ insetfloatlist.C    21 Aug 2003 14:33:51 -0000
@@ -12,6 +12,7 @@
 
 #include "insetfloatlist.h"
 #include "FloatList.h"
+#include "metricsinfo.h"
 #include "LaTeXFeatures.h"
 #include "lyxlex.h"
 #include "BufferView.h"
@@ -95,6 +96,22 @@ void InsetFloatList::read(Buffer const *
                               "Read: `$$Token'");
        }
 }
+
+
+void InsetFloatList::metrics(MetricsInfo & mi, Dimension & dim) const
+{
+       InsetCommand::metrics(mi, dim);
+       center_indent_ = (mi.base.textwidth - dim.wid) / 2;
+       dim.wid = mi.base.textwidth;
+       dim_ = dim;
+}
+
+
+void InsetFloatList::draw(PainterInfo & pi, int x, int y) const
+{
+       InsetCommand::draw(pi, x + center_indent_, y);
+}
+
 
 
 dispatch_result InsetFloatList::localDispatch(FuncRequest const & cmd)
Index: insetfloatlist.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetfloatlist.h,v
retrieving revision 1.26
diff -u -p -r1.26 insetfloatlist.h
--- insetfloatlist.h    25 Jul 2003 21:20:20 -0000      1.26
+++ insetfloatlist.h    21 Aug 2003 14:33:51 -0000
@@ -30,13 +30,17 @@ public:
                return std::auto_ptr<InsetBase>(new InsetFloatList(getCmdName()));
        }
        ///
+       void metrics(MetricsInfo &, Dimension &) const;
+       ///
+       void draw(PainterInfo & pi, int x, int y) const;
+       ///
        dispatch_result localDispatch(FuncRequest const & cmd);
        ///
        string const getScreenLabel(Buffer const *) const;
        ///
        EDITABLE editable() const { return IS_EDITABLE; }
        ///
-       bool display() const { return true; }
+       //bool display() const { return true; }
        ///
        InsetOld::Code lyxCode() const;
        ///
@@ -54,6 +58,9 @@ public:
        int ascii(Buffer const *, std::ostream &, int linelen) const;
        ///
        void validate(LaTeXFeatures & features) const;
+
+private:
+       mutable unsigned int center_indent_;
 };
 
 #endif
Index: insetfootlike.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetfootlike.C,v
retrieving revision 1.23
diff -u -p -r1.23 insetfootlike.C
--- insetfootlike.C     30 Jul 2003 15:41:39 -0000      1.23
+++ insetfootlike.C     21 Aug 2003 14:33:51 -0000
@@ -11,6 +11,7 @@
 #include <config.h>
 
 #include "insetfootlike.h"
+#include "metricsinfo.h"
 #include "lyxfont.h"
 #include "buffer.h"
 #include "lyxtext.h"
@@ -39,6 +40,14 @@ InsetFootlike::InsetFootlike(InsetFootli
        font.decSize();
        font.setColor(LColor::collapsable);
        setLabelFont(font);
+}
+
+void InsetFootlike::metrics(MetricsInfo & mi, Dimension & dim) const
+{
+               InsetCollapsable::metrics(mi, dim);
+               if (isOpen()) 
+                       dim.wid = mi.base.textwidth;
+               dim_ = dim;
 }
 
 
Index: insetfootlike.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetfootlike.h,v
retrieving revision 1.17
diff -u -p -r1.17 insetfootlike.h
--- insetfootlike.h     25 Jul 2003 21:20:20 -0000      1.17
+++ insetfootlike.h     21 Aug 2003 14:33:51 -0000
@@ -24,6 +24,8 @@ public:
        ///
        InsetFootlike(InsetFootlike const &);
        ///
+       void metrics(MetricsInfo &, Dimension &) const;
+       ///
        void write(Buffer const * buf, std::ostream & os) const;
        ///
        bool insetAllowed(InsetOld::Code) const;
Index: insetinclude.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetinclude.C,v
retrieving revision 1.134
diff -u -p -r1.134 insetinclude.C
--- insetinclude.C      5 Aug 2003 08:07:03 -0000       1.134
+++ insetinclude.C      21 Aug 2003 14:33:51 -0000
@@ -241,12 +241,12 @@ void InsetInclude::read(Buffer const *, 
        }
 }
 
-
+#if 0
 bool InsetInclude::display() const
 {
        return !(params_.flag == INPUT);
 }
-
+#endif
 
 string const InsetInclude::getScreenLabel(Buffer const *) const
 {
@@ -530,6 +530,11 @@ void InsetInclude::metrics(MetricsInfo &
                }
                button_.metrics(mi, dim);
        }
+       if (params_.flag == INPUT)
+               center_indent_ = 0;
+       else
+               center_indent_ = (mi.base.textwidth - dim.wid) / 2;
+       dim.wid = mi.base.textwidth;
        dim_ = dim;
 }
 
@@ -538,14 +543,14 @@ void InsetInclude::draw(PainterInfo & pi
 {
        cache(pi.base.bv);
        if (!preview_->previewReady()) {
-               button_.draw(pi, x, y);
+               button_.draw(pi, x + center_indent_, y);
                return;
        }
 
        if (!preview_->monitoring())
                preview_->startMonitoring();
 
-       pi.pain.image(x, y - dim_.asc, dim_.wid, dim_.height(),
+       pi.pain.image(x + center_indent_, y - dim_.asc, dim_.wid, dim_.height(),
                            *(preview_->pimage()->image()));
 }
 
Index: insetinclude.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetinclude.h,v
retrieving revision 1.76
diff -u -p -r1.76 insetinclude.h
--- insetinclude.h      25 Jul 2003 21:20:20 -0000      1.76
+++ insetinclude.h      21 Aug 2003 14:33:51 -0000
@@ -103,7 +103,7 @@ public:
        void validate(LaTeXFeatures &) const;
 
        /// take up a whole row if we're not type INPUT
-       bool display() const;
+       //bool display() const;
 
        /// return true if the file is or got loaded.
        bool loadIfNeeded() const;
@@ -135,6 +135,7 @@ private:
        /// cache
        mutable bool set_label_;
        mutable ButtonRenderer button_;
+       mutable unsigned int center_indent_;
 };
 
 
Index: insetindex.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetindex.C,v
retrieving revision 1.42
diff -u -p -r1.42 insetindex.C
--- insetindex.C        25 Jul 2003 21:20:20 -0000      1.42
+++ insetindex.C        21 Aug 2003 14:33:51 -0000
@@ -11,6 +11,7 @@
 
 
 #include "insetindex.h"
+#include "metricsinfo.h"
 #include "BufferView.h"
 #include "funcrequest.h"
 #include "frontends/LyXView.h"
@@ -41,6 +42,21 @@ InsetIndex::~InsetIndex()
 string const InsetIndex::getScreenLabel(Buffer const *) const
 {
        return _("Idx");
+}
+
+
+void InsetPrintIndex::metrics(MetricsInfo & mi, Dimension & dim) const
+{
+       InsetCommand::metrics(mi, dim);
+       center_indent_ = (mi.base.textwidth - dim.wid) / 2;
+       dim.wid = mi.base.textwidth;
+       dim_ = dim;
+}
+
+
+void InsetPrintIndex::draw(PainterInfo & pi, int x, int y) const
+{
+                   InsetCommand::draw(pi, x + center_indent_, y);
 }
 
 
Index: insetindex.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetindex.h,v
retrieving revision 1.40
diff -u -p -r1.40 insetindex.h
--- insetindex.h        25 Jul 2003 21:20:20 -0000      1.40
+++ insetindex.h        21 Aug 2003 14:33:51 -0000
@@ -59,13 +59,20 @@ public:
        ///
        EDITABLE editable() const { return NOT_EDITABLE; }
        ///
-       bool display() const { return true; }
+       //bool display() const { return true; }
        ///
        InsetOld::Code lyxCode() const;
        ///
        string const getScreenLabel(Buffer const *) const;
        ///
-       virtual bool needFullRow() const { return true; }
+       //virtual bool needFullRow() const { return true; }
+       ///
+       void metrics(MetricsInfo &, Dimension &) const; 
+       ///
+       void draw(PainterInfo & pi, int x, int y) const;
+
+private:
+       mutable unsigned int center_indent_;
 };
 
 #endif
Index: insetminipage.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetminipage.h,v
retrieving revision 1.50
diff -u -p -r1.50 insetminipage.h
--- insetminipage.h     25 Jul 2003 21:20:20 -0000      1.50
+++ insetminipage.h     21 Aug 2003 14:33:51 -0000
@@ -79,7 +79,7 @@ public:
        ///
        bool insetAllowed(InsetOld::Code) const;
        ///
-       bool needFullRow() const { return false; }
+       //bool needFullRow() const { return false; }
        /** returns true if, when outputing LaTeX, font changes should
            be closed before generating this inset. This is needed for
            insets that may contain several paragraphs */
Index: insetnote.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetnote.C,v
retrieving revision 1.39
diff -u -p -r1.39 insetnote.C
--- insetnote.C 5 Aug 2003 08:07:03 -0000       1.39
+++ insetnote.C 21 Aug 2003 14:33:51 -0000
@@ -15,6 +15,7 @@
 #include "Lsstream.h"
 
 #include "insetnote.h"
+#include "metricsinfo.h"
 #include "gettext.h"
 #include "lyxfont.h"
 #include "language.h"
@@ -101,15 +102,30 @@ void InsetNote::setButtonLabel()
                setLabel(_("Comment"));
                font.setColor(LColor::comment);
                setBackgroundColor(LColor::commentbg);
-       } else {
+       } else if (params_.type == "Greyedout") {
                setLabel(_("Greyed Out"));
                font.setColor(LColor::greyedout);
                setBackgroundColor(LColor::greyedoutbg);
-       }
+       } else
+               setLabel(_("[Boxed]"));
+               font.setColor(LColor::greyedout);
+               setBackgroundColor(LColor::greyedoutbg);
        setLabelFont(font);
 }
 
 
+void InsetNote::metrics(MetricsInfo & mi, Dimension & dim) const
+{
+       InsetCollapsable::metrics(mi, dim);
+       // Contrary to Greyedout, these cannot be construed as part of the
+       // running text: make them stand on their own
+       if (params_.type == "Note" || params_.type == "Comment")
+               if (!collapsed_)
+                       dim.wid = mi.base.textwidth;
+       dim_ = dim;
+}
+
+
 bool InsetNote::showInsetDialog(BufferView * bv) const
 {
        InsetNoteMailer("note", const_cast<InsetNote &>(*this)).showDialog(bv);
@@ -166,16 +182,21 @@ int InsetNote::latex(Buffer const * buf,
        else if (pt == "Greyedout")
                 // we roll our own macro
                os << "%\n\\begin{lyxgreyedout}\n";
+       else if (pt == "Boxed")
+               os << "%\n\\fbox{\\parbox{\\columnwidth-2\\fboxsep-2\\fboxrule}{\n";
 
        if (pt != "Note")
                i = inset.latex(buf, os, runparams);
 
        if (pt == "Comment") {
                os << "%\n\\end{comment}\n";
-               i += 3;
+               i += 4;
        } else if (pt == "Greyedout") {
                os << "%\n\\end{lyxgreyedout}\n";
-               i += 2;
+               i += 4;
+       } else if (pt == "Boxed") {
+               os << "%\\medskip\n}}\n";
+               i += 4;
        }
        return i;
 }
@@ -239,6 +260,9 @@ void InsetNote::validate(LaTeXFeatures &
        if (params_.type == "Greyedout") {
                features.require("color");
                features.require("lyxgreyedout");
+       }
+       if (params_.type == "Boxed") {
+               features.require("calc");
        }
        inset.validate(features);
 }
Index: insetnote.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetnote.h,v
retrieving revision 1.27
diff -u -p -r1.27 insetnote.h
--- insetnote.h 25 Jul 2003 21:20:21 -0000      1.27
+++ insetnote.h 21 Aug 2003 14:33:51 -0000
@@ -53,6 +53,8 @@ public:
        void setButtonLabel();
        ///
        dispatch_result InsetNote::localDispatch(FuncRequest const &);
+       ///
+       void metrics(MetricsInfo &, Dimension &) const;
        /// show the note dialog
        bool showInsetDialog(BufferView * bv) const;
        ///
Index: insettheorem.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettheorem.C,v
retrieving revision 1.18
diff -u -p -r1.18 insettheorem.C
--- insettheorem.C      16 Jun 2003 11:49:34 -0000      1.18
+++ insettheorem.C      21 Aug 2003 14:33:51 -0000
@@ -12,6 +12,7 @@
 
 
 #include "insettheorem.h"
+#include "metricsinfo.h"
 #include "gettext.h"
 #include "lyxfont.h"
 #include "BufferView.h"
@@ -62,6 +63,20 @@ InsetBase * InsetTheorem::clone() const
 
        result->collapsed_ = collapsed_;
        return result;
+}
+
+void InsetTheorem::metrics(MetricsInfo & mi, Dimension & dim) const
+{
+       InsetCollapsable::metrics(mi, dim);
+       center_indent_ = (mi.base.textwidth - dim.wid) / 2;
+       dim.wid = mi.base.textwidth;
+       dim_ = dim;
+}
+
+
+void InsetTOC::draw(PainterInfo & pi, int x, int y) const
+{
+       InsetCollapsable::draw(pi, x + center_indent_, y);
 }
 
 
Index: insettheorem.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettheorem.h,v
retrieving revision 1.17
diff -u -p -r1.17 insettheorem.h
--- insettheorem.h      16 Jun 2003 11:49:34 -0000      1.17
+++ insettheorem.h      21 Aug 2003 14:33:51 -0000
@@ -29,12 +29,19 @@ public:
        ///
        Inset::Code lyxCode() const { return Inset::THEOREM_CODE; }
        ///
-       bool display() const { return true; }
+       void metrics(MetricsInfo &, Dimension &) const;
+       ///
+       void draw(PainterInfo & pi, int x, int y) const;
+       ///
+       //bool display() const { return true; }
        ///
        int latex(Buffer const *, std::ostream &,
                  LatexRunParams const &) const;
        ///
        string const editMessage() const;
+
+private:
+       mutable unsigned int center_indent_;
 };
 
 #endif
Index: insettoc.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettoc.C,v
retrieving revision 1.47
diff -u -p -r1.47 insettoc.C
--- insettoc.C  27 Jul 2003 13:18:55 -0000      1.47
+++ insettoc.C  21 Aug 2003 14:33:51 -0000
@@ -54,6 +54,21 @@ InsetOld::Code InsetTOC::lyxCode() const
 }
 
 
+void InsetTOC::metrics(MetricsInfo & mi, Dimension & dim) const
+{
+       InsetCommand::metrics(mi, dim);
+       center_indent_ = (mi.base.textwidth - dim.wid) / 2;
+       dim.wid = mi.base.textwidth;
+       dim_ = dim;
+}
+
+
+void InsetTOC::draw(PainterInfo & pi, int x, int y) const
+{
+       InsetCommand::draw(pi, x + center_indent_, y);
+}
+
+
 dispatch_result InsetTOC::localDispatch(FuncRequest const & cmd)
 {
        switch (cmd.action) {
Index: insettoc.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettoc.h,v
retrieving revision 1.44
diff -u -p -r1.44 insettoc.h
--- insettoc.h  25 Jul 2003 21:20:22 -0000      1.44
+++ insettoc.h  21 Aug 2003 14:33:51 -0000
@@ -14,6 +14,7 @@
 
 
 #include "insetcommand.h"
+#include "metricsinfo.h"
 
 /** Used to insert table of contents
  */
@@ -28,13 +29,17 @@ public:
                return std::auto_ptr<InsetBase>(new InsetTOC(params()));
        }
        ///
+       void metrics(MetricsInfo &, Dimension &) const;
+       ///
+       void draw(PainterInfo & pi, int x, int y) const;
+       ///
        dispatch_result localDispatch(FuncRequest const & cmd);
        ///
        string const getScreenLabel(Buffer const *) const;
        ///
        EDITABLE editable() const { return IS_EDITABLE; }
        ///
-       bool display() const { return true; }
+       //bool display() const { return true; }
        ///
        InsetOld::Code lyxCode() const;
        ///
@@ -43,6 +48,9 @@ public:
        int linuxdoc(Buffer const *, std::ostream &) const;
        ///
        int docbook(Buffer const *, std::ostream &, bool mixcont) const;
+
+private:
+       mutable unsigned int center_indent_;
 };
 
 #endif

Attachment: pgp00000.pgp
Description: PGP signature

Reply via email to