PageRenderTime 27ms CodeModel.GetById 23ms app.highlight 2ms RepoModel.GetById 2ms app.codeStats 0ms

/graphics/pen.d

http://github.com/wilkie/djehuty
D | 54 lines | 33 code | 16 blank | 5 comment | 2 complexity | e0acca60db5d961cc57e6772a266d30b MD5 | raw file
 1module graphics.pen;
 2
 3import platform.vars.pen;
 4
 5import Scaffold = scaffold.graphics;
 6
 7import core.color;
 8
 9import graphics.view;
10import graphics.brush;
11
12class Pen {
13
14public:
15
16	// Constructor
17	this(Color clr, double width = 1.0) {
18		_width = width;
19		Scaffold.createPen(&_pfvars, clr, width);
20	}
21
22	this(Brush brush, double width = 1.0) {
23		_width = width;
24		Scaffold.createPenWithBrush(&_pfvars, brush._pfvars, width);
25	}
26
27	// Destructor
28	~this() {
29		Scaffold.destroyPen(&_pfvars);
30	}
31
32	// Sets color of a solid brush
33	void setColor(Color clr) {
34		Scaffold.destroyPen(&_pfvars);
35		Scaffold.createPen(&_pfvars, clr, _width);
36
37		// when tied to a locked view, update the brush being used
38		if (_view !is null) {
39			if (_view._locked) {
40				_view._graphics.pen = _view._pen;
41			}
42		}
43	}
44
45private:
46
47	double _width;
48
49	package PenPlatformVars _pfvars;
50
51	// tied to a view?
52	package View _view; // will be null if no view is tied with it
53
54}