diff options
| author | jpbruyere <jp.bruyere@hotmail.com> | 2015-06-02 10:44:23 +0200 |
|---|---|---|
| committer | jpbruyere <jp.bruyere@hotmail.com> | 2015-06-02 10:44:23 +0200 |
| commit | b56c22ad826a49b7ea0013c1ca78cf64169fc326 (patch) | |
| tree | 588a3bc9ae0ed826012096a072b138a94ded4e61 /src/GraphicObjects/RadioButton.cs | |
| parent | 999f18b6daf7db54879a85f0f8b5c7b22f740ce7 (diff) | |
TemplatedControls, Picture objects for pixmap and svg raw data sharing
among controls
Diffstat (limited to 'src/GraphicObjects/RadioButton.cs')
| -rw-r--r-- | src/GraphicObjects/RadioButton.cs | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/src/GraphicObjects/RadioButton.cs b/src/GraphicObjects/RadioButton.cs new file mode 100644 index 00000000..9d6990db --- /dev/null +++ b/src/GraphicObjects/RadioButton.cs @@ -0,0 +1,73 @@ +using System;
+
+
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+//using OpenTK.Graphics.OpenGL;
+
+using Cairo;
+
+using winColors = System.Drawing.Color;
+using System.Diagnostics;
+using System.Xml.Serialization;
+using OpenTK.Input;
+using System.ComponentModel;
+
+namespace go
+{
+ public class RadioButton : TemplatedControl
+ {
+ Label _caption;
+ Image _image;
+
+ public RadioButton() : base()
+ {
+ }
+
+ protected override void loadTemplate()
+ {
+ this.setChild (Interface.Load ("#go.Templates.RadioButton.goml"));
+ _caption = this.child.FindByName ("Caption") as Label;
+ _image = this.child.FindByName ("Image") as Image;
+ _image.SvgSub = "unchecked";
+ }
+
+
+ [XmlAttributeAttribute()][DefaultValue("RadioButton")]
+ public string Caption {
+ get { return _caption.Text; }
+ set {
+ _caption.Text = value;
+ }
+ }
+ [XmlAttributeAttribute()][DefaultValue(false)]
+ public bool IsChecked
+ {
+ get { return _image == null ? false :_image.SvgSub == "checked"; }
+ set
+ {
+// if (value == IsChecked)
+// return;
+//
+ if (value)
+ _image.SvgSub = "checked";
+ else
+ _image.SvgSub = "unchecked";
+
+ registerForGraphicUpdate();
+ }
+ }
+
+ public override void onMouseClick (object sender, MouseButtonEventArgs e)
+ {
+ Group pg = Parent as Group;
+ if (pg != null) {
+ foreach (RadioButton c in pg.Children.OfType<RadioButton>())
+ c.IsChecked = (c == this);
+ }
+
+ base.onMouseClick (sender, e);
+ }
+ }
+}
|