Author: rolf
Date: 2007-06-04 18:33:53 -0400 (Mon, 04 Jun 2007)
New Revision: 78599

Modified:
   trunk/moon/src/ChangeLog
   trunk/moon/src/runtime.cpp
   trunk/moon/src/runtime.h
Log:
2007-06-05  Rolf Bjarne Kvinge  <[EMAIL PROTECTED]>

        * runtime.cpp, runtime.h: implemented DependencyProperty and 
DependencyObject.



Modified: trunk/moon/src/ChangeLog
===================================================================
--- trunk/moon/src/ChangeLog    2007-06-04 21:17:42 UTC (rev 78598)
+++ trunk/moon/src/ChangeLog    2007-06-04 22:33:53 UTC (rev 78599)
@@ -1,3 +1,7 @@
+2007-06-05  Rolf Bjarne Kvinge  <[EMAIL PROTECTED]>
+
+       * runtime.cpp, runtime.h: implemented DependencyProperty and 
DependencyObject.
+
 2007-06-04  Chris Toshok  <[EMAIL PROTECTED]>
 
        * animation.h, animation.cpp: initial pass at some of the

Modified: trunk/moon/src/runtime.cpp
===================================================================
--- trunk/moon/src/runtime.cpp  2007-06-04 21:17:42 UTC (rev 78598)
+++ trunk/moon/src/runtime.cpp  2007-06-04 22:33:53 UTC (rev 78599)
@@ -447,7 +447,90 @@
        return s->drawing_area;
 }
 
+/*
+       DependencyObject
+*/
 
+GHashTable *DependencyObject::default_values = NULL;
+
+void
+DependencyObject::SetValue (DependencyProperty *Property, void *Value)
+{
+       g_hash_table_insert (current_values, Property->Name, Value);
+}
+
+void *
+DependencyObject::GetValue (DependencyProperty *Property)
+{
+       void *value = NULL;
+       GHashTable * table = NULL;
+
+       value = g_hash_table_lookup (current_values, Property->Name);
+
+       if (NULL != value)
+               return value;
+
+       if (NULL == default_values)
+               return NULL;
+
+       table = (GHashTable*) g_hash_table_lookup (default_values, 
&Property->Type);
+       
+       if (NULL == table)
+               return NULL;
+
+       value = g_hash_table_lookup (table, Property->Name);
+
+       return value;
+}
+
+DependencyObject::DependencyObject ()
+{
+       current_values = g_hash_table_new (g_str_hash, g_str_equal);
+}
+
+DependencyObject::~DependencyObject ()
+{
+       g_hash_table_destroy (current_values);
+}
+
+DependencyProperty *
+DependencyObject::Register (int type, char *name, void *default_value)
+{
+       if (NULL == default_values)
+               default_values = g_hash_table_new (g_int_hash, g_int_equal);
+
+       DependencyProperty *property = new DependencyProperty (name, 
default_value);
+       property->Type = type;
+       
+       GHashTable *table;
+
+       table = (GHashTable*) g_hash_table_lookup (default_values, 
&property->Type);
+
+       if (NULL == table) {
+               table = g_hash_table_new (g_str_hash, g_str_equal);
+               g_hash_table_insert (default_values, &property->Type, table);
+       }
+
+       g_hash_table_insert (table, property->Name, property->DefaultValue);
+
+       return property;
+}
+
+/*
+       DependencyProperty
+*/
+DependencyProperty::DependencyProperty (char *name, void *default_value)
+{
+       this->Name = g_strdup (name);
+       this->DefaultValue = default_value;
+}
+
+DependencyProperty::~DependencyProperty ()
+{
+       g_free (Name);
+}
+
+
 // event handlers for c++
 typedef struct {
   EventHandler func;

Modified: trunk/moon/src/runtime.h
===================================================================
--- trunk/moon/src/runtime.h    2007-06-04 21:17:42 UTC (rev 78598)
+++ trunk/moon/src/runtime.h    2007-06-04 22:33:53 UTC (rev 78599)
@@ -23,6 +23,8 @@
 
 class Surface;
 class Brush;
+class DependencyObject;
+class DependencyProperty;
        
 typedef void (*BrushChangedNotify)(Brush *brush, void *data);
 
@@ -92,6 +94,36 @@
 void collection_remove (Collection *collection, void *data);
 
 //
+// DependencyObject
+// 
+
+class DependencyObject {
+ public:
+       DependencyObject ();
+       ~DependencyObject ();
+       static DependencyProperty* Register (int type, char *name, void 
*default_value);
+       void SetValue (DependencyProperty *property, void *value);
+       void* GetValue (DependencyProperty *property);
+
+ private:
+       static GHashTable *default_values;
+       GHashTable *current_values;
+};
+
+//
+// DependencyProperty
+//
+class DependencyProperty {
+ public:
+       DependencyProperty () {} ;
+       ~DependencyProperty ();
+       DependencyProperty (char *name, void *default_value);
+       char *Name;
+       void *DefaultValue;
+       int Type;
+};
+
+//
 // This guy provide reference counting
 //
 #define BASE_FLOATS 0x80000000

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to