-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontentcontrol.cpp
More file actions
100 lines (82 loc) · 2.39 KB
/
contentcontrol.cpp
File metadata and controls
100 lines (82 loc) · 2.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* contentcontrol.cpp:
*
* Contact:
* Moonlight List (moonlight-list@lists.ximian.com)
*
* Copyright 2007-2009 Novell, Inc. (http://www.novell.com)
*
* See the LICENSE file included with the distribution for details.
*
*/
#include <config.h>
#include "application.h"
#include "contentcontrol.h"
#include "managedtypeinfo.h"
namespace Moonlight {
ContentControl::ContentControl ()
{
SetContentSetsParent (true);
SetObjectType (Type::CONTENTCONTROL);
ManagedTypeInfo type_info (GetObjectType ());
SetDefaultStyleKey (&type_info);
}
ContentControl::~ContentControl ()
{
}
UIElement *
ContentControl::GetDefaultTemplate ()
{
Value *content = GetValue (ContentControl::ContentProperty);
if (!content || content->GetIsNull ())
return NULL;
if (content->Is (GetDeployment (), Type::UIELEMENT))
return content->AsUIElement ();
return Control::GetDefaultTemplate ();
}
void
ContentControl::OnPropertyChanged (PropertyChangedEventArgs *args, MoonError *error)
{
if (args->GetProperty ()->GetOwnerType () != Type::CONTENTCONTROL) {
Control::OnPropertyChanged (args, error);
return;
}
if (args->GetId () == ContentControl::ContentProperty) {
if (args->GetOldValue() && args->GetOldValue()->Is(GetDeployment (), Type::FRAMEWORKELEMENT)) {
if (GetContentSetsParent ()) {
args->GetOldValue()->AsFrameworkElement()->SetLogicalParent (NULL, error);
if (error->number)
return;
}
}
if (args->GetNewValue() && args->GetNewValue()->Is(GetDeployment (), Type::FRAMEWORKELEMENT)) {
if (GetContentSetsParent ()) {
args->GetNewValue()->AsFrameworkElement()->SetLogicalParent (this, error);
if (error->number)
return;
}
}
if (HasHandlers (ContentControl::ContentControlChangedEvent))
Emit (ContentControl::ContentControlChangedEvent, new ContentControlChangedEventArgs (args->GetOldValue(), args->GetNewValue()));
InvalidateMeasure ();
}
NotifyListenersOfPropertyChange (args, error);
}
ContentControlChangedEventArgs::ContentControlChangedEventArgs (Value *old_content, Value *new_content)
{
SetObjectType (Type::CONTENTCONTROLCHANGEDEVENTARGS);
this->old_content = old_content;
this->new_content = new_content;
}
Value *
ContentControlChangedEventArgs::GetOldContent ()
{
return old_content;
}
Value*
ContentControlChangedEventArgs::GetNewContent ()
{
return new_content;
}
};