]> git.lyx.org Git - features.git/commitdiff
Some more changes for updating text-insets.
authorJürgen Vigna <jug@sad.it>
Tue, 4 Jul 2000 15:46:55 +0000 (15:46 +0000)
committerJürgen Vigna <jug@sad.it>
Tue, 4 Jul 2000 15:46:55 +0000 (15:46 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@856 a592a061-630c-0410-9148-cb99ea01b6c8

src/insets/insetcollapsable.C
src/insets/insettabular.h
src/insets/insettext.C
src/insets/insettext.h
src/text.C

index 0daae7037f1b2ba64c3c08b8050bcc2e47139406..718600a2d9722975794c7be1100ccfe9c06807df 100644 (file)
@@ -156,11 +156,11 @@ void InsetCollapsable::draw(BufferView * bv, LyXFont const & f,
        return;
     }
 
-    if (!cleared && ((need_update == FULL) ||
+    if (!cleared && ((inset->need_update == InsetText::FULL) ||
                     (top_x!=int(x)) || (top_baseline!=baseline))) {
        int w =  owner()? width(pain, f) : pain.paperWidth();
        int h = ascent(pain,f) + descent(pain, f);
-       int tx = (display() && !owner())? 0:int(x);
+       int tx = (needFullRow() && !owner())? 0:int(x);
        int ty = baseline - ascent(pain,f);
        
        if (ty < 0)
@@ -291,8 +291,8 @@ int InsetCollapsable::getMaxTextWidth(Painter & pain,
 }
 
 
-void InsetCollapsable::update(BufferView * bv,
-                             LyXFont const & font, bool dodraw)
+void InsetCollapsable::update(BufferView * bv, LyXFont const & font,
+                             bool dodraw)
 {
     if (!widthCollapsed) {
        widthCollapsed = width_collapsed(bv->painter(), font);
index 9a2a6ee796666060f4a2e1180ba671989850f4c6..2cb39167ee47836390876e6f2d50b79dd1d8b69e 100644 (file)
@@ -91,7 +91,7 @@ public:
     ///
     void draw(BufferView *, const LyXFont &, int , float &, bool) const;
     ///
-    void update(BufferView *, LyXFont const &, bool);
+    void update(BufferView *, LyXFont const &, bool =false);
     ///
     const char * EditMessage() const;
     ///
index 10347afe2e30591f994f7a9f295d418fce579ff8..f8be238c2edb5fbee6f978bee8e2d0bc38a3f980 100644 (file)
@@ -214,14 +214,14 @@ int InsetText::textWidth(Painter & pain) const
     }
 #if 0
     if (owner()) {
-       w = w - top_x + owner()->x();
-       printf("WW2: %d\n",w);
+       w = w - top_x; // + owner()->x();
+//     printf("WW2: %d\n",w);
        return w; // - top_x + owner()->x();
     }
 #endif
     w -= (2 * TEXT_TO_INSET_OFFSET);
 //    printf("WW2: %d\n",w);
-    return w; // - top_x - (2 * TEXT_TO_INSET_OFFSET);
+    return w - top_x; // - top_x - (2 * TEXT_TO_INSET_OFFSET);
 }
 
 
@@ -290,12 +290,12 @@ void InsetText::draw(BufferView * bv, LyXFont const & f,
     if ((drawFrame == ALWAYS) || ((drawFrame == LOCKED) && locked)) {
            pain.rectangle(top_x, baseline - insetAscent, insetWidth,
                           insetAscent + insetDescent, frame_color);
-    } else {
+    } else if (need_update == CLEAR_FRAME) {
            pain.rectangle(top_x, baseline - insetAscent, insetWidth,
                           insetAscent + insetDescent,
                           LColor::background);
     }
-    x += width(pain, f) - TEXT_TO_INSET_OFFSET;
+    x += insetWidth - TEXT_TO_INSET_OFFSET;
     need_update = NONE;
 }
 
@@ -310,9 +310,10 @@ void InsetText::update(BufferView * bv, LyXFont const & font, bool dodraw)
     }
     int oldw = insetWidth;
 #if 1
-    insetWidth = max(textWidth(bv->painter()),
-                    static_cast<int>(TEXT(bv)->width) + drawTextXOffset) +
-       (2 * TEXT_TO_INSET_OFFSET);
+    insetWidth = TEXT(bv)->width + (2 * TEXT_TO_INSET_OFFSET);
+    // max(textWidth(bv->painter()),
+    // static_cast<int>(TEXT(bv)->width) + drawTextXOffset) +
+    // (2 * TEXT_TO_INSET_OFFSET);
 #else
     insetWidth = textWidth(bv->painter());
     if (insetWidth < 0)
@@ -322,10 +323,13 @@ void InsetText::update(BufferView * bv, LyXFont const & font, bool dodraw)
            printf("TW(%p): %d-%d-%d-%d\n",this,insetWidth, oldw,
                   textWidth(bv->painter()),static_cast<int>(TEXT(bv)->width));
        deleteLyXText(bv);
+       need_update = FULL;
 #if 0
        if (owner()) {
-               owner()->update(bv, font, dodraw);
-               return;
+           owner()->update(bv, font, dodraw);
+           return;
+       } else {
+           update(bv, font, dodraw);
        }
 #else
 #if 1
@@ -347,6 +351,9 @@ void InsetText::update(BufferView * bv, LyXFont const & font, bool dodraw)
        TEXT(bv)->UpdateInset(bv, the_locking_inset);
     }
 
+    if (TEXT(bv)->status == LyXText::NEED_MORE_REFRESH)
+       need_update = FULL;
+
     long int y_temp = 0;
     Row * row = TEXT(bv)->GetRowNearY(y_temp);
     insetAscent = row->ascent_of_text() + TEXT_TO_INSET_OFFSET;
@@ -408,7 +415,7 @@ void InsetText::InsetUnlock(BufferView * bv)
     no_selection = false;
     locked = false;
     TEXT(bv)->selection = 0;
-    UpdateLocal(bv, CURSOR_PAR, false);
+    UpdateLocal(bv, CLEAR_FRAME, false);
     bv->owner()->getToolbar()->combox->select(bv->text->cursor.par()->GetLayout()+1);
 }
 
@@ -1100,10 +1107,9 @@ bool InsetText::checkAndActivateInset(BufferView * bv, int x, int y,
 }
 
 
-int InsetText::getMaxTextWidth(Painter & pain,
-                              UpdatableInset const * inset) const
+int InsetText::getMaxWidth(Painter & pain, UpdatableInset const * inset) const
 {
-    return getMaxWidth(pain, inset) - (2 * TEXT_TO_INSET_OFFSET);
+    return UpdatableInset::getMaxWidth(pain, inset) - (2*TEXT_TO_INSET_OFFSET);
 }
 
 
@@ -1148,7 +1154,7 @@ void InsetText::SetDrawFrame(BufferView * bv, DrawFrame how)
     if (how != drawFrame) {
        drawFrame = how;
        if (bv)
-           UpdateLocal(bv, FRAME, false);
+           UpdateLocal(bv, DRAW_FRAME, false);
     }
 }
 
