]> git.lyx.org Git - features.git/commitdiff
Some more inset-text/tabular update fixes, still some position and update
authorJürgen Vigna <jug@sad.it>
Wed, 28 Jun 2000 15:12:29 +0000 (15:12 +0000)
committerJürgen Vigna <jug@sad.it>
Wed, 28 Jun 2000 15:12:29 +0000 (15:12 +0000)
problem for inset in inset in inset to fix.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@847 a592a061-630c-0410-9148-cb99ea01b6c8

ChangeLog
src/insets/insetcollapsable.C
src/insets/insetcollapsable.h
src/insets/insetfoot.C
src/insets/insetmarginal.C
src/insets/insettabular.C
src/insets/insettext.C
src/insets/insettext.h
src/text.C

index 467c37c17bbb3ee061fc40a03991cab8a53a9870..c4fe36d1af2594358dfe8749d42a8cbcc68bb461 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2000-06-28  Juergen Vigna  <jug@sad.it>
+
+       * src/text.C (GetVisibleRow): fixed clearing of text if rowHeight >
+       insetHeight.
+
 2000-06-28  Jean-Marc Lasgouttes  <Jean-Marc.Lasgouttes@inria.fr>
 
        * src/insets/insetindex.C (Edit): add a callback when popup is
index 3bc130945558ae3f71fca171c33886faac1d035e..2fc7ff83ed511677c55a5eeed1a7b879aa7d90b7 100644 (file)
@@ -48,8 +48,8 @@ Inset * InsetCollapsable::Clone() const
 
 void InsetCollapsable::Write(Buffer const * buf, ostream & os) const
 {
-       os << "collapsed " << tostr(!display()) << "\n";
-       WriteParagraphData(buf, os);
+    os << "collapsed " << tostr(!display()) << "\n";
+    WriteParagraphData(buf, os);
 }
 
 
@@ -141,18 +141,38 @@ void InsetCollapsable::draw(BufferView * bv, LyXFont const & f,
     button_length = width_collapsed(pain, labelfont) + 2;
     button_top_y = -ascent_collapsed(pain, f);
     button_bottom_y = descent_collapsed(pain, f);
-    top_x = int(x);
-    top_baseline = baseline;
     if (collapsed) {
        draw_collapsed(pain, f, baseline, x);
        return;
     }
 
-    draw_collapsed(pain, f, baseline, x);
-    x -= TEXT_TO_INSET_OFFSET;
+    if (!cleared && ((need_update==FULL) || (topx!=int(x)) ||
+                    (topbaseline!=baseline))) {
+       int w =  width(pain, f);
+       int h = ascent(pain,f) + descent(pain, f);
+       int tx = display()? 0:topx;
+       int ty = baseline - ascent(pain,f);
+       
+       if (ty < 0)
+           ty = 0;
+       if ((ty + h) > pain.paperHeight())
+           h = pain.paperHeight();
+       if ((topx + w) > pain.paperWidth())
+           w = pain.paperWidth();
+       pain.fillRectangle(tx, ty-1, w, h+2);
+       cleared = true;
+    }
+
+    // not needed if collapsed
+    topx = int(x);
+    topbaseline = baseline;
 
     int w =  InsetText::width(pain, f) + (2 * TEXT_TO_INSET_OFFSET);
     int h = ascent(pain,f) + descent(pain, f);
+
+    draw_collapsed(pain, f, baseline, x);
+    x -= TEXT_TO_INSET_OFFSET;
+
     int save_x = static_cast<int>(x);
     x += TEXT_TO_INSET_OFFSET;
     InsetText::draw(bv, f, baseline, x, cleared);
index 6e65c586ac869175c965ab0886a7d35097d2e39f..42ec6507fbcec9472d03846e2e365df1ce5eb85b 100644 (file)
@@ -110,6 +110,9 @@ protected:
 private:
     ///
     int widthOffset;
+    ///
+    mutable int topx;
+    mutable int topbaseline;
 };
 
 #endif
index 9b33e6f08b25a1559e1836a9642c39f27f867fe6..6d03835a5f0a66d5b37480ba086ec1fe671665e3 100644 (file)
@@ -39,8 +39,8 @@ InsetFoot::InsetFoot() : InsetCollapsable()
 
 void InsetFoot::Write(Buffer const * buf, ostream & os) const 
 {
-       os << getInsetName() << "\n";
-       InsetCollapsable::Write(buf, os);
+    os << getInsetName() << "\n";
+    InsetCollapsable::Write(buf, os);
 }
 
 
