Author: jackson
Date: 2007-06-20 14:53:45 -0400 (Wed, 20 Jun 2007)
New Revision: 80347

Modified:
   trunk/moon/src/ChangeLog
   trunk/moon/src/control.cpp
   trunk/moon/src/demo.cpp
   trunk/moon/src/runtime.h
   trunk/moon/src/xaml.cpp
Log:

        * xaml.cpp/runtime.h: Add one more callback, this one will
        * hookup
        events to methods. So things like Loaded=CanvasLoaded will work.
        * demo.cpp:
        * control.cpp:



Modified: trunk/moon/src/ChangeLog
===================================================================
--- trunk/moon/src/ChangeLog    2007-06-20 18:53:22 UTC (rev 80346)
+++ trunk/moon/src/ChangeLog    2007-06-20 18:53:45 UTC (rev 80347)
@@ -1,5 +1,12 @@
 2007-06-20  Jackson Harper  <[EMAIL PROTECTED]>
 
+       * xaml.cpp/runtime.h: Add one more callback, this one will hookup
+       events to methods. So things like Loaded=CanvasLoaded will work.
+       * demo.cpp:
+       * control.cpp:
+       
+2007-06-20  Jackson Harper  <[EMAIL PROTECTED]>
+
        * xaml.cpp: More verbose debug output with namespace lookup
        errors.
        - Map in the default namespaces if we are unable to lookup the

