]> git.lyx.org Git - features.git/commitdiff
Small fixes noticed by Jean-Marc.
authorJürgen Vigna <jug@sad.it>
Fri, 10 Nov 2000 16:04:51 +0000 (16:04 +0000)
committerJürgen Vigna <jug@sad.it>
Fri, 10 Nov 2000 16:04:51 +0000 (16:04 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1210 a592a061-630c-0410-9148-cb99ea01b6c8

ChangeLog
src/insets/inset.C
src/insets/insettabular.C
src/insets/insettabular.h
src/insets/insettext.C
src/text2.C

index 2e3dde696672f738152cecc3de63cbeef4537cd4..d800b58e098fbcac0e95ad46047dfbb23f39848a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2000-11-10  Juergen Vigna  <jug@sad.it>
+
+       * src/insets/insettext.C (resizeLyXText): check !cache[bv]
+       (deleteLyXText): ditto
+
+       * src/insets/insettabular.C (InsetButtonPress): don't clear the
+       selection on mouse-button-3.
+
+       * src/insets/insettabular.h: new function clearSelection(), use this
+       functions inside insettabular.C.
+
+       * src/insets/insettabular.C (TabularFeatures): clear the selection
+       on remove_row/column.
+
+       * src/insets/inset.C (scroll): fixed some scroll stuff.
+
+       * src/insets/insettabular.C (draw): fixed another minor draw problem.
+
 2000-11-10  Jean-Marc Lasgouttes  <Jean-Marc.Lasgouttes@inria.fr>
 
        * lib/CREDITS: add Yves Bastide
index aa1fadca8141c6de87c82d18c989273161aaad1b..c5526aa723fd0b909c94bad24e276512901be91d 100644 (file)
@@ -167,6 +167,10 @@ void UpdatableInset::scroll(BufferView * bv, float s) const
 {
     LyXFont font;
 
+    if (!s) {
+       scx = 0;
+       return;
+    }
     if (((top_x - scx) > 0) && 
        (top_x - scx + width(bv, font)) < bv->workWidth())
        return;
@@ -189,7 +193,7 @@ void UpdatableInset::scroll(BufferView * bv, float s) const
 void UpdatableInset::scroll(BufferView * bv, int offset) const
 {
     if (offset > 0) {
-       if (!scx && top_x > 0)
+       if (!scx && top_x >= 20)
            return;
        if ((top_x + offset) > 20)
            scx += offset - (top_x - scx + offset - 20);
index 88b234dfc42a84e634d8466ed807dc43355db574..89f19028de4d61f8c6df165507ac4b4610b788ff 100644 (file)
@@ -129,9 +129,9 @@ InsetTabular::InsetTabular(Buffer const & buf, int rows, int columns)
     locked = no_selection = cursor_visible = false;
     cursor.x_fix(-1);
     oldcell = -1;
-    actcell = 0;
+    actrow = actcell = 0;
     cursor.pos(0);
-    sel_pos_start = sel_pos_end = sel_cell_start = sel_cell_end = 0;
+    clearSelection();
     need_update = INIT;
 }
 
@@ -144,7 +144,7 @@ InsetTabular::InsetTabular(InsetTabular const & tab, Buffer const & buf)
     locked = no_selection = cursor_visible = false;
     cursor.x_fix(-1);
     oldcell = -1;
-    actcell = 0;
+    actrow = actcell = 0;
     cursor.pos(0);
     sel_pos_start = sel_pos_end = sel_cell_start = sel_cell_end = 0;
     need_update = INIT;
@@ -292,6 +292,7 @@ void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline,
        }
         i = tabular->row_of_cell(actcell);
        if (the_locking_inset == tabular->GetCellInset(cell)) {
+#if 0
            LyXText::text_status st = bv->text->status;
            do {
                cx = nx + tabular->GetBeginningOfTextInCell(cell);
@@ -310,12 +311,38 @@ void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline,
                        baseline - tabular->GetAscentOfRow(i) + 1,
                        tabular->GetWidthOfColumn(cell) -
                        tabular->GetBeginningOfTextInCell(cell) -
-                       the_locking_inset->width(bv,font) - 1,
+                       the_locking_inset->width(bv,font) -
+                       tabular->GetAdditionalWidth(cell) - 1,
                        tabular->GetAscentOfRow(i) +
                        tabular->GetDescentOfRow(i) - 1);
                }
                tabular->GetCellInset(cell)->draw(bv,font,baseline, cx, false);
            } while(bv->text->status == LyXText::CHANGED_IN_DRAW);
+#else
+           cx = nx + tabular->GetBeginningOfTextInCell(cell);
+           if (need_update == CELL) {
+               // clear before the inset
+               pain.fillRectangle(
+                   nx + 1,
+                   baseline - tabular->GetAscentOfRow(i) + 1,
+                   int(cx - nx - 1),
+                   tabular->GetAscentOfRow(i) +
+                   tabular->GetDescentOfRow(i) - 1);
+               // clear behind the inset
+               pain.fillRectangle(
+                   int(cx + the_locking_inset->width(bv,font) + 1),
+                   baseline - tabular->GetAscentOfRow(i) + 1,
+                   tabular->GetWidthOfColumn(cell) -
+                   tabular->GetBeginningOfTextInCell(cell) -
+                   the_locking_inset->width(bv,font) -
+                   tabular->GetAdditionalWidth(cell) - 1,
+                   tabular->GetAscentOfRow(i) +
+                   tabular->GetDescentOfRow(i) - 1);
+           }
+           tabular->GetCellInset(cell)->draw(bv,font,baseline, cx, false);
+           if (bv->text->status == LyXText::CHANGED_IN_DRAW)
+               return;
+#endif
        }
     }
     x -= ADD_TO_TABULAR_WIDTH;
