2009-11-08 Chris Toshok <toshok@ximian.com>
[moon.git] / src / control.h
blob2236254f9f0ec7e80e966e7181c9bb1bdac5c5fc
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /*
3 * control.h:
5 * Copyright 2007 Novell, Inc. (http://www.novell.com)
7 * See the LICENSE file included with the distribution for details.
8 *
9 */
11 #ifndef __CONTROL_H__
12 #define __CONTROL_H__
14 #include <glib.h>
16 #include "frameworkelement.h"
17 #include "thickness.h"
18 #include "brush.h"
19 #include "enums.h"
20 #include "xaml.h"
21 #include "template.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 // Control Class
35 /* @Namespace=System.Windows.Controls */
36 /* @CallInitialize */
37 class Control : public FrameworkElement {
38 public:
39 /* @GenerateCBinding,GeneratePInvoke,ManagedAccess=Protected */
40 Control ();
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);
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 OnApplyTemplate ();
60 virtual void SetVisualParent (UIElement *visual_parent);
62 virtual bool Focus (bool recurse = true);
64 /* @GenerateCBinding,GeneratePInvoke */
65 DependencyObject *GetTemplateChild (const char *name);
67 UIElement *GetTemplateRoot () { return template_root; }
70 // Property Accessors
72 void SetBackground (Brush *bg);
73 Brush *GetBackground ();
75 void SetBorderBrush (Brush *brush);
76 Brush *GetBorderBrush ();
78 void SetBorderThickness (Thickness *thickness);
79 Thickness *GetBorderThickness ();
81 void SetFontFamily (FontFamily *family);
82 FontFamily *GetFontFamily ();
84 void SetFontSize (double size);
85 double GetFontSize ();
87 void SetFontStretch (FontStretch* stretch);
88 FontStretch* GetFontStretch ();
90 void SetFontStyle (FontStyle* style);
91 FontStyle* GetFontStyle ();
93 void SetFontWeight (FontWeight* weight);
94 FontWeight* GetFontWeight ();
96 void SetForeground (Brush *fg);
97 Brush *GetForeground ();
99 void SetHorizontalContentAlignment (HorizontalAlignment alignment);
100 HorizontalAlignment GetHorizontalContentAlignment ();
102 void SetIsEnabled (bool value);
103 bool GetIsEnabled ();
105 void SetIsTabStop (bool value);
106 bool GetIsTabStop ();
108 void SetPadding (Thickness *padding);
109 Thickness *GetPadding ();
111 void SetTabIndex (int index);
112 int GetTabIndex ();
114 void SetTabNavigation (KeyboardNavigationMode mode);
115 KeyboardNavigationMode GetTabNavigation ();
117 void SetTemplate (ControlTemplate *value);
118 ControlTemplate* GetTemplate ();
120 void SetVerticalContentAlignment (VerticalAlignment alignment);
121 VerticalAlignment GetVerticalContentAlignment ();
123 void SetDefaultStyleKey (ManagedTypeInfo *value);
124 ManagedTypeInfo* GetDefaultStyleKey ();
126 static void SetIsTemplateItem (DependencyObject *object, bool value);
127 static bool GetIsTemplateItem (DependencyObject *object);
129 static bool GetParentEnabledState (UIElement *element);
131 void UpdateEnabled ();
132 // Events
133 /* @DelegateType=DependencyPropertyChangedEventHandler */
134 const static int IsEnabledChangedEvent;
135 /* @GenerateManagedEvent=false */
136 const static int TemplateAppliedEvent;
138 /* @PropertyType=Brush,GenerateAccessors */
139 const static int BackgroundProperty;
140 /* @PropertyType=Brush,GenerateAccessors */
141 const static int BorderBrushProperty;
142 /* @PropertyType=Thickness,DefaultValue=Thickness(0.0),GenerateAccessors */
143 const static int BorderThicknessProperty;
144 /* @PropertyType=FontFamily,DefaultValue=FontFamily(CONTROL_FONT_FAMILY),GenerateAccessors */
145 const static int FontFamilyProperty;
146 /* @PropertyType=double,AutoCreator=CreateDefaultFontSize,GenerateAccessors */
147 const static int FontSizeProperty;
148 /* @PropertyType=FontStretch,DefaultValue=FontStretch(CONTROL_FONT_STRETCH),GenerateAccessors */
149 const static int FontStretchProperty;
150 /* @PropertyType=FontStyle,DefaultValue=FontStyle(CONTROL_FONT_STYLE),GenerateAccessors */
151 const static int FontStyleProperty;
152 /* @PropertyType=FontWeight,DefaultValue=FontWeight(CONTROL_FONT_WEIGHT),GenerateAccessors */
153 const static int FontWeightProperty;
154 /* @PropertyType=Brush,DefaultValue=new SolidColorBrush("black"),GenerateAccessors */
155 const static int ForegroundProperty;
156 /* @PropertyType=HorizontalAlignment,DefaultValue=HorizontalAlignmentCenter,GenerateAccessors */
157 const static int HorizontalContentAlignmentProperty;
158 /* @PropertyType=bool,DefaultValue=true,GenerateAccessors */
159 const static int IsEnabledProperty;
160 /* @PropertyType=bool,DefaultValue=false,ManagedAccess=Internal,Attached,GenerateAccessors */
161 const static int IsTemplateItemProperty;
162 /* @PropertyType=bool,DefaultValue=true,GenerateAccessors */
163 const static int IsTabStopProperty;
164 /* @PropertyType=Thickness,DefaultValue=Thickness(0.0),GenerateAccessors */
165 const static int PaddingProperty;
166 /* @PropertyType=gint32,DefaultValue=INT_MAX,GenerateAccessors */
167 const static int TabIndexProperty;
168 /* @PropertyType=KeyboardNavigationMode,DefaultValue=KeyboardNavigationModeLocal,GenerateAccessors */
169 const static int TabNavigationProperty;
170 /* @PropertyType=ControlTemplate,GenerateAccessors,Validator=TemplateValidator */
171 const static int TemplateProperty;
172 /* @PropertyType=VerticalAlignment,DefaultValue=VerticalAlignmentCenter,GenerateAccessors */
173 const static int VerticalContentAlignmentProperty;
174 /* @PropertyType=ManagedTypeInfo,ManagedPropertyType=object,GenerateManagedDP=false,GenerateAccessors */
175 const static int DefaultStyleKeyProperty;
177 bool enabled_parent;
178 protected:
179 virtual ~Control ();
181 private:
182 bool enabled_local;
183 UIElement *template_root;
187 #endif /* __CONTROL_H__ */