Mercurial > projects > mde
diff 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 |
line wrap: on
line diff
--- a/mde/gui/widget/AParentWidget.d Mon Jun 29 21:20:16 2009 +0200 +++ b/mde/gui/widget/AParentWidget.d Sun Jul 26 11:04:17 2009 +0200 @@ -77,7 +77,7 @@ // widget id and the content are the same (as its it and content). override void recursionCheck (widgetID wID, IContent c) { debug assert (id !is null && parent !is null, "recursionCheck called before parent and id set"); - if (wID is id) + if (wID == id) throw new WidgetRecursionException (wID); parent.recursionCheck (wID, c); } @@ -166,7 +166,6 @@ if (childIPPW) { ret = childIPPW.getPopupWidget (cx, cy, closePopup); if (closePopup && ret is null) { - menuActive = MenuPosition.INACTIVE; removeChildIPPW (childIPPW); } } @@ -210,3 +209,35 @@ IChildWidget popup; MenuPosition mAIPPW; } + +import mde.content.Content; +/****************************************************************************** + * Not "really" a widget (zero size, no direct interaction), but a handler for + * popup widgets. + * + * Intended to manage a context menu for WidgetManager, and not to work quite + * like a regular IPPW. + *****************************************************************************/ +class PopupHandlerWidget : APopupParentWidget +{ + this (IWidgetManager mgr, IParentWidget parent, widgetID id, char[] subWidg, IContent c) { + super (mgr, parent, id); + + popup = mgr.makeWidget (this, subWidg, c); + subWidgets = [popup]; + + w = mw = 0; + h = mh = 0; + } + + /// Open a context menu + void openMenu (IChildWidget underMouse, Content contextContent) { + if (mAIPPW != MenuPosition.INACTIVE) return; // already in use + //TODO: + //subWidgets[0].setContent (contextContent); + parentIPPW.addChildIPPW (this); + // For context menus, don't set parentIPPW.menuActive like for clicked menus: + menuActive = mgr.positionPopup (underMouse, popup); + mgr.requestRedraw; + } +}