comparison mde/gui/widget/AParentWidget.d @ 133:9fd705793568

Fixed menu popup bug, improved recursion detection. Menu popups can now determine whether or not they are sub-menus. Recursion detection can now also check content (if not the same, there's not a risk of infinite recursion).
author Diggory Hardy <diggory.hardy@gmail.com>
date Fri, 23 Jan 2009 16:05:05 +0000
parents 9cff74f68b84
children 9f035cd139c6
comparison
equal deleted inserted replaced
132:264028f4115a 133:9fd705793568
21 *****************************************************************************/ 21 *****************************************************************************/
22 module mde.gui.widget.AParentWidget; 22 module mde.gui.widget.AParentWidget;
23 23
24 public import mde.gui.widget.AChildWidget; 24 public import mde.gui.widget.AChildWidget;
25 import mde.gui.exception; 25 import mde.gui.exception;
26 import mde.content.Content;
26 27
27 debug { 28 debug {
28 import tango.util.log.Log : Log, Logger; 29 import tango.util.log.Log : Log, Logger;
29 private Logger logger; 30 private Logger logger;
30 static this () { 31 static this () {
70 return i; 71 return i;
71 72
72 throw new GuiException ("getWidgetIndex: widget not found (code error)"); 73 throw new GuiException ("getWidgetIndex: widget not found (code error)");
73 } 74 }
74 75
75 // Don't override; use the WIDGET_TYPE.SAFE_RECURSION flag for safe widgets. 76 // Parents taking a content should override, only throwing if both the
76 //NOTE: should be override (compiler bug) 77 // widget id and the content are the same (as its it and content).
77 final void recursionCheck (widgetID a) { 78 override void recursionCheck (widgetID wID, IContent c) {
78 debug assert (id !is null && parent !is null, "recursionCheck called before parent and id set"); 79 debug assert (id !is null && parent !is null, "recursionCheck called before parent and id set");
79 if (a is id) 80 if (wID is id)
80 throw new GuiException ("Infite recursion of "~a); 81 throw new WidgetRecursionException (wID);
81 parent.recursionCheck (a); 82 parent.recursionCheck (wID, c);
82 } 83 }
83 84
84 IPopupParentWidget getParentIPPW () { 85 IPopupParentWidget getParentIPPW () {
85 return parent.getParentIPPW; 86 return parent.getParentIPPW;
86 } 87 }
149 childIPPW.menuActive = mA; 150 childIPPW.menuActive = mA;
150 } 151 }
151 override bool menuActive () { 152 override bool menuActive () {
152 return mAIPPW; 153 return mAIPPW;
153 } 154 }
154 155 override bool parentMenuActive () {
156 return parentIPPW.menuActive;
157 }
158
155 override void menuDone () { // default actions, for popup menus: 159 override void menuDone () { // default actions, for popup menus:
156 parentIPPW.removeChildIPPW (this); // remove self 160 parentIPPW.removeChildIPPW (this); // remove self
157 parentIPPW.menuDone; // and propegate 161 parentIPPW.menuDone; // and propegate
158 } 162 }
159 163