From 54ff9d82e0d195bc335916b8a30a27651f830502 Mon Sep 17 00:00:00 2001 From: jpbruyere Date: Thu, 25 Feb 2016 11:52:35 +0100 Subject: [PATCH] DefaultStyle attribute, loaded in defvalues --- Crow.csproj | 11 ++++++++-- Styles/Button.style | 2 ++ {Style => Styles}/CheckBox.style | 0 Styles/ComboBox.style | 2 ++ Styles/Expandable.style | 2 ++ Styles/GroupBox.style | 2 ++ Styles/Popper.style | 2 ++ Styles/RadioButton.style | 2 ++ Styles/Splitter.style | 2 ++ Tests/GOLIBTests.cs | 4 ++-- Tests/Interfaces/testPopper.goml | 10 ++++----- src/GraphicObjects/Button.cs | 17 +-------------- src/GraphicObjects/CheckBox.cs | 14 +++--------- src/GraphicObjects/ComboBox.cs | 1 + src/GraphicObjects/Expandable.cs | 13 ++++------- src/GraphicObjects/GroupBox.cs | 10 +-------- src/GraphicObjects/Popper.cs | 9 ++------ src/GraphicObjects/RadioButton.cs | 36 +++++++++++++------------------ src/GraphicObjects/Splitter.cs | 3 ++- 19 files changed, 59 insertions(+), 83 deletions(-) create mode 100644 Styles/Button.style rename {Style => Styles}/CheckBox.style (100%) create mode 100644 Styles/ComboBox.style create mode 100644 Styles/Expandable.style create mode 100644 Styles/GroupBox.style create mode 100644 Styles/Popper.style create mode 100644 Styles/RadioButton.style create mode 100644 Styles/Splitter.style diff --git a/Crow.csproj b/Crow.csproj index 439302fa..fb12b57d 100644 --- a/Crow.csproj +++ b/Crow.csproj @@ -172,7 +172,7 @@ - + @@ -232,7 +232,14 @@ - + + + + + + + + diff --git a/Styles/Button.style b/Styles/Button.style new file mode 100644 index 00000000..2038c524 --- /dev/null +++ b/Styles/Button.style @@ -0,0 +1,2 @@ +Focusable = true +Fit = true diff --git a/Style/CheckBox.style b/Styles/CheckBox.style similarity index 100% rename from Style/CheckBox.style rename to Styles/CheckBox.style diff --git a/Styles/ComboBox.style b/Styles/ComboBox.style new file mode 100644 index 00000000..a5be8e2a --- /dev/null +++ b/Styles/ComboBox.style @@ -0,0 +1,2 @@ +Focusable = true +Height = -1 diff --git a/Styles/Expandable.style b/Styles/Expandable.style new file mode 100644 index 00000000..536e13dd --- /dev/null +++ b/Styles/Expandable.style @@ -0,0 +1,2 @@ +Focusable = true +Background = DimGray diff --git a/Styles/GroupBox.style b/Styles/GroupBox.style new file mode 100644 index 00000000..536e13dd --- /dev/null +++ b/Styles/GroupBox.style @@ -0,0 +1,2 @@ +Focusable = true +Background = DimGray diff --git a/Styles/Popper.style b/Styles/Popper.style new file mode 100644 index 00000000..a5be8e2a --- /dev/null +++ b/Styles/Popper.style @@ -0,0 +1,2 @@ +Focusable = true +Height = -1 diff --git a/Styles/RadioButton.style b/Styles/RadioButton.style new file mode 100644 index 00000000..a5be8e2a --- /dev/null +++ b/Styles/RadioButton.style @@ -0,0 +1,2 @@ +Focusable = true +Height = -1 diff --git a/Styles/Splitter.style b/Styles/Splitter.style new file mode 100644 index 00000000..536e13dd --- /dev/null +++ b/Styles/Splitter.style @@ -0,0 +1,2 @@ +Focusable = true +Background = DimGray diff --git a/Tests/GOLIBTests.cs b/Tests/GOLIBTests.cs index 3d6e619f..b46bcd7b 100644 --- a/Tests/GOLIBTests.cs +++ b/Tests/GOLIBTests.cs @@ -37,6 +37,8 @@ namespace test int frameCpt = 0; int idx = 0; string[] testFiles = { + "1.crow", + "5.crow", "testCheckbox.goml", "testTabView.crow", "testExpandable.goml", @@ -45,14 +47,12 @@ namespace test "testOutOfClipUpdate.crow", "test_Listbox.goml", "testTreeView.crow", - "1.crow", "testWindow.goml", "clip4.crow", "clip3.crow", "clip2.crow", "clip0.crow", "clip1.crow", - "5.crow", "testCombobox.goml", "testPopper.goml", "testTextBox.crow", diff --git a/Tests/Interfaces/testPopper.goml b/Tests/Interfaces/testPopper.goml index 0ba9beca..d1fe92ce 100755 --- a/Tests/Interfaces/testPopper.goml +++ b/Tests/Interfaces/testPopper.goml @@ -2,16 +2,16 @@ - - - - + + + + - + diff --git a/src/GraphicObjects/Button.cs b/src/GraphicObjects/Button.cs index 9903888b..92d19af6 100644 --- a/src/GraphicObjects/Button.cs +++ b/src/GraphicObjects/Button.cs @@ -13,6 +13,7 @@ using System.ComponentModel; namespace Crow { + [DefaultStyle("#Crow.Styles.Button.style")] [DefaultTemplate("#Crow.Templates.Button.crow")] public class Button : TemplatedContainer { @@ -42,22 +43,6 @@ namespace Crow } #region GraphicObject Overrides -// [XmlAttributeAttribute()][DefaultValue(50)] -// public override int Width { -// get { return base.Width; } -// set { base.Width = value; } -// } -// [XmlAttributeAttribute()][DefaultValue(20)] -// public override int Height { -// get { return base.Height; } -// set { base.Height = value; } -// } - [XmlAttributeAttribute()][DefaultValue(true)] - public override bool Focusable - { - get { return base.Focusable; } - set { base.Focusable = value; } - } public override void ResolveBindings () { base.ResolveBindings (); diff --git a/src/GraphicObjects/CheckBox.cs b/src/GraphicObjects/CheckBox.cs index fa37c70c..edf6650b 100644 --- a/src/GraphicObjects/CheckBox.cs +++ b/src/GraphicObjects/CheckBox.cs @@ -5,6 +5,7 @@ using System.Xml.Serialization; namespace Crow { + [DefaultStyle("#Crow.Styles.CheckBox.style")] [DefaultTemplate("#Crow.Templates.CheckBox.goml")] public class CheckBox : TemplatedControl { @@ -14,21 +15,12 @@ namespace Crow #region CTOR public CheckBox() : base() - { - } + {} #endregion public event EventHandler Checked; public event EventHandler Unchecked; - #region GraphicObject overrides - [XmlAttributeAttribute()][DefaultValue("#Crow.Style.CheckBox.style")] - public override string Style { - get { return base.Style; } - set { base.Style = value; } - } - #endregion - [XmlAttributeAttribute()][DefaultValue("Checkbox")] public string Caption { get { return caption; } @@ -49,7 +41,6 @@ namespace Crow NotifyValueChanged ("Image", image); } } - [XmlAttributeAttribute()][DefaultValue(false)] public bool IsChecked { @@ -69,6 +60,7 @@ namespace Crow Unchecked.Raise (this, null); } } + public override void onMouseClick (object sender, MouseButtonEventArgs e) { IsChecked = !IsChecked; diff --git a/src/GraphicObjects/ComboBox.cs b/src/GraphicObjects/ComboBox.cs index 7b98ca4f..4f948e5b 100644 --- a/src/GraphicObjects/ComboBox.cs +++ b/src/GraphicObjects/ComboBox.cs @@ -2,6 +2,7 @@ namespace Crow { + [DefaultStyle("#Crow.Styles.ComboBox.style")] [DefaultTemplate("#Crow.Templates.ComboBox.goml")] public class ComboBox : ListBox { diff --git a/src/GraphicObjects/Expandable.cs b/src/GraphicObjects/Expandable.cs index be4018c9..3593bf90 100644 --- a/src/GraphicObjects/Expandable.cs +++ b/src/GraphicObjects/Expandable.cs @@ -5,6 +5,7 @@ using System.Xml.Serialization; namespace Crow { + [DefaultStyle("#Crow.Styles.Expandable.style")] [DefaultTemplate("#Crow.Templates.Expandable.goml")] public class Expandable : TemplatedContainer { @@ -27,11 +28,10 @@ namespace Crow #endregion #region GraphicObject overrides - [XmlAttributeAttribute()][DefaultValue(true)] - public override bool Focusable + public override void onMouseClick (object sender, MouseButtonEventArgs e) { - get { return base.Focusable; } - set { base.Focusable = value; } + IsExpanded = !IsExpanded; + base.onMouseClick (sender, e); } #endregion @@ -49,11 +49,6 @@ namespace Crow _contentContainer = this.child.FindByName ("Content") as Container; } - public override void onMouseClick (object sender, MouseButtonEventArgs e) - { - IsExpanded = !IsExpanded; - base.onMouseClick (sender, e); - } public override void ResolveBindings () { base.ResolveBindings (); diff --git a/src/GraphicObjects/GroupBox.cs b/src/GraphicObjects/GroupBox.cs index e3001663..86c659d0 100644 --- a/src/GraphicObjects/GroupBox.cs +++ b/src/GraphicObjects/GroupBox.cs @@ -4,6 +4,7 @@ using System.ComponentModel; namespace Crow { + [DefaultStyle("#Crow.Styles.GroupBox.style")] [DefaultTemplate("#Crow.Templates.GroupBox.goml")] public class GroupBox : TemplatedContainer { @@ -31,15 +32,6 @@ namespace Crow } #endregion - #region GraphicObject overrides - [XmlAttributeAttribute()][DefaultValue(true)]//overiden to get default to true - public override bool Focusable - { - get { return base.Focusable; } - set { base.Focusable = value; } - } - #endregion - [XmlAttributeAttribute()][DefaultValue("Groupbox")] public string Caption { get { return caption; } diff --git a/src/GraphicObjects/Popper.cs b/src/GraphicObjects/Popper.cs index be19818f..4c5ca11c 100644 --- a/src/GraphicObjects/Popper.cs +++ b/src/GraphicObjects/Popper.cs @@ -5,6 +5,7 @@ using OpenTK.Input; namespace Crow { + [DefaultStyle("#Crow.Styles.Popper.style")] [DefaultTemplate("#Crow.Templates.Popper.goml")] public class Popper : TemplatedContainer { @@ -87,12 +88,6 @@ namespace Crow } #region GraphicObject overrides - [XmlAttributeAttribute()][DefaultValue(true)]//overiden to get default to true - public override bool Focusable - { - get { return base.Focusable; } - set { base.Focusable = value; } - } public override void ClearBinding () { //ensure popped window is cleared @@ -119,8 +114,8 @@ namespace Crow } public override void onMouseLeave (object sender, MouseMoveEventArgs e) { - base.onMouseLeave (sender, e); IsPopped = false; + base.onMouseLeave (sender, e); } #endregion diff --git a/src/GraphicObjects/RadioButton.cs b/src/GraphicObjects/RadioButton.cs index 6ca636b1..4370d157 100644 --- a/src/GraphicObjects/RadioButton.cs +++ b/src/GraphicObjects/RadioButton.cs @@ -5,6 +5,7 @@ using System.Xml.Serialization; namespace Crow { + [DefaultStyle("#Crow.Styles.RadioButton.style")] [DefaultTemplate("#Crow.Templates.RadioButton.goml")] public class RadioButton : TemplatedControl { @@ -20,11 +21,20 @@ namespace Crow public event EventHandler Unchecked; #region GraphicObject overrides - [XmlAttributeAttribute()][DefaultValue(true)] - public override bool Focusable - { - get { return base.Focusable; } - set { base.Focusable = value; } + public override void onMouseClick (object sender, MouseButtonEventArgs e) + { + Group pg = Parent as Group; + if (pg != null) { + for (int i = 0; i < pg.Children.Count; i++) { + RadioButton c = pg.Children [i] as RadioButton; + if (c == null) + continue; + c.IsChecked = (c == this); + } + } else + IsChecked = !IsChecked; + + base.onMouseClick (sender, e); } #endregion @@ -68,21 +78,5 @@ namespace Crow Unchecked.Raise (this, null); } } - - public override void onMouseClick (object sender, MouseButtonEventArgs e) - { - Group pg = Parent as Group; - if (pg != null) { - for (int i = 0; i < pg.Children.Count; i++) { - RadioButton c = pg.Children [i] as RadioButton; - if (c == null) - continue; - c.IsChecked = (c == this); - } - } else - IsChecked = !IsChecked; - - base.onMouseClick (sender, e); - } } } diff --git a/src/GraphicObjects/Splitter.cs b/src/GraphicObjects/Splitter.cs index f3fdb341..97cce52c 100644 --- a/src/GraphicObjects/Splitter.cs +++ b/src/GraphicObjects/Splitter.cs @@ -24,7 +24,7 @@ using System.ComponentModel; namespace Crow { - [StyleAttribute("Background", "DimGray")] + [DefaultStyle("#Crow.Styles.Splitter.style")] public class Splitter : GraphicObject { #region CTOR @@ -32,6 +32,7 @@ namespace Crow #endregion int thickness; + [XmlAttributeAttribute()][DefaultValue(1)] public virtual int Thickness { get { return thickness; } -- 2.47.3