comparison mde/gui/widget/textContent.d @ 112:fe061009029d

EnumContent; log level can be selected from a popup list. New EnumContent, with code to load translations in Items. Editable as an AStringContent. Hacked OptionsMisc to use an EnumContent. Implemented a EnumContentWidget providing a pop-up list to select from (still needs improving). Moved IContent to its own module. ContentExceptions thrown via WDCCheck now. Fixed a small bug with reloading translations.
author Diggory Hardy <diggory.hardy@gmail.com>
date Sat, 13 Dec 2008 12:54:43 +0000
parents 1655693702fc
children b16a534f5302
comparison
equal deleted inserted replaced
111:1655693702fc 112:fe061009029d
29 static this () { 29 static this () {
30 logger = Log.getLogger ("mde.gui.widget.textContent"); 30 logger = Log.getLogger ("mde.gui.widget.textContent");
31 } 31 }
32 } 32 }
33 33
34 /// Just displays the content 34 /// Just displays the content. Generic − any IContent.
35 class DisplayContentWidget : ATextWidget 35 class DisplayContentWidget : ATextWidget
36 { 36 {
37 this (IWidgetManager mgr, widgetID id, WidgetData data, IContent c) { 37 this (IWidgetManager mgr, widgetID id, WidgetData data, IContent c) {
38 WDMinCheck(data, 1);
39 content = c; 38 content = c;
40 if (!content) throw new ContentException (); 39 WDCMinCheck(data, 1,0, content);
41 adapter = mgr.renderer.getAdapter (); 40 adapter = mgr.renderer.getAdapter ();
42 adapter.text = content.toString(0); 41 adapter.text = content.toString(0);
43 super (mgr, id, data); 42 super (mgr, id, data);
44 } 43 }
45 44
46 protected: 45 protected:
47 IContent content; 46 IContent content;
48 } 47 }
49 48
50 /// Capable of editing any ValueContent class 49 /// Text-box for editing a content. Generic − any AStringContent.
51 class AStringContentWidget : ATextWidget 50 class AStringContentWidget : ATextWidget
52 { 51 {
53 this (IWidgetManager mgr, widgetID id, WidgetData data, IContent c) { 52 this (IWidgetManager mgr, widgetID id, WidgetData data, IContent c) {
54 WDMinCheck(data, 1); 53 content = cast(AStringContent) c;
55 content = cast(AStringContent) c; 54 WDCMinCheck(data, 1,0, content);
56 if (!content) //content = new TextContent (null, null);
57 throw new ContentException ();
58 adapter = mgr.renderer.getAdapter (); 55 adapter = mgr.renderer.getAdapter ();
59 adapter.text = content.toString(0); 56 adapter.text = content.toString(0);
60 super (mgr, id, data); 57 super (mgr, id, data);
61 } 58 }
62 59
75 adapter.index = content.editIndex; 72 adapter.index = content.editIndex;
76 adapter.getDimensions (mw, mh); // NOTE: only passively change size: next resize will see new minimal size 73 adapter.getDimensions (mw, mh); // NOTE: only passively change size: next resize will see new minimal size
77 mgr.requestRedraw; 74 mgr.requestRedraw;
78 } 75 }
79 void keyFocusLost () { 76 void keyFocusLost () {
77 adapter.text = content.endEdit; // update other users of content relying on callbacks
80 adapter.index; 78 adapter.index;
81 content.endEdit; // update other users of content relying on callbacks
82 mgr.requestRedraw; 79 mgr.requestRedraw;
83 } 80 }
84 81
85 protected: 82 protected:
86 AStringContent content; 83 AStringContent content;