Repository navigation
Expand file tree
/
Copy pathtext.cpp
More file actions
49 lines (39 loc) · 1.63 KB
/
Copy pathtext.cpp
File metadata and controls
49 lines (39 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//+----------------------------------------------------------------------------+
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
//| Copyright: (C) 2001 - 2012 Twan van Laarhoven and Sean Hunt |
//| License: GNU General Public License 2 or later (see file COPYING) |
//+----------------------------------------------------------------------------+
// ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp>
#include <render/value/text.hpp>
#include <render/card/viewer.hpp>
// ----------------------------------------------------------------------------- : TextValueViewer
IMPLEMENT_VALUE_VIEWER(Text);
bool TextValueViewer::prepare(RotatedDC& dc) {
getMask(dc); // ensure alpha/contour mask is loaded
return v.prepare(dc, value().value->toString(), style(), viewer.getContext());
}
void TextValueViewer::draw(RotatedDC& dc) {
drawFieldBorder(dc);
if (!v.prepared()) {
v.prepare(dc, value().value->toString(), style(), viewer.getContext());
dc.setStretch(getStretch());
}
DrawWhat what = viewer.drawWhat(this);
v.draw(dc, style(), (DrawWhat)(what & DRAW_ACTIVE));
setFieldBorderPen(dc);
v.draw(dc, style(), (DrawWhat)(what & ~DRAW_ACTIVE));
}
void TextValueViewer::onValueChange() {
v.reset(false);
}
void TextValueViewer::onStyleChange(int changes) {
v.reset(true);
ValueViewer::onStyleChange(changes);
}
void TextValueViewer::onAction(const Action&, bool undone) {
v.reset(true);
}
double TextValueViewer::getStretch() const {
return v.prepared() ? style().getStretch() : 1.0;
}