just kick off another build
[moon.git] / src / eventargs.h
blob19978e0f5352acb2ad4012d6d9bcbbe9655f91fb
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /*
3 * eventargs.h
5 * Copyright 2007 Novell, Inc. (http://www.novell.com)
7 * See the LICENSE file included with the distribution for details.
8 *
9 */
11 #ifndef __EVENTARGS_H__
12 #define __EVENTARGS_H__
14 #include <glib.h>
16 #include <cairo.h>
17 #include <gdk/gdkevents.h>
18 #include "dependencyobject.h"
19 #include "keyboard.h"
20 #include "enums.h"
22 class StylusInfo;
23 class StylusPointCollection;
24 class UIElement;
27 * EventArgs needs to be ref counted since js can keep objects around until
28 * after the event has been emitted.
31 /* @Namespace=None */
32 class EventArgs : public DependencyObject {
33 public:
34 EventArgs ();
36 protected:
37 virtual ~EventArgs ();
38 EventArgs (Type::Kind type);
41 /* @Namespace=None */
42 class RenderingEventArgs : public EventArgs {
43 public:
44 RenderingEventArgs (TimeSpan renderingTime);
46 /* @GenerateCBinding,GeneratePInvoke */
47 TimeSpan GetRenderingTime ();
49 protected:
50 virtual ~RenderingEventArgs ();
52 private:
54 TimeSpan renderingTime;
57 enum CollectionChangedAction {
58 CollectionChangedActionAdd,
59 CollectionChangedActionRemove,
60 CollectionChangedActionReplace,
61 CollectionChangedActionClearing,
62 CollectionChangedActionCleared,
65 /* @Namespace=None */
66 class CollectionChangedEventArgs : public EventArgs {
67 public:
68 /* @GenerateCBinding,GeneratePInvoke */
69 CollectionChangedEventArgs ();
71 CollectionChangedEventArgs (CollectionChangedAction action, Value *new_value, Value *old_value, int index);
73 /* @GenerateCBinding,GeneratePInvoke */
74 void SetChangedAction (CollectionChangedAction action);
76 /* @GenerateCBinding,GeneratePInvoke */
77 CollectionChangedAction GetChangedAction ();
79 /* @GenerateCBinding,GeneratePInvoke */
80 void SetNewItem (Value *item);
82 /* @GenerateCBinding,GeneratePInvoke */
83 Value *GetNewItem ();
85 /* @GenerateCBinding,GeneratePInvoke */
86 void SetOldItem (Value *item);
88 /* @GenerateCBinding,GeneratePInvoke */
89 Value *GetOldItem ();
91 /* @GenerateCBinding,GeneratePInvoke */
92 void SetIndex (int index);
94 /* @GenerateCBinding,GeneratePInvoke */
95 int GetIndex ();
97 protected:
98 virtual ~CollectionChangedEventArgs ();
101 private:
102 CollectionChangedAction action;
103 Value *old_item;
104 Value *new_item;
105 int index;
108 /* @Namespace=None */
109 class CollectionItemChangedEventArgs : public EventArgs {
110 public:
111 CollectionItemChangedEventArgs (DependencyObject *collectionItem,
112 DependencyProperty *property,
113 Value *oldValue,
114 Value *newValue)
116 this->collectionItem = collectionItem;
117 this->property = property;
118 this->oldValue = oldValue;
119 this->newValue = newValue;
122 DependencyObject* GetCollectionItem() { return collectionItem; }
123 DependencyProperty* GetProperty() { return property; }
124 Value* GetOldValue () { return oldValue; }
125 Value* GetNewValue () { return newValue; }
127 private:
128 DependencyObject *collectionItem;
129 DependencyProperty *property;
130 Value *oldValue;
131 Value *newValue;
134 /* @Namespace=None */
135 class DownloadProgressEventArgs : public EventArgs {
136 private:
137 double progress;
139 protected:
140 virtual ~DownloadProgressEventArgs ();
142 public:
143 DownloadProgressEventArgs ();
144 DownloadProgressEventArgs (double progress);
146 void SetProgress (double progress);
148 /* @GenerateCBinding,GeneratePInvoke */
149 double GetProgress ();
152 /* @Namespace=None */
153 class RoutedEventArgs : public EventArgs {
154 public:
155 /* @GenerateCBinding,GeneratePInvoke */
156 RoutedEventArgs ();
158 RoutedEventArgs (DependencyObject *source);
160 /* @GenerateCBinding,GeneratePInvoke */
161 DependencyObject *GetSource ();
163 /* @GenerateCBinding,GeneratePInvoke */
164 void SetSource(DependencyObject *el);
166 /* @GenerateCBinding,GeneratePInvoke */
167 void SetHandled (bool handled);
169 /* @GenerateCBinding,GeneratePInvoke */
170 bool GetHandled ();
172 protected:
173 virtual ~RoutedEventArgs ();
174 RoutedEventArgs (DependencyObject *source, Type::Kind kind);
175 RoutedEventArgs (Type::Kind kind);
177 private:
178 DependencyObject *source;
179 bool handled;
182 /* @Namespace=None */
183 class ExceptionRoutedEventArgs : public RoutedEventArgs {
184 protected:
185 virtual ~ExceptionRoutedEventArgs ();
187 public:
188 ExceptionRoutedEventArgs ();
192 /* @Namespace=None */
193 class KeyEventArgs : public RoutedEventArgs {
194 public:
195 /* @GenerateCBinding,GeneratePInvoke */
196 KeyEventArgs ();
197 KeyEventArgs (GdkEventKey *event);
199 /* @GenerateCBinding,GeneratePInvoke */
200 int GetKey ();
202 /* @GenerateCBinding,GeneratePInvoke */
203 int GetPlatformKeyCode ();
205 // accessors for the native GdkEventKey
206 GdkEventKey *GetEvent ();
207 GdkModifierType GetModifiers ();
208 gunichar GetUnicode ();
209 guint GetKeyVal ();
210 bool IsModifier ();
212 protected:
213 virtual ~KeyEventArgs ();
215 private:
216 GdkEventKey *event;
219 /* @Namespace=None */
220 class MouseEventArgs : public RoutedEventArgs {
221 public:
222 /* @GenerateCBinding,GeneratePInvoke */
223 MouseEventArgs ();
224 MouseEventArgs (GdkEvent *event);
226 GdkEvent *GetEvent () { return event; }
228 int GetState ();
230 int GetButton ();
231 int GetClickCount ();
233 /* @GenerateCBinding,GeneratePInvoke */
234 void GetPosition (UIElement *relative_to, double *x, double *y);
236 /* @GenerateCBinding,GeneratePInvoke */
237 StylusInfo *GetStylusInfo ();
239 /* @GenerateCBinding,GeneratePInvoke */
240 StylusPointCollection *GetStylusPoints (UIElement *ink_presenter);
242 protected:
243 virtual ~MouseEventArgs ();
245 private:
246 GdkEvent *event;
249 /* @Namespace=None */
250 class MouseWheelEventArgs : public RoutedEventArgs {
251 public:
252 /* @GenerateCBinding,GeneratePInvoke */
253 MouseWheelEventArgs ();
254 MouseWheelEventArgs (GdkEvent *event);
256 GdkEvent *GetEvent () { return event; }
258 /* @GenerateCBinding,GeneratePInvoke */
259 int GetWheelDelta ();
261 protected:
262 virtual ~MouseWheelEventArgs ();
264 private:
265 GdkEvent *event;
268 #endif /* __EVENTARGS_H__ */