#include "LyXRC.h"
#include "MetricsInfo.h"
#include "ParagraphParameters.h"
-#include "rowpainter.h"
+#include "RowPainter.h"
#include "Text.h"
#include "TextClass.h"
#include "VSpace.h"
}
-int TextMetrics::getAlign(Paragraph const & par, pos_type const pos) const
+LyXAlignment TextMetrics::getAlign(Paragraph const & par, pos_type const pos) const
{
Layout const & layout = par.layout();
- int align;
+ LyXAlignment align;
if (par.params().align() == LYX_ALIGN_LAYOUT)
align = layout.align;
else
Paragraph const & par = text_->getPar(pit);
- double w = width - row.right_margin - row.width();
+ double const w = width - row.right_margin - row.width();
// FIXME: put back this assertion when the crash on new doc is solved.
//LASSERT(w >= 0, /**/);
} else if (int(row.width()) < max_width_) {
// is it block, flushleft or flushright?
// set x how you need it
- int const align = getAlign(par, row.pos());
-
- switch (align) {
+ switch (getAlign(par, row.pos())) {
case LYX_ALIGN_BLOCK: {
int const ns = numberOfSeparators(row);
/** If we have separators, and this row has
* not be broken abruptly by a display inset
* or newline, then stretch it */
- if (ns && !row.right_boundary()
+ if (ns && !row.right_boundary()
&& row.endpos() != par.size()) {
setSeparatorWidth(row, w / ns);
row.dimension().wid = width;
row.x += w;
break;
case LYX_ALIGN_CENTER:
- row.dimension().wid = width - w / 2;
+ row.dimension().wid = width - int(w / 2);
row.x += w / 2;
break;
+ case LYX_ALIGN_LEFT:
+ case LYX_ALIGN_NONE:
+ case LYX_ALIGN_LAYOUT:
+ case LYX_ALIGN_SPECIAL:
+ case LYX_ALIGN_DECIMAL:
+ break;
}
}
}
#endif
+ // Finally, handle hfill insets
pos_type const endpos = row.endpos();
pos_type body_pos = par.beginOfBody();
if (body_pos > 0
&& (body_pos > endpos || !par.isLineSeparator(body_pos - 1)))
body_pos = 0;
-
ParagraphMetrics & pm = par_metrics_[pit];
Row::iterator cit = row.begin();
Row::iterator const cend = row.end();
for ( ; cit != cend; ++cit) {
if (row.label_hfill && cit->endpos == body_pos
&& cit->type == Row::SPACE)
- cit->dim.wid -= row.label_hfill * (nlh - 1);
+ cit->dim.wid -= int(row.label_hfill * (nlh - 1));
if (!cit->inset || !cit->inset->isHfill())
continue;
if (pm.hfillExpansion(row, cit->pos))
Paragraph const & par = text_->getPar(pit);
LBUFERR(par.beginOfBody() > 0 || par.isEnvSeparator(0));
- int w = 0;
+ double w = 0;
Row::const_iterator cit = row.begin();
Row::const_iterator const end = row.end();
// iterate over elements before main body (except the last one,
FontMetrics const & fm
= theFontMetrics(text_->labelFont(par));
- return max(0, fm.width(label) - w);
+ return max(0, fm.width(label) - int(w));
}
int const width = max_width_ - right_margin;
pos_type const body_pos = par.beginOfBody();
row.clear();
- row.x = leftMargin(max_width_, pit, pos);
- row.dimension().wid = row.x;
+ row.dimension().wid = leftMargin(max_width_, pit, pos);
row.right_margin = right_margin;
if (pos >= end || row.width() > width) {
pos_type pos = row.pos();
boundary = false;
if (row.empty())
- x = row.x;
+ x = int(row.x);
else if (x <= row.x) {
pos = row.front().left_pos();
- x = row.x;
+ x = int(row.x);
} else if (x >= row.width() - row.right_margin) {
pos = row.back().right_pos();
x = row.width() - row.right_margin;
if (w <= x && w + cit->width() > x) {
double x_offset = x - w;
pos = cit->x2pos(x_offset);
- x = x_offset + w;
+ x = int(x_offset + w);
break;
}
w += cit->width();
}
/** This tests for the case where the cursor is set at the end
- * of a row which has been broken due to a display inset on
- * next row. This is indicated by Row::right_boundary.
+ * of a row which has been broken due something else than a
+ * separator (a display inset or a forced breaking of the
+ * row). We know that there is a separator when the end of the
+ * row is larger than the end of its last element.
*/
if (!row.empty() && pos == row.back().endpos
&& row.back().endpos == row.endpos())
- boundary = row.right_boundary();
+ boundary = true;
x += xo;
return pos;