comparison mde/gui/widget/Floating.d @ 92:085f2ca31914

Shared alignments supported in more complex cases.
author Diggory Hardy <diggory.hardy@gmail.com>
date Tue, 21 Oct 2008 09:57:19 +0100
parents 4d5d53e4f881
children 2a364c7d82c9
comparison
equal deleted inserted replaced
91:4d5d53e4f881 92:085f2ca31914
51 * 51 *
52 * Data: Each string item is interpreted as a subwidget widgetID. 52 * Data: Each string item is interpreted as a subwidget widgetID.
53 * Ints supplied may consist of just the widget type or 53 * Ints supplied may consist of just the widget type or
54 * additionally an (x,y) coordinate for each subwidget (all x coords first, then all y coords). 54 * additionally an (x,y) coordinate for each subwidget (all x coords first, then all y coords).
55 */ 55 */
56 class FloatingAreaWidget : SizableWidget 56 class FloatingAreaWidget : ParentWidget
57 { 57 {
58 this (IWidgetManager mgr, widgetID id, WidgetData data) { 58 this (IWidgetManager mgr, widgetID id, WidgetData data) {
59 subWidgets.length = data.strings.length; 59 subWidgets.length = data.strings.length;
60 foreach (i,s; data.strings) 60 foreach (i,s; data.strings)
61 subWidgets[i] = mgr.makeWidget (s); 61 subWidgets[i] = mgr.makeWidget (s);
62 foreach (w; subWidgets)
63 w.finalize;
62 sWCoords.length = subWidgets.length; 64 sWCoords.length = subWidgets.length;
63 65
64 if (data.ints.length != 1) { 66 if (data.ints.length != 1) {
65 if (data.ints.length != 2*subWidgets.length + 1) { 67 if (data.ints.length != 2*subWidgets.length + 1) {
66 throw new WidgetDataException (this); 68 throw new WidgetDataException (this);
78 w.setWidth (w.minWidth, -1); 80 w.setWidth (w.minWidth, -1);
79 w.setHeight (w.minHeight, -1); 81 w.setHeight (w.minHeight, -1);
80 } 82 }
81 } 83 }
82 84
85 bool isWSizable () { return true; }
86 bool isHSizable () { return true; }
87
83 void setPosition (wdim x, wdim y) { 88 void setPosition (wdim x, wdim y) {
84 super.setPosition (x,y); 89 super.setPosition (x,y);
85 90
86 foreach (i,c; sWCoords) 91 foreach (i,c; sWCoords)
87 subWidgets[i].setPosition (x+c.x, y+c.y); 92 subWidgets[i].setPosition (x+c.x, y+c.y);
95 foreach (w; subWidgets) 100 foreach (w; subWidgets)
96 w.draw; 101 w.draw;
97 } 102 }
98 103
99 protected: 104 protected:
100 IChildWidget[] subWidgets; // all subwidgets, framed or not
101 wdimPair[] sWCoords; // coords for subwidgets, relative to this widget 105 wdimPair[] sWCoords; // coords for subwidgets, relative to this widget
102 106
103 /+ 107 /+
104 /** Call after loading is finished to setup the window and confirm that it's valid. 108 /** Call after loading is finished to setup the window and confirm that it's valid.
105 * 109 *