two-phase-drawing for InsetText & InsetTabular

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7312 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2003-07-18 07:47:07 +00:00
parent 8d2394b02c
commit 99b64f351e
30 changed files with 217 additions and 192 deletions

View File

@ -1,3 +1,14 @@
2003-07-18 André Pönitz <poenitz@gmx.net>
* lyxtext.h:
* metricsinfo.C:
* metricsinfo.h:
* rowpainter.C:
* text.C:
* text2.C:
* text3.C: two-phase drawing for InsetText and InsetTabular
some float -> int changes.
2003-07-18 Alfredo Braunstein <abraunst@libero.it> 2003-07-18 Alfredo Braunstein <abraunst@libero.it>
* lyx_main.C: fix a crash in batch mode if no files specified * lyx_main.C: fix a crash in batch mode if no files specified

View File

@ -1,4 +1,23 @@
2003-07-18 André Pönitz <poenitz@gmx.net>
* inset.[Ch]:
* insetbibitem.C:
* insetcollapsable.C:
* insetcommand.C:
* insetert.C:
* insetexternal.C:
* insetgraphics.[Ch]:
* insetlatexaccent.[Ch]:
* insetminipage.C:
* insetnewline.C:
* insetquotes.C:
* insetspace.C:
* insetspecialchar.C:
* insettabular.[Ch]:
* insettext.[Ch]:
* updatableinset.C: two-phase-drawing for InsetText & InsetTabular
2003-07-17 André Pönitz <poenitz@gmx.net> 2003-07-17 André Pönitz <poenitz@gmx.net>
* insetcollapsable.C: * insetcollapsable.C:

View File

@ -142,28 +142,19 @@ int Inset::latexTextWidth(BufferView * bv) const
} }
int Inset::ascent(BufferView * bv, LyXFont const & font) const int Inset::ascent() const
{ {
Dimension dim; return dim_.asc;
MetricsInfo mi(bv, font);
metrics(mi, dim);
return dim.ascent();
} }
int Inset::descent(BufferView * bv, LyXFont const & font) const int Inset::descent() const
{ {
Dimension dim; return dim_.des;
MetricsInfo mi(bv, font);
metrics(mi, dim);
return dim.descent();
} }
int Inset::width(BufferView * bv, LyXFont const & font) const int Inset::width() const
{ {
Dimension dim; return dim_.wid;
MetricsInfo mi(bv, font);
metrics(mi, dim);
return dim.width();
} }

View File

@ -17,6 +17,7 @@
#include "LColor.h" #include "LColor.h"
#include "insetbase.h" #include "insetbase.h"
#include "dimension.h"
#include "support/types.h" #include "support/types.h"
#include <vector> #include <vector>
@ -157,11 +158,11 @@ public:
/// ///
Inset(Inset const & in); Inset(Inset const & in);
/// ///
int ascent(BufferView *, LyXFont const &) const; int ascent() const;
/// ///
int descent(BufferView *, LyXFont const &) const; int descent() const;
/// ///
int width(BufferView *, LyXFont const &) const; int width() const;
/// what appears in the minibuffer when opening /// what appears in the minibuffer when opening
virtual string const editMessage() const; virtual string const editMessage() const;
/// ///
@ -331,6 +332,8 @@ protected:
unsigned int id_; unsigned int id_;
/// ///
static unsigned int inset_id; static unsigned int inset_id;
///
mutable Dimension dim_;
private: private:
/// ///

View File

@ -141,7 +141,8 @@ int bibitemMaxWidth(BufferView * bv, LyXFont const & font)
ParagraphList::iterator end = bv->buffer()->paragraphs.end(); ParagraphList::iterator end = bv->buffer()->paragraphs.end();
for (; it != end; ++it) { for (; it != end; ++it) {
if (it->bibitem()) { if (it->bibitem()) {
int const wx = it->bibitem()->width(bv, font); #warning metrics broken!
int const wx = it->bibitem()->width();
if (wx > w) if (wx > w)
w = wx; w = wx;
} }

View File

@ -129,13 +129,15 @@ int InsetCollapsable::height_collapsed() const
void InsetCollapsable::metrics(MetricsInfo & mi, Dimension & dim) const void InsetCollapsable::metrics(MetricsInfo & mi, Dimension & dim) const
{ {
//lyxerr << "InsetCollapsable::metrics: width: " << mi.base.textwidth << "\n";
dimension_collapsed(dim); dimension_collapsed(dim);
if (collapsed_) if (!collapsed_) {
return; Dimension insetdim;
Dimension insetdim; inset.metrics(mi, insetdim);
inset.metrics(mi, insetdim); dim.des += insetdim.height() + TEXT_TO_BOTTOM_OFFSET;
dim.des += insetdim.height() + TEXT_TO_BOTTOM_OFFSET; dim.wid = max(dim.wid, insetdim.wid);
dim.wid = max(dim.wid, insetdim.wid); }
dim_ = dim;
} }
@ -156,7 +158,7 @@ void InsetCollapsable::draw(PainterInfo & pi, int x, int y, bool inlined) const
Dimension dim_collapsed; Dimension dim_collapsed;
dimension_collapsed(dim_collapsed); dimension_collapsed(dim_collapsed);
int const aa = ascent(pi.base.bv, pi.base.font); int const aa = ascent();
button_length = dim_collapsed.width(); button_length = dim_collapsed.width();
button_top_y = -aa; button_top_y = -aa;
button_bottom_y = -aa + dim_collapsed.height(); button_bottom_y = -aa + dim_collapsed.height();
@ -180,8 +182,7 @@ void InsetCollapsable::draw(PainterInfo & pi, int x, int y, bool inlined) const
inset.draw(pi, x, y); inset.draw(pi, x, y);
} else { } else {
draw_collapsed(pi, old_x, bl); draw_collapsed(pi, old_x, bl);
int const yy = bl + dim_collapsed.descent() int const yy = bl + dim_collapsed.descent() + inset.ascent();
+ inset.ascent(pi.base.bv, pi.base.font);
inset.draw(pi, x, yy); inset.draw(pi, x, yy);
} }
} }
@ -221,10 +222,8 @@ void InsetCollapsable::insetUnlock(BufferView * bv)
FuncRequest InsetCollapsable::adjustCommand(FuncRequest const & cmd) FuncRequest InsetCollapsable::adjustCommand(FuncRequest const & cmd)
{ {
LyXFont font(LyXFont::ALL_SANE);
FuncRequest cmd1 = cmd; FuncRequest cmd1 = cmd;
cmd1.y = ascent(cmd.view(), font) + cmd.y - cmd1.y = ascent() + cmd.y - (height_collapsed() + inset.ascent());
(height_collapsed() + inset.ascent(cmd.view(), font));
return cmd1; return cmd1;
} }
@ -341,9 +340,7 @@ Inset::RESULT InsetCollapsable::localDispatch(FuncRequest const & cmd)
if (cmd.y <= button_bottom_y) { if (cmd.y <= button_bottom_y) {
cmd1.y = 0; cmd1.y = 0;
} else { } else {
LyXFont font(LyXFont::ALL_SANE); cmd1.y = ascent() + cmd.y - (height_collapsed() + inset.ascent());
cmd1.y = ascent(bv, font) + cmd.y -
(height_collapsed() + inset.ascent(bv, font));
} }
inset.localDispatch(cmd); inset.localDispatch(cmd);
} }
@ -465,8 +462,7 @@ void InsetCollapsable::deleteLyXText(BufferView * bv, bool recursive) const
void InsetCollapsable::resizeLyXText(BufferView * bv, bool force) const void InsetCollapsable::resizeLyXText(BufferView * bv, bool force) const
{ {
inset.resizeLyXText(bv, force); inset.resizeLyXText(bv, force);
LyXFont font(LyXFont::ALL_SANE); oldWidth = width();
oldWidth = width(bv, font);
} }

