Mercurial > projects > mde
diff mde/gui/widget/AChildWidget.d @ 174:3d58adc17d20
Temporary commit to allow backup
author | Diggory Hardy <diggory.hardy@gmail.com> |
---|---|
date | Mon, 31 Aug 2009 13:54:23 +0200 |
parents | 0dd49f333189 |
children | 1cbde9807293 |
line wrap: on
line diff
--- a/mde/gui/widget/AChildWidget.d Sat Aug 08 15:53:10 2009 +0200 +++ b/mde/gui/widget/AChildWidget.d Mon Aug 31 13:54:23 2009 +0200 @@ -39,7 +39,7 @@ * This abstract class, and the more concrete FixedWidget and ScalableWidget * classes provides useful basic implementations for widgets. *****************************************************************************/ -abstract class AChildWidget : IChildWidget +abstract class AChildWidget : IChildWidget, IWidget { //BEGIN Load and save // Base this() for child Widgets. @@ -55,7 +55,7 @@ } // Don't save any data: fine for many widgets. - override bool saveChanges () { + public override bool saveChanges () { return false; } @@ -133,36 +133,38 @@ } /* Dummy functions; many widgets don't need to respond to dragging. */ - void dragMotion (wdabs cx, wdabs cy, IChildWidget) {} - bool dragRelease (wdabs cx, wdabs cy, IChildWidget) { + override void dragMotion (wdabs cx, wdabs cy, IChildWidget) {} + override bool dragRelease (wdabs cx, wdabs cy, IChildWidget) { return false; // any widgets not handling events should let them be passed as normal to clickEvent } /* Dummy functions: suitable for widgets with no text input. */ - override void keyEvent (ushort, char[]) {} - override void keyFocusLost () {} + public override void keyEvent (ushort, char[]) {} + public override void keyFocusLost () {} // Called when mouse moves over or off this override void underMouse (bool state) {} - override bool dropContent (IContent content) { + public override bool dropContent (IContent content) { return parent.dropContent (content); } // Only useful to widgets creating popups. - override void popupClose () {} - override bool popupParentClick () { + protected override void popupClose () {} + protected override bool popupParentClick () { return true; } //END Events /* Basic draw method: draw the background (all widgets should do this). */ - override void draw () { + public override void draw () { + //TODO: possibly enforce all widgets to implement this so their invariant runs: + //assert (false, "all widgets should override draw"); mgr.renderer.drawWidgetBack (x,y, w,h); } // Debug function to print size info. Intended to be correct not optimal. - debug override void logWidgetSize () { + debug public override void logWidgetSize () { logger.trace ("size: {,4},{,4}; minimal: {,4},{,4}; sizable: {},{} - {,-50} {}", this.width, this.height, this.minWidth, this.minHeight, cast(int)this.isWSizable, cast(int)this.isHSizable, this, id); } @@ -211,6 +213,11 @@ mgr.requestRedraw; } + invariant { + assert (w >= mw); + assert (h >= mh); + } + IWidgetManager mgr; // the enclosing window IParentWidget parent; // the parent widget wdim x, y; // position @@ -309,7 +316,7 @@ } /// The action triggered when the button is clicked... - void activated (); + abstract void activated (); protected: bool pushed = false; /// True if button is pushed in (visually)