@@ -1158,7 +1164,7 @@ void InsetText::SetFrameColor(BufferView * bv, LColor::color col)
     if (frame_color != col) {
        frame_color = col;
        if (bv)
-           UpdateLocal(bv, FRAME, false);
+           UpdateLocal(bv, DRAW_FRAME, false);
     }
 }
 
index f6382fe61ab107ea7c980f4b0008ea377d4fae56..223b34ede153db528872a1d1681847b569954042 100644 (file)
@@ -45,7 +45,8 @@ public:
        CURSOR_PAR,
        CURSOR,
        SELECTION,
-       FRAME
+       DRAW_FRAME,
+       CLEAR_FRAME
     };
     ///
     enum DrawFrame {
@@ -135,6 +136,8 @@ public:
     ///
     void SetFont(BufferView *, LyXFont const &, bool toggleall = false);
     ///
+    int getMaxWidth(Painter &, UpdatableInset const *) const;
+    ///
     void init(InsetText const * ins = 0);
     ///
     void WriteParagraphData(Buffer const *, std::ostream &) const;
@@ -153,12 +156,12 @@ public:
     void deleteLyXText(BufferView *);
 
     LyXParagraph * par;
+    ///
+    mutable UpdateCodes need_update;
 
 protected:
     ///
     void UpdateLocal(BufferView *, UpdateCodes, bool mark_dirty);
-    ///
-    virtual int getMaxTextWidth(Painter &, UpdatableInset const *) const;
 
     mutable int drawTextXOffset;
     mutable int drawTextYOffset;
@@ -167,8 +170,6 @@ protected:
     DrawFrame drawFrame;
     ///
     LColor::color frame_color;
-    ///
-    mutable UpdateCodes need_update;
 
 private:
     ///
index e769dc96e3aeb02ef6c9f3bc5ce9f2150082423e..525bb546101cd90a07c5209a4dd0c3c425ba85a0 100644 (file)
@@ -567,7 +567,7 @@ void LyXText::draw(BufferView * bview, Row const * row,
                if (c == LyXParagraph::META_INSET) {
                Inset * tmpinset = row->par()->GetInset(pos);
                if (tmpinset) {
-                       tmpinset->update(bview, font);
+                       tmpinset->update(bview, font, false);
                        tmpinset->draw(bview, font, offset+row->baseline(), x,
                                       cleared);
                }
@@ -1699,7 +1699,7 @@ void LyXText::SetHeightOfRow(BufferView * bview, Row * row_ptr) const
    row_ptr->width(maxwidth+x);
    if (inset_owner) {
           Row * r = firstrow;
-          width = 0;
+          width = max(0,workWidth(bview));
           while(r) {
                   if (r->width() > width)
                           width = r->width();