- pain.line(1, y_offset,
- 1, y_offset + row_ptr->height(),
- LColor::appendixline);
- pain.line(ww - 2, y_offset,
- ww - 2, y_offset + row_ptr->height(),
- LColor::appendixline);
- }
-
- // Draw depth lines
- Paragraph::depth_type const depth = firstpar->getDepth();
- if (depth > 0) {
- Paragraph::depth_type next_depth = 0;
- Paragraph::depth_type prev_depth = 0;
- if (row_ptr->next())
- next_depth = row_ptr->next()->par()->getDepth();
- if (row_ptr->previous())
- prev_depth = row_ptr->previous()->par()->getDepth();
-
- for (Paragraph::depth_type i = 1; i <= depth; ++i) {
- int const line_x = (LYX_PAPER_MARGIN / 5) *
- i + box_x + x_offset;
- pain.line(line_x, y_offset, line_x,
- y_offset + row_ptr->height() - 1 - (i - next_depth - 1) * 3,
- LColor::depthbar);
-
- if (i > prev_depth)
- pain.fillRectangle(line_x, y_offset, LYX_PAPER_MARGIN / 5, 2,
- LColor::depthbar);
- if (i > next_depth)
- pain.fillRectangle(line_x,
- y_offset + row_ptr->height() - 2 - (i - next_depth - 1) * 3,
- LYX_PAPER_MARGIN / 5, 2,
- LColor::depthbar);
- }
- }
-
-
- LyXLayout const & layout =
- textclasslist.Style(bview->buffer()->params.textclass,
- row_ptr->par()->getLayout());
+ p.pain->line(1, p.yo, 1, p.yo + p.row->height(), LColor::appendixline);
+ p.pain->line(ww - 2, p.yo, ww - 2, p.yo + p.row->height(), LColor::appendixline);
+ }
+}
+
+
+void LyXText::paintRowDepthBar(DrawRowParams & p)
+{
+ Paragraph::depth_type const depth = p.row->par()->getDepth();
+
+ if (depth <= 0)
+ return;
+
+ Paragraph::depth_type prev_depth = 0;
+ if (p.row->previous())
+ prev_depth = p.row->previous()->par()->getDepth();
+ Paragraph::depth_type next_depth = 0;
+ if (p.row->next())
+ next_depth = p.row->next()->par()->getDepth();
+
+ for (Paragraph::depth_type i = 1; i <= depth; ++i) {
+ int const x = (LYX_PAPER_MARGIN / 5) * i + p.xo;
+ int const h = p.yo + p.row->height() - 1 - (i - next_depth - 1) * 3;
+
+ p.pain->line(x, p.yo, x, h, LColor::depthbar);
+
+ int const w = LYX_PAPER_MARGIN / 5;
+
+ if (i > prev_depth) {
+ p.pain->fillRectangle(x, p.yo, w, 2, LColor::depthbar);
+ }
+ if (i > next_depth) {
+ p.pain->fillRectangle(x, h, w, 2, LColor::depthbar);
+ }
+ }
+}
+
+
+int LyXText::getLengthMarkerHeight(BufferView * bv, VSpace const & vsp) const
+{
+ int const arrow_size = 4;
+ int const space_size = int(vsp.inPixels(bv));
+
+ if (vsp.kind() != VSpace::LENGTH) {
+ return space_size;
+ }
+
+ LyXFont font;
+ font.decSize();
+ int const min_size = max(3 * arrow_size,
+ font_metrics::maxAscent(font)
+ + font_metrics::maxDescent(font));
+
+ if (vsp.length().len().value() < 0.0)
+ return min_size;
+ else
+ return max(min_size, space_size);
+}
+
+
+int LyXText::drawLengthMarker(DrawRowParams & p, string const & prefix,
+ VSpace const & vsp, int start)
+{
+ int const arrow_size = 4;
+ int const size = getLengthMarkerHeight(p.bv, vsp);
+ int const end = start + size;
+
+ // the label to display (if any)
+ string str;
+ // y-values for top arrow
+ int ty1, ty2;
+ // y-values for bottom arrow
+ int by1, by2;
+ switch (vsp.kind()) {
+ case VSpace::LENGTH:
+ {
+ str = prefix + " (" + vsp.asLyXCommand() + ')';
+ // adding or removing space
+ bool const added = !(vsp.length().len().value() < 0.0);
+ ty1 = added ? (start + arrow_size) : start;
+ ty2 = added ? start : (start + arrow_size);
+ by1 = added ? (end - arrow_size) : end;
+ by2 = added ? end : (end - arrow_size);
+ break;
+ }
+ case VSpace::VFILL:
+ str = prefix + _(" (vertical fill)");
+ ty1 = ty2 = start;
+ by1 = by2 = end;
+ break;
+ default:
+ // nothing to draw here
+ return size;
+ }
+
+ int const leftx = p.xo + leftMargin(p.bv, p.row);
+ int const midx = leftx + arrow_size;
+ int const rightx = midx + arrow_size;
+
+ // first the string
+ int w = 0;
+ int a = 0;
+ int d = 0;
+
+ LyXFont font;
+ font.setColor(LColor::added_space).decSize();
+ font_metrics::rectText(str, font, w, a, d);
+
+ p.pain->rectText(leftx + 2 * arrow_size + 5,
+ start + ((end - start) / 2) + d,
+ str, font);
+
+ // top arrow
+ p.pain->line(leftx, ty1, midx, ty2, LColor::added_space);
+ p.pain->line(midx, ty2, rightx, ty1, LColor::added_space);
+
+ // bottom arrow
+ p.pain->line(leftx, by1, midx, by2, LColor::added_space);
+ p.pain->line(midx, by2, rightx, by1, LColor::added_space);
+
+ // joining line
+ p.pain->line(midx, ty2, midx, by2, LColor::added_space);
+
+ return size;
+}
+
+
+int LyXText::paintPageBreak(string const & label, int y, DrawRowParams & p)
+{
+ LyXFont pb_font;
+ pb_font.setColor(LColor::pagebreak).decSize();
+
+ int w = 0;
+ int a = 0;
+ int d = 0;
+ font_metrics::rectText(label, pb_font, w, a, d);
+
+ int const text_start = p.xo + ((p.width - w) / 2);
+ int const text_end = text_start + w;
+
+ p.pain->rectText(text_start, y + d, label, pb_font);
+
+ p.pain->line(p.xo, y, text_start, y,
+ LColor::pagebreak, Painter::line_onoffdash);
+ p.pain->line(text_end, y, p.xo + p.width, y,
+ LColor::pagebreak, Painter::line_onoffdash);
+
+ return 3 * defaultHeight();
+}
+
+
+void LyXText::paintFirstRow(DrawRowParams & p)
+{
+ Paragraph * par = p.row->par();
+ ParagraphParameters const & parparams = par->params();
+
+ // start of appendix?
+ if (parparams.startOfAppendix()) {
+ p.pain->line(1, p.yo, p.width - 2, p.yo, LColor::appendixline);
+ }