Mercurial > projects > mde
diff mde/gui/widget/TextWidget.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 | 1048b5c7cab1 |
children | 36df0ffe34d2 |
line wrap: on
line diff
--- a/mde/gui/widget/TextWidget.d Tue Feb 10 13:10:53 2009 +0000 +++ b/mde/gui/widget/TextWidget.d Wed Feb 11 12:00:12 2009 +0000 @@ -88,27 +88,31 @@ class DisplayContentWidget : ATextWidget { this (IWidgetManager mgr, IParentWidget parent, widgetID id, WidgetData data, IContent c) { - content = cast(Content) c; - WDCMinCheck (data, 1, 0, content); + content_ = cast(Content) c; + WDCMinCheck (data, 1, 0, content_); super (mgr, parent, id); if (data.ints.length >= 3) cIndex = data.ints[2]; // otherwise display '0', the value if (cIndex == 0) - content.addCallback (&updateVal); + content_.addCallback (&updateVal); adapter = mgr.renderer.getAdapter (); } override bool setup (uint n, uint flags) { if (!(flags & 3)) return false; // string or renderer (and possibly font) changed - adapter.text = content.toString(cIndex); + adapter.text = content_.toString(cIndex); return super.setup (n, 3); // force redimensioning } + override IContent content () { + return content_; + } + protected: void updateVal (Content) { // callback - adapter.text = content.toString(cIndex); + adapter.text = content_.toString(cIndex); wdim omw = mw, omh = mh; adapter.getDimensions (mw, mh); if (omw != mw) @@ -116,7 +120,7 @@ if (omh != mh) parent.minHChange (this, mh); } - Content content; + Content content_; int cIndex; } @@ -124,13 +128,17 @@ class AStringContentWidget : ATextWidget { this (IWidgetManager mgr, IParentWidget parent, widgetID id, WidgetData, IContent c) { - content = cast(AStringContent) c; - if (content is null) throw new ContentException (this); + content_ = cast(AStringContent) c; + if (content_ is null) throw new ContentException (this); super (mgr, parent, id); - content.addCallback (&update); + content_.addCallback (&update); adapter = mgr.renderer.getAdapter (); - adapter.text = content.toString(0); + adapter.text = content_.toString(0); + } + + override IContent content () { + return content_; } override bool isWSizable () { @@ -142,15 +150,15 @@ /** On click, request keyboard input. */ override int clickEvent (wdabs cx, wdabs, ubyte, bool) { - //adapter.index = content.editIndex; - content.editIndex = adapter.setIndex (cx - x); + //adapter.index = content_.editIndex; + content_.editIndex = adapter.setIndex (cx - x); mgr.requestRedraw; return 1; // get keyboard input via keyEvent } override void keyEvent (ushort s, char[] i) { - adapter.text = content.keyStroke (s, i); - adapter.index = content.editIndex; + adapter.text = content_.keyStroke (s, i); + adapter.index = content_.editIndex; wdim omw = mw, omh = mh; adapter.getDimensions (mw, mh); if (omw != mw) @@ -160,14 +168,14 @@ mgr.requestRedraw; } override void keyFocusLost () { - adapter.text = content.endEdit; // update other users of content relying on callbacks + adapter.text = content_.endEdit; // update other users of content_ relying on callbacks adapter.index; mgr.requestRedraw; } protected: void update (Content) { // callback - adapter.text = content.toString(0); + adapter.text = content_.toString(0); wdim omw = mw, omh = mh; adapter.getDimensions (mw, mh); if (omw != mw) @@ -175,5 +183,5 @@ if (omh != mh) parent.minHChange (this, mh); } - AStringContent content; + AStringContent content_; }