index b5cb2537602ff1bc9776e656dba99d2308642129..889743d2a5cdc9a12e4a77729e1cc3926e39148e 100644 (file)
@@ -26,37 +26,37 @@ using std::endl;
 
 InsetMarginal::InsetMarginal() : InsetCollapsable()
 {
-       setLabel(_("margin"));
-       LyXFont font(LyXFont::ALL_SANE);
-       font.decSize();
-       font.decSize();
-       font.setColor(LColor::footnote);
-       setLabelFont(font);
-       setAutoCollapse(false);
-       setInsetName("Marginal");
+    setLabel(_("margin"));
+    LyXFont font(LyXFont::ALL_SANE);
+    font.decSize();
+    font.decSize();
+    font.setColor(LColor::footnote);
+    setLabelFont(font);
+    setAutoCollapse(false);
+    setInsetName("Marginal");
 }
 
 
 void InsetMarginal::Write(Buffer const * buf, ostream & os) const
 {
-       os << getInsetName() << "\n";
-       InsetCollapsable::Write(buf, os);
+    os << getInsetName() << "\n";
+    InsetCollapsable::Write(buf, os);
 }
 
 
 Inset * InsetMarginal::Clone() const
 {
-       InsetMarginal * result = new InsetMarginal;
-       result->init(this);
-
-       result->collapsed = collapsed;
-       return result;
+    InsetMarginal * result = new InsetMarginal;
+    result->init(this);
+    
+    result->collapsed = collapsed;
+    return result;
 }
 
 
 char const * InsetMarginal::EditMessage() const
 {
-       return _("Opened Marginal Note Inset");
+    return _("Opened Marginal Note Inset");
 }
 
 
index cbffdc4647320ff59f5853c88a2283b4f9d66cf0..b9a6ba935fb630422de138a12b15a6ab7f0acb1b 100644 (file)
@@ -158,10 +158,25 @@ void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline,
     float cx;
 
     UpdatableInset::draw(bv,font,baseline,x,cleared);
