in class/System.Windows/Mono:
[moon.git] / src / eventargs.h
blob3b88708850e7a26962cf8c80ad226fdcf68bf122
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"
21 #include "error.h"
23 class StylusInfo;
24 class StylusPointCollection;
25 class UIElement;
28 * EventArgs needs to be ref counted since js can keep objects around until
29 * after the event has been emitted.
32 /* @Namespace=None */
33 class EventArgs : public DependencyObject {
34 public:
35 EventArgs ();
37 protected:
38 virtual ~EventArgs ();
39 EventArgs (Type::Kind type);
42 class PropertyChangedEventArgs : public EventArgs {
43 public:
44 PropertyChangedEventArgs (DependencyProperty *p, int pid, Value *ov, Value *nv) : obj (p), id (pid), old_value(ov), new_value (nv) { }
46 /* @GenerateCBinding,GeneratePInvoke */
47 DependencyProperty *GetProperty () { return obj; }
48 /* @GenerateCBinding,GeneratePInvoke */
49 int GetId () { return id; }
50 /* @GenerateCBinding,GeneratePInvoke */
51 Value* GetOldValue () { return old_value; }
52 /* @GenerateCBinding,GeneratePInvoke */
53 Value* GetNewValue () { return new_value; }
55 private:
56 DependencyProperty *obj;
57 int id;
59 Value *old_value;
60 Value *new_value;
63 /* @Namespace=None */
64 class RenderingEventArgs : public EventArgs {
65 public:
66 RenderingEventArgs (TimeSpan renderingTime);
68 /* @GenerateCBinding,GeneratePInvoke */
69 TimeSpan GetRenderingTime ();
71 protected:
72 virtual ~RenderingEventArgs ();
74 private:
76 TimeSpan renderingTime;
79 enum CollectionChangedAction {
80 CollectionChangedActionAdd,
81 CollectionChangedActionRemove,
82 CollectionChangedActionReplace,
83 CollectionChangedActionClearing,
84 CollectionChangedActionCleared,
87 /* @Namespace=None */
88 class CollectionChangedEventArgs : public EventArgs {
89 public:
90 /* @GenerateCBinding,GeneratePInvoke */
91 CollectionChangedEventArgs ();
93 CollectionChangedEventArgs (CollectionChangedAction action, Value *new_value, Value *old_value, int index);
95 /* @GenerateCBinding,GeneratePInvoke */
96 void SetChangedAction (CollectionChangedAction action);
98 /* @GenerateCBinding,GeneratePInvoke */
99 CollectionChangedAction GetChangedAction ();
101 /* @GenerateCBinding,GeneratePInvoke */
102 void SetNewItem (Value *item);
104 /* @GenerateCBinding,GeneratePInvoke */
105 Value *GetNewItem ();
107 /* @GenerateCBinding,GeneratePInvoke */
108 void SetOldItem (Value *item);
110 /* @GenerateCBinding,GeneratePInvoke */
111 Value *GetOldItem ();
113 /* @GenerateCBinding,GeneratePInvoke */
114 void SetIndex (int index);
116 /* @GenerateCBinding,GeneratePInvoke */
117 int GetIndex ();
119 protected:
120 virtual ~CollectionChangedEventArgs ();
123 private:
124 CollectionChangedAction action;
125 Value *old_item;
126 Value *new_item;
127 int index;
130 /* @Namespace=None */
131 class CollectionItemChangedEventArgs : public EventArgs {
132 public:
133 CollectionItemChangedEventArgs (DependencyObject *collectionItem,
134 DependencyProperty *property,
135 Value *oldValue,
136 Value *newValue)
138 this->collectionItem = collectionItem;
139 this->property = property;
140 this->oldValue = oldValue;
141 this->newValue = newValue;
144 DependencyObject* GetCollectionItem() { return collectionItem; }
145 DependencyProperty* GetProperty() { return property; }
146 Value* GetOldValue () { return oldValue; }
147 Value* GetNewValue () { return newValue; }
149 private:
150 DependencyObject *collectionItem;
151 DependencyProperty *property;
152 Value *oldValue;
153 Value *newValue;
156 /* @Namespace=None */
157 class DownloadProgressEventArgs : public EventArgs {
158 private:
159 double progress;
161 protected:
162 virtual ~DownloadProgressEventArgs ();
164 public:
165 DownloadProgressEventArgs ();
166 DownloadProgressEventArgs (double progress);
168 void SetProgress (double progress);
170 /* @GenerateCBinding,GeneratePInvoke */
171 double GetProgress ();
174 /* @Namespace=None */
175 class RoutedEventArgs : public EventArgs {
176 public:
177 /* @GenerateCBinding,GeneratePInvoke */
178 RoutedEventArgs ();
180 RoutedEventArgs (DependencyObject *source);
182 /* @GenerateCBinding,GeneratePInvoke */
183 DependencyObject *GetSource ();
185 /* @GenerateCBinding,GeneratePInvoke */
186 void SetSource(DependencyObject *el);
188 /* @GenerateCBinding,GeneratePInvoke */
189 void SetHandled (bool handled);
191 /* @GenerateCBinding,GeneratePInvoke */
192 bool GetHandled ();
194 protected:
195 virtual ~RoutedEventArgs ();
196 RoutedEventArgs (DependencyObject *source, Type::Kind kind);
197 RoutedEventArgs (Type::Kind kind);
199 private:
200 DependencyObject *source;
201 bool handled;
204 /* @Namespace=None */
205 class KeyEventArgs : public RoutedEventArgs {
206 public:
207 /* @GenerateCBinding,GeneratePInvoke */
208 KeyEventArgs ();
209 KeyEventArgs (GdkEventKey *event);
211 /* @GenerateCBinding,GeneratePInvoke */
212 int GetKey ();
214 /* @GenerateCBinding,GeneratePInvoke */
215 int GetPlatformKeyCode ();
217 // accessors for the native GdkEventKey
218 GdkEventKey *GetEvent ();
219 GdkModifierType GetModifiers ();
220 gunichar GetUnicode ();
221 guint GetKeyVal ();
222 bool IsModifier ();
224 protected:
225 virtual ~KeyEventArgs ();
227 private:
228 GdkEventKey *event;
231 /* @Namespace=None */
232 class MouseEventArgs : public RoutedEventArgs {
233 public:
234 /* @GenerateCBinding,GeneratePInvoke */
235 MouseEventArgs ();
236 MouseEventArgs (GdkEvent *event);
238 GdkEvent *GetEvent () { return event; }
240 int GetState ();
242 /* @GenerateCBinding,GeneratePInvoke */
243 void GetPosition (UIElement *relative_to, double *x, double *y);
245 /* @GenerateCBinding,GeneratePInvoke */
246 StylusInfo *GetStylusInfo ();
248 /* @GenerateCBinding,GeneratePInvoke */
249 StylusPointCollection *GetStylusPoints (UIElement *ink_presenter);
251 protected:
252 virtual ~MouseEventArgs ();
253 MouseEventArgs (Type::Kind kind, GdkEvent *event);
255 GdkEvent *event;
258 /* @Namespace=None */
259 class MouseButtonEventArgs : public MouseEventArgs {
260 public:
261 /* @GenerateCBinding,GeneratePInvoke */
262 MouseButtonEventArgs ();
263 MouseButtonEventArgs (GdkEvent *event);
265 int GetButton ();
266 int GetClickCount ();
268 protected:
269 virtual ~MouseButtonEventArgs ();
272 /* @Namespace=None */
273 class MouseWheelEventArgs : public MouseEventArgs {
274 public:
275 /* @GenerateCBinding,GeneratePInvoke */
276 MouseWheelEventArgs ();
277 MouseWheelEventArgs (GdkEvent *event);
279 /* @GenerateCBinding,GeneratePInvoke */
280 int GetWheelDelta ();
282 protected:
283 virtual ~MouseWheelEventArgs ();
287 /* @Namespace=None,ManagedDependencyProperties=None */
288 class ErrorEventArgs : public EventArgs {
289 private:
290 MoonError *error;
291 void Initialize (Type::Kind kind, ErrorEventArgsType type, const MoonError &error, int extended_error_code, const char *extended_msg);
292 int extended_code;
293 char *extended_message;
294 ErrorEventArgsType error_type;
296 protected:
297 virtual ~ErrorEventArgs ();
298 ErrorEventArgs (Type::Kind kind, ErrorEventArgsType type, const MoonError error);
300 public:
301 ErrorEventArgs (ErrorEventArgsType type, MoonError error);
302 ErrorEventArgs (ErrorEventArgsType type, MoonError error, int extended_code, const char *extended_msg);
304 /* @GenerateCBinding,GeneratePInvoke */
305 gpointer GetMoonError () { return error; }
307 /* @GenerateCBinding,GeneratePInvoke */
308 const char *GetErrorMessage () { return error->message; }
309 /* @GenerateCBinding,GeneratePInvoke */
310 int GetErrorCode () { return error->code; }
311 /* @GenerateCBinding,GeneratePInvoke */
312 int GetErrorType () { return error_type; }
314 // To match SL behaviour we need to match SL error messages, which aren't all that helpful
315 // This is here to keep extra error information we have,
316 // but don't want to report to the user.
317 // extended_code:
318 // 3 (MEDIA_UNKNOWN_CODEC): used by playlist to determine if we should raise a MediaFailed event or just continue to play the next entry.
319 int GetExtendedCode () { return extended_code; }
320 const char *GetExtendedMessage () { return extended_message; }
323 /* @Namespace=None,ManagedDependencyProperties=None */
324 class ImageErrorEventArgs : public ErrorEventArgs {
325 public:
326 ImageErrorEventArgs (MoonError error);
328 protected:
329 virtual ~ImageErrorEventArgs ();
333 /* @Namespace=None,ManagedDependencyProperties=None */
334 class ParserErrorEventArgs : public ErrorEventArgs {
335 protected:
336 virtual ~ParserErrorEventArgs ();
338 public:
339 ParserErrorEventArgs (const char *msg, const char *file,
340 int line, int column, int error_code,
341 const char *element, const char *attribute);
343 int char_position;
344 int line_number;
345 char *xaml_file;
346 char *xml_element;
347 char *xml_attribute;
350 #endif /* __EVENTARGS_H__ */