Mercurial > projects > dynamin
annotate dynamin/gui/label.d @ 103:73060bc3f004
Change license to Boost 1.0 and MPL 2.0.
author | Jordan Miner <jminer7@gmail.com> |
---|---|
date | Tue, 15 May 2012 22:06:02 -0500 |
parents | aa4efef0f0b1 |
children |
rev | line source |
---|---|
0 | 1 |
2 /* | |
103
73060bc3f004
Change license to Boost 1.0 and MPL 2.0.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
3 * Copyright Jordan Miner |
0 | 4 * |
103
73060bc3f004
Change license to Boost 1.0 and MPL 2.0.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
5 * This Source Code Form is subject to the terms of the Mozilla Public |
73060bc3f004
Change license to Boost 1.0 and MPL 2.0.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
6 * License, v. 2.0. If a copy of the MPL was not distributed with this |
73060bc3f004
Change license to Boost 1.0 and MPL 2.0.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
0 | 8 * |
9 */ | |
10 | |
11 module dynamin.gui.label; | |
12 | |
13 import dynamin.core.string; | |
14 import dynamin.all_painting; | |
15 import dynamin.all_gui; | |
16 | |
17 /// | |
18 class Label : Control { | |
19 protected: | |
20 override Size bestSize() { | |
21 Size s; | |
22 withGraphics((Graphics g) { s = g.getTextExtents(text); }); | |
23 return s; | |
24 } | |
25 override void whenPainting(PaintingEventArgs e) { | |
26 with(e.graphics) { | |
27 drawText(text, 0, (height-getTextExtents(text).height)/2); | |
28 } | |
29 } | |
30 public: | |
31 this() { | |
32 } | |
33 this(string text) { | |
34 this(); | |
35 this.text = text; | |
36 } | |
37 override int baseline() { return 10; } | |
38 } | |
39 |