]> git.lyx.org Git - lyx.git/commitdiff
Fixed inset-redraw problems on resizing lyx-window, and some other small
authorJürgen Vigna <jug@sad.it>
Fri, 14 Jul 2000 14:57:20 +0000 (14:57 +0000)
committerJürgen Vigna <jug@sad.it>
Fri, 14 Jul 2000 14:57:20 +0000 (14:57 +0000)
fixes in inset-text and inset-tabular (layout update).

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

19 files changed:
ChangeLog
po/POTFILES.in
src/BufferView_pimpl.C
src/buffer.C
src/buffer.h
src/frontends/xforms/FormTabular.C
src/frontends/xforms/FormTabular.h
src/frontends/xforms/form_tabular.C
src/frontends/xforms/form_tabular.h
src/frontends/xforms/forms/form_tabular.fd
src/insets/insetcollapsable.C
src/insets/insetcollapsable.h
src/insets/insettabular.C
src/insets/insettabular.h
src/insets/insettext.C
src/insets/insettext.h
src/insets/lyxinset.h
src/lyxparagraph.h
src/paragraph.C

index 3d3d730fdd6dd1b5f5df10e0ec7568021ec84b4d..d0d93f6d5072004c6a8eeec043a754bcf659d635 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
 2000-07-14  Juergen Vigna  <jug@sad.it>
 
+       * src/insets/insettext.C (clear): fixed for multiple paragraps/layouts.
+
+       * src/frontends/xforms/forms/form_tabular.fd: updated a bit.
+
+       * src/insets/insettabular.C (resizeLyXText): need this to be able to
+       do a redraw when the window is resized!
+       (LocalDispatch): small fix so LFUN_TAB works only with locked_inset.
+
+       * src/insets/insettext.C (resizeLyXText): added function to correctly
+       being able to resize the LyXWindow.
+
        * src/table.C (Read): fixed read on DOS-lyx-file (lf-lr)
 
 2000-07-13  Angus Leeming  <a.leeming@ic.ac.uk>
index 0961c34f8edf6d75b3fbb71c3d915dc128dd6e5a..fabdfa0ebe0cade35f6a63dc20eec591c5b94e11 100644 (file)
@@ -33,11 +33,6 @@ src/frontends/xforms/FormPreferences.C
 src/frontends/xforms/form_preferences.C
 src/frontends/xforms/FormPrint.C
 src/frontends/xforms/form_print.C
-src/frontends/xforms/forms/form_citation.C
-src/frontends/xforms/forms/form_copyright.C
-src/frontends/xforms/forms/form_preferences.C
-src/frontends/xforms/forms/form_print.C
-src/frontends/xforms/forms/form_tabular.C
 src/frontends/xforms/FormTabular.C
 src/frontends/xforms/form_tabular.C
 src/gettext.h
index aad1957478cf1178f350ee8aa44bbe621536c278..f50a1206efe6188e8b012fd87270219455fafe70 100644 (file)
@@ -270,10 +270,8 @@ int BufferView::Pimpl::resizeCurrentBuffer()
                }
        }
        bv_->text->first = screen_->TopCursorVisible(bv_->text);
-       /* this will scroll the
-        * screen such that the
-        * cursor becomes
-        * visible */ 
+       buffer_->resizeInsets(bv_);
+       // this will scroll the screen such that the cursor becomes visible
        updateScrollbar();
        redraw();
        owner_->getMiniBuffer()->Init();
index 3ff1ddadc6141826a229ed26778484d0fb0ac6d7..2dd798f084f4e1e325c01579bef443a2e93c5116 100644 (file)
@@ -3732,18 +3732,21 @@ bool Buffer::Dispatch(int action, string const & argument)
 
 void Buffer::resize()
 {
-       /// first resize the BufferViews!
-       if (users) {
+       /// resize the BufferViews!
+       if (users)
                users->resize();
-       }
+}
+
+
+void Buffer::resizeInsets(BufferView * bv)
+{
        /// then remove all LyXText in text-insets
        LyXParagraph * par = paragraph;
        for(;par;par = par->next) {
-               par->deleteInsetsLyXText(users);
+           par->resizeInsetsLyXText(bv);
        }
 }
 
