}
-pit_type TextMetrics::firstPit() const
+pair<pit_type, ParagraphMetrics const *> TextMetrics::first() const
{
- return par_metrics_.begin()->first;
+ ParMetricsCache::const_iterator it = par_metrics_.begin();
+ return make_pair(it->first, &it->second);
}
-pit_type TextMetrics::lastPit() const
+pair<pit_type, ParagraphMetrics const *> TextMetrics::last() const
{
- return par_metrics_.rbegin()->first;
+ LBUFERR(!par_metrics_.empty());
+ ParMetricsCache::const_reverse_iterator it = par_metrics_.rbegin();
+ return make_pair(it->first, &it->second);
}
}
+ParagraphMetrics & TextMetrics::parMetrics(pit_type pit)
+{
+ return parMetrics(pit, true);
+}
+
+
void TextMetrics::newParMetricsDown()
{
pair<pit_type, ParagraphMetrics> const & last = *par_metrics_.rbegin();
}
-int TextMetrics::topPosition() const
-{
- ParagraphMetrics const & firstpm = par_metrics_.begin()->second;
- return firstpm.position() - firstpm.ascent();
-}
-
-
-int TextMetrics::bottomPosition() const
-{
- ParagraphMetrics const & lastpm = par_metrics_.rbegin()->second;
- return lastpm.position() + lastpm.descent();
-}
-
-
void TextMetrics::applyOuterFont(Font & font) const
{
FontInfo lf(font_.fontInfo());
if (row_index < pm.rows().size())
pm.rows().resize(row_index);
- // FIXME: It might be better to move this in another method
- // specially tailored for the main text.
- // Top and bottom margin of the document (only at top-level)
- if (text_->isMainText()) {
- if (pit == 0) {
- pm.rows().front().top_padding += bv_->topMargin();
- pm.dim().asc += bv_->topMargin();
- }
- ParagraphList const & pars = text_->paragraphs();
- if (pit + 1 == pit_type(pars.size())) {
- pm.rows().back().bottom_padding += bv_->bottomMargin();
- pm.dim().des += bv_->bottomMargin();
- }
- }
-
// The space above and below the paragraph.
int const top = parTopSpacing(pit);
pm.rows().front().dim().asc += top;
pm.dim().asc += pm.rows()[0].ascent();
pm.dim().des -= pm.rows()[0].ascent();
+ // Top and bottom margin of the document (only at top-level)
+ // FIXME: It might be better to move this in another method
+ // specially tailored for the main text.
+ if (text_->isMainText()) {
+ if (pit == 0)
+ pm.dim().asc += bv_->topMargin();
+ ParagraphList const & pars = text_->paragraphs();
+ if (pit + 1 == pit_type(pars.size())) {
+ pm.dim().des += bv_->bottomMargin();
+ }
+ }
+
changed |= old_dim.height() != pm.dim().height();
return changed;
int maxasc = int(fm.maxAscent() * spacing_val);
int maxdes = int(fm.maxDescent() * spacing_val);
+ // Take label string into account (useful if labelfont is large)
+ if (row.pos() == 0 && layout.labelIsInline()) {
+ FontInfo const labelfont = text_->labelFont(par);
+ FontMetrics const & lfm = theFontMetrics(labelfont);
+ maxasc = max(maxasc, int(lfm.maxAscent() * spacing_val));
+ maxdes = max(maxdes, int(lfm.maxDescent() * spacing_val));
+ }
+
// Find the ascent/descent of the row contents
for (Row::Element const & e : row) {
if (e.inset) {
{
ParagraphMetrics const & pm = par_metrics_[pit];
- int yy = pm.position() - pm.ascent();
+ int yy = pm.position() - pm.rows().front().ascent();
LBUFERR(!pm.rows().empty());
RowList::const_iterator rit = pm.rows().begin();
RowList::const_iterator rlast = pm.rows().end();