diff mde/gui/widget/TextWidget.d @ 126:c9843fbaac88

Dynamic minimal size changing improved; works over layouts sharing alignment. EnumContent sub-contents use EnumValueContent instead of BoolContent; fixes a few small bugs. EnumContent substrings get translated (bug fixed). The widget manager no longer attempts to set widget sizes smaller than their minimals, even though some will not be shown. SwitchWidget: has fixed sizableness now.
author Diggory Hardy <diggory.hardy@gmail.com>
date Thu, 08 Jan 2009 13:05:44 +0000
parents d3b2cefd46c9
children c5c38eaadb64
line wrap: on
line diff
--- a/mde/gui/widget/TextWidget.d	Tue Jan 06 16:54:04 2009 +0000
+++ b/mde/gui/widget/TextWidget.d	Thu Jan 08 13:05:44 2009 +0000
@@ -111,11 +111,17 @@
         if (content is null) throw new ContentException (this);
         super (mgr, parent, id);
         
+        Content c2 = cast(Content) content;
+        if (c2)		// add callback if possible
+            c2.addCallback (&update);
         adapter = mgr.renderer.getAdapter ();
 	adapter.text = content.toString(0);
     }
     
 protected:
+    void update (Content) {	// callback
+        adapter.text = content.toString(0);
+    }
     IContent content;
 }
 
@@ -127,6 +133,7 @@
         if (content is null) throw new ContentException (this);
         super (mgr, parent, id);
         
+        content.addCallback (&update);
         adapter = mgr.renderer.getAdapter ();
 	adapter.text = content.toString(0);
     }
@@ -145,8 +152,12 @@
     override void keyEvent (ushort s, char[] i) {
 	adapter.text = content.keyStroke (s, i);
 	adapter.index = content.editIndex;
-	adapter.getDimensions (mw, mh);
-        parent.minSizeChange (this, mw, mh);
+        wdim omw = mw, omh = mh;
+        adapter.getDimensions (mw, mh);
+        if (omw != mw)
+            parent.minWChange (this, mw);
+        if (omh != mh)
+            parent.minHChange (this, mh);
 	mgr.requestRedraw;
     }
     override void keyFocusLost () {
@@ -156,5 +167,14 @@
     }
     
 protected:
+    void update (Content) {	// callback
+        adapter.text = content.toString(0);
+        wdim omw = mw, omh = mh;
+        adapter.getDimensions (mw, mh);
+        if (omw != mw)
+            parent.minWChange (this, mw);
+        if (omh != mh)
+            parent.minHChange (this, mh);
+    }
     AStringContent content;
 }