comparison 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
comparison
equal deleted inserted replaced
93:08a4ae11454b 94:9520cc0448e5
98 class TrialContentLayoutWidget : GridWidget 98 class TrialContentLayoutWidget : GridWidget
99 { 99 {
100 this (IWidgetManager mgr, widgetID id, WidgetData data) { 100 this (IWidgetManager mgr, widgetID id, WidgetData data) {
101 debug scope (failure) 101 debug scope (failure)
102 logger.warn ("TrialContentLayoutWidget: failure"); 102 logger.warn ("TrialContentLayoutWidget: failure");
103 WDCheck (data, 2, 1); 103 WDCheck (data, 2, 2);
104 104
105 OptionList optsList = OptionList.trial(); 105 OptionList optsList = new OptionList(data.strings[1]);
106 rows = optsList.list.length;
107 cols = 1; 106 cols = 1;
108 107 if ((rows = optsList.list.length) > 0) {
109 // Get all sub-widgets 108 // Get all sub-widgets
110 subWidgets.length = rows*cols; 109 subWidgets.length = rows*cols;
111 foreach (i, c; optsList.list) { 110 foreach (i, c; optsList.list) {
112 subWidgets[i] = mgr.makeWidget (data.strings[0], c); 111 subWidgets[i] = mgr.makeWidget (data.strings[0], c);
112 }
113 } else {
114 rows = 1;
115 subWidgets = [mgr.makeWidget (data.strings[0], new TextContent (data.strings[1], "Invalid Options section"))];
113 } 116 }
114 super (mgr, id, data); 117 super (mgr, id, data);
115 } 118 }
116 119
117 bool saveChanges () { 120 bool saveChanges () {
174 177
175 /** Responsible for calculating the minimal size and initializing some stuff. 178 /** Responsible for calculating the minimal size and initializing some stuff.
176 * 179 *
177 * As such, this must be the first function called after this(). */ 180 * As such, this must be the first function called after this(). */
178 void finalize () { 181 void finalize () {
179 logger.trace ("initWidths.length: {}", initWidths.length);
180 if (initWidths.length == cols + rows) { 182 if (initWidths.length == cols + rows) {
181 col.setWidths (initWidths[0..cols]); 183 col.setWidths (initWidths[0..cols]);
182 row.setWidths (initWidths[cols..$]); 184 row.setWidths (initWidths[cols..$]);
183 } else { 185 } else {
184 col.setWidths; 186 col.setWidths;