comparison mde/gui/widget/Ifaces.d @ 152:c67d074a7111

Menu placement now takes into account left/right placement of parent menus.
author Diggory Hardy <diggory.hardy@gmail.com>
date Fri, 10 Apr 2009 15:19:46 +0200
parents 783969f4665c
children ccd01fde535e
comparison
equal deleted inserted replaced
151:e785e98d3b78 152:c67d074a7111
105 * The widget manager is an IPPW, but unlike most IPPWs its popup(s), if 105 * The widget manager is an IPPW, but unlike most IPPWs its popup(s), if
106 * existing, probably have nothing to do with its child IPPWs. 106 * existing, probably have nothing to do with its child IPPWs.
107 *****************************************************************************/ 107 *****************************************************************************/
108 interface IPopupParentWidget : IParentWidget 108 interface IPopupParentWidget : IParentWidget
109 { 109 {
110 /// menuActive's type
111 enum MenuPosition {
112 INACTIVE = 0,
113 ACTIVE = 1,
114 LEFT = 3,
115 RIGHT = 5
116 }
117
110 /** Add caller ippw as current child IPopupParentWidget of called IPPW. 118 /** Add caller ippw as current child IPopupParentWidget of called IPPW.
111 * 119 *
112 * ippw is added as called IPPW's child IPPW, and its functions are 120 * ippw is added as called IPPW's child IPPW, and its functions are
113 * called to draw popup and pass events. The called IPPW's previous child 121 * called to draw popup and pass events. The called IPPW's previous child
114 * IPPW is replaced. 122 * IPPW is replaced.
126 bool removeChildIPPW (IPopupParentWidget ippw); 134 bool removeChildIPPW (IPopupParentWidget ippw);
127 135
128 /** Notify the called IPPW that it has been removed. */ 136 /** Notify the called IPPW that it has been removed. */
129 void removedIPPW (); 137 void removedIPPW ();
130 138
131 /** Set/get menuActive state. 139 /** Set/get menuActive state, which includes position information.
132 * 140 *
133 * This is set on the parent IPPW when a popup menu is opened and unset 141 * This is set on the parent IPPW when a popup menu is opened and unset
134 * when the menu is closed. 142 * when the menu is closed.
135 * If set on the parent IPPW, popup menus can be opened with just a mouse- 143 * If set on the parent IPPW, popup menus can be opened with just a mouse-
136 * over and buttons activated with an up-click. */ 144 * over and buttons activated with an up-click.
137 void menuActive (bool); 145 *
138 bool menuActive (); 146 * It is also used by positionPopup to signal if the popup was left or
139 /** Returns the IPPW's parent's menuActive (WM returns false). If true, 147 * right of the previous popup, to enable a further popup to be placed by
140 * popup widgets may assume they are sub-menu popups not top-level menu 148 * positionPopup without overlapping previous popups. */
141 * popups. */ 149 void menuActive (MenuPosition);
142 bool parentMenuActive (); 150 MenuPosition menuActive ();
151 /** Returns the IPPW's parent's menuActive (WM returns false). If
152 * (menuActive & MenuPosition.ACTIVE) popup widgets may assume they are
153 * sub-menu popups not top-level menu popups. */
154 MenuPosition parentMenuActive ();
143 155
144 /** Called by descendant widgets such as buttons when an action occurred, 156 /** Called by descendant widgets such as buttons when an action occurred,
145 * which should close a menu. (But also called when not in a menu.) */ 157 * which should close a menu. (But also called when not in a menu.) */
146 void menuDone (); 158 void menuDone ();
147 159
151 * If this doesn't yield a widget, it should try getting one from its popup 163 * If this doesn't yield a widget, it should try getting one from its popup
152 * and then itself. It should return the first widget found or null. 164 * and then itself. It should return the first widget found or null.
153 * 165 *
154 * If closePopup is true and a widget isn't returned from the childIPPW, 166 * If closePopup is true and a widget isn't returned from the childIPPW,
155 * the childIPPW should be removed (to close popups when a click is not on 167 * the childIPPW should be removed (to close popups when a click is not on
156 * the popup or its parent) and menuActive set false. */ 168 * the popup or its parent) and menuActive set to INACTIVE. */
157 IChildWidget getPopupWidget (wdabs cx, wdabs cy, bool closePopup); 169 IChildWidget getPopupWidget (wdabs cx, wdabs cy, bool closePopup);
158 170
159 /** Draw. 171 /** Draw.
160 * 172 *
161 * The IPPW should first draw its popup, then call on its child IPPW if 173 * The IPPW should first draw its popup, then call on its child IPPW if
197 WidgetData widgetData (widgetID id); 209 WidgetData widgetData (widgetID id);
198 void widgetData (widgetID id, WidgetData data); /// ditto 210 void widgetData (widgetID id, WidgetData data); /// ditto
199 wdims dimData (widgetID id); /// ditto 211 wdims dimData (widgetID id); /// ditto
200 void dimData (widgetID id, wdims d); /// ditto 212 void dimData (widgetID id, wdims d); /// ditto
201 213
202 /** Position popup below or above parent, or right or left of parent 214 /** Position popup adjacent to parent.
203 * (flags & 1 == 1). */ 215 *
204 void positionPopup (IChildWidget parent, IChildWidget popup, int flags = 0); 216 * If position is 0, place popup below parent, or above if there isn't
217 * space below, and expand popup's width to at least that of parent.
218 *
219 * If (position & MenuPosition.ACTIVE), place popup to the side of parent,
220 * using the side indicated by LEFT or RIGHT, if any.
221 *
222 * Returns:
223 * MenuPosition.ACTIVE if popup placed above or below, and LEFT or RIGHT
224 * if placed left or right of parent. */
225 MenuPosition positionPopup (IChildWidget parent, IChildWidget popup, MenuPosition position = MenuPosition.INACTIVE);
205 226
206 // Rendering: 227 // Rendering:
207 /** For when a widget needs redrawing. 228 /** For when a widget needs redrawing.
208 * 229 *
209 * Must be called because rendering may only be done on events. 230 * Must be called because rendering may only be done on events.