Mercurial > projects > mde
comparison 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 |
comparison
equal
deleted
inserted
replaced
56:f9f5e04f20b2 | 57:9e1f05fbbcef |
---|---|
104 | 104 |
105 /// Basic text widget | 105 /// Basic text widget |
106 class TextWidget : Widget | 106 class TextWidget : Widget |
107 { | 107 { |
108 this (IWindow wind, int[] data) { | 108 this (IWindow wind, int[] data) { |
109 if (data.length != 1) throw new WidgetDataException; | 109 if (data.length != 2) throw new WidgetDataException; |
110 if (font is null) font = FontStyle.get("default"); | 110 if (font is null) font = FontStyle.get("default"); |
111 font.updateBlock (str, textCache); | 111 font.updateBlock (str, textCache); |
112 mw = textCache.w; | 112 mw = textCache.w; |
113 mh = textCache.h; | 113 mh = textCache.h; |
114 colour = Colour (cast(ubyte) (data[1] >> 16u), | |
115 cast(ubyte) (data[1] >> 8u), | |
116 cast(ubyte) data[1] ); | |
114 super (wind,data); | 117 super (wind,data); |
115 } | 118 } |
116 | 119 |
117 void draw () { | 120 void draw () { |
118 super.draw(); | 121 super.draw(); |
119 font.textBlock (x,y, str, textCache); // test new-lines and unicode characters | 122 font.textBlock (x,y, str, textCache, colour); // test new-lines and unicode characters |
120 } | 123 } |
121 | 124 |
122 protected: | 125 protected: |
123 const str = "Text Widget\nαβγ − ΑΒΓ"; | 126 const str = "Text Widget\nαβγ − ΑΒΓ"; |
124 TextBlock textCache; | 127 TextBlock textCache; |
128 Colour colour; | |
125 static FontStyle font; | 129 static FontStyle font; |
126 } | 130 } |