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
35 /* @Namespace=System.Windows.Controls */
37 class Control
: public FrameworkElement
{
39 /* @GenerateCBinding,GeneratePInvoke,ManagedAccess=Protected */
42 virtual bool CanCaptureMouse () { return GetIsEnabled (); }
43 virtual bool CanFindElement () { return GetIsEnabled (); }
44 virtual void FindElementsInHostCoordinates (cairo_t
*cr
, Point p
, List
*uielement_list
);
45 virtual void HitTest (cairo_t
*cr
, Point p
, List
*uielement_list
);
46 virtual void Dispose ();
47 virtual bool IsLayoutContainer () { return true; }
49 virtual bool InsideObject (cairo_t
*cr
, double x
, double y
);
51 virtual void OnLoaded ();
52 virtual void OnPropertyChanged (PropertyChangedEventArgs
*args
, MoonError
*error
);
53 virtual bool SetValueWithErrorImpl (DependencyProperty
*property
, Value
*value
, MoonError
*error
);
55 virtual void ElementAdded (UIElement
*item
);
56 virtual void ElementRemoved (UIElement
*item
);
58 virtual bool DoApplyTemplate ();
59 virtual void SetVisualParent (UIElement
*visual_parent
);
61 virtual bool Focus (bool recurse
= true);
63 /* @GenerateCBinding,GeneratePInvoke */
64 DependencyObject
*GetTemplateChild (const char *name
);
66 UIElement
*GetTemplateRoot () { return template_root
; }
71 void SetBackground (Brush
*bg
);
72 Brush
*GetBackground ();
74 void SetBorderBrush (Brush
*brush
);
75 Brush
*GetBorderBrush ();
77 void SetBorderThickness (Thickness
*thickness
);
78 Thickness
*GetBorderThickness ();
80 void SetFontFamily (FontFamily
*family
);
81 FontFamily
*GetFontFamily ();
83 void SetFontSize (double size
);
84 double GetFontSize ();
86 void SetFontStretch (FontStretch
* stretch
);
87 FontStretch
* GetFontStretch ();
89 void SetFontStyle (FontStyle
* style
);
90 FontStyle
* GetFontStyle ();
92 void SetFontWeight (FontWeight
* weight
);
93 FontWeight
* GetFontWeight ();
95 void SetForeground (Brush
*fg
);
96 Brush
*GetForeground ();
98 void SetHorizontalContentAlignment (HorizontalAlignment alignment
);
99 HorizontalAlignment
GetHorizontalContentAlignment ();
101 void SetIsEnabled (bool value
);
102 bool GetIsEnabled ();
104 void SetIsTabStop (bool value
);
105 bool GetIsTabStop ();
107 void SetPadding (Thickness
*padding
);
108 Thickness
*GetPadding ();
110 void SetTabIndex (int index
);
113 void SetTabNavigation (KeyboardNavigationMode mode
);
114 KeyboardNavigationMode
GetTabNavigation ();
116 void SetTemplate (ControlTemplate
*value
);
117 ControlTemplate
* GetTemplate ();
119 void SetVerticalContentAlignment (VerticalAlignment alignment
);
120 VerticalAlignment
GetVerticalContentAlignment ();
122 void SetDefaultStyleKey (ManagedTypeInfo
*value
);
123 ManagedTypeInfo
* GetDefaultStyleKey ();
125 static void SetIsTemplateItem (DependencyObject
*object
, bool value
);
126 static bool GetIsTemplateItem (DependencyObject
*object
);
128 static bool GetParentEnabledState (UIElement
*element
);
130 void UpdateEnabled ();
132 /* @DelegateType=DependencyPropertyChangedEventHandler */
133 const static int IsEnabledChangedEvent
;
135 /* @PropertyType=Brush,GenerateAccessors */
136 const static int BackgroundProperty
;
137 /* @PropertyType=Brush,GenerateAccessors */
138 const static int BorderBrushProperty
;
139 /* @PropertyType=Thickness,DefaultValue=Thickness(0.0),GenerateAccessors */
140 const static int BorderThicknessProperty
;
141 /* @PropertyType=FontFamily,DefaultValue=FontFamily(CONTROL_FONT_FAMILY),GenerateAccessors */
142 const static int FontFamilyProperty
;
143 /* @PropertyType=double,AutoCreator=CreateDefaultFontSize,GenerateAccessors */
144 const static int FontSizeProperty
;
145 /* @PropertyType=FontStretch,DefaultValue=FontStretch(CONTROL_FONT_STRETCH),GenerateAccessors */
146 const static int FontStretchProperty
;
147 /* @PropertyType=FontStyle,DefaultValue=FontStyle(CONTROL_FONT_STYLE),GenerateAccessors */
148 const static int FontStyleProperty
;
149 /* @PropertyType=FontWeight,DefaultValue=FontWeight(CONTROL_FONT_WEIGHT),GenerateAccessors */
150 const static int FontWeightProperty
;
151 /* @PropertyType=Brush,DefaultValue=new SolidColorBrush("black"),GenerateAccessors */
152 const static int ForegroundProperty
;
153 /* @PropertyType=HorizontalAlignment,DefaultValue=HorizontalAlignmentCenter,GenerateAccessors */
154 const static int HorizontalContentAlignmentProperty
;
155 /* @PropertyType=bool,DefaultValue=true,GenerateAccessors */
156 const static int IsEnabledProperty
;
157 /* @PropertyType=bool,DefaultValue=false,ManagedAccess=Internal,Attached,GenerateAccessors */
158 const static int IsTemplateItemProperty
;
159 /* @PropertyType=bool,DefaultValue=true,GenerateAccessors */
160 const static int IsTabStopProperty
;
161 /* @PropertyType=Thickness,DefaultValue=Thickness(0.0),GenerateAccessors */
162 const static int PaddingProperty
;
163 /* @PropertyType=gint32,DefaultValue=INT_MAX,GenerateAccessors */
164 const static int TabIndexProperty
;
165 /* @PropertyType=KeyboardNavigationMode,DefaultValue=KeyboardNavigationModeLocal,GenerateAccessors */
166 const static int TabNavigationProperty
;
167 /* @PropertyType=ControlTemplate,GenerateAccessors,Validator=TemplateValidator */
168 const static int TemplateProperty
;
169 /* @PropertyType=VerticalAlignment,DefaultValue=VerticalAlignmentCenter,GenerateAccessors */
170 const static int VerticalContentAlignmentProperty
;
171 /* @PropertyType=ManagedTypeInfo,ManagedPropertyType=object,GenerateManagedDP=false,GenerateAccessors */
172 const static int DefaultStyleKeyProperty
;
180 UIElement
*template_root
;
184 #endif /* __CONTROL_H__ */