]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insettext.C
Clean up InsetGraphics::Cache and rename as GraphicsInset.
[lyx.git] / src / insets / insettext.C
index 0b036445725325587c9a37b3dc90b357673ee93d..6f68e04604e47037f74738eb662a7107c0ae2122 100644 (file)
@@ -39,7 +39,7 @@
 #include "sgml.h"
 #include "rowpainter.h"
 #include "insetnewline.h"
-#include "Lsstream.h"
+#include "metricsinfo.h"
 
 #include "frontends/Alert.h"
 #include "frontends/Dialogs.h"
@@ -224,7 +224,7 @@ void InsetText::clear(bool just_mark_erased)
 }
 
 
-Inset * InsetText::clone(Buffer const &) const
+Inset * InsetText::clone() const
 {
        return new InsetText(*this);
 }
@@ -293,15 +293,14 @@ void InsetText::read(Buffer const * buf, LyXLex & lex)
 }
 
 
-void InsetText::dimension(BufferView * bv, LyXFont const &,
-       Dimension & dim) const
+void InsetText::metrics(MetricsInfo & mi, Dimension & dim) const
 {
+       BufferView * bv = mi.base.bv;
        LyXText * text = getLyXText(bv);
        dim.asc = text->rows().begin()->ascent_of_text() + TEXT_TO_INSET_OFFSET;
        dim.des = text->height - dim.asc + TEXT_TO_INSET_OFFSET;
        dim.wid = max(textWidth(bv), int(text->width)) + 2 * TEXT_TO_INSET_OFFSET;
        dim.wid = max(dim.wid, 10);
-       // cache it
        dim_ = dim;
 }
 
@@ -321,38 +320,34 @@ int InsetText::textWidth(BufferView * bv, bool fordraw) const
 }
 
 
-void InsetText::draw(BufferView * bv, LyXFont const & f,
-                    int baseline, float & x) const
+void InsetText::draw(PainterInfo & pi, int x, int baseline) const
 {
        if (nodraw())
                return;
 
        // update our idea of where we are. Clearly, we should
        // not have to know this information.
-       if (top_x != int(x))
-               top_x = int(x);
-
-       int const start_x = int(x);
+       if (top_x != x)
+               top_x = x;
 
-       Painter & pain = bv->painter();
+       int const start_x = x;
 
-       // call this method so that dim_ has the right value
-       dimension(bv, f, dim_);
+       BufferView * bv = pi.base.bv;
+       Painter & pain = pi.pain;
 
        // repaint the background if needed
        if (backgroundColor() != LColor::background)
                clearInset(bv, start_x + TEXT_TO_INSET_OFFSET, baseline);
 
        // no draw is necessary !!!
-       if ((drawFrame_ == LOCKED) && !locked && paragraphs.begin()->empty()) {
+       if (drawFrame_ == LOCKED && !locked && paragraphs.begin()->empty()) {
                top_baseline = baseline;
-               x += width(bv, f);
                need_update = NONE;
                return;
        }
 
        if (!owner())
-               x += static_cast<float>(scroll());
+               x += scroll();
 
        top_baseline = baseline;
        top_y = baseline - dim_.asc;
@@ -681,14 +676,14 @@ bool InsetText::lockInsetInInset(BufferView * bv, UpdatableInset * inset)
                        InsetList::iterator const end =
                                pit->insetlist.end();
                        for (; it != end; ++it) {
-                               if (it.getInset() == inset) {
-                                       getLyXText(bv)->setCursorIntern(pit, it.getPos());
+                               if (it->inset == inset) {
+                                       getLyXText(bv)->setCursorIntern(pit, it->pos);
                                        lockInset(bv, inset);
                                        return true;
                                }
-                               if (it.getInset()->getInsetFromID(id)) {
-                                       getLyXText(bv)->setCursorIntern(pit, it.getPos());
-                                       it.getInset()->localDispatch(FuncRequest(bv, LFUN_INSET_EDIT));
+                               if (it->inset->getInsetFromID(id)) {
+                                       getLyXText(bv)->setCursorIntern(pit, it->pos);
+                                       it->inset->localDispatch(FuncRequest(bv, LFUN_INSET_EDIT));
                                        return the_locking_inset->lockInsetInInset(bv, inset);
                                }
                        }
@@ -1821,10 +1816,10 @@ vector<string> const InsetText::getLabelList() const
        ParagraphList::const_iterator pit = paragraphs.begin();
        ParagraphList::const_iterator pend = paragraphs.end();
        for (; pit != pend; ++pit) {
-               InsetList::iterator beg = pit->insetlist.begin();
-               InsetList::iterator end = pit->insetlist.end();
+               InsetList::const_iterator beg = pit->insetlist.begin();
+               InsetList::const_iterator end = pit->insetlist.end();
                for (; beg != end; ++beg) {
-                       vector<string> const l = beg.getInset()->getLabelList();
+                       vector<string> const l = beg->inset->getLabelList();
                        label_list.insert(label_list.end(), l.begin(), l.end());
                }
        }
@@ -2359,12 +2354,12 @@ Inset * InsetText::getInsetFromID(int id_arg) const
        ParagraphList::const_iterator pit = paragraphs.begin();
        ParagraphList::const_iterator pend = paragraphs.end();
        for (; pit != pend; ++pit) {
-               InsetList::iterator it = pit->insetlist.begin();
-               InsetList::iterator end = pit->insetlist.end();
+               InsetList::const_iterator it = pit->insetlist.begin();
+               InsetList::const_iterator end = pit->insetlist.end();
                for (; it != end; ++it) {
-                       if (it.getInset()->id() == id_arg)
-                               return it.getInset();
-                       Inset * in = it.getInset()->getInsetFromID(id_arg);
+                       if (it->inset->id() == id_arg)
+                               return it->inset;
+                       Inset * in = it->inset->getInsetFromID(id_arg);
                        if (in)
                                return in;
                }
@@ -2654,10 +2649,10 @@ void InsetText::addPreview(grfx::PreviewLoader & loader) const
        ParagraphList::const_iterator pend = paragraphs.end();
 
        for (; pit != pend; ++pit) {
-               InsetList::iterator it  = pit->insetlist.begin();
-               InsetList::iterator end = pit->insetlist.end();
+               InsetList::const_iterator it  = pit->insetlist.begin();
+               InsetList::const_iterator end = pit->insetlist.end();
                for (; it != end; ++it) {
-                       it.getInset()->addPreview(loader);
+                       it->inset->addPreview(loader);
                }
        }
 }