View File

@ -47,6 +47,7 @@ void InsetCommand::metrics(MetricsInfo & mi, Dimension & dim) const
editable() != NOT_EDITABLE); editable() != NOT_EDITABLE);
} }
button_.metrics(mi, dim); button_.metrics(mi, dim);
dim_ = dim;
} }

View File

@ -297,9 +297,9 @@ bool InsetERT::lfunMouseRelease(FuncRequest const & cmd)
(cmd.y >= button_top_y) && (cmd.y <= button_bottom_y)) { (cmd.y >= button_top_y) && (cmd.y <= button_bottom_y)) {
updateStatus(bv, true); updateStatus(bv, true);
} else { } else {
LyXFont font(LyXFont::ALL_SANE);
FuncRequest cmd1 = cmd; FuncRequest cmd1 = cmd;
cmd1.y = ascent(bv, font) + cmd.y - inset.ascent(bv, font); #warning metrics?
cmd1.y = ascent() + cmd.y - inset.ascent();
// inlined is special - the text appears above // inlined is special - the text appears above
// button_bottom_y // button_bottom_y
@ -554,6 +554,7 @@ void InsetERT::metrics(MetricsInfo & mi, Dimension & dim) const
inset.metrics(mi, dim); inset.metrics(mi, dim);
else else
InsetCollapsable::metrics(mi, dim); InsetCollapsable::metrics(mi, dim);
dim_ = dim;
} }

View File

@ -170,6 +170,7 @@ dispatch_result InsetExternal::localDispatch(FuncRequest const & cmd)
void InsetExternal::metrics(MetricsInfo & mi, Dimension & dim) const void InsetExternal::metrics(MetricsInfo & mi, Dimension & dim) const
{ {
renderer_->metrics(mi, dim); renderer_->metrics(mi, dim);
dim_ = dim;
} }

View File

@ -204,6 +204,7 @@ dispatch_result InsetGraphics::localDispatch(FuncRequest const & cmd)
void InsetGraphics::metrics(MetricsInfo & mi, Dimension & dim) const void InsetGraphics::metrics(MetricsInfo & mi, Dimension & dim) const
{ {
graphic_->metrics(mi, dim); graphic_->metrics(mi, dim);
dim_ = dim;
} }

View File

@ -133,7 +133,6 @@ private:
boost::scoped_ptr<PreviewImpl> const preview_; boost::scoped_ptr<PreviewImpl> const preview_;
/// cache /// cache
mutable Dimension dim_;
mutable bool set_label_; mutable bool set_label_;
mutable ButtonRenderer button_; mutable ButtonRenderer button_;
}; };

View File

@ -404,7 +404,8 @@ void InsetLatexAccent::draw(PainterInfo & pi, int x, int baseline) const
// closer to the top of the dot-less 'i' or 'j'. // closer to the top of the dot-less 'i' or 'j'.
char tmpic = ic; // store the ic when we char tmpic = ic; // store the ic when we
ic = 'x'; // calculates the ascent of ic = 'x'; // calculates the ascent of
int asc = ascent(bv, font); // the dot-less version (here: 'x') #warning metrics?
int asc = ascent(); // the dot-less version (here: 'x')
ic = tmpic; // set the orig ic back ic = tmpic; // set the orig ic back
y = baseline - asc; // update to new y coord. y = baseline - asc; // update to new y coord.
} }
@ -473,7 +474,7 @@ void InsetLatexAccent::draw(PainterInfo & pi, int x, int baseline) const
case CIRCLE: // circle case CIRCLE: // circle
{ {
LyXFont tmpf(font); LyXFont tmpf = font;
tmpf.decSize().decSize(); tmpf.decSize().decSize();
pi.pain.text(int(x2 - (font_metrics::rbearing(0xB0, tmpf) - font_metrics::lbearing(0xB0, tmpf)) / 2.0), pi.pain.text(int(x2 - (font_metrics::rbearing(0xB0, tmpf) - font_metrics::lbearing(0xB0, tmpf)) / 2.0),
int(baseline - font_metrics::ascent(ic, font) - font_metrics::descent(0xB0, tmpf) - (font_metrics::ascent(0xB0, tmpf) + font_metrics::descent(0xB0, tmpf)) / 3.0), int(baseline - font_metrics::ascent(ic, font) - font_metrics::descent(0xB0, tmpf) - (font_metrics::ascent(0xB0, tmpf) + font_metrics::descent(0xB0, tmpf)) / 3.0),

View File

@ -129,8 +129,6 @@ private:
bool plusdesc; bool plusdesc;
/// international char /// international char
mutable char ic; mutable char ic;
///
mutable Dimension dim_;
}; };

View File

@ -24,6 +24,7 @@
#include "lyxlex.h" #include "lyxlex.h"
#include "lyxtext.h" #include "lyxtext.h"
#include "Lsstream.h" #include "Lsstream.h"
#include "metricsinfo.h"
#include "frontends/LyXView.h" #include "frontends/LyXView.h"
#include "frontends/Dialogs.h" #include "frontends/Dialogs.h"
@ -220,7 +221,9 @@ void InsetMinipage::metrics(MetricsInfo & mi, Dimension & dim) const
dimension_collapsed(dim); dimension_collapsed(dim);
else { else {
Dimension d; Dimension d;
InsetCollapsable::metrics(mi, d); MetricsInfo m = mi;
m.base.textwidth = params_.width.inPixels(mi.base.textwidth);
InsetCollapsable::metrics(m, d);
switch (params_.pos) { switch (params_.pos) {
case top: case top:
dim.asc = d.asc; dim.asc = d.asc;
@ -237,6 +240,7 @@ void InsetMinipage::metrics(MetricsInfo & mi, Dimension & dim) const
} }
dim.wid = d.wid; dim.wid = d.wid;
} }
dim_ = dim;
} }
@ -347,7 +351,7 @@ void InsetMinipageMailer::string2params(string const & in,
return; return;
istringstream data(STRCONV(in)); istringstream data(STRCONV(in));
LyXLex lex(0,0); LyXLex lex(0, 0);
lex.setStream(data); lex.setStream(data);
if (lex.isOK()) { if (lex.isOK()) {

View File

@ -44,6 +44,7 @@ void InsetNewline::metrics(MetricsInfo & mi, Dimension & dim) const
dim.asc = font_metrics::maxAscent(font); dim.asc = font_metrics::maxAscent(font);
dim.des = font_metrics::maxDescent(font); dim.des = font_metrics::maxDescent(font);
dim.wid = font_metrics::width('n', font); dim.wid = font_metrics::width('n', font);
dim_ = dim;
} }

View File

@ -189,6 +189,7 @@ void InsetQuotes::metrics(MetricsInfo & mi, Dimension & dim) const
else else
dim.wid += font_metrics::width(',', font); dim.wid += font_metrics::width(',', font);
} }
dim_ = dim;
} }

