2009-06-17 Jeffrey Stedfast <fejj@novell.com>
[moon.git] / src / stylus.h
blob30c0c7801c796477f2cac6edb8a93ac60b7b4893
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 class StylusPoint : public DependencyObject {
56 protected:
57 virtual ~StylusPoint () {}
59 public:
60 /* @PropertyType=double,DefaultValue=0.5,GenerateAccessors */
61 const static int PressureFactorProperty;
62 /* @PropertyType=double,DefaultValue=0.0,GenerateAccessors */
63 const static int XProperty;
64 /* @PropertyType=double,DefaultValue=0.0,GenerateAccessors */
65 const static int YProperty;
67 /* @GenerateCBinding,GeneratePInvoke */
68 StylusPoint () { SetObjectType (Type::STYLUSPOINT); }
71 // Property Accessors
73 /* @GenerateCBinding,GeneratePInvoke */
74 void SetPressureFactor (double factor);
75 /* @GenerateCBinding,GeneratePInvoke */
76 double GetPressureFactor ();
78 /* @GenerateCBinding,GeneratePInvoke */
79 void SetX (double x);
80 /* @GenerateCBinding,GeneratePInvoke */
81 double GetX ();
83 /* @GenerateCBinding,GeneratePInvoke */
84 void SetY (double y);
85 /* @GenerateCBinding,GeneratePInvoke */
86 double GetY ();
90 /* @Namespace=System.Windows.Input */
91 class StylusPointCollection : public DependencyObjectCollection {
92 protected:
93 virtual bool CanAdd (Value *value);
95 virtual ~StylusPointCollection () {}
97 public:
98 /* @GenerateCBinding,GeneratePInvoke */
99 StylusPointCollection () { SetObjectType (Type::STYLUSPOINT_COLLECTION); }
101 virtual Type::Kind GetElementType () { return Type::STYLUSPOINT; }
103 /* @GenerateCBinding,GeneratePInvoke */
104 double AddStylusPoints (StylusPointCollection *stylusPointCollection);
106 Rect GetBounds ();
110 /* @Namespace=System.Windows.Ink */
111 class DrawingAttributes : public DependencyObject {
112 protected:
113 virtual ~DrawingAttributes () {}
115 public:
116 /* @PropertyType=Color,DefaultValue=Color (0xFF000000),ManagedFieldAccess=Private,GenerateAccessors */
117 const static int ColorProperty;
118 /* @PropertyType=Color,DefaultValue=Color (0x00000000),ManagedFieldAccess=Private,GenerateAccessors */
119 const static int OutlineColorProperty;
120 /* @PropertyType=double,DefaultValue=3.0,ManagedFieldAccess=Private,GenerateAccessors */
121 const static int HeightProperty;
122 /* @PropertyType=double,DefaultValue=3.0,ManagedFieldAccess=Private,GenerateAccessors */
123 const static int WidthProperty;
125 /* @GenerateCBinding,GeneratePInvoke */
126 DrawingAttributes () { SetObjectType (Type::DRAWINGATTRIBUTES); }
128 void Render (cairo_t *cr, StylusPointCollection *collection);
129 static void RenderWithoutDrawingAttributes (cairo_t *cr, StylusPointCollection *collection);
132 // Property Accessors
134 void SetColor (Color *color);
135 Color *GetColor ();
137 void SetOutlineColor (Color *color);
138 Color *GetOutlineColor ();
140 void SetHeight (double height);
141 double GetHeight ();
143 void SetWidth (double width);
144 double GetWidth ();
148 /* @Namespace=System.Windows.Ink */
149 class Stroke : public DependencyObject {
150 Rect old_bounds;
151 Rect bounds;
152 Rect dirty;
154 Rect AddStylusPointToBounds (StylusPoint *stylus_point, const Rect &bounds);
155 void ComputeBounds ();
157 bool HitTestEndcapSegment (Point c, double w, double h, Point p1, Point p2);
158 bool HitTestEndcapPoint (Point c, double w, double h, Point p1);
159 bool HitTestEndcap (Point p, double w, double h, StylusPointCollection *stylusPoints);
161 bool HitTestSegmentSegment (Point stroke_p1, Point stroke_p2, double w, double h, Point p1, Point p2);
162 bool HitTestSegmentPoint (Point stroke_p1, Point stroke_p2, double w, double h, Point p1);
163 bool HitTestSegment (Point stroke_p1, Point stroke_p2, double w, double h, StylusPointCollection *stylusPoints);
165 protected:
166 virtual ~Stroke () {}
168 public:
169 /* @PropertyType=DrawingAttributes,AutoCreateValue,ManagedFieldAccess=Private,GenerateAccessors */
170 const static int DrawingAttributesProperty;
171 /* @PropertyType=StylusPointCollection,AutoCreateValue,ManagedFieldAccess=Private,GenerateAccessors */
172 const static int StylusPointsProperty;
174 /* @GenerateCBinding,GeneratePInvoke */
175 Stroke ();
177 /* @GenerateCBinding,GeneratePInvoke */
178 bool HitTest (StylusPointCollection *stylusPoints);
180 Rect GetOldBounds () { return old_bounds; }
181 Rect GetBounds () { return bounds; }
183 void ResetDirty () { dirty = Rect (); }
184 Rect GetDirty () { return dirty; }
186 virtual void OnCollectionItemChanged (Collection *col, DependencyObject *obj, PropertyChangedEventArgs *args);
187 virtual void OnCollectionChanged (Collection *col, CollectionChangedEventArgs *args);
188 virtual void OnPropertyChanged (PropertyChangedEventArgs *args, MoonError *error);
189 virtual void OnSubPropertyChanged (DependencyProperty *prop, DependencyObject *obj, PropertyChangedEventArgs *subobj_args);
192 // Property Accessors
194 void SetDrawingAttributes (DrawingAttributes *attrs);
195 DrawingAttributes *GetDrawingAttributes ();
197 void SetStylusPoints (StylusPointCollection *points);
198 StylusPointCollection *GetStylusPoints ();
202 /* @Namespace=System.Windows.Ink */
203 class StrokeCollection : public DependencyObjectCollection {
204 protected:
205 virtual bool CanAdd (Value *value);
207 virtual ~StrokeCollection () {}
209 public:
210 /* @GenerateCBinding,GeneratePInvoke */
211 StrokeCollection () { SetObjectType (Type::STROKE_COLLECTION); }
213 virtual Type::Kind GetElementType () { return Type::STROKE; }
215 virtual bool AddedToCollection (Value *value, MoonError *error);
217 /* @GenerateCBinding,GeneratePInvoke */
218 StrokeCollection *HitTest (StylusPointCollection *stylusPoints);
220 Rect GetBounds ();
224 /* @Namespace=System.Windows.Controls */
225 class InkPresenter : public Canvas {
226 Rect render_bounds;
228 protected:
229 virtual ~InkPresenter () {}
231 virtual void PostRender (cairo_t *cr, Region *region, bool front_to_back);
233 public:
234 /* @PropertyType=StrokeCollection,AutoCreateValue,GenerateAccessors */
235 const static int StrokesProperty;
237 /* @GenerateCBinding,GeneratePInvoke */
238 InkPresenter ();
240 virtual void OnCollectionChanged (Collection *col, CollectionChangedEventArgs *args);
241 virtual void OnCollectionItemChanged (Collection *col, DependencyObject *obj, PropertyChangedEventArgs *args);
242 virtual void OnPropertyChanged (PropertyChangedEventArgs *args, MoonError *error);
244 virtual void ComputeBounds ();
246 virtual Rect GetRenderBounds ();
248 virtual void ShiftPosition (Point p);
251 // Property Accessors
253 void SetStrokes (StrokeCollection *strokes);
254 StrokeCollection *GetStrokes ();
258 G_BEGIN_DECLS
260 /* @GeneratePInvoke */
261 void stroke_get_bounds (Stroke *stroke, /* @MarshalAs=Rect,IsRef */ Rect *bounds);
262 /* @GeneratePInvoke */
263 void stroke_collection_get_bounds (StrokeCollection *collection, /* @MarshalAs=Rect,IsRef */ Rect *bounds);
265 G_END_DECLS
267 #endif /* __STYLUS_H__ */