From 008dad0e3acf58e680dd599c407467651c47ca92 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Sun, 17 Jul 2005 01:13:36 +0000 Subject: [PATCH] clean up git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10265 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/insets/insetbase.C | 9 +++++ src/insets/insetbase.h | 18 +++------- src/insets/insettabular.h | 3 ++ src/insets/insettext.C | 72 ++++++++++++++++----------------------- src/insets/insettext.h | 10 ------ src/mathed/ref_inset.C | 3 +- src/mathed/ref_inset.h | 3 -- 7 files changed, 47 insertions(+), 71 deletions(-) diff --git a/src/insets/insetbase.C b/src/insets/insetbase.C index d775917a5e..580739f316 100644 --- a/src/insets/insetbase.C +++ b/src/insets/insetbase.C @@ -29,6 +29,7 @@ #include "frontends/Painter.h" #include +#include namespace { @@ -114,6 +115,14 @@ InsetBase::InsetBase(InsetBase const &) {} +std::auto_ptr InsetBase::clone() const +{ + std::auto_ptr b = doClone(); + BOOST_ASSERT(typeid(*b) == typeid(*this)); + return b; +} + + InsetBase::Code InsetBase::translate(std::string const & name) { static TranslatorMap const translator = build_translator(); diff --git a/src/insets/insetbase.h b/src/insets/insetbase.h index d405bfc9ca..7c496f256b 100644 --- a/src/insets/insetbase.h +++ b/src/insets/insetbase.h @@ -12,17 +12,13 @@ #ifndef INSETBASE_H #define INSETBASE_H -#include - +#include #include -#include #include -#include class Buffer; class BufferView; class CursorSlice; -class DispatchResult; class FuncRequest; class FuncStatus; class LaTeXFeatures; @@ -34,7 +30,6 @@ class MetricsInfo; class Dimension; class PainterInfo; class OutputParams; -class UpdatableInset; namespace lyx { namespace graphics { class PreviewLoader; } } @@ -64,13 +59,7 @@ public: /// virtual base class destructor virtual ~InsetBase() {} /// replicate ourselves - std::auto_ptr clone() const - { - std::auto_ptr b = doClone(); - BOOST_ASSERT(typeid(*b) == typeid(*this)); - return b; - } - + std::auto_ptr clone() const; /// identification as math inset virtual MathInset * asMathInset() { return 0; } @@ -338,7 +327,6 @@ public: 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? @@ -397,6 +385,8 @@ public: /// pretty arbitrary virtual int descent() const { return 10; } /// + int scroll() const { return 0; } + /// enum CollapseStatus { Collapsed, Inlined, diff --git a/src/insets/insettabular.h b/src/insets/insettabular.h index 5bb7dbed46..7b8830a47d 100644 --- a/src/insets/insettabular.h +++ b/src/insets/insettabular.h @@ -148,6 +148,9 @@ protected: virtual void doDispatch(LCursor & cur, FuncRequest & cmd); /// bool getStatus(LCursor & cur, FuncRequest const & cmd, FuncStatus &) const; + /// + int scroll() const { return scx_; } + private: virtual std::auto_ptr doClone() const; diff --git a/src/insets/insettext.C b/src/insets/insettext.C index 89b01b12d5..97cb709699 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -190,43 +190,33 @@ void InsetText::draw(PainterInfo & pi, int x, int y) const // 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"); @@ -289,7 +279,7 @@ int InsetText::plaintext(Buffer const & buf, ostream & os, asciiParagraph(buf, *it, os, runparams, ref_printed); // FIXME: Give the total numbers of lines - return 0; + return 1; } @@ -368,11 +358,20 @@ void InsetText::setText(string const & data, LyXFont const & font) 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); } @@ -404,17 +403,6 @@ void InsetText::setViewCache(BufferView const * bv) const } -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(&text_) : 0; diff --git a/src/insets/insettext.h b/src/insets/insettext.h index 0d2f18a986..639591c1fd 100644 --- a/src/insets/insettext.h +++ b/src/insets/insettext.h @@ -27,9 +27,7 @@ class BufferView; class CursorSlice; class Dimension; class LColor_color; -class Painter; class ParagraphList; -class Row; /** @@ -150,14 +148,6 @@ private: virtual std::auto_ptr doClone() const; /// void init(); - /// - void setCharFont(Buffer const &, int pos, LyXFont const & font); - /// - void removeNewlines(); - /// - void drawFrame(Painter &, int x, int y) const; - /// - void clearInset(Painter &, int x, int y) const; /// bool drawFrame_; diff --git a/src/mathed/ref_inset.C b/src/mathed/ref_inset.C index 775ba5d9ac..47734214da 100644 --- a/src/mathed/ref_inset.C +++ b/src/mathed/ref_inset.C @@ -156,8 +156,6 @@ int RefInset::docbook(Buffer const & buf, std::ostream & os, OutputParams const } - - RefInset::ref_type_info RefInset::types[] = { { "ref", N_("Standard"), N_("Ref: ")}, { "eqref", N_("Equation"), N_("EqRef: ")}, @@ -167,3 +165,4 @@ RefInset::ref_type_info RefInset::types[] = { { "prettyref", N_("PrettyRef"), N_("PrettyRef: ")}, { "", "", "" } }; + diff --git a/src/mathed/ref_inset.h b/src/mathed/ref_inset.h index 5e30a3dfaa..7e3c58ce2d 100644 --- a/src/mathed/ref_inset.h +++ b/src/mathed/ref_inset.h @@ -41,9 +41,6 @@ public: /// docbook output int docbook(Buffer const & buf, std::ostream & os, OutputParams const &) const; - /// small wrapper for the time being - DispatchResult localDispatch(FuncRequest & cmd); - struct ref_type_info { /// std::string latex_name; -- 2.39.2