2 using System.Windows;
\r
3 using System.Windows.Controls;
\r
4 using System.Windows.Documents;
\r
5 using System.Windows.Input;
\r
6 using System.Windows.Media;
\r
7 using System.Windows.Media.Animation;
\r
8 using System.Windows.Media.Imaging;
\r
9 using System.Windows.Shapes;
\r
10 using System.Windows.Browser;
\r
19 class Widget : public Figure {
\r
31 static bool initialized__;
\r
32 static Image default_button, default_horiz_grad;
\r
33 enum TYPE_TAG { NORMAL, ALERT };
\r
35 Color normal_foreground[2], active_foreground[2];
\r
36 Color normal_background[2], active_background[2], over_background[2];
\r
37 Stroke normal_stroke[2], active_stroke[2];
\r
38 Image button_back, *horiz_grad;
\r
40 static Theme current;
\r
41 static void initialize();
\r
46 class WidgetRect : Widget
\r
49 HumanInterfaceDevice::ButtonStateHolder mleft;
\r
54 //Theme::TYPE_TAG theme_type;
\r
55 public Rectangle area;
\r
56 public Letters label;
\r
58 public abstract WidgetRect();
\r
59 public virtual const Point getDatum() const;
\r
60 public virtual WidgetRect& setDatum(const Point&);
\r
61 public virtual WidgetRect& centering(const Point&);
\r
62 public double getWidth() const;
\r
63 public double getHeight() const;
\r
64 public double getLeft() const;
\r
65 public double getTop() const;
\r
66 public double getRight() const;
\r
67 public double getBottom() const;
\r
68 public WidgetRect& alignLeft(const double lef);
\r
69 public WidgetRect& alignTop(const double to_);
\r
70 public WidgetRect& alignRight(const double rig);
\r
71 public WidgetRect& alignBottom(const double bot);
\r
73 public virtual WidgetRect& set(double wid, double hei);
\r
74 public virtual WidgetRect& set(std::wstring name);
\r
75 public virtual WidgetRect& set(std::wstring name, double hei);
\r
76 public virtual WidgetRect& setLabel(std::wstring s);
\r
77 public virtual WidgetRect& draw(Drawable &target = *Drawable::prime);
\r
78 public bool pushed();
\r
79 public WidgetRect& pushThis();
\r
85 public Rectangle outer;
\r
91 internal System.Windows.UIElement instance;
\r
92 internal System.Windows.Controls.Slider uislider;
\r
93 internal string label;
\r
94 internal Interval range;
\r
96 public Slider(string l, Interval r)
\r
100 Psychlops.Widgets.Connector.stackSlider(this);
\r
102 public static implicit operator double(Slider s)
\r
106 public double value {
\r
107 get { return uislider.Value; }
\r
108 set { if(uislider!=null) uislider.Dispatcher.BeginInvoke( new Action<System.Windows.Controls.Slider, double>(Connector.sliderSet) , uislider, value ); }
\r
110 public bool changed { get; set; }
\r
114 public class Browser
\r
116 public class Element
\r
119 System.Object retval;
\r
126 public static Element byID(string id_tag)
\r
128 return getElementById(id_tag);
\r
130 public static Element getElementById(string id_tag)
\r
132 Element tmp = new Element();
\r
133 Internal.Main.widgetStack.Dispatcher.BeginInvoke(new Connector.VoidString(tmp.getElementById__), id_tag);
\r
136 void getElementById__(string id_tag)
\r
138 elem = HtmlPage.Document.GetElementById(id_tag);
\r
141 public void setProperty(string name, System.Object value)
\r
143 Internal.Main.widgetStack.Dispatcher.BeginInvoke(new Connector.VoidStringObject(setProperty__), name, value);
\r
145 public void setProperty__(string name, System.Object value)
\r
147 elem.SetProperty(name, value);
\r
151 public static implicit operator double(Element i) { return i.getValueAsDouble(); }
\r
152 public double getValueAsDouble()
\r
155 getProperty("value");
\r
158 v = double.Parse(retval.ToString());
\r
160 catch (FormatException e)
\r
167 public static implicit operator string(Element i) { return i.getProperty("value").ToString(); }
\r
168 public System.Object getProperty(string name)
\r
170 Internal.Main.widgetStack.Dispatcher.BeginInvoke(new Connector.VoidString(getProperty__), name);
\r
173 public void getProperty__(string name)
\r
175 retval = elem.GetProperty(name);
\r
182 internal static class Connector
\r
184 internal delegate void VoidString(string s);
\r
185 internal delegate void VoidStringObject(String s, System.Object o);
\r
189 delegate void StackSlider_(Slider s);
\r
190 internal static void stackSlider(Slider s)
\r
192 Internal.Main.widgetStack.Dispatcher.BeginInvoke(new StackSlider_(stackSlider__), s);
\r
194 static void stackSlider__(Slider ss)
\r
196 var holder = new System.Windows.Controls.Canvas { Width = 200 };
\r
197 var val = new System.Windows.Controls.TextBox { Width = 100 };
\r
198 System.Windows.Controls.Canvas.SetLeft(val, 100);
\r
199 var slide = new System.Windows.Controls.Slider {
\r
200 Minimum = ss.range.begin.val, Maximum = ss.range.end.val,
\r
202 Tag = ss, Width = 200,
\r
204 System.Windows.Controls.Canvas.SetTop(slide, 25);
\r
205 var b = new System.Windows.Data.Binding {
\r
206 Path = new PropertyPath("Value"),
\r
207 Mode = System.Windows.Data.BindingMode.TwoWay,
\r
210 val.SetBinding(TextBox.TextProperty, b);
\r
211 ss.uislider = slide;
\r
212 //var b2 = new System.Windows.Data.Binding
\r
214 // Path = new PropertyPath("value"),
\r
215 // Mode = System.Windows.Data.BindingMode.TwoWay,
\r
218 //val.SetBinding(System.Windows.Controls.Slider.ValueProperty, b2);
\r
219 var label = new System.Windows.Controls.TextBlock { Text = ss.label };
\r
220 System.Windows.Controls.Canvas.SetLeft(label, 3);
\r
221 System.Windows.Controls.Canvas.SetTop(label, 3);
\r
223 holder.Children.Add(label);
\r
224 holder.Children.Add(slide);
\r
225 holder.Children.Add(val);
\r
226 ss.instance = holder;
\r
227 Internal.Main.widgetStack.Children.Add(ss.instance);
\r
229 public static void sliderSet(System.Windows.Controls.Slider s, double v)
\r