1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
5 * Copyright 2007 Novell, Inc. (http://www.novell.com)
7 * See the LICENSE file included with the distribution for details.
11 #ifndef __EVENTARGS_H__
12 #define __EVENTARGS_H__
17 #include <gdk/gdkevents.h>
18 #include "dependencyobject.h"
24 class StylusPointCollection
;
28 * EventArgs needs to be ref counted since js can keep objects around until
29 * after the event has been emitted.
33 class EventArgs
: public DependencyObject
{
38 virtual ~EventArgs ();
39 EventArgs (Type::Kind type
);
42 class PropertyChangedEventArgs
: public EventArgs
{
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
; }
56 DependencyProperty
*obj
;
64 class RenderingEventArgs
: public EventArgs
{
66 RenderingEventArgs (TimeSpan renderingTime
);
68 /* @GenerateCBinding,GeneratePInvoke */
69 TimeSpan
GetRenderingTime ();
72 virtual ~RenderingEventArgs ();
76 TimeSpan renderingTime
;
79 enum CollectionChangedAction
{
80 CollectionChangedActionAdd
,
81 CollectionChangedActionRemove
,
82 CollectionChangedActionReplace
,
83 CollectionChangedActionClearing
,
84 CollectionChangedActionCleared
,
88 class CollectionChangedEventArgs
: public EventArgs
{
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 */
120 virtual ~CollectionChangedEventArgs ();
124 CollectionChangedAction action
;
130 /* @Namespace=None */
131 class CollectionItemChangedEventArgs
: public EventArgs
{
133 CollectionItemChangedEventArgs (DependencyObject
*collectionItem
,
134 DependencyProperty
*property
,
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
; }
150 DependencyObject
*collectionItem
;
151 DependencyProperty
*property
;
156 /* @Namespace=None */
157 class DownloadProgressEventArgs
: public EventArgs
{
162 virtual ~DownloadProgressEventArgs ();
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
{
177 /* @GenerateCBinding,GeneratePInvoke */
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 */
195 virtual ~RoutedEventArgs ();
196 RoutedEventArgs (DependencyObject
*source
, Type::Kind kind
);
197 RoutedEventArgs (Type::Kind kind
);
200 DependencyObject
*source
;
204 /* @Namespace=None */
205 class KeyEventArgs
: public RoutedEventArgs
{
207 /* @GenerateCBinding,GeneratePInvoke */
209 KeyEventArgs (GdkEventKey
*event
);
211 /* @GenerateCBinding,GeneratePInvoke */
214 /* @GenerateCBinding,GeneratePInvoke */
215 int GetPlatformKeyCode ();
217 // accessors for the native GdkEventKey
218 GdkEventKey
*GetEvent ();
219 GdkModifierType
GetModifiers ();
220 gunichar
GetUnicode ();
225 virtual ~KeyEventArgs ();
231 /* @Namespace=None */
232 class MouseEventArgs
: public RoutedEventArgs
{
234 /* @GenerateCBinding,GeneratePInvoke */
236 MouseEventArgs (GdkEvent
*event
);
238 GdkEvent
*GetEvent () { return event
; }
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
);
252 virtual ~MouseEventArgs ();
253 MouseEventArgs (Type::Kind kind
, GdkEvent
*event
);
258 /* @Namespace=None */
259 class MouseButtonEventArgs
: public MouseEventArgs
{
261 /* @GenerateCBinding,GeneratePInvoke */
262 MouseButtonEventArgs ();
263 MouseButtonEventArgs (GdkEvent
*event
);
266 int GetClickCount ();
269 virtual ~MouseButtonEventArgs ();
272 /* @Namespace=None */
273 class MouseWheelEventArgs
: public MouseEventArgs
{
275 /* @GenerateCBinding,GeneratePInvoke */
276 MouseWheelEventArgs ();
277 MouseWheelEventArgs (GdkEvent
*event
);
279 /* @GenerateCBinding,GeneratePInvoke */
280 int GetWheelDelta ();
283 virtual ~MouseWheelEventArgs ();
287 /* @Namespace=None,ManagedDependencyProperties=None */
288 class ErrorEventArgs
: public EventArgs
{
291 void Initialize (Type::Kind kind
, ErrorEventArgsType type
, const MoonError
&error
, int extended_error_code
, const char *extended_msg
);
293 char *extended_message
;
294 ErrorEventArgsType error_type
;
297 virtual ~ErrorEventArgs ();
298 ErrorEventArgs (Type::Kind kind
, ErrorEventArgsType type
, const MoonError error
);
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.
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
{
326 ImageErrorEventArgs (MoonError error
);
329 virtual ~ImageErrorEventArgs ();
333 /* @Namespace=None,ManagedDependencyProperties=None */
334 class ParserErrorEventArgs
: public ErrorEventArgs
{
336 virtual ~ParserErrorEventArgs ();
339 ParserErrorEventArgs (const char *msg
, const char *file
,
340 int line
, int column
, int error_code
,
341 const char *element
, const char *attribute
);
350 #endif /* __EVENTARGS_H__ */