diff mde/gui/widget/miscWidgets.d @ 57:9e1f05fbbcef

Coloured and alpha-blended text is now supported. TextWidgets get text colour from argument.
author Diggory Hardy <diggory.hardy@gmail.com>
date Sat, 14 Jun 2008 13:09:03 +0100
parents bca7e2342d77
children d43523ed4b62
line wrap: on
line diff
--- a/mde/gui/widget/miscWidgets.d	Sat Jun 14 12:04:25 2008 +0100
+++ b/mde/gui/widget/miscWidgets.d	Sat Jun 14 13:09:03 2008 +0100
@@ -106,21 +106,25 @@
 class TextWidget : Widget
 {
     this (IWindow wind, int[] data) {
-        if (data.length != 1) throw new WidgetDataException;
+        if (data.length != 2) throw new WidgetDataException;
         if (font is null) font = FontStyle.get("default");
         font.updateBlock (str, textCache);
         mw = textCache.w;
         mh = textCache.h;
+        colour = Colour (cast(ubyte) (data[1] >> 16u),
+                         cast(ubyte) (data[1] >> 8u),
+                         cast(ubyte) data[1] );
         super (wind,data);
     }
     
     void draw () {
         super.draw();
-        font.textBlock (x,y, str, textCache);	// test new-lines and unicode characters
+        font.textBlock (x,y, str, textCache, colour);	// test new-lines and unicode characters
     }
     
 protected:
     const str = "Text Widget\nαβγ − ΑΒΓ";
     TextBlock textCache;
+    Colour colour;
     static FontStyle font;
 }