View File

@ -71,12 +71,13 @@ void InsetSpace::metrics(MetricsInfo & mi, Dimension & dim) const
dim.wid = 10; dim.wid = 10;
break; break;
} }
dim_ = dim;
} }
void InsetSpace::draw(PainterInfo & pi, int x, int y) const void InsetSpace::draw(PainterInfo & pi, int x, int y) const
{ {
int const w = width(pi.base.bv, pi.base.font); int const w = width();
int const h = font_metrics::ascent('x', pi.base.font); int const h = font_metrics::ascent('x', pi.base.font);
int xp[4], yp[4]; int xp[4], yp[4];

View File

@ -56,6 +56,7 @@ void InsetSpecialChar::metrics(MetricsInfo & mi, Dimension & dim) const
dim.wid = font_metrics::width(s, font); dim.wid = font_metrics::width(s, font);
if (kind_ == HYPHENATION && dim.wid > 5) if (kind_ == HYPHENATION && dim.wid > 5)
dim.wid -= 2; // to make it look shorter dim.wid -= 2; // to make it look shorter
dim_ = dim;
} }

View File

@ -263,33 +263,18 @@ void InsetTabular::metrics(MetricsInfo & mi, Dimension & dim) const
Assert(0); Assert(0);
} }
calculate_dimensions_of_cells(mi.base.bv); calculate_dimensions_of_cells(mi);
//lyxerr << "InsetTabular::metrics, bv: " << mi.base.bv << endl;
for (int i = 0; i < tabular.getNumberOfCells(); ++i) {
LyXTabular::cellstruct * ci = tabular.cellinfo_of_cell(i);
int col = tabular.column_of_cell(i);
InsetText & cell = ci->inset;
cell.text_.bv_owner = mi.base.bv;
int wid = tabular.column_info[col].p_width.inPixels(mi.base.textwidth);
//lyxerr << " " << i << " - " << ci->width_of_cell << " - "
// << tabular.column_info[col].width_of_column << " - "
// << wid << " ";
MetricsInfo m = mi;
m.base.textwidth = wid;
Dimension d;
cell.metrics(m, d);
}
//lyxerr << endl;
dim.asc = tabular.getAscentOfRow(0); dim.asc = tabular.getAscentOfRow(0);
dim.des = tabular.getHeightOfTabular() - tabular.getAscentOfRow(0) + 1; dim.des = tabular.getHeightOfTabular() - tabular.getAscentOfRow(0) + 1;
dim.wid = tabular.getWidthOfTabular() + 2 * ADD_TO_TABULAR_WIDTH; dim.wid = tabular.getWidthOfTabular() + 2 * ADD_TO_TABULAR_WIDTH;
dim_ = dim;
} }
void InsetTabular::draw(PainterInfo & pi, int x, int y) const void InsetTabular::draw(PainterInfo & pi, int x, int y) const
{ {
lyxerr << "InsetTabular::draw: " << x << " " << y << "\n"; //lyxerr << "InsetTabular::draw: " << x << " " << y << "\n";
if (nodraw()) { if (nodraw()) {
need_update = FULL; need_update = FULL;
return; return;
@ -454,9 +439,6 @@ void InsetTabular::insetUnlock(BufferView * bv)
void InsetTabular::updateLocal(BufferView * bv, UpdateCodes what) const void InsetTabular::updateLocal(BufferView * bv, UpdateCodes what) const
{ {
lyxerr << "InsetTabular::updateLocal: " << what << "\n"; lyxerr << "InsetTabular::updateLocal: " << what << "\n";
if (what == INIT) {
calculate_dimensions_of_cells(bv);
}
if (!locked && what == CELL) if (!locked && what == CELL)
what = FULL; what = FULL;
if (need_update < what) // only set this if it has greater update if (need_update < what) // only set this if it has greater update
@ -1246,30 +1228,31 @@ void InsetTabular::validate(LaTeXFeatures & features) const
} }
void InsetTabular::calculate_dimensions_of_cells(BufferView * bv) const void InsetTabular::calculate_dimensions_of_cells(MetricsInfo & mi) const
{ {
// FIXME: since InsetText ignores this anyway, it doesn't #if 1
// matter what we pass it. Ugly
LyXFont font;
// if we have a locking_inset we should have to check only this cell for // if we have a locking_inset we should have to check only this cell for
// change so I'll try this to have a boost, but who knows ;) // change so I'll try this to have a boost, but who knows ;) (Jug?)
// This is _really_ important (André)
if (need_update != INIT && if (need_update != INIT &&
the_locking_inset == tabular.getCellInset(actcell)) { the_locking_inset == tabular.getCellInset(actcell)) {
int maxAsc = 0; int maxAsc = 0;
int maxDesc = 0; int maxDesc = 0;
for(int i = 0; i < tabular.columns(); ++i) { for (int j = 0; j < tabular.columns(); ++j) {
Dimension dim; Dimension dim;
MetricsInfo mi(bv, font); MetricsInfo m = mi;
tabular.getCellInset(actrow, i)->metrics(mi, dim); m.base.textwidth =
maxAsc = max(dim.asc, maxAsc); tabular.column_info[j].p_width.inPixels(mi.base.textwidth);
tabular.getCellInset(actrow, j)->metrics(m, dim);
maxAsc = max(dim.asc, maxAsc);
maxDesc = max(dim.des, maxDesc); maxDesc = max(dim.des, maxDesc);
} }
tabular.setWidthOfCell(actcell, the_locking_inset->width(bv, font)); tabular.setWidthOfCell(actcell, the_locking_inset->width());
tabular.setAscentOfRow(actrow, maxAsc + ADD_TO_HEIGHT); tabular.setAscentOfRow(actrow, maxAsc + ADD_TO_HEIGHT);
tabular.setDescentOfRow(actrow, maxDesc + ADD_TO_HEIGHT); tabular.setDescentOfRow(actrow, maxDesc + ADD_TO_HEIGHT);
return; return;
} }
#endif
int cell = -1; int cell = -1;
bool changed = false; bool changed = false;
@ -1281,17 +1264,19 @@ void InsetTabular::calculate_dimensions_of_cells(BufferView * bv) const
continue; continue;
++cell; ++cell;
Dimension dim; Dimension dim;
MetricsInfo mi(bv, font); MetricsInfo m = mi;
tabular.getCellInset(cell)->metrics(mi, dim); m.base.textwidth =
maxAsc = max(maxAsc, dim.asc); tabular.column_info[j].p_width.inPixels(mi.base.textwidth);
tabular.getCellInset(cell)->metrics(m, dim);
maxAsc = max(maxAsc, dim.asc);
maxDesc = max(maxDesc, dim.des); maxDesc = max(maxDesc, dim.des);
changed = tabular.setWidthOfCell(cell, dim.wid) || changed; changed = tabular.setWidthOfCell(cell, dim.wid) || changed;
} }
changed = tabular.setAscentOfRow(i, maxAsc + ADD_TO_HEIGHT) || changed; changed = tabular.setAscentOfRow(i, maxAsc + ADD_TO_HEIGHT) || changed;
changed = tabular.setDescentOfRow(i, maxDesc + ADD_TO_HEIGHT) || changed; changed = tabular.setDescentOfRow(i, maxDesc + ADD_TO_HEIGHT) || changed;
} }
if (changed) //if (changed)
tabular.reinit(); // tabular.reinit();
} }
@ -2051,15 +2036,15 @@ void InsetTabular::tabularFeatures(BufferView * bv,
} }
bool InsetTabular::activateCellInset(BufferView * bv, int x, int y, mouse_button::state button, bool InsetTabular::activateCellInset(BufferView * bv, int x, int y,
bool behind) mouse_button::state button, bool behind)
{ {
UpdatableInset * inset = UpdatableInset * inset =
static_cast<UpdatableInset*>(tabular.getCellInset(actcell)); static_cast<UpdatableInset*>(tabular.getCellInset(actcell));
LyXFont font(LyXFont::ALL_SANE);
if (behind) { if (behind) {
x = inset->x() + inset->width(bv, font); #warning metrics?
y = inset->descent(bv, font); x = inset->x() + inset->width();
y = inset->descent();
} }
//inset_x = cursor.x() - top_x + tabular.getBeginningOfTextInCell(actcell); //inset_x = cursor.x() - top_x + tabular.getBeginningOfTextInCell(actcell);
//inset_y = cursor.y(); //inset_y = cursor.y();
@ -2083,8 +2068,8 @@ bool InsetTabular::activateCellInsetAbs(BufferView * bv, int x, int y,
bool InsetTabular::insetHit(BufferView *, int x, int) const bool InsetTabular::insetHit(BufferView *, int x, int) const
{ {
return (x + top_x) return x + top_x
> (cursor_.x() + tabular.getBeginningOfTextInCell(actcell)); > cursor_.x() + tabular.getBeginningOfTextInCell(actcell);
} }

View File

@ -240,7 +240,7 @@ private:
/// ///
void lfunMouseMotion(FuncRequest const &); void lfunMouseMotion(FuncRequest const &);
/// ///
void calculate_dimensions_of_cells(BufferView *) const; void calculate_dimensions_of_cells(MetricsInfo & mi) const;
/// ///
void drawCellLines(Painter &, int x, int baseline, void drawCellLines(Painter &, int x, int baseline,
int row, int cell) const; int row, int cell) const;

View File

@ -152,12 +152,14 @@ InsetText & InsetText::operator=(InsetText const & it)
void InsetText::init(InsetText const * ins) void InsetText::init(InsetText const * ins)
{ {
if (ins) { if (ins) {
textwidth_ = ins->textwidth_;
text_.bv_owner = ins->text_.bv_owner; text_.bv_owner = ins->text_.bv_owner;
setParagraphData(ins->paragraphs); setParagraphData(ins->paragraphs);
autoBreakRows = ins->autoBreakRows; autoBreakRows = ins->autoBreakRows;
drawFrame_ = ins->drawFrame_; drawFrame_ = ins->drawFrame_;
frame_color = ins->frame_color; frame_color = ins->frame_color;
} else { } else {
textwidth_ = 0; // unbounded
drawFrame_ = NEVER; drawFrame_ = NEVER;
frame_color = LColor::insetframe; frame_color = LColor::insetframe;
autoBreakRows = false; autoBreakRows = false;
@ -274,7 +276,10 @@ void InsetText::read(Buffer const * buf, LyXLex & lex)
void InsetText::metrics(MetricsInfo & mi, Dimension & dim) const void InsetText::metrics(MetricsInfo & mi, Dimension & dim) const
{ {
//lyxerr << "InsetText::metrics: width: " << mi.base.textwidth << "\n"; //lyxerr << "InsetText::metrics: " << getInsetName()
// << " width: " << mi.base.textwidth << "\n";
if (mi.base.textwidth)
textwidth_ = mi.base.textwidth;
BufferView * bv = mi.base.bv; BufferView * bv = mi.base.bv;
setViewCache(bv); setViewCache(bv);
text_.rebuild(mi.base.textwidth); text_.rebuild(mi.base.textwidth);
@ -288,6 +293,7 @@ void InsetText::metrics(MetricsInfo & mi, Dimension & dim) const
int InsetText::textWidth(BufferView * bv, bool fordraw) const int InsetText::textWidth(BufferView * bv, bool fordraw) const
{ {
/*
int w = autoBreakRows ? getMaxWidth(bv, this) : -1; int w = autoBreakRows ? getMaxWidth(bv, this) : -1;
if (fordraw) if (fordraw)
@ -298,6 +304,10 @@ int InsetText::textWidth(BufferView * bv, bool fordraw) const
return -1; return -1;
return w - 2 * TEXT_TO_INSET_OFFSET; return w - 2 * TEXT_TO_INSET_OFFSET;
lyxerr << "InsetText::textWidth: " << getInsetName()
<< " " << textwidth_ << endl;
*/
return textwidth_;
} }
@ -1866,7 +1876,7 @@ int InsetText::cx(BufferView * bv) const
LyXFont font = text_.getFont(bv->buffer(), text_.cursor.par(), LyXFont font = text_.getFont(bv->buffer(), text_.cursor.par(),
text_.cursor.pos()); text_.cursor.pos());
if (font.isVisibleRightToLeft()) if (font.isVisibleRightToLeft())
x -= the_locking_inset->width(bv, font); x -= the_locking_inset->width();
} }
return x; return x;
} }
@ -1879,7 +1889,7 @@ int InsetText::cix(BufferView * bv) const
LyXFont font = text_.getFont(bv->buffer(), text_.cursor.par(), LyXFont font = text_.getFont(bv->buffer(), text_.cursor.par(),
text_.cursor.pos()); text_.cursor.pos());
if (font.isVisibleRightToLeft()) if (font.isVisibleRightToLeft())
x -= the_locking_inset->width(bv, font); x -= the_locking_inset->width();
} }
return x; return x;
} }

View File

@ -328,8 +328,6 @@ private:
/// ///
mutable bool locked; mutable bool locked;
/// ///
mutable Dimension dim_;
///
mutable int top_y; mutable int top_y;
/// ///
ParagraphList::iterator inset_par; ParagraphList::iterator inset_par;
@ -371,5 +369,7 @@ public:
void reinitLyXText() const; void reinitLyXText() const;
/// ///
mutable LyXText text_; mutable LyXText text_;
///
mutable int textwidth_;
}; };
#endif #endif

