Mercurial > projects > mde
diff mde/gui/widget/miscContent.d @ 146:783969f4665c
Simple, inefficient context menus (displaying content description).
author | Diggory Hardy <diggory.hardy@gmail.com> |
---|---|
date | Wed, 11 Feb 2009 12:00:12 +0000 |
parents | 2ac3e0012788 |
children | 17438f17bfb5 |
line wrap: on
line diff
--- a/mde/gui/widget/miscContent.d Tue Feb 10 13:10:53 2009 +0000 +++ b/mde/gui/widget/miscContent.d Wed Feb 11 12:00:12 2009 +0000 @@ -37,39 +37,43 @@ class BoolContentWidget : AButtonWidget { this (IWidgetManager mgr, IParentWidget parent, widgetID id, WidgetData, IContent c) { - content = cast(BoolContent) c; - if (content is null) throw new ContentException (this); + content_ = cast(BoolContent) c; + if (content_ is null) throw new ContentException (this); super (mgr, parent, id); wdimPair s = mgr.renderer.getToggleSize; w = mw = s.x; h = mh = s.y; } + override IContent content () { + return content_; + } + override void draw () { - mgr.renderer.drawToggle (x,y, content(), pushed); + mgr.renderer.drawToggle (x,y, content_(), pushed); } override void activated () { - content = !content(); + content_ = !content_(); } protected: - BoolContent content; + BoolContent content_; } /// A button connected to an EventContent class ButtonContentWidget : AButtonWidget { this (IWidgetManager mgr, IParentWidget parent, widgetID id, WidgetData, IContent c) { - content = cast(Content) c; - if (content is null) throw new ContentException (this); + content_ = cast(Content) c; + if (content_ is null) throw new ContentException (this); adapter = mgr.renderer.getAdapter (); super (mgr, parent, id); } override bool setup (uint n, uint flags) { if (!(flags & 3)) return false; // string or renderer (and possibly font) changed - adapter.text = content.toString(1); + adapter.text = content_.toString(1); adapter.getDimensions (mw, mh); if (mw != w || mh != h) { w = mw; @@ -78,18 +82,22 @@ return true; } + override IContent content () { + return content_; + } + override void draw () { super.draw(); adapter.draw (x,y); } override void activated () { - content.endEvent; + content_.endEvent; } protected: IRenderer.TextAdapter adapter; - Content content; + Content content_; int index; } @@ -97,23 +105,27 @@ class SliderContentWidget : AChildWidget { this (IWidgetManager mgr, IParentWidget parent, widgetID id, WidgetData, IContent c) { - content = cast(DoubleContent) c; - if (content is null) throw new ContentException (this); + content_ = cast(DoubleContent) c; + if (content_ is null) throw new ContentException (this); super (mgr, parent, id); wdimPair s = mgr.renderer.getSliderSize; w = mw = s.x; h = mh = s.y; } + override IContent content () { + return content_; + } + override bool isWSizable () { return true; } override void draw () { - mgr.renderer.drawSlider (x,y, w, content()); + mgr.renderer.drawSlider (x,y, w, content_()); } protected: - DoubleContent content; + DoubleContent content_; }