Mercurial > projects > mde
diff mde/gui/widget/Widget.d @ 112:fe061009029d
EnumContent; log level can be selected from a popup list.
New EnumContent, with code to load translations in Items. Editable as an AStringContent.
Hacked OptionsMisc to use an EnumContent.
Implemented a EnumContentWidget providing a pop-up list to select from (still needs improving).
Moved IContent to its own module.
ContentExceptions thrown via WDCCheck now.
Fixed a small bug with reloading translations.
author | Diggory Hardy <diggory.hardy@gmail.com> |
---|---|
date | Sat, 13 Dec 2008 12:54:43 +0000 |
parents | 1655693702fc |
children | 9824bee909fd |
line wrap: on
line diff
--- a/mde/gui/widget/Widget.d Sat Dec 06 17:41:42 2008 +0000 +++ b/mde/gui/widget/Widget.d Sat Dec 13 12:54:43 2008 +0000 @@ -26,6 +26,7 @@ module mde.gui.widget.Widget; public import mde.gui.widget.Ifaces; +import mde.content.IContent; import mde.gui.exception; debug { @@ -130,9 +131,14 @@ protected: /********************************************************************************************** - * Widgets may use WDCheck as a utility to check what data holds. Its use is encouraged, so - * that the checks can easily be updated should WidgetData be changed. WDMinCheck is similar, - * but allows more data than required; it is used by some generic content widgets. + * Widgets may use W*Check as a utility to check for existance of data. Its use is encouraged, + * so that the checks can easily be updated should WidgetData be changed. + * + * Variants: + * WDCheck checks the exact length of integer and string data. + * WDCCheck checks data as WDCheck and that the content passed is valid. + * WDCMinCheck does the same as WDCCheck, but allows more data than required (used by some + * generic widgets). * * Params: * data = the WidgetData to check lengths of @@ -145,10 +151,20 @@ throw new WidgetDataException (this); } /** ditto */ - void WDMinCheck (WidgetData data, size_t n_ints, size_t n_strings = 0) { + void WDCCheck (WidgetData data, size_t n_ints, size_t n_strings, IContent c) { + if (data.ints.length != n_ints || + data.strings.length != n_strings) + throw new WidgetDataException (this); + if (c is null) + throw new ContentException (this); + } + /** ditto */ + void WDCMinCheck (WidgetData data, size_t n_ints, size_t n_strings, IContent c) { if (data.ints.length < n_ints || data.strings.length < n_strings) throw new WidgetDataException (this); + if (c is null) + throw new ContentException (this); } widgetID id; // The widget's ID, used for saving data