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.
16 #include "frameworkelement.h"
17 #include "thickness.h"
22 #include "fontfamily.h"
23 #include "fontstretch.h"
24 #include "fontstyle.h"
25 #include "fontweight.h"
27 #define CONTROL_FONT_FAMILY "Portable User Interface"
28 #define CONTROL_FONT_STRETCH FontStretchesNormal
29 #define CONTROL_FONT_WEIGHT FontWeightsNormal
30 #define CONTROL_FONT_STYLE FontStylesNormal
33 TemplateStatusApplied
,
34 TemplateStatusAlreadyApplied
,
35 TemplateStatusNotApplied
41 /* @Namespace=System.Windows.Controls */
43 class Control
: public FrameworkElement
{
45 /* @GenerateCBinding,GeneratePInvoke,ManagedAccess=Protected */
47 virtual void Dispose ();
49 virtual bool CanCaptureMouse () { return GetIsEnabled (); }
50 virtual bool CanFindElement () { return GetIsEnabled (); }
51 virtual void FindElementsInHostCoordinates (cairo_t
*cr
, Point p
, List
*uielement_list
);
52 virtual void HitTest (cairo_t
*cr
, Point p
, List
*uielement_list
);
54 virtual bool IsLayoutContainer () { return true; }
56 virtual bool InsideObject (cairo_t
*cr
, double x
, double y
);
58 virtual void OnLoaded ();
59 virtual void OnPropertyChanged (PropertyChangedEventArgs
*args
, MoonError
*error
);
60 virtual bool SetValueWithErrorImpl (DependencyProperty
*property
, Value
*value
, MoonError
*error
);
62 virtual void ElementAdded (UIElement
*item
);
63 virtual void ElementRemoved (UIElement
*item
);
65 virtual void OnApplyTemplate ();
66 virtual void SetVisualParent (UIElement
*visual_parent
);
68 virtual bool Focus (bool recurse
= true);
70 /* @GenerateCBinding,GeneratePInvoke */
71 virtual bool ApplyTemplate ();
72 void ClearTemplate ();
74 /* @GenerateCBinding,GeneratePInvoke */
75 DependencyObject
*GetTemplateChild (const char *name
);
76 const static int TemplateAppliedEvent
;
81 void SetBackground (Brush
*bg
);
82 Brush
*GetBackground ();
84 void SetBorderBrush (Brush
*brush
);
85 Brush
*GetBorderBrush ();
87 void SetBorderThickness (Thickness
*thickness
);
88 Thickness
*GetBorderThickness ();
90 void SetFontFamily (FontFamily
*family
);
91 FontFamily
*GetFontFamily ();
93 void SetFontSize (double size
);
94 double GetFontSize ();
96 void SetFontStretch (FontStretch
* stretch
);
97 FontStretch
* GetFontStretch ();
99 void SetFontStyle (FontStyle
* style
);
100 FontStyle
* GetFontStyle ();
102 void SetFontWeight (FontWeight
* weight
);
103 FontWeight
* GetFontWeight ();
105 void SetForeground (Brush
*fg
);
106 Brush
*GetForeground ();
108 void SetHorizontalContentAlignment (HorizontalAlignment alignment
);
109 HorizontalAlignment
GetHorizontalContentAlignment ();
111 void SetIsEnabled (bool value
);
112 bool GetIsEnabled ();
114 void SetIsTabStop (bool value
);
115 bool GetIsTabStop ();
117 void SetPadding (Thickness
*padding
);
118 Thickness
*GetPadding ();
120 void SetTabIndex (int index
);
123 void SetTabNavigation (KeyboardNavigationMode mode
);
124 KeyboardNavigationMode
GetTabNavigation ();
126 void SetTemplate (ControlTemplate
*value
);
127 ControlTemplate
* GetTemplate ();
129 void SetVerticalContentAlignment (VerticalAlignment alignment
);
130 VerticalAlignment
GetVerticalContentAlignment ();
132 void SetDefaultStyleKey (ManagedTypeInfo
*value
);
133 ManagedTypeInfo
* GetDefaultStyleKey ();
135 static void SetIsTemplateItem (DependencyObject
*object
, bool value
);
136 static bool GetIsTemplateItem (DependencyObject
*object
);
138 void UpdateEnabled ();
140 const static int IsEnabledChangedEvent
;
142 /* @PropertyType=Brush,GenerateAccessors */
143 const static int BackgroundProperty
;
144 /* @PropertyType=Brush,GenerateAccessors */
145 const static int BorderBrushProperty
;
146 /* @PropertyType=Thickness,DefaultValue=Thickness(0.0),GenerateAccessors */
147 const static int BorderThicknessProperty
;
148 /* @PropertyType=FontFamily,DefaultValue=FontFamily(CONTROL_FONT_FAMILY),GenerateAccessors */
149 const static int FontFamilyProperty
;
150 /* @PropertyType=double,AutoCreator=CreateDefaultFontSize,GenerateAccessors */
151 const static int FontSizeProperty
;
152 /* @PropertyType=FontStretch,DefaultValue=FontStretch(CONTROL_FONT_STRETCH),GenerateAccessors */
153 const static int FontStretchProperty
;
154 /* @PropertyType=FontStyle,DefaultValue=FontStyle(CONTROL_FONT_STYLE),GenerateAccessors */
155 const static int FontStyleProperty
;
156 /* @PropertyType=FontWeight,DefaultValue=FontWeight(CONTROL_FONT_WEIGHT),GenerateAccessors */
157 const static int FontWeightProperty
;
158 /* @PropertyType=Brush,DefaultValue=new SolidColorBrush("black"),GenerateAccessors */
159 const static int ForegroundProperty
;
160 /* @PropertyType=HorizontalAlignment,DefaultValue=HorizontalAlignmentCenter,GenerateAccessors */
161 const static int HorizontalContentAlignmentProperty
;
162 /* @PropertyType=bool,DefaultValue=true,GenerateAccessors */
163 const static int IsEnabledProperty
;
164 /* @PropertyType=bool,DefaultValue=false,Attached,GenerateAccessors */
165 const static int IsTemplateItemProperty
;
166 /* @PropertyType=bool,DefaultValue=true,GenerateAccessors */
167 const static int IsTabStopProperty
;
168 /* @PropertyType=Thickness,DefaultValue=Thickness(0.0),GenerateAccessors */
169 const static int PaddingProperty
;
170 /* @PropertyType=gint32,DefaultValue=INT_MAX,GenerateAccessors */
171 const static int TabIndexProperty
;
172 /* @PropertyType=KeyboardNavigationMode,DefaultValue=KeyboardNavigationModeLocal,GenerateAccessors */
173 const static int TabNavigationProperty
;
174 /* @PropertyType=ControlTemplate,GenerateAccessors,Validator=TemplateValidator */
175 const static int TemplateProperty
;
176 /* @PropertyType=VerticalAlignment,DefaultValue=VerticalAlignmentCenter,GenerateAccessors */
177 const static int VerticalContentAlignmentProperty
;
178 /* @PropertyType=ManagedTypeInfo,ManagedPropertyType=object,GenerateManagedDP=false,GenerateAccessors */
179 const static int DefaultStyleKeyProperty
;
183 UIElement
*template_root
;
184 TemplateStatus
ApplyTemplate (FrameworkTemplate
*t
);
185 TemplateStatus
ApplyTemplateRoot (UIElement
*root
);
188 FrameworkTemplate
*applied_template
;
194 #endif /* __CONTROL_H__ */