#ifndef INSETBASE_H
#define INSETBASE_H
-#include <boost/assert.hpp>
-
+#include <memory>
#include <string>
-#include <typeinfo>
#include <vector>
-#include <memory>
class Buffer;
class BufferView;
class CursorSlice;
-class DispatchResult;
class FuncRequest;
class FuncStatus;
class LaTeXFeatures;
class Dimension;
class PainterInfo;
class OutputParams;
-class UpdatableInset;
namespace lyx { namespace graphics { class PreviewLoader; } }
/// virtual base class destructor
virtual ~InsetBase() {}
/// replicate ourselves
- std::auto_ptr<InsetBase> clone() const
- {
- std::auto_ptr<InsetBase> b = doClone();
- BOOST_ASSERT(typeid(*b) == typeid(*this));
- return b;
- }
-
+ std::auto_ptr<InsetBase> clone() const;
/// identification as math inset
virtual MathInset * asMathInset() { return 0; }
virtual std::string const & getInsetName() const;
/// used to toggle insets
/// is the inset open?
- virtual bool isOpen() const { return false; }
/// should this inset be handled like a normal charater
virtual bool isChar() const { return false; }
/// is this equivalent to a letter?
/// pretty arbitrary
virtual int descent() const { return 10; }
///
+ int scroll() const { return 0; }
+ ///
enum CollapseStatus {
Collapsed,
Inlined,
// update our idea of where we are
setPosCache(pi, x, y);
- BufferView * bv = pi.base.bv;
- bv->hideCursor();
+ //BufferView * bv = pi.base.bv;
+ ////bv->hideCursor();
text_.draw(pi, x + border_, y);
- if (drawFrame_)
- drawFrame(pi.pain, x, y);
+ if (drawFrame_) {
+ int const w = text_.width() + 2 * border_;
+ int const a = text_.ascent() + border_;
+ int const h = a + text_.descent() + border_;
+ pi.pain.rectangle(x, y - a, w, h, frameColor());
+ }
}
void InsetText::drawSelection(PainterInfo & pi, int x, int y) const
{
- // repaint the background if needed
- if (backgroundColor() != LColor::background)
- clearInset(pi.pain, x, y);
+ if (backgroundColor() != LColor::background) {
+ // repaint the background if needed
+ int const w = text_.width() + 2 * border_;
+ int const a = text_.ascent() + border_;
+ int const h = a + text_.descent() + border_;
+ pi.pain.fillRectangle(x, y - a, w, h, backgroundColor());
+ }
text_.drawSelection(pi, x, y);
}
-void InsetText::drawFrame(Painter & pain, int x, int y) const
-{
- int const w = text_.width() + 2 * border_;
- int const a = text_.ascent() + border_;
- int const h = a + text_.descent() + border_;
- pain.rectangle(x, y - a, w, h, frameColor());
-}
-
-
-void InsetText::clearInset(Painter & pain, int x, int y) const
-{
- int const w = text_.width() + 2 * border_;
- int const a = text_.ascent() + border_;
- int const h = a + text_.descent() + border_;
- pain.fillRectangle(x, y - a, w, h, backgroundColor());
-}
-
-
string const InsetText::editMessage() const
{
return _("Opened Text Inset");
asciiParagraph(buf, *it, os, runparams, ref_printed);
// FIXME: Give the total numbers of lines
- return 0;
+ return 1;
}
void InsetText::setAutoBreakRows(bool flag)
{
- if (flag != text_.autoBreakRows_) {
- text_.autoBreakRows_ = flag;
- if (!flag)
- removeNewlines();
- }
+ if (flag == text_.autoBreakRows_)
+ return;
+
+ text_.autoBreakRows_ = flag;
+ if (flag)
+ return;
+
+ // remove previously existing newlines
+ ParagraphList::iterator it = paragraphs().begin();
+ ParagraphList::iterator end = paragraphs().end();
+ for (; it != end; ++it)
+ for (int i = 0; i < it->size(); ++i)
+ if (it->isNewline(i))
+ it->erase(i);
}
}
-void InsetText::removeNewlines()
-{
- ParagraphList::iterator it = paragraphs().begin();
- ParagraphList::iterator end = paragraphs().end();
- for (; it != end; ++it)
- for (int i = 0; i < it->size(); ++i)
- if (it->isNewline(i))
- it->erase(i);
-}
-
-
LyXText * InsetText::getText(int i) const
{
return (i == 0) ? const_cast<LyXText*>(&text_) : 0;