Mercurial > projects > dynamin
comparison dynamin/gui/label.d @ 0:aa4efef0f0b1
Initial commit of code.
author | Jordan Miner <jminer7@gmail.com> |
---|---|
date | Mon, 15 Jun 2009 22:10:48 -0500 |
parents | |
children | 73060bc3f004 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:aa4efef0f0b1 |
---|---|
1 // Written in the D programming language | |
2 // www.digitalmars.com/d/ | |
3 | |
4 /* | |
5 * The contents of this file are subject to the Mozilla Public License Version | |
6 * 1.1 (the "License"); you may not use this file except in compliance with | |
7 * the License. You may obtain a copy of the License at | |
8 * http://www.mozilla.org/MPL/ | |
9 * | |
10 * Software distributed under the License is distributed on an "AS IS" basis, | |
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | |
12 * for the specific language governing rights and limitations under the | |
13 * License. | |
14 * | |
15 * The Original Code is the Dynamin library. | |
16 * | |
17 * The Initial Developer of the Original Code is Jordan Miner. | |
18 * Portions created by the Initial Developer are Copyright (C) 2007-2009 | |
19 * the Initial Developer. All Rights Reserved. | |
20 * | |
21 * Contributor(s): | |
22 * Jordan Miner <jminer7@gmail.com> | |
23 * | |
24 */ | |
25 | |
26 module dynamin.gui.label; | |
27 | |
28 import dynamin.core.string; | |
29 import dynamin.all_painting; | |
30 import dynamin.all_gui; | |
31 | |
32 /// | |
33 class Label : Control { | |
34 protected: | |
35 override Size bestSize() { | |
36 Size s; | |
37 withGraphics((Graphics g) { s = g.getTextExtents(text); }); | |
38 return s; | |
39 } | |
40 override void whenPainting(PaintingEventArgs e) { | |
41 with(e.graphics) { | |
42 drawText(text, 0, (height-getTextExtents(text).height)/2); | |
43 } | |
44 } | |
45 public: | |
46 this() { | |
47 } | |
48 this(string text) { | |
49 this(); | |
50 this.text = text; | |
51 } | |
52 override int baseline() { return 10; } | |
53 } | |
54 |