2001-10-27 Miguel de Icaza <miguel@ximian.com>
authorMiguel de Icaza <miguel@gnome.org>
Sat, 27 Oct 2001 19:38:07 +0000 (19:38 -0000)
committerMiguel de Icaza <miguel@gnome.org>
Sat, 27 Oct 2001 19:38:07 +0000 (19:38 -0000)
* DesignerSerializationVisibilityAttribute.cs: Implemented.

* DesignerSerializationVisibility.cs: New enumeration.

* LocalizableAttribute.cs: Implemented.

* BrowsableAttribute.cs: Implemented.

* DesignOnlyAttribute.cs: Implemented.

* DescriptionAttribute.cs: Implement.

* MemberDescriptor.cs: Implemented.

* CategoryAttribute.cs: implemented.

svn path=/trunk/mcs/; revision=1215

mcs/class/System/System.ComponentModel/BrowsableAttribute.cs [new file with mode: 0755]
mcs/class/System/System.ComponentModel/CategoryAttribute.cs [new file with mode: 0755]
mcs/class/System/System.ComponentModel/ChangeLog
mcs/class/System/System.ComponentModel/DescriptionAttribute.cs [new file with mode: 0755]
mcs/class/System/System.ComponentModel/DesignOnlyAttribute.cs [new file with mode: 0755]
mcs/class/System/System.ComponentModel/DesignerSerializationVisibility.cs [new file with mode: 0755]
mcs/class/System/System.ComponentModel/DesignerSerializationVisibilityAttribute.cs [new file with mode: 0755]
mcs/class/System/System.ComponentModel/LocalizableAttribute.cs [new file with mode: 0755]
mcs/class/System/System.ComponentModel/MemberDescriptor.cs [new file with mode: 0755]
mcs/class/System/System.ComponentModel/PropertyDescriptor.cs [new file with mode: 0755]
mcs/class/System/System.ComponentModel/TypeConverter.cs [new file with mode: 0755]

