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>
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
}
}
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();
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)
{
/// should be changed to work for a list.
void resize();
+ void resizeInsets(BufferView *);
/// Update window titles of all users
void updateTitles() const;
#include FORMS_H_LOCATION
#include "FormTabular.h"
+#include "form_tabular.h"
#include "xform_macros.h"
#include "input_validators.h"
#include "LyXView.h"
#define FORMTABULAR_H
#include "DialogBase.h"
-#include "form_tabular.h"
#ifdef SIGC_CXX_NAMESPACES
using SigC::Connection;
#endif
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.
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);
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);
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);
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);
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);
-/** 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_
=============== 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
--------------------
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
--------------------
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
--------------------
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
--------------------
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
--------------------
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
=============== 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
=============== 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
=============== 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
=============== 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
}
if (!widthCollapsed) {
widthCollapsed = width_collapsed(bv->painter(), font);
- inset->deleteLyXText(bv);
+ inset->resizeLyXText(bv);
need_update = FULL;
if (owner()) {
owner()->update(bv, 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);
}
-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);
}
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:
///
///
int widthCollapsed;
///
- int oldWidth;
+ mutable int oldWidth;
///
mutable int topx;
mutable int topbaseline;
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);
resetPos(bv);
return result;
}
- result=DISPATCHED;
if ((action < 0) && arg.empty())
return FINISHED;
bool hs = hasSelection();
HideInsetCursor(bv);
+ result=DISPATCHED;
switch (action) {
// Normal chars not handled here
case -1:
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()))
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:
{
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:
{
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;
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
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:
{
// cx += tabular->GetWidthOfColumn(cell);
}
}
+
+
+void InsetTabular::resizeLyXText(BufferView *) const
+{
+ need_update = FULL;
+}
///
bool InsertInset(BufferView *, Inset *);
///
+ bool IsTextInset() const { return true; }
+ ///
bool display() const { return tabular->IsLongTabular(); }
///
void InsetButtonRelease(BufferView *, int, int, int);
int getMaxWidth(Painter & pain, UpdatableInset const *) const;
///
Buffer * BufferOwner() const { return buffer; }
+ ///
+ void resizeLyXText(BufferView *) const;
///
/// Public structures and variables
}
+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);
{
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);
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()) {
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);
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;
}
}
-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;
}
///
InsetText & operator= (InsetText const & it);
///
- void clear() const { par->clearContents(); }
+ void clear();
///
void Read(Buffer const *, LyXLex &);
///
// 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;
///
/// 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:
///
void SetInsetOwner(Inset * i);
///
void deleteInsetsLyXText(BufferView *);
+ void resizeInsetsLyXText(BufferView *);
private:
///
TextContainer text;
}
}
}
+
+
+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);
+ }
+ }
+ }
+}