]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetText.h
Request buffer update rather than do it.
[lyx.git] / src / insets / InsetText.h
index b42dce39ef76c8200a3b8579eaf903e39105b896..41bfa183671f664bef0141244b024ee6246ba447 100644 (file)
@@ -25,6 +25,7 @@ class Dimension;
 class ParagraphList;
 class InsetCaption;
 class InsetTabular;
+class TocBuilder;
 
 /**
  A text inset is like a TeX box to write full text
@@ -47,7 +48,7 @@ public:
        void setBuffer(Buffer &);
 
        ///
-       Dimension const dimension(BufferView const &) const;
+       Dimension const dimensionHelper(BufferView const &) const;
 
        /// empty inset to empty par
        void clear();
@@ -59,12 +60,14 @@ public:
        void metrics(MetricsInfo & mi, Dimension & dim) const;
        ///
        void draw(PainterInfo & pi, int x, int y) const;
+       /// Drawing background is handled in draw
+       virtual void drawBackground(PainterInfo &, int, int) const {}
        ///
        bool editable() const { return true; }
        ///
        bool canTrackChanges() const { return true; }
-       ///
-       bool canPaintChange(BufferView const &) const { return false; }
+       /// Rely on RowPainter to draw the cue of inline insets.
+       bool canPaintChange(BufferView const &) const { return allowMultiPar(); }
        ///
        InsetText * asInsetText() { return this; }
        ///
@@ -90,11 +93,11 @@ public:
                WriteEverything = 7
        };
        ///
-       docstring insetAsXHTML(XHTMLStream &, OutputParams const &, 
+       docstring insetAsXHTML(XHTMLStream &, OutputParams const &,
                               XHTMLOptions) const;
        ///
        void validate(LaTeXFeatures & features) const;
-       
+
        /// return the argument(s) only
        void getArgs(otexstream & os, OutputParams const &, bool const post = false) const;
 
@@ -166,7 +169,7 @@ public:
 
        /// Update the counters of this inset and of its contents
        virtual void updateBuffer(ParIterator const &, UpdateType);
-       /// 
+       ///
        void setMacrocontextPositionRecursive(DocIterator const & pos);
        ///
        void toString(odocstream &) const;
@@ -174,7 +177,7 @@ public:
        void forOutliner(docstring &, size_t const, bool const) const;
        ///
        void addToToc(DocIterator const & di, bool output_active,
-                                 UpdateType utype) const;
+                                 UpdateType utype, TocBackend & backend) const;
        ///
        Inset * clone() const { return new InsetText(*this); }
        ///
@@ -201,13 +204,14 @@ public:
        /// returns the text to be used as tooltip
        /// \param prefix: a string that will preced the tooltip,
        /// e.g., "Index: ".
-       /// \param numlines: the number of lines in the tooltip
-       /// \param len: length of those lines
-       /// NOTE This routine is kind of slow. It's fine to use it within the 
+       /// \param len: length of the resulting string
+       /// NOTE This routine is kind of slow. It's fine to use it within the
        /// GUI, but definitely do not try to use it in updateBuffer or anything
-       /// of that sort.
+       /// of that sort. (Note: unnecessary internal copies have been removed
+       /// since the previous note. The efficiency would have to be assessed
+       /// again by profiling.)
        docstring toolTipText(docstring prefix = empty_docstring(),
-                       size_t numlines = 5, size_t len = 80) const;
+                             size_t len = 400) const;
 
        ///
        std::string contextMenu(BufferView const &, int, int) const;
@@ -215,23 +219,36 @@ public:
        std::string contextMenuName() const;
        ///
        void doDispatch(Cursor & cur, FuncRequest & cmd);
-protected:
+
        ///
-       InsetCaption const * getCaptionInset() const;
+       bool confirmDeletion() const { return !text().empty(); }
+
        ///
-       docstring getCaptionText(OutputParams const &) const;
+       bool needsCProtection(bool const maintext = false,
+                             bool const fragile = false) const;
        ///
-       docstring getCaptionHTML(OutputParams const &) const;
+       bool hasCProtectContent(bool const fragile = false) const;
+
+protected:
        ///
        void iterateForToc(DocIterator const & cdit, bool output_active,
-                                          UpdateType utype) const;
+                                          UpdateType utype, TocBackend & backend) const;
 private:
+       /// Open the toc item for paragraph pit. Returns the paragraph index where
+       /// it should end.
+       pit_type openAddToTocForParagraph(pit_type pit,
+                                         DocIterator const & dit,
+                                         bool output_active,
+                                         TocBackend & backend) const;
+       /// Close a toc item opened in start and closed in end
+       void closeAddToTocForParagraph(pit_type start, pit_type end,
+                                      TocBackend & backend) const;
        ///
        bool drawFrame_;
        ///
        ColorCode frame_color_;
        ///
-       mutable Text text_;
+       Text text_;
 };