From 9704a004bd76e70296a79170d43d9bce16e5121f Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=BCrgen=20Vigna?= Date: Mon, 19 Feb 2001 16:01:31 +0000 Subject: [PATCH] Various fixes to InsetTabular and InsetText + Angus's cleanup patch. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1535 a592a061-630c-0410-9148-cb99ea01b6c8 --- po/POTFILES.in | 34 ++++----- src/BufferView.C | 6 ++ src/BufferView_pimpl.C | 5 ++ src/ChangeLog | 4 + src/buffer.h | 4 +- src/frontends/xforms/ChangeLog | 14 ++++ src/frontends/xforms/FormError.C | 2 +- src/frontends/xforms/FormGraphics.C | 2 +- src/frontends/xforms/FormInset.C | 2 +- src/frontends/xforms/FormTabular.C | 6 +- src/frontends/xforms/form_tabular.C | 2 +- src/frontends/xforms/forms/form_tabular.fd | 2 +- src/insets/ChangeLog | 25 ++++++ src/insets/inset.C | 3 +- src/insets/insetcommand.h | 4 +- src/insets/inseterror.h | 5 +- src/insets/insetgraphics.C | 2 +- src/insets/insetgraphics.h | 3 +- src/insets/insettabular.C | 89 ++++++++++++++++++---- src/insets/insettabular.h | 6 +- src/insets/insettext.C | 2 +- src/lyxtext.h | 2 + src/text.C | 9 +++ 23 files changed, 181 insertions(+), 52 deletions(-) diff --git a/po/POTFILES.in b/po/POTFILES.in index 57191a66e3..3b7b1bd1e4 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -71,44 +71,44 @@ src/frontends/qt2/FormTabularCreate.C src/frontends/qt2/paragraphdlgimpl.C src/frontends/qt2/tabularcreatedlgimpl.C src/frontends/xforms/FormBase.h -src/frontends/xforms/form_bibitem.C src/frontends/xforms/FormBibitem.C -src/frontends/xforms/form_bibtex.C +src/frontends/xforms/form_bibitem.C src/frontends/xforms/FormBibtex.C +src/frontends/xforms/form_bibtex.C src/frontends/xforms/form_browser.C -src/frontends/xforms/form_citation.C src/frontends/xforms/FormCitation.C -src/frontends/xforms/form_copyright.C +src/frontends/xforms/form_citation.C src/frontends/xforms/FormCopyright.C -src/frontends/xforms/form_document.C +src/frontends/xforms/form_copyright.C src/frontends/xforms/FormDocument.C -src/frontends/xforms/form_error.C +src/frontends/xforms/form_document.C src/frontends/xforms/FormError.C -src/frontends/xforms/form_graphics.C +src/frontends/xforms/form_error.C src/frontends/xforms/FormGraphics.C -src/frontends/xforms/form_include.C +src/frontends/xforms/form_graphics.C src/frontends/xforms/FormInclude.C -src/frontends/xforms/form_index.C +src/frontends/xforms/form_include.C src/frontends/xforms/FormIndex.C +src/frontends/xforms/form_index.C src/frontends/xforms/FormInset.h src/frontends/xforms/FormLog.C -src/frontends/xforms/form_paragraph.C src/frontends/xforms/FormParagraph.C -src/frontends/xforms/form_preferences.C +src/frontends/xforms/form_paragraph.C src/frontends/xforms/FormPreferences.C -src/frontends/xforms/form_print.C +src/frontends/xforms/form_preferences.C src/frontends/xforms/FormPrint.C -src/frontends/xforms/form_ref.C +src/frontends/xforms/form_print.C src/frontends/xforms/FormRef.C +src/frontends/xforms/form_ref.C src/frontends/xforms/FormSplash.C -src/frontends/xforms/form_tabular.C src/frontends/xforms/FormTabular.C -src/frontends/xforms/form_tabular_create.C +src/frontends/xforms/form_tabular.C src/frontends/xforms/FormTabularCreate.C -src/frontends/xforms/form_toc.C +src/frontends/xforms/form_tabular_create.C src/frontends/xforms/FormToc.C -src/frontends/xforms/form_url.C +src/frontends/xforms/form_toc.C src/frontends/xforms/FormUrl.C +src/frontends/xforms/form_url.C src/frontends/xforms/FormVCLog.C src/frontends/xforms/input_validators.C src/frontends/xforms/Menubar_pimpl.C diff --git a/src/BufferView.C b/src/BufferView.C index 99474cf9d8..0eca845aeb 100644 --- a/src/BufferView.C +++ b/src/BufferView.C @@ -116,6 +116,12 @@ void BufferView::updateScrollbar() } +void BufferView::scrollCB(double value) +{ + pimpl_->scrollCB(value); +} + + Inset * BufferView::checkInsetHit(LyXText * text, int & x, int & y, unsigned int button) { diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index fd5cdea0d8..dff6e8a53e 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -242,6 +242,8 @@ int BufferView::Pimpl::resizeCurrentBuffer() LyXParagraph * par = 0; LyXParagraph * selstartpar = 0; LyXParagraph * selendpar = 0; + UpdatableInset * the_locking_inset; + int pos = 0; int selstartpos = 0; int selendpos = 0; @@ -261,6 +263,7 @@ int BufferView::Pimpl::resizeCurrentBuffer() selendpos = bv_->text->sel_end_cursor.pos(); selection = bv_->text->selection; mark_set = bv_->text->mark_set; + the_locking_inset = bv_->text->the_locking_inset; delete bv_->text; bv_->text = new LyXText(bv_); } else { @@ -298,6 +301,8 @@ int BufferView::Pimpl::resizeCurrentBuffer() bv_->text->sel_cursor = bv_->text->cursor; bv_->text->selection = false; } + // remake the inset locking + bv_->text->the_locking_inset = the_locking_inset; } bv_->text->first = screen_->TopCursorVisible(bv_->text); buffer_->resizeInsets(bv_); diff --git a/src/ChangeLog b/src/ChangeLog index a941dbf506..001068ecf9 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2001-02-19 Angus Leeming + + * src/buffer.h: tiny clean-ups to allow compilation with DEC cxx. + 2001-02-17 Dekel Tsur * LaTeX.C (run): Do not use 'scanres & RERUN' when deciding diff --git a/src/buffer.h b/src/buffer.h index 9d736bf5cc..9508b1a3bb 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -527,7 +527,7 @@ void Buffer::markBakClean() inline -void Buffer::setUnnamed(bool flag = true) +void Buffer::setUnnamed(bool flag) { unnamed = flag; } @@ -578,7 +578,7 @@ BufferView * Buffer::getUser() const inline -void Buffer::Buffer::setParentName(string const & name) +void Buffer::setParentName(string const & name) { params.parentname = name; } diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index 27a4ec595f..9c0ea0bbc0 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,3 +1,17 @@ +2001-02-19 Juergen Vigna + + * FormTabular.C (build): make all input field accepted only after + a "RETURN". + + * forms/form_tabular.fd: removed default "Return" on Close-Button. + +2001-02-19 Angus Leeming + + * FormError.C: + * FormGraphics.C: + * FormInset.C (showInset): change associated with name change + inset::hide to inset::hideDialog. + 2001-02-19 Angus Leeming * FormCitation.C (build): altering "Text after" now activates the Ok, diff --git a/src/frontends/xforms/FormError.C b/src/frontends/xforms/FormError.C index a5a9fe7f2e..46345e92f4 100644 --- a/src/frontends/xforms/FormError.C +++ b/src/frontends/xforms/FormError.C @@ -65,7 +65,7 @@ void FormError::showInset(InsetError * inset) inset_ = inset; message_ = inset->getContents(); - ih_ = inset->hide.connect(slot(this, &FormError::hide)); + ih_ = inset->hideDialog.connect(slot(this, &FormError::hide)); show(); } diff --git a/src/frontends/xforms/FormGraphics.C b/src/frontends/xforms/FormGraphics.C index 170125430f..48838a712d 100644 --- a/src/frontends/xforms/FormGraphics.C +++ b/src/frontends/xforms/FormGraphics.C @@ -178,7 +178,7 @@ void FormGraphics::showDialog(InsetGraphics * inset) inset_ = inset; - ih_ = inset_->hide.connect(slot(this, &FormGraphics::hide)); + ih_ = inset_->hideDialog.connect(slot(this, &FormGraphics::hide)); show(); } diff --git a/src/frontends/xforms/FormInset.C b/src/frontends/xforms/FormInset.C index 88dc3b5202..7f81476aaf 100644 --- a/src/frontends/xforms/FormInset.C +++ b/src/frontends/xforms/FormInset.C @@ -81,7 +81,7 @@ void FormCommand::showInset(InsetCommand * inset) inset_ = inset; params = inset->params(); - ih_ = inset->hide.connect(slot(this, &FormCommand::hide)); + ih_ = inset->hideDialog.connect(slot(this, &FormCommand::hide)); show(); } diff --git a/src/frontends/xforms/FormTabular.C b/src/frontends/xforms/FormTabular.C index cb6adf37f9..fa7a051ed3 100644 --- a/src/frontends/xforms/FormTabular.C +++ b/src/frontends/xforms/FormTabular.C @@ -118,11 +118,11 @@ void FormTabular::build() fl_set_input_return(column_options_->input_column_width, FL_RETURN_END); fl_set_input_return(column_options_->input_special_alignment, - FL_RETURN_CHANGED); + FL_RETURN_END); fl_set_input_return(cell_options_->input_mcolumn_width, - FL_RETURN_CHANGED); + FL_RETURN_END); fl_set_input_return(cell_options_->input_special_multialign, - FL_RETURN_CHANGED); + FL_RETURN_END); fl_addto_tabfolder(dialog_->tabFolder, _("Tabular"), tabular_options_->form); diff --git a/src/frontends/xforms/form_tabular.C b/src/frontends/xforms/form_tabular.C index ca7c8d5114..d6b674ecd7 100644 --- a/src/frontends/xforms/form_tabular.C +++ b/src/frontends/xforms/form_tabular.C @@ -28,7 +28,7 @@ FD_form_tabular * FormTabular::build_tabular() fdui->tabFolder = obj = fl_add_tabfolder(FL_TOP_TABFOLDER, 0, 0, 505, 250, _("Tabbed folder")); fl_set_object_resize(obj, FL_RESIZE_ALL); { - char const * const dummy = N_("Close|^[^M"); + char const * const dummy = N_("Close|^["); fdui->button_close = obj = fl_add_button(FL_NORMAL_BUTTON, 415, 260, 90, 30, idex(_(dummy))); fl_set_button_shortcut(obj, scex(_(dummy)), 1); } diff --git a/src/frontends/xforms/forms/form_tabular.fd b/src/frontends/xforms/forms/form_tabular.fd index a62399ed84..906504f6d0 100644 --- a/src/frontends/xforms/forms/form_tabular.fd +++ b/src/frontends/xforms/forms/form_tabular.fd @@ -59,7 +59,7 @@ alignment: FL_ALIGN_CENTER style: FL_NORMAL_STYLE size: FL_NORMAL_SIZE lcol: FL_BLACK -label: Close|^[^M +label: Close|^[ shortcut: resize: FL_RESIZE_ALL gravity: FL_NoGravity FL_NoGravity diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index 4fbc6d7cf2..d763a57c63 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,28 @@ +2001-02-19 Angus Leeming + + * insetcommand.h: + * inseterror.h: + * insetgraphics.C: change name of "hide" signal to "hideDialog", + consistent with InsetTabular. + +2001-02-19 Juergen Vigna + + * insettabular.C (LocalDispatch): implement PAGE up/down. + + * insettext.C (draw): clear all of it on need_update==INIT too! + + * insettabular.C (InsetUnlock): always clear the selection. + + * inset.C (scroll): normally we only want to scroll the inset until + it is fully visible so if top_x + offset > 20 then just set scx to 0. + +2001-02-14 Juergen Vigna + + * insettabular.C (LocalDispatch): remove x_fix as it is not used. + (resetPos): fixed scroll behaviour. + (LocalDispatch): do an update if moving cursor inside a table cell + requests a scroll of the tabular. + 2001-02-16 Lars Gullik Bjønnes * insettext.C (textWidth): constify local var diff --git a/src/insets/inset.C b/src/insets/inset.C index 61996ac77c..d8cd78c143 100644 --- a/src/insets/inset.C +++ b/src/insets/inset.C @@ -191,7 +191,8 @@ void UpdatableInset::scroll(BufferView * bv, int offset) const if (!scx && top_x >= 20) return; if ((top_x + offset) > 20) - scx += offset - (top_x - scx + offset - 20); + scx = 0; +// scx += offset - (top_x - scx + offset - 20); else scx += offset; } else { diff --git a/src/insets/insetcommand.h b/src/insets/insetcommand.h index 0dd010df7e..d0fb7a5c9f 100644 --- a/src/insets/insetcommand.h +++ b/src/insets/insetcommand.h @@ -84,7 +84,7 @@ public: explicit InsetCommand(InsetCommandParams const &); /// - virtual ~InsetCommand() { hide(); } + virtual ~InsetCommand() { hideDialog(); } /// void Write(Buffer const *, std::ostream & os) const { p_.Write( os ); } @@ -131,7 +131,7 @@ public: /// void setParams(InsetCommandParams const &); /// - Signal0 hide; + Signal0 hideDialog; private: /// InsetCommandParams p_; diff --git a/src/insets/inseterror.h b/src/insets/inseterror.h index a333d543a5..8233d2dbe6 100644 --- a/src/insets/inseterror.h +++ b/src/insets/inseterror.h @@ -35,7 +35,7 @@ public: explicit InsetError(string const &); /// - ~InsetError() { hide(); } + ~InsetError() { hideDialog(); } /// int ascent(BufferView *, LyXFont const &) const; /// @@ -73,7 +73,8 @@ public: /// string const & getContents() const { return contents; } /// - Signal0 hide; + Signal0 hideDialog; + private: /// string contents; diff --git a/src/insets/insetgraphics.C b/src/insets/insetgraphics.C index a5e6b8adea..77bfa69b7a 100644 --- a/src/insets/insetgraphics.C +++ b/src/insets/insetgraphics.C @@ -176,7 +176,7 @@ InsetGraphics::InsetGraphics() InsetGraphics::~InsetGraphics() { // Emits the hide signal to the dialog connected (if any) - hide(); + hideDialog(); } char const * diff --git a/src/insets/insetgraphics.h b/src/insets/insetgraphics.h index 52d0da7a3a..d0c9925b47 100644 --- a/src/insets/insetgraphics.h +++ b/src/insets/insetgraphics.h @@ -100,7 +100,8 @@ public: /** This signal is connected by our dialog and called when the inset is deleted. */ - Signal0 hide; + Signal0 hideDialog; + private: /// Update the inset after parameter change. void updateInset() const; diff --git a/src/insets/insettabular.C b/src/insets/insettabular.C index 2c4f73e0fa..e1fc2a2305 100644 --- a/src/insets/insettabular.C +++ b/src/insets/insettabular.C @@ -121,7 +121,6 @@ InsetTabular::InsetTabular(Buffer const & buf, int rows, int columns) // just for test!!! the_locking_inset = 0; locked = no_selection = cursor_visible = false; - cursor.x_fix(-1); oldcell = -1; actrow = actcell = 0; clearSelection(); @@ -136,7 +135,6 @@ InsetTabular::InsetTabular(InsetTabular const & tab, Buffer const & buf) tabular = new LyXTabular(this, *(tab.tabular)); the_locking_inset = 0; locked = no_selection = cursor_visible = false; - cursor.x_fix(-1); oldcell = -1; actrow = actcell = 0; sel_cell_start = sel_cell_end = 0; @@ -251,6 +249,7 @@ void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline, if (cleared) { int cell = 0; float cx; + first_visible_cell = -1; for (i = 0; i < tabular->rows(); ++i) { nx = int(x); dodraw = ((baseline + tabular->GetDescentOfRow(i)) > 0) && @@ -260,6 +259,8 @@ void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline, continue; cx = nx + tabular->GetBeginningOfTextInCell(cell); if (dodraw) { + if (first_visible_cell < 0) + first_visible_cell = cell; if (hasSelection()) DrawCellSelection(pain, nx, baseline, i, j, cell); tabular->GetCellInset(cell)->draw(bv, font, baseline, cx, @@ -484,10 +485,9 @@ void InsetTabular::InsetUnlock(BufferView * bv) oldcell = -1; locked = false; if (scroll() || hasSelection()) { + sel_cell_start = sel_cell_end = 0; if (scroll()) { scroll(bv, 0.0F); - } else { - sel_cell_start = sel_cell_end = 0; } UpdateLocal(bv, FULL, false); } @@ -731,14 +731,18 @@ UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv, int action, if ((action < 0) && arg.empty()) return FINISHED; - if ((action != LFUN_DOWN) && (action != LFUN_UP) && - (action != LFUN_DOWNSEL) && (action != LFUN_UPSEL)) - cursor.x_fix(-1); if (the_locking_inset) { result=the_locking_inset->LocalDispatch(bv, action, arg); - if (result == DISPATCHED_NOUPDATE) + if (result == DISPATCHED_NOUPDATE) { + int sc = scroll(); + resetPos(bv); + if (sc != scroll()) { // inset has been scrolled + the_locking_inset->ToggleInsetCursor(bv); + UpdateLocal(bv, FULL, false); + the_locking_inset->ToggleInsetCursor(bv); + } return result; - else if (result == DISPATCHED) { + } else if (result == DISPATCHED) { the_locking_inset->ToggleInsetCursor(bv); UpdateLocal(bv, CELL, false); the_locking_inset->ToggleInsetCursor(bv); @@ -814,6 +818,45 @@ UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv, int action, if (hs) UpdateLocal(bv, SELECTION, false); break; + case LFUN_NEXT: { + int column = actcol; + if (the_locking_inset) { + UnlockInsetInInset(bv, the_locking_inset); + the_locking_inset = 0; + } + if (bv->text->first + bv->painter().paperHeight() < + (top_baseline + tabular->GetHeightOfTabular())) + { + bv->scrollCB(bv->text->first + bv->painter().paperHeight()); + UpdateLocal(bv, FULL, false); + actcell = tabular->GetCellBelow(first_visible_cell) + column; + } else { + actcell = tabular->GetFirstCellInRow(tabular->rows() - 1) + column; + } + resetPos(bv); + UpdateLocal(bv, CURSOR, false); + break; + } + case LFUN_PRIOR: { + int column = actcol; + if (the_locking_inset) { + UnlockInsetInInset(bv, the_locking_inset); + the_locking_inset = 0; + } + if (top_baseline < 0) { + bv->scrollCB(bv->text->first - bv->painter().paperHeight()); + UpdateLocal(bv, FULL, false); + if (top_baseline > 0) + actcell = column; + else + actcell = tabular->GetCellBelow(first_visible_cell) + column; + } else { + actcell = column; + } + resetPos(bv); + UpdateLocal(bv, CURSOR, false); + break; + } case LFUN_BACKSPACE: break; case LFUN_DELETE: @@ -1192,9 +1235,25 @@ void InsetTabular::resetPos(BufferView * bv) const new_x += offset; cursor.x(new_x); // cursor.x(getCellXPos(actcell) + offset); - if (((cursor.x() - offset) > 20) && - ((cursor.x()-offset+tabular->GetWidthOfColumn(actcell)) > - (bv->workWidth()-20))) + if (scroll() && (tabular->GetWidthOfTabular() < bv->workWidth()-20)) + scroll(bv, 0.0F); + else if (the_locking_inset && + (tabular->GetWidthOfColumn(actcell) > bv->workWidth()-20)) + { + int xx = cursor.x() - offset + bv->text->GetRealCursorX(bv); + printf("%d\n", xx); + if (xx > (bv->workWidth()-20)) + scroll(bv, -(xx - bv->workWidth() + 60)); + else if (xx < 20) { + if (xx < 0) + xx = -xx + 60; + else + xx = 60; + scroll(bv, xx); + } + } else if (((cursor.x() - offset) > 20) && + ((cursor.x()-offset+tabular->GetWidthOfColumn(actcell)) > + (bv->workWidth()-20))) { scroll(bv, -tabular->GetWidthOfColumn(actcell)-20); UpdateLocal(bv, FULL, false); @@ -1208,9 +1267,9 @@ void InsetTabular::resetPos(BufferView * bv) const if ((!the_locking_inset || !the_locking_inset->GetFirstLockingInsetOfType(TABULAR_CODE)) && (actcell != oldcell)) { - InsetTabular * inset = const_cast(this); - bv->owner()->getDialogs()->updateTabular(inset); - oldcell = actcell; + InsetTabular * inset = const_cast(this); + bv->owner()->getDialogs()->updateTabular(inset); + oldcell = actcell; } } diff --git a/src/insets/insettabular.h b/src/insets/insettabular.h index 91a5cfb7df..d6f87f2dfb 100644 --- a/src/insets/insettabular.h +++ b/src/insets/insettabular.h @@ -178,8 +178,8 @@ public: // Public structures and variables /// LyXTabular * tabular; - /// - Signal0 hideDialog; + /// + Signal0 hideDialog; private: /// @@ -272,6 +272,8 @@ private: /// mutable int actrow; /// + mutable int first_visible_cell; + /// bool no_selection; /// bool no_draw; diff --git a/src/insets/insettext.C b/src/insets/insettext.C index 967d41d6bd..38bfe81a2e 100644 --- a/src/insets/insettext.C +++ b/src/insets/insettext.C @@ -291,7 +291,7 @@ void InsetText::draw(BufferView * bv, LyXFont const & f, // if top_x differs we have a rule down and we don't have to clear anything if (!cleared && (top_x == int(x)) && - ((need_update==FULL) || (top_baseline!=baseline))) + ((need_update==INIT)||(need_update==FULL)||(top_baseline!=baseline))) { int w = insetWidth; int h = insetAscent + insetDescent; diff --git a/src/lyxtext.h b/src/lyxtext.h index beb32a2da7..a2092628ae 100644 --- a/src/lyxtext.h +++ b/src/lyxtext.h @@ -75,6 +75,8 @@ public: /// UpdatableInset * the_locking_inset; + /// + int GetRealCursorX(BufferView *) const; /// LyXFont const GetFont(Buffer const *, LyXParagraph * par, LyXParagraph::size_type pos) const; diff --git a/src/text.C b/src/text.C index a63f0d4465..2964b22df4 100644 --- a/src/text.C +++ b/src/text.C @@ -54,6 +54,15 @@ int LyXText::workWidth(BufferView * bview) const } +int LyXText::GetRealCursorX(BufferView * bview) const +{ + int x = cursor.x(); + if (the_locking_inset && (the_locking_inset->getLyXText(bview)!=this)) + x = the_locking_inset->getLyXText(bview)->GetRealCursorX(bview); + return x; +} + + unsigned char LyXText::TransformChar(unsigned char c, LyXParagraph * par, LyXParagraph::size_type pos) const { -- 2.39.2