view 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
line wrap: on
line source


/*
 * Copyright Jordan Miner
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 */

module dynamin.gui.label;

import dynamin.core.string;
import dynamin.all_painting;
import dynamin.all_gui;

///
class Label : Control {
protected:
	override Size bestSize() {
		Size s;
		withGraphics((Graphics g) { s = g.getTextExtents(text); });
		return s;
	}
	override void whenPainting(PaintingEventArgs e) {
		with(e.graphics) {
			drawText(text, 0, (height-getTextExtents(text).height)/2);
		}
	}
public:
	this() {
	}
	this(string text) {
		this();
		this.text = text;
	}
	override int baseline() { return 10; }
}