diff mde/gui/widget/Widget.d @ 77:3dfd934100f7

Continuing widget data changes started in last commit: all previous widgets work again now (but lacking saving).
author Diggory Hardy <diggory.hardy@gmail.com>
date Tue, 29 Jul 2008 17:11:22 +0100
parents 65780e0e48e6
children 79a1809421aa
line wrap: on
line diff
--- a/mde/gui/widget/Widget.d	Mon Jul 28 18:49:18 2008 +0100
+++ b/mde/gui/widget/Widget.d	Tue Jul 29 17:11:22 2008 +0100
@@ -13,21 +13,43 @@
 You should have received a copy of the GNU General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>. */
 
-/** GUI Widget module.
+/*************************************************************************************************
+ * GUI Widget module.
  *
  * This module contains some base widget classes suitable for widget classes to inherit. However,
- * inheriting one of them is by no means necessary for a widget so long as the IWidget interface is
- * implemented. */
+ * inheriting one of them is by no means necessary for a widget so long as the IWidget interface
+ * is implemented.
+ *************************************************************************************************/
 module mde.gui.widget.Widget;
 
 public import mde.gui.widget.Ifaces;
 import mde.gui.renderer.IRenderer;
+import mde.gui.exception;
 
-/** An abstract base widget class.
-*
-* This abstract class, and the more concrete FixedWidget and ScalableWidget classes provides a
-* useful basic implementation for widgets. Widgets need not inherit these (they only need implement
-* IWidget); they are simply provided for convenience and to promote code reuse. */
+
+/*************************************************************************************************
+ * 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.
+ * 
+ * Params:
+ *  data    = the WidgetData to check lengths of
+ *  n_ints  = number of integers wanted
+ *  n_strings= number of strings (default 0 since not all widgets use strings)
+ *************************************************************************************************/
+void WDCheck (WidgetData data, size_t n_ints, size_t n_strings = 0) {
+    if (data.ints.length    != n_ints ||
+        data.strings.length != n_strings)
+        throw new WidgetDataException;
+}
+
+
+/*************************************************************************************************
+ * An abstract base widget class.
+ *
+ * This abstract class, and the more concrete FixedWidget and ScalableWidget classes provides a
+ * useful basic implementation for widgets. Widgets need not inherit these (they only need
+ * implement IWidget); they are simply provided for convenience and to promote code reuse.
+ *************************************************************************************************/
 abstract class Widget : IChildWidget
 {
 //BEGIN Load and save