mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
drawing <line> borders
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@128 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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 <line> 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&);
|
||||
|
||||
Reference in New Issue
Block a user