-
 void Buffer::ChangeLanguage(Language const * from, Language const * to)
 {
 
index 9f968892a87cc27aa5f44ec52e2b7ec8e3e33a11..d970148f772071c737b59b9491695551c6575d22 100644 (file)
@@ -89,6 +89,7 @@ public:
 
        /// should be changed to work for a list.
        void resize();
+       void resizeInsets(BufferView *);
 
        /// Update window titles of all users
        void updateTitles() const;
index eaf2bb7cc8133a01e0e2558ff58a0fd5ecde5837..bbe35664ee180d9dcf5e5f57672083171e48d38e 100644 (file)
@@ -8,6 +8,7 @@
 #include FORMS_H_LOCATION
 
 #include "FormTabular.h"
+#include "form_tabular.h"
 #include "xform_macros.h"
 #include "input_validators.h"
 #include "LyXView.h"
index c2f69e66ed8ca28942541e167be9ca3586b364b0..b8fb925dca76fc88b749e47961df22aacfbc8e91 100644 (file)
@@ -18,7 +18,6 @@
 #define FORMTABULAR_H
 
 #include "DialogBase.h"
-#include "form_tabular.h"
 #ifdef SIGC_CXX_NAMESPACES
 using SigC::Connection;
 #endif
@@ -26,6 +25,12 @@ using SigC::Connection;
 class LyXView;
 class Dialogs;
 class InsetTabular;
+struct FD_form_tabular;
+struct FD_form_tabular_options;
+struct FD_form_column_options;
+struct FD_form_cell_options;
+struct FD_form_longtable_options;
+struct FD_form_create_tabular;
 
 /** This class provides an XForms implementation of the FormTabular Dialog.
     The tabular dialog allows users to set/save their tabular.
index 78d425b2e714ed45c6e3b7ab161826b22e1dfabd..49e1001e127465436b9756bde56dfdc62b4494a8 100644 (file)
@@ -15,21 +15,21 @@ FD_form_tabular * FormTabular::build_tabular()
   FL_OBJECT *obj;
   FD_form_tabular *fdui = new FD_form_tabular;
 
-  fdui->form_tabular = fl_bgn_form(FL_NO_BOX, 510, 340);
+  fdui->form_tabular = fl_bgn_form(FL_NO_BOX, 510, 285);
   fdui->form_tabular->u_vdata = this;
-  obj = fl_add_box(FL_FLAT_BOX, 0, 0, 510, 340, "");
-  fdui->tabFolder = obj = fl_add_tabfolder(FL_TOP_TABFOLDER, 10, 10, 485, 240, _("Tabbed folder"));
+  obj = fl_add_box(FL_FLAT_BOX, 0, 0, 510, 285, "");
+  fdui->tabFolder = obj = fl_add_tabfolder(FL_TOP_TABFOLDER, 0, 0, 505, 245, _("Tabbed folder"));
     fl_set_object_resize(obj, FL_RESIZE_ALL);
-  fdui->button_close = obj = fl_add_button(FL_NORMAL_BUTTON, 395, 300, 100, 30, idex(_("Close|#C")));fl_set_button_shortcut(obj, scex(_("Close|#C")), 1);
+  fdui->button_close = obj = fl_add_button(FL_NORMAL_BUTTON, 415, 250, 90, 30, idex(_("Close|#C")));fl_set_button_shortcut(obj, scex(_("Close|#C")), 1);
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
     fl_set_object_callback(obj, C_FormTabularCloseCB, 0);
-  fdui->input_tabular_column = obj = fl_add_input(FL_NORMAL_INPUT, 15, 300, 60, 30, _("Column"));
+  fdui->input_tabular_column = obj = fl_add_input(FL_NORMAL_INPUT, 5, 250, 60, 30, "");
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
     fl_set_object_lalign(obj, FL_ALIGN_TOP_LEFT);
-  fdui->input_tabular_row = obj = fl_add_input(FL_NORMAL_INPUT, 85, 300, 60, 30, _("Row"));
+  fdui->input_tabular_row = obj = fl_add_input(FL_NORMAL_INPUT, 65, 250, 60, 30, "");
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
     fl_set_object_lalign(obj, FL_ALIGN_TOP_LEFT);
-  fdui->text_warning = obj = fl_add_text(FL_NORMAL_TEXT, 10, 250, 485, 30, "");
+  fdui->text_warning = obj = fl_add_text(FL_NORMAL_TEXT, 125, 250, 290, 30, "");
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
     fl_set_object_lalign(obj, FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
     fl_set_object_lstyle(obj, FL_BOLD_STYLE);
@@ -46,9 +46,9 @@ FD_form_tabular_options * FormTabular::build_tabular_options()
   FL_OBJECT *obj;
   FD_form_tabular_options *fdui = new FD_form_tabular_options;
 
-  fdui->form_tabular_options = fl_bgn_form(FL_NO_BOX, 485, 220);
+  fdui->form_tabular_options = fl_bgn_form(FL_NO_BOX, 505, 227);
   fdui->form_tabular_options->u_vdata = this;
-  obj = fl_add_box(FL_UP_BOX, 0, 0, 485, 220, "");
+  obj = fl_add_box(FL_UP_BOX, 0, 0, 505, 227, "");
   obj = fl_add_frame(FL_ENGRAVED_FRAME, 280, 20, 120, 75, "");
     fl_set_object_color(obj, FL_COL1, FL_COL1);
   fdui->button_append_column = obj = fl_add_button(FL_NORMAL_BUTTON, 10, 40, 120, 30, idex(_("Append Column|#A")));fl_set_button_shortcut(obj, scex(_("Append Column|#A")), 1);
@@ -90,9 +90,9 @@ FD_form_column_options * FormTabular::build_column_options()
   FL_OBJECT *obj;
   FD_form_column_options *fdui = new FD_form_column_options;
 
-  fdui->form_column_options = fl_bgn_form(FL_NO_BOX, 485, 220);
+  fdui->form_column_options = fl_bgn_form(FL_NO_BOX, 505, 227);
   fdui->form_column_options->u_vdata = this;
-  obj = fl_add_box(FL_UP_BOX, 0, 0, 485, 220, "");
+  obj = fl_add_box(FL_UP_BOX, 0, 0, 505, 227, "");
   obj = fl_add_frame(FL_ENGRAVED_FRAME, 20, 20, 170, 105, "");
     fl_set_object_color(obj, FL_COL1, FL_COL1);
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
@@ -172,9 +172,9 @@ FD_form_cell_options * FormTabular::build_cell_options()
   FL_OBJECT *obj;
   FD_form_cell_options *fdui = new FD_form_cell_options;
 
-  fdui->form_cell_options = fl_bgn_form(FL_NO_BOX, 485, 220);
+  fdui->form_cell_options = fl_bgn_form(FL_NO_BOX, 505, 227);
   fdui->form_cell_options->u_vdata = this;
-  obj = fl_add_box(FL_UP_BOX, 0, 0, 485, 220, "");
+  obj = fl_add_box(FL_UP_BOX, 0, 0, 505, 227, "");
   obj = fl_add_frame(FL_ENGRAVED_FRAME, 10, 110, 180, 100, "");
     fl_set_object_color(obj, FL_COL1, FL_COL1);
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
@@ -265,9 +265,9 @@ FD_form_longtable_options * FormTabular::build_longtable_options()
   FL_OBJECT *obj;
   FD_form_longtable_options *fdui = new FD_form_longtable_options;
 
-  fdui->form_longtable_options = fl_bgn_form(FL_NO_BOX, 485, 220);
+  fdui->form_longtable_options = fl_bgn_form(FL_NO_BOX, 505, 227);
   fdui->form_longtable_options->u_vdata = this;
-  obj = fl_add_box(FL_UP_BOX, 0, 0, 485, 220, "");
+  obj = fl_add_box(FL_UP_BOX, 0, 0, 505, 227, "");
   obj = fl_add_frame(FL_ENGRAVED_FRAME, 10, 20, 100, 75, "");
   obj = fl_add_text(FL_NORMAL_TEXT, 15, 10, 85, 20, _("Header"));
     fl_set_object_lsize(obj, FL_NORMAL_SIZE);
index d675a3d1fdc6b4ff613566bf75ee97729d54bb59..e4f449e9e5039cc2ea5cf18f1f556e80d36d1952 100644 (file)
@@ -1,4 +1,4 @@
-/** Header file generated with fdesign on Fri Jul 14 09:35:06 2000.**/
+/** Header file generated with fdesign on Fri Jul 14 15:53:33 2000.**/
 
 #ifndef FD_form_tabular_h_
 #define FD_form_tabular_h_
index 2c8268c1c329dabbc9e0028d402eb0b2e9f87d95..50d7b0352a7050df9186f5db1b3d41b88ed97e96 100644 (file)
@@ -10,13 +10,13 @@ SnapGrid: 5
 =============== FORM ===============
 Name: form_tabular
 Width: 510
-Height: 340
+Height: 285
 Number of Objects: 6
 
 --------------------
 class: FL_BOX
 type: FLAT_BOX
-box: 0 0 510 340
+box: 0 0 510 285
 boxtype: FL_FLAT_BOX
 colors: FL_COL1 FL_COL1
 alignment: FL_ALIGN_CENTER
@@ -34,7 +34,7 @@ argument:
 --------------------
 class: FL_TABFOLDER
 type: TOP_TABFOLDER
-box: 10 10 485 240
+box: 0 0 505 245
 boxtype: FL_UP_BOX
 colors: FL_COL1 FL_COL1
 alignment: FL_ALIGN_TOP_LEFT
@@ -52,7 +52,7 @@ argument:
 --------------------
 class: FL_BUTTON
 type: NORMAL_BUTTON
-box: 395 300 100 30
+box: 415 250 90 30
 boxtype: FL_UP_BOX
 colors: FL_COL1 FL_COL1
 alignment: FL_ALIGN_CENTER
@@ -70,14 +70,14 @@ argument: 0
 --------------------
 class: FL_INPUT
 type: NORMAL_INPUT
-box: 15 300 60 30
+box: 64 250 60 30
 boxtype: FL_DOWN_BOX
 colors: FL_COL1 FL_MCOL
 alignment: FL_ALIGN_TOP_LEFT
 style: FL_NORMAL_STYLE
 size: FL_NORMAL_SIZE
 lcol: FL_BLACK
-label: Column
+label: 
 shortcut: 
 resize: FL_RESIZE_ALL
 gravity: FL_NoGravity FL_NoGravity
@@ -88,14 +88,14 @@ argument:
 --------------------
 class: FL_INPUT
 type: NORMAL_INPUT
-box: 85 300 60 30
+box: 5 250 60 30
 boxtype: FL_DOWN_BOX
 colors: FL_COL1 FL_MCOL
 alignment: FL_ALIGN_TOP_LEFT
 style: FL_NORMAL_STYLE
 size: FL_NORMAL_SIZE
 lcol: FL_BLACK
-label: Row
+label: 
 shortcut: 
 resize: FL_RESIZE_ALL
 gravity: FL_NoGravity FL_NoGravity
@@ -106,7 +106,7 @@ argument:
 --------------------
 class: FL_TEXT
 type: NORMAL_TEXT
-box: 10 250 485 30
+box: 125 250 290 30
 boxtype: FL_FLAT_BOX
 colors: FL_COL1 FL_MCOL
 alignment: FL_ALIGN_LEFT|FL_ALIGN_INSIDE
@@ -123,14 +123,14 @@ argument:
 
 =============== FORM ===============
 Name: form_tabular_options
-Width: 485
-Height: 220
+Width: 505
+Height: 227
 Number of Objects: 11
 
 --------------------
 class: FL_BOX
 type: UP_BOX
-box: 0 0 485 220
+box: 0 0 505 227
 boxtype: FL_UP_BOX
 colors: FL_COL1 FL_COL1
 alignment: FL_ALIGN_CENTER
@@ -327,14 +327,14 @@ argument:
 
 =============== FORM ===============
 Name: form_column_options
-Width: 485
-Height: 220
+Width: 505
+Height: 227
 Number of Objects: 21
 
 --------------------
 class: FL_BOX
 type: UP_BOX
-box: 0 0 485 220
+box: 0 0 505 227
 boxtype: FL_UP_BOX
 colors: FL_COL1 FL_COL1
 alignment: FL_ALIGN_CENTER
@@ -711,14 +711,14 @@ argument:
 
 =============== FORM ===============
 Name: form_cell_options
-Width: 485
-Height: 220
+Width: 505
+Height: 227
 Number of Objects: 26
 
 --------------------
 class: FL_BOX
 type: UP_BOX
-box: 0 0 485 220
+box: 0 0 505 227
 boxtype: FL_UP_BOX
 colors: FL_COL1 FL_COL1
 alignment: FL_ALIGN_CENTER
@@ -1185,14 +1185,14 @@ argument: 0
 
 =============== FORM ===============
 Name: form_longtable_options
-Width: 485
-Height: 220
+Width: 505
+Height: 227
 Number of Objects: 12
 
 --------------------
 class: FL_BOX
 type: UP_BOX
-box: 0 0 485 220
+box: 0 0 505 227
 boxtype: FL_UP_BOX
 colors: FL_COL1 FL_COL1
 alignment: FL_ALIGN_CENTER
index 8240f90894504683cca993ae4b37b12499589240..4c8207c4cec6a1923d928921cf79b165de2dc9e5 100644 (file)
@@ -321,7 +321,7 @@ void InsetCollapsable::update(BufferView * bv, LyXFont const & font,
     }
     if (!widthCollapsed) {
        widthCollapsed = width_collapsed(bv->painter(), font);
-       inset->deleteLyXText(bv);
+       inset->resizeLyXText(bv);
        need_update = FULL;
        if (owner()) {
                owner()->update(bv, font);
@@ -330,7 +330,7 @@ void InsetCollapsable::update(BufferView * bv, LyXFont const & font,
     }
     if (oldWidth != width(bv, font)) {
        oldWidth = width(bv, font);
-       inset->deleteLyXText(bv);
+       inset->resizeLyXText(bv);
        need_update = FULL;
        if (owner()) {
                owner()->update(bv, font);
@@ -435,7 +435,15 @@ LyXText * InsetCollapsable::getLyXText(BufferView * bv) const
 }
 
 
-void InsetCollapsable::deleteLyXText(BufferView * bv) const
+void InsetCollapsable::deleteLyXText(BufferView * bv, bool recursive) const
 {
-    inset->deleteLyXText(bv);
+    inset->deleteLyXText(bv, recursive);
+}
+
+
+void InsetCollapsable::resizeLyXText(BufferView * bv) const
+{
+    inset->resizeLyXText(bv);
+    LyXFont font(LyXFont::ALL_SANE);
+    oldWidth = width(bv, font);
 }
index 3d8dd7e21028e31b5b63e5457655523058e6298f..e717107d0d92b765f7e554d68e9131adc54f28af 100644 (file)
@@ -120,7 +120,8 @@ public:
     int getMaxWidth(Painter & pain, UpdatableInset const *) const;
     ///
     LyXText * getLyXText(BufferView *) const;
-    void deleteLyXText(BufferView *) const;
+    void deleteLyXText(BufferView *, bool recursive=true) const;
+    void resizeLyXText(BufferView *) const;
 
 protected:
     ///
@@ -156,7 +157,7 @@ private:
     ///
     int widthCollapsed;
     ///
-    int oldWidth;
+    mutable int oldWidth;
     ///
     mutable int topx;
     mutable int topbaseline;
index 646587c82a9a538416a50f91a64d55b23c379e77..1a42ac18f171be364e6fbee43ea619232cee9ac6 100644 (file)
@@ -162,7 +162,7 @@ void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline,
     if (!cleared && ((need_update == INIT) || (need_update == FULL) ||
                     (top_x != int(x)) || (top_baseline != baseline))) {
        int h = ascent(bv, font) + descent(bv, font);
-       int tx = display()? 0:top_x;
+       int tx = display()||!owner()? 0:top_x;
        int w =  tx? width(bv, font):pain.paperWidth();
        int ty = baseline - ascent(bv, font);
        
@@ -567,7 +567,6 @@ UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv, int action,
        resetPos(bv);
        return result;
     }
-    result=DISPATCHED;
 
     if ((action < 0) && arg.empty())
         return FINISHED;
@@ -599,6 +598,7 @@ UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv, int action,
 
     bool hs = hasSelection();
     HideInsetCursor(bv);
+    result=DISPATCHED;
     switch (action) {
        // Normal chars not handled here
     case -1:
@@ -623,7 +623,7 @@ UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv, int action,
        sel_pos_start = sel_pos_end = cursor.pos();
        sel_cell_start = sel_cell_end = actcell;
        if (hs)
-           UpdateLocal(bv, CURSOR, false);
+           UpdateLocal(bv, SELECTION, false);
        break;
     case LFUN_LEFTSEL:
        if (tabular->IsFirstCellInRow(actcell) && cellstart(cursor.pos()))
@@ -644,7 +644,7 @@ UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv, int action,
        sel_pos_start = sel_pos_end = cursor.pos();
        sel_cell_start = sel_cell_end = actcell;
        if (hs)
-           UpdateLocal(bv, CURSOR, false);
+           UpdateLocal(bv, SELECTION, false);
        break;
     case LFUN_DOWNSEL:
     {
@@ -664,7 +664,7 @@ UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv, int action,
        sel_pos_start = sel_pos_end = cursor.pos();
        sel_cell_start = sel_cell_end = actcell;
        if (hs)
-           UpdateLocal(bv, CURSOR, false);
+           UpdateLocal(bv, SELECTION, false);
        break;
     case LFUN_UPSEL:
     {
@@ -684,7 +684,7 @@ UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv, int action,
        sel_pos_start = sel_pos_end = cursor.pos();
        sel_cell_start = sel_cell_end = actcell;
        if (hs)
-           UpdateLocal(bv, CURSOR, false);
+           UpdateLocal(bv, SELECTION, false);
        break;
     case LFUN_BACKSPACE:
        break;
@@ -697,9 +697,9 @@ UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv, int action,
     case LFUN_SHIFT_TAB:
     case LFUN_TAB:
        if (the_locking_inset) {
-           the_locking_inset->InsetUnlock(bv);
+           UnlockInsetInInset(bv, the_locking_inset);
+           the_locking_inset = 0;
        }
-       the_locking_inset = 0;
        if (action == LFUN_TAB)
            moveNextCell(bv);
        else
@@ -707,7 +707,7 @@ UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv, int action,
        sel_pos_start = sel_pos_end = cursor.pos();
        sel_cell_start = sel_cell_end = actcell;
        if (hs)
-           UpdateLocal(bv, CURSOR, false);
+           UpdateLocal(bv, SELECTION, false);
        break;
     case LFUN_LAYOUT_TABLE:
     {
@@ -1349,3 +1349,9 @@ void InsetTabular::recomputeTextInsets(BufferView * bv, const LyXFont & font) co
 //     cx += tabular->GetWidthOfColumn(cell);
     }
 }
+
+
+void InsetTabular::resizeLyXText(BufferView *) const
+{
+    need_update = FULL;
+}
index 8bc8788463d0163b100b452b5704830645448639..2bae6750c22a355183f6dc71d331cd64a850e0e9 100644 (file)
@@ -118,6 +118,8 @@ public:
     ///
     bool InsertInset(BufferView *, Inset *);
     ///
+    bool IsTextInset() const { return true; }
+    ///
     bool display() const { return tabular->IsLongTabular(); }
     ///
     void InsetButtonRelease(BufferView *, int, int, int);
@@ -155,6 +157,8 @@ public:
     int getMaxWidth(Painter & pain, UpdatableInset const *) const;
     ///
     Buffer * BufferOwner() const { return buffer; }
+    ///
+    void resizeLyXText(BufferView *) const;
 
     ///
     /// Public structures and variables
index 292fcbc8ccf0bc3654f17be51e4e5c748e7c6778..d38d9da270f010c8fc9629beb07698b2fd2756cb 100644 (file)
@@ -116,6 +116,19 @@ InsetText::~InsetText()
 }
 
 
+void InsetText::clear()
+{
+    LyXParagraph * p = par->next;
+    delete par;
+    while(p) {
+       par = p;
+       p = p->next;
+       delete par;
+    }
+    par = new LyXParagraph();
+}
+
+
 Inset * InsetText::Clone() const
 {
     InsetText * t = new InsetText(*this);
@@ -323,15 +336,18 @@ void InsetText::update(BufferView * bv, LyXFont const & font, bool reinit)
 {
     if (reinit) {  // && (need_update != CURSOR)) {
        need_update = INIT;
-       deleteLyXText(bv);
+       resizeLyXText(bv);
        if (owner())
            owner()->update(bv, font, true);
        return;
     }
-    if (the_locking_inset)
+    if (the_locking_inset) {
+       inset_x = cx(bv) - top_x + drawTextXOffset;
+       inset_y = cy(bv) + drawTextYOffset;
        the_locking_inset->update(bv, font, reinit);
+    }
     if (need_update == INIT) {
-       deleteLyXText(bv);
+       resizeLyXText(bv);
        need_update = FULL;
 //     if (!owner() && bv->text)
 //         bv->text->UpdateInset(bv, this);
@@ -350,7 +366,7 @@ void InsetText::update(BufferView * bv, LyXFont const & font, bool reinit)
     if (oldw != insetWidth) {
 //         printf("TW(%p): %d-%d-%d-%d\n",this,insetWidth, oldw,
 //                textWidth(bv->painter()),static_cast<int>(TEXT(bv)->width));
-       deleteLyXText(bv);
+       resizeLyXText(bv);
        need_update = FULL;
 #if 0
        if (owner()) {
@@ -781,6 +797,16 @@ InsetText::LocalDispatch(BufferView * bv,
        UpdateLocal(bv, CURSOR_PAR, false);
        break;
     case LFUN_PASTE:
+       if (!autoBreakRows) {
+           CutAndPaste cap;
+
+           if (cap.nrOfParagraphs() > 1) {
+               WriteAlert(_("Impossible operation"),
+                          _("Cannot include more than one paragraph!"),
+                          _("Sorry."));
+               break;
+           }
+       }
        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);
@@ -960,7 +986,7 @@ void InsetText::ToggleInsetCursor(BufferView * bv)
     if (cursor_visible)
         bv->hideLockedInsetCursor();
     else
-        bv->showLockedInsetCursor(cx(bv), cy(bv),
+        bv->showLockedInsetCursor(cx(bv)-1, cy(bv),
                                  asc, desc);
     cursor_visible = !cursor_visible;
 }
@@ -1252,12 +1278,74 @@ LyXText * InsetText::getLyXText(BufferView * bv) const
 }
 
 
-void InsetText::deleteLyXText(BufferView * bv) const
+void InsetText::deleteLyXText(BufferView * bv, bool recursive) const
 {
     cache.erase(bv);
-    /// then remove all LyXText in text-insets
-    LyXParagraph * p = par;
-    for(;p;p = p->next) {
+    if (recursive) {
+       /// then remove all LyXText in text-insets
+       LyXParagraph * p = par;
+       for(;p;p = p->next) {
            p->deleteInsetsLyXText(bv);
+       }
+    }
+}
+
+void InsetText::resizeLyXText(BufferView * bv) const
+{
+    if (!par->next && !par->size()) // not neccessary!
+       return;
+
+    LyXParagraph * lpar = 0;
+    LyXParagraph * selstartpar = 0;
+    LyXParagraph * selendpar = 0;
+    int pos = 0;
+    int selstartpos = 0;
+    int selendpos = 0;
+    int selection = 0;
+    int mark_set = 0;
+
+//    ProhibitInput(bv);
+
+    lpar = TEXT(bv)->cursor.par();
+    pos = TEXT(bv)->cursor.pos();
+    selstartpar = TEXT(bv)->sel_start_cursor.par();
+    selstartpos = TEXT(bv)->sel_start_cursor.pos();
+    selendpar = TEXT(bv)->sel_end_cursor.par();
+    selendpos = TEXT(bv)->sel_end_cursor.pos();
+    selection = TEXT(bv)->selection;
+    mark_set = TEXT(bv)->mark_set;
+    deleteLyXText(bv, (the_locking_inset == 0));
+
+    if (lpar) {
+       TEXT(bv)->selection = true;
+       /* at this point just to avoid the Delete-Empty-Paragraph
+        * Mechanism when setting the cursor */
+       TEXT(bv)->mark_set = mark_set;
+       if (selection) {
+           TEXT(bv)->SetCursor(bv, selstartpar, selstartpos);
+           TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
+           TEXT(bv)->SetCursor(bv, selendpar, selendpos);
+           TEXT(bv)->SetSelection();
+           TEXT(bv)->SetCursor(bv, lpar, pos);
+       } else {
+           TEXT(bv)->SetCursor(bv, lpar, pos);
+           TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
+           TEXT(bv)->selection = false;
+       }
+    }
+    if (bv->screen())
+           TEXT(bv)->first = bv->screen()->TopCursorVisible(TEXT(bv));
+    // this will scroll the screen such that the cursor becomes visible 
+    bv->updateScrollbar();
+//    AllowInput(bv);
+    if (the_locking_inset) {
+       /// then resize all LyXText in text-insets
+       inset_x = cx(bv) - top_x + drawTextXOffset;
+       inset_y = cy(bv) + drawTextYOffset;
+       LyXParagraph * p = par;
+       for(;p;p = p->next) {
+           p->resizeInsetsLyXText(bv);
+       }
     }
+    need_update = FULL;
 }
index 54efee5a404a4ab115e761d2721aeff008df95bb..b4b76b8790004c2c4e7a26dee7a14b97977d17ba 100644 (file)
@@ -66,7 +66,7 @@ public:
     ///
     InsetText & operator= (InsetText const & it);
     ///
-    void clear() const { par->clearContents(); }
+    void clear();
     ///
     void Read(Buffer const *, LyXLex &);
     ///
@@ -153,7 +153,8 @@ public:
 //    LyXFont GetDrawFont(BufferView *, LyXParagraph *, int pos) const;
     ///
     LyXText * getLyXText(BufferView *) const;
-    void deleteLyXText(BufferView *) const;
+    void deleteLyXText(BufferView *, bool recursive=true) const;
+    void resizeLyXText(BufferView *) const;
 
     LyXParagraph * par;
     ///
index 1a190f2b69c265da4f19cba6de2da77319e9bdfb..ec4d9b1a95b597e808aa30eb74db5169d275bfc3 100644 (file)
@@ -212,7 +212,8 @@ public:
        /// because we could have fake text insets and have to call this
        /// inside them without cast!!!
        virtual LyXText * getLyXText(BufferView *) const;
-       virtual void deleteLyXText(BufferView *) const {}
+       virtual void deleteLyXText(BufferView *, bool =true) const {}
+       virtual void resizeLyXText(BufferView *) const {}
 
 protected:
        ///
index ae3d2ca36666f608826c9e9fbc7bc415ddc2f2c6..717b387063e14a0a7599214ebd399b740c6e158e 100644 (file)
@@ -200,6 +200,7 @@ public:
        void SetInsetOwner(Inset * i);
        ///
        void deleteInsetsLyXText(BufferView *);
+       void resizeInsetsLyXText(BufferView *);
 private:
        ///
        TextContainer text;
index 6c2042c2d878f84d98f012e08c5059e4a204e97b..de63c27ae8c1eb6278a81202b9a238022c778d67 100644 (file)
@@ -4429,3 +4429,18 @@ void LyXParagraph::deleteInsetsLyXText(BufferView * bv)
                }
        }
 }
+
+
+void LyXParagraph::resizeInsetsLyXText(BufferView * bv)
+{
+       // then the insets
+       for (InsetList::const_iterator cit = insetlist.begin();
+            cit != insetlist.end(); ++cit) {
+               if ((*cit).inset) {
+                       if ((*cit).inset->IsTextInset()) {
+                               static_cast<UpdatableInset *>
+                                       ((*cit).inset)->resizeLyXText(bv);
+                       }
+               }
+       }
+}