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
);
43 class PropertyChangedEventArgs
: public EventArgs
{
45 PropertyChangedEventArgs (DependencyProperty
*p
, int pid
, Value
*ov
, Value
*nv
) : obj (p
), id (pid
), old_value(ov
), new_value (nv
) { }
47 /* @GenerateCBinding,GeneratePInvoke */
48 DependencyProperty
*GetProperty () { return obj
; }
49 /* @GenerateCBinding,GeneratePInvoke */
50 int GetId () { return id
; }
51 /* @GenerateCBinding,GeneratePInvoke */
52 Value
* GetOldValue () { return old_value
; }
53 /* @GenerateCBinding,GeneratePInvoke */
54 Value
* GetNewValue () { return new_value
; }
57 DependencyProperty
*obj
;
65 class RenderingEventArgs
: public EventArgs
{
67 RenderingEventArgs (TimeSpan renderingTime
);
69 /* @GenerateCBinding,GeneratePInvoke */
70 TimeSpan
GetRenderingTime ();
73 virtual ~RenderingEventArgs ();
77 TimeSpan renderingTime
;
80 enum CollectionChangedAction
{
81 CollectionChangedActionAdd
,
82 CollectionChangedActionRemove
,
83 CollectionChangedActionReplace
,
84 CollectionChangedActionClearing
,
85 CollectionChangedActionCleared
,
89 class CollectionChangedEventArgs
: public EventArgs
{
91 /* @GenerateCBinding,GeneratePInvoke */
92 CollectionChangedEventArgs ();
94 CollectionChangedEventArgs (CollectionChangedAction action
, Value
*new_value
, Value
*old_value
, int index
);
96 /* @GenerateCBinding,GeneratePInvoke */
97 void SetChangedAction (CollectionChangedAction action
);
99 /* @GenerateCBinding,GeneratePInvoke */
100 CollectionChangedAction
GetChangedAction ();
102 /* @GenerateCBinding,GeneratePInvoke */
103 void SetNewItem (Value
*item
);
105 /* @GenerateCBinding,GeneratePInvoke */
106 Value
*GetNewItem ();
108 /* @GenerateCBinding,GeneratePInvoke */
109 void SetOldItem (Value
*item
);
111 /* @GenerateCBinding,GeneratePInvoke */
112 Value
*GetOldItem ();
114 /* @GenerateCBinding,GeneratePInvoke */
115 void SetIndex (int index
);
117 /* @GenerateCBinding,GeneratePInvoke */
121 virtual ~CollectionChangedEventArgs ();
125 CollectionChangedAction action
;
131 /* @Namespace=None */
132 class CollectionItemChangedEventArgs
: public EventArgs
{
134 CollectionItemChangedEventArgs (DependencyObject
*collectionItem
,
135 DependencyProperty
*property
,
139 this->collectionItem
= collectionItem
;
140 this->property
= property
;
141 this->oldValue
= oldValue
;
142 this->newValue
= newValue
;
145 DependencyObject
* GetCollectionItem() { return collectionItem
; }
146 DependencyProperty
* GetProperty() { return property
; }
147 Value
* GetOldValue () { return oldValue
; }
148 Value
* GetNewValue () { return newValue
; }
151 DependencyObject
*collectionItem
;
152 DependencyProperty
*property
;
157 /* @Namespace=None */
158 class DownloadProgressEventArgs
: public EventArgs
{
163 virtual ~DownloadProgressEventArgs ();
166 DownloadProgressEventArgs ();
167 DownloadProgressEventArgs (double progress
);
169 void SetProgress (double progress
);
171 /* @GenerateCBinding,GeneratePInvoke */
172 double GetProgress ();
175 /* @Namespace=None */
176 class RoutedEventArgs
: public EventArgs
{
178 /* @GenerateCBinding,GeneratePInvoke */
181 RoutedEventArgs (DependencyObject
*source
);
183 /* @GenerateCBinding,GeneratePInvoke */
184 DependencyObject
*GetSource ();
186 /* @GenerateCBinding,GeneratePInvoke */
187 void SetSource(DependencyObject
*el
);
189 /* @GenerateCBinding,GeneratePInvoke */
190 void SetHandled (bool handled
);
192 /* @GenerateCBinding,GeneratePInvoke */
196 virtual ~RoutedEventArgs ();
197 RoutedEventArgs (DependencyObject
*source
, Type::Kind kind
);
198 RoutedEventArgs (Type::Kind kind
);
201 DependencyObject
*source
;
205 /* @Namespace=None */
206 class KeyEventArgs
: public RoutedEventArgs
{
208 /* @GenerateCBinding,GeneratePInvoke */
210 KeyEventArgs (GdkEventKey
*event
);
212 /* @GenerateCBinding,GeneratePInvoke */
215 /* @GenerateCBinding,GeneratePInvoke */
216 int GetPlatformKeyCode ();
218 // accessors for the native GdkEventKey
219 GdkEventKey
*GetEvent ();
220 GdkModifierType
GetModifiers ();
221 gunichar
GetUnicode ();
226 virtual ~KeyEventArgs ();
232 /* @Namespace=None */
233 class MouseEventArgs
: public RoutedEventArgs
{
235 /* @GenerateCBinding,GeneratePInvoke */
237 MouseEventArgs (GdkEvent
*event
);
239 GdkEvent
*GetEvent () { return event
; }
243 /* @GenerateCBinding,GeneratePInvoke */
244 void GetPosition (UIElement
*relative_to
, double *x
, double *y
);
246 /* @GenerateCBinding,GeneratePInvoke */
247 StylusInfo
*GetStylusInfo ();
249 /* @GenerateCBinding,GeneratePInvoke */
250 StylusPointCollection
*GetStylusPoints (UIElement
*ink_presenter
);
253 virtual ~MouseEventArgs ();
254 MouseEventArgs (Type::Kind kind
, GdkEvent
*event
);
259 /* @Namespace=None */
260 class LogReadyRoutedEventArgs
: public RoutedEventArgs
{
262 /* @GenerateCBinding,GeneratePInvoke */
263 LogReadyRoutedEventArgs ();
265 const char *GetLog () { return log
; }
266 LogSource
GetLogSource () { return log_source
; }
270 LogSource log_source
;
273 /* @Namespace=None */
274 class MouseButtonEventArgs
: public MouseEventArgs
{
276 /* @GenerateCBinding,GeneratePInvoke */
277 MouseButtonEventArgs ();
278 MouseButtonEventArgs (GdkEvent
*event
);
281 int GetClickCount ();
284 virtual ~MouseButtonEventArgs ();
287 /* @Namespace=None */
288 class MouseWheelEventArgs
: public MouseEventArgs
{
290 /* @GenerateCBinding,GeneratePInvoke */
291 MouseWheelEventArgs ();
292 MouseWheelEventArgs (GdkEvent
*event
);
294 /* @GenerateCBinding,GeneratePInvoke */
295 int GetWheelDelta ();
298 virtual ~MouseWheelEventArgs ();
302 /* @Namespace=None,ManagedDependencyProperties=None */
303 class ErrorEventArgs
: public EventArgs
{
306 void Initialize (Type::Kind kind
, ErrorEventArgsType type
, const MoonError
&error
, int extended_error_code
, const char *extended_msg
);
308 char *extended_message
;
309 ErrorEventArgsType error_type
;
312 virtual ~ErrorEventArgs ();
313 ErrorEventArgs (Type::Kind kind
, ErrorEventArgsType type
, const MoonError error
);
316 ErrorEventArgs (ErrorEventArgsType type
, MoonError error
);
317 ErrorEventArgs (ErrorEventArgsType type
, MoonError error
, int extended_code
, const char *extended_msg
);
319 /* @GenerateCBinding,GeneratePInvoke */
320 gpointer
GetMoonError () { return error
; }
322 /* @GenerateCBinding,GeneratePInvoke */
323 const char *GetErrorMessage () { return error
->message
; }
324 /* @GenerateCBinding,GeneratePInvoke */
325 int GetErrorCode () { return error
->code
; }
326 /* @GenerateCBinding,GeneratePInvoke */
327 int GetErrorType () { return error_type
; }
329 // To match SL behaviour we need to match SL error messages, which aren't all that helpful
330 // This is here to keep extra error information we have,
331 // but don't want to report to the user.
333 // 3 (MEDIA_UNKNOWN_CODEC): used by playlist to determine if we should raise a MediaFailed event or just continue to play the next entry.
334 int GetExtendedCode () { return extended_code
; }
335 const char *GetExtendedMessage () { return extended_message
; }
338 /* @Namespace=None,ManagedDependencyProperties=None */
339 class ImageErrorEventArgs
: public ErrorEventArgs
{
341 ImageErrorEventArgs (MoonError error
);
344 virtual ~ImageErrorEventArgs ();
348 /* @Namespace=None,ManagedDependencyProperties=None */
349 class ParserErrorEventArgs
: public ErrorEventArgs
{
351 virtual ~ParserErrorEventArgs ();
354 ParserErrorEventArgs (const char *msg
, const char *file
,
355 int line
, int column
, int error_code
,
356 const char *element
, const char *attribute
);
365 /* @Namespace=None */
366 class TimelineMarkerRoutedEventArgs
: public RoutedEventArgs
{
367 TimelineMarker
*marker
;
370 virtual ~TimelineMarkerRoutedEventArgs ();
373 /* @GenerateCBinding,GeneratePInvoke */
374 TimelineMarkerRoutedEventArgs (TimelineMarker
*marker
);
376 /* @GenerateCBinding,GeneratePInvoke */
377 TimelineMarker
*GetMarker () { return marker
; }
380 #endif /* __EVENTARGS_H__ */