View File

@ -73,21 +73,18 @@ void UpdatableInset::scroll(BufferView * bv, float s) const
int const workW = bv->workWidth(); int const workW = bv->workWidth();
int const tmp_top_x = top_x - scx; int const tmp_top_x = top_x - scx;
if (tmp_top_x > 0 && if (tmp_top_x > 0 && tmp_top_x + width() < workW)
(tmp_top_x + width(bv, font)) < workW)
return; return;
if (s > 0 && top_x > 0) if (s > 0 && top_x > 0)
return; return;
// int mx_scx=abs((width(bv,font) - bv->workWidth())/2);
//int const save_scx = scx;
scx = int(s * workW / 2); scx = int(s * workW / 2);
// if (!display()) // if (!display())
// scx += 20; // scx += 20;
if ((tmp_top_x + scx + width(bv, font)) < (workW / 2)) { #warning metrics?
scx += (workW / 2) - (tmp_top_x + scx + width(bv, font)); if (tmp_top_x + scx + width() < workW / 2) {
scx += workW / 2 - (tmp_top_x + scx + width());
} }
} }
@ -102,11 +99,11 @@ void UpdatableInset::scroll(BufferView * bv, int offset) const
else else
scx += offset; scx += offset;
} else { } else {
LyXFont const font; #warning metrics?
if (!scx && (top_x + width(bv, font)) < (bv->workWidth() - 20)) if (!scx && top_x + width() < bv->workWidth() - 20)
return; return;
if ((top_x - scx + offset + width(bv, font)) < (bv->workWidth() - 20)) { if (top_x - scx + offset + width() < bv->workWidth() - 20) {
scx = bv->workWidth() - width(bv, font) - top_x + scx - 20; scx += bv->workWidth() - width() - top_x - 20;
} else { } else {
scx += offset; scx += offset;
} }
@ -141,7 +138,7 @@ int UpdatableInset::getMaxWidth(BufferView * bv, UpdatableInset const *) const
int w; int w;
if (owner()) { if (owner()) {
w = static_cast<UpdatableInset *>(owner())->getMaxWidth(bv, this); w = owner()->getMaxWidth(bv, this);
} else { } else {
w = bv->text->workWidth(this); w = bv->text->workWidth(this);
} }

View File

@ -495,10 +495,10 @@ public:
/** this calculates the specified parameters. needed when setting /** this calculates the specified parameters. needed when setting
* the cursor and when creating a visible row */ * the cursor and when creating a visible row */
void prepareToPrint(RowList::iterator row, float & x, void prepareToPrint(RowList::iterator row, int & x,
float & fill_separator, int & fill_separator,
float & fill_hfill, int & fill_hfill,
float & fill_label_hfill, int & fill_label_hfill,
bool bidi = true) const; bool bidi = true) const;
private: private:

View File

@ -16,9 +16,9 @@ MetricsBase::MetricsBase()
MetricsBase::MetricsBase(BufferView * b, LyXFont const & f) MetricsBase::MetricsBase(BufferView * b, LyXFont const & f, int w)
: bv(b), font(f), style(LM_ST_TEXT), fontname("mathnormal"), : bv(b), font(f), style(LM_ST_TEXT), fontname("mathnormal"),
restrictwidth(false), textwidth(0) restrictwidth(false), textwidth(w)
{} {}
@ -27,8 +27,8 @@ MetricsInfo::MetricsInfo()
{} {}
MetricsInfo::MetricsInfo(BufferView * bv, LyXFont const & font) MetricsInfo::MetricsInfo(BufferView * bv, LyXFont const & font, int textwidth)
: base(bv, font) : base(bv, font, textwidth)
{} {}

View File

@ -28,7 +28,7 @@ struct MetricsBase {
/// ///
MetricsBase(); MetricsBase();
/// ///
MetricsBase(BufferView * bv, LyXFont const & font); MetricsBase(BufferView * bv, LyXFont const & font, int textwidth);
/// the current view /// the current view
BufferView * bv; BufferView * bv;
@ -53,7 +53,7 @@ struct MetricsInfo {
/// ///
MetricsInfo(); MetricsInfo();
/// ///
MetricsInfo(BufferView * bv, LyXFont const & font); MetricsInfo(BufferView * bv, LyXFont const & font, int textwidth);
/// ///
MetricsBase base; MetricsBase base;

View File

@ -74,7 +74,7 @@ private:
void paintChangeBar(); void paintChangeBar();
void paintFirst(); void paintFirst();
void paintLast(); void paintLast();
void paintForeignMark(float const orig_x, LyXFont const & orig_font); void paintForeignMark(int orig_x, LyXFont const & orig_font);
void paintHebrewComposeChar(lyx::pos_type & vpos); void paintHebrewComposeChar(lyx::pos_type & vpos);
void paintArabicComposeChar(lyx::pos_type & vpos); void paintArabicComposeChar(lyx::pos_type & vpos);
void paintChars(lyx::pos_type & vpos, bool hebrew, bool arabic); void paintChars(lyx::pos_type & vpos, bool hebrew, bool arabic);
@ -118,12 +118,12 @@ private:
// Looks ugly - is // Looks ugly - is
int xo_; int xo_;
int yo_; int yo_;
float x_; int x_;
int y_; int y_;
int width_; int width_;
float separator_; int separator_;
float hfill_; int hfill_;
float label_hfill_; int label_hfill_;
}; };
RowPainter::RowPainter(BufferView const & bv, LyXText const & text, RowPainter::RowPainter(BufferView const & bv, LyXText const & text,
@ -178,11 +178,15 @@ void RowPainter::paintInset(pos_type const pos)
Assert(inset); Assert(inset);
MetricsInfo mi(perv(bv_), getFont(pos), text_.workWidth());
Dimension dim;
inset->metrics(mi, dim);
PainterInfo pi(perv(bv_)); PainterInfo pi(perv(bv_));
pi.base.font = getFont(pos); pi.base.font = getFont(pos);
int const w = inset->width(perv(bv_), pi.base.font); #warning metrics?
inset->draw(pi, int(x_), yo_ + row_->baseline()); inset->draw(pi, int(x_), yo_ + row_->baseline());
x_ += w; x_ += dim.wid;
} }
@ -310,7 +314,7 @@ void RowPainter::paintChars(pos_type & vpos, bool hebrew, bool arabic)
} }
void RowPainter::paintForeignMark(float const orig_x, LyXFont const & orig_font) void RowPainter::paintForeignMark(int orig_x, LyXFont const & orig_font)
{ {
if (!lyxrc.mark_foreign_language) if (!lyxrc.mark_foreign_language)
return; return;
@ -330,7 +334,7 @@ void RowPainter::paintFromPos(pos_type & vpos)
LyXFont const & orig_font = getFont(pos); LyXFont const & orig_font = getFont(pos);
float const orig_x = x_; int const orig_x = x_;
char const c = pit_->getChar(pos); char const c = pit_->getChar(pos);
@ -430,11 +434,11 @@ void RowPainter::paintSelection()
pos_type const body_pos = pit_->beginningOfBody(); pos_type const body_pos = pit_->beginningOfBody();
pos_type const last = lastPrintablePos(text_, row_); pos_type const last = lastPrintablePos(text_, row_);
float tmpx = x_; int tmpx = x_;
for (pos_type vpos = row_->pos(); vpos <= last; ++vpos) { for (pos_type vpos = row_->pos(); vpos <= last; ++vpos) {
pos_type pos = text_.vis2log(vpos); pos_type pos = text_.vis2log(vpos);
float const old_tmpx = tmpx; int const old_tmpx = tmpx;
if (body_pos > 0 && pos == body_pos - 1) { if (body_pos > 0 && pos == body_pos - 1) {
LyXLayout_ptr const & layout = pit_->layout(); LyXLayout_ptr const & layout = pit_->layout();
LyXFont const lfont = getLabelFont(); LyXFont const lfont = getLabelFont();
@ -714,7 +718,7 @@ void RowPainter::paintFirst()
y_top += asc; y_top += asc;
int const w = (text_.isInInset() ? text_.inset_owner->width(perv(bv_), font) : ww); int const w = (text_.isInInset() ? text_.inset_owner->width() : ww);
int const xp = static_cast<int>(text_.isInInset() ? xo_ : 0); int const xp = static_cast<int>(text_.isInInset() ? xo_ : 0);
pain_.line(xp, yo_ + y_top, xp + w, yo_ + y_top, pain_.line(xp, yo_ + y_top, xp + w, yo_ + y_top,
LColor::topline, Painter::line_solid, LColor::topline, Painter::line_solid,
@ -733,7 +737,7 @@ void RowPainter::paintFirst()
LyXFont font = getLabelFont(); LyXFont font = getLabelFont();
if (!pit_->getLabelstring().empty()) { if (!pit_->getLabelstring().empty()) {
float x = x_; int x = x_;
string const str = pit_->getLabelstring(); string const str = pit_->getLabelstring();
// this is special code for the chapter layout. This is // this is special code for the chapter layout. This is
@ -757,7 +761,7 @@ void RowPainter::paintFirst()
font_metrics::width(str, font); font_metrics::width(str, font);
} }
pain_.text(int(x), pain_.text(x,
yo_ + row_->baseline() - yo_ + row_->baseline() -
row_->ascent_of_text() - maxdesc, row_->ascent_of_text() - maxdesc,
str, font); str, font);
@ -771,7 +775,7 @@ void RowPainter::paintFirst()
- font_metrics::width(str, font); - font_metrics::width(str, font);
} }
pain_.text(int(x), yo_ + row_->baseline(), str, font); pain_.text(x, yo_ + row_->baseline(), str, font);
} }
} }
@ -795,7 +799,7 @@ void RowPainter::paintFirst()
int(font_metrics::maxDescent(font) * layout->spacing.getValue() * spacing_val int(font_metrics::maxDescent(font) * layout->spacing.getValue() * spacing_val
+ (layout->labelbottomsep * defaultRowHeight())); + (layout->labelbottomsep * defaultRowHeight()));
float x = x_; int x = x_;
if (layout->labeltype == LABEL_CENTERED_TOP_ENVIRONMENT) { if (layout->labeltype == LABEL_CENTERED_TOP_ENVIRONMENT) {
x = ((is_rtl ? leftMargin() : x_) x = ((is_rtl ? leftMargin() : x_)
+ ww - text_.rightMargin(*bv_.buffer(), *row_)) / 2; + ww - text_.rightMargin(*bv_.buffer(), *row_)) / 2;
@ -804,7 +808,7 @@ void RowPainter::paintFirst()
x = ww - leftMargin() - x = ww - leftMargin() -
font_metrics::width(str, font); font_metrics::width(str, font);
} }
pain_.text(int(x), yo_ + row_->baseline() pain_.text(x, yo_ + row_->baseline()
- row_->ascent_of_text() - maxdesc, - row_->ascent_of_text() - maxdesc,
str, font); str, font);
} }
@ -842,7 +846,7 @@ void RowPainter::paintLast()
y_bottom -= asc; y_bottom -= asc;
int const w = (text_.isInInset() ? text_.inset_owner->width(perv(bv_), font) : ww); int const w = text_.isInInset() ? text_.inset_owner->width() : ww;
int const xp = static_cast<int>(text_.isInInset() ? xo_ : 0); int const xp = static_cast<int>(text_.isInInset() ? xo_ : 0);
int const y = yo_ + y_bottom; int const y = yo_ + y_bottom;
pain_.line(xp, y, xp + w, y, LColor::topline, Painter::line_solid, pain_.line(xp, y, xp + w, y, LColor::topline, Painter::line_solid,
@ -879,7 +883,7 @@ void RowPainter::paintLast()
LyXFont font = getLabelFont(); LyXFont font = getLabelFont();
string const & str = pit_->layout()->endlabelstring(); string const & str = pit_->layout()->endlabelstring();
int const x = is_rtl ? int const x = is_rtl ?
int(x_) - font_metrics::width(str, font) x_ - font_metrics::width(str, font)
: ww - text_.rightMargin(*bv_.buffer(), *row_) - row_->fill(); : ww - text_.rightMargin(*bv_.buffer(), *row_) - row_->fill();
pain_.text(x, yo_ + row_->baseline(), str, font); pain_.text(x, yo_ + row_->baseline(), str, font);
break; break;
@ -904,7 +908,7 @@ void RowPainter::paintText()
bool running_strikeout = false; bool running_strikeout = false;
bool is_struckout = false; bool is_struckout = false;
float last_strikeout_x = 0.0; int last_strikeout_x = 0;
pos_type vpos = row_->pos(); pos_type vpos = row_->pos();
while (vpos <= last) { while (vpos <= last) {
@ -938,7 +942,7 @@ void RowPainter::paintText()
if (running_strikeout && (highly_editable_inset || !is_struckout)) { if (running_strikeout && (highly_editable_inset || !is_struckout)) {
int const middle = yo_ + row_->top_of_text() int const middle = yo_ + row_->top_of_text()
+ ((row_->baseline() - row_->top_of_text()) / 2); + ((row_->baseline() - row_->top_of_text()) / 2);
pain_.line(int(last_strikeout_x), middle, int(x_), middle, pain_.line(last_strikeout_x, middle, x_, middle,
LColor::strikeout, Painter::line_solid, Painter::line_thin); LColor::strikeout, Painter::line_solid, Painter::line_thin);
running_strikeout = false; running_strikeout = false;
} }
@ -957,28 +961,25 @@ void RowPainter::paintText()
int const y0 = yo_ + row_->baseline(); int const y0 = yo_ + row_->baseline();
int const y1 = y0 - defaultRowHeight() / 2; int const y1 = y0 - defaultRowHeight() / 2;
pain_.line(int(x_), y1, int(x_), y0, pain_.line(x_, y1, x_, y0,
LColor::added_space); LColor::added_space);
if (hfillExpansion(text_, row_, pos)) { if (hfillExpansion(text_, row_, pos)) {
int const y2 = (y0 + y1) / 2; int const y2 = (y0 + y1) / 2;
if (pos >= body_pos) { if (pos >= body_pos) {
pain_.line(int(x_), y2, pain_.line(x_, y2, x_ + hfill_, y2,
int(x_ + hfill_), y2,
LColor::added_space, LColor::added_space,
Painter::line_onoffdash); Painter::line_onoffdash);
x_ += hfill_; x_ += hfill_;
} else { } else {
pain_.line(int(x_), y2, pain_.line(x_, y2,
int(x_ + label_hfill_), y2, x_ + label_hfill_, y2,
LColor::added_space, LColor::added_space,
Painter::line_onoffdash); Painter::line_onoffdash);
x_ += label_hfill_; x_ += label_hfill_;
} }
pain_.line(int(x_), y1, pain_.line(x_, y1, x_, y0, LColor::added_space);
int(x_), y0,
LColor::added_space);
} }
x_ += 2; x_ += 2;
++vpos; ++vpos;
@ -996,7 +997,7 @@ void RowPainter::paintText()
if (running_strikeout) { if (running_strikeout) {
int const middle = yo_ + row_->top_of_text() int const middle = yo_ + row_->top_of_text()
+ ((row_->baseline() - row_->top_of_text()) / 2); + ((row_->baseline() - row_->top_of_text()) / 2);
pain_.line(int(last_strikeout_x), middle, int(x_), middle, pain_.line(last_strikeout_x, middle, x_, middle,
LColor::strikeout, Painter::line_solid, Painter::line_thin); LColor::strikeout, Painter::line_solid, Painter::line_thin);
running_strikeout = false; running_strikeout = false;
} }
@ -1059,7 +1060,7 @@ int getLengthMarkerHeight(BufferView const & bv, VSpace const & vsp)
return 0; return 0;
int const arrow_size = 4; int const arrow_size = 4;
int const space_size = int(vsp.inPixels(bv)); int const space_size = vsp.inPixels(bv);
LyXFont font; LyXFont font;
font.decSize(); font.decSize();

View File

@ -322,13 +322,12 @@ int LyXText::singleWidth(ParagraphList::iterator pit,
// should be changed! (Jug 20011204) // should be changed! (Jug 20011204)
//tmpinset->update(bv()); //tmpinset->update(bv());
Dimension dim; Dimension dim;
MetricsInfo mi; MetricsInfo mi(bv(), font, workWidth());
mi.base.bv = bv();
mi.base.font = font;
tmpinset->metrics(mi, dim); tmpinset->metrics(mi, dim);
#endif
//return tmpinset->width(bv(), font);
return dim.wid; return dim.wid;
#else
return tmpinset->width();
#endif
} }
return 0; return 0;
} }
@ -1084,18 +1083,20 @@ void LyXText::setHeightOfRow(RowList::iterator rit)
tmpfont = getFont(bv()->buffer(), pit, pos); tmpfont = getFont(bv()->buffer(), pit, pos);
tmpinset = pit->getInset(pos); tmpinset = pit->getInset(pos);
if (tmpinset) { if (tmpinset) {
#if 1 // this is needed for deep update on initialitation #if 0 // this is needed for deep update on initialitation
#warning inset->update FIXME #warning inset->update FIXME
//tmpinset->update(bv()); //tmpinset->update(bv());
Dimension dim; Dimension dim;
MetricsInfo mi; MetricsInfo mi(bv(), tmpfont, workWidth());
mi.base.bv = bv();
mi.base.font = tmpfont;
tmpinset->metrics(mi, dim); tmpinset->metrics(mi, dim);
#endif
maxwidth += dim.wid; maxwidth += dim.wid;
maxasc = max(maxasc, dim.asc); maxasc = max(maxasc, dim.asc);
maxdesc = max(maxdesc, dim.des); maxdesc = max(maxdesc, dim.des);
#else
maxwidth += tmpinset->width();
maxasc = max(maxasc, tmpinset->ascent());
maxdesc = max(maxdesc, tmpinset->descent());
#endif
} }
} else { } else {
maxwidth += singleWidth(pit, pos); maxwidth += singleWidth(pit, pos);
@ -1317,9 +1318,9 @@ void LyXText::setHeightOfRow(RowList::iterator rit)
rit->top_of_text(rit->baseline() - font_metrics::maxAscent(font)); rit->top_of_text(rit->baseline() - font_metrics::maxAscent(font));
float x = 0; int x = 0;
if (layout->margintype != MARGIN_RIGHT_ADDRESS_BOX) { if (layout->margintype != MARGIN_RIGHT_ADDRESS_BOX) {
float dummy; int dummy;
// this IS needed // this IS needed
rit->width(maxwidth); rit->width(maxwidth);
prepareToPrint(rit, x, dummy, dummy, dummy, false); prepareToPrint(rit, x, dummy, dummy, dummy, false);
@ -1826,13 +1827,13 @@ void LyXText::charInserted()
} }
void LyXText::prepareToPrint(RowList::iterator rit, float & x, void LyXText::prepareToPrint(RowList::iterator rit, int & x,
float & fill_separator, int & fill_separator,
float & fill_hfill, int & fill_hfill,
float & fill_label_hfill, int & fill_label_hfill,
bool bidi) const bool bidi) const
{ {
float w = rit->fill(); int w = rit->fill();
fill_hfill = 0; fill_hfill = 0;
fill_label_hfill = 0; fill_label_hfill = 0;
fill_separator = 0; fill_separator = 0;
@ -1842,12 +1843,10 @@ void LyXText::prepareToPrint(RowList::iterator rit, float & x,
bool const is_rtl = bool const is_rtl =
pit->isRightToLeftPar(bv()->buffer()->params); pit->isRightToLeftPar(bv()->buffer()->params);
if (is_rtl) { if (is_rtl)
x = (workWidth() > 0) x = workWidth() > 0 ? rightMargin(*bv()->buffer(), *rit) : 0;
? rightMargin(*bv()->buffer(), *rit) : 0; else
} else x = workWidth() > 0 ? leftMargin(*rit) : 0;
x = (workWidth() > 0)
? leftMargin(*rit) : 0;
// is there a manual margin with a manual label // is there a manual margin with a manual label
LyXLayout_ptr const & layout = pit->layout(); LyXLayout_ptr const & layout = pit->layout();
@ -1855,7 +1854,7 @@ void LyXText::prepareToPrint(RowList::iterator rit, float & x,
if (layout->margintype == MARGIN_MANUAL if (layout->margintype == MARGIN_MANUAL
&& layout->labeltype == LABEL_MANUAL) { && layout->labeltype == LABEL_MANUAL) {
/// We might have real hfills in the label part /// We might have real hfills in the label part
float nlh = numberOfLabelHfills(*this, rit); int nlh = numberOfLabelHfills(*this, rit);
// A manual label par (e.g. List) has an auto-hfill // A manual label par (e.g. List) has an auto-hfill
// between the label text and the body of the // between the label text and the body of the
@ -1866,12 +1865,12 @@ void LyXText::prepareToPrint(RowList::iterator rit, float & x,
++nlh; ++nlh;
if (nlh && !pit->getLabelWidthString().empty()) { if (nlh && !pit->getLabelWidthString().empty()) {
fill_label_hfill = labelFill(*rit) / nlh; fill_label_hfill = int(labelFill(*rit) / nlh);
} }
} }
// are there any hfills in the row? // are there any hfills in the row?
float const nh = numberOfHfills(*this, rit); int const nh = numberOfHfills(*this, rit);
if (nh) { if (nh) {
if (w > 0) if (w > 0)
@ -1879,7 +1878,7 @@ void LyXText::prepareToPrint(RowList::iterator rit, float & x,
// we don't have to look at the alignment if it is ALIGN_LEFT and // we don't have to look at the alignment if it is ALIGN_LEFT and
// if the row is already larger then the permitted width as then // if the row is already larger then the permitted width as then
// we force the LEFT_ALIGN'edness! // we force the LEFT_ALIGN'edness!
} else if (static_cast<int>(rit->width()) < workWidth()) { } else if (int(rit->width()) < workWidth()) {
// is it block, flushleft or flushright? // is it block, flushleft or flushright?
// set x how you need it // set x how you need it
int align; int align;
@ -1908,7 +1907,7 @@ void LyXText::prepareToPrint(RowList::iterator rit, float & x,
switch (align) { switch (align) {
case LYX_ALIGN_BLOCK: case LYX_ALIGN_BLOCK:
{ {
float const ns = numberOfSeparators(*this, rit); int const ns = numberOfSeparators(*this, rit);
RowList::iterator next_row = boost::next(rit); RowList::iterator next_row = boost::next(rit);
ParagraphList::iterator next_pit = next_row->par(); ParagraphList::iterator next_pit = next_row->par();
@ -2661,6 +2660,7 @@ LyXText::getRow(ParagraphList::iterator pit, pos_type pos) const
return rit; return rit;
} }
// returns pointer to a specified row // returns pointer to a specified row
RowList::iterator RowList::iterator
LyXText::getRow(ParagraphList::iterator pit, pos_type pos, int & y) const LyXText::getRow(ParagraphList::iterator pit, pos_type pos, int & y) const
@ -2690,6 +2690,7 @@ LyXText::getRow(ParagraphList::iterator pit, pos_type pos, int & y) const
return rit; return rit;
} }
// returns pointer to some fancy row 'below' specified row // returns pointer to some fancy row 'below' specified row
RowList::iterator LyXText::cursorIRow() const RowList::iterator LyXText::cursorIRow() const
{ {

View File

@ -1615,10 +1615,10 @@ float LyXText::getCursorX(RowList::iterator rit,
pos_type pos, pos_type last, bool boundary) const pos_type pos, pos_type last, bool boundary) const
{ {
pos_type cursor_vpos = 0; pos_type cursor_vpos = 0;
float x; int x;
float fill_separator; int fill_separator;
float fill_hfill; int fill_hfill;
float fill_label_hfill; int fill_label_hfill;
// This call HAS to be here because of the BidiTables!!! // This call HAS to be here because of the BidiTables!!!
prepareToPrint(rit, x, fill_separator, fill_hfill, prepareToPrint(rit, x, fill_separator, fill_hfill,
fill_label_hfill); fill_label_hfill);
@ -1752,13 +1752,12 @@ void LyXText::setCurrentFont()
pos_type pos_type
LyXText::getColumnNearX(RowList::iterator rit, int & x, bool & boundary) const LyXText::getColumnNearX(RowList::iterator rit, int & x, bool & boundary) const
{ {
float tmpx = 0.0; int tmpx = 0;
float fill_separator; int fill_separator;
float fill_hfill; int fill_hfill;
float fill_label_hfill; int fill_label_hfill;
prepareToPrint(rit, tmpx, fill_separator, prepareToPrint(rit, tmpx, fill_separator, fill_hfill, fill_label_hfill);
fill_hfill, fill_label_hfill);
pos_type vc = rit->pos(); pos_type vc = rit->pos();
pos_type last = lastPrintablePos(*this, rit); pos_type last = lastPrintablePos(*this, rit);
@ -1870,7 +1869,8 @@ void LyXText::setCursorFromCoordinates(int x, int y)
setCursorFromCoordinates(cursor, x, y); setCursorFromCoordinates(cursor, x, y);
setCurrentFont(); setCurrentFont();
deleteEmptyParagraphMechanism(old_cursor); #warning DEPM disabled, otherwise crash when entering new table
//deleteEmptyParagraphMechanism(old_cursor);
} }

View File

@ -115,15 +115,15 @@ namespace {
LyXFont const & font = text.getFont(bv->buffer(), par, pos); LyXFont const & font = text.getFont(bv->buffer(), par, pos);
int const width = inset->width(bv, font); int const width = inset->width();
int const inset_x = font.isVisibleRightToLeft() int const inset_x = font.isVisibleRightToLeft()
? (cur.ix() - width) : cur.ix(); ? (cur.ix() - width) : cur.ix();
Box b( Box b(
inset_x + inset->scroll(), inset_x + inset->scroll(),
inset_x + width, inset_x + width,
cur.iy() - inset->ascent(bv, font), cur.iy() - inset->ascent(),
cur.iy() + inset->descent(bv, font) cur.iy() + inset->descent()
); );
if (!b.contained(x, y)) { if (!b.contained(x, y)) {
@ -1297,7 +1297,7 @@ Inset::RESULT LyXText::dispatch(FuncRequest const & cmd)
LyXCursor cursor = bv->text->cursor; LyXCursor cursor = bv->text->cursor;
LyXFont font = bv->text->getFont(bv->buffer(), LyXFont font = bv->text->getFont(bv->buffer(),
cursor.par(), cursor.pos()); cursor.par(), cursor.pos());
int width = tli->width(bv, font); int width = tli->width();
int inset_x = font.isVisibleRightToLeft() int inset_x = font.isVisibleRightToLeft()
? cursor.ix() - width : cursor.ix(); ? cursor.ix() - width : cursor.ix();
int start_x = inset_x + tli->scroll(); int start_x = inset_x + tli->scroll();