2009-12-07 Rolf Bjarne Kvinge <RKvinge@novell.com>
[moon.git] / src / transform.h
blobef8ed1d1d441ff9e86a48ea46abbb7bbd7aeedfe
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /*
3 * transform.h:
5 * Contact:
6 * Moonlight List (moonlight-list@lists.ximian.com)
8 * Copyright 2007 Novell, Inc. (http://www.novell.com)
10 * See the LICENSE file included with the distribution for details.
13 #ifndef __TRANSFORM_H__
14 #define __TRANSFORM_H__
16 #include <glib.h>
17 #include <cairo.h>
19 #include "collection.h"
21 /* @Namespace=System.Windows.Media */
22 class GeneralTransform : public DependencyObject {
23 protected:
24 cairo_matrix_t _matrix;
25 bool need_update;
27 virtual ~GeneralTransform () {};
29 virtual void UpdateTransform ();
30 void MaybeUpdateTransform ();
32 public:
33 /* @GenerateCBinding,GeneratePInvoke,ManagedAccess=Internal */
34 GeneralTransform () : need_update (true) { SetObjectType (Type::GENERALTRANSFORM); }
36 virtual void OnPropertyChanged (PropertyChangedEventArgs *args, MoonError *error);
38 virtual void GetTransform (cairo_matrix_t *value);
40 /* @GenerateCBinding,GeneratePInvoke */
41 Matrix* GetMatrix ();
43 Point Transform (Point point);
47 /* @Namespace=System.Windows.Media */
48 class Transform : public GeneralTransform {
49 protected:
50 virtual ~Transform () {}
52 public:
53 /* @GenerateCBinding,GeneratePInvoke,ManagedAccess=Internal */
54 Transform () { SetObjectType (Type::TRANSFORM); }
58 /* @Namespace=System.Windows.Media */
59 class RotateTransform : public Transform {
60 protected:
61 virtual ~RotateTransform () {}
62 virtual void UpdateTransform ();
64 public:
65 /* @PropertyType=double,DefaultValue=0.0,GenerateAccessors */
66 const static int AngleProperty;
67 /* @PropertyType=double,DefaultValue=0.0,GenerateAccessors */
68 const static int CenterXProperty;
69 /* @PropertyType=double,DefaultValue=0.0,GenerateAccessors */
70 const static int CenterYProperty;
72 /* @GenerateCBinding,GeneratePInvoke */
73 RotateTransform () { SetObjectType (Type::ROTATETRANSFORM); }
76 // Property Accessors
78 void SetAngle (double angle);
79 double GetAngle ();
81 void SetCenterX (double centerX);
82 double GetCenterX ();
84 void SetCenterY (double centerY);
85 double GetCenterY ();
89 /* @Namespace=System.Windows.Media */
90 class TranslateTransform : public Transform {
91 protected:
92 virtual ~TranslateTransform () { }
93 virtual void UpdateTransform ();
95 public:
96 /* @PropertyType=double,DefaultValue=0.0,GenerateAccessors */
97 const static int XProperty;
98 /* @PropertyType=double,DefaultValue=0.0,GenerateAccessors */
99 const static int YProperty;
101 /* @GenerateCBinding,GeneratePInvoke */
102 TranslateTransform () { SetObjectType (Type::TRANSLATETRANSFORM); }
105 // Property Accessors
107 void SetX (double x);
108 double GetX ();
110 void SetY (double y);
111 double GetY ();
115 /* @Namespace=System.Windows.Media */
116 class ScaleTransform : public Transform {
117 protected:
118 virtual ~ScaleTransform () {}
119 virtual void UpdateTransform ();
121 public:
122 /* @PropertyType=double,DefaultValue=0.0,GenerateAccessors */
123 const static int CenterXProperty;
124 /* @PropertyType=double,DefaultValue=0.0,GenerateAccessors */
125 const static int CenterYProperty;
126 /* @PropertyType=double,DefaultValue=1.0,GenerateAccessors */
127 const static int ScaleXProperty;
128 /* @PropertyType=double,DefaultValue=1.0,GenerateAccessors */
129 const static int ScaleYProperty;
131 /* @GenerateCBinding,GeneratePInvoke */
132 ScaleTransform () { SetObjectType (Type::SCALETRANSFORM); }
135 // Property Accessors
137 void SetCenterX (double centerX);
138 double GetCenterX ();
140 void SetCenterY (double centerY);
141 double GetCenterY ();
143 void SetScaleX (double scaleX);
144 double GetScaleX ();
146 void SetScaleY (double scaleY);
147 double GetScaleY ();
151 /* @Namespace=System.Windows.Media */
152 class SkewTransform : public Transform {
153 protected:
154 virtual ~SkewTransform () {}
155 virtual void UpdateTransform ();
157 public:
158 /* @PropertyType=double,DefaultValue=0.0,GenerateAccessors */
159 const static int AngleXProperty;
160 /* @PropertyType=double,DefaultValue=0.0,GenerateAccessors */
161 const static int AngleYProperty;
162 /* @PropertyType=double,DefaultValue=0.0,GenerateAccessors */
163 const static int CenterXProperty;
164 /* @PropertyType=double,DefaultValue=0.0,GenerateAccessors */
165 const static int CenterYProperty;
167 /* @GenerateCBinding,GeneratePInvoke */
168 SkewTransform () { SetObjectType (Type::SKEWTRANSFORM); }
171 // Property Accessors
173 void SetAngleX (double angleX);
174 double GetAngleX ();
176 void SetAngleY (double angleY);
177 double GetAngleY ();
179 void SetCenterX (double centerX);
180 double GetCenterX ();
182 void SetCenterY (double centerY);
183 double GetCenterY ();
187 /* @Namespace=None */ // The managed Matrix is a struct
188 /* @ManagedDependencyProperties=Manual */
189 /* @ManagedEvents=None */
190 class Matrix : public DependencyObject {
191 cairo_matrix_t matrix;
193 protected:
194 virtual ~Matrix () {}
196 public:
197 /* @PropertyType=double,DefaultValue=1.0,GenerateAccessors */
198 const static int M11Property;
199 /* @PropertyType=double,DefaultValue=0.0,GenerateAccessors */
200 const static int M12Property;
201 /* @PropertyType=double,DefaultValue=0.0,GenerateAccessors */
202 const static int M21Property;
203 /* @PropertyType=double,DefaultValue=1.0,GenerateAccessors */
204 const static int M22Property;
205 /* @PropertyType=double,DefaultValue=0.0,GenerateAccessors */
206 const static int OffsetXProperty;
207 /* @PropertyType=double,DefaultValue=0.0,GenerateAccessors */
208 const static int OffsetYProperty;
210 /* @GenerateCBinding,GeneratePInvoke */
211 Matrix ();
212 Matrix (cairo_matrix_t *m);
214 virtual void OnPropertyChanged (PropertyChangedEventArgs *args, MoonError *error);
216 cairo_matrix_t GetUnderlyingMatrix ();
218 /* @GenerateCBinding,GeneratePInvoke */
219 cairo_matrix_t *GetMatrixValues () { return &matrix; }
222 // Property Accessors
224 void SetM11 (double m11);
225 double GetM11 ();
227 void SetM12 (double m12);
228 double GetM12 ();
230 void SetM21 (double m21);
231 double GetM21 ();
233 void SetM22 (double m22);
234 double GetM22 ();
236 void SetOffsetX (double offsetX);
237 double GetOffsetX ();
239 void SetOffsetY (double offsetY);
240 double GetOffsetY ();
243 /* @Namespace=System.Windows.Media */
244 // this type does not really exists - its purpose is to let the unmanaged (1.x) matrix be a dependency object
245 // and the later (2.x) managed code use a struct (non-DO) for the matrix
246 class UnmanagedMatrix : public Matrix {
248 protected:
249 virtual ~UnmanagedMatrix () {}
251 public:
252 /* @GenerateCBinding,GeneratePInvoke */
253 UnmanagedMatrix () { SetObjectType (Type::UNMANAGEDMATRIX); }
256 /* @Namespace=System.Windows.Media */
257 class MatrixTransform : public Transform {
258 protected:
259 virtual ~MatrixTransform () {}
261 virtual void UpdateTransform ();
263 public:
264 /* @PropertyType=Matrix,GenerateAccessors */
265 const static int MatrixProperty;
267 /* @GenerateCBinding,GeneratePInvoke */
268 MatrixTransform () { SetObjectType (Type::MATRIXTRANSFORM); }
270 virtual void OnSubPropertyChanged (DependencyProperty *prop, DependencyObject *obj, PropertyChangedEventArgs *subobj_args);
273 // Property Accessors
275 void SetMatrix (Matrix *matrix);
276 Matrix *GetMatrix ();
280 /* @Namespace=System.Windows.Media */
281 class TransformCollection : public DependencyObjectCollection {
282 protected:
283 virtual ~TransformCollection () {}
285 public:
286 /* @GenerateCBinding,GeneratePInvoke */
287 TransformCollection () { SetObjectType (Type::TRANSFORM_COLLECTION); }
289 virtual Type::Kind GetElementType () { return Type::TRANSFORM; }
293 /* @ContentProperty="Children" */
294 /* @Namespace=System.Windows.Media */
295 class TransformGroup : public Transform {
296 protected:
297 virtual ~TransformGroup () {}
299 virtual void UpdateTransform ();
301 public:
302 /* @PropertyType=TransformCollection,AutoCreateValue,GenerateAccessors */
303 const static int ChildrenProperty;
305 /* @GenerateCBinding,GeneratePInvoke */
306 TransformGroup ();
308 virtual void OnCollectionItemChanged (Collection *col, DependencyObject *obj, PropertyChangedEventArgs *args);
309 virtual void OnCollectionChanged (Collection *col, CollectionChangedEventArgs *args);
310 virtual void OnPropertyChanged (PropertyChangedEventArgs *args, MoonError *error);
313 // Property Accessors
315 void SetChildren (TransformCollection *children);
316 TransformCollection *GetChildren ();
320 G_BEGIN_DECLS
322 /* @GeneratePInvoke */
323 void general_transform_transform_point (GeneralTransform *t, /* @MarshalAs=Point,IsRef */ Point *p, /* @MarshalAs=Point,IsRef */ Point *r);
325 G_END_DECLS
327 #endif