1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
5 * Copyright 2009 Novell, Inc. (http://www.novell.com)
7 * See the LICENSE file included with the distribution for details.
16 SetObjectType (Type::POPUP
);
17 shutting_down
= false;
19 GetDeployment ()->AddHandler (Deployment::ShuttingDownEvent
, ShuttingDownCallback
, this);
25 if (!shutting_down
&& GetIsOpen ())
27 GetDeployment ()->RemoveHandler (Deployment::ShuttingDownEvent
, ShuttingDownCallback
, this);
28 FrameworkElement::Dispose ();
32 Popup::HitTest (cairo_t
*cr
, Point p
, List
*uielement_list
)
35 FrameworkElement::HitTest (cr
, p
, uielement_list
);
39 Popup::OnPropertyChanged (PropertyChangedEventArgs
*args
, MoonError
*error
)
41 if (args
->GetProperty ()->GetOwnerType() != Type::POPUP
) {
42 FrameworkElement::OnPropertyChanged (args
, error
);
46 if (args
->GetId () == Popup::IsOpenProperty
) {
47 // we intentionally don't track whether we've added a tick
48 // call (to make sure we only add it once) for this event
49 // because multiple IsOpen changes cause multiple async events
51 if (args
->GetNewValue () && args
->GetNewValue ()->AsBool ()) {
54 EmitAsync (Popup::OpenedEvent
);
59 EmitAsync (Popup::ClosedEvent
);
61 } else if (args
->GetId () == Popup::ChildProperty
) {
62 if (args
->GetOldValue () && !args
->GetOldValue ()->GetIsNull ()) {
63 FrameworkElement
*el
= args
->GetOldValue ()->AsFrameworkElement ();
67 el
->SetLogicalParent (NULL
, error
);
71 if (args
->GetNewValue () && !args
->GetNewValue ()->GetIsNull ()) {
72 FrameworkElement
*el
= args
->GetNewValue ()->AsFrameworkElement ();
73 args
->GetNewValue ()->AsFrameworkElement ()->SetLogicalParent (this, error
);
80 } else if (args
->GetId () == Popup::HorizontalOffsetProperty
81 || args
->GetId () == Popup::VerticalOffsetProperty
) {
82 UIElement
* child
= GetChild ();
84 child
->UpdateTransform ();
86 NotifyListenersOfPropertyChange (args
, error
);
90 Popup::ShuttingDownHandler (Deployment
*sender
, EventArgs
*args
)
96 Popup::Hide (UIElement
*child
)
98 if (!visible
|| !child
)
102 Deployment::GetCurrent ()->GetSurface ()->DetachLayer (child
);
106 Popup::SetSurface (Surface
*s
)
108 FrameworkElement::SetSurface (s
);
112 Popup::Show (UIElement
*child
)
114 if (visible
|| !child
)
118 Deployment::GetCurrent ()->GetSurface ()->AttachLayer (child
);