mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-06 00:10:59 +00:00
prepare passing down max text widths...
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7309 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
2353291b37
commit
6da2800573
@ -73,12 +73,6 @@ dispatch_result InsetBibitem::localDispatch(FuncRequest const & cmd)
|
||||
|
||||
setParams(p);
|
||||
cmd.view()->updateInset(this);
|
||||
|
||||
// We need to do a redraw because the maximum
|
||||
// InsetBibitem width could have changed
|
||||
#warning please check you mean repaint() not update(),
|
||||
#warning and whether the repaint() is needed at all
|
||||
cmd.view()->repaint();
|
||||
cmd.view()->fitCursor();
|
||||
return DISPATCHED;
|
||||
}
|
||||
|
@ -256,14 +256,30 @@ void InsetTabular::read(Buffer const * buf, LyXLex & lex)
|
||||
|
||||
void InsetTabular::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
{
|
||||
if (mi.base.bv) {
|
||||
calculate_dimensions_of_cells(mi.base.bv);
|
||||
//lyxerr << "InsetTabular::metrics, bv: " << mi.base.bv << endl;
|
||||
for (int i = 0; i < tabular.getNumberOfCells(); ++i) {
|
||||
tabular.cellinfo_of_cell(i)->inset.text_.bv_owner = mi.base.bv;
|
||||
tabular.cellinfo_of_cell(i)->inset.reinitLyXText();
|
||||
}
|
||||
//lyxerr << "InsetTabular::metrics: " << mi.base.bv << " width: " <<
|
||||
// mi.base.textwidth << "\n";
|
||||
if (!mi.base.bv) {
|
||||
lyxerr << "InsetTabular::metrics: need bv\n";
|
||||
Assert(0);
|
||||
}
|
||||
|
||||
calculate_dimensions_of_cells(mi.base.bv);
|
||||
//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.des = tabular.getHeightOfTabular() - tabular.getAscentOfRow(0) + 1;
|
||||
@ -273,6 +289,7 @@ void InsetTabular::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
|
||||
void InsetTabular::draw(PainterInfo & pi, int x, int y) const
|
||||
{
|
||||
lyxerr << "InsetTabular::draw: " << x << " " << y << "\n";
|
||||
if (nodraw()) {
|
||||
need_update = FULL;
|
||||
return;
|
||||
@ -436,6 +453,7 @@ void InsetTabular::insetUnlock(BufferView * bv)
|
||||
|
||||
void InsetTabular::updateLocal(BufferView * bv, UpdateCodes what) const
|
||||
{
|
||||
lyxerr << "InsetTabular::updateLocal: " << what << "\n";
|
||||
if (what == INIT) {
|
||||
calculate_dimensions_of_cells(bv);
|
||||
}
|
||||
|
@ -274,9 +274,10 @@ void InsetText::read(Buffer const * buf, LyXLex & lex)
|
||||
|
||||
void InsetText::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
{
|
||||
//lyxerr << "InsetText::metrics: width: " << mi.base.textwidth << "\n";
|
||||
BufferView * bv = mi.base.bv;
|
||||
setViewCache(bv);
|
||||
text_.rebuild();
|
||||
text_.rebuild(mi.base.textwidth);
|
||||
dim.asc = text_.rows().begin()->ascent_of_text() + TEXT_TO_INSET_OFFSET;
|
||||
dim.des = text_.height - dim.asc + TEXT_TO_INSET_OFFSET;
|
||||
dim.wid = max(textWidth(bv), int(text_.width)) + 2 * TEXT_TO_INSET_OFFSET;
|
||||
|
@ -164,7 +164,7 @@ public:
|
||||
/// a full rebreak of the whole text
|
||||
void fullRebreak();
|
||||
/// rebuild RowList cache
|
||||
void rebuild();
|
||||
void rebuild(int maxwidth);
|
||||
|
||||
///
|
||||
RowList::iterator need_break_row;
|
||||
|
18
src/text2.C
18
src/text2.C
@ -692,7 +692,7 @@ void LyXText::fullRebreak()
|
||||
}
|
||||
|
||||
|
||||
void LyXText::rebuild()
|
||||
void LyXText::rebuild(int maxwidth)
|
||||
{
|
||||
rowlist_.clear();
|
||||
need_break_row = rows().end();
|
||||
@ -704,17 +704,15 @@ void LyXText::rebuild()
|
||||
ParagraphList::iterator pit = ownerParagraphs().begin();
|
||||
ParagraphList::iterator end = ownerParagraphs().end();
|
||||
|
||||
//current_font = getFont(bview->buffer(), pit, 0);
|
||||
for (; pit != end; ++pit) {
|
||||
// insert a new row, starting at position 0
|
||||
Row newrow(pit, 0);
|
||||
RowList::iterator rit = rowlist_.insert(rowlist_.end(), newrow);
|
||||
|
||||
for (; pit != end; ++pit)
|
||||
insertParagraph(pit, rowlist_.end());
|
||||
// and now append the whole paragraph before the new row
|
||||
appendParagraph(rit);
|
||||
}
|
||||
|
||||
//setCursorIntern(rowlist_.begin()->par(), 0);
|
||||
//selection.cursor = cursor;
|
||||
|
||||
//updateCounters();
|
||||
|
||||
//setCursorIntern(cursor.par(), cursor.pos());
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user