-    if ((need_update == INIT)|| (top_x != int(x)) || (top_baseline != baseline)) {
+    if (!cleared && ((need_update == INIT) || (need_update == FULL) ||
+                    (top_x != int(x)) || (top_baseline != baseline))) {
+#if 1
+       int h = ascent(pain, font) + descent(pain, font);
+       int tx = display()? 0:top_x;
+       int w =  tx? width(pain, font):pain.paperWidth();
+       int ty = baseline - ascent(pain, font);
+       
+       if (ty < 0)
+           ty = 0;
+       if ((ty + h) > pain.paperHeight())
+           h = pain.paperHeight();
+       if ((top_x + w) > pain.paperWidth())
+           w = pain.paperWidth();
+       pain.fillRectangle(tx, ty, w, h);
+       need_update = FULL;
+       cleared = true;
+#else
        need_update = FULL;
-       top_x = int(x);
-       top_baseline = baseline;
        resetPos(pain);
        if (locked) { // repaint this way as the background was not cleared
                if (the_locking_inset)
@@ -171,10 +186,13 @@ void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline,
                locked = true;
                return;
        }
+#endif
     }
+    top_x = int(x);
+    top_baseline = baseline;
     bool dodraw;
     x += ADD_TO_TABULAR_WIDTH;
-    if (cleared || !locked || (need_update == FULL) || (need_update == CELL)) {
+    if (cleared || (need_update == FULL) || (need_update == CELL)) {
        for(i=0;i<tabular->rows();++i) {
            nx = int(x);
            dodraw = ((baseline+tabular->GetDescentOfRow(i)) > 0) &&
index a38e02d82b26c7d29da848c4903859430cad11bd..b8157f7f9a549d1a780c3ceec43c6f5afabc62b8 100644 (file)
@@ -221,25 +221,19 @@ void InsetText::draw(BufferView * bv, LyXFont const & f,
 
     if (!cleared && ((need_update==FULL) || (top_x!=int(x)) ||
                     (top_baseline!=baseline))) {
-#if 0
-           // && locked && ((need_update==FULL) || (top_x!=int(x)) ||
-           //    (top_baseline!=baseline))) {
-       need_update = NONE;
-       top_x = int(x);
-       top_baseline = baseline;
-       locked = false;
-       bv->updateInset(const_cast<InsetText *>(this), false);
-       locked = true;
-       if (drawLockedFrame)
-               pain.rectangle(top_x, baseline - ascent(pain, f),
-                              width(pain, f), ascent(pain,f)+descent(pain, f),
-                              frame_color);
-       return;
-#else
-       pain.fillRectangle(top_x+drawTextXOffset, top_y, last_width,
-                          last_height);
+       int w =  insetWidth;
+       int h = insetAscent + insetDescent;
+       int ty = baseline - insetAscent;
+       
+       if (ty < 0)
+           ty = 0;
+       if ((ty + h) > pain.paperHeight())
+           h = pain.paperHeight();
+       if ((top_x + drawTextXOffset + w) > pain.paperWidth())
+           w = pain.paperWidth();
+       pain.fillRectangle(top_x+drawTextXOffset, ty, w, h);
+       cleared = true;
        need_update = FULL;
-#endif
     }
 
     if (!cleared && (need_update == NONE))
@@ -258,7 +252,7 @@ void InsetText::draw(BufferView * bv, LyXFont const & f,
        inset_x = cx(bv) - top_x + drawTextXOffset;
        inset_y = cy(bv) + drawTextYOffset;
     }
-    if (need_update == CURSOR) {
+    if (!cleared && (need_update == CURSOR)) {
        x += width(pain, f);
        need_update = NONE;
        return;
@@ -337,11 +331,10 @@ void InsetText::Edit(BufferView * bv, int x, int y, unsigned int button)
     locked = true;
     the_locking_inset = 0;
     inset_pos = inset_x = inset_y = 0;
-#warning Fix cursor setting here!!! (Jug)
-    TEXT(bv)->SetCursor(bv, par, 0);
-//    setPos(bv->painter(), x, y);
+    TEXT(bv)->SetCursorFromCoordinates(bv, x-drawTextXOffset,
+                                      y+TEXT(bv)->first-drawTextYOffset+
+                                      insetAscent);
     checkAndActivateInset(bv, x, y, button);
-//    selection_start_cursor = selection_end_cursor = cursor;
     TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
     bv->text->FinishUndo();
     UpdateLocal(bv, FULL, false);
@@ -435,7 +428,9 @@ void InsetText::InsetButtonPress(BufferView * bv, int x, int y, int button)
        UpdateLocal(bv, FULL, false);
     }
     no_selection = false;
-    TEXT(bv)->SetCursorFromCoordinates(bv, x, y+TEXT(bv)->first);
+    TEXT(bv)->SetCursorFromCoordinates(bv, x-drawTextXOffset,
+                                      y+TEXT(bv)->first-drawTextYOffset+
+                                      insetAscent);
     if (the_locking_inset) {
        UpdatableInset * inset = 0;
        if (cpar(bv)->GetChar(cpos(bv)) == LyXParagraph::META_INSET)
@@ -698,7 +693,7 @@ InsetText::LocalDispatch(BufferView * bv,
        if (!autoBreakRows)
            return DISPATCHED;
        TEXT(bv)->BreakParagraph(bv, 0);
-       UpdateLocal(bv, CURSOR_PAR, true);
+       UpdateLocal(bv, FULL, true);
        break;
     case LFUN_BREAKLINE:
        if (!autoBreakRows)
index 7174d2a55e9901d4565ecafbebb889fd3eaf25ef..b6738d95db03eaa233cc52d5a70fd6662e0f3323 100644 (file)
@@ -162,6 +162,8 @@ protected:
     bool drawLockedFrame;
     ///
     LColor::color frame_color;
+    ///
+    mutable UpdateCodes need_update;
 
 private:
     ///
@@ -196,10 +198,10 @@ private:
     LyXParagraph * cpar(BufferView *) const;
     Row * crow(BufferView *) const;
 
-       /// This instead of a macro
-       LyXText * TEXT(BufferView * bv) const {
-               return getLyXText(bv);
-       }
+    /// This instead of a macro
+    LyXText * TEXT(BufferView * bv) const {
+       return getLyXText(bv);
+    }
        
     /* Private structures and variables */
     ///
@@ -224,8 +226,6 @@ private:
     ///
     mutable float xpos;
     ///
-    mutable UpdateCodes need_update;
-    ///
     UpdatableInset * the_locking_inset;
     ///
     LyXParagraph * old_par;
index b5f04719ce9c048ec922ffd20d3bdb432a744539..24269e9d88cb216228ba9b4833eb2a3ee4065ac0 100644 (file)
@@ -3837,12 +3837,13 @@ void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset,
        ww = bview->workWidth();
 
        bool clear_area = true;
+       Inset * inset = 0;
 
        if ((last == row_ptr->pos()) &&
            (row_ptr->par()->GetChar(row_ptr->pos()) == LyXParagraph::META_INSET) &&
-           (row_ptr->par()->GetInset(row_ptr->pos())))
+           (inset=row_ptr->par()->GetInset(row_ptr->pos())))
        {
-               clear_area = row_ptr->par()->GetInset(row_ptr->pos())->doClearArea();
+               clear_area = inset->doClearArea();
        }
        if (clear_area) {
                int w;
@@ -3851,6 +3852,16 @@ void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset,
                else
                        w = ww;
                pain.fillRectangle(x_offset, y_offset, w, row_ptr->height());
+       } else if (inset != 0) {
+               int h = row_ptr->baseline() - inset->ascent(pain, font);
+               if (h > 0) {
+                       int w;
+                       if (inset_owner)
+                               w = inset_owner->width(bview->painter(), font);
+                       else
+                               w = ww;
+                       pain.fillRectangle(x_offset, y_offset, w, h);
+               }
        }
        
        if (selection) {