diff --git a/mcs/class/System/System.ComponentModel/BrowsableAttribute.cs b/mcs/class/System/System.ComponentModel/BrowsableAttribute.cs
new file mode 100755 (executable)
index 0000000..e56beb2
--- /dev/null
@@ -0,0 +1,38 @@
+//
+// System.ComponentModel.BrowsableAttribute.cs
+//
+// Author:
+//   Miguel de Icaza (miguel@ximian.com)
+//
+// (C) Ximian, Inc.  http://www.ximian.com
+//
+//
+
+namespace System.ComponentModel {
+
+       [AttributeUsage (AttributeTargets.Property | AttributeTargets.Event)]
+       public sealed class BrowsableAttribute : Attribute {
+               bool browsable;
+               
+               public static readonly BrowsableAttribute No;
+               public static readonly BrowsableAttribute Yes;
+
+               static BrowsableAttribute ()
+               {
+                       No = new BrowsableAttribute (false);
+                       Yes = new BrowsableAttribute (false);
+               }
+               
+               public BrowsableAttribute (bool browsable)
+               {
+                       this.browsable = browsable;
+               }
+
+               public bool Browsable {
+                       get {
+                               return browsable;
+                       }
+               }
+               
+       }
+}
diff --git a/mcs/class/System/System.ComponentModel/CategoryAttribute.cs b/mcs/class/System/System.ComponentModel/CategoryAttribute.cs
new file mode 100755 (executable)
index 0000000..c1d981f
--- /dev/null
@@ -0,0 +1,226 @@
+//
+// System.ComponentModel.CategoryAttribute.cs
+//
+// Author:
+//   Miguel de Icaza (miguel@ximian.com)
+//
+// (C) Ximian, Inc.  http://www.ximian.com
+//
+//
+
+namespace System.ComponentModel {
+
+       [AttributeUsage (AttributeTargets.Property | AttributeTargets.Event)]
+       public class CategoryAttribute : Attribute {
+               string category;
+
+               static CategoryAttribute action, appearance, behaviour, data,   def;
+               static CategoryAttribute design, drag_drop,  focus,     format, key;
+               static CategoryAttribute layout, mouse,      window_style;
+               
+               public CategoryAttribute (string category)
+               {
+                       this.category = category;
+               }
+
+               public CategoryAttribute ()
+               {
+                       this.category = "Misc";
+               }
+
+               protected virtual string GetLocalizedString (string value)
+               {
+                       // FIXME: IMPLEMENT
+
+                       return category;
+               }
+
+               public string Category {
+                       get {
+                               return category;
+                       }
+               }
+               
+               public static CategoryAttribute Action {
+                       get {
+                               if (action != null)
+                                       return action;
+
+                               lock (typeof (CategoryAttribute)){
+                                       if (action == null)
+                                               action = new CategoryAttribute ("Action");
+
+                                       return action;
+                               }
+                       }
+               }
+
+               public static CategoryAttribute Appearance {
+                       get {
+                               if (appearance != null)
+                                       return appearance;
+
+                               lock (typeof (CategoryAttribute)){
+                                       if (appearance == null)
+                                               appearance = new CategoryAttribute ("Appearance");
+
+                                       return appearance;
+                               }
+                       }
+               }
+
+               public static CategoryAttribute Behaviour {
+                       get {
+                               if (behaviour != null)
+                                       return behaviour;
+
+                               lock (typeof (CategoryAttribute)){
+                                       if (behaviour == null)
+                                               behaviour = new CategoryAttribute ("Action");
+
+                                       return behaviour;
+                               }
+                       }
+               }
+
+               public static CategoryAttribute Data {
+                       get {
+                               if (data != null)
+                                       return data;
+
+                               lock (typeof (CategoryAttribute)){
+                                       if (data == null)
+                                               data = new CategoryAttribute ("Data");
+
+                                       return data;
+                               }
+                       }
+               }
+
+               public static CategoryAttribute Default {
+                       get {
+                               if (def != null)
+                                       return def;
+
+                               lock (typeof (CategoryAttribute)){
+                                       if (def == null)
+                                               def = new CategoryAttribute ("Default");
+
+                                       return def;
+                               }
+                       }
+               }
+
+               public static CategoryAttribute Design {
+                       get {
+                               if (design != null)
+                                       return design;
+
+                               lock (typeof (CategoryAttribute)){
+                                       if (design == null)
+                                               design = new CategoryAttribute ("Design");
+
+                                       return design;
+                               }
+                       }
+               }
+
+               public static CategoryAttribute DragDrop {
+                       get {
+                               if (drag_drop != null)
+                                       return drag_drop;
+
+                               lock (typeof (CategoryAttribute)){
+                                       if (drag_drop == null)
+                                               drag_drop = new CategoryAttribute ("Drag Drop");
+
+                                       return drag_drop;
+                               }
+                       }
+               }
+
+               public static CategoryAttribute Focus {
+                       get {
+                               if (focus != null)
+                                       return focus;
+
+                               lock (typeof (CategoryAttribute)){
+                                       if (focus == null)
+                                               focus = new CategoryAttribute ("Focus");
+
+                                       return focus;
+                               }
+                       }
+               }
+
+               public static CategoryAttribute Format {
+                       get {
+                               if (format != null)
+                                       return format;
+
+                               lock (typeof (CategoryAttribute)){
+                                       if (format == null)
+                                               format = new CategoryAttribute ("Format");
+
+                                       return format;
+                               }
+                       }
+               }
+
+               public static CategoryAttribute Key {
+                       get {
+                               if (key != null)
+                                       return key;
+
+                               lock (typeof (CategoryAttribute)){
+                                       if (key == null)
+                                               key = new CategoryAttribute ("Key");
+
+                                       return key;
+                               }
+                       }
+               }
+
+               public static CategoryAttribute Layout {
+                       get {
+                               if (layout != null)
+                                       return layout;
+
+                               lock (typeof (CategoryAttribute)){
+                                       if (layout == null)
+                                               layout = new CategoryAttribute ("Layout");
+
+                                       return layout;
+                               }
+                       }
+               }
+
+               public static CategoryAttribute Mouse {
+                       get {
+                               if (mouse != null)
+                                       return mouse;
+
+                               lock (typeof (CategoryAttribute)){
+                                       if (mouse == null)
+                                               mouse = new CategoryAttribute ("Mouse");
+
+                                       return mouse;
+                               }
+                       }
+               }
+
+               public static CategoryAttribute WindowStyle {
+                       get {
+                               if (window_style != null)
+                                       return window_style;
+
+                               lock (typeof (CategoryAttribute)){
+                                       if (window_style == null)
+                                               window_style = new CategoryAttribute ("Window Style");
+
+                                       return window_style;
+                               }
+                       }
+               }
+       }
+}
index f7b907d7dbfaec0e6d2c0ee65d39511a835e2dce..32d82b52bbe9c0619036659817af78c2ef5a5c6d 100644 (file)
@@ -1,3 +1,21 @@
+2001-10-27  Miguel de Icaza  <miguel@ximian.com>
+
+       * DesignerSerializationVisibilityAttribute.cs: Implemented.
+
+       * DesignerSerializationVisibility.cs: New enumeration.
+
+       * LocalizableAttribute.cs: Implemented.
+
+       * BrowsableAttribute.cs: Implemented.
+
+       * DesignOnlyAttribute.cs: Implemented.
+
+       * DescriptionAttribute.cs: Implement.
+
+       * MemberDescriptor.cs: Implemented.
+
+       * CategoryAttribute.cs: implemented.
+
 2001-08-21  Nick Drochak <ndrochak@gol.com>
 
        * Component.cs: Eliminated compile errors by removing redundant fields and
