diff mde/gui/widget/miscContent.d @ 105:08651e8a8c51

Quit button, big changes to content system. Moved mde.gui.content to mde.content to reflect it's not only used by the gui. Split Content module into Content and AStringContent. New AContent and EventContent class. Callbacks are now generic and implemented in AContent. Renamed TextContent to StringContent and ValueContent to AStringContent.
author Diggory Hardy <diggory.hardy@gmail.com>
date Sat, 29 Nov 2008 12:36:39 +0000
parents 42e241e7be3e
children 1655693702fc
line wrap: on
line diff
--- a/mde/gui/widget/miscContent.d	Wed Nov 26 13:07:46 2008 +0000
+++ b/mde/gui/widget/miscContent.d	Sat Nov 29 12:36:39 2008 +0000
@@ -24,8 +24,8 @@
 import mde.gui.widget.layout;
 
 import mde.gui.renderer.IRenderer;
-import mde.gui.content.Content;
-import Items = mde.gui.content.Items;
+import mde.content.AStringContent;
+import Items = mde.content.Items;
 
 /*************************************************************************************************
  * A function which uses Items.get (data.strings[0]) to get a content and creates a widget from
@@ -52,8 +52,8 @@
     if (c is null) throw new ContentException;
     if (cast(BoolContent) c)
         return new BoolContentWidget(mgr,id,data,c);
-    else if (cast(ValueContent) c)
-	return new ValueContentWidget(mgr,id,data,c);
+    else if (cast(AStringContent) c)
+	return new AStringContentWidget(mgr,id,data,c);
     else if (cast(ContentList) c)
 	return new ContentListWidget(mgr,id,data,c);
     else        // generic uneditable option
@@ -85,3 +85,32 @@
     BoolContent content;
 }
 
+/// A button connected to an EventContent
+class ButtonContentWidget : AButtonWidget
+{
+    this (IWidgetManager mgr, widgetID id, WidgetData data, IContent c) {
+	WDCheck (data, 1);
+	content = cast(EventContent) c;
+	if (!content) throw new ContentException ();
+	adapter = mgr.renderer.getAdapter (content.toString (1));
+	adapter.getDimensions (mw, mh);
+	w = mw;
+	h = mh;
+	super (mgr, id, data);
+    }
+    
+    void draw () {
+	super.draw();
+	adapter.draw (x,y);
+    }
+    
+    void activated () {
+	content.endEvent;
+    }
+    
+    protected:
+	IRenderer.TextAdapter adapter;
+	EventContent content;
+	int index;
+}
+