Mercurial > projects > mde
diff mde/gui/widget/Ifaces.d @ 121:5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
WidgetManager code redistributed between classes; WMScreen class moved to WMScreen.d.
addContent function now calls makeWidget with another id.
author | Diggory Hardy <diggory.hardy@gmail.com> |
---|---|
date | Fri, 02 Jan 2009 18:07:10 +0000 |
parents | aba2dd815a1f |
children | d3b2cefd46c9 |
line wrap: on
line diff
--- a/mde/gui/widget/Ifaces.d Thu Jan 01 15:16:00 2009 +0000 +++ b/mde/gui/widget/Ifaces.d Fri Jan 02 18:07:10 2009 +0000 @@ -29,16 +29,17 @@ /************************************************************************************************* - * Common interface for all widgets. + * Interface for parent widgets, including IWidgetManager. * * Notation: * Positive/negative direction: along the x/y axis in this direction. * Layout widget: a widget containing multiple sub-widges (which hence controls how they are * laid out). *************************************************************************************************/ -//NOTE: keep this? -interface IWidget +interface IParentWidget { + /** Checks for recursion of unsafe widgets to prevent infinite recursion. */ + void recursionCheck (widgetID); } @@ -47,29 +48,33 @@ * * This class handles widget rendering, input, loading and saving. *************************************************************************************************/ -interface IWidgetManager : IWidget +interface IWidgetManager : IParentWidget { // Loading/saving: - /** Create a widget by ID. + /** Create a widget by looking up the data for id then looking up data.ints[0] in WIDGET_TYPES. * * Params: * id = Identifier, within data files, of the data for the widget. * data = Pass this data to the widget, not data looked up via id. * content = An IContent may be passed to some widgets on creation. * + * When used in a this(), super() should be called before any calls to makeWidget (or at least + * parent and id set) due to recursionCheck being called on the widget. + * * Creates a widget, using the widget data with index id. Widget data is loaded from files, * and per design (multiple gui layouts, called designs, may exist; data is per design). */ - IChildWidget makeWidget (widgetID id, IContent content = null); - - /** Get dimension data for a widget. */ - wdims dimData (widgetID id); + IChildWidget makeWidget (IParentWidget parent, widgetID id, IContent content = null); - /** Record some changes, for saving. Should only be called from IWidget.saveChanges() to avoid - * multiple calls for instanced widgets of same id. - * - * WidgetData is for most data, dimensional data (wdims) is for dimensions. */ - void setData (widgetID id, WidgetData); - void setDimData (widgetID id, wdims d); /// ditto + /** Get or set widget id's WidgetData or dimension data. + * + * WidgetData is for most data, dimensional data (wdims) is for dimensions. + * + * Data should only be set from IChildWidget.saveChanges() to + * avoid setting multiple times when a widget id has several instances. */ + WidgetData widgetData (widgetID id); + void widgetData (widgetID id, WidgetData data); /// ditto + wdims dimData (widgetID id); /// ditto + void dimData (widgetID id, wdims d); /// ditto // Rendering: /** For when a widget needs redrawing. @@ -151,7 +156,7 @@ * although some parents may set child-widgets' size during their creation. *************************************************************************************************/ //NOTE: add another this() without the data for default initialization, for the GUI editor? -interface IChildWidget : IWidget +interface IChildWidget : IParentWidget { //BEGIN Load and save /** 2nd stage of initialization for widgets; also called on some changes.