Mercurial > projects > mde
comparison mde/gui/widget/Widget.d @ 77:3dfd934100f7
Continuing widget data changes started in last commit: all previous widgets work again now (but lacking saving).
author | Diggory Hardy <diggory.hardy@gmail.com> |
---|---|
date | Tue, 29 Jul 2008 17:11:22 +0100 |
parents | 65780e0e48e6 |
children | 79a1809421aa |
comparison
equal
deleted
inserted
replaced
76:65780e0e48e6 | 77:3dfd934100f7 |
---|---|
11 See the GNU General Public License for more details. | 11 See the GNU General Public License for more details. |
12 | 12 |
13 You should have received a copy of the GNU General Public License | 13 You should have received a copy of the GNU General Public License |
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 Widget module. | 16 /************************************************************************************************* |
17 * GUI Widget module. | |
17 * | 18 * |
18 * This module contains some base widget classes suitable for widget classes to inherit. However, | 19 * This module contains some base widget classes suitable for widget classes to inherit. However, |
19 * inheriting one of them is by no means necessary for a widget so long as the IWidget interface is | 20 * inheriting one of them is by no means necessary for a widget so long as the IWidget interface |
20 * implemented. */ | 21 * is implemented. |
22 *************************************************************************************************/ | |
21 module mde.gui.widget.Widget; | 23 module mde.gui.widget.Widget; |
22 | 24 |
23 public import mde.gui.widget.Ifaces; | 25 public import mde.gui.widget.Ifaces; |
24 import mde.gui.renderer.IRenderer; | 26 import mde.gui.renderer.IRenderer; |
27 import mde.gui.exception; | |
25 | 28 |
26 /** An abstract base widget class. | 29 |
27 * | 30 /************************************************************************************************* |
28 * This abstract class, and the more concrete FixedWidget and ScalableWidget classes provides a | 31 * Widgets may use WDCheck as a utility to check what data holds. Its use is encouraged, so that |
29 * useful basic implementation for widgets. Widgets need not inherit these (they only need implement | 32 * the checks can easily be updated should WidgetData be changed. |
30 * IWidget); they are simply provided for convenience and to promote code reuse. */ | 33 * |
34 * Params: | |
35 * data = the WidgetData to check lengths of | |
36 * n_ints = number of integers wanted | |
37 * n_strings= number of strings (default 0 since not all widgets use strings) | |
38 *************************************************************************************************/ | |
39 void WDCheck (WidgetData data, size_t n_ints, size_t n_strings = 0) { | |
40 if (data.ints.length != n_ints || | |
41 data.strings.length != n_strings) | |
42 throw new WidgetDataException; | |
43 } | |
44 | |
45 | |
46 /************************************************************************************************* | |
47 * An abstract base widget class. | |
48 * | |
49 * This abstract class, and the more concrete FixedWidget and ScalableWidget classes provides a | |
50 * useful basic implementation for widgets. Widgets need not inherit these (they only need | |
51 * implement IWidget); they are simply provided for convenience and to promote code reuse. | |
52 *************************************************************************************************/ | |
31 abstract class Widget : IChildWidget | 53 abstract class Widget : IChildWidget |
32 { | 54 { |
33 //BEGIN Load and save | 55 //BEGIN Load and save |
34 // Base this() for child Widgets. | 56 // Base this() for child Widgets. |
35 this (IWidgetManager mgr, WidgetData data) { | 57 this (IWidgetManager mgr, WidgetData data) { |