]> git.lyx.org Git - features.git/commitdiff
Various fixes in insettext/tabular to make update work selective.
authorJürgen Vigna <jug@sad.it>
Wed, 21 Jun 2000 15:07:57 +0000 (15:07 +0000)
committerJürgen Vigna <jug@sad.it>
Wed, 21 Jun 2000 15:07:57 +0000 (15:07 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@826 a592a061-630c-0410-9148-cb99ea01b6c8

35 files changed:
ChangeLog
src/BufferView.C
src/BufferView.h
src/BufferView_pimpl.C
src/insets/figinset.C
src/insets/figinset.h
src/insets/inset.C
src/insets/insetbutton.C
src/insets/insetbutton.h
src/insets/insetcite.C
src/insets/insetcollapsable.C
src/insets/insetcollapsable.h
src/insets/inseterror.C
src/insets/inseterror.h
src/insets/insetfoot.C
src/insets/insetfoot.h
src/insets/insetgraphics.C
src/insets/insetgraphics.h
src/insets/insetinfo.C
src/insets/insetinfo.h
src/insets/insetlatexaccent.C
src/insets/insetlatexaccent.h
src/insets/insetquotes.C
src/insets/insetquotes.h
src/insets/insetspecialchar.C
src/insets/insetspecialchar.h
src/insets/insettabular.C
src/insets/insettabular.h
src/insets/insettext.C
src/insets/insettext.h
src/insets/lyxinset.h
src/lyxfunc.C
src/lyxtext.h
src/text.C
src/text2.C

index c5d31555d43d9395c789cb98d65511162854c01a..7f16f75021812f49385cb1c84d4ffe039765f6a9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2000-06-21  Juergen Vigna  <jug@sad.it>
+
+       * src/text.C (GetVisibleRow): look if I should clear the area or not
+       using Inset::doClearArea() function.
+
+       * src/insets/lyxinset.h: added doClearArea() function and
+       modified draw(Painter &, ...) to draw(BufferView *, ...)
+
+       * src/text2.C (UpdateInset): return bool insted of int
+
+2000-06-20  Juergen Vigna  <jug@sad.it>
+
+       * src/insets/insettext.C (SetParagraphData): set insetowner on
+       2- paragraphs.
+
 2000-06-21  Lars Gullik Bjønnes  <larsbj@lyx.org>
 
        * src/Timeout.[Ch]: Change to use signals instead of callbacks. 
index 4fb7f0eb6dafdfcd9e0905912bfcc4e271498360..1d8592f3c3e5ecb2584caa3048092939f073cddd 100644 (file)
@@ -51,6 +51,12 @@ LyXScreen * BufferView::screen() const
 }
 
 
