2009-12-01 Jeffrey Stedfast <fejj@novell.com>
[moon.git] / src / stylus.h
blob73f69e2981c83b001c509eed6a7934d1422bb281
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
28 /* @Namespace=System.Windows.Input */
29 class StylusInfo : public DependencyObject {
30 protected:
31 virtual ~StylusInfo () {}
33 public:
34 /* @PropertyType=TabletDeviceType,ManagedPropertyType=int,DefaultValue=TabletDeviceTypeMouse,GenerateAccessors */
35 const static int DeviceTypeProperty;
36 /* @PropertyType=bool,DefaultValue=false,GenerateAccessors */
37 const static int IsInvertedProperty;
39 /* @ManagedAccess=Internal,GenerateCBinding,GeneratePInvoke */
40 StylusInfo () { SetObjectType (Type::STYLUSINFO); }
43 // Property Accessors
45 void SetDeviceType (TabletDeviceType type);
46 TabletDeviceType GetDeviceType ();
48 void SetIsInverted (bool inverted);
49 bool GetIsInverted ();
53 /* @Namespace=None */
54 /* @ManagedDependencyProperties=Manual */ // It's a managed struct
55 /* @ManagedEvents=Manual */ // It's a managed struct
56 class StylusPoint : public DependencyObject {
57 protected:
58 virtual ~StylusPoint () {}
60 public:
61 /* @PropertyType=double,DefaultValue=0.5,GenerateAccessors */
62 const static int PressureFactorProperty;
63 /* @PropertyType=double,DefaultValue=0.0,GenerateAccessors */
64 const static int XProperty;
65 /* @PropertyType=double,DefaultValue=0.0,GenerateAccessors */
66 const static int YProperty;
68 /* @GenerateCBinding,GeneratePInvoke */
69 StylusPoint () { SetObjectType (Type::STYLUSPOINT); }
72 // Property Accessors
74 /* @GenerateCBinding,GeneratePInvoke */
75 void SetPressureFactor (double factor);
76 /* @GenerateCBinding,GeneratePInvoke */
77 double GetPressureFactor ();
79 /* @GenerateCBinding,GeneratePInvoke */
80 void SetX (double x);
81 /* @GenerateCBinding,GeneratePInvoke */
82 double GetX ();
84 /* @GenerateCBinding,GeneratePInvoke */
85 void SetY (double y);
86 /* @GenerateCBinding,GeneratePInvoke */
87 double GetY ();
91 /* @Namespace=System.Windows.Input */
92 class StylusPointCollection : public DependencyObjectCollection {
93 protected:
94 virtual bool CanAdd (Value *value);
96 virtual ~StylusPointCollection () {}
98 public:
99 /* @GenerateCBinding,GeneratePInvoke */
100 StylusPointCollection () { SetObjectType (Type::STYLUSPOINT_COLLECTION); }
102 virtual Type::Kind GetElementType () { return Type::STYLUSPOINT; }
104 /* @GenerateCBinding,GeneratePInvoke */
105 double AddStylusPoints (StylusPointCollection *stylusPointCollection);
107 Rect GetBounds ();
111 /* @Namespace=System.Windows.Ink */
112 class DrawingAttributes : public DependencyObject {
113 protected:
114 virtual ~DrawingAttributes () {}
116 public:
117 /* @PropertyType=Color,DefaultValue=Color (0xFF000000),ManagedFieldAccess=Private,GenerateAccessors */
118 const static int ColorProperty;
119 /* @PropertyType=Color,DefaultValue=Color (0x00000000),ManagedFieldAccess=Private,GenerateAccessors */
120 const static int OutlineColorProperty;
121 /* @PropertyType=double,DefaultValue=3.0,ManagedFieldAccess=Private,GenerateAccessors */
122 const static int HeightProperty;
123 /* @PropertyType=double,DefaultValue=3.0,ManagedFieldAccess=Private,GenerateAccessors */
124 const static int WidthProperty;
126 /* @GenerateCBinding,GeneratePInvoke */
127 DrawingAttributes () { SetObjectType (Type::DRAWINGATTRIBUTES); }
129 void Render (cairo_t *cr, StylusPointCollection *collection);
130 static void RenderWithoutDrawingAttributes (cairo_t *cr, StylusPointCollection *collection);
133 // Property Accessors
135 void SetColor (Color *color);
136 Color *GetColor ();
138 void SetOutlineColor (Color *color);
139 Color *GetOutlineColor ();
141 void SetHeight (double height);
142 double GetHeight ();
144 void SetWidth (double width);
145 double GetWidth ();
149 /* @Namespace=System.Windows.Ink */
150 class Stroke : public DependencyObject {
151 Rect old_bounds;
152 Rect bounds;
153 Rect dirty;
155 Rect AddStylusPointToBounds (StylusPoint *stylus_point, const Rect &bounds);
156 void ComputeBounds ();
158 bool HitTestEndcapSegment (Point c, double w, double h, Point p1, Point p2);
159 bool HitTestEndcapPoint (Point c, double w, double h, Point p1);
160 bool HitTestEndcap (Point p, double w, double h, StylusPointCollection *stylusPoints);
162 bool HitTestSegmentSegment (Point stroke_p1, Point stroke_p2, double w, double h, Point p1, Point p2);
163 bool HitTestSegmentPoint (Point stroke_p1, Point stroke_p2, double w, double h, Point p1);
164 bool HitTestSegment (Point stroke_p1, Point stroke_p2, double w, double h, StylusPointCollection *stylusPoints);
166 protected:
167 virtual ~Stroke () {}
169 public:
170 /* @PropertyType=DrawingAttributes,AutoCreateValue,ManagedFieldAccess=Private,GenerateAccessors */
171 const static int DrawingAttributesProperty;
172 /* @PropertyType=StylusPointCollection,AutoCreateValue,ManagedFieldAccess=Private,GenerateAccessors */
173 const static int StylusPointsProperty;
175 /* @GenerateCBinding,GeneratePInvoke */
176 Stroke ();
178 /* @GenerateCBinding,GeneratePInvoke */
179 bool HitTest (StylusPointCollection *stylusPoints);
181 Rect GetOldBounds () { return old_bounds; }
182 Rect GetBounds () { return bounds; }
184 void ResetDirty () { dirty = Rect (); }
185 Rect GetDirty () { return dirty; }
187 virtual void OnCollectionItemChanged (Collection *col, DependencyObject *obj, PropertyChangedEventArgs *args);
188 virtual void OnCollectionChanged (Collection *col, CollectionChangedEventArgs *args);
189 virtual void OnPropertyChanged (PropertyChangedEventArgs *args, MoonError *error);
190 virtual void OnSubPropertyChanged (DependencyProperty *prop, DependencyObject *obj, PropertyChangedEventArgs *subobj_args);
193 // Property Accessors
195 void SetDrawingAttributes (DrawingAttributes *attrs);
196 DrawingAttributes *GetDrawingAttributes ();
198 void SetStylusPoints (StylusPointCollection *points);
199 StylusPointCollection *GetStylusPoints ();
203 /* @Namespace=System.Windows.Ink */
204 class StrokeCollection : public DependencyObjectCollection {
205 protected:
206 virtual bool CanAdd (Value *value);
208 virtual ~StrokeCollection () {}
210 public:
211 /* @GenerateCBinding,GeneratePInvoke */
212 StrokeCollection () { SetObjectType (Type::STROKE_COLLECTION); }
214 virtual Type::Kind GetElementType () { return Type::STROKE; }
216 virtual bool AddedToCollection (Value *value, MoonError *error);
218 /* @GenerateCBinding,GeneratePInvoke */
219 StrokeCollection *HitTest (StylusPointCollection *stylusPoints);
221 Rect GetBounds ();
225 /* @Namespace=System.Windows.Controls */
226 class InkPresenter : public Canvas {
227 Rect render_bounds;
229 protected:
230 virtual ~InkPresenter () {}
232 virtual void PostRender (cairo_t *cr, Region *region, bool front_to_back);
234 public:
235 /* @PropertyType=StrokeCollection,AutoCreateValue,GenerateAccessors */
236 const static int StrokesProperty;
238 /* @GenerateCBinding,GeneratePInvoke */
239 InkPresenter ();
241 virtual void OnCollectionChanged (Collection *col, CollectionChangedEventArgs *args);
242 virtual void OnCollectionItemChanged (Collection *col, DependencyObject *obj, PropertyChangedEventArgs *args);
243 virtual void OnPropertyChanged (PropertyChangedEventArgs *args, MoonError *error);
245 virtual void ComputeBounds ();
247 virtual Rect GetRenderBounds ();
249 virtual void ShiftPosition (Point p);
252 // Property Accessors
254 void SetStrokes (StrokeCollection *strokes);
255 StrokeCollection *GetStrokes ();
259 G_BEGIN_DECLS
261 /* @GeneratePInvoke */
262 void stroke_get_bounds (Stroke *stroke, /* @MarshalAs=Rect,IsRef */ Rect *bounds);
263 /* @GeneratePInvoke */
264 void stroke_collection_get_bounds (StrokeCollection *collection, /* @MarshalAs=Rect,IsRef */ Rect *bounds);
266 G_END_DECLS
268 #endif /* __STYLUS_H__ */