Commit 0f33f760 authored by twanvl's avatar twanvl

drawing <line> borders

parent 027e1199
...@@ -67,6 +67,11 @@ TextViewer::~TextViewer() {} ...@@ -67,6 +67,11 @@ TextViewer::~TextViewer() {}
void TextViewer::draw(RotatedDC& dc, const TextStyle& style, DrawWhat what) { void TextViewer::draw(RotatedDC& dc, const TextStyle& style, DrawWhat what) {
assert(!lines.empty()); assert(!lines.empty());
Rotater r(dc, style.getRotation()); Rotater r(dc, style.getRotation());
// separator lines?
// do this first, so pen is still set from drawing the field border
if (what & DRAW_BORDERS) {
drawSeparators(dc);
}
// Draw the text, line by line // Draw the text, line by line
FOR_EACH(l, lines) { FOR_EACH(l, lines) {
if (l.visible(dc)) { if (l.visible(dc)) {
...@@ -98,6 +103,26 @@ void TextViewer::Line::drawSelection(RotatedDC& dc, size_t sel_start, size_t sel ...@@ -98,6 +103,26 @@ void TextViewer::Line::drawSelection(RotatedDC& dc, size_t sel_start, size_t sel
} }
} }
void TextViewer::drawSeparators(RotatedDC& dc) {
// separator lines
bool separator = false;
double y = 0;
FOR_EACH(l, lines) {
double y2 = l.top + l.line_height;
if (separator && l.visible(dc)) {
// between the two lines
y = (y + l.top) / 2;
dc.DrawLine(RealPoint(0, y), RealPoint(dc.getInternalRect().width, y));
}
separator = l.separator_after;
y = y2;
}
// separator at the end?
if (separator) {
dc.DrawLine(RealPoint(0, y), RealPoint(dc.getInternalRect().width, y));
}
}
void TextViewer::prepare(RotatedDC& dc, const String& text, const TextStyle& style, Context& ctx) { void TextViewer::prepare(RotatedDC& dc, const String& text, const TextStyle& style, Context& ctx) {
if (lines.empty()) { if (lines.empty()) {
// not prepared yet // not prepared yet
......
...@@ -50,6 +50,8 @@ class TextViewer { ...@@ -50,6 +50,8 @@ class TextViewer {
void draw(RotatedDC& dc, const TextStyle& style, DrawWhat what); void draw(RotatedDC& dc, const TextStyle& style, DrawWhat what);
/// Draw an indicator for selected text /// Draw an indicator for selected text
void drawSelection(RotatedDC& dc, const TextStyle& style, size_t sel_start, size_t sel_end); void drawSelection(RotatedDC& dc, const TextStyle& style, size_t sel_start, size_t sel_end);
/// Draw separators for <line> tags
void drawSeparators(RotatedDC& dc);
/// Prepare the text for drawing, if it is not already prepared /// Prepare the text for drawing, if it is not already prepared
void prepare(RotatedDC& dc, const String& text, const TextStyle& style, Context&); void prepare(RotatedDC& dc, const String& text, const TextStyle& style, Context&);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment