comparison mde/gui/widget/miscContent.d @ 146:783969f4665c

Simple, inefficient context menus (displaying content description).
author Diggory Hardy <diggory.hardy@gmail.com>
date Wed, 11 Feb 2009 12:00:12 +0000
parents 2ac3e0012788
children 17438f17bfb5
comparison
equal deleted inserted replaced
145:1048b5c7cab1 146:783969f4665c
35 35
36 /// Editable boolean widget 36 /// Editable boolean widget
37 class BoolContentWidget : AButtonWidget 37 class BoolContentWidget : AButtonWidget
38 { 38 {
39 this (IWidgetManager mgr, IParentWidget parent, widgetID id, WidgetData, IContent c) { 39 this (IWidgetManager mgr, IParentWidget parent, widgetID id, WidgetData, IContent c) {
40 content = cast(BoolContent) c; 40 content_ = cast(BoolContent) c;
41 if (content is null) throw new ContentException (this); 41 if (content_ is null) throw new ContentException (this);
42 super (mgr, parent, id); 42 super (mgr, parent, id);
43 wdimPair s = mgr.renderer.getToggleSize; 43 wdimPair s = mgr.renderer.getToggleSize;
44 w = mw = s.x; 44 w = mw = s.x;
45 h = mh = s.y; 45 h = mh = s.y;
46 } 46 }
47 47
48 override IContent content () {
49 return content_;
50 }
51
48 override void draw () { 52 override void draw () {
49 mgr.renderer.drawToggle (x,y, content(), pushed); 53 mgr.renderer.drawToggle (x,y, content_(), pushed);
50 } 54 }
51 55
52 override void activated () { 56 override void activated () {
53 content = !content(); 57 content_ = !content_();
54 } 58 }
55 59
56 protected: 60 protected:
57 BoolContent content; 61 BoolContent content_;
58 } 62 }
59 63
60 /// A button connected to an EventContent 64 /// A button connected to an EventContent
61 class ButtonContentWidget : AButtonWidget 65 class ButtonContentWidget : AButtonWidget
62 { 66 {
63 this (IWidgetManager mgr, IParentWidget parent, widgetID id, WidgetData, IContent c) { 67 this (IWidgetManager mgr, IParentWidget parent, widgetID id, WidgetData, IContent c) {
64 content = cast(Content) c; 68 content_ = cast(Content) c;
65 if (content is null) throw new ContentException (this); 69 if (content_ is null) throw new ContentException (this);
66 adapter = mgr.renderer.getAdapter (); 70 adapter = mgr.renderer.getAdapter ();
67 super (mgr, parent, id); 71 super (mgr, parent, id);
68 } 72 }
69 73
70 override bool setup (uint n, uint flags) { 74 override bool setup (uint n, uint flags) {
71 if (!(flags & 3)) return false; // string or renderer (and possibly font) changed 75 if (!(flags & 3)) return false; // string or renderer (and possibly font) changed
72 adapter.text = content.toString(1); 76 adapter.text = content_.toString(1);
73 adapter.getDimensions (mw, mh); 77 adapter.getDimensions (mw, mh);
74 if (mw != w || mh != h) { 78 if (mw != w || mh != h) {
75 w = mw; 79 w = mw;
76 h = mh; 80 h = mh;
77 } 81 }
78 return true; 82 return true;
79 } 83 }
80 84
85 override IContent content () {
86 return content_;
87 }
88
81 override void draw () { 89 override void draw () {
82 super.draw(); 90 super.draw();
83 adapter.draw (x,y); 91 adapter.draw (x,y);
84 } 92 }
85 93
86 override void activated () { 94 override void activated () {
87 content.endEvent; 95 content_.endEvent;
88 } 96 }
89 97
90 protected: 98 protected:
91 IRenderer.TextAdapter adapter; 99 IRenderer.TextAdapter adapter;
92 Content content; 100 Content content_;
93 int index; 101 int index;
94 } 102 }
95 103
96 /// Display a double in a progress bar/slider. Non-editable. 104 /// Display a double in a progress bar/slider. Non-editable.
97 class SliderContentWidget : AChildWidget 105 class SliderContentWidget : AChildWidget
98 { 106 {
99 this (IWidgetManager mgr, IParentWidget parent, widgetID id, WidgetData, IContent c) { 107 this (IWidgetManager mgr, IParentWidget parent, widgetID id, WidgetData, IContent c) {
100 content = cast(DoubleContent) c; 108 content_ = cast(DoubleContent) c;
101 if (content is null) throw new ContentException (this); 109 if (content_ is null) throw new ContentException (this);
102 super (mgr, parent, id); 110 super (mgr, parent, id);
103 wdimPair s = mgr.renderer.getSliderSize; 111 wdimPair s = mgr.renderer.getSliderSize;
104 w = mw = s.x; 112 w = mw = s.x;
105 h = mh = s.y; 113 h = mh = s.y;
114 }
115
116 override IContent content () {
117 return content_;
106 } 118 }
107 119
108 override bool isWSizable () { 120 override bool isWSizable () {
109 return true; 121 return true;
110 } 122 }
111 123
112 override void draw () { 124 override void draw () {
113 mgr.renderer.drawSlider (x,y, w, content()); 125 mgr.renderer.drawSlider (x,y, w, content_());
114 } 126 }
115 127
116 protected: 128 protected:
117 DoubleContent content; 129 DoubleContent content_;
118 } 130 }
119 131