From 6f852e5846608c0d654f947824fc6197676ff7d7 Mon Sep 17 00:00:00 2001 From: twanvl Date: Tue, 19 Dec 2006 17:36:17 +0000 Subject: [PATCH] drawing borders git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@128 0fc631ac-6414-0410-93d0-97cfa31319b6 --- src/render/text/viewer.cpp | 25 +++++++++++++++++++++++++ src/render/text/viewer.hpp | 2 ++ 2 files changed, 27 insertions(+) diff --git a/src/render/text/viewer.cpp b/src/render/text/viewer.cpp index 4c41ac74..b807d40b 100644 --- a/src/render/text/viewer.cpp +++ b/src/render/text/viewer.cpp @@ -67,6 +67,11 @@ TextViewer::~TextViewer() {} void TextViewer::draw(RotatedDC& dc, const TextStyle& style, DrawWhat what) { assert(!lines.empty()); 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 FOR_EACH(l, lines) { if (l.visible(dc)) { @@ -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) { if (lines.empty()) { // not prepared yet diff --git a/src/render/text/viewer.hpp b/src/render/text/viewer.hpp index 325f5119..2417048a 100644 --- a/src/render/text/viewer.hpp +++ b/src/render/text/viewer.hpp @@ -50,6 +50,8 @@ class TextViewer { void draw(RotatedDC& dc, const TextStyle& style, DrawWhat what); /// Draw an indicator for selected text void drawSelection(RotatedDC& dc, const TextStyle& style, size_t sel_start, size_t sel_end); + /// Draw separators for tags + void drawSeparators(RotatedDC& dc); /// Prepare the text for drawing, if it is not already prepared void prepare(RotatedDC& dc, const String& text, const TextStyle& style, Context&);