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
This commit is contained in:
Jürgen Vigna 2001-02-19 16:01:31 +00:00
parent 1dd613bb03
commit 9704a004bd
23 changed files with 181 additions and 52 deletions

View File

@ -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

View File

@ -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)
{

View File

@ -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_);

View File

@ -1,3 +1,7 @@
2001-02-19 Angus Leeming <a.leeming@ic.ac.uk>
* src/buffer.h: tiny clean-ups to allow compilation with DEC cxx.
2001-02-17 Dekel Tsur <dekelts@tau.ac.il>
* LaTeX.C (run): Do not use 'scanres & RERUN' when deciding

View File

@ -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;
}

View File

@ -1,3 +1,17 @@
2001-02-19 Juergen Vigna <jug@sad.it>
* 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 <a.leeming@ic.ac.uk>
* FormError.C:
* FormGraphics.C:
* FormInset.C (showInset): change associated with name change
inset::hide to inset::hideDialog.
2001-02-19 Angus Leeming <a.leeming@ic.ac.uk>
* FormCitation.C (build): altering "Text after" now activates the Ok,

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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);

View File

@ -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);
}

View File

@ -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

View File

@ -1,3 +1,28 @@
2001-02-19 Angus Leeming <a.leeming@ic.ac.uk>
* insetcommand.h:
* inseterror.h:
* insetgraphics.C: change name of "hide" signal to "hideDialog",
consistent with InsetTabular.
2001-02-19 Juergen Vigna <jug@sad.it>
* 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 <jug@sad.it>
* 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 <larsbj@lyx.org>
* insettext.C (textWidth): constify local var

View File

@ -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 {

View File

@ -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<void> hide;
Signal0<void> hideDialog;
private:
///
InsetCommandParams p_;

View File

@ -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<void> hide;
Signal0<void> hideDialog;
private:
///
string contents;

View File

@ -176,7 +176,7 @@ InsetGraphics::InsetGraphics()
InsetGraphics::~InsetGraphics()
{
// Emits the hide signal to the dialog connected (if any)
hide();
hideDialog();
}
char const *

View File

@ -100,7 +100,8 @@ public:
/** This signal is connected by our dialog and called when the inset
is deleted.
*/
Signal0 <void> hide;
Signal0 <void> hideDialog;
private:
/// Update the inset after parameter change.
void updateInset() const;

View File

@ -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<InsetTabular *>(this);
bv->owner()->getDialogs()->updateTabular(inset);
oldcell = actcell;
InsetTabular * inset = const_cast<InsetTabular *>(this);
bv->owner()->getDialogs()->updateTabular(inset);
oldcell = actcell;
}
}

View File

@ -178,8 +178,8 @@ public:
// Public structures and variables
///
LyXTabular * tabular;
///
Signal0<void> hideDialog;
///
Signal0<void> hideDialog;
private:
///
@ -272,6 +272,8 @@ private:
///
mutable int actrow;
///
mutable int first_visible_cell;
///
bool no_selection;
///
bool no_draw;

View File

@ -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;

View File

@ -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;

View File

@ -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
{