1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
5 * Copyright 2007 Novell, Inc. (http://www.novell.com)
7 * See the LICENSE file included with the distribution for details.
11 #ifndef __MOON_FRAMEWORKELEMENT_H__
12 #define __MOON_FRAMEWORKELEMENT_H__
17 #include "uielement.h"
19 /* @CBindingRequisite */
20 typedef Size (*MeasureOverrideCallback
)(Size availableSize
);
21 /* @CBindingRequisite */
22 typedef Size (*ArrangeOverrideCallback
)(Size finalSize
);
24 /* @Namespace=System.Windows */
26 class FrameworkElement
: public UIElement
{
28 /* @PropertyType=double,DefaultValue=NAN,GenerateAccessors */
29 const static int HeightProperty
;
30 /* @PropertyType=double,DefaultValue=NAN,GenerateAccessors */
31 const static int WidthProperty
;
33 /* @PropertyType=double,DefaultValue=0.0,Version=2,ManagedSetterAccess=Internal,GenerateAccessors,ReadOnly */
34 const static int ActualHeightProperty
;
35 /* @PropertyType=double,DefaultValue=0.0,Version=2,ManagedSetterAccess=Internal,GenerateAccessors,ReadOnly */
36 const static int ActualWidthProperty
;
37 /* @PropertyType=object,Version=2.0 */
38 const static int DataContextProperty
;
39 /* @PropertyType=HorizontalAlignment,DefaultValue=HorizontalAlignmentStretch,Version=2.0,GenerateAccessors */
40 const static int HorizontalAlignmentProperty
;
41 /* @PropertyType=string,DefaultValue=\"en-US\",Version=2.0,ManagedPropertyType=XmlLanguage,Validator=NonNullValidator,GenerateAccessors */
42 const static int LanguageProperty
;
43 /* @PropertyType=Thickness,DefaultValue=Thickness (0),Version=2.0,GenerateAccessors */
44 const static int MarginProperty
;
45 /* @PropertyType=double,DefaultValue=INFINITY,Version=2.0,GenerateAccessors */
46 const static int MaxHeightProperty
;
47 /* @PropertyType=double,DefaultValue=INFINITY,Version=2.0,GenerateAccessors */
48 const static int MaxWidthProperty
;
49 /* @PropertyType=double,DefaultValue=0.0,Version=2.0,GenerateAccessors */
50 const static int MinHeightProperty
;
51 /* @PropertyType=double,DefaultValue=0.0,Version=2.0,GenerateAccessors */
52 const static int MinWidthProperty
;
53 /* @PropertyType=VerticalAlignment,DefaultValue=VerticalAlignmentStretch,Version=2.0,GenerateAccessors */
54 const static int VerticalAlignmentProperty
;
55 /* @PropertyType=Style,Version=2.0,GenerateAccessors,Validator=StyleValidator */
56 const static int StyleProperty
;
58 /* @GenerateCBinding,GeneratePInvoke,ManagedAccess=Protected */
61 virtual void ComputeBounds ();
62 virtual Rect
GetSubtreeBounds ();
64 virtual void HitTest (cairo_t
*cr
, Point p
, List
*uielement_list
);
65 virtual void FindElementsInHostCoordinates (cairo_t
*cr
, Point P
, List
*uielement_list
);
66 virtual void FindElementsInHostCoordinates (cairo_t
*cr
, Rect r
, List
*uielement_list
);
68 //virtual void OnSubPropertyChanged (DependencyProperty *prop, DependencyObject *obj, PropertyChangedEventArgs *subobj_args);
69 virtual void OnPropertyChanged (PropertyChangedEventArgs
*args
, MoonError
*error
);
71 virtual bool InsideObject (cairo_t
*cr
, double x
, double y
);
72 void RenderLayoutClip (cairo_t
*cr
);
74 virtual void GetSizeForBrush (cairo_t
*cr
, double *width
, double *height
);
75 virtual Point
GetTransformOrigin ();
77 /* @GenerateCBinding,GeneratePInvoke */
78 void SetLogicalParent (DependencyObject
*logical_parent
, MoonError
*error
);
79 /* @GenerateCBinding,GeneratePInvoke */
80 DependencyObject
*GetLogicalParent () { return logical_parent
; }
85 void SetHeight (double height
);
88 void SetWidth (double width
);
91 void SetLanguage (const char *value
);
92 const char *GetLanguage ();
98 virtual void Measure (Size availableSize
);
99 virtual void Arrange (Rect finalRect
);
101 /* @GeneratePInvoke,GenerateCBinding */
102 void RegisterManagedOverrides (MeasureOverrideCallback measure_cb
, ArrangeOverrideCallback arrange_cb
);
104 // These two methods call into managed land using the
105 // delegates registered in RegisterManagedOverrides. If
106 // classes want to implement fully unmanaged layout, they
107 // should override these two methods.
109 /* @GenerateCBinding,GeneratePInvoke */
110 virtual Size
MeasureOverride (Size availableSize
);
111 /* @GenerateCBinding,GeneratePInvoke */
112 virtual Size
ArrangeOverride (Size finalSize
);
113 virtual Size
ComputeActualSize ();
116 // Apply specific constraint values to the given size
117 Size
ApplySizeConstraints (const Size
&size
);
119 virtual void UpdateLayout ();
121 const static int LayoutUpdatedEvent
;
122 /* @DelegateType=SizeChangedEventHandler */
123 const static int SizeChangedEvent
;
124 // XXX 2.0 also has the Loaded event moved here from
128 // Property Accessors (2.0)
131 void SetActualWidth (double width
);
132 double GetActualWidth ();
134 void SetActualHeight (double width
);
135 double GetActualHeight ();
137 Thickness
*GetMargin ();
138 void SetMargin (Thickness
*value
);
140 double GetMaxHeight ();
141 void SetMaxHeight (double value
);
143 double GetMinHeight ();
144 void SetMinHeight (double value
);
146 double GetMaxWidth ();
147 void SetMaxWidth (double value
);
149 double GetMinWidth ();
150 void SetMinWidth (double value
);
152 HorizontalAlignment
GetHorizontalAlignment ();
153 void SetHorizontalAlignment (HorizontalAlignment value
);
156 void SetStyle (Style
*value
);
158 VerticalAlignment
GetVerticalAlignment ();
159 void SetVerticalAlignment (VerticalAlignment value
);
161 /* @GenerateCBinding,GeneratePInvoke */
162 void SetDefaultStyle (Style
*value
);
164 bool default_style_applied
;
167 Rect bounds_with_children
;
170 virtual void ElementAdded (UIElement
*item
);
172 virtual ~FrameworkElement ();
175 MeasureOverrideCallback measure_cb
;
176 ArrangeOverrideCallback arrange_cb
;
178 DependencyObject
*logical_parent
;
181 class FrameworkElementProvider
: public PropertyValueProvider
{
182 Value
*actual_height_value
;
183 Value
*actual_width_value
;
187 FrameworkElementProvider (DependencyObject
*obj
, PropertyPrecedence precedence
);
188 virtual ~FrameworkElementProvider ();
189 virtual Value
*GetPropertyValue (DependencyProperty
*property
);
193 #endif /* __FRAMEWORKELEMENT_H__ */