comparison mde/gui/widget/layout.d @ 131:9cff74f68b84

Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module. Moved Widget.AWidget to AChildWidget.AChildWidget and Widget.AParentWidget to AParentWidget.AParentWidget. Removed ASingleParentWidget to improve code sharing. AChildWidget doesn't implement IParentWidget like AWidget did. New IPopupParentWidget extending IParentWidget for the WM and some widgets to handle popups. Cut old popup management code. New underMouse() function replacing highlight(); called on all widgets. Separate menu-popup and button widgets aren't needed for menus now. Functions returning content widgets have been moved to their own module. Cleaned up jobs.txt. Switched to 80 line length for Ddoc.
author Diggory Hardy <diggory.hardy@gmail.com>
date Wed, 21 Jan 2009 13:01:40 +0000
parents c5c38eaadb64
children 9fd705793568
comparison
equal deleted inserted replaced
130:c5c38eaadb64 131:9cff74f68b84
14 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 14 along with this program. If not, see <http://www.gnu.org/licenses/>. */
15 15
16 /// Gui layout widgets. 16 /// Gui layout widgets.
17 module mde.gui.widget.layout; 17 module mde.gui.widget.layout;
18 18
19 import mde.gui.widget.Widget; 19 import mde.gui.widget.AParentWidget;
20 import mde.gui.exception; 20 import mde.gui.exception;
21 21
22 import mde.content.miscContent; 22 import mde.content.miscContent;
23 23
24 import tango.util.container.HashMap; 24 import tango.util.container.HashMap;
33 33
34 /************************************************************************************************* 34 /*************************************************************************************************
35 * Encapsulates a grid of Widgets. 35 * Encapsulates a grid of Widgets.
36 * 36 *
37 * Currently there is no support for changing number of cells, sub-widgets or sub-widget properties 37 * Currently there is no support for changing number of cells, sub-widgets or sub-widget properties
38 * (namely isW/HSizable and minimal size) after this() has run. 38 * (namely isW/HSizable) after this() has run.
39 *
40 * Since a grid with either dimension zero is not useful, there must be at least one sub-widget.
41 *
42 * The grid has no border but has spacing between widgets.
43 *************************************************************************************************/ 39 *************************************************************************************************/
44 class GridLayoutWidget : GridWidget 40 class GridLayoutWidget : GridWidget
45 { 41 {
46 /** Constructor for a grid layout widget. 42 /** Constructor for a grid layout widget.
47 * 43 *
48 * Widget uses the initialisation data: 44 * Widget uses the initialisation data:
49 * --- 45 * ---
50 * ints = [widget_type, align_flags, rows, cols] 46 * ints = [widget_type, align_flags, rows, cols]
51 * // or with column widths and row heights:
52 * ints = [widget_type, align_flags, rows, cols, col1width, ..., colCwidth, row1height, ..., rowRheight]
53 * strings = [w11, w12, ..., w1C, ..., wR1, ..., wRC] 47 * strings = [w11, w12, ..., w1C, ..., wR1, ..., wRC]
48 * // dimData may be:
49 * dimData = [col1width, ..., colCwidth, row1height, ..., rowRheight]
54 * --- 50 * ---
55 * where R and C are the number of rows and columns, and wij is the ID (from parent Window's 51 * where R and C are the number of rows and columns, and wij is the ID (from parent Window's
56 * list) for the widget in row i and column j. The number of parameters must be r*c + 3. 52 * list) for the widget in row i and column j. The number of parameters must be r*c + 3.
57 * 53 *
58 * The content parameter is passed on to all children accepting an IContent. */ 54 * The content parameter is passed on to all children accepting an IContent. */
134 130
135 /************************************************************************************************* 131 /*************************************************************************************************
136 * Backend for grid-based (includes column/row) layout widgets. 132 * Backend for grid-based (includes column/row) layout widgets.
137 * 133 *
138 * A deriving class must at least do some work in it's constructor (see Ddoc for this() below) 134 * A deriving class must at least do some work in it's constructor (see Ddoc for this() below)
139 * and provide an implementation of getCreationData() (unless Widget's version is sufficient). 135 * and provide an implementation of saveChanges() (unless Widget's version is sufficient).
140 * 136 *
141 * Since a grid with either dimension zero is not useful, there must be at least one sub-widget. 137 * Since a grid with either dimension zero is not useful, there must be at least one sub-widget.
142 * 138 *
143 * The grid has no border but has spacing between widgets. 139 * The grid has no border but optionally has spacing between widgets.
140 *
141 * Several flags are tested against ints[1]:
142 * $(TABLE
143 * $(TR $(TD 1) $(TD Column alignment is shared against other instances of thes widget id))
144 * $(TR $(TD 2) $(TD Row alignment is shared against other instances of thes widget id))
145 * $(TR $(TD 4) $(TD Spacing is inserted between elements; the renderer may draw this))
146 * $(TR $(TD 8) $(TD For ContentListWidget only, list is horizontal instead of vertical))
147 * )
144 *************************************************************************************************/ 148 *************************************************************************************************/
145 // Note: mw, mh inherited from AWidget are not used; use col.mw, row.mw instead. 149 // Note: mw, mh inherited from AWidget are not used; use col.mw, row.mw instead.
146 abstract class GridWidget : AParentWidget 150 abstract class GridWidget : AParentWidget
147 { 151 {
148 //BEGIN Creation & saving 152 //BEGIN Creation & saving
849 static HashMap!(widgetID,AlignColumns) instances; 853 static HashMap!(widgetID,AlignColumns) instances;
850 static this () { 854 static this () {
851 instances = new HashMap!(widgetID,AlignColumns); 855 instances = new HashMap!(widgetID,AlignColumns);
852 } 856 }
853 857
854 alias IChildWidget.SIZABILITY SIZABILITY; 858 alias IParentWidget.SIZABILITY SIZABILITY;
855 alias IChildWidget.SIZABILITY_ENUM SIZABILITY_ENUM; 859 alias IParentWidget.SIZABILITY_ENUM SIZABILITY_ENUM;
856 860
857 debug invariant() 861 debug invariant()
858 { 862 {
859 if (setupWidths) { 863 if (setupWidths) {
860 assert (width.length == cols, "invariant: bad width length"); 864 assert (width.length == cols, "invariant: bad width length");