2009-12-07 Rolf Bjarne Kvinge <RKvinge@novell.com>
[moon.git] / src / stylus.h
blobb4ab08a73c3667bf9b094ba5f4e7cf998e6ead4d
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /*
3 * stylus.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.
14 #ifndef __STYLUS_H__
15 #define __STYLUS_H__
17 #include <glib.h>
18 #include "canvas.h"
19 #include "collection.h"
21 enum TabletDeviceType {
22 TabletDeviceTypeMouse,
23 TabletDeviceTypeStylus,
24 TabletDeviceTypeTouch
27 enum TouchAction {
28 TouchActionDown = 1,
29 TouchActionMove = 2,
30 TouchActionUp = 3
33 /* @Namespace=System.Windows.Input */
34 class StylusInfo : public DependencyObject {
35 protected:
36 virtual ~StylusInfo () {}
38 public:
39 /* @PropertyType=TabletDeviceType,DefaultValue=TabletDeviceTypeMouse,GenerateAccessors */
40 const static int DeviceTypeProperty;
41 /* @PropertyType=bool,DefaultValue=false,GenerateAccessors */
42 const static int IsInvertedProperty;
44 /* @ManagedAccess=Internal,GenerateCBinding,GeneratePInvoke */
45 StylusInfo () { SetObjectType (Type::STYLUSINFO); }
48 // Property Accessors
50 void SetDeviceType (TabletDeviceType type);
51 TabletDeviceType GetDeviceType ();
53 void SetIsInverted (bool inverted);
54 bool GetIsInverted ();
58 /* @Namespace=None */
59 /* @ManagedDependencyProperties=Manual */ // It's a managed struct
60 /* @ManagedEvents=Manual */ // It's a managed struct
61 class StylusPoint : public DependencyObject {
62 protected:
63 virtual ~StylusPoint () {}
65 public:
66 /* @PropertyType=double,DefaultValue=0.5,GenerateAccessors */
67 const static int PressureFactorProperty;
68 /* @PropertyType=double,DefaultValue=0.0,GenerateAccessors */
69 const static int XProperty;
70 /* @PropertyType=double,DefaultValue=0.0,GenerateAccessors */
71 const static int YProperty;
73 /* @GenerateCBinding,GeneratePInvoke */
74 StylusPoint () { SetObjectType (Type::STYLUSPOINT); }
77 // Property Accessors
79 /* @GenerateCBinding,GeneratePInvoke */
80 void SetPressureFactor (double factor);
81 /* @GenerateCBinding,GeneratePInvoke */
82 double GetPressureFactor ();
84 /* @GenerateCBinding,GeneratePInvoke */
85 void SetX (double x);
86 /* @GenerateCBinding,GeneratePInvoke */
87 double GetX ();
89 /* @GenerateCBinding,GeneratePInvoke */
90 void SetY (double y);
91 /* @GenerateCBinding,GeneratePInvoke */
92 double GetY ();
96 /* @Namespace=System.Windows.Input */
97 class StylusPointCollection : public DependencyObjectCollection {
98 protected:
99 virtual bool CanAdd (Value *value);
101 virtual ~StylusPointCollection () {}
103 public:
104 /* @GenerateCBinding,GeneratePInvoke */
105 StylusPointCollection () { SetObjectType (Type::STYLUSPOINT_COLLECTION); }
107 virtual Type::Kind GetElementType () { return Type::STYLUSPOINT; }
109 /* @GenerateCBinding,GeneratePInvoke */
110 double AddStylusPoints (StylusPointCollection *stylusPointCollection);
112 Rect GetBounds ();
115 /* @Namespace=System.Windows.Input */
116 class TouchDevice : public DependencyObject {
117 protected:
118 virtual ~TouchDevice () {}
120 public:
121 /* @PropertyType=UIElement,ManagedSetterAccess=Internal,GenerateAccessors */
122 const static int DirectlyOverProperty;
123 /* @PropertyType=gint32,ManagedSetterAccess=Internal,GenerateAccessors */
124 const static int IdProperty;
126 /* @GenerateCBinding,GeneratePInvoke */
127 TouchDevice () { SetObjectType (Type::TOUCHDEVICE); }
130 // Property Accessors
133 /* @GenerateCBinding,GeneratePInvoke */
134 void SetDirectlyOver (UIElement *element);
135 /* @GenerateCBinding,GeneratePInvoke */
136 UIElement *GetDirectlyOver ();
138 /* @GenerateCBinding,GeneratePInvoke */
139 void SetId (int id);
140 /* @GenerateCBinding,GeneratePInvoke */
141 int GetId ();
144 /* @Namespace=System.Windows.Input */
145 class TouchPoint : public DependencyObject {
146 protected:
147 virtual ~TouchPoint () {}
149 public:
150 /* @PropertyType=TouchAction,ManagedSetterAccess=Internal,GenerateAccessors */
151 const static int ActionProperty;
152 /* @PropertyType=Point,ManagedSetterAccess=Internal,GenerateAccessors */
153 const static int PositionProperty;
154 /* @PropertyType=Size,ManagedSetterAccess=Internal,GenerateAccessors */
155 const static int SizeProperty;
156 /* @PropertyType=TouchDevice,ManagedSetterAccess=Internal,GenerateAccessors */
157 const static int TouchDeviceProperty;
159 /* @GenerateCBinding,GeneratePInvoke */
160 TouchPoint () { SetObjectType (Type::TOUCHPOINT); }
163 // Property Accessors
166 /* @GenerateCBinding,GeneratePInvoke */
167 void SetAction (TouchAction action);
168 /* @GenerateCBinding,GeneratePInvoke */
169 TouchAction GetAction ();
171 /* @GenerateCBinding,GeneratePInvoke */
172 void SetPosition (Point *position);
173 /* @GenerateCBinding,GeneratePInvoke */
174 Point *GetPosition ();
176 /* @GenerateCBinding,GeneratePInvoke */
177 void SetSize (Size *size);
178 /* @GenerateCBinding,GeneratePInvoke */
179 Size *GetSize ();
181 /* @GenerateCBinding,GeneratePInvoke */
182 void SetTouchDevice (TouchDevice *device);
183 /* @GenerateCBinding,GeneratePInvoke */
184 TouchDevice *GetTouchDevice ();
188 /* @Namespace=System.Windows.Input */
189 class TouchPointCollection : public DependencyObjectCollection {
190 protected:
191 virtual ~TouchPointCollection () {}
193 public:
194 /* @GenerateCBinding,GeneratePInvoke */
195 TouchPointCollection () { SetObjectType (Type::TOUCHPOINT_COLLECTION); }
197 virtual Type::Kind GetElementType () { return Type::TOUCHPOINT; }
201 /* @Namespace=System.Windows.Ink */
202 class DrawingAttributes : public DependencyObject {
203 protected:
204 virtual ~DrawingAttributes () {}
206 public:
207 /* @PropertyType=Color,DefaultValue=Color (0xFF000000),ManagedFieldAccess=Private,GenerateAccessors */
208 const static int ColorProperty;
209 /* @PropertyType=Color,DefaultValue=Color (0x00000000),ManagedFieldAccess=Private,GenerateAccessors */
210 const static int OutlineColorProperty;
211 /* @PropertyType=double,DefaultValue=3.0,ManagedFieldAccess=Private,GenerateAccessors */
212 const static int HeightProperty;
213 /* @PropertyType=double,DefaultValue=3.0,ManagedFieldAccess=Private,GenerateAccessors */
214 const static int WidthProperty;
216 /* @GenerateCBinding,GeneratePInvoke */
217 DrawingAttributes () { SetObjectType (Type::DRAWINGATTRIBUTES); }
219 void Render (cairo_t *cr, StylusPointCollection *collection);
220 static void RenderWithoutDrawingAttributes (cairo_t *cr, StylusPointCollection *collection);
223 // Property Accessors
225 void SetColor (Color *color);
226 Color *GetColor ();
228 void SetOutlineColor (Color *color);
229 Color *GetOutlineColor ();
231 void SetHeight (double height);
232 double GetHeight ();
234 void SetWidth (double width);
235 double GetWidth ();
239 /* @Namespace=System.Windows.Ink */
240 class Stroke : public DependencyObject {
241 Rect old_bounds;
242 Rect bounds;
243 Rect dirty;
245 Rect AddStylusPointToBounds (StylusPoint *stylus_point, const Rect &bounds);
246 void ComputeBounds ();
248 bool HitTestEndcapSegment (Point c, double w, double h, Point p1, Point p2);
249 bool HitTestEndcapPoint (Point c, double w, double h, Point p1);
250 bool HitTestEndcap (Point p, double w, double h, StylusPointCollection *stylusPoints);
252 bool HitTestSegmentSegment (Point stroke_p1, Point stroke_p2, double w, double h, Point p1, Point p2);
253 bool HitTestSegmentPoint (Point stroke_p1, Point stroke_p2, double w, double h, Point p1);
254 bool HitTestSegment (Point stroke_p1, Point stroke_p2, double w, double h, StylusPointCollection *stylusPoints);
256 protected:
257 virtual ~Stroke () {}
259 public:
260 /* @PropertyType=DrawingAttributes,AutoCreateValue,ManagedFieldAccess=Private,GenerateAccessors */
261 const static int DrawingAttributesProperty;
262 /* @PropertyType=StylusPointCollection,AutoCreateValue,ManagedFieldAccess=Private,GenerateAccessors */
263 const static int StylusPointsProperty;
265 /* @GenerateCBinding,GeneratePInvoke */
266 Stroke ();
268 /* @GenerateCBinding,GeneratePInvoke */
269 bool HitTest (StylusPointCollection *stylusPoints);
271 Rect GetOldBounds () { return old_bounds; }
272 Rect GetBounds () { return bounds; }
274 void ResetDirty () { dirty = Rect (); }
275 Rect GetDirty () { return dirty; }
277 virtual void OnCollectionItemChanged (Collection *col, DependencyObject *obj, PropertyChangedEventArgs *args);
278 virtual void OnCollectionChanged (Collection *col, CollectionChangedEventArgs *args);
279 virtual void OnPropertyChanged (PropertyChangedEventArgs *args, MoonError *error);
280 virtual void OnSubPropertyChanged (DependencyProperty *prop, DependencyObject *obj, PropertyChangedEventArgs *subobj_args);
283 // Property Accessors
285 void SetDrawingAttributes (DrawingAttributes *attrs);
286 DrawingAttributes *GetDrawingAttributes ();
288 void SetStylusPoints (StylusPointCollection *points);
289 StylusPointCollection *GetStylusPoints ();
293 /* @Namespace=System.Windows.Ink */
294 class StrokeCollection : public DependencyObjectCollection {
295 protected:
296 virtual bool CanAdd (Value *value);
298 virtual ~StrokeCollection () {}
300 public:
301 /* @GenerateCBinding,GeneratePInvoke */
302 StrokeCollection () { SetObjectType (Type::STROKE_COLLECTION); }
304 virtual Type::Kind GetElementType () { return Type::STROKE; }
306 virtual bool AddedToCollection (Value *value, MoonError *error);
308 /* @GenerateCBinding,GeneratePInvoke */
309 StrokeCollection *HitTest (StylusPointCollection *stylusPoints);
311 Rect GetBounds ();
315 /* @Namespace=System.Windows.Controls */
316 class InkPresenter : public Canvas {
317 Rect render_bounds;
319 protected:
320 virtual ~InkPresenter () {}
322 virtual void PostRender (cairo_t *cr, Region *region, bool front_to_back);
324 public:
325 /* @PropertyType=StrokeCollection,AutoCreateValue,GenerateAccessors */
326 const static int StrokesProperty;
328 /* @GenerateCBinding,GeneratePInvoke */
329 InkPresenter ();
331 virtual void OnCollectionChanged (Collection *col, CollectionChangedEventArgs *args);
332 virtual void OnCollectionItemChanged (Collection *col, DependencyObject *obj, PropertyChangedEventArgs *args);
333 virtual void OnPropertyChanged (PropertyChangedEventArgs *args, MoonError *error);
335 virtual void ComputeBounds ();
337 virtual Rect GetRenderBounds ();
339 virtual void ShiftPosition (Point p);
342 // Property Accessors
344 void SetStrokes (StrokeCollection *strokes);
345 StrokeCollection *GetStrokes ();
349 G_BEGIN_DECLS
351 /* @GeneratePInvoke */
352 void stroke_get_bounds (Stroke *stroke, /* @MarshalAs=Rect,IsRef */ Rect *bounds);
353 /* @GeneratePInvoke */
354 void stroke_collection_get_bounds (StrokeCollection *collection, /* @MarshalAs=Rect,IsRef */ Rect *bounds);
356 G_END_DECLS
358 #endif /* __STYLUS_H__ */