mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-27 06:19:36 +00:00
Various fixes to Tabular, InsetTabular and InsetText. Fixed left border for
multicolumn cells, fixed repaint and recalc issues of insets, fixed scrolling of large tabulars, ADDED settings of fonts on selections, more minor stuff I cannot remember right now, more to follow. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2027 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
6b971d39b2
commit
4bcf99c809
@ -1,3 +1,26 @@
|
||||
2001-05-28 Juergen Vigna <jug@sad.it>
|
||||
|
||||
* text.C (SetHeightOfRow): added the update() call again as it is
|
||||
needed to initialize inset dimensions!
|
||||
|
||||
2001-05-16 Juergen Vigna <jug@sad.it>
|
||||
|
||||
* text2.C (SetCharFont): Add new function with BufferView * and
|
||||
bool toggleall parameters for setting insets internal fonts.
|
||||
(SetFont): Freeze the undo as we may change fonts in Insets and
|
||||
all this change should be inside only one Undo!
|
||||
|
||||
* bufferview_funcs.C (ToggleAndShow): fixed this functions for
|
||||
setting font's in insets as for them we have the SetFont function!
|
||||
|
||||
2001-05-15 Juergen Vigna <jug@sad.it>
|
||||
|
||||
* text2.C (ClearSelection): to be sure we REALLY don't have any
|
||||
selection anymore!
|
||||
|
||||
* tabular.C (TeXCellPreamble): fixed the left border problem for
|
||||
multicolumn cells.
|
||||
|
||||
2001-05-27 Dekel Tsur <dekelts@tau.ac.il>
|
||||
|
||||
* LaTeX.C (deplog): Make sure that the main .tex file is in the
|
||||
|
@ -245,6 +245,10 @@ string const CurrentState(BufferView * bv)
|
||||
void ToggleAndShow(BufferView * bv, LyXFont const & font, bool toggleall)
|
||||
{
|
||||
if (bv->available()) {
|
||||
if (bv->theLockingInset()) {
|
||||
bv->theLockingInset()->SetFont(bv, font, toggleall);
|
||||
return;
|
||||
}
|
||||
LyXText * text = bv->getLyXText();
|
||||
|
||||
bv->hideCursor();
|
||||
@ -254,7 +258,8 @@ void ToggleAndShow(BufferView * bv, LyXFont const & font, bool toggleall)
|
||||
|
||||
if (font.language() != ignore_language ||
|
||||
font.latex() != LyXFont::IGNORE ||
|
||||
font.number() != LyXFont::IGNORE) {
|
||||
font.number() != LyXFont::IGNORE)
|
||||
{
|
||||
LyXCursor & cursor = text->cursor;
|
||||
text->ComputeBidiTables(bv->buffer(), cursor.row());
|
||||
if (cursor.boundary() !=
|
||||
|
@ -1,3 +1,21 @@
|
||||
2001-05-28 Juergen Vigna <jug@sad.it>
|
||||
|
||||
* insettext.C (resizeLyXText): clear LyXText ONLY if we don't have
|
||||
a endless-width inset (maxWidth < 0).
|
||||
(Edit): change language only if not equal.
|
||||
|
||||
* insettabular.C (resetPos): call UpdateLocal only on REAL scroll!
|
||||
|
||||
* insettext.C (draw): fixed draw/clear of InsetText-Frame
|
||||
|
||||
2001-05-16 Juergen Vigna <jug@sad.it>
|
||||
|
||||
* insettext.C (selectAll): added
|
||||
(clearSelection): added
|
||||
|
||||
* insettabular.C (SetFont): now we may set a font on a whole selection!
|
||||
(getSelection): added helper function.
|
||||
|
||||
2001-05-27 Dekel Tsur <dekelts@tau.ac.il>
|
||||
|
||||
* insetcite.C (Ascii): Add method.
|
||||
|
@ -149,7 +149,7 @@ void UpdatableInset::draw(BufferView *, LyXFont const &,
|
||||
}
|
||||
|
||||
|
||||
void UpdatableInset::SetFont(BufferView *, LyXFont const &, bool )
|
||||
void UpdatableInset::SetFont(BufferView *, LyXFont const &, bool, bool )
|
||||
{}
|
||||
|
||||
|
||||
|
@ -442,10 +442,10 @@ UpdatableInset * InsetCollapsable::GetFirstLockingInsetOfType(Inset::Code c)
|
||||
}
|
||||
|
||||
|
||||
void InsetCollapsable::SetFont(BufferView * bv,
|
||||
LyXFont const & font, bool toggleall)
|
||||
void InsetCollapsable::SetFont(BufferView * bv, LyXFont const & font,
|
||||
bool toggleall, bool selectall)
|
||||
{
|
||||
inset.SetFont(bv, font, toggleall);
|
||||
inset.SetFont(bv, font, toggleall, selectall);
|
||||
}
|
||||
|
||||
|
||||
|
@ -109,7 +109,8 @@ public:
|
||||
///
|
||||
UpdatableInset * GetFirstLockingInsetOfType(Inset::Code);
|
||||
///
|
||||
void SetFont(BufferView *, LyXFont const &, bool toggleall = false);
|
||||
void SetFont(BufferView *, LyXFont const &, bool toggleall = false,
|
||||
bool selectall = false);
|
||||
///
|
||||
void setLabel(string const & l) { label = l; }
|
||||
///
|
||||
|
@ -60,8 +60,11 @@ string const InsetERT::EditMessage() const
|
||||
}
|
||||
|
||||
|
||||
void InsetERT::SetFont(BufferView *, LyXFont const &, bool)
|
||||
void InsetERT::SetFont(BufferView *, LyXFont const &, bool, bool selectall)
|
||||
{
|
||||
// if selectall is activated then the fontchange was an outside general
|
||||
// fontchange and this messages is not needed
|
||||
if (!selectall)
|
||||
WriteAlert(_("Impossible Operation!"),
|
||||
_("Not permitted to change font-types inside ERT-insets!"),
|
||||
_("Sorry."));
|
||||
|
@ -38,7 +38,8 @@ public:
|
||||
///
|
||||
bool InsertInset(BufferView *, Inset *) { return false; }
|
||||
///
|
||||
void SetFont(BufferView *, LyXFont const &, bool toggleall = false);
|
||||
void SetFont(BufferView *, LyXFont const &, bool toggleall = false,
|
||||
bool selectall = false);
|
||||
///
|
||||
void Edit(BufferView *, int, int, unsigned int);
|
||||
};
|
||||
|
@ -166,9 +166,6 @@ void InsetMinipage::Read(Buffer const * buf, LyXLex & lex)
|
||||
if (width_.empty())
|
||||
width_ = lex.GetString() + "%";
|
||||
token = string();
|
||||
} else {
|
||||
lyxerr << "InsetMinipage::Read: Missing 'widthp_'-tag!"
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
if (!token.empty())
|
||||
|
@ -223,10 +223,13 @@ void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline,
|
||||
{
|
||||
if (nodraw())
|
||||
return;
|
||||
if (bv->text->status == LyXText::CHANGED_IN_DRAW)
|
||||
return;
|
||||
|
||||
// lyxerr << "InsetTabular::draw(" << need_update << ")\n";
|
||||
#if 0
|
||||
if (need_update == INIT) {
|
||||
if (calculate_dimensions_of_cells(bv, font, true))
|
||||
bv->text->status = LyXText::CHANGED_IN_DRAW;
|
||||
need_update = FULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
Painter & pain = bv->painter();
|
||||
int i;
|
||||
@ -346,8 +349,10 @@ void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline,
|
||||
float cx = dx;
|
||||
//cx = dx = nx + tabular->GetBeginningOfTextInCell(cell);
|
||||
tabular->GetCellInset(cell)->draw(bv,font,baseline, dx, false);
|
||||
#if 0
|
||||
if (bv->text->status == LyXText::CHANGED_IN_DRAW)
|
||||
return;
|
||||
#endif
|
||||
// clear only if we didn't have a change
|
||||
if (need_update == CELL) {
|
||||
// clear before the inset
|
||||
@ -371,11 +376,16 @@ void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline,
|
||||
}
|
||||
x -= ADD_TO_TABULAR_WIDTH;
|
||||
x += width(bv, font);
|
||||
if (bv->text->status == LyXText::CHANGED_IN_DRAW)
|
||||
if (bv->text->status == LyXText::CHANGED_IN_DRAW) {
|
||||
int i=0;
|
||||
for(Inset * inset=owner();inset;++i)
|
||||
inset = inset->owner();
|
||||
if (calculate_dimensions_of_cells(bv, font, false))
|
||||
need_update = INIT;
|
||||
else
|
||||
} else {
|
||||
need_update = NONE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void InsetTabular::DrawCellLines(Painter & pain, int x, int baseline,
|
||||
@ -772,6 +782,8 @@ InsetTabular::LocalDispatch(BufferView * bv,
|
||||
case LFUN_SHIFT_TAB:
|
||||
case LFUN_TAB:
|
||||
{
|
||||
if (GetFirstLockingInsetOfType(Inset::TABULAR_CODE))
|
||||
break;
|
||||
HideInsetCursor(bv);
|
||||
if (the_locking_inset) {
|
||||
UnlockInsetInInset(bv, the_locking_inset);
|
||||
@ -1276,16 +1288,17 @@ void InsetTabular::resetPos(BufferView * bv) const
|
||||
} else if (the_locking_inset &&
|
||||
(tabular->GetWidthOfColumn(actcell) > bv->workWidth()-20)) {
|
||||
int xx = cursor.x() - offset + bv->text->GetRealCursorX(bv);
|
||||
if (xx > (bv->workWidth()-20))
|
||||
if (xx > (bv->workWidth()-20)) {
|
||||
scroll(bv, -(xx - bv->workWidth() + 60));
|
||||
else if (xx < 20) {
|
||||
UpdateLocal(bv, FULL, false);
|
||||
} else if (xx < 20) {
|
||||
if (xx < 0)
|
||||
xx = -xx + 60;
|
||||
else
|
||||
xx = 60;
|
||||
scroll(bv, xx);
|
||||
}
|
||||
UpdateLocal(bv, FULL, false);
|
||||
}
|
||||
} else if ((cursor.x() - offset) > 20 &&
|
||||
(cursor.x() - offset + tabular->GetWidthOfColumn(actcell))
|
||||
> (bv->workWidth() - 20)) {
|
||||
@ -1447,8 +1460,36 @@ bool InsetTabular::Delete()
|
||||
}
|
||||
|
||||
|
||||
void InsetTabular::SetFont(BufferView * bv, LyXFont const & font, bool tall)
|
||||
void InsetTabular::SetFont(BufferView * bv, LyXFont const & font, bool tall,
|
||||
bool selectall)
|
||||
{
|
||||
if (selectall) {
|
||||
sel_cell_start = 0;
|
||||
sel_cell_end = tabular->GetNumberOfCells() - 1;
|
||||
}
|
||||
if (hasSelection()) {
|
||||
bool frozen;
|
||||
bv->text->SetUndo(bv->buffer(), Undo::EDIT,
|
||||
bv->text->cursor.par()->previous(),
|
||||
bv->text->cursor.par()->next());
|
||||
frozen = bv->text->undo_frozen;
|
||||
if (!frozen)
|
||||
bv->text->FreezeUndo();
|
||||
// apply the fontchange on the whole selection
|
||||
int sel_row_start;
|
||||
int sel_row_end;
|
||||
int sel_col_start;
|
||||
int sel_col_end;
|
||||
getSelection(sel_row_start, sel_row_end, sel_col_start, sel_col_end);
|
||||
for(int i=sel_row_start; i <= sel_row_end; ++i) {
|
||||
for(int j=sel_col_start; j <= sel_col_end; ++j) {
|
||||
tabular->GetCellInset(i, j)->SetFont(bv, font, tall, true);
|
||||
}
|
||||
}
|
||||
if (!frozen)
|
||||
bv->text->UnFreezeUndo();
|
||||
UpdateLocal(bv, INIT, true);
|
||||
}
|
||||
if (the_locking_inset)
|
||||
the_locking_inset->SetFont(bv, font, tall);
|
||||
}
|
||||
@ -1524,23 +1565,7 @@ void InsetTabular::TabularFeatures(BufferView * bv,
|
||||
break;
|
||||
}
|
||||
if (hasSelection()) {
|
||||
sel_col_start = tabular->column_of_cell(sel_cell_start);
|
||||
sel_col_end = tabular->column_of_cell(sel_cell_end);
|
||||
if (sel_col_start > sel_col_end) {
|
||||
sel_col_end = sel_col_start;
|
||||
sel_col_start = tabular->column_of_cell(sel_cell_end);
|
||||
} else {
|
||||
sel_col_end = tabular->right_column_of_cell(sel_cell_end);
|
||||
}
|
||||
|
||||
sel_row_start = tabular->row_of_cell(sel_cell_start);
|
||||
sel_row_end = tabular->row_of_cell(sel_cell_end);
|
||||
if (sel_row_start > sel_row_end) {
|
||||
//int tmp = sel_row_start;
|
||||
//sel_row_start = sel_row_end;
|
||||
//sel_row_end = tmp;
|
||||
swap(sel_row_start, sel_row_end);
|
||||
}
|
||||
getSelection(sel_row_start, sel_row_end, sel_col_start, sel_col_end);
|
||||
} else {
|
||||
sel_col_start = sel_col_end = tabular->column_of_cell(actcell);
|
||||
sel_row_start = sel_row_end = tabular->row_of_cell(actcell);
|
||||
@ -1952,14 +1977,7 @@ LyXFunc::func_status InsetTabular::getStatus(string const & what) const
|
||||
bool flag = true;
|
||||
|
||||
if (hasSelection()) {
|
||||
sel_row_start = tabular->row_of_cell(sel_cell_start);
|
||||
sel_row_end = tabular->row_of_cell(sel_cell_end);
|
||||
if (sel_row_start > sel_row_end) {
|
||||
//int tmp = sel_row_start;
|
||||
//sel_row_start = sel_row_end;
|
||||
//sel_row_end = tmp;
|
||||
swap(sel_row_start, sel_row_end);
|
||||
}
|
||||
getSelection(sel_row_start, sel_row_end, dummy, dummy);
|
||||
} else {
|
||||
sel_row_start = sel_row_end = tabular->row_of_cell(actcell);
|
||||
}
|
||||
@ -2309,6 +2327,22 @@ bool InsetTabular::doClearArea() const
|
||||
{
|
||||
return !locked || (need_update & (FULL|INIT));
|
||||
}
|
||||
|
||||
void InsetTabular::getSelection(int & srow, int & erow, int & scol, int & ecol) const
|
||||
{
|
||||
srow = tabular->row_of_cell(sel_cell_start);
|
||||
erow = tabular->row_of_cell(sel_cell_end);
|
||||
if (srow > erow)
|
||||
swap(srow, erow);
|
||||
|
||||
scol = tabular->column_of_cell(sel_cell_start);
|
||||
ecol = tabular->column_of_cell(sel_cell_end);
|
||||
if (scol > ecol)
|
||||
swap(scol, ecol);
|
||||
else
|
||||
ecol = tabular->right_column_of_cell(sel_cell_end);
|
||||
}
|
||||
|
||||
/* Emacs:
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
|
@ -160,7 +160,8 @@ public:
|
||||
///
|
||||
int GetActCell() const { return actcell; }
|
||||
///
|
||||
void SetFont(BufferView *, LyXFont const &, bool toggleall = false);
|
||||
void SetFont(BufferView *, LyXFont const &, bool toggleall = false,
|
||||
bool selectall = false);
|
||||
///
|
||||
int getMaxWidth(BufferView *, UpdatableInset const *) const;
|
||||
///
|
||||
@ -265,6 +266,8 @@ private:
|
||||
bool cutSelection();
|
||||
///
|
||||
bool isRightToLeft(BufferView *);
|
||||
///
|
||||
void getSelection(int & scol, int & ecol, int & srow, int & erow) const;
|
||||
|
||||
//
|
||||
// Private structures and variables
|
||||
|
@ -92,7 +92,7 @@ void InsetText::init(InsetText const * ins)
|
||||
insetDescent = 0;
|
||||
insetWidth = 0;
|
||||
the_locking_inset = 0;
|
||||
interline_space = 1;
|
||||
old_max_width = 0;
|
||||
no_selection = false;
|
||||
need_update = INIT;
|
||||
drawTextXOffset = 0;
|
||||
@ -259,6 +259,8 @@ void InsetText::draw(BufferView * bv, LyXFont const & f,
|
||||
x += width(bv, f);
|
||||
if (!cleared && (need_update & CLEAR_FRAME))
|
||||
clearFrame(pain, cleared);
|
||||
else if (cleared)
|
||||
frame_is_visible = false;
|
||||
need_update = NONE;
|
||||
return;
|
||||
}
|
||||
@ -270,10 +272,12 @@ void InsetText::draw(BufferView * bv, LyXFont const & f,
|
||||
if (!owner())
|
||||
x += static_cast<float>(scroll());
|
||||
#endif
|
||||
#if 0
|
||||
// update insetWidth and insetHeight with dummy calls
|
||||
(void)ascent(bv, f);
|
||||
(void)descent(bv, f);
|
||||
(void)width(bv, f);
|
||||
#endif
|
||||
|
||||
// if top_x differs we have a rule down and we don't have to clear anything
|
||||
if (!cleared && (top_x == int(x)) &&
|
||||
@ -296,14 +300,25 @@ void InsetText::draw(BufferView * bv, LyXFont const & f,
|
||||
cleared = true;
|
||||
need_update = FULL;
|
||||
}
|
||||
if (cleared)
|
||||
frame_is_visible = false;
|
||||
|
||||
if (!cleared && (need_update == NONE))
|
||||
return;
|
||||
|
||||
if (top_x != int(x)) {
|
||||
need_update |= INIT;
|
||||
top_x = int(x);
|
||||
if ((getMaxWidth(bv, this) > 0) && (TEXT(bv)->width != old_max_width)){
|
||||
resizeLyXText(bv);
|
||||
need_update |= FULL;
|
||||
old_max_width = TEXT(bv)->width;
|
||||
bv->text->status = LyXText::CHANGED_IN_DRAW;
|
||||
}
|
||||
top_x = int(x);
|
||||
#if 1
|
||||
cleared = true;
|
||||
#else
|
||||
return;
|
||||
#endif
|
||||
}
|
||||
|
||||
// lyxerr << "InsetText::draw[" << this << "](" << need_update << ":" << int(x) << ":" << top_x << ")\n";
|
||||
@ -525,8 +540,10 @@ void InsetText::Edit(BufferView * bv, int x, int y, unsigned int button)
|
||||
UpdateLocal(bv, CURSOR, false);
|
||||
|
||||
// If the inset is empty set the language of the current font to the
|
||||
// language to the surronding text.
|
||||
if (par->size() == 0 && !par->next()) {
|
||||
// language to the surronding text (if different).
|
||||
if (par->size() == 0 && !par->next() &&
|
||||
bv->getParentLanguage(this) != TEXT(bv)->current_font.language())
|
||||
{
|
||||
LyXFont font(LyXFont::ALL_IGNORE);
|
||||
font.setLanguage(bv->getParentLanguage(this));
|
||||
SetFont(bv, font, false);
|
||||
@ -543,12 +560,16 @@ void InsetText::InsetUnlock(BufferView * bv)
|
||||
HideInsetCursor(bv);
|
||||
no_selection = false;
|
||||
locked = false;
|
||||
UpdateLocal(bv, CLEAR_FRAME|CURSOR, false);
|
||||
if (owner())
|
||||
int code = CURSOR|CLEAR_FRAME;
|
||||
if (TEXT(bv)->selection) {
|
||||
TEXT(bv)->ClearSelection(bv);
|
||||
code = FULL;
|
||||
} else if (owner())
|
||||
bv->owner()->setLayout(owner()->getLyXText(bv)
|
||||
->cursor.par()->GetLayout());
|
||||
else
|
||||
bv->owner()->setLayout(bv->text->cursor.par()->GetLayout());
|
||||
UpdateLocal(bv, code, false);
|
||||
}
|
||||
|
||||
|
||||
@ -1370,15 +1391,23 @@ std::vector<string> const InsetText::getLabelList() const
|
||||
}
|
||||
|
||||
|
||||
void InsetText::SetFont(BufferView * bv, LyXFont const & font, bool toggleall)
|
||||
void InsetText::SetFont(BufferView * bv, LyXFont const & font, bool toggleall,
|
||||
bool selectall)
|
||||
{
|
||||
if (TEXT(bv)->selection) {
|
||||
bv->text->SetUndo(bv->buffer(), Undo::EDIT,
|
||||
bv->text->cursor.par()->previous(),
|
||||
bv->text->cursor.par()->next());
|
||||
}
|
||||
if (selectall)
|
||||
selectAll(bv);
|
||||
TEXT(bv)->SetFont(bv, font, toggleall);
|
||||
if (selectall)
|
||||
TEXT(bv)->ClearSelection(bv);
|
||||
bv->fitCursor(TEXT(bv));
|
||||
if (selectall || TEXT(bv)->selection)
|
||||
UpdateLocal(bv, FULL, true);
|
||||
else
|
||||
UpdateLocal(bv, CURSOR_PAR, true);
|
||||
}
|
||||
|
||||
@ -1612,7 +1641,9 @@ void InsetText::deleteLyXText(BufferView * bv, bool recursive) const
|
||||
|
||||
void InsetText::resizeLyXText(BufferView * bv) const
|
||||
{
|
||||
if (!par->next() && !par->size()) // resize not neccessary!
|
||||
if (!par->next() && !par->size()) // no data, resize not neccessary!
|
||||
return;
|
||||
if (getMaxWidth(bv, this) < 0) // one endless line, no resize necessary
|
||||
return;
|
||||
if ((cache.find(bv) == cache.end()) || !cache[bv])
|
||||
return;
|
||||
@ -1716,6 +1747,20 @@ bool InsetText::doClearArea() const
|
||||
{
|
||||
return !locked || (need_update & (FULL|INIT));
|
||||
}
|
||||
|
||||
void InsetText::selectAll(BufferView * bv)
|
||||
{
|
||||
TEXT(bv)->CursorTop(bv);
|
||||
TEXT(bv)->sel_cursor = TEXT(bv)->cursor;
|
||||
TEXT(bv)->CursorBottom(bv);
|
||||
TEXT(bv)->SetSelection(bv);
|
||||
}
|
||||
|
||||
void InsetText::clearSelection(BufferView * bv)
|
||||
{
|
||||
TEXT(bv)->ClearSelection(bv);
|
||||
}
|
||||
|
||||
/* Emacs:
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
|
@ -152,7 +152,8 @@ public:
|
||||
///
|
||||
UpdatableInset * GetFirstLockingInsetOfType(Inset::Code);
|
||||
///
|
||||
void SetFont(BufferView *, LyXFont const &, bool toggleall = false);
|
||||
void SetFont(BufferView *, LyXFont const &, bool toggleall = false,
|
||||
bool selectall = false);
|
||||
///
|
||||
int getMaxWidth(BufferView *, UpdatableInset const *) const;
|
||||
///
|
||||
@ -189,6 +190,10 @@ public:
|
||||
void scroll(BufferView *bv, int offset) const {
|
||||
UpdatableInset::scroll(bv, offset);
|
||||
}
|
||||
///
|
||||
void selectAll(BufferView *bv);
|
||||
///
|
||||
void clearSelection(BufferView *bv);
|
||||
|
||||
LyXParagraph * par;
|
||||
///
|
||||
@ -297,7 +302,7 @@ private:
|
||||
///
|
||||
mutable int inset_y;
|
||||
///
|
||||
int interline_space;
|
||||
mutable int old_max_width;
|
||||
///
|
||||
bool no_selection;
|
||||
///
|
||||
|
@ -336,7 +336,7 @@ public:
|
||||
int baseline, float & x, bool cleared) const;
|
||||
///
|
||||
virtual void SetFont(BufferView *, LyXFont const &,
|
||||
bool toggleall = false);
|
||||
bool toggleall = false, bool selectall = false);
|
||||
///
|
||||
virtual bool InsertInset(BufferView *, Inset *) { return false; }
|
||||
///
|
||||
|
@ -82,8 +82,10 @@ public:
|
||||
LyXParagraph::size_type pos) const;
|
||||
///
|
||||
void SetCharFont(Buffer const *, LyXParagraph * par,
|
||||
LyXParagraph::size_type pos, LyXFont const & font);
|
||||
void SetCharFont(BufferView *, LyXParagraph * par,
|
||||
LyXParagraph::size_type pos,
|
||||
LyXFont const & font);
|
||||
LyXFont const & font, bool toggleall);
|
||||
/// returns a pointer to the very first LyXParagraph
|
||||
LyXParagraph * FirstParagraph() const;
|
||||
|
||||
@ -218,7 +220,7 @@ public:
|
||||
///
|
||||
mutable LyXCursor sel_cursor;
|
||||
///
|
||||
LyXCursor sel_start_cursor;
|
||||
mutable LyXCursor sel_start_cursor;
|
||||
///
|
||||
mutable LyXCursor sel_end_cursor;
|
||||
/// needed for the toggling
|
||||
|
@ -1967,8 +1967,13 @@ int LyXTabular::TeXCellPreamble(ostream & os, int cell) const
|
||||
if (!cellinfo_of_cell(cell)->align_special.empty()) {
|
||||
os << cellinfo_of_cell(cell)->align_special << "}{";
|
||||
} else {
|
||||
if (LeftLine(cell))
|
||||
if (LeftLine(cell) &&
|
||||
(IsFirstCellInRow(cell) ||
|
||||
(!IsMultiColumn(cell-1) && !LeftLine(cell, true) &&
|
||||
!RightLine(cell-1, true))))
|
||||
{
|
||||
os << '|';
|
||||
}
|
||||
if (!GetPWidth(cell).empty()) {
|
||||
switch (GetVAlignment(cell)) {
|
||||
case LYX_VALIGN_TOP:
|
||||
@ -2517,7 +2522,7 @@ InsetText * LyXTabular::GetCellInset(int cell) const
|
||||
|
||||
InsetText * LyXTabular::GetCellInset(int row, int column) const
|
||||
{
|
||||
return GetCellInset(GetCellNumber(row, column));
|
||||
return & cell_info[row][column].inset;
|
||||
}
|
||||
|
||||
|
||||
|
@ -157,7 +157,9 @@ int LyXText::SingleWidth(BufferView * bview, LyXParagraph * par,
|
||||
} else if (c == LyXParagraph::META_INSET) {
|
||||
Inset * tmpinset = par->GetInset(pos);
|
||||
if (tmpinset) {
|
||||
#if 0 // seems not to be needed, but ...
|
||||
tmpinset->update(bview, font);
|
||||
#endif
|
||||
return tmpinset->width(bview, font);
|
||||
} else
|
||||
return 0;
|
||||
@ -428,7 +430,7 @@ void LyXText::draw(BufferView * bview, Row const * row,
|
||||
if (c == LyXParagraph::META_INSET) {
|
||||
Inset * tmpinset = row->par()->GetInset(pos);
|
||||
if (tmpinset) {
|
||||
// tmpinset->update(bview, font, false);
|
||||
tmpinset->update(bview, font, false);
|
||||
tmpinset->draw(bview, font, offset+row->baseline(), x,
|
||||
cleared);
|
||||
#ifdef SEEMS_TO_BE_NOT_NEEDED
|
||||
@ -1217,7 +1219,9 @@ void LyXText::SetHeightOfRow(BufferView * bview, Row * row_ptr) const
|
||||
tmpfont = GetFont(bview->buffer(), row_ptr->par(), pos);
|
||||
tmpinset = row_ptr->par()->GetInset(pos);
|
||||
if (tmpinset) {
|
||||
// tmpinset->update(bview, tmpfont);
|
||||
#if 1 // this is needed for deep update on initialitation
|
||||
tmpinset->update(bview, tmpfont);
|
||||
#endif
|
||||
asc = tmpinset->ascent(bview, tmpfont);
|
||||
desc = tmpinset->descent(bview, tmpfont);
|
||||
maxwidth += tmpinset->width(bview, tmpfont);
|
||||
|
67
src/text2.C
67
src/text2.C
@ -138,6 +138,7 @@ void LyXText::init(BufferView * bview)
|
||||
SetCursorIntern(bview, firstrow->par(), 0);
|
||||
sel_cursor = cursor;
|
||||
#if 0
|
||||
printf("TP = %x\n",inset_owner->owner());
|
||||
// Dump all rowinformation:
|
||||
Row * tmprow = firstrow;
|
||||
lyxerr << "Width = " << width << endl;
|
||||
@ -247,14 +248,63 @@ LyXFont const LyXText::GetFont(Buffer const * buf, LyXParagraph * par,
|
||||
}
|
||||
|
||||
|
||||
void LyXText::SetCharFont(BufferView * bv, LyXParagraph * par,
|
||||
LyXParagraph::size_type pos, LyXFont const & fnt,
|
||||
bool toggleall)
|
||||
{
|
||||
Buffer const * buf = bv->buffer();
|
||||
LyXFont font = GetFont(buf, par, pos);
|
||||
font.update(fnt, buf->params.language, toggleall);
|
||||
// Let the insets convert their font
|
||||
if (par->GetChar(pos) == LyXParagraph::META_INSET) {
|
||||
Inset * inset = par->GetInset(pos);
|
||||
if (inset) {
|
||||
if (inset->Editable()==Inset::HIGHLY_EDITABLE) {
|
||||
UpdatableInset * uinset = static_cast<UpdatableInset *>(inset);
|
||||
uinset->SetFont(bv, fnt, toggleall, true);
|
||||
}
|
||||
font = inset->ConvertFont(font);
|
||||
}
|
||||
}
|
||||
|
||||
LyXLayout const & layout =
|
||||
textclasslist.Style(buf->params.textclass,
|
||||
par->GetLayout());
|
||||
|
||||
// Get concrete layout font to reduce against
|
||||
LyXFont layoutfont;
|
||||
|
||||
if (pos < BeginningOfMainBody(buf, par))
|
||||
layoutfont = layout.labelfont;
|
||||
else
|
||||
layoutfont = layout.font;
|
||||
|
||||
// Realize against environment font information
|
||||
if (par->GetDepth()){
|
||||
LyXParagraph * tp = par;
|
||||
while (!layoutfont.resolved() && tp && tp->GetDepth()) {
|
||||
tp = tp->DepthHook(tp->GetDepth()-1);
|
||||
if (tp)
|
||||
layoutfont.realize(textclasslist.
|
||||
Style(buf->params.textclass,
|
||||
tp->GetLayout()).font);
|
||||
}
|
||||
}
|
||||
|
||||
layoutfont.realize(textclasslist.TextClass(buf->params.textclass).defaultfont());
|
||||
|
||||
// Now, reduce font against full layout font
|
||||
font.reduce(layoutfont);
|
||||
|
||||
par->SetFont(pos, font);
|
||||
}
|
||||
|
||||
void LyXText::SetCharFont(Buffer const * buf, LyXParagraph * par,
|
||||
LyXParagraph::size_type pos,
|
||||
LyXFont const & fnt)
|
||||
LyXParagraph::size_type pos, LyXFont const & fnt)
|
||||
{
|
||||
LyXFont font(fnt);
|
||||
// Let the insets convert their font
|
||||
if (par->GetChar(pos) == LyXParagraph::META_INSET) {
|
||||
if (par->GetInset(pos))
|
||||
font = par->GetInset(pos)->ConvertFont(font);
|
||||
}
|
||||
|
||||
@ -676,25 +726,21 @@ void LyXText::SetFont(BufferView * bview, LyXFont const & font, bool toggleall)
|
||||
SetUndo(bview->buffer(), Undo::EDIT,
|
||||
sel_start_cursor.par()->previous(),
|
||||
sel_end_cursor.par()->next());
|
||||
FreezeUndo();
|
||||
cursor = sel_start_cursor;
|
||||
while (cursor.par() != sel_end_cursor.par() ||
|
||||
(cursor.pos() < sel_end_cursor.pos())) {
|
||||
if (cursor.pos() < cursor.par()->size()) {
|
||||
// an open footnote should behave
|
||||
// like a closed one
|
||||
LyXFont newfont = GetFont(bview->buffer(),
|
||||
cursor.par(), cursor.pos());
|
||||
newfont.update(font,
|
||||
bview->buffer()->params.language,
|
||||
toggleall);
|
||||
SetCharFont(bview->buffer(),
|
||||
cursor.par(), cursor.pos(), newfont);
|
||||
SetCharFont(bview, cursor.par(), cursor.pos(), font, toggleall);
|
||||
cursor.pos(cursor.pos() + 1);
|
||||
} else {
|
||||
cursor.pos(0);
|
||||
cursor.par(cursor.par()->next());
|
||||
}
|
||||
}
|
||||
UnFreezeUndo();
|
||||
|
||||
RedoParagraphs(bview, sel_start_cursor, sel_end_cursor.par()->next());
|
||||
|
||||
@ -971,6 +1017,7 @@ void LyXText::ClearSelection(BufferView * /*bview*/) const
|
||||
{
|
||||
selection = false;
|
||||
mark_set = false;
|
||||
sel_end_cursor = sel_start_cursor = cursor;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user