From 08c732ecfad8cb933399b31f5591373fe8195f3a Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=BCrgen=20Vigna?= Date: Fri, 14 Jul 2000 14:57:20 +0000 Subject: [PATCH] Fixed inset-redraw problems on resizing lyx-window, and some other small 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 --- ChangeLog | 11 +++ po/POTFILES.in | 5 - src/BufferView_pimpl.C | 6 +- src/buffer.C | 13 ++- src/buffer.h | 1 + src/frontends/xforms/FormTabular.C | 1 + src/frontends/xforms/FormTabular.h | 7 +- src/frontends/xforms/form_tabular.C | 30 +++--- src/frontends/xforms/form_tabular.h | 2 +- src/frontends/xforms/forms/form_tabular.fd | 42 ++++---- src/insets/insetcollapsable.C | 16 +++- src/insets/insetcollapsable.h | 5 +- src/insets/insettabular.C | 24 +++-- src/insets/insettabular.h | 4 + src/insets/insettext.C | 106 +++++++++++++++++++-- src/insets/insettext.h | 5 +- src/insets/lyxinset.h | 3 +- src/lyxparagraph.h | 1 + src/paragraph.C | 15 +++ 19 files changed, 218 insertions(+), 79 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3d3d730fdd..d0d93f6d50 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,16 @@ 2000-07-14 Juergen Vigna + * 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 diff --git a/po/POTFILES.in b/po/POTFILES.in index 0961c34f8e..fabdfa0ebe 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -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 diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index aad1957478..f50a1206ef 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -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(); diff --git a/src/buffer.C b/src/buffer.C index 3ff1ddadc6..2dd798f084 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -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) { diff --git a/src/buffer.h b/src/buffer.h index 9f968892a8..d970148f77 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -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; diff --git a/src/frontends/xforms/FormTabular.C b/src/frontends/xforms/FormTabular.C index eaf2bb7cc8..bbe35664ee 100644 --- a/src/frontends/xforms/FormTabular.C +++ b/src/frontends/xforms/FormTabular.C @@ -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" diff --git a/src/frontends/xforms/FormTabular.h b/src/frontends/xforms/FormTabular.h index c2f69e66ed..b8fb925dca 100644 --- a/src/frontends/xforms/FormTabular.h +++ b/src/frontends/xforms/FormTabular.h @@ -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. diff --git a/src/frontends/xforms/form_tabular.C b/src/frontends/xforms/form_tabular.C index 78d425b2e7..49e1001e12 100644 --- a/src/frontends/xforms/form_tabular.C +++ b/src/frontends/xforms/form_tabular.C @@ -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); diff --git a/src/frontends/xforms/form_tabular.h b/src/frontends/xforms/form_tabular.h index d675a3d1fd..e4f449e9e5 100644 --- a/src/frontends/xforms/form_tabular.h +++ b/src/frontends/xforms/form_tabular.h @@ -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_ diff --git a/src/frontends/xforms/forms/form_tabular.fd b/src/frontends/xforms/forms/form_tabular.fd index 2c8268c1c3..50d7b0352a 100644 --- a/src/frontends/xforms/forms/form_tabular.fd +++ b/src/frontends/xforms/forms/form_tabular.fd @@ -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 diff --git a/src/insets/insetcollapsable.C b/src/insets/insetcollapsable.C index 8240f90894..4c8207c4ce 100644 --- a/src/insets/insetcollapsable.C +++ b/src/insets/insetcollapsable.C @@ -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); } diff --git a/src/insets/insetcollapsable.h b/src/insets/insetcollapsable.h index 3d8dd7e210..e717107d0d 100644 --- a/src/insets/insetcollapsable.h +++ b/src/insets/insetcollapsable.h @@ -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; diff --git a/src/insets/insettabular.C b/src/insets/insettabular.C index 646587c82a..1a42ac18f1 100644 --- a/src/insets/insettabular.C +++ b/src/insets/insettabular.C @@ -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; +} diff --git a/src/insets/insettabular.h b/src/insets/insettabular.h index 8bc8788463..2bae6750c2 100644 --- a/src/insets/insettabular.h +++ b/src/insets/insettabular.h @@ -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 diff --git a/src/insets/insettext.C b/src/insets/insettext.C index 292fcbc8cc..d38d9da270 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -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(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; } diff --git a/src/insets/insettext.h b/src/insets/insettext.h index 54efee5a40..b4b76b8790 100644 --- a/src/insets/insettext.h +++ b/src/insets/insettext.h @@ -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; /// diff --git a/src/insets/lyxinset.h b/src/insets/lyxinset.h index 1a190f2b69..ec4d9b1a95 100644 --- a/src/insets/lyxinset.h +++ b/src/insets/lyxinset.h @@ -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: /// diff --git a/src/lyxparagraph.h b/src/lyxparagraph.h index ae3d2ca366..717b387063 100644 --- a/src/lyxparagraph.h +++ b/src/lyxparagraph.h @@ -200,6 +200,7 @@ public: void SetInsetOwner(Inset * i); /// void deleteInsetsLyXText(BufferView *); + void resizeInsetsLyXText(BufferView *); private: /// TextContainer text; diff --git a/src/paragraph.C b/src/paragraph.C index 6c2042c2d8..de63c27ae8 100644 --- a/src/paragraph.C +++ b/src/paragraph.C @@ -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 + ((*cit).inset)->resizeLyXText(bv); + } + } + } +} -- 2.39.5