comparison mde/gui/widget/Ifaces.d @ 162:2476790223b8

First drag and drop support: can drag from AStringContentWidget to any content editable. No visual feedback while dragging.
author Diggory Hardy <diggory.hardy@gmail.com>
date Fri, 22 May 2009 19:59:22 +0200
parents ccd01fde535e
children 55667d048c31
comparison
equal deleted inserted replaced
161:e3fe6acc16fb 162:2476790223b8
33 public import mde.gui.renderer.IRenderer; 33 public import mde.gui.renderer.IRenderer;
34 public import mde.content.IContent; 34 public import mde.content.IContent;
35 35
36 36
37 /****************************************************************************** 37 /******************************************************************************
38 * The root widget interface, for methods required by both IParentWidget and
39 * IChildWidget.
40 *****************************************************************************/
41 interface IWidget
42 {
43
44 /** Called on a widget when something is dragged onto it.
45 *
46 * Generally, content editing widgets should implement this as:
47 * ---
48 override bool dropContent (IContent content) {
49 if (content_.setContent (content))
50 return true;
51 return parent.dropContent (content);
52 }
53 * ---
54 * And other widgets should just:
55 * ---
56 * return parent.dropContent (content);
57 * ---
58 *
59 * Returns: true if the content was received (false if it reaches the
60 * WidgetManager and is still not used). */
61 bool dropContent (IContent content);
62 }
63
64 /******************************************************************************
38 * Interface for parent widgets, including IWidgetManager. 65 * Interface for parent widgets, including IWidgetManager.
39 * 66 *
40 * All widgets implement this via AWidget to make things simpler (code sharing). 67 * All widgets implement this via AWidget to make things simpler (code sharing).
41 * 68 *
42 * Notation: 69 * Notation:
43 * Positive/negative direction: along the x/y axis in this direction. 70 * Positive/negative direction: along the x/y axis in this direction.
44 * Layout widget: a widget containing multiple sub-widges (which hence 71 * Layout widget: a widget containing multiple sub-widges (which hence
45 * controls how they are laid out). 72 * controls how they are laid out).
46 *****************************************************************************/ 73 *****************************************************************************/
47 interface IParentWidget 74 interface IParentWidget : IWidget
48 { 75 {
49 /** Checks for recursion of unsafe widgets to prevent infinite recursion. */ 76 /** Checks for recursion of unsafe widgets to prevent infinite recursion. */
50 void recursionCheck (widgetID, IContent); 77 void recursionCheck (widgetID, IContent);
51 78
52 /** IPPWs return self, other widgets recurse call on parent. */ 79 /** IPPWs return self, other widgets recurse call on parent. */
271 * All widgets should set their own size in this() or setup() (must be setup() 298 * All widgets should set their own size in this() or setup() (must be setup()
272 * if it could change), although some parents may set child-widgets' size 299 * if it could change), although some parents may set child-widgets' size
273 * during their creation. 300 * during their creation.
274 *****************************************************************************/ 301 *****************************************************************************/
275 //NOTE: add another this() without the data for default initialization, for the GUI editor? 302 //NOTE: add another this() without the data for default initialization, for the GUI editor?
276 interface IChildWidget 303 interface IChildWidget : IWidget
277 { 304 {
278 //BEGIN Load and save 305 //BEGIN Load and save
279 /** 2nd stage of initialization for widgets; also called on some changes. 306 /** 2nd stage of initialization for widgets; also called on some changes.
280 * 307 *
281 * Widgets should call recursively on their children, redo anything 308 * Widgets should call recursively on their children, redo anything