diff --git a/mcs/class/System/System.ComponentModel/DescriptionAttribute.cs b/mcs/class/System/System.ComponentModel/DescriptionAttribute.cs
new file mode 100755 (executable)
index 0000000..03e6f41
--- /dev/null
@@ -0,0 +1,46 @@
+//
+// System.ComponentModel.DescriptionAttribute.cs
+//
+// Author:
+//   Miguel de Icaza (miguel@ximian.com)
+//
+// (C) Ximian, Inc.  http://www.ximian.com
+//
+//
+
+namespace System.ComponentModel {
+
+       [AttributeUsage (AttributeTargets.Property | AttributeTargets.Event)]
+       public class DescriptionAttribute : Attribute {
+               string desc;
+                       
+               public DescriptionAttribute (string name)
+               {
+                       desc = name;
+               }
+
+               public DescriptionAttribute ()
+               {
+                       desc = "";
+               }
+
+               public virtual string Description {
+                       get {
+                               return DescriptionValue;
+                       }
+               }
+
+               //
+               // Notice that the default Description implementation uses this by default
+               //
+               protected string DescriptionValue {
+                       get {
+                               return desc;
+                       }
+
+                       set {
+                               desc = value;
+                       }
+               }
+       }
+}
diff --git a/mcs/class/System/System.ComponentModel/DesignOnlyAttribute.cs b/mcs/class/System/System.ComponentModel/DesignOnlyAttribute.cs
new file mode 100755 (executable)
index 0000000..2cb9e77
--- /dev/null
@@ -0,0 +1,37 @@
+//
+// System.ComponentModel.DesignOnlyAttribute.cs
+//
+// Author:
+//   Miguel de Icaza (miguel@ximian.com)
+//
+// (C) Ximian, Inc.  http://www.ximian.com
+//
+//
+
+namespace System.ComponentModel {
+
+       [AttributeUsage (AttributeTargets.Property)]
+       public class DesignOnlyAttribute : Attribute {
+               bool design_only;
+               
+               public static readonly DesignOnlyAttribute No;
+               public static readonly DesignOnlyAttribute Yes;
+
+               static DesignOnlyAttribute ()
+               {
+                       No = new DesignOnlyAttribute (false);
+                       Yes = new DesignOnlyAttribute (false);
+               }
+               
+               public DesignOnlyAttribute (bool design_only)
+               {
+                       this.design_only = design_only;
+               }
+
+               public bool IsDesignOnly {
+                       get {
+                               return design_only;
+                       }
+               }
+       }
+}
diff --git a/mcs/class/System/System.ComponentModel/DesignerSerializationVisibility.cs b/mcs/class/System/System.ComponentModel/DesignerSerializationVisibility.cs
new file mode 100755 (executable)
index 0000000..d4291a8
--- /dev/null
@@ -0,0 +1,16 @@
+//
+// System.ComponentModel.DesignerSerializationVisibility.cs
+//
+// Author:
+//   Miguel de Icaza (miguel@ximian.com)
+//
+// (C) Ximian, Inc.  http://www.ximian.com
+//
+//
+
+namespace System.ComponentModel {
+
+       public enum DesignerSerializationVisibility {
+               Hidden, Visible, Content
+       }
+}
diff --git a/mcs/class/System/System.ComponentModel/DesignerSerializationVisibilityAttribute.cs b/mcs/class/System/System.ComponentModel/DesignerSerializationVisibilityAttribute.cs
new file mode 100755 (executable)
index 0000000..4063238
--- /dev/null
@@ -0,0 +1,42 @@
+//
+// System.ComponentModel.DesignerSerializationVisibilityAttribute.cs
+//
+// Author:
+//   Miguel de Icaza (miguel@ximian.com)
+//
+// (C) Ximian, Inc.  http://www.ximian.com
+//
+//
+
+namespace System.ComponentModel {
+
+       [AttributeUsage (AttributeTargets.Property)]
+       public sealed class DesignerSerializationVisibilityAttribute : Attribute {
+               DesignerSerializationVisibility visibility;
+
+               static DesignerSerializationVisibilityAttribute ()
+               {
+                       Content = new DesignerSerializationVisibilityAttribute (
+                               DesignerSerializationVisibility.Content);
+                       Hidden = new DesignerSerializationVisibilityAttribute (
+                               DesignerSerializationVisibility.Hidden);
+                       Visible = new DesignerSerializationVisibilityAttribute (
+                               DesignerSerializationVisibility.Visible);
+               }
+               
+               DesignerSerializationVisibilityAttribute (DesignerSerializationVisibility vis)
+               {
+                       visibility = vis;
+               }
+
+               public static readonly DesignerSerializationVisibilityAttribute Content;
+               public static readonly DesignerSerializationVisibilityAttribute Hidden;
+               public static readonly DesignerSerializationVisibilityAttribute Visible;
+
+               public DesignerSerializationVisibility Visibility {
+                       get {
+                               return visibility;
+                       }
+               }
+       }
+}
diff --git a/mcs/class/System/System.ComponentModel/LocalizableAttribute.cs b/mcs/class/System/System.ComponentModel/LocalizableAttribute.cs
new file mode 100755 (executable)
index 0000000..b5425ef
--- /dev/null
@@ -0,0 +1,40 @@
+//
+// System.ComponentModel.LocalizableAttribute.cs
+//
+// Author:
+//   Miguel de Icaza (miguel@ximian.com)
+//
+// (C) Ximian, Inc.  http://www.ximian.com
+//
+//
+
+using System;
+
+namespace System.ComponentModel {
+
+       [AttributeUsage (AttributeTargets.Property)]
+       public sealed class LocalizableAttribute : Attribute {
+               bool localizable;
+               
+               public static readonly LocalizableAttribute No;
+               public static readonly LocalizableAttribute Yes;
+
+               static LocalizableAttribute ()
+               {
+                       No = new LocalizableAttribute (false);
+                       Yes = new LocalizableAttribute (false);
+               }
+               
+               public LocalizableAttribute (bool localizable)
+               {
+                       this.localizable = localizable;
+               }
+
+               public bool IsLocalizable {
+                       get {
+                               return localizable;
+                       }
+               }
+               
+       }
+}
diff --git a/mcs/class/System/System.ComponentModel/MemberDescriptor.cs b/mcs/class/System/System.ComponentModel/MemberDescriptor.cs
new file mode 100755 (executable)
index 0000000..a689a81
--- /dev/null
@@ -0,0 +1,119 @@
+//
+// System.ComponentModel.MemberDescriptor.cs
+//
+// Author:
+//   Miguel de Icaza (miguel@ximian.com)
+//
+// (C) Ximian, Inc.  http://www.ximian.com
+//
+
+namespace System.ComponentModel {
+
+       public class MemberDescriptor {
+               string name;
+               Attribute [] attrs;
+               
+               protected MemberDescriptor (string name, Attribute [] attrs)
+               {
+                       this.name = name;
+                       this.attrs = attrs;
+               }
+
+               protected MemberDescriptor (MemberDescriptor reference, Attribute [] attrs)
+               {
+                       name = reference.name;
+                       this.attrs = attrs;
+               }
+
+               protected MemberDescriptor (string name)
+               {
+                       this.name = name;
+               }
+
+               protected MemberDescriptor (MemberDescriptor reference)
+               {
+                       name = reference.name;
+                       attrs = reference.attrs;
+               }
+
+               protected virtual Attribute [] AttributeArray {
+                       get {
+                               return attrs;
+                       }
+
+                       set {
+                               attrs = value;
+                       }
+               }
+
+               // FIXME: Implement Attributes property
+
+               public virtual string Category {
+                       get {
+                               foreach (Attribute attr in attrs){
+
+
+
+                                       if (attr is CategoryAttribute){
+                                               return ((CategoryAttribute) attr).Category;
+                                       }
+                               }
+                               return "Misc";
+                       }
+               }
+
+               public virtual string Description {
+                       get {
+                               foreach (Attribute attr in attrs){
+                                       if (attr is DescriptionAttribute)
+                                               return ((DescriptionAttribute) attr).Description;
+                               }
+
+                               return "";
+                       }
+               }
+
+               public virtual bool DesignTimeOnly {
+                       get {
+                               foreach (Attribute attr in attrs){
+                                       if (attr is DesignOnlyAttribute)
+                                               return ((DesignOnlyAttribute) attr).IsDesignOnly;
+                               }
+
+                               return false;
+                       }
+               }
+
+               //
+               // FIXME: Is there any difference between DisplayName and Name?
+               //
+               public virtual string DisplayName {
+                       get {
+                               return name;
+                       }
+               }
+
+               public virtual string Name {
+                       get {
+                               return name;
+                       }
+               }
+
+               public virtual bool IsBrowsable {
+                       get {
+                               foreach (Attribute attr in attrs){
+                                       if (attr is BrowsableAttribute)
+                                               return ((BrowsableAttribute) attr).Browsable;
+                               }
+
+                               return false;
+                       }
+               }
+
+               protected virtual int NameHashCode {
+                       get {
+                               return name.GetHashCode ();
+                       }
+               }
+       }
+}
diff --git a/mcs/class/System/System.ComponentModel/PropertyDescriptor.cs b/mcs/class/System/System.ComponentModel/PropertyDescriptor.cs
new file mode 100755 (executable)
index 0000000..0ea740d
--- /dev/null
@@ -0,0 +1,113 @@
+//
+// System.ComponentModel.PropertyDescriptor.cs
+//
+// Author:
+//   Miguel de Icaza (miguel@ximian.com)
+//
+// (C) Ximian, Inc.  http://www.ximian.com
+//
+
+using System;
+using System.Collections;
+
+namespace System.ComponentModel {
+
+       public abstract class PropertyDescriptor : MemberDescriptor {
+
+               public PropertyDescriptor (MemberDescriptor reference)
+                       : base (reference)
+               {
+               }
+
+               public PropertyDescriptor (MemberDescriptor reference, Attribute [] attrs)
+                       : base (reference, attrs)
+               {
+               }
+
+               public PropertyDescriptor (string name, Attribute [] attrs)
+                       : base (name, attrs)
+               {
+               }
+
+               public abstract Type ComponentType { get; }
+
+               public virtual TypeConverter Converter {
+                       get {
+                               // FIXME: Implement me.
+                               
+                               return null;
+                       }
+               }
+
+               public virtual bool IsLocalizable {
+                       get {
+                               foreach (Attribute attr in AttributeArray){
+                                       if (attr is LocalizableAttribute){
+                                               return ((LocalizableAttribute) attr).IsLocalizable;
+                                       }
+                               }
+
+                               return false;
+                       }
+               }
+
+               public abstract bool IsReadOnly { get; }
+
+               public abstract Type PropertyType { get; }
+
+               public DesignerSerializationVisibility SerializationVisibility {
+                       get {
+                               foreach (Attribute attr in AttributeArray){
+                                       if (attr is DesignerSerializationVisibilityAttribute){
+                                               DesignerSerializationVisibilityAttribute a;
+
+                                               a = (DesignerSerializationVisibilityAttribute) attr;
+
+                                               return a.Visibility;
+                                       }
+                               }
+
+                               //
+                               // Is this a good default if we cant find the property?
+                               //
+                               return DesignerSerializationVisibility.Hidden;
+                       }
+               }
+
+               Hashtable notifiers;
+
+               public virtual void AddValueChanged (object component, EventHandler handler)
+               {
+                       EventHandler component_notifiers;
+                       
+                       if (component == null)
+                               throw new ArgumentNullException ("component");
+
+                       if (handler == null)
+                               throw new ArgumentNullException ("handler");
+
+                       if (notifiers == null)
+                               notifiers = new Hashtable ();
+
+                       component_notifiers = (EventHandler) notifiers [component];
+
+                       if (component_notifiers != null)
+                               component_notifiers += handler;
+                       else
+                               notifiers [component] = handler;
+               }
+               
+               protected virtual void OnValueChanged (object component, EventArgs e)
+               {
+                       if (notifiers == null)
+                               return;
+
+                       EventHandler component_notifiers = (EventHandler) notifiers [component];
+
+                       if (component_notifiers == null)
+                               return;
+
+                       component_notifiers (component, e);
+               }
+       }
+}
diff --git a/mcs/class/System/System.ComponentModel/TypeConverter.cs b/mcs/class/System/System.ComponentModel/TypeConverter.cs
new file mode 100755 (executable)
index 0000000..caeb21a
--- /dev/null
@@ -0,0 +1,8 @@
+//
+// Nothing implemented yet
+//
+namespace System.ComponentModel {
+       
+       public class TypeConverter {
+       }
+}