Author: jackson
Date: 2007-06-14 23:19:55 -0400 (Thu, 14 Jun 2007)
New Revision: 79667
Modified:
trunk/moon/src/ChangeLog
trunk/moon/src/xaml.cpp
Log:
* xaml.cpp: Set content properties when adding child
* elements. We
now no longer need to special case any elements except panel.
Modified: trunk/moon/src/ChangeLog
===================================================================
--- trunk/moon/src/ChangeLog 2007-06-15 03:02:05 UTC (rev 79666)
+++ trunk/moon/src/ChangeLog 2007-06-15 03:19:55 UTC (rev 79667)
@@ -1,5 +1,10 @@
2007-06-14 Jackson Harper <[EMAIL PROTECTED]>
+ * xaml.cpp: Set content properties when adding child elements. We
+ now no longer need to special case any elements except panel.
+
+2007-06-14 Jackson Harper <[EMAIL PROTECTED]>
+
* xaml.cpp: I must have been very tired when I wrote that.
2007-06-14 Sebastien Pouliot <[EMAIL PROTECTED]>
Modified: trunk/moon/src/xaml.cpp
===================================================================
--- trunk/moon/src/xaml.cpp 2007-06-15 03:02:05 UTC (rev 79666)
+++ trunk/moon/src/xaml.cpp 2007-06-15 03:19:55 UTC (rev 79667)
@@ -917,18 +917,28 @@
DependencyProperty *dep =
DependencyObject::GetDependencyProperty (parent->info->dependency_type,
(char *) parent->info->content_property);
+ if (!dep)
+ return;
+
+ Type *prop_type = Type::Find (dep->value_type);
+ bool is_collection = prop_type->IsSubclassOf
(Value::COLLECTION);
+
+ if (!is_collection && prop_type->IsSubclassOf
(child->info->dependency_type)) {
+ DependencyObject *obj = (DependencyObject *)
parent->item;
+ obj->SetValue (dep, (DependencyObject *) child->item);
+ return;
+
+ }
+
// We only want to enter this if statement if we are NOT
dealing with the content property element,
// otherwise, attempting to use explicit property setting,
would add the content property element
// to the content property element collection
- if (dep && dep->value_type != child->info->dependency_type) {
- Type *col_type = Type::Find (dep->value_type);
- if (col_type->IsSubclassOf (Value::COLLECTION)) {
- DependencyObject *obj = (DependencyObject *)
parent->item;
- Value *col_v = obj->GetValue (dep);
- Collection *col = (Collection *)
col_v->AsCollection ();
- col->Add ((DependencyObject *) child->item);
- return;
- }
+ if (is_collection && dep->value_type !=
child->info->dependency_type) {
+ DependencyObject *obj = (DependencyObject *)
parent->item;
+ Value *col_v = obj->GetValue (dep);
+ Collection *col = (Collection *) col_v->AsCollection ();
+ col->Add ((DependencyObject *) child->item);
+ return;
}
}
@@ -944,36 +954,6 @@
dependency_object_add_child (p, parent, child);
}
-void
-begin_storyboard_add_child (XamlParserInfo *p, XamlElementInstance *parent,
XamlElementInstance *child)
-{
- if (!is_instance_of (child, Value::STORYBOARD)) {
- g_warning ("error, attempting to add non storyboard type (%d)
to BeginStoryboard element\n",
- child->info->dependency_type);
- return;
- }
-
- BeginStoryboard *bsb = (BeginStoryboard *) parent->item;
- Storyboard *sb = (Storyboard *) child->item;
-
- bsb->SetStoryboard (sb);
-}
-
-void
-storyboard_add_child (XamlParserInfo *p, XamlElementInstance *parent,
XamlElementInstance *child)
-{
- if (!is_instance_of (child, Value::TIMELINE)) {
- g_warning ("error, attempting to add non timeline type (%d) to
Storyboard element\n",
- child->info->dependency_type);
- return;
- }
-
- Storyboard *sb = (Storyboard *) parent->item;
- Timeline *t = (Timeline *) child->item;
-
- sb->AddChild (t);
-}
-
///
/// set property funcs
///
@@ -1308,7 +1288,7 @@
XamlElementInfo *prltl = register_ghost_element ("ParallelTimeline",
tlg, Value::PARALLELTIMELINE);
XamlElementInfo *sb = rdoe (dem, "Storyboard", prltl,
Value::STORYBOARD, (create_item_func) storyboard_new);
- sb->add_child = storyboard_add_child;
+ sb->content_property = "Children";
///
/// Triggers
@@ -1316,7 +1296,7 @@
XamlElementInfo *trg = register_ghost_element ("Trigger", NULL,
Value::TRIGGERACTION);
XamlElementInfo *bsb = rdoe (dem, "BeginStoryboard", trg,
Value::BEGINSTORYBOARD,
(create_item_func) begin_storyboard_new);
- bsb->add_child = begin_storyboard_add_child;
+ bsb->content_property = "Storyboard";
XamlElementInfo *evt = rdoe (dem, "EventTrigger", NULL,
Value::EVENTTRIGGER, (create_item_func) event_trigger_new);
evt->content_property = "Actions";
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches