On Sun, Apr 29, 2007 at 01:00:40PM +0200, Jean-Marc Lasgouttes wrote:
> >>>>> "Andre" == Andre Poenitz <[EMAIL PROTECTED]> writes:
> 
> >> What do you think?
> 
> Andre> But I do not really want 'name_' in InstBase. _Every_ character
> Andre> in math will contain that...
> 
> Andre> Of course we could implement name_ several times fuirther down
> Andre> in the hierarchy...
> 
> Do we really need to _set_ the inset name? Couldn'it be just a virtual
> method returning the name?

That would be something like the attached [plus renaming of InsetBase to
Inset].

Andre'
Index: insets/InsetERT.h
===================================================================
--- insets/InsetERT.h   (revision 18084)
+++ insets/InsetERT.h   (working copy)
@@ -44,6 +44,8 @@
        ///
        InsetBase::Code lyxCode() const { return InsetBase::ERT_CODE; }
        ///
+       docstring getInsetName() const { return from_ascii("ERT"); }
+       ///
        void write(Buffer const & buf, std::ostream & os) const;
        ///
        void read(Buffer const & buf, Lexer & lex);
Index: insets/InsetTabular.h
===================================================================
--- insets/InsetTabular.h       (revision 18084)
+++ insets/InsetTabular.h       (working copy)
@@ -36,7 +36,7 @@
 #ifndef INSETTABULAR_H
 #define INSETTABULAR_H
 
-#include "Inset.h"
+#include "InsetBase.h"
 #include "MailInset.h"
 #include "Length.h"
 #include "InsetText.h"
@@ -661,7 +661,7 @@
 
 
 
-class InsetTabular : public InsetOld {
+class InsetTabular : public InsetBase {
 public:
        ///
        InsetTabular(Buffer const &, row_type rows = 1,
Index: insets/InsetGraphics.h
===================================================================
--- insets/InsetGraphics.h      (revision 18084)
+++ insets/InsetGraphics.h      (working copy)
@@ -13,7 +13,7 @@
 #ifndef INSET_GRAPHICS_H
 #define INSET_GRAPHICS_H
 
-#include "Inset.h"
+#include "InsetBase.h"
 #include "InsetGraphicsParams.h"
 #include "MailInset.h"
 
@@ -28,7 +28,7 @@
 class LaTeXFeatures;
 
 ///
-class InsetGraphics : public InsetOld, public boost::signals::trackable {
+class InsetGraphics : public InsetBase, public boost::signals::trackable {
 public:
        ///
        InsetGraphics();
Index: insets/InsetFoot.cpp
===================================================================
--- insets/InsetFoot.cpp        (revision 18084)
+++ insets/InsetFoot.cpp        (working copy)
@@ -35,7 +35,6 @@
        : InsetFootlike(bp)
 {
        setLabel(_("foot"));
-       setInsetName(from_ascii("Foot"));
 }
 
 
@@ -43,7 +42,6 @@
        : InsetFootlike(in)
 {
        setLabel(_("foot"));
-       setInsetName(from_ascii("Foot"));
 }
 
 
Index: insets/InsetWrap.h
===================================================================
--- insets/InsetWrap.h  (revision 18084)
+++ insets/InsetWrap.h  (working copy)
@@ -76,11 +76,15 @@
 protected:
        ///
        virtual void doDispatch(Cursor & cur, FuncRequest & cmd);
+       ///
+       virtual docstring getInsetName() const { return name_; }
 private:
        virtual std::auto_ptr<InsetBase> doClone() const;
 
        ///
        InsetWrapParams params_;
+       ///
+       docstring name_;
 };
 
 
Index: insets/Inset.cpp
===================================================================
--- insets/Inset.cpp    (revision 18084)
+++ insets/Inset.cpp    (working copy)
@@ -1,47 +0,0 @@
-/**
- * \file Inset.cpp
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Alejandro Aguilar Sierra
- * \author J�rgen Vigna
- * \author Lars Gullik Bj�nnes
- * \author Matthias Ettrich
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "Inset.h"
-
-#include "BufferView.h"
-#include "debug.h"
-#include "gettext.h"
-#include "LyXText.h"
-#include "MetricsInfo.h"
-#include "CoordCache.h"
-
-
-namespace lyx {
-
-using std::string;
-
-
-InsetOld::InsetOld()
-{}
-
-
-InsetOld::InsetOld(InsetOld const & in)
-       : InsetBase(in), name_(in.name_)
-{}
-
-
-void InsetOld::setPosCache(PainterInfo const & pi, int x, int y) const
-{
-       //lyxerr << "InsetOld:: position cache to " << x << " " << y << 
std::endl;
-       pi.base.bv->coordCache().insets().add(this, x, y);
-}
-
-
-} // namespace lyx
Index: insets/InsetExternal.cpp
===================================================================
--- insets/InsetExternal.cpp    (revision 18084)
+++ insets/InsetExternal.cpp    (working copy)
@@ -400,7 +400,7 @@
 
 
 InsetExternal::InsetExternal(InsetExternal const & other)
-       : InsetOld(other),
+       : InsetBase(other),
          boost::signals::trackable(),
          params_(other.params_),
          renderer_(other.renderer_->clone(this))
Index: insets/InsetQuotes.h
===================================================================
--- insets/InsetQuotes.h        (revision 18084)
+++ insets/InsetQuotes.h        (working copy)
@@ -13,7 +13,7 @@
 #define INSET_QUOTES_H
 
 
-#include "Inset.h"
+#include "InsetBase.h"
 
 #include "support/types.h"
 
@@ -28,7 +28,7 @@
 /** Quotes.
   Used for the various quotes. German, English, French, all either
   double or single **/
-class InsetQuotes : public InsetOld {
+class InsetQuotes : public InsetBase {
 public:
        ///
        enum quote_language {
@@ -74,6 +74,8 @@
        /// Direct access to inner/outer quotation marks
        InsetQuotes(char_type c, quote_language l, quote_times t);
        ///
+       docstring getInsetName() const { return from_ascii("Quotes"); }
+       ///
        bool metrics(MetricsInfo &, Dimension &) const;
        ///
        void draw(PainterInfo & pi, int x, int y) const;
Index: insets/InsetVSpace.h
===================================================================
--- insets/InsetVSpace.h        (revision 18084)
+++ insets/InsetVSpace.h        (working copy)
@@ -13,14 +13,14 @@
 #define INSET_VSPACE_H
 
 
-#include "Inset.h"
+#include "InsetBase.h"
 #include "VSpace.h"
 #include "MailInset.h"
 
 
 namespace lyx {
 
-class InsetVSpace : public InsetOld {
+class InsetVSpace : public InsetBase {
 public:
        ///
        InsetVSpace() {}
Index: insets/InsetMarginal.cpp
===================================================================
--- insets/InsetMarginal.cpp    (revision 18084)
+++ insets/InsetMarginal.cpp    (working copy)
@@ -31,7 +31,6 @@
        : InsetFootlike(bp)
 {
        setLabel(_("margin"));
-       setInsetName(from_ascii("Marginal"));
 }
 
 
@@ -39,7 +38,6 @@
        : InsetFootlike(in)
 {
        setLabel(_("margin"));
-       setInsetName(from_ascii("Marginal"));
 }
 
 
Index: insets/InsetERT.cpp
===================================================================
--- insets/InsetERT.cpp (revision 18084)
+++ insets/InsetERT.cpp (working copy)
@@ -53,7 +53,6 @@
 void InsetERT::init()
 {
        setButtonLabel();
-
        LyXFont font(LyXFont::ALL_SANE);
        font.decSize();
        font.decSize();
@@ -61,8 +60,6 @@
        setLabelFont(font);
        text_.current_font.setLanguage(latex_language);
        text_.real_current_font.setLanguage(latex_language);
-
-       setInsetName(from_ascii("ERT"));
 }
 
 
Index: insets/InsetTabular.cpp
===================================================================
--- insets/InsetTabular.cpp     (revision 18084)
+++ insets/InsetTabular.cpp     (working copy)
@@ -2874,7 +2874,7 @@
 
 
 InsetTabular::InsetTabular(InsetTabular const & tab)
-       : InsetOld(tab), tabular(tab.tabular),
+       : InsetBase(tab), tabular(tab.tabular),
                buffer_(tab.buffer_), scx_(0), is_deleted_(false)
 {}
 
Index: insets/InsetBox.h
===================================================================
--- insets/InsetBox.h   (revision 18084)
+++ insets/InsetBox.h   (working copy)
@@ -109,6 +109,8 @@
        virtual void doDispatch(Cursor & cur, FuncRequest & cmd);
        /// Is the width forced to some value?
        virtual bool hasFixedWidth() const;
+       ///
+       virtual docstring getInsetName() const { return from_ascii("Box"); }
 private:
        friend class InsetBoxParams;
 
Index: insets/InsetBranch.cpp
===================================================================
--- insets/InsetBranch.cpp      (revision 18084)
+++ insets/InsetBranch.cpp      (working copy)
@@ -39,7 +39,6 @@
 
 void InsetBranch::init()
 {
-       setInsetName(from_utf8("Branch"));
        setButtonLabel();
 }
 
Index: insets/InsetGraphics.cpp
===================================================================
--- insets/InsetGraphics.cpp    (revision 18084)
+++ insets/InsetGraphics.cpp    (working copy)
@@ -153,7 +153,7 @@
 
 
 InsetGraphics::InsetGraphics(InsetGraphics const & ig)
-       : InsetOld(ig),
+       : InsetBase(ig),
          boost::signals::trackable(),
                graphic_label(sgml::uniqueID(from_ascii("graph"))),
          graphic_(new RenderGraphic(*ig.graphic_, this))
Index: insets/InsetSpace.h
===================================================================
--- insets/InsetSpace.h (revision 18084)
+++ insets/InsetSpace.h (working copy)
@@ -16,7 +16,7 @@
 #define INSET_SPACE_H
 
 
-#include "Inset.h"
+#include "InsetBase.h"
 
 
 namespace lyx {
@@ -24,7 +24,7 @@
 class LaTeXFeatures;
 
 ///  Used to insert different kinds of spaces
-class InsetSpace : public InsetOld {
+class InsetSpace : public InsetBase {
 public:
 
        /// The different kinds of spaces we support
Index: insets/InsetCharStyle.h
===================================================================
--- insets/InsetCharStyle.h     (revision 18084)
+++ insets/InsetCharStyle.h     (working copy)
@@ -52,6 +52,8 @@
        InsetCharStyle(BufferParams const &, std::string const);
        ///
        InsetCharStyle(BufferParams const &, CharStyles::iterator);
+       ///
+       docstring getInsetName() const { return from_ascii("CharStyle"); }
        /// Is this character style defined in the document's textclass?
        /// May be wrong after textclass change or paste from another document
        bool undefined() const;
Index: insets/InsetNote.cpp
===================================================================
--- insets/InsetNote.cpp        (revision 18084)
+++ insets/InsetNote.cpp        (working copy)
@@ -112,7 +112,6 @@
 
 void InsetNote::init()
 {
-       setInsetName(from_ascii("Note"));
        setButtonLabel();
 }
 
Index: insets/InsetFoot.h
===================================================================
--- insets/InsetFoot.h  (revision 18084)
+++ insets/InsetFoot.h  (working copy)
@@ -28,6 +28,8 @@
        ///
        InsetBase::Code lyxCode() const { return InsetBase::FOOT_CODE; }
        ///
+       docstring getInsetName() const { return from_ascii("Foot"); }
+       ///
        int latex(Buffer const &, odocstream &,
                  OutputParams const &) const;
        ///
Index: insets/RenderPreview.cpp
===================================================================
--- insets/RenderPreview.cpp    (revision 18084)
+++ insets/RenderPreview.cpp    (working copy)
@@ -11,12 +11,12 @@
 #include <config.h>
 
 #include "insets/RenderPreview.h"
-#include "insets/Inset.h"
+#include "insets/InsetBase.h"
 
 #include "BufferView.h"
+#include "Color.h"
 #include "Dimension.h"
 #include "gettext.h"
-#include "Color.h"
 #include "LyX.h"
 #include "LyXRC.h"
 #include "MetricsInfo.h"
@@ -154,7 +154,7 @@
                              *image);
 
        } else {
-               int const offset = InsetOld::TEXT_TO_INSET_OFFSET;
+               int const offset = InsetBase::TEXT_TO_INSET_OFFSET;
 
                pi.pain.rectangle(x + offset,
                                  y - dim_.asc,
Index: insets/InsetQuotes.cpp
===================================================================
--- insets/InsetQuotes.cpp      (revision 18084)
+++ insets/InsetQuotes.cpp      (working copy)
@@ -85,14 +85,12 @@
 InsetQuotes::InsetQuotes(string const & str)
 {
        parseString(str);
-       setInsetName(from_utf8("InsetQuotes"));
 }
 
 
 InsetQuotes::InsetQuotes(quote_language l, quote_side s, quote_times t)
        : language_(l), side_(s), times_(t)
 {
-       setInsetName(from_utf8("InsetQuotes"));
 }
 
 
@@ -100,7 +98,6 @@
        : language_(params.quotes_language), times_(params.quotes_times)
 {
        getPosition(c);
-       setInsetName(from_utf8("InsetQuotes"));
 }
 
 
@@ -108,7 +105,6 @@
        : language_(l), times_(t)
 {
        getPosition(c);
-       setInsetName(from_utf8("InsetQuotes"));
 }
 
 
Index: insets/InsetInclude.cpp
===================================================================
--- insets/InsetInclude.cpp     (revision 18084)
+++ insets/InsetInclude.cpp     (working copy)
@@ -104,7 +104,7 @@
 
 
 InsetInclude::InsetInclude(InsetInclude const & other)
-       : InsetOld(other),
+       : InsetBase(other),
          params_(other.params_),
          include_label(other.include_label),
          preview_(new RenderMonitoredPreview(this)),
Index: insets/Inset.h
===================================================================
--- insets/Inset.h      (revision 18084)
+++ insets/Inset.h      (working copy)
@@ -1,68 +0,0 @@
-// -*- C++ -*-
-/**
- * \file Inset.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Alejandro Aguilar Sierra
- * \author J�rgen Vigna
- * \author Lars Gullik Bj�nnes
- * \author Matthias Ettrich
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef INSETOLD_H
-#define INSETOLD_H
-
-#include "InsetBase.h"
-
-
-namespace lyx {
-
-/// Insets
-class InsetOld : public InsetBase {
-public:
-       ///
-       enum {
-               ///
-               TEXT_TO_INSET_OFFSET = 4
-       };
-
-       ///
-       InsetOld();
-
-       ///
-       void setInsetName(docstring const & s) { name_ = s; }
-       ///
-       virtual docstring const & getInsetName() const { return name_; }
-       /// set x/y drawing position cache
-       void setPosCache(PainterInfo const &, int, int) const;
-
-protected:
-       ///
-       InsetOld(InsetOld const & in);
-
-private:
-       InsetOld & operator=(InsetOld const &) const;
-
-       ///
-       docstring name_;
-};
-
-
-/** \c InsetBase_code is a wrapper for InsetBase::Code.
- *  It can be forward-declared and passed as a function argument without
- *  having to expose Inset.h.
- */
-class InsetBase_code {
-       InsetBase::Code val_;
-public:
-       InsetBase_code(InsetBase::Code val) : val_(val) {}
-       operator InsetBase::Code() const { return val_; }
-};
-
-
-} // namespace lyx
-
-#endif
Index: insets/InsetBox.cpp
===================================================================
--- insets/InsetBox.cpp (revision 18084)
+++ insets/InsetBox.cpp (working copy)
@@ -90,7 +90,6 @@
 
 void InsetBox::init()
 {
-       setInsetName(from_ascii("Box"));
        setButtonLabel();
 }
 
Index: insets/InsetLine.h
===================================================================
--- insets/InsetLine.h  (revision 18084)
+++ insets/InsetLine.h  (working copy)
@@ -13,12 +13,12 @@
 #define INSET_LINE_H
 
 
-#include "Inset.h"
+#include "InsetBase.h"
 
 
 namespace lyx {
 
-class InsetLine : public InsetOld {
+class InsetLine : public InsetBase {
 public:
 
        InsetLine() {}
Index: insets/InsetCharStyle.cpp
===================================================================
--- insets/InsetCharStyle.cpp   (revision 18084)
+++ insets/InsetCharStyle.cpp   (working copy)
@@ -51,7 +51,6 @@
 
 void InsetCharStyle::init()
 {
-       setInsetName(from_utf8("CharStyle"));
        setInlined();
        setDrawFrame(false);
 }
Index: insets/InsetBranch.h
===================================================================
--- insets/InsetBranch.h        (revision 18084)
+++ insets/InsetBranch.h        (working copy)
@@ -80,8 +80,12 @@
        bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
 
 protected:
+       ///
        InsetBranch(InsetBranch const &);
+       ///
        virtual void doDispatch(Cursor & cur, FuncRequest & cmd);
+       ///
+       docstring getInsetName() const { return from_ascii("Branch"); }
 private:
        friend class InsetBranchParams;
 
Index: insets/InsetTheorem.cpp
===================================================================
--- insets/InsetTheorem.cpp     (revision 18084)
+++ insets/InsetTheorem.cpp     (working copy)
@@ -1,5 +1,5 @@
 /**
- * \file InsetTheorem.cpp
+ * \file InsetBase.heorem.cpp
  * This file is part of LyX, the document processor.
  * Licence details can be found in the file COPYING.
  *
@@ -10,7 +10,7 @@
 
 #include <config.h>
 
-#include "InsetTheorem.h"
+#include "InsetBase.heorem.h"
 #include "insets/InsetText.h"
 
 #include "debug.h"
@@ -35,7 +35,7 @@
    user.
 */
 
-InsetTheorem::InsetTheorem()
+InsetBase.heorem::InsetTheorem()
        : InsetCollapsable()
 {
        setLabel(_("theorem"));
@@ -51,25 +51,25 @@
 }
 
 
-void InsetTheorem::write(Buffer const * buf, ostream & os) const
+void InsetBase.heorem::write(Buffer const * buf, ostream & os) const
 {
        os << getInsetName() << "\n";
        InsetCollapsable::write(buf, os);
 }
 
 
-auto_ptr<InsetBase> InsetTheorem::doClone() const
+auto_ptr<InsetBase> InsetBase.heorem::doClone() const
 {
 #ifdef WITH_WARNINGS
 #warning Is this inset used? If YES this is WRONG!!! (Jug)
 #endif
-       auto_ptr<InsetTheorem> result(new InsetTheorem);
+       auto_ptr<InsetBase.heorem> result(new InsetTheorem);
        result->setCollapsed(!isOpen());
 
        return result;
 }
 
-bool InsetTheorem::metrics(MetricsInfo & mi, Dimension & dim) const
+bool InsetBase.heorem::metrics(MetricsInfo & mi, Dimension & dim) const
 {
        InsetCollapsable::metrics(mi, dim);
        center_indent_ = (mi.base.textwidth - dim.wid) / 2;
@@ -86,13 +86,13 @@
 }
 
 
-string const InsetTheorem::editMessage() const
+string const InsetBase.heorem::editMessage() const
 {
        return _("Opened Theorem Inset");
 }
 
 
-int InsetTheorem::latex(Buffer const * buf, odocstream & os,
+int InsetBase.heorem::latex(Buffer const * buf, odocstream & os,
                        OutputParams const & runparams) const
 {
        os << "\\begin{theorem}%\n";
Index: insets/InsetFloat.cpp
===================================================================
--- insets/InsetFloat.cpp       (revision 18084)
+++ insets/InsetFloat.cpp       (working copy)
@@ -116,7 +116,7 @@
 
 
 InsetFloat::InsetFloat(BufferParams const & bp, string const & type)
-       : InsetCollapsable(bp)
+       : InsetCollapsable(bp), name_(from_utf8(type))
 {
        setLabel(_("float: ") + floatName(type, bp));
        LyXFont font(LyXFont::ALL_SANE);
@@ -125,7 +125,6 @@
        font.setColor(Color::collapsable);
        setLabelFont(font);
        params_.type = type;
-       setInsetName(from_utf8(type));
 }
 
 
Index: insets/InsetNewline.h
===================================================================
--- insets/InsetNewline.h       (revision 18084)
+++ insets/InsetNewline.h       (working copy)
@@ -13,12 +13,12 @@
 #define INSET_NEWLINE_H
 
 
-#include "Inset.h"
+#include "InsetBase.h"
 
 
 namespace lyx {
 
-class InsetNewline : public InsetOld {
+class InsetNewline : public InsetBase {
 public:
 
        InsetNewline() {}
Index: insets/InsetEnvironment.h
===================================================================
--- insets/InsetEnvironment.h   (revision 18084)
+++ insets/InsetEnvironment.h   (working copy)
@@ -23,6 +23,8 @@
        ///
        InsetEnvironment(BufferParams const &, std::string const & name);
        ///
+       docstring getInsetName() const { return name_; }
+       ///
        void write(Buffer const & buf, std::ostream & os) const;
        ///
        void read(Buffer const & buf, Lexer & lex);
@@ -50,6 +52,8 @@
        virtual std::auto_ptr<InsetBase> doClone() const;
        /// the layout
        LyXLayout_ptr layout_;
+       ///
+       docstring name_;
 };
 
 
Index: insets/InsetNote.h
===================================================================
--- insets/InsetNote.h  (revision 18084)
+++ insets/InsetNote.h  (working copy)
@@ -52,6 +52,8 @@
        ///
        InsetBase::Code lyxCode() const { return InsetBase::NOTE_CODE; }
        ///
+       docstring getInsetName() const { return from_ascii("Note"); }
+       ///
        void write(Buffer const &, std::ostream &) const;
        ///
        void read(Buffer const & buf, Lexer & lex);
Index: insets/RenderGraphic.cpp
===================================================================
--- insets/RenderGraphic.cpp    (revision 18084)
+++ insets/RenderGraphic.cpp    (working copy)
@@ -12,7 +12,7 @@
 
 #include "RenderGraphic.h"
 
-#include "insets/Inset.h"
+#include "insets/InsetBase.h"
 
 #include "gettext.h"
 #include "Color.h"
@@ -149,7 +149,7 @@
 
        if (image_ready) {
                dim.wid = loader_.image()->getWidth() +
-                       2 * InsetOld::TEXT_TO_INSET_OFFSET;
+                       2 * InsetBase::TEXT_TO_INSET_OFFSET;
        } else {
                int font_width = 0;
 
@@ -194,16 +194,16 @@
        // loaded yet, we draw just a rectangle.
 
        if (displayGraphic(params_) && readyToDisplay(loader_)) {
-               pi.pain.image(x + InsetOld::TEXT_TO_INSET_OFFSET,
+               pi.pain.image(x + InsetBase::TEXT_TO_INSET_OFFSET,
                              y - dim_.asc,
-                             dim_.wid - 2 * InsetOld::TEXT_TO_INSET_OFFSET,
+                             dim_.wid - 2 * InsetBase::TEXT_TO_INSET_OFFSET,
                              dim_.asc + dim_.des,
                              *loader_.image());
 
        } else {
-               pi.pain.rectangle(x + InsetOld::TEXT_TO_INSET_OFFSET,
+               pi.pain.rectangle(x + InsetBase::TEXT_TO_INSET_OFFSET,
                                  y - dim_.asc,
-                                 dim_.wid - 2 * InsetOld::TEXT_TO_INSET_OFFSET,
+                                 dim_.wid - 2 * 
InsetBase::TEXT_TO_INSET_OFFSET,
                                  dim_.asc + dim_.des,
                                  Color::foreground);
 
@@ -214,7 +214,7 @@
 
                if (!justname.empty()) {
                        msgFont.setSize(LyXFont::SIZE_FOOTNOTE);
-                       pi.pain.text(x + InsetOld::TEXT_TO_INSET_OFFSET + 6,
+                       pi.pain.text(x + InsetBase::TEXT_TO_INSET_OFFSET + 6,
                                   y - theFontMetrics(msgFont).maxAscent() - 4,
                                   from_utf8(justname), msgFont);
                }
@@ -223,7 +223,7 @@
                docstring const msg = statusMessage(params_, loader_.status());
                if (!msg.empty()) {
                        msgFont.setSize(LyXFont::SIZE_TINY);
-                       pi.pain.text(x + InsetOld::TEXT_TO_INSET_OFFSET + 6,
+                       pi.pain.text(x + InsetBase::TEXT_TO_INSET_OFFSET + 6,
                                     y - 4, msg, msgFont);
                }
        }
Index: insets/InsetBase.h
===================================================================
--- insets/InsetBase.h  (revision 18084)
+++ insets/InsetBase.h  (working copy)
@@ -4,7 +4,10 @@
  * This file is part of LyX, the document processor.
  * Licence details can be found in the file COPYING.
  *
- * \author none
+ * \author Alejandro Aguilar Sierra
+ * \author Jürgen Vigna
+ * \author Lars Gullik Bjønnes
+ * \author Matthias Ettrich
  *
  * Full author contact details are available in file CREDITS.
  */
@@ -133,7 +136,7 @@
        /// last drawn position for 'important' insets
        int yo(BufferView const & bv) const;
        /// set x/y drawing position cache if available
-       virtual void setPosCache(PainterInfo const &, int, int) const {}
+       virtual void setPosCache(PainterInfo const &, int, int) const;
        /// do we cover screen position x/y?
        virtual bool covers(BufferView const & bv, int x, int y) const;
        /// get the screen positions of the cursor (see note in Cursor.cpp)
@@ -362,7 +365,7 @@
        virtual bool hasFixedWidth() const { return false; }
 
        ///
-       virtual docstring const & getInsetName() const;
+       virtual docstring getInsetName() const;
        /// used to toggle insets
        /// is the inset open?
        /// should this inset be handled like a normal charater
@@ -457,6 +460,9 @@
        };
        ///
        virtual void setStatus(Cursor &, CollapseStatus) {}
+       //
+       enum { TEXT_TO_INSET_OFFSET = 4 };
+
 protected:
        InsetBase();
        InsetBase(InsetBase const & i);
@@ -497,6 +503,20 @@
  */
 bool isHighlyEditableInset(InsetBase const * inset);
 
+/** \c InsetBase_code is a wrapper for InsetBase::Code.
+ *  It can be forward-declared and passed as a function argument without
+ *  having to expose InsetBase.h.
+ */
+
+class InsetBase_code {
+       InsetBase::Code val_;
+public:
+       InsetBase_code(InsetBase::Code val) : val_(val) {}
+       operator InsetBase::Code() const { return val_; }
+};
+
+
+
 } // namespace lyx
 
 #endif
Index: insets/InsetCollapsable.cpp
===================================================================
--- insets/InsetCollapsable.cpp (revision 18084)
+++ insets/InsetCollapsable.cpp (working copy)
@@ -58,24 +58,23 @@
        setAutoBreakRows(true);
        setDrawFrame(true);
        setFrameColor(Color::collapsableframe);
-       setInsetName(from_ascii("Collapsable"));
        setButtonLabel();
 }
 
 
-InsetCollapsable::InsetCollapsable(InsetCollapsable const & rhs):
-       InsetText(rhs),         
-       labelfont_(rhs.labelfont_),
-       button_dim(rhs.button_dim),
-       topx(rhs.topx),
-       topbaseline(rhs.topbaseline),
-       label(rhs.label),
-       status_(rhs.status_),
-       openinlined_(rhs.openinlined_),
-       autoOpen_(rhs.autoOpen_),
-       textdim_(rhs.textdim_),
-       // the sole purpose of this copy constructor
-       mouse_hover_(false)
+InsetCollapsable::InsetCollapsable(InsetCollapsable const & rhs)
+       : InsetText(rhs),       
+               labelfont_(rhs.labelfont_),
+               button_dim(rhs.button_dim),
+               topx(rhs.topx),
+               topbaseline(rhs.topbaseline),
+               label(rhs.label),
+               status_(rhs.status_),
+               openinlined_(rhs.openinlined_),
+               autoOpen_(rhs.autoOpen_),
+               textdim_(rhs.textdim_),
+               // the sole purpose of this copy constructor
+               mouse_hover_(false)
 {
 }
 
Index: insets/InsetCommand.h
===================================================================
--- insets/InsetCommand.h       (revision 18084)
+++ insets/InsetCommand.h       (working copy)
@@ -13,7 +13,7 @@
 #ifndef INSET_LATEXCOMMAND_H
 #define INSET_LATEXCOMMAND_H
 
-#include "Inset.h"
+#include "InsetBase.h"
 #include "InsetCommandParams.h"
 #include "RenderButton.h"
 #include "MailInset.h"
@@ -31,7 +31,7 @@
  */
 
 ///
-class InsetCommand : public InsetOld {
+class InsetCommand : public InsetBase {
 public:
        ///
        InsetCommand(InsetCommandParams const &, std::string const & 
mailer_name);
@@ -109,10 +109,13 @@
 private:
        ///
        InsetCommandParams p_;
+       ///
        std::string mailer_name_;
        /// changes color when mouse enters/leaves this inset
        bool mouse_hover_;
+       ///
        mutable bool updateButtonLabel_;
+       ///
        mutable RenderButton button_;
 };
 
Index: insets/InsetSpecialChar.h
===================================================================
--- insets/InsetSpecialChar.h   (revision 18084)
+++ insets/InsetSpecialChar.h   (working copy)
@@ -15,7 +15,7 @@
 #define INSET_SPECIALCHAR_H
 
 
-#include "Inset.h"
+#include "InsetBase.h"
 
 
 namespace lyx {
@@ -23,7 +23,7 @@
 class LaTeXFeatures;
 
 ///  Used to insert special chars
-class InsetSpecialChar : public InsetOld {
+class InsetSpecialChar : public InsetBase {
 public:
 
        /// The different kinds of special chars we support
Index: insets/InsetInclude.h
===================================================================
--- insets/InsetInclude.h       (revision 18084)
+++ insets/InsetInclude.h       (working copy)
@@ -12,7 +12,7 @@
 #ifndef INSET_INCLUDE_H
 #define INSET_INCLUDE_H
 
-#include "Inset.h"
+#include "InsetBase.h"
 #include "InsetCommandParams.h"
 #include "RenderButton.h"
 #include "MailInset.h"
@@ -30,7 +30,7 @@
 
 
 /// for including tex/lyx files
-class InsetInclude : public InsetOld {
+class InsetInclude : public InsetBase {
 public:
        ///
        InsetInclude(InsetCommandParams const &);
Index: insets/InsetText.h
===================================================================
--- insets/InsetText.h  (revision 18084)
+++ insets/InsetText.h  (working copy)
@@ -12,7 +12,7 @@
 #ifndef INSETTEXT_H
 #define INSETTEXT_H
 
-#include "Inset.h"
+#include "InsetBase.h"
 #include "RowList_fwd.h"
 #include "LyXFont.h"
 #include "LyXText.h"
@@ -37,7 +37,7 @@
  A text inset is like a TeX box to write full text
  (including styles and other insets) in a given space.
  */
-class InsetText : public InsetOld {
+class InsetText : public InsetBase {
 public:
        ///
        explicit InsetText(BufferParams const &);
Index: insets/InsetEnvironment.cpp
===================================================================
--- insets/InsetEnvironment.cpp (revision 18084)
+++ insets/InsetEnvironment.cpp (working copy)
@@ -29,9 +29,8 @@
 
 InsetEnvironment::InsetEnvironment
                (BufferParams const & bp, string const & name)
-       : InsetText(bp), layout_(bp.getLyXTextClass()[name])
+       : InsetText(bp), layout_(bp.getLyXTextClass()[name]), 
name_(from_utf8(name))
 {
-       setInsetName(from_utf8(name));
        setAutoBreakRows(true);
        setDrawFrame(true);
 }
Index: insets/InsetTheorem.h
===================================================================
--- insets/InsetTheorem.h       (revision 18084)
+++ insets/InsetTheorem.h       (working copy)
@@ -1,6 +1,6 @@
 // -*- C++ -*-
 /**
- * \file InsetTheorem.h
+ * \file InsetBase.heorem.h
  * This file is part of LyX, the document processor.
  * Licence details can be found in the file COPYING.
  *
@@ -9,8 +9,8 @@
  * Full author contact details are available in file CREDITS.
  */
 
-#ifndef InsetTheorem_H
-#define InsetTheorem_H
+#ifndef InsetBase.heorem_H
+#define InsetBase.heorem_H
 
 
 #include "InsetCollapsable.h"
@@ -21,10 +21,10 @@
 /** The theorem inset
 
 */
-class InsetTheorem : public InsetCollapsable {
+class InsetBase.heorem : public InsetCollapsable {
 public:
        ///
-       InsetTheorem();
+       InsetBase.heorem();
        ///
        void write(Buffer const & buf, std::ostream & os) const;
        ///
Index: insets/InsetWrap.cpp
===================================================================
--- insets/InsetWrap.cpp        (revision 18084)
+++ insets/InsetWrap.cpp        (working copy)
@@ -44,7 +44,7 @@
 
 
 InsetWrap::InsetWrap(BufferParams const & bp, string const & type)
-       : InsetCollapsable(bp)
+       : InsetCollapsable(bp), name_(from_utf8(type))
 {
        setLabel(_("wrap: ") + floatName(type, bp));
        LyXFont font(LyXFont::ALL_SANE);
@@ -54,7 +54,6 @@
        setLabelFont(font);
        params_.type = type;
        params_.width = Length(50, Length::PCW);
-       setInsetName(from_utf8(type));
 }
 
 
Index: insets/InsetFloat.h
===================================================================
--- insets/InsetFloat.h (revision 18084)
+++ insets/InsetFloat.h (working copy)
@@ -49,6 +49,8 @@
        ///
        ~InsetFloat();
        ///
+       docstring getInsetName() const { return name_; }
+       ///
        void write(Buffer const & buf, std::ostream & os) const;
        ///
        void read(Buffer const & buf, Lexer & lex);
@@ -90,10 +92,12 @@
 protected:
        virtual void doDispatch(Cursor & cur, FuncRequest & cmd);
 private:
+       ///
        virtual std::auto_ptr<InsetBase> doClone() const;
-
        ///
        InsetFloatParams params_;
+       ///
+       docstring name_;
 };
 
 
Index: insets/InsetBase.cpp
===================================================================
--- insets/InsetBase.cpp        (revision 18084)
+++ insets/InsetBase.cpp        (working copy)
@@ -3,6 +3,10 @@
  * This file is part of LyX, the document processor.
  * Licence details can be found in the file COPYING.
  *
+ * \author Alejandro Aguilar Sierra
+ * \author J�rgen Vigna
+ * \author Lars Gullik Bj�nnes
+ * \author Matthias Ettrich
  * \author Andr� P�nitz
  *
  * Full author contact details are available in file CREDITS.
@@ -13,11 +17,12 @@
 #include "InsetBase.h"
 
 #include "Buffer.h"
-#include "CoordCache.h"
 #include "BufferView.h"
 #include "Color.h"
+#include "CoordCache.h"
 #include "Cursor.h"
 #include "debug.h"
+#include "debug.h"
 #include "Dimension.h"
 #include "DispatchResult.h"
 #include "FuncRequest.h"
@@ -25,6 +30,7 @@
 #include "gettext.h"
 #include "LyXText.h"
 #include "MetricsInfo.h"
+#include "MetricsInfo.h"
 
 #include "frontends/Painter.h"
 
@@ -109,12 +115,13 @@
 
 
 /// pretty arbitrary dimensions
-InsetBase::InsetBase(): dim_(10, 10, 10), background_color_(Color::background)
+InsetBase::InsetBase()
+       : dim_(10, 10, 10), background_color_(Color::background)
 {}
 
 
-InsetBase::InsetBase(InsetBase const & i)
-: dim_(i.dim_), background_color_(i.background_color_)
+InsetBase::InsetBase(InsetBase const & inset)
+       : dim_(inset.dim_), background_color_(inset.background_color_)
 {}
 
 
@@ -126,6 +133,12 @@
 }
 
 
+docstring InsetBase::getInsetName() const 
+{
+       return from_ascii("unknown");
+}
+
+
 InsetBase::Code InsetBase::translate(std::string const & name)
 {
        static TranslatorMap const translator = build_translator();
@@ -253,13 +266,6 @@
 }
 
 
-docstring const & InsetBase::getInsetName() const
-{
-       static docstring const name = from_ascii("unknown");
-       return name;
-}
-
-
 void InsetBase::cursorPos(BufferView const & /*bv*/, CursorSlice const &,
                bool, int & x, int & y) const
 {
@@ -367,6 +373,13 @@
 }
 
 
+void InsetBase::setPosCache(PainterInfo const & pi, int x, int y) const
+{
+       //lyxerr << "InsetBase:: position cache to " << x << " " << y << 
std::endl;
+       pi.base.bv->coordCache().insets().add(this, x, y);
+}
+
+
 /////////////////////////////////////////
 
 bool isEditableInset(InsetBase const * inset)
Index: insets/InsetText.cpp
===================================================================
--- insets/InsetText.cpp        (revision 18084)
+++ insets/InsetText.cpp        (working copy)
@@ -89,7 +89,7 @@
 
 
 InsetText::InsetText(InsetText const & in)
-       : InsetOld(in), text_()
+       : InsetBase(in), text_()
 {
        text_.autoBreakRows_ = in.text_.autoBreakRows_;
        drawFrame_ = in.drawFrame_;
Index: insets/Makefile.am
===================================================================
--- insets/Makefile.am  (revision 18084)
+++ insets/Makefile.am  (working copy)
@@ -27,8 +27,6 @@
        RenderGraphic.h \
        RenderPreview.cpp \
        RenderPreview.h \
-       Inset.cpp \
-       Inset.h \
        InsetBase.h \
        InsetBase.cpp \
        InsetBibitem.cpp \
Index: insets/InsetCollapsable.h
===================================================================
--- insets/InsetCollapsable.h   (revision 18084)
+++ insets/InsetCollapsable.h   (working copy)
@@ -14,7 +14,7 @@
 #ifndef INSETCOLLAPSABLE_H
 #define INSETCOLLAPSABLE_H
 
-#include "Inset.h"
+#include "InsetBase.h"
 #include "InsetText.h"
 
 #include "Box.h"
@@ -44,6 +44,8 @@
        ///
        InsetCollapsable(InsetCollapsable const & rhs);
        ///
+       docstring getInsetName() const { return from_ascii("Collapsable"); }
+       ///
        void read(Buffer const &, Lexer &);
        ///
        void write(Buffer const &, std::ostream &) const;
Index: insets/InsetPagebreak.h
===================================================================
--- insets/InsetPagebreak.h     (revision 18084)
+++ insets/InsetPagebreak.h     (working copy)
@@ -13,13 +13,13 @@
 #define INSET_PAGEBREAK_H
 
 
-#include "Inset.h"
+#include "InsetBase.h"
 #include "gettext.h"
 
 
 namespace lyx {
 
-class InsetPagebreak : public InsetOld {
+class InsetPagebreak : public InsetBase {
 public:
        InsetPagebreak() {}
 
Index: insets/InsetExternal.h
===================================================================
--- insets/InsetExternal.h      (revision 18084)
+++ insets/InsetExternal.h      (working copy)
@@ -12,7 +12,7 @@
 #ifndef INSET_EXTERNAL_H
 #define INSET_EXTERNAL_H
 
-#include "Inset.h"
+#include "InsetBase.h"
 #include "ExternalTransforms.h"
 
 #include "support/FileName.h"
@@ -104,7 +104,7 @@
 class RenderBase;
 
 ///
-class InsetExternal : public InsetOld, public boost::signals::trackable
+class InsetExternal : public InsetBase, public boost::signals::trackable
 {
 public:
        InsetExternal();
Index: CoordCache.cpp
===================================================================
--- CoordCache.cpp      (revision 18084)
+++ CoordCache.cpp      (working copy)
@@ -58,8 +58,9 @@
        return posit->second;
 }
 
-void
-CoordCache::dump() const {
+
+void CoordCache::dump() const
+{
        lyxerr << "ParPosCache contains:" << std::endl;
        for (ParPosCache::const_iterator i = getParPos().begin(); i != 
getParPos().end(); ++i) {
                LyXText const * lt = (*i).first;

Reply via email to