Changeset 59:672b6b162a36
- Timestamp:
- 06/14/08 12:52:22
(7 months ago)
- Author:
- Diggory Hardy <diggory.hardy@gmail.com>
- branch:
- default
- Message:
Added very basic (and currently useless) content support.
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r58 |
r59 |
|
| 32 | 32 | alias wdim wdsize; /// ditto |
|---|
| 33 | 33 | |
|---|
| 34 | | /// A pair of wdim variables, and strictly no other data (methods may be added if deemed useful). |
|---|
| | 34 | /** A pair of wdim variables, and strictly no other data (methods may be added if deemed useful). |
|---|
| | 35 | * |
|---|
| | 36 | * Potentially usable to return two wdim variables, e.g. width and height, from a function. |
|---|
| | 37 | * However, the current usage of out variables looks like it's better. */ |
|---|
| 35 | 38 | struct wdimPair { |
|---|
| 36 | 39 | wdim x, y; /// data |
|---|
| r45 |
r59 |
|
| 23 | 23 | import mde.gui.widget.layout; |
|---|
| 24 | 24 | import mde.gui.widget.miscWidgets; |
|---|
| | 25 | import mde.gui.widget.TextWidget; |
|---|
| 25 | 26 | |
|---|
| 26 | 27 | /** Create a widget of type data[0] (see enum WIDGET_TYPES) for _window window, with initialisation |
|---|
| r58 |
r59 |
|
| 20 | 20 | import mde.gui.exception; |
|---|
| 21 | 21 | import mde.gui.renderer.IRenderer; |
|---|
| 22 | | |
|---|
| 23 | | import mde.resource.font; |
|---|
| 24 | 22 | |
|---|
| 25 | 23 | import tango.io.Stdout; |
|---|
| … | … | |
| 102 | 100 | } |
|---|
| 103 | 101 | } |
|---|
| 104 | | |
|---|
| 105 | | /// Basic text widget |
|---|
| 106 | | class TextWidget : Widget |
|---|
| 107 | | { |
|---|
| 108 | | this (IWindow wind, int[] data) { |
|---|
| 109 | | if (data.length != 2) throw new WidgetDataException; |
|---|
| 110 | | if (font is null) font = FontStyle.get("default"); |
|---|
| 111 | | font.updateBlock (str, textCache); |
|---|
| 112 | | mw = cast(wdim) textCache.w; |
|---|
| 113 | | mh = cast(wdim) textCache.h; |
|---|
| 114 | | colour = Colour (cast(ubyte) (data[1] >> 16u), |
|---|
| 115 | | cast(ubyte) (data[1] >> 8u), |
|---|
| 116 | | cast(ubyte) data[1] ); |
|---|
| 117 | | super (wind,data); |
|---|
| 118 | | } |
|---|
| 119 | | |
|---|
| 120 | | void draw () { |
|---|
| 121 | | super.draw(); |
|---|
| 122 | | font.textBlock (x,y, str, textCache, colour); // test new-lines and unicode characters |
|---|
| 123 | | } |
|---|
| 124 | | |
|---|
| 125 | | protected: |
|---|
| 126 | | const str = "Text Widget\nαβγ â ÎÎÎ"; |
|---|
| 127 | | TextBlock textCache; |
|---|
| 128 | | Colour colour; |
|---|
| 129 | | static FontStyle font; |
|---|
| 130 | | } |
|---|