Mercurial > projects > mde
comparison mde/gui/widget/Ifaces.d @ 175:1cbde9807293
Compile/link-time fixes for ldc & non-debug builds.
Moved WidgetManager to widget/
Reverted IChildWidget to an interface, not an abstract class.
Introduced a work-around for a compiler problem. May not cover all cases.
author | Diggory Hardy <diggory.hardy@gmail.com> |
---|---|
date | Fri, 11 Sep 2009 20:56:53 +0200 |
parents | 3d58adc17d20 |
children | af40e9679436 |
comparison
equal
deleted
inserted
replaced
174:3d58adc17d20 | 175:1cbde9807293 |
---|---|
348 * All widgets should set their own size in this() or setup() (must be setup() | 348 * All widgets should set their own size in this() or setup() (must be setup() |
349 * if it could change), although some parents may set child-widgets' size | 349 * if it could change), although some parents may set child-widgets' size |
350 * during their creation. | 350 * during their creation. |
351 *****************************************************************************/ | 351 *****************************************************************************/ |
352 //NOTE: add another this() without the data for default initialization, for the GUI editor? | 352 //NOTE: add another this() without the data for default initialization, for the GUI editor? |
353 abstract class IChildWidget : IWidget | 353 interface IChildWidget : IWidget |
354 { | 354 { |
355 //BEGIN Load and save | 355 //BEGIN Load and save |
356 /** 2nd stage of initialization for widgets; also called on some changes. | 356 /** 2nd stage of initialization for widgets; also called on some changes. |
357 * | 357 * |
358 * Widgets should call recursively on their children, redo anything | 358 * Widgets should call recursively on their children, redo anything |
367 * These flags are always true on first run. | 367 * These flags are always true on first run. |
368 * | 368 * |
369 * Returns: | 369 * Returns: |
370 * The method must return true on initial setup and if its dimensions | 370 * The method must return true on initial setup and if its dimensions |
371 * (may) have changed. */ | 371 * (may) have changed. */ |
372 bool setup (uint n, uint flags) {return 0;} | 372 bool setup (uint n, uint flags); |
373 | 373 |
374 /+ Use when widget editing is available? Requires widgets to know their parents. | 374 /+ Use when widget editing is available? Requires widgets to know their parents. |
375 /** Called when a child widget's size has changed. | 375 /** Called when a child widget's size has changed. |
376 * | 376 * |
377 * Should be propegated up to parents. */ | 377 * Should be propegated up to parents. */ |
385 * Normally, this means does the widget benifit from being enlarged? If not, the widget has | 385 * Normally, this means does the widget benifit from being enlarged? If not, the widget has |
386 * "fixed" dimensions equal to it's minimal size; however it $(I may) still be enlarged. | 386 * "fixed" dimensions equal to it's minimal size; however it $(I may) still be enlarged. |
387 * | 387 * |
388 * Parents normally take their resizability from sub-widgets; see SIZABILITY for how they do | 388 * Parents normally take their resizability from sub-widgets; see SIZABILITY for how they do |
389 * this. */ | 389 * this. */ |
390 bool isWSizable () {return 0;} | 390 bool isWSizable (); |
391 bool isHSizable () {return 0;} /// ditto | 391 bool isHSizable (); /// ditto |
392 | 392 |
393 /** The minimal size the widget could be shrunk to (or its fixed size). | 393 /** The minimal size the widget could be shrunk to (or its fixed size). |
394 * | 394 * |
395 * Takes into account child-widgets and any other contents. */ | 395 * Takes into account child-widgets and any other contents. */ |
396 wdim minWidth () {return 0;} | 396 wdim minWidth (); |
397 wdim minHeight() {return 0;} /// ditto | 397 wdim minHeight(); /// ditto |
398 | 398 |
399 /** Get the current size of the widget. */ | 399 /** Get the current size of the widget. */ |
400 wdim width () {return 0;} | 400 wdim width (); |
401 wdim height() {return 0;} /// ditto | 401 wdim height(); /// ditto |
402 | 402 |
403 /** (Smallest) coordinates of widget. */ | 403 /** (Smallest) coordinates of widget. */ |
404 wdabs xPos () {return 0;} | 404 wdabs xPos (); |
405 wdabs yPos () {return 0;} /// ditto | 405 wdabs yPos (); /// ditto |
406 | 406 |
407 /** Used to adjust the size. | 407 /** Used to adjust the size. |
408 * | 408 * |
409 * Params: | 409 * Params: |
410 * nw/nh = The new width/height | 410 * nw/nh = The new width/height |
416 * A widget should never be resized smaller than it's minimal size (if it is, it should assume | 416 * A widget should never be resized smaller than it's minimal size (if it is, it should assume |
417 * it's minimal size and print a warning when in debug mode). | 417 * it's minimal size and print a warning when in debug mode). |
418 * A "fixed" size widget should enlarge itself as requested. | 418 * A "fixed" size widget should enlarge itself as requested. |
419 * | 419 * |
420 * setPosition must be called after calling either setWidth or setHeight. */ | 420 * setPosition must be called after calling either setWidth or setHeight. */ |
421 void setWidth (wdim nw, int dir) {} | 421 void setWidth (wdim nw, int dir); |
422 void setHeight (wdim nh, int dir) {} /// ditto | 422 void setHeight (wdim nh, int dir); /// ditto |
423 | 423 |
424 /** Set the current position (called after setup and to move widget). */ | 424 /** Set the current position (called after setup and to move widget). */ |
425 void setPosition (wdim x, wdim y) {} | 425 void setPosition (wdim x, wdim y); |
426 //END Size and position | 426 //END Size and position |
427 | 427 |
428 //BEGIN Content | 428 //BEGIN Content |
429 /** Return the widget's content, or null. */ | 429 /** Return the widget's content, or null. */ |
430 IContent content () {return null;} | 430 IContent content (); |
431 | 431 |
432 /** Set the widget's content, if the widget takes content and changing it | 432 /** Set the widget's content, if the widget takes content and changing it |
433 * at this stage is feasible. (Also pass to sub-widgets, where the | 433 * at this stage is feasible. (Also pass to sub-widgets, where the |
434 * constructor normally does so.) */ | 434 * constructor normally does so.) */ |
435 void setContent (IContent) {} | 435 void setContent (IContent); |
436 //END Content | 436 //END Content |
437 | 437 |
438 //BEGIN Events | 438 //BEGIN Events |
439 /** Recursively scan the widget tree to find the widget under (cx,cy). | 439 /** Recursively scan the widget tree to find the widget under (cx,cy). |
440 * | 440 * |
443 * | 443 * |
444 * In the case of Window this may not be the case; it should check and return null if not under | 444 * In the case of Window this may not be the case; it should check and return null if not under |
445 * (cx,cy). | 445 * (cx,cy). |
446 * | 446 * |
447 * Note: use global coordinates (cx,cy) not coordinates relative to the widget. */ | 447 * Note: use global coordinates (cx,cy) not coordinates relative to the widget. */ |
448 IChildWidget getWidget (wdabs cx, wdabs cy) {return null;} | 448 IChildWidget getWidget (wdabs cx, wdabs cy); |
449 | 449 |
450 /** Return true if (cx,cy) is on self's box (doesn't matter if actually on a subwidget). */ | 450 /** Return true if (cx,cy) is on self's box (doesn't matter if actually on a subwidget). */ |
451 bool onSelf (wdabs cx, wdabs cy) {return 0;} | 451 bool onSelf (wdabs cx, wdabs cy); |
452 | 452 |
453 /** Receive a mouse click event at cx,cy from button b (1-5 correspond to L,M,B, wheel up,down) | 453 /** Receive a mouse click event at cx,cy from button b (1-5 correspond to L,M,B, wheel up,down) |
454 * which is a down-click if state is true. | 454 * which is a down-click if state is true. |
455 * | 455 * |
456 * Widget may assume coordinates are on the widget (caller must check). | 456 * Widget may assume coordinates are on the widget (caller must check). |
459 * $(TABLE | 459 * $(TABLE |
460 * $(TR $(TD 1) $(TD Request keyboard input)) | 460 * $(TR $(TD 1) $(TD Request keyboard input)) |
461 * $(TR $(TD 2) $(TD Request the functions dragMotion and dragRelease are called)) | 461 * $(TR $(TD 2) $(TD Request the functions dragMotion and dragRelease are called)) |
462 * $(TR $(TD 4) $(TD Display the widget's content while dragging (requires 2))) | 462 * $(TR $(TD 4) $(TD Display the widget's content while dragging (requires 2))) |
463 * ) */ | 463 * ) */ |
464 int clickEvent (wdabs cx, wdabs cy, ubyte b, bool state) {return 0;} | 464 int clickEvent (wdabs cx, wdabs cy, ubyte b, bool state); |
465 | 465 |
466 /** Called when dragging motion occurs, originating from this widget. | 466 /** Called when dragging motion occurs, originating from this widget. |
467 * | 467 * |
468 * Params: target = The widget under the mouse | 468 * Params: target = The widget under the mouse |
469 * | 469 * |
470 * Only called if requested by clickEvent. */ | 470 * Only called if requested by clickEvent. */ |
471 void dragMotion (wdabs cx, wdabs cy, IChildWidget target) {} | 471 void dragMotion (wdabs cx, wdabs cy, IChildWidget target); |
472 | 472 |
473 /** Called at the end of a drag which originated from this widget. | 473 /** Called at the end of a drag which originated from this widget. |
474 * | 474 * |
475 * Params: target = The widget under the mouse when the click was released | 475 * Params: target = The widget under the mouse when the click was released |
476 * | 476 * |
477 * Returns: true if the up-click event should not be passed to | 477 * Returns: true if the up-click event should not be passed to |
478 * clickEvent on the relevent widget. | 478 * clickEvent on the relevent widget. |
479 * | 479 * |
480 * Only called if requested by clickEvent. */ | 480 * Only called if requested by clickEvent. */ |
481 bool dragRelease (wdabs cx, wdabs cy, IChildWidget target) {return 0;} | 481 bool dragRelease (wdabs cx, wdabs cy, IChildWidget target); |
482 | 482 |
483 /** Receives keyboard events when requested. | 483 /** Receives keyboard events when requested. |
484 * | 484 * |
485 * Params: | 485 * Params: |
486 * sym SDLKey key sym, useful for keys with no character code such as arrow keys | 486 * sym SDLKey key sym, useful for keys with no character code such as arrow keys |
490 /** Called when keyboard input focus is lost. */ | 490 /** Called when keyboard input focus is lost. */ |
491 public void keyFocusLost (); | 491 public void keyFocusLost (); |
492 | 492 |
493 /** Called on all widgets when the mouse moves over it (state == true) and | 493 /** Called on all widgets when the mouse moves over it (state == true) and |
494 * when it leaves (state == false). */ | 494 * when it leaves (state == false). */ |
495 void underMouse (bool state) {} | 495 void underMouse (bool state); |
496 | 496 |
497 /** When a pop-up is closed the manager calls requestRedraw and this function on its parent. */ | 497 /** When a pop-up is closed the manager calls requestRedraw and this function on its parent. */ |
498 protected void popupClose (); | 498 protected void popupClose (); |
499 /** When a click is on the parent of a popup, this function is called instead of the usual | 499 /** When a click is on the parent of a popup, this function is called instead of the usual |
500 * clickEvent. | 500 * clickEvent. |