comparison mde/gui/widget/AParentWidget.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 c67d074a7111
children 0dd49f333189
comparison
equal deleted inserted replaced
170:e45226d3deae 171:7f7b2011b759
75 75
76 // Parents taking a content should override, only throwing if both the 76 // Parents taking a content should override, only throwing if both the
77 // widget id and the content are the same (as its it and content). 77 // widget id and the content are the same (as its it and content).
78 override void recursionCheck (widgetID wID, IContent c) { 78 override void recursionCheck (widgetID wID, IContent c) {
79 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");
80 if (wID is id) 80 if (wID == id)
81 throw new WidgetRecursionException (wID); 81 throw new WidgetRecursionException (wID);
82 parent.recursionCheck (wID, c); 82 parent.recursionCheck (wID, c);
83 } 83 }
84 84
85 IPopupParentWidget getParentIPPW () { 85 IPopupParentWidget getParentIPPW () {
164 override IChildWidget getPopupWidget (wdabs cx, wdabs cy, bool closePopup) { 164 override IChildWidget getPopupWidget (wdabs cx, wdabs cy, bool closePopup) {
165 IChildWidget ret; 165 IChildWidget ret;
166 if (childIPPW) { 166 if (childIPPW) {
167 ret = childIPPW.getPopupWidget (cx, cy, closePopup); 167 ret = childIPPW.getPopupWidget (cx, cy, closePopup);
168 if (closePopup && ret is null) { 168 if (closePopup && ret is null) {
169 menuActive = MenuPosition.INACTIVE;
170 removeChildIPPW (childIPPW); 169 removeChildIPPW (childIPPW);
171 } 170 }
172 } 171 }
173 if (ret is null) { 172 if (ret is null) {
174 if (popup.onSelf (cx, cy)) 173 if (popup.onSelf (cx, cy))
208 IPopupParentWidget parentIPPW; 207 IPopupParentWidget parentIPPW;
209 IPopupParentWidget childIPPW; 208 IPopupParentWidget childIPPW;
210 IChildWidget popup; 209 IChildWidget popup;
211 MenuPosition mAIPPW; 210 MenuPosition mAIPPW;
212 } 211 }
212
213 import mde.content.Content;
214 /******************************************************************************
215 * Not "really" a widget (zero size, no direct interaction), but a handler for
216 * popup widgets.
217 *
218 * Intended to manage a context menu for WidgetManager, and not to work quite
219 * like a regular IPPW.
220 *****************************************************************************/
221 class PopupHandlerWidget : APopupParentWidget
222 {
223 this (IWidgetManager mgr, IParentWidget parent, widgetID id, char[] subWidg, IContent c) {
224 super (mgr, parent, id);
225
226 popup = mgr.makeWidget (this, subWidg, c);
227 subWidgets = [popup];
228
229 w = mw = 0;
230 h = mh = 0;
231 }
232
233 /// Open a context menu
234 void openMenu (IChildWidget underMouse, Content contextContent) {
235 if (mAIPPW != MenuPosition.INACTIVE) return; // already in use
236 //TODO:
237 //subWidgets[0].setContent (contextContent);
238 parentIPPW.addChildIPPW (this);
239 // For context menus, don't set parentIPPW.menuActive like for clicked menus:
240 menuActive = mgr.positionPopup (underMouse, popup);
241 mgr.requestRedraw;
242 }
243 }