Mercurial > projects > mde
diff mde/gui/widget/Widget.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 | b16a534f5302 |
line wrap: on
line diff
--- a/mde/gui/widget/Widget.d Sat Dec 13 12:54:43 2008 +0000 +++ b/mde/gui/widget/Widget.d Fri Dec 19 10:32:28 2008 +0000 @@ -84,6 +84,13 @@ return h; } + wdabs xPos () { + return x; + } + wdabs yPos () { + return y; + } + deprecated void getCurrentSize (out wdim cw, out wdim ch) { cw = w; ch = h; @@ -122,6 +129,12 @@ /* Dummy functions: suitable for widgets with no text input. */ void keyEvent (ushort, char[]) {} void keyFocusLost () {} + + // Currently only applies to popup widgets. + void highlight (bool state) {} + + // Only useful to widgets creating popups. + void popupRemoved () {} //END Events /* Basic draw method: draw the background (all widgets should do this). */ @@ -176,7 +189,7 @@ } /************************************************************************************************* - * An abstract base widget class for parent widgets (many parent widgets don't use these methods). + * Abstract base widget classes to facilitate parent widgets. * * Parent widgets probably need to overload these functions (from AWidget): * setup, saveChanges, setPosition, getWidget, draw, setWidth and setHeight. @@ -189,8 +202,10 @@ bool setup (uint n, uint flags) { bool c = false; - foreach (w; subWidgets) + foreach (w; subWidgets) { + debug assert (w); c |= w.setup (n,flags); + } return c; } @@ -204,6 +219,25 @@ protected: IChildWidget[] subWidgets; } +/** ditto */ +abstract class AParentSingleWidget : AWidget +{ + this (IWidgetManager mgr, widgetID id, WidgetData data) { + super (mgr, id, data); + } + + bool setup (uint n, uint flags) { + debug assert (subWidget); + return subWidget.setup (n,flags); + } + + bool saveChanges () { + return subWidget.saveChanges; + } + +protected: + IChildWidget subWidget; +} /** A base for fixed-size widgets taking their size from the creation data. */ class FixedWidget : AWidget { @@ -286,5 +320,3 @@ protected: bool pushed = false; /// True if button is pushed in (visually) } - -