]> git.lyx.org Git - features.git/commitdiff
Various fixes to Tabular, InsetTabular and InsetText. Fixed left border for
authorJürgen Vigna <jug@sad.it>
Mon, 28 May 2001 15:11:24 +0000 (15:11 +0000)
committerJürgen Vigna <jug@sad.it>
Mon, 28 May 2001 15:11:24 +0000 (15:11 +0000)
multicolumn cells, fixed repaint and recalc issues of insets, fixed scrolling
of large tabulars, ADDED settings of fonts on selections, more minor stuff
I cannot remember right now, more to follow.

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

18 files changed:
src/ChangeLog
src/bufferview_funcs.C
src/insets/ChangeLog
src/insets/inset.C
src/insets/insetcollapsable.C
src/insets/insetcollapsable.h
src/insets/insetert.C
src/insets/insetert.h
src/insets/insetminipage.C
src/insets/insettabular.C
src/insets/insettabular.h
src/insets/insettext.C
src/insets/insettext.h
src/insets/lyxinset.h
src/lyxtext.h
src/tabular.C
src/text.C
src/text2.C

index 15ed67f6506b78d1c8a32603b16309d25fd7093f..affd70d3d0a82813aca51ab3ea9c9d19bb703a17 100644 (file)
@@ -1,3 +1,26 @@
+2001-05-28  Juergen Vigna  <jug@sad.it>
+
+       * text.C (SetHeightOfRow): added the update() call again as it is
+       needed to initialize inset dimensions!
+
+2001-05-16  Juergen Vigna  <jug@sad.it>
+
+       * text2.C (SetCharFont): Add new function with BufferView * and
+       bool toggleall parameters for setting insets internal fonts.
+       (SetFont): Freeze the undo as we may change fonts in Insets and
+       all this change should be inside only one Undo!
+
+       * bufferview_funcs.C (ToggleAndShow): fixed this functions for
+       setting font's in insets as for them we have the SetFont function!
+
+2001-05-15  Juergen Vigna  <jug@sad.it>
+
+       * text2.C (ClearSelection): to be sure we REALLY don't have any
+       selection anymore!
+
+       * tabular.C (TeXCellPreamble): fixed the left border problem for
+       multicolumn cells.
+
 2001-05-27  Dekel Tsur  <dekelts@tau.ac.il>
 
        * LaTeX.C (deplog): Make sure that the main .tex file is in the
index 56ddcad68d9c967c3512e56038ae6b1992167de2..c028e0af285244ff86c873cbcbb9cb5696930ec0 100644 (file)
@@ -245,6 +245,10 @@ string const CurrentState(BufferView * bv)
 void ToggleAndShow(BufferView * bv, LyXFont const & font, bool toggleall)
 {
        if (bv->available()) { 
+               if (bv->theLockingInset()) {
+                       bv->theLockingInset()->SetFont(bv, font, toggleall);
+                       return;
+               }
                LyXText * text = bv->getLyXText();
 
                bv->hideCursor();
@@ -254,7 +258,8 @@ void ToggleAndShow(BufferView * bv, LyXFont const & font, bool toggleall)
 
                if (font.language() != ignore_language ||
                    font.latex() != LyXFont::IGNORE ||
-                   font.number() != LyXFont::IGNORE) {
+                   font.number() != LyXFont::IGNORE)
+               {
                        LyXCursor & cursor = text->cursor;
                        text->ComputeBidiTables(bv->buffer(), cursor.row());
                        if (cursor.boundary() != 
index 6157da3d994c7c2343c792d189dbad350b85f96c..760a641bad17a3c214772a8507594ebd6ad6170f 100644 (file)
@@ -1,3 +1,21 @@
+2001-05-28  Juergen Vigna  <jug@sad.it>
+
+       * insettext.C (resizeLyXText): clear LyXText ONLY if we don't have
+       a endless-width inset (maxWidth < 0).
+       (Edit): change language only if not equal.
+
+       * insettabular.C (resetPos): call UpdateLocal only on REAL scroll!
+
+       * insettext.C (draw): fixed draw/clear of InsetText-Frame
+
+2001-05-16  Juergen Vigna  <jug@sad.it>
+
+       * insettext.C (selectAll): added
+       (clearSelection): added
+
+       * insettabular.C (SetFont): now we may set a font on a whole selection!
+       (getSelection): added helper function.
+
 2001-05-27  Dekel Tsur  <dekelts@tau.ac.il>
 
        * insetcite.C (Ascii): Add method.
index bb97e2bc10fbf8ad98e0e13e6fbf0c155946dce6..73a9d57640faabc4f878cfc3f69fae8721f3cf23 100644 (file)
@@ -149,7 +149,7 @@ void UpdatableInset::draw(BufferView *, LyXFont const &,
 }
 
 
-void UpdatableInset::SetFont(BufferView *, LyXFont const &, bool )
+void UpdatableInset::SetFont(BufferView *, LyXFont const &, bool, bool )
 {}
 
 
index d1cd344fea309d4d5c99f0dc63a2b5290279f72b..50f123c7b813d6227bc626d6748e072f9ba5b32e 100644 (file)
@@ -442,10 +442,10 @@ UpdatableInset * InsetCollapsable::GetFirstLockingInsetOfType(Inset::Code c)
 }
 
 
-void InsetCollapsable::SetFont(BufferView * bv,
-                              LyXFont const & font, bool toggleall)
+void InsetCollapsable::SetFont(BufferView * bv, LyXFont const & font,
+                               bool toggleall, bool selectall)
 {
-       inset.SetFont(bv, font, toggleall);
+       inset.SetFont(bv, font, toggleall, selectall);
 }
 
 
index de94c0c9882d9535a57268102a0bf700409bce97..edd2e167e51a1307ae1824926ece1094a6a392f0 100644 (file)
@@ -109,7 +109,8 @@ public:
        ///
        UpdatableInset * GetFirstLockingInsetOfType(Inset::Code);
        ///
-       void SetFont(BufferView *, LyXFont const &, bool toggleall = false);
+       void SetFont(BufferView *, LyXFont const &, bool toggleall = false,
+                 bool selectall = false);
        ///
        void setLabel(string const & l) { label = l; }
        ///
index c83ad95e4eee2653cdd879d8819dc011443efe36..4f7558aea2ced1be4a707a3477d525516cf263ff 100644 (file)
@@ -60,11 +60,14 @@ string const InsetERT::EditMessage() const
 }
 
 
-void InsetERT::SetFont(BufferView *, LyXFont const &, bool)
+void InsetERT::SetFont(BufferView *, LyXFont const &, bool, bool selectall)
 {
-       WriteAlert(_("Impossible Operation!"),
-                  _("Not permitted to change font-types inside ERT-insets!"),
-                  _("Sorry."));
+       // if selectall is activated then the fontchange was an outside general
+       // fontchange and this messages is not needed
+       if (!selectall)
+               WriteAlert(_("Impossible Operation!"),
+                          _("Not permitted to change font-types inside ERT-insets!"),
+                          _("Sorry."));
 }
 
 
index d50f1e244f97879c38245f11278aaf31285aba8c..f57208d4c8906d3f06c58046f01f02630800581c 100644 (file)
@@ -38,7 +38,8 @@ public:
        ///
        bool InsertInset(BufferView *, Inset *) { return false; }
        ///
-       void SetFont(BufferView *, LyXFont const &, bool toggleall = false);
+       void SetFont(BufferView *, LyXFont const &, bool toggleall = false,
+                 bool selectall = false);
        ///
        void Edit(BufferView *, int, int, unsigned int);
 };
index d0d9ea13157a37d3a07c9a775f997dbb4960db1f..d781a3daf9cbf92f930030513e9b6d058deefe8d 100644 (file)
@@ -93,87 +93,84 @@ void InsetMinipage::Write(Buffer const * buf, ostream & os) const
 
 void InsetMinipage::Read(Buffer const * buf, LyXLex & lex)
 {
-    string token;
-
-    if (lex.IsOK()) {
-       lex.next();
-       token = lex.GetString();
-       if (token == "position") {
-           lex.next();
-           pos_ = static_cast<Position>(lex.GetInteger());
-           token = string();
-       } else {
-               lyxerr << "InsetMinipage::Read: Missing 'position'-tag!"
-                      << endl;
-       }
-    }
-    if (lex.IsOK()) {
-       if (token.empty()) {
-           lex.next();
-           token = lex.GetString();
-       }
-       if (token == "inner_position") {
-           lex.next();
-           inner_pos_ = static_cast<InnerPosition>(lex.GetInteger());
-           token = string();
-       } else {
-               lyxerr << "InsetMinipage::Read: Missing 'inner_position'-tag!"
-                      << endl;
-       }
-    }
-    if (lex.IsOK()) {
-       if (token.empty()) {
-           lex.next();
-           token = lex.GetString();
+       string token;
+
+       if (lex.IsOK()) {
+               lex.next();
+               token = lex.GetString();
+               if (token == "position") {
+                       lex.next();
+                       pos_ = static_cast<Position>(lex.GetInteger());
+                       token = string();
+               } else {
+                       lyxerr << "InsetMinipage::Read: Missing 'position'-tag!"
+                                  << endl;
+               }
        }
-       if (token == "height") {
-           lex.next();
-           height_ = lex.GetString();
-           token = string();
-       } else {
-               lyxerr << "InsetMinipage::Read: Missing 'height'-tag!"
-                      << endl;
+       if (lex.IsOK()) {
+               if (token.empty()) {
+                       lex.next();
+                       token = lex.GetString();
+               }
+               if (token == "inner_position") {
+                       lex.next();
+                       inner_pos_ = static_cast<InnerPosition>(lex.GetInteger());
+                       token = string();
+               } else {
+                       lyxerr << "InsetMinipage::Read: Missing 'inner_position'-tag!"
+                                  << endl;
+               }
        }
-    }
-    if (lex.IsOK()) {
-       if (token.empty()) {
-           lex.next();
-           token = lex.GetString();
+       if (lex.IsOK()) {
+               if (token.empty()) {
+                       lex.next();
+                       token = lex.GetString();
+               }
+               if (token == "height") {
+                       lex.next();
+                       height_ = lex.GetString();
+                       token = string();
+               } else {
+                       lyxerr << "InsetMinipage::Read: Missing 'height'-tag!"
+                                  << endl;
+               }
        }
-       if (token == "width") {
-           lex.next();
-           width_ = lex.GetString();
-           token = string();
-       } else {
-               lyxerr << "InsetMinipage::Read: Missing 'width'-tag!"
-                      << endl;
+       if (lex.IsOK()) {
+               if (token.empty()) {
+                       lex.next();
+                       token = lex.GetString();
+               }
+               if (token == "width") {
+                       lex.next();
+                       width_ = lex.GetString();
+                       token = string();
+               } else {
+                       lyxerr << "InsetMinipage::Read: Missing 'width'-tag!"
+                                  << endl;
+               }
        }
-    }
 #ifdef WITH_WARNINGS
 #warning Remove me before final 1.2.0 (Jug)
 #warning Can we please remove this as soon as possible? (Lgb)
 #endif
-    // this is only for compatibility to the intermediate format and should
-    // vanish till the final 1.2.0!
-    if (lex.IsOK()) {
-       if (token.empty()) {
-           lex.next();
-           token = lex.GetString();
-       }
-       if (token == "widthp") {
-           lex.next();
-           // only do this if the width_-string was not already set!
-           if (width_.empty())
-               width_ = lex.GetString() + "%";
-           token = string();
-       } else {
-               lyxerr << "InsetMinipage::Read: Missing 'widthp_'-tag!"
-                      << endl;
+       // this is only for compatibility to the intermediate format and should
+       // vanish till the final 1.2.0!
+       if (lex.IsOK()) {
+               if (token.empty()) {
+                       lex.next();
+                       token = lex.GetString();
+               }
+               if (token == "widthp") {
+                       lex.next();
+                       // only do this if the width_-string was not already set!
+                       if (width_.empty())
+                               width_ = lex.GetString() + "%";
+                       token = string();
+               }
        }
-    }
-    if (!token.empty())
-       lex.pushToken(token);
-    InsetCollapsable::Read(buf, lex);
+       if (!token.empty())
+               lex.pushToken(token);
+       InsetCollapsable::Read(buf, lex);
 }
 
 
@@ -330,28 +327,28 @@ void InsetMinipage::width(string const & ll)
 
 bool InsetMinipage::ShowInsetDialog(BufferView * bv) const
 {
-    if (!inset.ShowInsetDialog(bv))
+       if (!inset.ShowInsetDialog(bv))
        bv->owner()->getDialogs()->showMinipage(const_cast<InsetMinipage *>(this));
-    return true;
+       return true;
 }
 
 
 void InsetMinipage::InsetButtonRelease(BufferView * bv, int x, int y,
                                       int button)
 {
-    if (button == 3) {
+       if (button == 3) {
        ShowInsetDialog(bv);
        return;
-    }
-    InsetCollapsable::InsetButtonRelease(bv, x, y, button);
+       }
+       InsetCollapsable::InsetButtonRelease(bv, x, y, button);
 }
 
 
 int InsetMinipage::getMaxWidth(BufferView * bv, UpdatableInset const * inset)
-    const
+       const
 {
-    if (!width_.empty())
+       if (!width_.empty())
        return VSpace(width_).inPixels(bv);
-    // this should not happen!
-    return InsetCollapsable::getMaxWidth(bv, inset);
+       // this should not happen!
+       return InsetCollapsable::getMaxWidth(bv, inset);
 }
index 73aaf52f8bb123741b2ecd47552cf02f214c5447..f09f5694ae63ef643d8702a7ec9d9c5020be7325 100644 (file)
@@ -223,10 +223,13 @@ void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline,
 {
        if (nodraw())
                return;
-       if (bv->text->status == LyXText::CHANGED_IN_DRAW)
-               return;
-
-//     lyxerr << "InsetTabular::draw(" << need_update << ")\n";
+#if 0
+       if (need_update == INIT) {
+               if (calculate_dimensions_of_cells(bv, font, true))
+                       bv->text->status = LyXText::CHANGED_IN_DRAW;
+               need_update = FULL;
+       }
+#endif
 
        Painter & pain = bv->painter();
        int i;
@@ -346,8 +349,10 @@ void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline,
                float cx = dx;
                //cx = dx = nx + tabular->GetBeginningOfTextInCell(cell);
                tabular->GetCellInset(cell)->draw(bv,font,baseline, dx, false);
+#if 0
                if (bv->text->status == LyXText::CHANGED_IN_DRAW)
                        return;
+#endif
                // clear only if we didn't have a change
                if (need_update == CELL) {
                        // clear before the inset
@@ -371,10 +376,15 @@ void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline,
        }
        x -= ADD_TO_TABULAR_WIDTH;
        x += width(bv, font);
-       if (bv->text->status == LyXText::CHANGED_IN_DRAW)
-               need_update = INIT;
-       else
+       if (bv->text->status == LyXText::CHANGED_IN_DRAW) {
+               int i=0;
+               for(Inset * inset=owner();inset;++i)
+                       inset = inset->owner();
+               if (calculate_dimensions_of_cells(bv, font, false))
+                       need_update = INIT;
+       } else {
                need_update = NONE;
+       }
 }
 
 
@@ -772,6 +782,8 @@ InsetTabular::LocalDispatch(BufferView * bv,
        case LFUN_SHIFT_TAB:
        case LFUN_TAB:
        {
+               if (GetFirstLockingInsetOfType(Inset::TABULAR_CODE))
+                       break;
                HideInsetCursor(bv);
                if (the_locking_inset) {
                        UnlockInsetInInset(bv, the_locking_inset);
@@ -1276,16 +1288,17 @@ void InsetTabular::resetPos(BufferView * bv) const
        } else if (the_locking_inset &&
                 (tabular->GetWidthOfColumn(actcell) > bv->workWidth()-20)) {
                int xx = cursor.x() - offset + bv->text->GetRealCursorX(bv);
-               if (xx > (bv->workWidth()-20))
+               if (xx > (bv->workWidth()-20)) {
                        scroll(bv, -(xx - bv->workWidth() + 60));
-               else if (xx < 20) {
+                       UpdateLocal(bv, FULL, false);
+               } else if (xx < 20) {
                        if (xx < 0)
                                xx = -xx + 60;
                        else
                                xx = 60;
                        scroll(bv, xx);
+                       UpdateLocal(bv, FULL, false);
                }
-               UpdateLocal(bv, FULL, false);
        } else if ((cursor.x() - offset) > 20 &&
                   (cursor.x() - offset + tabular->GetWidthOfColumn(actcell))
                   > (bv->workWidth() - 20)) {
@@ -1447,8 +1460,36 @@ bool InsetTabular::Delete()
 }
 
 
-void InsetTabular::SetFont(BufferView * bv, LyXFont const & font, bool tall)
+void InsetTabular::SetFont(BufferView * bv, LyXFont const & font, bool tall,
+                           bool selectall)
 {
+       if (selectall) {
+               sel_cell_start = 0;
+               sel_cell_end = tabular->GetNumberOfCells() - 1;
+       }
+       if (hasSelection()) {
+               bool frozen;
+               bv->text->SetUndo(bv->buffer(), Undo::EDIT,
+                                 bv->text->cursor.par()->previous(),
+                                 bv->text->cursor.par()->next());
+               frozen = bv->text->undo_frozen;
+               if (!frozen)
+                       bv->text->FreezeUndo();
+               // apply the fontchange on the whole selection
+               int sel_row_start;
+               int sel_row_end;
+               int sel_col_start;
+               int sel_col_end;
+               getSelection(sel_row_start, sel_row_end, sel_col_start, sel_col_end);
+               for(int i=sel_row_start; i <= sel_row_end; ++i) {
+                       for(int j=sel_col_start; j <= sel_col_end; ++j) {
+                               tabular->GetCellInset(i, j)->SetFont(bv, font, tall, true);
+                       }
+               }
+               if (!frozen)
+                       bv->text->UnFreezeUndo();
+               UpdateLocal(bv, INIT, true);
+       }
        if (the_locking_inset)
                the_locking_inset->SetFont(bv, font, tall);
 }
@@ -1524,23 +1565,7 @@ void InsetTabular::TabularFeatures(BufferView * bv,
                break;
        }
        if (hasSelection()) {
-               sel_col_start = tabular->column_of_cell(sel_cell_start);
-               sel_col_end = tabular->column_of_cell(sel_cell_end);
-               if (sel_col_start > sel_col_end) {
-                       sel_col_end = sel_col_start;
-                       sel_col_start = tabular->column_of_cell(sel_cell_end);
-               } else {
-                       sel_col_end = tabular->right_column_of_cell(sel_cell_end);
-               }
-       
-               sel_row_start = tabular->row_of_cell(sel_cell_start);
-               sel_row_end = tabular->row_of_cell(sel_cell_end);
-               if (sel_row_start > sel_row_end) {
-                       //int tmp = sel_row_start;
-                       //sel_row_start = sel_row_end;
-                       //sel_row_end = tmp;
-                       swap(sel_row_start, sel_row_end);
-               }
+               getSelection(sel_row_start, sel_row_end, sel_col_start, sel_col_end);
        } else {
                sel_col_start = sel_col_end = tabular->column_of_cell(actcell);
                sel_row_start = sel_row_end = tabular->row_of_cell(actcell);
@@ -1952,14 +1977,7 @@ LyXFunc::func_status InsetTabular::getStatus(string const & what) const
        bool flag = true;
 
        if (hasSelection()) {
-               sel_row_start = tabular->row_of_cell(sel_cell_start);
-               sel_row_end = tabular->row_of_cell(sel_cell_end);
-               if (sel_row_start > sel_row_end) {
-                       //int tmp = sel_row_start;
-                       //sel_row_start = sel_row_end;
-                       //sel_row_end = tmp;
-                       swap(sel_row_start, sel_row_end);
-               }
+               getSelection(sel_row_start, sel_row_end, dummy, dummy);
        } else {
                sel_row_start = sel_row_end = tabular->row_of_cell(actcell);
        }
@@ -2309,6 +2327,22 @@ bool InsetTabular::doClearArea() const
 {
        return !locked || (need_update & (FULL|INIT));
 }
+
+void InsetTabular::getSelection(int & srow, int & erow, int & scol, int & ecol) const
+{
+               srow = tabular->row_of_cell(sel_cell_start);
+               erow = tabular->row_of_cell(sel_cell_end);
+               if (srow > erow)
+                       swap(srow, erow);
+
+               scol = tabular->column_of_cell(sel_cell_start);
+               ecol = tabular->column_of_cell(sel_cell_end);
+               if (scol > ecol)
+                       swap(scol, ecol);
+               else
+                       ecol = tabular->right_column_of_cell(sel_cell_end);
+}
+
 /* Emacs:
  * Local variables:
  * tab-width: 4
index ba72465347d888035e94748d4bc635afc9f47c52..b91165f04be9b15b52f31756f467b300b116591f 100644 (file)
@@ -160,7 +160,8 @@ public:
        ///
        int GetActCell() const { return actcell; }
        ///
-       void SetFont(BufferView *, LyXFont const &, bool toggleall = false);
+       void SetFont(BufferView *, LyXFont const &, bool toggleall = false,
+                    bool selectall = false);
        ///
        int getMaxWidth(BufferView *, UpdatableInset const *) const;
        ///
@@ -265,6 +266,8 @@ private:
        bool cutSelection();
        ///
        bool isRightToLeft(BufferView *);
+       ///
+       void getSelection(int & scol, int & ecol, int & srow, int & erow) const;
 
        //
        // Private structures and variables
index b72b19a4a3ca124aee328c651f08ba786d17a728..64b3b1b1d120102395c953f8daddf7efd6cc8aa1 100644 (file)
@@ -92,7 +92,7 @@ void InsetText::init(InsetText const * ins)
        insetDescent = 0;
        insetWidth = 0;
        the_locking_inset = 0;
-       interline_space = 1;
+       old_max_width = 0;
        no_selection = false;
        need_update = INIT;
        drawTextXOffset = 0;
@@ -259,6 +259,8 @@ void InsetText::draw(BufferView * bv, LyXFont const & f,
                x += width(bv, f);
                if (!cleared && (need_update & CLEAR_FRAME))
                        clearFrame(pain, cleared);
+               else if (cleared)
+                       frame_is_visible = false;
                need_update = NONE;
                return;
        }
@@ -270,10 +272,12 @@ void InsetText::draw(BufferView * bv, LyXFont const & f,
        if (!owner())
                x += static_cast<float>(scroll());
 #endif
+#if 0
        // update insetWidth and insetHeight with dummy calls
        (void)ascent(bv, f);
        (void)descent(bv, f);
        (void)width(bv, f);
+#endif
 
        // if top_x differs we have a rule down and we don't have to clear anything
        if (!cleared && (top_x == int(x)) &&
@@ -296,14 +300,25 @@ void InsetText::draw(BufferView * bv, LyXFont const & f,
                cleared = true;
                need_update = FULL;
        }
+       if (cleared)
+               frame_is_visible = false;
+
        if (!cleared && (need_update == NONE))
                return;
 
        if (top_x != int(x)) {
-               need_update |= INIT;
+               if ((getMaxWidth(bv, this) > 0) && (TEXT(bv)->width != old_max_width)){
+                       resizeLyXText(bv);
+                       need_update |= FULL;
+                       old_max_width = TEXT(bv)->width;
+                       bv->text->status = LyXText::CHANGED_IN_DRAW;
+               }
                top_x = int(x);
-               bv->text->status = LyXText::CHANGED_IN_DRAW;
+#if 1
+               cleared = true;
+#else
                return;
+#endif
        }
 
 //     lyxerr << "InsetText::draw[" << this << "](" << need_update << ":" << int(x) << ":" << top_x << ")\n";
@@ -355,10 +370,10 @@ void InsetText::draw(BufferView * bv, LyXFont const & f,
                y = 0;
                while ((row != 0) && (yf < ph)) {
                        TEXT(bv)->GetVisibleRow(bv, y+y_offset, int(x), row,
-                                               y+first, cleared);
-               y += row->height();
-               yf += row->height();
-               row = row->next();
+                                               y+first, cleared);
+                       y += row->height();
+                       yf += row->height();
+                       row = row->next();
                }
        } else if (!locked) {
                if (need_update & CURSOR) {
@@ -525,8 +540,10 @@ void InsetText::Edit(BufferView * bv, int x, int y, unsigned int button)
        UpdateLocal(bv, CURSOR, false);
 
        // If the inset is empty set the language of the current font to the
-       // language to the surronding text.
-       if (par->size() == 0 && !par->next()) {
+       // language to the surronding text (if different).
+       if (par->size() == 0 && !par->next() &&
+               bv->getParentLanguage(this) != TEXT(bv)->current_font.language())
+       {
                LyXFont font(LyXFont::ALL_IGNORE);
                font.setLanguage(bv->getParentLanguage(this));
                SetFont(bv, font, false);
@@ -543,12 +560,16 @@ void InsetText::InsetUnlock(BufferView * bv)
        HideInsetCursor(bv);
        no_selection = false;
        locked = false;
-       UpdateLocal(bv, CLEAR_FRAME|CURSOR, false);
-       if (owner())
+       int code = CURSOR|CLEAR_FRAME;
+       if (TEXT(bv)->selection) {
+               TEXT(bv)->ClearSelection(bv);
+               code = FULL;
+       } else if (owner())
                bv->owner()->setLayout(owner()->getLyXText(bv)
-                                      ->cursor.par()->GetLayout());
+                                      ->cursor.par()->GetLayout());
        else
                bv->owner()->setLayout(bv->text->cursor.par()->GetLayout());
+       UpdateLocal(bv, code, false);
 }
 
 
@@ -1370,16 +1391,24 @@ std::vector<string> const InsetText::getLabelList() const
 }
 
 
-void InsetText::SetFont(BufferView * bv, LyXFont const & font, bool toggleall)
+void InsetText::SetFont(BufferView * bv, LyXFont const & font, bool toggleall,
+                        bool selectall)
 {
        if (TEXT(bv)->selection) {
                bv->text->SetUndo(bv->buffer(), Undo::EDIT,
                                  bv->text->cursor.par()->previous(),
                                  bv->text->cursor.par()->next());
        }
+       if (selectall)
+               selectAll(bv);
        TEXT(bv)->SetFont(bv, font, toggleall);
+       if (selectall)
+               TEXT(bv)->ClearSelection(bv);
        bv->fitCursor(TEXT(bv));
-       UpdateLocal(bv, CURSOR_PAR, true);
+       if (selectall || TEXT(bv)->selection)
+               UpdateLocal(bv, FULL, true);
+       else
+               UpdateLocal(bv, CURSOR_PAR, true);
 }
 
 
@@ -1612,7 +1641,9 @@ void InsetText::deleteLyXText(BufferView * bv, bool recursive) const
 
 void InsetText::resizeLyXText(BufferView * bv) const
 {
-       if (!par->next() && !par->size()) // resize not neccessary!
+       if (!par->next() && !par->size()) // no data, resize not neccessary!
+               return;
+       if (getMaxWidth(bv, this) < 0) // one endless line, no resize necessary
                return;
        if ((cache.find(bv) == cache.end()) || !cache[bv])
                return;
@@ -1716,6 +1747,20 @@ bool InsetText::doClearArea() const
 {
        return !locked || (need_update & (FULL|INIT));
 }
+
+void InsetText::selectAll(BufferView * bv)
+{
+       TEXT(bv)->CursorTop(bv);
+       TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
+       TEXT(bv)->CursorBottom(bv);
+       TEXT(bv)->SetSelection(bv);
+}
+
+void InsetText::clearSelection(BufferView * bv)
+{
+       TEXT(bv)->ClearSelection(bv);
+}
+
 /* Emacs:
  * Local variables:
  * tab-width: 4
index 4d2c08985d4c060b58a36f2d92e085ca47be1443..615078abec0934359510e4c14ec11dd3c80d76ed 100644 (file)
@@ -152,7 +152,8 @@ public:
        ///
        UpdatableInset * GetFirstLockingInsetOfType(Inset::Code);
        ///
-       void SetFont(BufferView *, LyXFont const &, bool toggleall = false);
+       void SetFont(BufferView *, LyXFont const &, bool toggleall = false,
+                    bool selectall = false);
        ///
        int getMaxWidth(BufferView *, UpdatableInset const *) const;
        ///
@@ -189,6 +190,10 @@ public:
        void scroll(BufferView *bv, int offset) const {
                UpdatableInset::scroll(bv, offset);
        }
+       ///
+       void selectAll(BufferView *bv);
+       ///
+       void clearSelection(BufferView *bv);
 
        LyXParagraph * par;
        ///
@@ -297,7 +302,7 @@ private:
        ///
        mutable int inset_y;
        ///
-       int interline_space;
+       mutable int old_max_width;
        ///
        bool no_selection;
        ///
index 5d14cd0ae3ac00a5fa595c19a901b64d6bd18089..3e22948e8188b0cb0b111d3b84586cc84b0f724e 100644 (file)
@@ -336,7 +336,7 @@ public:
                          int baseline, float & x, bool cleared) const;
        ///
        virtual void SetFont(BufferView *, LyXFont const &,
-                            bool toggleall = false);
+                         bool toggleall = false, bool selectall = false);
        ///
        virtual bool InsertInset(BufferView *, Inset *) { return false; }
        ///
index d651cf154cf755184420733145540884b82908fe..33c0d196dea13cb0df1fe0a9c2c9c533c5d2fa37 100644 (file)
@@ -82,8 +82,10 @@ public:
                        LyXParagraph::size_type pos) const;
        ///
        void SetCharFont(Buffer const *, LyXParagraph * par,
-                        LyXParagraph::size_type pos,
-                        LyXFont const & font);
+                        LyXParagraph::size_type pos, LyXFont const & font);
+       void SetCharFont(BufferView *, LyXParagraph * par,
+                        LyXParagraph::size_type pos,
+                        LyXFont const & font, bool toggleall);
        /// returns a pointer to the very first LyXParagraph
        LyXParagraph * FirstParagraph() const;
   
@@ -218,7 +220,7 @@ public:
        ///
        mutable LyXCursor sel_cursor;
        ///
-       LyXCursor sel_start_cursor;
+       mutable LyXCursor sel_start_cursor;
        ///
        mutable LyXCursor sel_end_cursor;
        /// needed for the toggling
index ce8d196ee99fd69dadf8f46032d4f1f77a8bb07f..668e79b5a28af3432d1b8a3a478c280653236ffa 100644 (file)
@@ -1967,8 +1967,13 @@ int LyXTabular::TeXCellPreamble(ostream & os, int cell) const
                if (!cellinfo_of_cell(cell)->align_special.empty()) {
                        os << cellinfo_of_cell(cell)->align_special << "}{";
                } else {
-                       if (LeftLine(cell))
+                       if (LeftLine(cell) &&
+                               (IsFirstCellInRow(cell) || 
+                                (!IsMultiColumn(cell-1) && !LeftLine(cell, true) &&
+                                 !RightLine(cell-1, true))))
+                       {
                                os << '|';
+                       }
                        if (!GetPWidth(cell).empty()) {
                                switch (GetVAlignment(cell)) {
                                case LYX_VALIGN_TOP:
@@ -2517,7 +2522,7 @@ InsetText * LyXTabular::GetCellInset(int cell) const
 
 InsetText * LyXTabular::GetCellInset(int row, int column) const
 {
-       return GetCellInset(GetCellNumber(row, column));
+       return & cell_info[row][column].inset;
 }
 
 
index 075df005f7d354e404cb6afaa318ce4b13b0f69f..435d784ad11600aeffdbc717975aeeef5bdccbc3 100644 (file)
@@ -157,7 +157,9 @@ int LyXText::SingleWidth(BufferView * bview, LyXParagraph * par,
        } else if (c == LyXParagraph::META_INSET) {
                Inset * tmpinset = par->GetInset(pos);
                if (tmpinset) {
+#if 0 // seems not to be needed, but ...
                        tmpinset->update(bview, font);
+#endif
                        return tmpinset->width(bview, font);
                } else
                        return 0;
@@ -428,9 +430,9 @@ 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, false);
+                       tmpinset->update(bview, font, false);
                        tmpinset->draw(bview, font, offset+row->baseline(), x,
-                                      cleared);
+                                      cleared);
 #ifdef SEEMS_TO_BE_NOT_NEEDED
                        if (status == CHANGED_IN_DRAW) {
                                UpdateInset(bview, tmpinset);
@@ -1217,7 +1219,9 @@ void LyXText::SetHeightOfRow(BufferView * bview, Row * row_ptr) const
                   tmpfont = GetFont(bview->buffer(), row_ptr->par(), pos);
                   tmpinset = row_ptr->par()->GetInset(pos);
                   if (tmpinset) {
-//                        tmpinset->update(bview, tmpfont);
+#if 1 // this is needed for deep update on initialitation
+                          tmpinset->update(bview, tmpfont);
+#endif
                           asc = tmpinset->ascent(bview, tmpfont);
                           desc = tmpinset->descent(bview, tmpfont);
                           maxwidth += tmpinset->width(bview, tmpfont);
@@ -2784,7 +2788,7 @@ void LyXText::Backspace(BufferView * bview)
 
 
 void LyXText::GetVisibleRow(BufferView * bview, int y_offset, int x_offset,
-                           Row * row_ptr, int y, bool cleared)
+                            Row * row_ptr, int y, bool cleared)
 {
        // returns a printed row
        Painter & pain = bview->painter();
index 08df463fd1ae5c1541bd1e439ed4bd570efb9049..84157b6d92294af72ed2cb52840d186dd1ddea98 100644 (file)
@@ -138,6 +138,7 @@ void LyXText::init(BufferView * bview)
        SetCursorIntern(bview, firstrow->par(), 0);
        sel_cursor = cursor;
 #if 0
+       printf("TP = %x\n",inset_owner->owner());
        // Dump all rowinformation:
        Row * tmprow = firstrow;
        lyxerr << "Width = " << width << endl;
@@ -247,15 +248,64 @@ LyXFont const LyXText::GetFont(Buffer const * buf, LyXParagraph * par,
 }
 
 
+void LyXText::SetCharFont(BufferView * bv, LyXParagraph * par,
+                          LyXParagraph::size_type pos, LyXFont const & fnt,
+                          bool toggleall)
+{
+       Buffer const * buf = bv->buffer();
+       LyXFont font = GetFont(buf, par, pos);
+       font.update(fnt, buf->params.language, toggleall);
+       // Let the insets convert their font
+       if (par->GetChar(pos) == LyXParagraph::META_INSET) {
+               Inset * inset = par->GetInset(pos);
+               if (inset) {
+                       if (inset->Editable()==Inset::HIGHLY_EDITABLE) {
+                               UpdatableInset * uinset = static_cast<UpdatableInset *>(inset);
+                               uinset->SetFont(bv, fnt, toggleall, true);
+                       }
+                       font = inset->ConvertFont(font);
+               }
+       }
+
+       LyXLayout const & layout =
+               textclasslist.Style(buf->params.textclass,
+                                   par->GetLayout());
+
+       // Get concrete layout font to reduce against
+       LyXFont layoutfont;
+
+       if (pos < BeginningOfMainBody(buf, par))
+               layoutfont = layout.labelfont;
+       else
+               layoutfont = layout.font;
+
+       // Realize against environment font information
+       if (par->GetDepth()){
+               LyXParagraph * tp = par;
+               while (!layoutfont.resolved() && tp && tp->GetDepth()) {
+                       tp = tp->DepthHook(tp->GetDepth()-1);
+                       if (tp)
+                               layoutfont.realize(textclasslist.
+                                               Style(buf->params.textclass,
+                                                     tp->GetLayout()).font);
+               }
+       }
+
+       layoutfont.realize(textclasslist.TextClass(buf->params.textclass).defaultfont());
+
+       // Now, reduce font against full layout font
+       font.reduce(layoutfont);
+
+       par->SetFont(pos, font);
+}
+
 void LyXText::SetCharFont(Buffer const * buf, LyXParagraph * par,
-                         LyXParagraph::size_type pos,
-                         LyXFont const & fnt)
+                          LyXParagraph::size_type pos, LyXFont const & fnt)
 {
        LyXFont font(fnt);
        // Let the insets convert their font
        if (par->GetChar(pos) == LyXParagraph::META_INSET) {
-               if (par->GetInset(pos))
-                       font = par->GetInset(pos)->ConvertFont(font);
+               font = par->GetInset(pos)->ConvertFont(font);
        }
 
        LyXLayout const & layout =
@@ -676,25 +726,21 @@ void LyXText::SetFont(BufferView * bview, LyXFont const & font, bool toggleall)
        SetUndo(bview->buffer(), Undo::EDIT,
                sel_start_cursor.par()->previous(),
                sel_end_cursor.par()->next()); 
+       FreezeUndo();
        cursor = sel_start_cursor;
        while (cursor.par() != sel_end_cursor.par() ||
               (cursor.pos() < sel_end_cursor.pos())) {
                if (cursor.pos() < cursor.par()->size()) {
                        // an open footnote should behave
                        // like a closed one
-                       LyXFont newfont = GetFont(bview->buffer(), 
-                                                 cursor.par(), cursor.pos());
-                       newfont.update(font,
-                                      bview->buffer()->params.language,
-                                      toggleall);
-                       SetCharFont(bview->buffer(),
-                                   cursor.par(), cursor.pos(), newfont);
+                       SetCharFont(bview, cursor.par(), cursor.pos(), font, toggleall);
                        cursor.pos(cursor.pos() + 1);
                } else {
                        cursor.pos(0);
                        cursor.par(cursor.par()->next());
                }
        }
+       UnFreezeUndo();
    
        RedoParagraphs(bview, sel_start_cursor, sel_end_cursor.par()->next());
    
@@ -971,6 +1017,7 @@ void LyXText::ClearSelection(BufferView * /*bview*/) const
 {
        selection = false;
        mark_set = false;
+       sel_end_cursor = sel_start_cursor = cursor;
 }
 
 
@@ -1012,7 +1059,7 @@ void LyXText::CursorBottom(BufferView * bview) const
    
    
 void LyXText::ToggleFree(BufferView * bview,
-                        LyXFont const & font, bool toggleall)
+                         LyXFont const & font, bool toggleall)
 {
        // If the mask is completely neutral, tell user
        if (font == LyXFont(LyXFont::ALL_IGNORE)) {