+WorkArea * BufferView::workarea() const
+{
+       return pimpl_->workarea_;
+}
+
+
 LyXView * BufferView::owner() const
 {
        return pimpl_->owner_;
index e714c63d33f5b1b199ab62c41fb326d3eb9019d9..ed2e57805cf9dfdd6a8acb2d1bb38803c8ac70db 100644 (file)
@@ -24,6 +24,7 @@ class LyXText;
 class TeXErrors;
 class Buffer;
 class LyXScreen;
+class WorkArea;
 
 ///
 class BufferView {
@@ -47,6 +48,8 @@ public:
        ///
        LyXScreen * screen() const;
        ///
+       WorkArea * workarea() const;
+       ///
        void buffer(Buffer * b);
        ///
        void resize(int, int, int, int);
index 6f9ecaffa3fee42f8b6789b21c8466eaad52dab8..57f7f74d811b982b8cf2afa6d70c2acb9340a7b1 100644 (file)
@@ -1302,7 +1302,7 @@ void BufferView::Pimpl::setState()
 void BufferView::Pimpl::insetSleep()
 {
        if (bv_->the_locking_inset && !bv_->inset_slept) {
-               bv_->the_locking_inset->GetCursorPos(bv_->slx, bv_->sly);
+               bv_->the_locking_inset->GetCursorPos(bv_, bv_->slx, bv_->sly);
                bv_->the_locking_inset->InsetUnlock(bv_);
                bv_->inset_slept = true;
        }
index 546a92c80edcd46510321c604e9e049467ae79a5..99e447c6c13b5518f13be2ffd61beffc3e5d35ba 100644 (file)
@@ -1034,10 +1034,11 @@ int InsetFig::width(Painter &, LyXFont const &) const
 }
 
 
-void InsetFig::draw(Painter & pain, LyXFont const & f,
+void InsetFig::draw(BufferView * bv, LyXFont const & f,
                    int baseline, float & x) const
 {
        LyXFont font(f);
+       Painter & pain = bv->painter();
        
        if (bitmap_waiting) getbitmaps();
        
index 8df0d8f94f6e9ec31d33890e56a72ef466f63334..cb53c9218c9f5e3242ad77bf6fb7de236aebfffb 100644 (file)
@@ -30,7 +30,7 @@ public:
        ///
        int width(Painter &, LyXFont const & font) const;
        ///
-       void draw(Painter &, LyXFont const & font,
+       void draw(BufferView *, LyXFont const & font,
                  int baseline, float & x) const;
        ///
        void Write(Buffer const *, std::ostream &) const;
index 19249a574e4bf9a6ad7af379ba157397b4dec113..35052a6dda2bbfd89d35cd0f59de0d318734d1a9 100644 (file)
@@ -42,15 +42,6 @@ Inset::EDITABLE Inset::Editable() const
 }
 
 
-bool Inset::IsTextInset() const
-{
-       return ((LyxCode() == TEXT_CODE) ||
-               (LyxCode() == ERT_CODE) ||
-               (LyxCode() == FOOT_CODE) ||
-               (LyxCode() == MARGIN_CODE));
-}
-
-
 void Inset::Validate(LaTeXFeatures &) const
 {
 }
@@ -145,7 +136,7 @@ void UpdatableInset::Edit(BufferView * bv, int, int, unsigned int)
 }
 
 
-void UpdatableInset::draw(Painter &, LyXFont const &,
+void UpdatableInset::draw(BufferView *, LyXFont const &,
                          int /* baseline */, float & x) const
 {
     if (scx) x += float(scx);
index f167fe65beeb8b56402d4837153bdbab42f56b57..327ab0b6566cd97f74cccae7a4c3f6e4c00f160b 100644 (file)
@@ -16,6 +16,7 @@
 
 #include "insetbutton.h"
 #include "debug.h"
+#include "BufferView.h"
 #include "Painter.h"
 
 using std::ostream;
@@ -86,9 +87,10 @@ int InsetButton::width(Painter & pain, LyXFont const &) const
 }
 
 
-void InsetButton::draw(Painter & pain, LyXFont const &,
+void InsetButton::draw(BufferView * bv, LyXFont const &,
                        int baseline, float & x) const
 {
+       Painter & pain = bv->painter();
        // Draw it as a box with the LaTeX text
        LyXFont font(LyXFont::ALL_SANE);
        font.setColor(LColor::command).decSize();
index 917b57ff85eb616587227ddc8077494f1e9edd2e..b88a83729ca612e985d9ca819cfb37a479abc6f2 100644 (file)
@@ -33,7 +33,7 @@ public:
        ///
        int width(Painter &, LyXFont const &) const;
        ///
-       void draw(Painter &, LyXFont const &, int baseline, float & x) const;
+       void draw(BufferView *, LyXFont const &, int baseline, float & x) const;
 
 protected:
        /// This should provide the text for the button
index 7b523bdfa07c6d7b672014c9f14983cb519094c2..3e657546d368b44643a86c024334fed8f5cad2b8 100644 (file)
@@ -179,10 +179,11 @@ void InsetCitation::Edit( BufferView * bv, int, int, unsigned int )
        if( citation_form->form->visible ) {
                fl_raise_form( citation_form->form );
        } else {
-               fl_show_form( citation_form->form,
-                             FL_PLACE_MOUSE, FL_FULLBORDER,
-                             _("Citation") );
-       } 
+               fl_show_form(citation_form->form,
+                            FL_PLACE_MOUSE | FL_FREE_SIZE,
+                            FL_FULLBORDER,
+                            _("Citation") );
+       }
 }
 
 
index 68f12ab101f36768546626ced3a4e5ab6d0ddf97..03537313d350a0585a03ab921da72a4a333f3b6f 100644 (file)
@@ -135,9 +135,11 @@ void InsetCollapsable::draw_collapsed(Painter & pain, LyXFont const & font,
 }
 
 
-void InsetCollapsable::draw(Painter & pain, LyXFont const & f, 
+void InsetCollapsable::draw(BufferView * bv, LyXFont const & f, 
                            int baseline, float & x) const
 {
+    Painter & pain = bv->painter();
+
     button_length = width_collapsed(pain, labelfont) + 2;
     button_top_y = -ascent_collapsed(pain, f);
     button_bottom_y = descent_collapsed(pain, f);
@@ -158,7 +160,7 @@ void InsetCollapsable::draw(Painter & pain, LyXFont const & f,
 
     x += TEXT_TO_INSET_OFFSET;
     drawTextXOffset = int(x) - top_x;
-    InsetText::draw(pain, f, baseline, x);
+    InsetText::draw(bv, f, baseline, x);
 }
 
 
@@ -166,7 +168,7 @@ void InsetCollapsable::Edit(BufferView * bv, int x, int y, unsigned int button)
 {
     if (collapsed && autocollapse) {
        collapsed = false;
-       UpdateLocal(bv, true, false);
+       UpdateLocal(bv, FULL, false);
        InsetText::Edit(bv, 0, 0, button);
     } else if (!collapsed) {
        InsetText::Edit(bv, x, y, button);
@@ -188,7 +190,7 @@ void InsetCollapsable::InsetUnlock(BufferView * bv)
        collapsed = true;
     }
     InsetText::InsetUnlock(bv);
-    UpdateLocal(bv, false, false);
+    UpdateLocal(bv, FULL, false);
 }
 
 
@@ -208,10 +210,10 @@ void InsetCollapsable::InsetButtonRelease(BufferView * bv,
        if (collapsed) {
            collapsed = false;
            InsetText::InsetButtonRelease(bv, 0, 0, button);
-           UpdateLocal(bv, true, false);
+           UpdateLocal(bv, FULL, false);
        } else {
            collapsed = true;
-           UpdateLocal(bv, false, false);
+           UpdateLocal(bv, FULL, false);
            bv->unlockInset(this);
        }
     } else if (!collapsed && (x >= button_length) && (y >= button_top_y)) {
index bf21fb5506cb976f976d31a2e3f35f118b692a9f..5107c448371627fe3da7cc58f255c04d15335a75 100644 (file)
@@ -51,7 +51,7 @@ public:
     ///
     int width(Painter &, LyXFont const & f) const;
     ///
-    void draw(Painter & pain, const LyXFont &, int , float &) const;
+    void draw(BufferView *, const LyXFont &, int , float &) const;
     ///
     void Edit(BufferView *, int, int, unsigned int);
     ///
index a01ca847812a517c396ed0fbc192e01620ec78d9..cc7584a287383c119a3fa3669733e1b8396fddc1 100644 (file)
@@ -18,6 +18,7 @@
 #include "gettext.h"
 #include "lyx_gui_misc.h" // CancelCloseBoxCB
 #include "Painter.h"
+#include "BufferView.h"
 #include "font.h"
 
 using std::ostream;
@@ -71,9 +72,10 @@ int InsetError::width(Painter &, LyXFont const & font) const
 }
 
 
-void InsetError::draw(Painter & pain, LyXFont const & font,
+void InsetError::draw(BufferView * bv, LyXFont const & font,
                      int baseline, float & x) const
 {
+       Painter & pain = bv->painter();
        LyXFont efont;
        efont.setSize(font.size()).decSize();
        efont.setColor(LColor::error);
index 0a47116373efa414879e7f00707cfbcc4c213bf0..1147e47e7466c3b6e61dc392009af87a9cc1f48c 100644 (file)
@@ -42,7 +42,7 @@ public:
        ///
        int width(Painter &, LyXFont const & font) const;
        ///
-       void draw(Painter &, LyXFont const & font, int baseline, float & x) const;
+       void draw(BufferView *, LyXFont const & font, int baseline, float & x) const;
        ///
        void Write(Buffer const *, std::ostream &) const;
        ///
index 8ef185da8c3458922a7e77e2b7dfe62086ad782f..6c67189a5c1f00d6ad333f2304ea7d557edf2b03 100644 (file)
@@ -83,9 +83,9 @@ bool InsetFoot::InsertInsetAllowed(Inset * inset) const
 }
 
 
-LyXFont InsetFoot::GetDrawFont(Buffer const * buf, LyXParagraph * p, int pos) const
+LyXFont InsetFoot::GetDrawFont(BufferView * bv,LyXParagraph * p, int pos) const
 {
-    LyXFont fn = text->GetFont(buf, p, pos);
+    LyXFont fn = getLyXText(bv)->GetFont(bv->buffer(), p, pos);
     fn.decSize().decSize();
     return fn;
 }
index f396d5aa0703333c80a0876c372d034e7e72fb00..a5404b4556183dba0a3664b3a848fd30963af642 100644 (file)
@@ -45,7 +45,7 @@ public:
     ///
     bool InsertInsetAllowed(Inset * inset) const;
     ///
-    LyXFont GetDrawFont(Buffer const *, LyXParagraph * par, int pos) const;
+    LyXFont GetDrawFont(BufferView *, LyXParagraph * par, int pos) const;
     ///
 };
 
index 39c3b19e6323e5b8b25ac6f5e452403e1ab85b92..35716df97fefdbc40a3f7a22ea373c42e377862c 100644 (file)
@@ -15,6 +15,7 @@
 #include <config.h>
 
 #include "insets/insetgraphics.h"
+#include "BufferView.h"
 #include "Painter.h"
 #include "form_graphics.h"
 #include "lyx_gui_misc.h"
@@ -133,9 +134,11 @@ int InsetGraphics::width(Painter &, LyXFont const &) const
 }
 
 
-void InsetGraphics::draw(Painter & pain, LyXFont const & font,
+void InsetGraphics::draw(BufferView * bv, LyXFont const & font,
                         int baseline, float & x) const
 {
+       Painter & pain = bv->painter();
+
        // This will draw the graphics. As for now we only draw a
        // placeholder rectangele.
        pain.rectangle(int(x), baseline - ascent(pain, font),
index d5e5415354d9f58b872b610867a7c1c353818ea6..76d2ec824eb2ea2f171081714c6ee8dce2ad75ce 100644 (file)
@@ -35,7 +35,7 @@ public:
        ///
        int width(Painter &, LyXFont const &) const;
        ///
-       void draw(Painter &, LyXFont const &,
+       void draw(BufferView *, LyXFont const &,
                          int baseline, float & x) const;
        ///
        void Edit(BufferView *, int, int, unsigned int);
index 9433bf70a21fde2c12836586c68052a8acd7603e..e57b91f0420f63e68027d3c22ec4f3b996b30676 100644 (file)
@@ -75,9 +75,10 @@ int InsetInfo::width(Painter &, LyXFont const & font) const
 }
 
 
-void InsetInfo::draw(Painter & pain, LyXFont const & f,
+void InsetInfo::draw(BufferView * bv, LyXFont const & f,
                     int baseline, float & x) const
 {
+       Painter & pain = bv->painter();
        LyXFont font(f);
        
        /* Info-insets are never LaTeX, so just correct the font */
index ca32a853d552b27dd84ab95b6f024f4e45365270..ef1cf83e1a4528d385b30a8ec227292acf9706b4 100644 (file)
@@ -44,7 +44,7 @@ public:
        ///
        int width(Painter &, LyXFont const &) const;
        ///
-       void draw(Painter &, LyXFont const &, int baseline, float & x) const;
+       void draw(BufferView *, LyXFont const &, int baseline, float & x) const;
        ///
        void Write(Buffer const *, std::ostream &) const;
        ///
index c332b6030b03431a6bfa78f477c268469126f0cb..89fdbfc710d2674ef5d54301b6052cae7f950651 100644 (file)
@@ -18,6 +18,7 @@
 #include "debug.h"
 #include "lyxrc.h"
 #include "support/lstrings.h"
+#include "BufferView.h"
 #include "Painter.h"
 #include "font.h"
 
@@ -354,9 +355,11 @@ bool InsetLatexAccent::DisplayISO8859_9(Painter & pain, LyXFont const & font,
 }
 
 
-void InsetLatexAccent::draw(Painter & pain, LyXFont const & font,
+void InsetLatexAccent::draw(BufferView * bv, LyXFont const & font,
                            int baseline, float & x) const
 {
+       Painter & pain = bv->painter();
+
        if (lyxrc.font_norm == "iso8859-9")
                if (DisplayISO8859_9(pain, font, baseline, x))  
                        return;
index 8f83dd56dabb2f861084a04aa5fd4c5826c31683..5e444703763dcd47cc76e8aaaf3de7ae41c3d5de 100644 (file)
@@ -41,7 +41,7 @@ public:
        ///
        int width(Painter &, LyXFont const &) const;
        ///
-       void draw(Painter &, LyXFont const &, int baseline, float & x) const;
+       void draw(BufferView *, LyXFont const &, int baseline, float & x) const;
        ///
        int Lbearing(LyXFont const & font) const;
        ///
index 2e028cc40cbecec9e22af5bd5b9ec736b35910ae..f2dfa4238efc3c3419e1c0d0de02adef3aba5cc0 100644 (file)
@@ -197,13 +197,13 @@ LyXFont InsetQuotes::ConvertFont(LyXFont font)
 }
 
 
-void InsetQuotes::draw(Painter & pain, LyXFont const & font,
+void InsetQuotes::draw(BufferView * bv, LyXFont const & font,
                       int baseline, float & x) const
 {
        string text = DispString();
 
-       pain.text(int(x), baseline, text, font);
-       x += width(pain, font);
+       bv->painter().text(int(x), baseline, text, font);
+       x += width(bv->painter(), font);
 }
 
 
index fd3565ba988b148d506256bea6c563d99e08d364..3c6a6f24b1464d96472311a276d8d83813263195 100644 (file)
@@ -78,7 +78,7 @@ public:
        ///
        int width(Painter &, LyXFont const &) const;
        ///
-       void draw(Painter &, LyXFont const &, int baseline, float & x) const;
+       void draw(BufferView *, LyXFont const &, int baseline, float & x) const;
        ///
        LyXFont ConvertFont(LyXFont font);
        ///
index cf8d0b6202e4d257200d152423b082de633c675f..81431d769faca7f7c926e5236efeb5b16ec05d9b 100644 (file)
@@ -16,6 +16,7 @@
 #include "insetspecialchar.h"
 #include "debug.h"
 #include "LaTeXFeatures.h"
+#include "BufferView.h"
 #include "Painter.h"
 #include "font.h"
 
@@ -71,10 +72,12 @@ int InsetSpecialChar::width(Painter &, LyXFont const & font) const
 }
 
 
-void InsetSpecialChar::draw(Painter & pain, LyXFont const & f,
+void InsetSpecialChar::draw(BufferView * bv, LyXFont const & f,
                            int baseline, float & x) const
 {
+       Painter & pain = bv->painter();
        LyXFont font(f);
+
        switch (kind) {
        case HYPHENATION:
        {
index d9a737dd14e3ff97f2d95fb4acebb2025c65d1e1..d02aec0d656c6652b05cb3390021b5f5db9dad0f 100644 (file)
@@ -50,7 +50,7 @@ public:
        ///
        int width(Painter &, LyXFont const &) const;
        ///
-       void draw(Painter &, LyXFont const &, int baseline, float & x) const;
+       void draw(BufferView *, LyXFont const &, int baseline, float & x) const;
        ///
        void Write(Buffer const *, std::ostream &) const;
        /// Will not be used when lyxf3
index 742ec1a1b738ca23e9567bad7c387334f490645e..fe873449d6f2bba9e3b48c5e6fa6e2f2054b902d 100644 (file)
@@ -131,45 +131,34 @@ void InsetTabular::Read(Buffer const * buf, LyXLex & lex)
 }
 
 
-int InsetTabular::ascent(Painter & pain, LyXFont const & font) const
+int InsetTabular::ascent(Painter &, LyXFont const &) const
 {
-    if (init_inset) {
-       calculate_width_of_cells(pain, font);
-       init_inset = false;
-    }
     return tabular->GetAscentOfRow(0);
 }
 
 
-int InsetTabular::descent(Painter & pain, LyXFont const & font) const
+int InsetTabular::descent(Painter &, LyXFont const &) const
 {
-    if (init_inset) {
-       calculate_width_of_cells(pain, font);
-       init_inset = false;
-    }
     return tabular->GetHeightOfTabular() - tabular->GetAscentOfRow(0);
 }
 
 
-int InsetTabular::width(Painter & pain, LyXFont const & font) const
+int InsetTabular::width(Painter &, LyXFont const &) const
 {
-    if (init_inset) {
-       calculate_width_of_cells(pain, font);
-       init_inset = false;
-    }
     return tabular->GetWidthOfTabular() + (2 * ADD_TO_TABULAR_WIDTH);
 }
 
 
-void InsetTabular::draw(Painter & pain, const LyXFont & font, int baseline,
+void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline,
                        float & x) const
 {
+    Painter & pain = bv->painter();
     int i, j, cell=0;
     int nx;
     float cx;
     bool reinit = false;
 
-    UpdatableInset::draw(pain,font,baseline,x);
+    UpdatableInset::draw(bv,font,baseline,x);
     if (init_inset || (top_x != int(x)) || (top_baseline != baseline)) {
 //     int ox = top_x;
        init_inset = false;
@@ -177,7 +166,7 @@ void InsetTabular::draw(Painter & pain, const LyXFont & font, int baseline,
        top_baseline = baseline;
 //     if (ox != top_x)
 //         recomputeTextInsets(pain, font);
-       calculate_width_of_cells(pain, font);
+//     calculate_width_of_cells(pain, font);
        resetPos(pain);
        reinit = true;
     }
@@ -190,7 +179,7 @@ void InsetTabular::draw(Painter & pain, const LyXFont & font, int baseline,
            cx = nx + tabular->GetBeginningOfTextInCell(cell);
            if (hasSelection())
                DrawCellSelection(pain, nx, baseline, i, j, cell);
-           tabular->GetCellInset(cell)->draw(pain, font, baseline, cx);
+           tabular->GetCellInset(cell)->draw(bv, font, baseline, cx);
            DrawCellLines(pain, nx, baseline, i, cell);
            nx += tabular->GetWidthOfColumn(cell);
            ++cell;
@@ -202,10 +191,12 @@ void InsetTabular::draw(Painter & pain, const LyXFont & font, int baseline,
 }
 
 
-void InsetTabular::update(BufferView * bv, LyXFont const & font) const
+void InsetTabular::update(BufferView * bv, LyXFont const & font, bool dodraw)
 {
-    if (init_inset)
-       recomputeTextInsets(bv, font);
+    if (init_inset) {
+       calculate_width_of_cells(bv, font, dodraw);
+//     recomputeTextInsets(bv, font);
+    }
 }
 
 
@@ -324,8 +315,9 @@ void InsetTabular::InsetUnlock(BufferView * bv)
 
 void InsetTabular::UpdateLocal(BufferView * bv, bool what, bool mark_dirty)
 {
-    if (what)
-       calculate_width_of_cells(bv->painter(), LyXFont(LyXFont::ALL_SANE));
+//    if (what)
+//     calculate_width_of_cells(bv->painter(), LyXFont(LyXFont::ALL_SANE));
+    init_inset = what;
     bv->updateInset(this, mark_dirty);
     if (what)
        resetPos(bv->painter());
@@ -732,8 +724,8 @@ void InsetTabular::Validate(LaTeXFeatures & features) const
 }
 
 
-void InsetTabular::calculate_width_of_cells(Painter & pain,
-                                           LyXFont const & font) const
+void InsetTabular::calculate_width_of_cells(BufferView * bv,
+                                           LyXFont const & font, bool dodraw) const
 {
     int cell = -1;
     int maxAsc, maxDesc;
@@ -746,9 +738,10 @@ void InsetTabular::calculate_width_of_cells(Painter & pain,
                continue;
            ++cell;
            inset = tabular->GetCellInset(cell);
-           maxAsc = max(maxAsc, inset->ascent(pain, font));
-           maxDesc = max(maxDesc, inset->descent(pain, font));
-           tabular->SetWidthOfCell(cell, inset->width(pain, font));
+           inset->update(bv, font, dodraw);
+           maxAsc = max(maxAsc, inset->ascent(bv->painter(), font));
+           maxDesc = max(maxDesc, inset->descent(bv->painter(), font));
+           tabular->SetWidthOfCell(cell, inset->width(bv->painter(), font));
        }
        tabular->SetAscentOfRow(i, maxAsc + ADD_TO_HEIGHT);
        tabular->SetDescentOfRow(i, maxDesc + ADD_TO_HEIGHT);
index 7c5b1340da07b7815e76077bf9eb87f3cfcd2104..5247e0241206718f4f6d2edbaf8e2e98ac8e31c1 100644 (file)
@@ -80,14 +80,16 @@ public:
     ///
     int width(Painter &, LyXFont const & f) const;
     ///
-    void draw(Painter & pain, const LyXFont &, int , float &) const;
+    void draw(BufferView *, const LyXFont &, int , float &) const;
     ///
-    void update(BufferView *, LyXFont const &) const;
+    void update(BufferView *, LyXFont const &, bool);
     ///
     const char * EditMessage() const;
     ///
     void Edit(BufferView *, int x, int y, unsigned int);
     ///
+    bool doClearArea() const { return !locked; };
+    ///
     void InsetUnlock(BufferView *);
     ///
     void UpdateLocal(BufferView *, bool what, bool mark_dirty);
@@ -150,7 +152,7 @@ public:
     LyXTabular * tabular;
 
 private:
-    void calculate_width_of_cells(Painter &, LyXFont const &) const;
+    void calculate_width_of_cells(BufferView *, LyXFont const &, bool =false) const;
     ///
     void DrawCellLines(Painter &, int x, int baseline, int row, int cell)
            const;
index 0a39eccf9077837366079f7d43e77d30589b56f1..695e923ba0a0e2c5c2c34af5ef4ea3be02e5a5f8 100644 (file)
@@ -55,15 +55,13 @@ using std::min;
 using std::max;
 
 extern unsigned char getCurrentTextClass(Buffer *);
-#warning BAAAAAAAADDDDDDD current_view (but Lars wanted it :) !!!
-extern BufferView * current_view;
 
+#define TEXT(a) getLyXText(a)
 
 InsetText::InsetText()
 {
     par = new LyXParagraph();
     init();
-    text = new LyXText(this);
 }
 
 
@@ -72,7 +70,6 @@ InsetText::InsetText(InsetText const & ins)
 {
     par = 0;
     init(&ins);
-    text = new LyXText(this);
     autoBreakRows = ins.autoBreakRows;
 }
 
@@ -80,18 +77,18 @@ InsetText::InsetText(InsetText const & ins)
 InsetText & InsetText::operator=(InsetText const & it)
 {
     init(&it);
-    text = new LyXText(this);
     autoBreakRows = it.autoBreakRows;
     return * this;
 }
 
 void InsetText::init(InsetText const * ins)
 {
+    insetAscent = insetDescent = insetWidth = 0;
     the_locking_inset = 0;
     cursor_visible = false;
     interline_space = 1;
     no_selection = false;
-    init_inset = true;
+    need_update = INIT;
     drawTextXOffset = drawTextYOffset = 0;
     autoBreakRows = drawLockedFrame = false;
     xpos = 0.0;
@@ -101,7 +98,6 @@ void InsetText::init(InsetText const * ins)
        drawLockedFrame = ins->drawLockedFrame;
     }
     par->SetInsetOwner(this);
-//    selection_start_cursor = selection_end_cursor = cursor;
     frame_color = LColor::insetframe;
     locked = false;
     old_par = 0;
@@ -188,86 +184,97 @@ void InsetText::Read(Buffer const * buf, LyXLex & lex)
         lex.printError("Missing \\end_inset at this point. "
                        "Read: `$$Token'");
     }
-    init_inset = true;
+    need_update = INIT;
 }
 
 
 int InsetText::ascent(Painter &, LyXFont const &) const
 {
-    long int y_temp = 0;
-    Row * row = text->GetRowNearY(y_temp);
-    return row->ascent_of_text() + 2;
+    return insetAscent;
 }
 
 
 int InsetText::descent(Painter &, LyXFont const &) const
 {
-    long int y = 0;
-    Row * row = text->GetRowNearY(y);
-    return text->height - row->ascent_of_text() + 2;
+    return insetDescent;
 }
 
 
-int InsetText::width(Painter & pain, LyXFont const &) const
+int InsetText::width(Painter &, LyXFont const &) const
 {
-    return std::max(static_cast<long int>(getMaxTextWidth(pain, this)),
-                   text->width);
+    return insetWidth;
 }
 
 
-void InsetText::draw(Painter & pain, LyXFont const & f,
+void InsetText::draw(BufferView * bv, LyXFont const & f,
                     int baseline, float & x) const
 {
+    Painter & pain = bv->painter();
+
     xpos = x;
-    UpdatableInset::draw(pain, f, baseline, x);
+    UpdatableInset::draw(bv, f, baseline, x);
  
     top_baseline = baseline;
     top_x = int(x);
 
-    if (the_locking_inset && (cpos() == inset_pos)) {
-       inset_x = cx() - top_x + drawTextXOffset;
-       inset_y = cy() + drawTextYOffset;
+    if (the_locking_inset && (cpos(bv) == inset_pos)) {
+       inset_x = cx(bv) - top_x + drawTextXOffset;
+       inset_y = cy(bv) + drawTextYOffset;
     }
     x += TEXT_TO_INSET_OFFSET; // place for border
     long int y = 0;
-    Row * row = text->GetRowNearY(y);
+    Row * row = TEXT(bv)->GetRowNearY(y);
     y += baseline - row->ascent_of_text() + 1;
-    while (row != 0) {
-       text->GetVisibleRow(current_view, y, x, row, y);
-       y += row->height();
-       row = row->next();
+    if (!locked || (need_update == FULL)) {
+       while (row != 0) {
+           TEXT(bv)->GetVisibleRow(bv, y, x, row, y);
+           y += row->height();
+           row = row->next();
+       }
+       if (drawLockedFrame && locked) {
+           pain.rectangle(top_x, baseline - ascent(pain, f), width(pain, f),
+                          ascent(pain,f) + descent(pain, f), frame_color);
+       }
+    } else {
+       bv->screen()->Update(TEXT(bv));
     }
     x += width(pain, f) - TEXT_TO_INSET_OFFSET;
-    if (drawLockedFrame && locked) {
-       pain.rectangle(top_x, baseline - ascent(pain, f), width(pain, f),
-                      ascent(pain,f) + descent(pain, f), frame_color);
-    }
 }
 
 
-void InsetText::update(BufferView * bv, LyXFont const &) const
+void InsetText::update(BufferView * bv, LyXFont const &, bool dodraw)
 {
-    if (init_inset) {
-       text->init(bv);
-       init_inset = false;
+    if (need_update == INIT) {
+       deleteLyXText(bv);
+       need_update = FULL;
+    }
+
 #if 0
-       // Dump all rowinformation:
-       long y_dummy = 0;
-       Row * tmprow = text->GetRowNearY(y_dummy);
-       lyxerr << "Width = " << text->width << endl;
-       lyxerr << "Baseline Paragraph Pos Height Ascent Fill\n";
-       while (tmprow) {
-               lyxerr << tmprow->baseline() << '\t'
-                      << tmprow->par() << '\t'
-                      << tmprow->pos() << '\t'
-                      << tmprow->height() << '\t'
-                      << tmprow->ascent_of_text() << '\t'
-                      << tmprow->fill() << '\n';
-               tmprow = tmprow->next();
-       }
-       lyxerr.flush();
-#endif
+    switch(need_update) {
+    case NONE: // most common first
+       break;
+    case INIT:
+       need_update = NONE;
+       break;
+    case CURSOR_PAR:
+       need_update = NONE;
+       break;
+    case FULL:
+       TEXT(bv)->FullRebreak(bv);
+       need_update = NONE;
+       break;
+    default:
+       need_update = NONE;
+       break;
     }
+#endif
+    TEXT(bv)->FullRebreak(bv);
+
+    long int y_temp = 0;
+    Row * row = TEXT(bv)->GetRowNearY(y_temp);
+    insetAscent = row->ascent_of_text() + 2;
+    insetDescent = TEXT(bv)->height - row->ascent_of_text() + 2;
+    insetWidth = max(getMaxTextWidth(bv->painter(), this), TEXT(bv)->width);
 }
 
 
@@ -279,7 +286,7 @@ char const * InsetText::EditMessage() const
 
 void InsetText::Edit(BufferView * bv, int x, int y, unsigned int button)
 {
-    par->SetInsetOwner(this);
+//    par->SetInsetOwner(this);
     UpdatableInset::Edit(bv, x, y, button);
 
     if (!bv->lockInset(this)) {
@@ -292,9 +299,9 @@ void InsetText::Edit(BufferView * bv, int x, int y, unsigned int button)
 //    setPos(bv->painter(), x, y);
     checkAndActivateInset(bv, x, y, button);
 //    selection_start_cursor = selection_end_cursor = cursor;
-    text->sel_cursor = text->cursor;
+    TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
     bv->text->FinishUndo();
-    UpdateLocal(bv, true, false);
+    UpdateLocal(bv, FULL, false);
 }
 
 
@@ -307,10 +314,11 @@ void InsetText::InsetUnlock(BufferView * bv)
     HideInsetCursor(bv);
     lyxerr[Debug::INSETS] << "InsetText::InsetUnlock(" << this <<
            ")" << endl;
-//    selection_start_cursor = selection_end_cursor = cursor;
     no_selection = false;
     locked = false;
-    UpdateLocal(bv, true, false);
+    TEXT(bv)->selection = 0;
+    UpdateLocal(bv, FULL, false);
+    bv->owner()->getToolbar()->combox->select(bv->text->cursor.par()->GetLayout()+1);
 }
 
 
@@ -319,20 +327,20 @@ bool InsetText::LockInsetInInset(BufferView * bv, UpdatableInset * inset)
     lyxerr[Debug::INSETS] << "InsetText::LockInsetInInset(" << inset << "): ";
     if (!inset)
        return false;
-    if (inset == par->GetInset(cpos())) {
+    if (inset == cpar(bv)->GetInset(cpos(bv))) {
        lyxerr[Debug::INSETS] << "OK" << endl;
        the_locking_inset = inset;
 //     resetPos(bv->painter());
-       inset_x = cx() - top_x + drawTextXOffset;
-       inset_y = cy() + drawTextYOffset;
-       inset_pos = cpos();
+       inset_x = cx(bv) - top_x + drawTextXOffset;
+       inset_y = cy(bv) + drawTextYOffset;
+       inset_pos = cpos(bv);
        return true;
     } else if (the_locking_inset && (the_locking_inset == inset)) {
-       if (cpos() == inset_pos) {
+       if (cpos(bv) == inset_pos) {
            lyxerr[Debug::INSETS] << "OK" << endl;
 //         resetPos(bv->painter());
-           inset_x = cx() - top_x + drawTextXOffset;
-           inset_y = cy() + drawTextYOffset;
+           inset_x = cx(bv) - top_x + drawTextXOffset;
+           inset_y = cy(bv) + drawTextYOffset;
        } else {
            lyxerr[Debug::INSETS] << "cursor.pos != inset_pos" << endl;
        }
@@ -369,10 +377,10 @@ bool InsetText::UpdateInsetInInset(BufferView * bv, Inset * inset)
         return the_locking_inset->UpdateInsetInInset(bv, inset);
     lyxerr[Debug::INSETS] << "InsetText::UpdateInsetInInset(" << inset <<
            ")" << endl;
-    UpdateLocal(bv, true, false);
-    if (cpos() == inset_pos) {
-       inset_x = cx() - top_x + drawTextXOffset;
-       inset_y = cy() + drawTextYOffset;
+    UpdateLocal(bv, FULL, false);
+    if (cpos(bv) == inset_pos) {
+       inset_x = cx(bv) - top_x + drawTextXOffset;
+       inset_y = cy(bv) + drawTextYOffset;
     }
     return true;
 }
@@ -380,29 +388,29 @@ bool InsetText::UpdateInsetInInset(BufferView * bv, Inset * inset)
 
 void InsetText::InsetButtonPress(BufferView * bv, int x, int y, int button)
 {
-    if (text->selection) {
-       text->selection = 0;
-       UpdateLocal(bv, false, false);
+    if (TEXT(bv)->selection) {
+       TEXT(bv)->selection = 0;
+       UpdateLocal(bv, FULL, false);
     }
     no_selection = false;
 //    setPos(bv->painter(), x, y);
 //    cursor.x_fix(-1);
-    text->SetCursorFromCoordinates(bv, x, y+bv->screen()->first);
+    TEXT(bv)->SetCursorFromCoordinates(bv, x, y+bv->screen()->first);
     if (the_locking_inset) {
        UpdatableInset * inset = 0;
-       if (par->GetChar(cpos()) == LyXParagraph::META_INSET)
-           inset = static_cast<UpdatableInset*>(par->GetInset(cpos()));
+       if (cpar(bv)->GetChar(cpos(bv)) == LyXParagraph::META_INSET)
+           inset = static_cast<UpdatableInset*>(cpar(bv)->GetInset(cpos(bv)));
        if (the_locking_inset == inset) {
            the_locking_inset->InsetButtonPress(bv,x-inset_x,y-inset_y,button);
            return;
        } else if (inset) {
            // otherwise unlock the_locking_inset and lock the new inset
            the_locking_inset->InsetUnlock(bv);
-           inset_x = cx() - top_x + drawTextXOffset;
-           inset_y = cy() + drawTextYOffset;
+           inset_x = cx(bv) - top_x + drawTextXOffset;
+           inset_y = cy(bv) + drawTextYOffset;
            inset->InsetButtonPress(bv, x - inset_x, y - inset_y, button);
            inset->Edit(bv, x - inset_x, y - inset_y, button);
-           UpdateLocal(bv, true, false);
+           UpdateLocal(bv, FULL, false);
            return;
        }
        // otherwise only unlock the_locking_inset
@@ -410,16 +418,16 @@ void InsetText::InsetButtonPress(BufferView * bv, int x, int y, int button)
        the_locking_inset = 0;
     }
     if (bv->the_locking_inset) {
-       if ((par->GetChar(cpos()) == LyXParagraph::META_INSET) &&
-           par->GetInset(cpos()) &&
-           (par->GetInset(cpos())->Editable() == Inset::HIGHLY_EDITABLE)) {
+       if ((cpar(bv)->GetChar(cpos(bv)) == LyXParagraph::META_INSET) &&
+           cpar(bv)->GetInset(cpos(bv)) &&
+           (cpar(bv)->GetInset(cpos(bv))->Editable() == Inset::HIGHLY_EDITABLE)) {
            UpdatableInset * inset =
-               static_cast<UpdatableInset*>(par->GetInset(cpos()));
-           inset_x = cx() - top_x + drawTextXOffset;
-           inset_y = cy() + drawTextYOffset;
+               static_cast<UpdatableInset*>(cpar(bv)->GetInset(cpos(bv)));
+           inset_x = cx(bv) - top_x + drawTextXOffset;
+           inset_y = cy(bv) + drawTextYOffset;
            inset->InsetButtonPress(bv, x - inset_x, y - inset_y, button);
            inset->Edit(bv, x - inset_x, y - inset_y, 0);
-           UpdateLocal(bv, true, false);
+           UpdateLocal(bv, FULL, false);
        }
     }
 //    selection_start_cursor = selection_end_cursor = cursor;
@@ -433,13 +441,13 @@ void InsetText::InsetButtonRelease(BufferView * bv, int x, int y, int button)
     if (the_locking_inset) {
            the_locking_inset->InsetButtonRelease(bv, x-inset_x, y-inset_y,button);
     } else {
-       if (par->GetChar(cpos()) == LyXParagraph::META_INSET) {
-           inset = static_cast<UpdatableInset*>(par->GetInset(cpos()));
+       if (cpar(bv)->GetChar(cpos(bv)) == LyXParagraph::META_INSET) {
+           inset = static_cast<UpdatableInset*>(cpar(bv)->GetInset(cpos(bv)));
            if (inset->Editable() == Inset::HIGHLY_EDITABLE) {
                inset->InsetButtonRelease(bv, x - inset_x, y - inset_y,button);
            } else {
-               inset_x = cx() - top_x + drawTextXOffset;
-               inset_y = cy() + drawTextYOffset;
+               inset_x = cx(bv) - top_x + drawTextXOffset;
+               inset_y = cy(bv) + drawTextYOffset;
                inset->InsetButtonRelease(bv, x - inset_x, y - inset_y,button);
                inset->Edit(bv, x - inset_x, y - inset_y, button);
            }
@@ -501,7 +509,7 @@ InsetText::LocalDispatch(BufferView * bv,
            return result;
        else if (result == DISPATCHED) {
            the_locking_inset->ToggleInsetCursor(bv);
-           UpdateLocal(bv, false, false);
+           UpdateLocal(bv, FULL, false);
            the_locking_inset->ToggleInsetCursor(bv);
             return result;
         } else if (result == FINISHED) {
@@ -509,7 +517,7 @@ InsetText::LocalDispatch(BufferView * bv,
            case -1:
            case LFUN_RIGHT:
                moveRight(bv);
-//             text->cursor.pos(inset_pos + 1);
+//             TEXT(bv)->cursor.pos(inset_pos + 1);
 //             resetPos(bv->painter());
                break;
            case LFUN_DOWN:
@@ -540,121 +548,121 @@ InsetText::LocalDispatch(BufferView * bv,
                              bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous,
                              bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next);
            if (lyxrc.auto_region_delete) {
-               if (text->selection){
-                   text->CutSelection(bv, false);
+               if (TEXT(bv)->selection){
+                   TEXT(bv)->CutSelection(bv, false);
                }
            }
-           text->ClearSelection();
+           TEXT(bv)->ClearSelection();
            for (string::size_type i = 0; i < arg.length(); ++i) {
-               bv->owner()->getIntl()->getTrans()->TranslateAndInsert(arg[i], text);
+               bv->owner()->getIntl()->getTrans()->TranslateAndInsert(arg[i], TEXT(bv));
            }
        }
-       UpdateLocal(bv, true, true);
+       UpdateLocal(bv, CURSOR_PAR, true);
        break;
         // --- Cursor Movements ---------------------------------------------
     case LFUN_RIGHTSEL:
        bv->text->FinishUndo();
        moveRight(bv, false);
-       text->SetSelection();
-       UpdateLocal(bv, false, false);
+       TEXT(bv)->SetSelection();
+       UpdateLocal(bv, CURSOR_PAR, false);
        break;
     case LFUN_RIGHT:
        bv->text->FinishUndo();
        result = moveRight(bv);
-       text->selection = 0;
-       text->sel_cursor = text->cursor;
-       UpdateLocal(bv, false, false);
+       TEXT(bv)->selection = 0;
+       TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
+       UpdateLocal(bv, CURSOR_PAR, false);
        break;
     case LFUN_LEFTSEL:
        bv->text->FinishUndo();
        moveLeft(bv, false);
-       text->SetSelection();
-       UpdateLocal(bv, false, false);
+       TEXT(bv)->SetSelection();
+       UpdateLocal(bv, CURSOR_PAR, false);
        break;
     case LFUN_LEFT:
        bv->text->FinishUndo();
        result= moveLeft(bv);
-       text->selection = 0;
-       text->sel_cursor = text->cursor;
-       UpdateLocal(bv, false, false);
+       TEXT(bv)->selection = 0;
+       TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
+       UpdateLocal(bv, CURSOR_PAR, false);
        break;
     case LFUN_DOWNSEL:
        bv->text->FinishUndo();
        moveDown(bv);
-       text->SetSelection();
-       UpdateLocal(bv, false, false);
+       TEXT(bv)->SetSelection();
+       UpdateLocal(bv, CURSOR_PAR, false);
        break;
     case LFUN_DOWN:
        bv->text->FinishUndo();
        result = moveDown(bv);
-       text->selection = 0;
-       text->sel_cursor = text->cursor;
-       UpdateLocal(bv, false, false);
+       TEXT(bv)->selection = 0;
+       TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
+       UpdateLocal(bv, CURSOR_PAR, false);
        break;
     case LFUN_UPSEL:
        bv->text->FinishUndo();
        moveUp(bv);
-       text->SetSelection();
-       UpdateLocal(bv, false, false);
+       TEXT(bv)->SetSelection();
+       UpdateLocal(bv, CURSOR_PAR, false);
        break;
     case LFUN_UP:
        bv->text->FinishUndo();
        result = moveUp(bv);
-       text->selection = 0;
-       text->sel_cursor = text->cursor;
-       UpdateLocal(bv, false, false);
+       TEXT(bv)->selection = 0;
+       TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
+       UpdateLocal(bv, CURSOR_PAR, false);
        break;
     case LFUN_HOME:
        bv->text->FinishUndo();
-       text->CursorHome(bv);
-       text->selection = 0;
-       text->sel_cursor = text->cursor;
-       UpdateLocal(bv, false, false);
+       TEXT(bv)->CursorHome(bv);
+       TEXT(bv)->selection = 0;
+       TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
+       UpdateLocal(bv, CURSOR_PAR, false);
        break;
     case LFUN_END:
-       text->CursorEnd(bv);
-       text->selection = 0;
-       text->sel_cursor = text->cursor;
-       UpdateLocal(bv, false, false);
+       TEXT(bv)->CursorEnd(bv);
+       TEXT(bv)->selection = 0;
+       TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
+       UpdateLocal(bv, CURSOR_PAR, false);
        break;
     case LFUN_BACKSPACE:
        bv->text->SetUndo(bv->buffer(), Undo::DELETE, 
          bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous,
          bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next);
-       text->Backspace(bv);
-       UpdateLocal(bv, true, true);
+       TEXT(bv)->Backspace(bv);
+       UpdateLocal(bv, CURSOR_PAR, true);
        break;
     case LFUN_DELETE:
        bv->text->SetUndo(bv->buffer(), Undo::DELETE, 
          bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous,
          bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next);
-       text->Delete(bv);
-       UpdateLocal(bv, true, true);
+       TEXT(bv)->Delete(bv);
+       UpdateLocal(bv, CURSOR_PAR, true);
        break;
     case LFUN_CUT:
        bv->text->SetUndo(bv->buffer(), Undo::DELETE, 
          bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous,
          bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next);
-       text->CutSelection(bv);
-       UpdateLocal(bv, true, true);
+       TEXT(bv)->CutSelection(bv);
+       UpdateLocal(bv, CURSOR_PAR, true);
        break;
     case LFUN_COPY:
        bv->text->FinishUndo();
-       text->CopySelection(bv);
-       UpdateLocal(bv, true, false);
+       TEXT(bv)->CopySelection(bv);
+       UpdateLocal(bv, CURSOR_PAR, false);
        break;
     case LFUN_PASTE:
        bv->text->SetUndo(bv->buffer(), Undo::INSERT, 
          bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous,
          bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next);
-       text->PasteSelection(bv);
-       UpdateLocal(bv, true, true);
+       TEXT(bv)->PasteSelection(bv);
+       UpdateLocal(bv, CURSOR_PAR, true);
        break;
     case LFUN_BREAKPARAGRAPH:
        if (!autoBreakRows)
            return DISPATCHED;
-       text->BreakParagraph(bv, 0);
-       UpdateLocal(bv, true, true);
+       TEXT(bv)->BreakParagraph(bv, 0);
+       UpdateLocal(bv, CURSOR_PAR, true);
        break;
     case LFUN_BREAKLINE:
        if (!autoBreakRows)
@@ -662,12 +670,12 @@ InsetText::LocalDispatch(BufferView * bv,
        bv->text->SetUndo(bv->buffer(), Undo::INSERT, 
            bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous,
            bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next);
-       text->InsertChar(bv, LyXParagraph::META_NEWLINE);
-       UpdateLocal(bv, true, true);
+       TEXT(bv)->InsertChar(bv, LyXParagraph::META_NEWLINE);
+       UpdateLocal(bv, CURSOR_PAR, true);
        break;
     case LFUN_LAYOUT:
     {
-      static LyXTextClass::size_type cur_layout = par->layout;
+      static LyXTextClass::size_type cur_layout = cpar(bv)->layout;
       
        // Derive layout number from given argument (string)
        // and current buffer's textclass (number). */    
@@ -694,9 +702,9 @@ InsetText::LocalDispatch(BufferView * bv,
 
        if (cur_layout != layout.second) {
            cur_layout = layout.second;
-           text->SetLayout(bv, layout.second);
-           bv->owner()->getToolbar()->combox->select(cpar()->GetLayout()+1);
-           UpdateLocal(bv, true, true);
+           TEXT(bv)->SetLayout(bv, layout.second);
+           bv->owner()->getToolbar()->combox->select(cpar(bv)->GetLayout()+1);
+           UpdateLocal(bv, CURSOR_PAR, true);
        }
     }
     break;
@@ -722,7 +730,11 @@ int InsetText::Latex(Buffer const * buf, ostream & os, bool, bool) const
 
 void InsetText::Validate(LaTeXFeatures & features) const
 {
-    par->validate(features);
+    LyXParagraph * p = par;
+    while(p) {
+       p->validate(features);
+       p = p->next;
+    }
 }
 
 
@@ -736,10 +748,10 @@ int InsetText::BeginningOfMainBody(Buffer const * buf, LyXParagraph * p) const
 }
 
 
-void InsetText::GetCursorPos(int & x, int & y) const
+void InsetText::GetCursorPos(BufferView * bv, int & x, int & y) const
 {
-    x = cx();
-    y = cy();
+    x = cx(bv);
+    y = cy(bv);
 }
 
 
@@ -759,7 +771,7 @@ void InsetText::ToggleInsetCursor(BufferView * bv)
         return;
     }
 
-    LyXFont font = text->GetFont(bv->buffer(), cpar(), cpos());
+    LyXFont font = TEXT(bv)->GetFont(bv->buffer(), cpar(bv), cpos(bv));
 
     int asc = lyxfont::maxAscent(font);
     int desc = lyxfont::maxDescent(font);
@@ -767,7 +779,7 @@ void InsetText::ToggleInsetCursor(BufferView * bv)
     if (cursor_visible)
         bv->hideLockedInsetCursor();
     else
-        bv->showLockedInsetCursor(cx(), cy(),
+        bv->showLockedInsetCursor(cx(bv), cy(bv),
                                  asc, desc);
     cursor_visible = !cursor_visible;
 }
@@ -780,13 +792,13 @@ void InsetText::ShowInsetCursor(BufferView * bv)
        return;
     }
     if (!cursor_visible) {
-       LyXFont font = text->GetFont(bv->buffer(), cpar(), cpos());
+       LyXFont font = TEXT(bv)->GetFont(bv->buffer(), cpar(bv), cpos(bv));
        
        int asc = lyxfont::maxAscent(font);
        int desc = lyxfont::maxDescent(font);
 
-       bv->fitLockedInsetCursor(cx(), cy(), asc, desc);
-       bv->showLockedInsetCursor(cx(), cy(), asc, desc);
+       bv->fitLockedInsetCursor(cx(bv), cy(bv), asc, desc);
+       bv->showLockedInsetCursor(cx(bv), cy(bv), asc, desc);
        cursor_visible = true;
     }
 }
@@ -806,13 +818,13 @@ void InsetText::HideInsetCursor(BufferView * bv)
 UpdatableInset::RESULT
 InsetText::moveRight(BufferView * bv, bool activate_inset)
 {
-    if (!cpar()->next && (cpos() >= cpar()->Last()))
+    if (!cpar(bv)->next && (cpos(bv) >= cpar(bv)->Last()))
        return FINISHED;
     if (activate_inset && checkAndActivateInset(bv)) {
        return DISPATCHED;
     }
-    text->CursorRight(bv);
-//    real_current_font = current_font = GetFont(bv->buffer(), cpar(), cpos());
+    TEXT(bv)->CursorRight(bv);
+//    real_current_font = current_font = GetFont(bv->buffer(), cpar(bv), cpos(bv));
     return DISPATCHED_NOUPDATE;
 }
 
@@ -820,9 +832,9 @@ InsetText::moveRight(BufferView * bv, bool activate_inset)
 UpdatableInset::RESULT
 InsetText::moveLeft(BufferView * bv, bool activate_inset)
 {
-    if (!cpar()->previous && (cpos() <= 0))
+    if (!cpar(bv)->previous && (cpos(bv) <= 0))
        return FINISHED;
-    text->CursorLeft(bv);
+    TEXT(bv)->CursorLeft(bv);
     if (activate_inset)
        if (checkAndActivateInset(bv, -1, -1))
            return DISPATCHED;
@@ -833,9 +845,9 @@ InsetText::moveLeft(BufferView * bv, bool activate_inset)
 UpdatableInset::RESULT
 InsetText::moveUp(BufferView * bv)
 {
-    if (!crow()->previous())
+    if (!crow(bv)->previous())
        return FINISHED;
-    text->CursorUp(bv);
+    TEXT(bv)->CursorUp(bv);
     return DISPATCHED_NOUPDATE;
 }
 
@@ -843,24 +855,13 @@ InsetText::moveUp(BufferView * bv)
 UpdatableInset::RESULT
 InsetText::moveDown(BufferView * bv)
 {
-    if (!crow()->next())
+    if (!crow(bv)->next())
        return FINISHED;
-    text->CursorDown(bv);
+    TEXT(bv)->CursorDown(bv);
     return DISPATCHED_NOUPDATE;
 }
 
 
-bool InsetText::Delete()
-{
-    if ((par->GetChar(cpos())==LyXParagraph::META_INSET) &&
-       !par->GetInset(cpos())->Deletable()) {
-       return false;
-    }
-    par->Erase(cpos());
-    return true;
-}
-
-
 bool InsetText::InsertInset(BufferView * bv, Inset * inset)
 {
     if (the_locking_inset) {
@@ -875,10 +876,10 @@ bool InsetText::InsertInset(BufferView * bv, Inset * inset)
        UpdatableInset * i = static_cast<UpdatableInset *>(inset);
        i->setOwner(static_cast<UpdatableInset *>(this));
     }
-    par->InsertChar(cpos(), LyXParagraph::META_INSET);
-    par->InsertInset(cpos(), inset);
-    text->selection = 0;
-    UpdateLocal(bv, true, true);
+    cpar(bv)->InsertChar(cpos(bv), LyXParagraph::META_INSET);
+    cpar(bv)->InsertInset(cpos(bv), inset);
+    TEXT(bv)->selection = 0;
+    UpdateLocal(bv, CURSOR_PAR, true);
     static_cast<UpdatableInset*>(inset)->Edit(bv, 0, 0, 0);
     return true;
 }
@@ -902,21 +903,17 @@ UpdatableInset * InsetText::GetFirstLockingInsetOfType(Inset::Code c)
 
 void InsetText::SetFont(BufferView * bv, LyXFont const & font, bool toggleall)
 {
-    text->SetFont(bv, font, toggleall);
+    TEXT(bv)->SetFont(bv, font, toggleall);
 }
 
 
-void InsetText::UpdateLocal(BufferView * bv, bool what, bool mark_dirty)
+void InsetText::UpdateLocal(BufferView * bv, UpdateCodes what, bool mark_dirty)
 {
-    if (what) {
-       text->FullRebreak(bv);
-    }
+    need_update = what;
     bv->updateInset(this, mark_dirty);
-//    if (flag)
-//     resetPos(bv->painter());
-    if (old_par != cpar()) {
-           bv->owner()->getToolbar()->combox->select(cpar()->GetLayout()+1);
-           old_par = cpar();
+    if (old_par != cpar(bv)) {
+           bv->owner()->getToolbar()->combox->select(cpar(bv)->GetLayout()+1);
+           old_par = cpar(bv);
     }
 }
 
@@ -924,20 +921,20 @@ void InsetText::UpdateLocal(BufferView * bv, bool what, bool mark_dirty)
 bool InsetText::checkAndActivateInset(BufferView * bv, int x, int y,
                                      int button)
 {
-    if (par->GetChar(cpos()) == LyXParagraph::META_INSET) {
+    if (cpar(bv)->GetChar(cpos(bv)) == LyXParagraph::META_INSET) {
        UpdatableInset * inset =
-           static_cast<UpdatableInset*>(par->GetInset(cpos()));
-       LyXFont font = text->GetFont(bv->buffer(), cpar(), cpos());
+           static_cast<UpdatableInset*>(cpar(bv)->GetInset(cpos(bv)));
+       LyXFont font = TEXT(bv)->GetFont(bv->buffer(), cpar(bv), cpos(bv));
        if (x < 0)
            x = inset->width(bv->painter(), font);
        if (y < 0)
            y = inset->descent(bv->painter(), font);
-       inset_x = cx() - top_x + drawTextXOffset;
-       inset_y = cy() + drawTextYOffset;
+       inset_x = cx(bv) - top_x + drawTextXOffset;
+       inset_y = cy(bv) + drawTextYOffset;
        inset->Edit(bv, x - inset_x, y - inset_y, button);
        if (!the_locking_inset)
            return false;
-       UpdateLocal(bv, true, false);
+       UpdateLocal(bv, CURSOR_PAR, false);
        return true;
     }
     return false;
@@ -970,62 +967,74 @@ void InsetText::SetParagraphData(LyXParagraph *p)
        np->next = p->Clone();
        np->next->previous = np;
        np = np->next;
+       np->SetInsetOwner(this);
     }
-    init_inset = true;
+    need_update = INIT;
 }
 
 void InsetText::SetAutoBreakRows(bool flag)
 {
     if (flag != autoBreakRows) {
        autoBreakRows = flag;
-       init_inset = true;
+       need_update = FULL;
     }
 }
 
 void InsetText::SetDrawLockedFrame(bool flag)
 {
-    if (flag != drawLockedFrame) {
+    if (flag != drawLockedFrame)
        drawLockedFrame = flag;
-       init_inset = true;
-    }
 }
 
 void InsetText::SetFrameColor(LColor::color col)
 {
-    if (frame_color != col) {
+    if (frame_color != col)
        frame_color = col;
-       init_inset = true;
-    }
 }
 
-LyXFont InsetText::GetDrawFont(Buffer const * buf, LyXParagraph * par, int pos) const
+LyXFont InsetText::GetDrawFont(BufferView * bv, LyXParagraph * p, int pos) const
 {
-    return text->GetFont(buf, par, pos);
+    return TEXT(bv)->GetFont(bv->buffer(), p, pos);
 }
 
-int InsetText::cx() const
+int InsetText::cx(BufferView * bv) const
 {
-    return text->cursor.x() + top_x + 1;
+    return TEXT(bv)->cursor.x() + top_x + 1;
 }
 
-int InsetText::cy() const
+int InsetText::cy(BufferView * bv) const
 {
     long int y_dummy = 0;
-    Row * tmprow = text->GetRowNearY(y_dummy);
-    return text->cursor.y() - tmprow->baseline();
+    Row * tmprow = TEXT(bv)->GetRowNearY(y_dummy);
+    return TEXT(bv)->cursor.y() - tmprow->baseline();
+}
+
+int InsetText::cpos(BufferView * bv) const
+{
+    return TEXT(bv)->cursor.pos();
+}
+
+LyXParagraph * InsetText::cpar(BufferView * bv) const
+{
+    return TEXT(bv)->cursor.par();
 }
 
-int InsetText::cpos() const
+Row * InsetText::crow(BufferView * bv) const
 {
-    return text->cursor.pos();
+    return TEXT(bv)->cursor.row();
 }
 
-LyXParagraph * InsetText::cpar() const
+LyXText * InsetText::getLyXText(BufferView * bv) const
 {
-    return text->cursor.par();
+    if (cache.find(bv) != cache.end())
+       return cache[bv];
+    LyXText *lt = new LyXText(const_cast<InsetText *>(this));
+    lt->init(bv);
+    cache[bv] = lt;
+    return lt;
 }
 
-Row * InsetText::crow() const
+void InsetText::deleteLyXText(BufferView * bv)
 {
-    return text->cursor.row();
+    cache.erase(bv);
 }
index 40193fa3c32496ca2365b04a173de398d0135a4e..b6a45ba050e34756f798fba70071c74a1e91a8aa 100644 (file)
@@ -29,6 +29,7 @@ class LyXCursor;
 class LyXParagraph;
 class LColor;
 class LyXText;
+class LyXScreen;
 
 /**
  * A text inset is like a TeX box to write full text
@@ -39,6 +40,13 @@ public:
     ///
     enum { TEXT_TO_INSET_OFFSET = 2 };
     ///
+    enum UpdateCodes {
+       NONE = 0,
+       INIT,
+       FULL,
+       CURSOR_PAR
+    };
+    ///
     explicit
     InsetText();
     ///
@@ -62,14 +70,18 @@ public:
     ///
     int width(Painter &, LyXFont const & f) const;
     ///
-    void draw(Painter & pain, LyXFont const &, int , float &) const;
+    void draw(BufferView *, LyXFont const &, int , float &) const;
     ///
-    void update(BufferView *, LyXFont const &) const;
+    void update(BufferView *, LyXFont const &, bool =false);
     ///
     char const * EditMessage() const;
     ///
     void Edit(BufferView *, int, int, unsigned int);
     ///
+    bool IsTextInset() const { return true; }
+    ///
+    bool doClearArea() const { return !locked; }
+    ///
     void InsetUnlock(BufferView *);
     ///
     bool LockInsetInInset(BufferView *, UpdatableInset *);
@@ -100,7 +112,7 @@ public:
     ///
     Inset::Code LyxCode() const { return Inset::TEXT_CODE; }
     ///
-    void GetCursorPos(int & x, int & y) const;
+    void GetCursorPos(BufferView *, int & x, int & y) const;
     ///
     int InsetInInsetY();
     ///
@@ -124,21 +136,21 @@ public:
     ///
     void SetFrameColor(LColor::color);
     ///
-    LyXFont GetDrawFont(Buffer const *, LyXParagraph *, int pos) const;
+    LyXFont GetDrawFont(BufferView *, LyXParagraph *, int pos) const;
     ///
+    LyXText * getLyXText(BufferView *) const;
+    void deleteLyXText(BufferView *);
+
     LyXParagraph * par;
-    ///
 
 protected:
     ///
-    void UpdateLocal(BufferView *, bool what, bool mark_dirty);
+    void UpdateLocal(BufferView *, UpdateCodes, bool mark_dirty);
     ///
     void WriteParagraphData(Buffer const *, std::ostream &) const;
     ///
     virtual int getMaxTextWidth(Painter &, UpdatableInset const *) const;
 
-    LyXText * text;
-    ///
     mutable int drawTextXOffset;
     mutable int drawTextYOffset;
     ///
@@ -148,6 +160,10 @@ protected:
     LColor::color frame_color;
 
 private:
+    ///
+    typedef std::map<BufferView *, LyXText *> Cache;
+    ///
+    typedef Cache::value_type value_type;
     ///
     int BeginningOfMainBody(Buffer const *, LyXParagraph * par) const;
     ///
@@ -163,24 +179,27 @@ private:
     ///
     UpdatableInset::RESULT moveDown(BufferView *);
     ///
-    bool Delete();
-    ///
     void SetCharFont(Buffer const *, int pos, LyXFont const & font);
     ///
     string getText(int);
     ///
     bool checkAndActivateInset(BufferView * bv, int x = 0, int y = 0,
                               int button = 0);
-    int cx() const;
-    int cy() const;
-    int cpos() const;
-    LyXParagraph * cpar() const;
-    Row * crow() const;
+    ///
+    int cx(BufferView *) const;
+    int cy(BufferView *) const;
+    int cpos(BufferView *) const;
+    LyXParagraph * cpar(BufferView *) const;
+    Row * crow(BufferView *) const;
        
     /* Private structures and variables */
     ///
     bool locked;
     ///
+    int insetAscent;
+    int insetDescent;
+    int insetWidth;
+    ///
     int inset_pos;
     ///
     mutable int inset_x;
@@ -193,10 +212,12 @@ private:
     ///
     mutable float xpos;
     ///
-    mutable bool init_inset;
+    mutable UpdateCodes need_update;
     ///
     UpdatableInset * the_locking_inset;
     ///
     LyXParagraph * old_par;
+    /// The cache.
+    mutable Cache cache;
 };
 #endif
index a4fe8ad2b9e373931f62cd89e979aa53ac031eb8..20117dae392f6a3d5a57b8189086c5e6a3076b48 100644 (file)
@@ -23,9 +23,9 @@
 #include "lyxfont.h"
 #include "lyxlex.h"
 
-class Painter;
 class BufferView;
 class Buffer;
+class Painter;
 
 struct LaTeXFeatures;
 
@@ -115,10 +115,11 @@ public:
        ///
        virtual int width(Painter &, LyXFont const &) const = 0;
        ///
-       virtual void draw(Painter &, LyXFont const &,
+       virtual void draw(BufferView *, LyXFont const &,
                          int baseline, float & x) const = 0;
        /// update the inset representation
-       virtual void update(BufferView *, LyXFont const &) const {}
+       virtual void update(BufferView *, LyXFont const &, bool =false)
+               {}
        ///
        virtual LyXFont ConvertFont(LyXFont font);
        /// what appears in the minibuffer when opening
@@ -134,7 +135,9 @@ public:
        /// This is caleld when the user moves the mouse inside an inset
        virtual void InsetMotionNotify(BufferView *, int , int , int) {}
        ///
-       bool IsTextInset() const;
+       virtual bool IsTextInset() const { return false; }
+       ///
+       virtual bool doClearArea() const { return true; }
        ///
        virtual bool AutoDelete() const;
        ///
@@ -272,7 +275,7 @@ public:
        ///
        virtual void HideInsetCursor(BufferView *);
        ///
-       virtual void GetCursorPos(int &, int &) const {}
+       virtual void GetCursorPos(BufferView *, int &, int &) const {}
        ///
        virtual void InsetButtonPress(BufferView *, int x, int y, int button);
        ///
@@ -287,7 +290,7 @@ public:
        ///
        virtual void Edit(BufferView *, int x, int y, unsigned int button);
        ///
-       virtual void draw(Painter &, LyXFont const &,
+       virtual void draw(BufferView *, LyXFont const &,
                          int baseline, float & x) const;
        ///
        virtual void SetFont(BufferView *, LyXFont const &,
index 030c0d3a87f341d03c0354c0c5a10483c7638c4a..24aaf44d0c349578b272baa0b04dd430548bf6a0 100644 (file)
@@ -542,7 +542,7 @@ string LyXFunc::Dispatch(int ac,
                                int slx, sly;
                                UpdatableInset * inset = 
                                        owner->view()->the_locking_inset;
-                               inset->GetCursorPos(slx, sly);
+                               inset->GetCursorPos(owner->view(), slx, sly);
                                owner->view()->unlockInset(inset);
                                owner->view()->menuUndo();
                                if (owner->view()->text->cursor.par()->
@@ -561,7 +561,7 @@ string LyXFunc::Dispatch(int ac,
                                int slx, sly;
                                UpdatableInset * inset = owner->view()->
                                        the_locking_inset;
-                               inset->GetCursorPos(slx, sly);
+                               inset->GetCursorPos(owner->view(), slx, sly);
                                owner->view()->unlockInset(inset);
                                owner->view()->menuRedo();
                                inset = static_cast<UpdatableInset*>(
index eb91ea29cba0c03b317b1ff6a36b445650d56575..f79f60b07341669879452d0cdb644e20ab2a751f 100644 (file)
 #include "lyxcursor.h"
 #include "lyxparagraph.h"
 #include "layout.h"
-#include "insets/insettext.h"
 
 class Buffer;
 class BufferParams;
 class Row;
 class BufferView;
+class InsetText;
 
 
 /**
@@ -63,7 +63,7 @@ public:
        mutable int number_of_rows;
        ///
        mutable long height;
-       mutable long width;
+       mutable int  width;
        /// the current font settings
        mutable LyXFont current_font;
        /// the current font
@@ -424,8 +424,8 @@ public:
 
        /* for the greater insets */
   
-       /// returns 0 if inset wasn't found
-       int UpdateInset(BufferView *, Inset * inset);
+       /// returns false if inset wasn't found
+       bool UpdateInset(BufferView *, Inset *);
        ///
        void CheckParagraph(BufferView *, LyXParagraph * par,
                            LyXParagraph::size_type pos);
index bfb9ce4c63c40915418372193e0eb71034659882..4a87628de48c9715fa5d9ba7bfd2625972c0b334 100644 (file)
@@ -22,6 +22,7 @@
 #include "lyxtext.h"
 #include "support/textutils.h"
 #include "insets/insetbib.h"
+#include "insets/insettext.h"
 #include "lyx_gui_misc.h"
 #include "gettext.h"
 #include "bufferparams.h"
@@ -566,8 +567,7 @@ void LyXText::draw(BufferView * bview, Row const * row,
        } else if (c == LyXParagraph::META_INSET) {
                Inset const * tmpinset = row->par()->GetInset(pos);
                if (tmpinset) {
-                       tmpinset->draw(bview->painter(), font,
-                                      offset + row->baseline(), x);
+                       tmpinset->draw(bview, font, offset+row->baseline(), x);
                }
                ++vpos;
 
@@ -3799,7 +3799,13 @@ void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset,
        else
                ww = bview->workWidth();
 
-       if (bv_owner)
+       bool clear_area = true;
+
+       if ((last == row_ptr->pos()) &&
+           row_ptr->par()->GetInset(row_ptr->pos())) {
+               clear_area = row_ptr->par()->GetInset(row_ptr->pos())->doClearArea();
+       }
+       if (bv_owner && clear_area)
                pain.fillRectangle(x_offset, y_offset, ww, row_ptr->height());
        
        if (selection) {
@@ -4314,8 +4320,7 @@ void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset,
                        else
                                tmpx = x - lyxfont::width(layout.labelsep, font)
                                        - row_ptr->par()->bibkey->width(bview->painter(), font);
-                       row_ptr->par()->bibkey->draw(pain,
-                                                  font,
+                       row_ptr->par()->bibkey->draw(bview, font,
                                                   y_offset + row_ptr->baseline(), 
                                                   tmpx);
                }
index 778e1dd368533923a105ae602f094d20d74d82e9..43cf4ba9598227b32fb0facffe2195b3f26b85da 100644 (file)
@@ -22,6 +22,7 @@
 #include "insets/inseterror.h"
 #include "insets/insetbib.h"
 #include "insets/insetspecialchar.h"
+#include "insets/insettext.h"
 #include "layout.h"
 #include "LyXView.h"
 #include "support/textutils.h"
@@ -1048,6 +1049,10 @@ void LyXText::RedoParagraphs(BufferView * bview, LyXCursor const & cur,
 
 bool LyXText::FullRebreak(BufferView * bview)
 {
+       if (!firstrow) {
+               init(bview);
+               return true;
+       }
        if (need_break_row) {
                BreakAgain(bview, need_break_row);
                need_break_row = 0;
@@ -2649,14 +2654,14 @@ void LyXText::CheckParagraph(BufferView * bview, LyXParagraph * par,
 }
 
 
-// returns 0 if inset wasn't found
-int LyXText::UpdateInset(BufferView * bview, Inset * inset)
+// returns false if inset wasn't found
+bool LyXText::UpdateInset(BufferView * bview, Inset * inset)
 {
        // first check the current paragraph
        int pos = cursor.par()->GetPositionOfInset(inset);
        if (pos != -1){
                CheckParagraph(bview, cursor.par(), pos);
-               return 1;
+               return true;
        }
   
        // check every paragraph
@@ -2668,13 +2673,13 @@ int LyXText::UpdateInset(BufferView * bview, Inset * inset)
                        pos = par->GetPositionOfInset(inset);
                        if (pos != -1){
                                CheckParagraph(bview, par, pos);
-                               return 1;
+                               return true;
                        }
                }
                par = par->Next();
        } while (par);
   
-       return 0;
+       return false;
 }