1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
5 * Copyright 2008 Novell, Inc. (http://www.novell.com)
7 * See the LICENSE file included with the distribution for details.
11 #ifndef __MOON_GRID_H__
12 #define __MOON_GRID_H__
18 /* @Namespace=System.Windows */
26 type
= GridUnitTypeAuto
;
29 GridLength (double v
, GridUnitType t
)
36 /* @Namespace=System.Windows.Controls */
37 class ColumnDefinition
: public DependencyObject
{
39 virtual ~ColumnDefinition ();
42 /* @PropertyType=double,DefaultValue=INFINITY,GenerateAccessors */
43 const static int MaxWidthProperty
;
44 /* @PropertyType=double,DefaultValue=0.0,GenerateAccessors */
45 const static int MinWidthProperty
;
46 /* @PropertyType=GridLength,DefaultValue=GridLength (1.0\, GridUnitTypeStar),GenerateAccessors */
47 const static int WidthProperty
;
48 /* @PropertyType=double,DefaultValue=0.0,GenerateAccessors,ManagedSetterAccess=Private,ManagedFieldAccess=Private */
49 const static int ActualWidthProperty
;
51 /* @GenerateCBinding,GeneratePInvoke */
55 double GetActualWidth ();
56 void SetActualWidth (double value
);
59 void SetMaxWidth (double value
);
62 void SetMinWidth (double value
);
64 GridLength
* GetWidth();
65 void SetWidth (GridLength
*value
);
68 /* @Namespace=System.Windows.Controls */
69 class RowDefinition
: public DependencyObject
{
71 virtual ~RowDefinition ();
74 /* @PropertyType=GridLength,DefaultValue=GridLength (1.0\, GridUnitTypeStar),GenerateAccessors */
75 const static int HeightProperty
;
76 /* @PropertyType=double,DefaultValue=INFINITY,GenerateAccessors */
77 const static int MaxHeightProperty
;
78 /* @PropertyType=double,DefaultValue=0.0,GenerateAccessors */
79 const static int MinHeightProperty
;
80 /* @PropertyType=double,DefaultValue=0.0,GenerateAccessors,ManagedSetterAccess=Private,ManagedFieldAccess=Private */
81 const static int ActualHeightProperty
;
83 /* @GenerateCBinding,GeneratePInvoke */
87 double GetActualHeight ();
88 void SetActualHeight (double value
);
90 double GetMaxHeight();
91 void SetMaxHeight (double value
);
93 double GetMinHeight();
94 void SetMinHeight (double value
);
96 GridLength
* GetHeight();
97 void SetHeight (GridLength
*value
);
100 /* @Namespace=System.Windows.Controls */
101 class ColumnDefinitionCollection
: public DependencyObjectCollection
{
103 virtual ~ColumnDefinitionCollection ();
105 virtual bool AddedToCollection (Value
*value
, MoonError
*error
);
108 /* @GenerateCBinding,GeneratePInvoke,ManagedAccess=Internal */
109 ColumnDefinitionCollection ();
111 virtual Type::Kind
GetElementType () { return Type::COLUMNDEFINITION
; }
115 /* @Namespace=System.Windows.Controls */
116 class RowDefinitionCollection
: public DependencyObjectCollection
{
118 virtual ~RowDefinitionCollection ();
120 virtual bool AddedToCollection (Value
*value
, MoonError
*error
);
123 /* @GenerateCBinding,GeneratePInvoke,ManagedAccess=Internal */
124 RowDefinitionCollection ();
126 virtual Type::Kind
GetElementType () { return Type::ROWDEFINITION
; }
137 Segment (double size
, double min
, double max
, GridUnitType type
);
140 void Init (double size
, double min
, double max
, GridUnitType type
);
143 /* @Namespace=System.Windows.Controls */
144 class Grid
: public Panel
{
147 Segment
**row_matrix
;
148 Segment
**col_matrix
;
150 void AllocateGridSegments (int row_count
, int col_count
);
151 void AssignSize (Segment
**matrix
, int start
, int end
, double *size
, GridUnitType type
);
152 void CreateMatrices (int row_count
, int col_count
);
153 void DestroyMatrices ();
154 void TryExpandStarRows (Size availableSize
, bool force_width_nan
, bool force_height_nan
);
155 void TryExpandStarCols (Size availableSize
, bool force_width_nan
, bool force_height_nan
);
159 virtual void PostRender (cairo_t
*cr
, Region
*region
, bool front_to_back
);
162 /* @PropertyType=gint32,DefaultValue=0,Attached,GenerateAccessors,Validator=PositiveIntValidator */
163 const static int ColumnProperty
;
164 /* @PropertyType=ColumnDefinitionCollection,AutoCreateValue,ManagedFieldAccess=Internal,ManagedSetterAccess=Internal,GenerateAccessors */
165 const static int ColumnDefinitionsProperty
;
166 /* @PropertyType=gint32,DefaultValue=1,Attached,GenerateAccessors,Validator=IntGreaterThanZeroValidator */
167 const static int ColumnSpanProperty
;
168 /* @PropertyType=gint32,DefaultValue=0,Attached,GenerateAccessors,Validator=PositiveIntValidator */
169 const static int RowProperty
;
170 /* @PropertyType=RowDefinitionCollection,AutoCreateValue,ManagedFieldAccess=Internal,ManagedSetterAccess=Internal,GenerateAccessors */
171 const static int RowDefinitionsProperty
;
172 /* @PropertyType=gint32,DefaultValue=1,Attached,GenerateAccessors,Validator=IntGreaterThanZeroValidator */
173 const static int RowSpanProperty
;
176 * NOTE: The ShowGridLines property defaults to false but appears
177 * to be uninitialized before InitializeComponents is called
178 * causing the current moon-unit test to fail.
180 /* @PropertyType=bool,DefaultValue=false,GenerateAccessors */
181 const static int ShowGridLinesProperty
;
183 /* @GenerateCBinding,GeneratePInvoke */
186 virtual void OnPropertyChanged (PropertyChangedEventArgs
*args
, MoonError
*error
);
187 virtual void OnCollectionChanged (Collection
*col
, CollectionChangedEventArgs
*args
);
188 virtual void OnCollectionItemChanged (Collection
*col
, DependencyObject
*obj
, PropertyChangedEventArgs
*args
);
189 virtual void ComputeBounds ();
191 virtual Size
MeasureOverride (Size availableSize
);
192 virtual Size
ArrangeOverride (Size finalSize
);
194 // property accessors
195 ColumnDefinitionCollection
*GetColumnDefinitions ();
196 void SetColumnDefinitions (ColumnDefinitionCollection
* value
);
198 static gint32
GetColumn (DependencyObject
*obj
);
199 static void SetColumn (DependencyObject
*obj
, gint32 value
);
201 static gint32
GetColumnSpan (DependencyObject
*obj
);
202 static void SetColumnSpan (DependencyObject
*obj
, gint32 value
);
204 RowDefinitionCollection
*GetRowDefinitions ();
205 void SetRowDefinitions (RowDefinitionCollection
* value
);
207 static gint32
GetRow (DependencyObject
*obj
);
208 static void SetRow (DependencyObject
*obj
, gint32 value
);
210 static gint32
GetRowSpan (DependencyObject
*obj
);
211 static void SetRowSpan (DependencyObject
*obj
, gint32 value
);
213 bool GetShowGridLines ();
214 void SetShowGridLines (bool value
);
216 static double Clamp (double val
, double min
, double max
);
219 // We need this class to figure out what kinds of elements the grid
220 // contains before the grid starts measuring them.
223 bool HasAutoAuto () { return has_auto_auto
; }
224 bool HasStarAuto () { return has_star_auto
; }
225 bool HasAutoStar () { return has_auto_star
; }
226 GridWalker (Grid
*grid
, Segment
**row_matrix
, int row_count
, Segment
**col_matrix
, int col_count
);
234 class GridNode
: public List::Node
{
241 GridNode (Segment
**matrix
, int row
, int col
, double size
) {
242 this->matrix
= matrix
;
248 #endif /* __MOON_PANEL_H__ */