diff mde/gui/widget/layout.d @ 94:9520cc0448e5

Boolean options are now encapsulated within a Content class (currently an experiment). This should facilitate generic option editing widgets.
author Diggory Hardy <diggory.hardy@gmail.com>
date Thu, 23 Oct 2008 17:45:49 +0100
parents 08a4ae11454b
children 2a364c7d82c9
line wrap: on
line diff
--- a/mde/gui/widget/layout.d	Tue Oct 21 11:35:15 2008 +0100
+++ b/mde/gui/widget/layout.d	Thu Oct 23 17:45:49 2008 +0100
@@ -100,16 +100,19 @@
     this (IWidgetManager mgr, widgetID id, WidgetData data) {
         debug scope (failure)
                 logger.warn ("TrialContentLayoutWidget: failure");
-        WDCheck (data, 2, 1);
+        WDCheck (data, 2, 2);
         
-        OptionList optsList = OptionList.trial();
-        rows = optsList.list.length;
+        OptionList optsList = new OptionList(data.strings[1]);
         cols = 1;
-        
-        // Get all sub-widgets
-        subWidgets.length = rows*cols;
-        foreach (i, c; optsList.list) {
-            subWidgets[i] = mgr.makeWidget (data.strings[0], c);
+        if ((rows = optsList.list.length) > 0) {
+            // Get all sub-widgets
+            subWidgets.length = rows*cols;
+            foreach (i, c; optsList.list) {
+                subWidgets[i] = mgr.makeWidget (data.strings[0], c);
+            }
+        } else {
+            rows = 1;
+            subWidgets = [mgr.makeWidget (data.strings[0], new TextContent (data.strings[1], "Invalid Options section"))];
         }
         super (mgr, id, data);
     }
@@ -176,7 +179,6 @@
      *
      * As such, this must be the first function called after this(). */
     void finalize () {
-        logger.trace ("initWidths.length: {}", initWidths.length);
         if (initWidths.length == cols + rows) {
             col.setWidths (initWidths[0..cols]);
             row.setWidths (initWidths[cols..$]);