comparison mde/gui/widget/Ifaces.d @ 113:9824bee909fd

Popup menu; works for simple menus except that clicking an item doesn't close it. Revised popup support a bit; EnumContentWidget is broken and due to be replaced.
author Diggory Hardy <diggory.hardy@gmail.com>
date Fri, 19 Dec 2008 10:32:28 +0000
parents fe061009029d
children 1b1e2297e2fc
comparison
equal deleted inserted replaced
112:fe061009029d 113:9824bee909fd
87 * 87 *
88 * Normally specific to the GUI, but widgets have no direct contact with the GUI and this 88 * Normally specific to the GUI, but widgets have no direct contact with the GUI and this
89 * provides the possibility of per-window renderers (if desired). */ 89 * provides the possibility of per-window renderers (if desired). */
90 IRenderer renderer (); 90 IRenderer renderer ();
91 91
92 /** Add/remove a pop-up [menu] to be drawn. */ 92 /** Add/remove a pop-up widget to be drawn.
93 void addPopup (wdabs x, wdabs y, IChildWidget popup); 93 *
94 void removePopup (IChildWidget popup); /// ditto 94 * Place popup as close to x,y as possible, or
95 * place popup next to parent (usually below). */
96 void addPopup (IChildWidget parent, IChildWidget popup);
97 //void removePopup (IChildWidget popup); Possibly useful later.
95 98
96 // User input: 99 // User input:
97 /** Add a mouse click callback. 100 /** Add a mouse click callback.
98 * 101 *
99 * This is a delegate this will be called for all mouse click events recieved by the gui, not 102 * This is a delegate this will be called for all mouse click events recieved by the gui, not
100 * simply all click events on the widget (as clickEvent recieves). 103 * simply all click events on the widget (as clickEvent recieves).
101 * 104 *
102 * The delegate should return true if it accepts the event and no further processing is 105 * The delegate should return true if it accepts the event and no further processing is
103 * required (i.e. the event should not be handled by anything else), false otherwise. 106 * required (i.e. the event should not be handled by anything else), false otherwise. */
104 *
105 * Note that this is not a mechanism to prevent unwanted event handling, and in the future
106 * may be removed (so event handling cannot be cut short). */
107 void addClickCallback (bool delegate (wdabs cx, wdabs cy, ubyte b, bool state) dg); 107 void addClickCallback (bool delegate (wdabs cx, wdabs cy, ubyte b, bool state) dg);
108 108
109 /** Add a mouse motion callback: delegate will be called for all motion events recieved by the 109 /** Add a mouse motion callback: delegate will be called for all motion events recieved by the
110 * gui. */ 110 * gui. */
111 void addMotionCallback (void delegate (wdabs cx, wdabs cy) dg); 111 void addMotionCallback (void delegate (wdabs cx, wdabs cy) dg);
203 203
204 /** Get the current size of the widget. */ 204 /** Get the current size of the widget. */
205 wdim width (); 205 wdim width ();
206 wdim height(); /// ditto 206 wdim height(); /// ditto
207 207
208 /** (Smallest) coordinates of widget. */
209 wdabs xPos ();
210 wdabs yPos (); /// ditto
211
208 /** Used to adjust the size. 212 /** Used to adjust the size.
209 * 213 *
210 * Params: 214 * Params:
211 * nw/nh = The new width/height 215 * nw/nh = The new width/height
212 * dir = Direction to resize from. This is only really applicable to layout widgets. 216 * dir = Direction to resize from. This is only really applicable to layout widgets.
234 * 238 *
235 * In the case of Window this may not be the case; it should check and return null if not under 239 * In the case of Window this may not be the case; it should check and return null if not under
236 * (x,y). 240 * (x,y).
237 * 241 *
238 * Note: use global coordinates (x,y) not coordinates relative to the widget. */ 242 * Note: use global coordinates (x,y) not coordinates relative to the widget. */
239 IChildWidget getWidget (wdim x, wdim y); 243 IChildWidget getWidget (wdabs x, wdabs y);
240 244
241 /** Receive a mouse click event at cx,cy from button b (1-5 correspond to L,M,B, wheel up,down) 245 /** Receive a mouse click event at cx,cy from button b (1-5 correspond to L,M,B, wheel up,down)
242 * which is a down-click if state is true. 246 * which is a down-click if state is true.
243 * 247 *
244 * Widget may assume coordinates are on the widget (caller must check). 248 * Widget may assume coordinates are on the widget (caller must check).
253 * letter The character input, in UTF-8 */ 257 * letter The character input, in UTF-8 */
254 void keyEvent (ushort sym, char[] letter); 258 void keyEvent (ushort sym, char[] letter);
255 259
256 /** Called when keyboard input focus is lost. */ 260 /** Called when keyboard input focus is lost. */
257 void keyFocusLost (); 261 void keyFocusLost ();
262
263 /** Called when the mouse moves over the button and when it leaves. No need to call
264 * requestRedraw. */
265 void highlight (bool state);
266
267 /** After adding a pop-up widget with mgr.addPopup(this,popupWidget), when that pop-up closes
268 * the manager calls requestRedraw, clickEvent if applicable, and then this function. */
269 void popupRemoved ();
258 //END Events 270 //END Events
259 271
260 /** Draw, using the stored values of x and y. 272 /** Draw, using the stored values of x and y.
261 * 273 *
262 * Maybe later enforce clipping of all sub-widget drawing, particularly for cases where only 274 * Maybe later enforce clipping of all sub-widget drawing, particularly for cases where only