comparison mde/gui/widget/Ifaces.d @ 171:7f7b2011b759

Partially complete commit: code runs but context menus don't work. Moved WMScreen.createRootWidget to WidgetManager.createWidgets. Put childContext under a popupHandler widget. TODO: implement IChildWidget.setContent(Content) (see AParentWidget.d:237).
author Diggory Hardy <diggory.hardy@gmail.com>
date Sun, 26 Jul 2009 11:04:17 +0200
parents 55667d048c31
children 0dd49f333189
comparison
equal deleted inserted replaced
170:e45226d3deae 171:7f7b2011b759
38 * The root widget interface, for methods required by both IParentWidget and 38 * The root widget interface, for methods required by both IParentWidget and
39 * IChildWidget. 39 * IChildWidget.
40 *****************************************************************************/ 40 *****************************************************************************/
41 interface IWidget 41 interface IWidget
42 { 42 {
43 /** When this is called, if the widget has any changed data to save it
44 * should do so (see widgetData/dimData) and return true. Otherwise it
45 * should return false.
46 *
47 * If the widget has subwidgets, it should also be recursively called on
48 * these, returning true if any data was saved.
49 *
50 * Actually the return value is ignored; I think widgets still return it
51 * correctly though. */
52 bool saveChanges ();
43 53
44 /** Called on a widget when something is dragged onto it. 54 /** Called on a widget when something is dragged onto it.
45 * 55 *
46 * Generally, content editing widgets should implement this as: 56 * Generally, content editing widgets should implement this as:
47 * --- 57 * ---
174 * 184 *
175 * This is set on the parent IPPW when a popup menu is opened and unset 185 * This is set on the parent IPPW when a popup menu is opened and unset
176 * when the menu is closed. 186 * when the menu is closed.
177 * If set on the parent IPPW, popup menus can be opened with just a mouse- 187 * If set on the parent IPPW, popup menus can be opened with just a mouse-
178 * over and buttons activated with an up-click. 188 * over and buttons activated with an up-click.
189 * So given IPPWs U-Z (indentation shows ancestry):
190 *
191 * ---
192 * X (window manager): menuActive false
193 * Y (popup window): menuActive true
194 * U (menu button): menuActive true, open popup menu
195 * V (menu button): menuActive false, menu closed but opens on hover
196 * Z (menu button): menuActive false, menu closed
197 * ---
179 * 198 *
180 * It is also used by positionPopup to signal if the popup was left or 199 * It is also used by positionPopup to signal if the popup was left or
181 * right of the previous popup, to enable a further popup to be placed by 200 * right of the previous popup, to enable a further popup to be placed by
182 * positionPopup without overlapping previous popups. */ 201 * positionPopup without overlapping previous popups. */
183 void menuActive (MenuPosition); 202 void menuActive (MenuPosition);
214 233
215 /****************************************************************************** 234 /******************************************************************************
216 * Interface for the widget manager. 235 * Interface for the widget manager.
217 * 236 *
218 * This class handles widget rendering, input, loading and saving. 237 * This class handles widget rendering, input, loading and saving.
238 *
239 * The widget manager is also a popup-parent for it's main child widget
240 * (childRoot), working as a normal popup-parent except that parentMenuActive
241 * is always false. It also has two special popup children: childContext and
242 * childDragged, which are handled indirectly via PopupHandlerWidget so that
243 * their menuActive state doesn't affect childRoot or decendants.
219 *****************************************************************************/ 244 *****************************************************************************/
220 interface IWidgetManager : IPopupParentWidget 245 interface IWidgetManager : IPopupParentWidget
221 { 246 {
222 // Loading/saving: 247 // Loading/saving:
223 /** Create a widget by looking up the data for id then looking up data.ints[0] in WIDGET_TYPES. 248 /** Create a widget by looking up the data for id then looking up data.ints[0] in WIDGET_TYPES.
326 * Returns: 351 * Returns:
327 * The method must return true on initial setup and if its dimensions 352 * The method must return true on initial setup and if its dimensions
328 * (may) have changed. */ 353 * (may) have changed. */
329 bool setup (uint n, uint flags); 354 bool setup (uint n, uint flags);
330 355
331 /** When this is called, if the widget has any changed data to save it should call
332 * IWidgetManager.setData (id, data) to set it and return true. Otherwise it should return
333 * false.
334 *
335 * If the widget has subwidgets, it should also be recursively called on these (passing their
336 * ids). */
337 bool saveChanges ();
338
339 /+ Use when widget editing is available? Requires widgets to know their parents. 356 /+ Use when widget editing is available? Requires widgets to know their parents.
340 /** Called when a child widget's size has changed. 357 /** Called when a child widget's size has changed.
341 * 358 *
342 * Should be propegated up to parents. */ 359 * Should be propegated up to parents. */
343 void childChanged (); 360 void childChanged ();