diff options
| author | j-p <jp.bruyere@live.be> | 2016-08-15 20:55:55 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-08-15 20:55:55 +0200 |
| commit | ea5ba40d536aa80b56db118c3e8e077790c24359 (patch) | |
| tree | 194329bce587f3f7035f9d4d6258728ac45f3d2b /src/GraphicObjects/TemplatedControl.cs | |
| parent | ed815a31113235890cf6c902c754fb3dc7536708 (diff) | |
| parent | 6c5120d8108af9ed53e7205d221cf96a281a28a4 (diff) | |
Merge pull request #19 from jpbruyere/TemplatesPathes
Default Templates searched among resources finishing with .template
Textbox and label debug
Keyboard repeat
Double click
Wrapper
Diffstat (limited to 'src/GraphicObjects/TemplatedControl.cs')
| -rw-r--r-- | src/GraphicObjects/TemplatedControl.cs | 45 |
1 files changed, 14 insertions, 31 deletions
diff --git a/src/GraphicObjects/TemplatedControl.cs b/src/GraphicObjects/TemplatedControl.cs index 422a45ec..b77c89e3 100644 --- a/src/GraphicObjects/TemplatedControl.cs +++ b/src/GraphicObjects/TemplatedControl.cs @@ -31,35 +31,14 @@ using System.Reflection; namespace Crow { - [AttributeUsage(AttributeTargets.Class)] - public class TemplateAttribute : Attribute - { - public string Path = ""; - public TemplateAttribute(string path) - { - Path = path; - } - } - - [AttributeUsage(AttributeTargets.Class)] - public class DefaultTemplate : TemplateAttribute - { - public DefaultTemplate(string path) : base(path){} - } - [AttributeUsage(AttributeTargets.Class)] - public class DefaultItemTemplate : TemplateAttribute - { - public DefaultItemTemplate(string path) : base(path){} - } - public abstract class TemplatedControl : PrivateContainer, IXmlSerializable { #region CTOR public TemplatedControl () : base() { - if (Interface.CurrentInterface.XmlLoading) - return; - loadTemplate (); +// if (CurrentInterface.XmlLoading) +// return; + //loadTemplate (); } #endregion @@ -78,7 +57,7 @@ namespace Crow if (string.IsNullOrEmpty(_template)) loadTemplate (); else - loadTemplate (Interface.Load (_template)); + loadTemplate (CurrentInterface.Load (_template)); } } [XmlAttributeAttribute][DefaultValue("#Crow.Templates.ItemTemplate.goml")] @@ -103,9 +82,12 @@ namespace Crow protected override void onDraw (Cairo.Context gr) { gr.Save (); - //clip to client zone - CairoHelpers.CairoRectangle (gr, ClientRectangle, CornerRadius); - gr.Clip (); + + if (ClipToClientRect) { + //clip to client zone + CairoHelpers.CairoRectangle (gr, ClientRectangle, CornerRadius); + gr.Clip (); + } if (child != null) child.Paint (ref gr); @@ -116,8 +98,9 @@ namespace Crow protected virtual void loadTemplate(GraphicObject template = null) { if (template == null) { - DefaultTemplate dt = (DefaultTemplate)this.GetType ().GetCustomAttributes (typeof(DefaultTemplate), true).FirstOrDefault(); - this.SetChild (Interface.Load (dt.Path)); + if (!Interface.DefaultTemplates.ContainsKey (this.GetType ().FullName)) + throw new Exception (string.Format ("No default template found for '{0}'", this.GetType ().FullName)); + this.SetChild (CurrentInterface.Load (Interface.DefaultTemplates[this.GetType ().FullName])); }else this.SetChild (template); @@ -195,7 +178,7 @@ namespace Crow } } } else - loadTemplate (Interface.Load (template)); + loadTemplate (CurrentInterface.Load (template)); //if no template found, load default one if (this.child == null) |