@@ -592,8 +619,8 @@ bool InsetTabular::InsertInset(BufferView * bv, Inset * inset)
 
 void InsetTabular::InsetButtonPress(BufferView * bv, int x, int y, int button)
 {
-    if (hasSelection()) {
-       sel_pos_start = sel_pos_end = sel_cell_start = sel_cell_end = 0;
+    if (hasSelection() && (button != 3)) {
+       clearSelection();
        UpdateLocal(bv, SELECTION, false);
     }
     no_selection = false;
@@ -1117,7 +1144,10 @@ void InsetTabular::resetPos(BufferView * bv) const
        }
     }
     static int const offset = ADD_TO_TABULAR_WIDTH + 2;
-    cursor.x(getCellXPos(actcell) + offset);
+    int new_x = getCellXPos(actcell);
+    new_x += offset;
+    cursor.x(new_x);
+//    cursor.x(getCellXPos(actcell) + offset);
     if (((cursor.x() - offset) > 20) &&
        ((cursor.x()-offset+tabular->GetWidthOfColumn(actcell)) >
         (bv->workWidth()-20)))
@@ -1387,6 +1417,7 @@ void InsetTabular::TabularFeatures(BufferView * bv,
        if ((row+1) > tabular->rows())
            --row;
        actcell = tabular->GetCellNumber(row, column);
+       clearSelection();
        UpdateLocal(bv, INIT, true);
        break;
     case LyXTabular::DELETE_COLUMN:
@@ -1394,6 +1425,7 @@ void InsetTabular::TabularFeatures(BufferView * bv,
        if ((column+1) > tabular->columns())
            --column;
        actcell = tabular->GetCellNumber(row, column);
+       clearSelection();
        UpdateLocal(bv, INIT, true);
        break;
     case LyXTabular::M_TOGGLE_LINE_TOP:
index 4a62f37108ee7d4652b70b29f3863ab7f5ae5695..f9d8396978d1e247f87babad3462af72dc0c0b95 100644 (file)
@@ -221,6 +221,10 @@ private:
     bool hasSelection() const { return ((sel_pos_start != sel_pos_end) ||
                                       (sel_cell_start != sel_cell_end));}
     ///
+    void clearSelection() const {
+       sel_pos_start = sel_pos_end = sel_cell_start = sel_cell_end = 0;
+    }
+    ///
     bool ActivateCellInset(BufferView *, int x = 0, int y = 0, int button = 0,
                           bool behind = false);
     ///
index 369d9b4ae6a66e87a47f31f407abe50ae53803d9..218521efbca3099c49124d38e9ab77fca011af5a 100644 (file)
@@ -405,8 +405,6 @@ void InsetText::update(BufferView * bv, LyXFont const & font, bool reinit)
     if (need_update == INIT) {
        resizeLyXText(bv);
        need_update = FULL;
-//     if (!owner() && bv->text)
-//         bv->text->UpdateInset(bv, this);
     }
     int oldw = insetWidth;
 #if 1
@@ -424,20 +422,7 @@ void InsetText::update(BufferView * bv, LyXFont const & font, bool reinit)
 //                textWidth(bv->painter()),static_cast<int>(TEXT(bv)->width));
        resizeLyXText(bv);
        need_update = FULL;
-#if 0
-       if (owner()) {
-           owner()->update(bv, font, reinit);
-           return;
-       } else {
-           update(bv, font, reinit);
-       }
-#else
-#if 1
        update(bv, font, reinit);
-#else
-       UpdateLocal(bv, INIT, false);
-#endif
-#endif
        return;
     }
     if ((need_update==CURSOR_PAR) && (TEXT(bv)->status==LyXText::UNCHANGED) &&
@@ -1510,7 +1495,7 @@ LyXText * InsetText::getLyXText(BufferView * bv) const
 
 void InsetText::deleteLyXText(BufferView * bv, bool recursive) const
 {
-    if (cache.find(bv) == cache.end())
+    if ((cache.find(bv) == cache.end()) || !cache[bv])
        return;
     delete cache[bv];
     cache.erase(bv);
@@ -1528,7 +1513,7 @@ void InsetText::resizeLyXText(BufferView * bv) const
 {
     if (!par->next && !par->size()) // resize not neccessary!
        return;
-    if (cache.find(bv) == cache.end())
+    if ((cache.find(bv) == cache.end()) || !cache[bv])
        return;
 
     LyXParagraph * lpar = 0;
index 9564e41c7f8d2321fc38890b2aa826887c41628d..6636883fe874dbe74f961a52a9406d19fb2fbba9 100644 (file)
@@ -3501,9 +3501,9 @@ Undo * LyXText::CreateUndo(Buffer * buf, Undo::undo_kind kind,
                        end = end->next;
        }
 
-       if (start && end
-           && start != end->next
-           && (before != behind || (!before && !behind))) {
+       if (start && end && (start != end->next) &&
+           ((before != behind) || (!before && !behind)))
+       {
                tmppar = start;
                tmppar2 = tmppar->Clone();
                tmppar2->id(tmppar->id());