Modified: trunk/moon/src/control.cpp
===================================================================
--- trunk/moon/src/control.cpp  2007-06-20 18:53:22 UTC (rev 80346)
+++ trunk/moon/src/control.cpp  2007-06-20 18:53:45 UTC (rev 80347)
@@ -141,7 +141,7 @@
 {
        // No callback, figure out how this will work in the plugin to satisfy 
deps
 
-       UIElement *element = xaml_create_from_str (xaml, false, NULL, NULL, 
element_type);
+       UIElement *element = xaml_create_from_str (xaml, false, NULL, NULL, 
NULL, element_type);
        if (element == NULL)
                return NULL;
 

Modified: trunk/moon/src/demo.cpp
===================================================================
--- trunk/moon/src/demo.cpp     2007-06-20 18:53:22 UTC (rev 80346)
+++ trunk/moon/src/demo.cpp     2007-06-20 18:53:45 UTC (rev 80347)
@@ -82,7 +82,7 @@
        printf ("button_press_event\n");
 
        printf ("Loading...\n");
-       UIElement *ee = xaml_create_from_file 
("../test/xaml/test-shape-ellipse.xaml", true, NULL, NULL, &kind);
+       UIElement *ee = xaml_create_from_file 
("../test/xaml/test-shape-ellipse.xaml", true, NULL, NULL, NULL, &kind);
        printf ("Loading... %p\n", ee);
        if (ee != NULL)
                surface_attach (t, ee);
@@ -192,7 +192,7 @@
 
                gtk_window_set_title (GTK_WINDOW (w), file);
                
-               UIElement *e = xaml_create_from_file (file, true, NULL, NULL, 
&kind);
+               UIElement *e = xaml_create_from_file (file, true, NULL, NULL, 
NULL, &kind);
                if (e == NULL){
                        printf ("Was not able to load the file\n");
                        return 1;
@@ -291,7 +291,7 @@
                panel_child_add (canvas, tb);
                
 #ifdef XAML_DEMO
-               panel_child_add (canvas, xaml_create_from_str ("<Line 
Stroke='Blue' X1='10' Y1='10' X2='10' Y2='300' />", false, NULL, NULL, NULL));
+               panel_child_add (canvas, xaml_create_from_str ("<Line 
Stroke='Blue' X1='10' Y1='10' X2='10' Y2='300' />", false, NULL, NULL, NULL, 
NULL));
 #endif
                
 #ifdef VIDEO_DEMO

Modified: trunk/moon/src/runtime.h
===================================================================
--- trunk/moon/src/runtime.h    2007-06-20 18:53:22 UTC (rev 80346)
+++ trunk/moon/src/runtime.h    2007-06-20 18:53:45 UTC (rev 80347)
@@ -985,11 +985,12 @@
 
 typedef DependencyObject *xaml_create_custom_element_callback (const char 
*xmlns, const char *name);
 typedef void xaml_set_custom_attribute_callback (void *target, const char 
*name, const char *value);
+typedef void xaml_hookup_event_callback (void *target, const char *ename, 
const char *evalue);
 
 UIElement  *xaml_create_from_file (const char *xaml, bool create_namescope, 
xaml_create_custom_element_callback *cecb,
-               xaml_set_custom_attribute_callback *sca, Type::Kind 
*element_type);
+               xaml_set_custom_attribute_callback *sca, 
xaml_hookup_event_callback *hue, Type::Kind *element_type);
 UIElement  *xaml_create_from_str  (const char *xaml, bool create_namescope, 
xaml_create_custom_element_callback *cecb,
-               xaml_set_custom_attribute_callback *sca, Type::Kind 
*element_type);
+               xaml_set_custom_attribute_callback *sca, 
xaml_hookup_event_callback *hue, Type::Kind *element_type);
 void       xaml_set_property_from_str (DependencyObject *obj, const char 
*prop, const char *value);
 
 

Modified: trunk/moon/src/xaml.cpp
===================================================================
--- trunk/moon/src/xaml.cpp     2007-06-20 18:53:22 UTC (rev 80346)
+++ trunk/moon/src/xaml.cpp     2007-06-20 18:53:45 UTC (rev 80347)
@@ -27,8 +27,8 @@
 
 #define READ_BUFFER 1024
 
-GHashTable *namespace_map = NULL;
-GHashTable *enum_map = NULL;
+static GHashTable *namespace_map = NULL;
+static GHashTable *enum_map = NULL;
 
 class XamlElementInfo;
 class XamlElementInstance;
@@ -38,8 +38,8 @@
 class XNamespace;
 
 
-DefaultNamespace *default_namespace = NULL;
-XNamespace *x_namespace = NULL;
+static DefaultNamespace *default_namespace = NULL;
+static XNamespace *x_namespace = NULL;
 
 
 typedef DependencyObject *(*create_item_func) (void);
@@ -79,12 +79,13 @@
 
        xaml_create_custom_element_callback *custom_element_callback;
        xaml_set_custom_attribute_callback *custom_attribute_callback;
+       xaml_hookup_event_callback *hookup_event_callback; 
 
        XamlParserInfo (XML_Parser parser, const char *file_name) :
                parser (parser), file_name (file_name), top_element (NULL), 
current_element (NULL),
                current_namespace (NULL), char_data_buffer (NULL), 
implicit_default_namespace (false),
                error_args (NULL), namescope (new NameScope()),
-               custom_element_callback (NULL), custom_attribute_callback (NULL)
+               custom_element_callback (NULL), custom_attribute_callback 
(NULL), hookup_event_callback (NULL)
        {
                namespace_map = g_hash_table_new (g_str_hash, g_str_equal);
        }
@@ -279,6 +280,7 @@
 
        virtual void SetAttribute (XamlParserInfo *p, XamlElementInstance 
*item, const char *attr, const char *value)
        {
+               printf ("Setting custom attribute:  %p\n", item->item);
                p->custom_attribute_callback (item->item, attr, value);
        }
 };
@@ -567,6 +569,7 @@
 xaml_create_from_file (const char *xaml_file, bool create_namescope,
                xaml_create_custom_element_callback *cecb,
                xaml_set_custom_attribute_callback *sca,
+               xaml_hookup_event_callback *hue,
                Type::Kind *element_type)
 {
        UIElement *res;
@@ -603,6 +606,7 @@
        parser_info = new XamlParserInfo (p, xaml_file);
        parser_info->custom_element_callback = cecb;
        parser_info->custom_attribute_callback = sca;
+       parser_info->hookup_event_callback = hue;
 
        // TODO: This is just in here temporarily, to make life less difficult 
for everyone
        // while we are developing.  
@@ -664,6 +668,7 @@
 xaml_create_from_str (const char *xaml, bool create_namescope,
                xaml_create_custom_element_callback *cecb,
                xaml_set_custom_attribute_callback *sca,
+               xaml_hookup_event_callback *hue,
                Type::Kind *element_type)
 {
        XML_Parser p = XML_ParserCreateNS (NULL, '|');
@@ -681,6 +686,7 @@
 
        parser_info->custom_element_callback = cecb;
        parser_info->custom_attribute_callback = sca;
+       parser_info->hookup_event_callback = hue;
 
        // from_str gets the default namespaces implictly added
        add_default_namespaces (parser_info);
@@ -1669,7 +1675,7 @@
 void
 dependency_object_missed_property (XamlElementInstance *item, 
XamlElementInstance *prop, XamlElementInstance *value, char **prop_name)
 {
-                       
+
 }
 
 void
@@ -1825,6 +1831,24 @@
        }
 }
 
+bool
+dependency_object_hookup_event (XamlParserInfo *p, XamlElementInstance *item, 
const char *name, const char *value)
+{
+       if (!strcmp (name, "Loaded")) {
+               if (!p->hookup_event_callback) {
+                       // void parser_error (XamlParserInfo *p, const char 
*el, const char *attr, const char *message);
+                       parser_error (p, item->element_name, name,
+                                       g_strdup_printf ("No hookup event 
callback handler installed '%s' event will not be hooked up\n"));
+                       return true;
+               }
+
+               p->hookup_event_callback (item->item, name, value);
+       }
+
+       return false;
+}
+
+
 // TODO: Merge more of this code with the above function
 void
 dependency_object_set_attributes (XamlParserInfo *p, XamlElementInstance 
*item, const char **attr)
@@ -1974,8 +1998,10 @@
                        }
 
                } else {
+                       bool event = dependency_object_hookup_event (p, item, 
pname, attr [i + 1]);
 #ifdef DEBUG_XAML
-                       printf ("can not find property:  %s  %s\n", pname, attr 
[i + 1]);
+                       if (!event)
+                               printf ("can not find property:  %s  %s\n", 
pname, attr [i + 1]);
 #endif
                }
 

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

Reply via email to