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
);
23 /* @CBindingRequisite */
24 typedef UIElement
*(*GetDefaultTemplateCallback
)(FrameworkElement
*element
);
25 /* @CBindingRequisite */
26 typedef void (*LoadedCallback
)(FrameworkElement
*element
);
28 /* @Namespace=System.Windows */
30 class FrameworkElement
: public UIElement
{
32 /* @PropertyType=double,DefaultValue=NAN,GenerateAccessors */
33 const static int HeightProperty
;
34 /* @PropertyType=double,DefaultValue=NAN,GenerateAccessors */
35 const static int WidthProperty
;
37 /* @PropertyType=double,DefaultValue=0.0,Version=2,ManagedSetterAccess=Internal,GenerateAccessors,ReadOnly */
38 const static int ActualHeightProperty
;
39 /* @PropertyType=double,DefaultValue=0.0,Version=2,ManagedSetterAccess=Internal,GenerateAccessors,ReadOnly */
40 const static int ActualWidthProperty
;
41 /* @PropertyType=object,Version=2.0 */
42 const static int DataContextProperty
;
43 /* @PropertyType=HorizontalAlignment,DefaultValue=HorizontalAlignmentStretch,Version=2.0,GenerateAccessors */
44 const static int HorizontalAlignmentProperty
;
45 /* @PropertyType=string,DefaultValue=\"en-US\",Version=2.0,ManagedPropertyType=XmlLanguage,Validator=NonNullValidator,GenerateAccessors */
46 const static int LanguageProperty
;
47 /* @PropertyType=Thickness,DefaultValue=Thickness (0),Version=2.0,GenerateAccessors */
48 const static int MarginProperty
;
49 /* @PropertyType=double,DefaultValue=INFINITY,Version=2.0,GenerateAccessors */
50 const static int MaxHeightProperty
;
51 /* @PropertyType=double,DefaultValue=INFINITY,Version=2.0,GenerateAccessors */
52 const static int MaxWidthProperty
;
53 /* @PropertyType=double,DefaultValue=0.0,Version=2.0,GenerateAccessors */
54 const static int MinHeightProperty
;
55 /* @PropertyType=double,DefaultValue=0.0,Version=2.0,GenerateAccessors */
56 const static int MinWidthProperty
;
57 /* @PropertyType=VerticalAlignment,DefaultValue=VerticalAlignmentStretch,Version=2.0,GenerateAccessors */
58 const static int VerticalAlignmentProperty
;
59 /* @PropertyType=Style,Version=2.0,GenerateAccessors,Validator=StyleValidator */
60 const static int StyleProperty
;
62 /* @GenerateCBinding,GeneratePInvoke,ManagedAccess=Protected */
65 /* @GenerateCBinding,GeneratePInvoke */
66 bool ApplyTemplate ();
67 virtual bool DoApplyTemplate ();
68 virtual UIElement
* GetDefaultTemplate ();
69 virtual void OnApplyTemplate ();
71 virtual void ElementRemoved (UIElement
*obj
);
73 virtual void ComputeBounds ();
74 virtual Rect
GetSubtreeBounds ();
75 virtual void Dispose ();
76 virtual void HitTest (cairo_t
*cr
, Point p
, List
*uielement_list
);
77 virtual void FindElementsInHostCoordinates (cairo_t
*cr
, Point P
, List
*uielement_list
);
78 virtual void FindElementsInHostCoordinates (cairo_t
*cr
, Rect r
, List
*uielement_list
);
80 //virtual void OnSubPropertyChanged (DependencyProperty *prop, DependencyObject *obj, PropertyChangedEventArgs *subobj_args);
81 virtual void OnPropertyChanged (PropertyChangedEventArgs
*args
, MoonError
*error
);
83 virtual bool InsideObject (cairo_t
*cr
, double x
, double y
);
84 bool InsideLayoutClip (double x
, double y
);
85 void RenderLayoutClip (cairo_t
*cr
);
87 virtual void GetSizeForBrush (cairo_t
*cr
, double *width
, double *height
);
88 virtual Point
GetTransformOrigin ();
90 /* @GenerateCBinding,GeneratePInvoke */
91 void SetLogicalParent (DependencyObject
*logical_parent
, MoonError
*error
);
92 /* @GenerateCBinding,GeneratePInvoke */
93 DependencyObject
*GetLogicalParent () { return logical_parent
; }
98 void SetHeight (double height
);
101 void SetWidth (double width
);
104 void SetLanguage (const char *value
);
105 const char *GetLanguage ();
111 virtual void Measure (Size availableSize
);
112 virtual void Arrange (Rect finalRect
);
114 /* @GeneratePInvoke,GenerateCBinding */
115 void RegisterManagedOverrides (MeasureOverrideCallback measure_cb
, ArrangeOverrideCallback arrange_cb
,
116 GetDefaultTemplateCallback get_default_template_cb
, LoadedCallback loaded_cb
);
118 // These two methods call into managed land using the
119 // delegates registered in RegisterManagedOverrides. If
120 // classes want to implement fully unmanaged layout, they
121 // should override these two methods.
123 /* @GenerateCBinding,GeneratePInvoke */
124 virtual Size
MeasureOverride (Size availableSize
);
125 /* @GenerateCBinding,GeneratePInvoke */
126 virtual Size
ArrangeOverride (Size finalSize
);
127 virtual Size
ComputeActualSize ();
130 // Apply specific constraint values to the given size
131 Size
ApplySizeConstraints (const Size
&size
);
133 virtual void UpdateLayout ();
135 virtual void OnLoaded ();
137 /* @DelegateType=SizeChangedEventHandler */
138 const static int SizeChangedEvent
;
139 /* @GenerateManagedEvent=false */
140 const static int TemplateAppliedEvent
;
141 // XXX 2.0 also has the Loaded event moved here from
145 // Property Accessors (2.0)
148 void SetActualWidth (double width
);
149 double GetActualWidth ();
151 void SetActualHeight (double width
);
152 double GetActualHeight ();
154 Thickness
*GetMargin ();
155 void SetMargin (Thickness
*value
);
157 double GetMaxHeight ();
158 void SetMaxHeight (double value
);
160 double GetMinHeight ();
161 void SetMinHeight (double value
);
163 double GetMaxWidth ();
164 void SetMaxWidth (double value
);
166 double GetMinWidth ();
167 void SetMinWidth (double value
);
169 HorizontalAlignment
GetHorizontalAlignment ();
170 void SetHorizontalAlignment (HorizontalAlignment value
);
173 void SetStyle (Style
*value
);
175 VerticalAlignment
GetVerticalAlignment ();
176 void SetVerticalAlignment (VerticalAlignment value
);
178 /* @GenerateCBinding,GeneratePInvoke */
179 void SetDefaultStyle (Style
*value
);
181 bool default_style_applied
;
184 GetDefaultTemplateCallback get_default_template_cb
;
185 Rect bounds_with_children
;
188 virtual ~FrameworkElement ();
191 MeasureOverrideCallback measure_cb
;
192 ArrangeOverrideCallback arrange_cb
;
193 LoadedCallback loaded_cb
;
195 DependencyObject
*logical_parent
;
196 UIElement
*default_template
;
199 class FrameworkElementProvider
: public PropertyValueProvider
{
200 Value
*actual_height_value
;
201 Value
*actual_width_value
;
205 FrameworkElementProvider (DependencyObject
*obj
, PropertyPrecedence precedence
);
206 virtual ~FrameworkElementProvider ();
207 virtual Value
*GetPropertyValue (DependencyProperty
*property
);
211 #endif /* __FRAMEWORKELEMENT_H__ */