just kick off another build
[moon.git] / src / control.h
blob2cd74819586723ba131265048b9c75a3a9b4a346
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
32 enum TemplateStatus {
33 TemplateStatusApplied,
34 TemplateStatusAlreadyApplied,
35 TemplateStatusNotApplied
39 // Control Class
41 /* @Namespace=System.Windows.Controls */
42 /* @CallInitialize */
43 class Control : public FrameworkElement {
44 public:
45 /* @GenerateCBinding,GeneratePInvoke,ManagedAccess=Protected */
46 Control ();
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;
79 // Property Accessors
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);
121 int GetTabIndex ();
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 ();
139 // Events
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;
181 protected:
182 virtual ~Control ();
183 UIElement *template_root;
184 TemplateStatus ApplyTemplate (FrameworkTemplate *t);
185 TemplateStatus ApplyTemplateRoot (UIElement *root);
187 private:
188 FrameworkTemplate *applied_template;
189 bool enabled_local;
190 bool enabled_parent;
194 #endif /* __CONTROL_H__ */