diff mde/gui/widget/layout.d @ 78:79a1809421aa

Widget data saving reimplemented for the new data system. (Now grid layout widgets remember their row & column sizes.)
author Diggory Hardy <diggory.hardy@gmail.com>
date Tue, 29 Jul 2008 18:14:53 +0100
parents 3dfd934100f7
children 56c0ddd90193
line wrap: on
line diff
--- a/mde/gui/widget/layout.d	Tue Jul 29 17:11:22 2008 +0100
+++ b/mde/gui/widget/layout.d	Tue Jul 29 18:14:53 2008 +0100
@@ -61,6 +61,7 @@
             (data.ints.length != 3 && data.ints.length != 3 + rows + cols) ||
             data.strings.length != rows * cols)
             throw new WidgetDataException;
+        this.data = data;
         
         // Get all sub-widgets
         subWidgets.length = rows*cols;
@@ -79,19 +80,20 @@
         }
         adjustCache;
     }
-    /+FIXME
-    /** Return construction data to recreate this GridLayoutWidget. */
-    int[] getCreationData () {
-        int[] ret;
-        ret.length = 3 + subWidgets.length;
-        
-        ret [0..3] = [widgetType, rows, cols];  // first data
-        
-        foreach (i,widget; subWidgets)          // sub widgets
-            ret[i+3] = window.addCreationData (widget);
-        
-        return ret;
-    }+/
+    
+    // Save column/row sizes. Currently always do so.
+    bool saveChanges (widgetID id) {
+        with (data) {
+            foreach (i, widget; subWidgets) // recurse on subwidgets
+                widget.saveChanges (strings[i]);
+            
+            ints = ints[0..3] ~ cast(int[])col.width ~ cast(int[])row.width;
+        }
+        mgr.setData (id, data);
+        return true;
+    }
+protected:
+    WidgetData data;
 }
 
 
@@ -124,11 +126,6 @@
         adjustCache;
     }
     
-    /+FIXME
-    int[] getCreationData () {
-        return [widgetType];
-    }+/
-    
 private:
     OptionList optsList;
 }
@@ -183,16 +180,6 @@
             widget.setHeight (row.width[i / cols], -1);
         }
     }
-    /+ FIXME - saving
-    /** Returns sub-widget mutable data along with column widths and row heights, as used by
-     *  adjust(). */
-    int[] getMutableData () {
-        int[] ret;
-        foreach (widget; subWidgets)
-            ret ~= widget.getMutableData;
-        
-        return ret ~ cast(int[])col.width ~ cast(int[])row.width;
-    }+/
     //END Creation & saving
     
     //BEGIN Size & position