Mercurial > projects > mde
comparison mde/gui/widget/TextWidget.d @ 77:3dfd934100f7
Continuing widget data changes started in last commit: all previous widgets work again now (but lacking saving).
author | Diggory Hardy <diggory.hardy@gmail.com> |
---|---|
date | Tue, 29 Jul 2008 17:11:22 +0100 |
parents | 25cb7420dc91 |
children | b525ff28774b |
comparison
equal
deleted
inserted
replaced
76:65780e0e48e6 | 77:3dfd934100f7 |
---|---|
58 Colour colour; | 58 Colour colour; |
59 static FontStyle font; | 59 static FontStyle font; |
60 } | 60 } |
61 | 61 |
62 /// Basic text widget | 62 /// Basic text widget |
63 // FIXME (content, creation for different types) | |
63 class ContentWidget(ContentT : IContent) : Widget | 64 class ContentWidget(ContentT : IContent) : Widget |
64 { | 65 { |
65 /** Constructor for a widget containing [fixed] content. | 66 /** Constructor for a widget containing [fixed] content. |
66 * | 67 * |
67 * Widget uses the initialisation data: | 68 * Widget uses the initialisation data: |
68 * [widgetID, contentID, colour] | 69 * [widgetID, contentID, colour] |
69 * where contentID is an ID for the string ID of the contained content | 70 * where contentID is an ID for the string ID of the contained content |
70 * and colour is an 8-bit-per-channel RGB colour of the form 0xRRGGBB. */ | 71 * and colour is an 8-bit-per-channel RGB colour of the form 0xRRGGBB. */ |
71 this (IWidgetManager mgr, WidgetData data) { | 72 this (IWidgetManager mgr, WidgetData data) { |
72 if (data.length != 2) throw new WidgetDataException; | 73 WDCheck (data, 2, 1); |
73 text.set (data.str, data[1]); | 74 text.set (data.strings[0], data.ints[1]); |
74 text.getDimensions (mw, mh); | 75 text.getDimensions (mw, mh); |
75 super (mgr,data); | 76 super (mgr,data); |
76 } | 77 } |
77 | 78 |
78 void draw () { | 79 void draw () { |
116 } | 117 } |
117 | 118 |
118 /// Basic text widget | 119 /// Basic text widget |
119 class ContentOptionWidget : Widget | 120 class ContentOptionWidget : Widget |
120 { | 121 { |
121 this (IWindow wind, int[] data, IContent c) { | 122 this (IWidgetManager mgr, WidgetData data, IContent c) { |
122 if (data.length != 2) throw new WidgetDataException; | 123 WDCheck (data, 2, 0); |
123 content.set (c, data[1]); | 124 content.set (c, data.ints[1]); |
124 content.getDimensions (mw, mh); | 125 content.getDimensions (mw, mh); |
125 super (wind,data); | 126 super (mgr,data); |
126 } | 127 } |
127 | 128 |
128 void draw () { | 129 void draw () { |
129 super.draw(); | 130 super.draw(); |
130 content.draw (x,y); | 131 content.draw (x,y); |