Mercurial > projects > mde
diff mde/gui/widget/TextWidget.d @ 95:2a364c7d82c9
Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Fixed a minor bug where layouts with the same id but without shared alignments would be messed up.
Tracked down the "nothing trawn until a resize" bug (see jobs.txt).
If widgets throw during creation they're now replaced by debug widgets.
Function pointers are converted to delegates using a safer method.
author | Diggory Hardy <diggory.hardy@gmail.com> |
---|---|
date | Thu, 06 Nov 2008 11:07:18 +0000 |
parents | 9520cc0448e5 |
children | dbf332403c6e |
line wrap: on
line diff
--- a/mde/gui/widget/TextWidget.d Thu Oct 23 17:45:49 2008 +0100 +++ b/mde/gui/widget/TextWidget.d Thu Nov 06 11:07:18 2008 +0000 @@ -32,18 +32,14 @@ } } -/// Basic text widget -class TextLabelWidget : Widget +/** Base text widget. + * + * Little use currently except to ease future additions. */ +class ATextWidget : AWidget { - /** Constructor for a widget containing [fixed] content. - * - * Widget uses the initialisation data: - * [widgetID, contentID, colour] - * where contentID is an ID for the string ID of the contained content - * and colour is an 8-bit-per-channel RGB colour of the form 0xRRGGBB. */ + /** Set the adapter first: + * adapter = mgr.renderer.getAdapter ("string", 0xRRGGBB); */ this (IWidgetManager mgr, widgetID id, WidgetData data) { - WDCheck (data, 2, 1); - adapter = mgr.renderer.getAdapter (data.strings[0], data.ints[1]); adapter.getDimensions (mw, mh); super (mgr, id, data); } @@ -57,26 +53,37 @@ IRenderer.TextAdapter adapter; } + +/// Basic text widget +class TextLabelWidget : ATextWidget +{ + /** Constructor for a widget containing [fixed] content. + * + * Widget uses the initialisation data: + * [widgetID, contentID, colour] + * where contentID is an ID for the string ID of the contained content + * and colour is an 8-bit-per-channel RGB colour of the form 0xRRGGBB. */ + this (IWidgetManager mgr, widgetID id, WidgetData data) { + WDCheck (data, 2, 1); + adapter = mgr.renderer.getAdapter (data.strings[0], data.ints[1]); + super (mgr, id, data); + } +} + /// Basic widget displaying a label from a content. -class ContentLabelWidget : Widget +class ContentLabelWidget : ATextWidget { this (IWidgetManager mgr, widgetID id, WidgetData data, IContent c) { debug assert (c, "content is null (code error)"); WDCheck (data, 3, 0); content = c; + if (!content) throw new ContentException (); index = data.ints[1]; adapter = mgr.renderer.getAdapter (content.toString(index), data.ints[2]); - adapter.getDimensions (mw, mh); super (mgr, id,data); } - void draw () { - super.draw(); - adapter.draw (x,y); - } - protected: - IRenderer.TextAdapter adapter; IContent content; int index; }