added MouseWheel event support for Silverlight 3.0
[moon.git] / plugin / plugin-class.h.in
blobee61597cbd14c7ab1c7f0a2caf065b329a63fda0
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /*
3 * plugin-class.h: MoonLight browser plugin - autogenerated header classes
5 * Contact:
6 * Moonlight List (moonlight-list@lists.ximian.com)
8 * Copyright 2007-2009 Novell, Inc. (http://www.novell.com)
10 * See the LICENSE file included with the distribution for details.
14 #ifndef __PLUGIN_CLASS_H__
15 #define __PLUGIN_CLASS_H__
17 #include "moonlight.h"
18 #include "error.h"
19 #include "plugin.h"
21 // debug javascript
22 #define DEBUG_JAVASCRIPT 1
24 #define DEPENDENCY_OBJECT_FROM_VARIANT(obj) (((MoonlightDependencyObjectObject*) NPVARIANT_TO_OBJECT (obj))->GetDependencyObject ())
26 #define THROW_JS_EXCEPTION(meth) \
27 do { \
28 char *message = g_strdup_printf ("Error calling method: %s", meth); \
29 NPN_SetException (this, message); \
30 g_free (message); \
31 return true; \
32 } while (0); \
34 #define THROW_JS_EXCEPTION2(obj, meth) \
35 do { \
36 char *message = g_strdup_printf ("Error calling method: %s", meth); \
37 NPN_SetException (obj, message); \
38 g_free (message); \
39 } while (0); \
42 enum PluginPropertyId {
43 NoMapping = 0,
45 // property names
46 MoonId_ErrorCode = 0x4000,
47 MoonId_ErrorType,
48 MoonId_ErrorMessage,
49 MoonId_LineNumber,
50 MoonId_CharPosition,
51 MoonId_XamlFile,
52 MoonId_MethodName,
53 MoonId_X,
54 MoonId_Y,
55 MoonId_Left,
56 MoonId_Right,
57 MoonId_Top,
58 MoonId_Bottom,
59 MoonId_TopLeft,
60 MoonId_TopRight,
61 MoonId_BottomLeft,
62 MoonId_BottomRight,
63 MoonId_Width,
64 MoonId_Height,
65 MoonId_Seconds,
66 MoonId_Name,
67 MoonId_Shift,
68 MoonId_Ctrl,
69 MoonId_Marker,
70 MoonId_Key,
71 MoonId_PlatformKeyCode,
72 MoonId_Progress,
73 MoonId_Settings,
74 MoonId_Content,
75 MoonId_InitParams,
76 MoonId_Id,
77 MoonId_IsLoaded,
78 MoonId_Source,
79 MoonId_Background,
80 MoonId_EnableFramerateCounter,
81 MoonId_EnableRedrawRegions,
82 MoonId_EnableHtmlAccess,
83 MoonId_MaxFrameRate,
84 MoonId_Version,
85 MoonId_Windowless,
86 MoonId_ActualHeight,
87 MoonId_ActualWidth,
88 MoonId_FullScreen,
89 MoonId_Root,
90 MoonId_Count,
91 MoonId_ResponseText,
92 MoonId_DeviceType,
93 MoonId_IsInverted,
94 MoonId_Handled,
95 MoonId_GridUnitType,
96 MoonId_Value,
97 MoonId_Accessibility,
98 MoonId_MultiScaleImage_Source,
100 // event names (handled by the property setters)
101 MoonId_BufferingProgressChanged,
102 MoonId_Completed,
103 MoonId_CurrentStateChanged,
104 MoonId_DownloadProgressChanged,
105 MoonId_GotFocus,
106 MoonId_ImageFailed,
107 MoonId_KeyDown,
108 MoonId_KeyUp,
109 MoonId_LostFocus,
110 MoonId_Loaded,
111 MoonId_MarkerReached,
112 MoonId_MediaEnded,
113 MoonId_MediaFailed,
114 MoonId_MediaOpened,
115 MoonId_MouseEnter,
116 MoonId_MouseLeave,
117 MoonId_MouseMove,
118 MoonId_MouseLeftButtonDown,
119 MoonId_MouseLeftButtonUp,
120 MoonId_OnResize,
121 MoonId_OnFullScreenChange,
122 MoonId_OnError,
123 MoonId_OnLoad,
124 MoonId_OnSourceDownloadProgressChanged,
125 MoonId_OnSourceDownloadComplete,
127 // method names
128 MoonId_GetPosition = 0x8000,
129 MoonId_CreateObject,
130 MoonId_IsVersionSupported,
131 MoonId_FindName,
132 MoonId_CreateFromXaml,
133 MoonId_CreateFromXamlDownloader,
134 MoonId_Equals,
135 MoonId_GetHost,
136 MoonId_GetParent,
137 MoonId_GetStylusInfo,
138 MoonId_GetStylusPoints,
139 MoonId_CaptureMouse,
140 MoonId_ReleaseMouseCapture,
141 MoonId_AddEventListener,
142 MoonId_RemoveEventListener,
143 MoonId_SetValue,
144 MoonId_GetValue,
145 MoonId_ToString,
146 #if DEBUG_JAVASCRIPT
147 MoonId_Printf,
148 MoonId_DumpNameScope,
149 #endif
150 MoonId_Add,
151 MoonId_Remove,
152 MoonId_RemoveAt,
153 MoonId_Insert,
154 MoonId_Clear,
155 MoonId_GetItem,
156 MoonId_GetItemByName,
157 MoonId_Begin,
158 MoonId_Pause,
159 MoonId_Resume,
160 MoonId_Seek,
161 MoonId_Stop,
162 MoonId_Play,
163 MoonId_SetSource,
164 MoonId_SetFontSource,
165 MoonId_Abort,
166 MoonId_Open,
167 MoonId_GetResponseText,
168 MoonId_Send,
169 MoonId_AddStylusPoints,
170 MoonId_GetBounds,
171 MoonId_HitTest,
172 MoonId_UpdateLayout,
174 MoonId_StopPropagation,
175 MoonId_PreventDefault,
176 MoonId_Detail,
178 MoonId_Focus,
180 MoonId_Select,
181 MoonId_SelectAll,
183 MoonId_MultiScaleImage_GetIthSubImage,
184 MoonId_MultiScaleImage_GetSubImageCount,
185 MoonId_MultiScaleImage_LogicalToElementX,
186 MoonId_MultiScaleImage_LogicalToElementY,
187 MoonId_MultiScaleImage_ZoomAboutLogicalPoint,
188 /*MAP_IDS*/
192 #define MAPPING_FLAG_SL1 0x01
193 #define MAPPING_FLAG_SL2 0x02
195 struct MoonNameIdMapping {
196 const char *name;
197 int id;
200 #define IS_METHOD(id) (((id) & 0x8000) != 0)
201 #define IS_PROPERTY(id) (((id) & 0x4000) != 0)
204 G_BEGIN_DECLS
205 G_GNUC_INTERNAL bool npobject_is_dependency_object (NPObject *obj);
207 G_GNUC_INTERNAL bool check_arg_list (const char *arglist, guint32 argc, const NPVariant *argv);
209 G_GNUC_INTERNAL void plugin_init_classes (void);
210 G_GNUC_INTERNAL void plugin_destroy_classes (void);
212 G_GNUC_INTERNAL void event_object_add_xaml_listener (EventObject *obj, PluginInstance *instance, const char *event_name, const char *cb_name);
214 void string_to_npvariant (const char *value, NPVariant *result);
215 G_GNUC_INTERNAL void variant_to_value (const NPVariant *v, Value **result);
216 G_END_DECLS
219 class MoonlightObject;
221 /*** EventListenerProxy */
222 typedef void (*EventArgsWrapper)(NPP instance, EventArgs *calldata, NPVariant *value);
224 class EventListenerProxy : public EventObject {
225 static void on_handler_removed (gpointer closure);
227 EventObject *target_object;
228 MoonlightObject *owner;
230 NPP instance;
231 bool is_func;
233 /* if @is_func == true, callback is an NPObject (the function object)
234 if @is_func == false, callback is a char* (the function name)
236 gpointer callback;
238 char *event_name;
239 int event_id;
240 int token;
242 bool one_shot;
244 public:
245 EventListenerProxy (NPP instance, const char *event_name, const char *cb_name);
246 EventListenerProxy (NPP instance, const char *event_name, const NPVariant *cb);
247 virtual ~EventListenerProxy ();
249 void SetOwner (MoonlightObject *owner);
251 int AddXamlHandler (EventObject *obj);
252 int AddHandler (EventObject *obj);
253 void RemoveHandler ();
254 const char *GetCallbackAsString ();
256 int GetEventId () { return event_id; }
257 int GetEventToken () { return token; }
259 void SetOneShot () { one_shot = true; }
261 static void proxy_listener_to_javascript (EventObject *sender, EventArgs *calldata, gpointer closure);
265 /*** MoonlightObjectClass **************************************************************/
267 struct MoonlightObjectType : NPClass {
268 MoonlightObjectType ();
270 ~MoonlightObjectType() { g_free (mapping); }
272 void AddMapping (const MoonNameIdMapping *mapping, int count);
274 bool Enumerate (NPIdentifier **value, guint32 *count);
276 int LookupName (NPIdentifier name);
278 MoonNameIdMapping *mapping;
279 int mapping_count;
281 NPIdentifier last_lookup;
282 int last_id;
285 extern MoonlightObjectType *MoonlightObjectClass;
287 struct MoonlightObject : NPObject {
288 MoonlightObject (NPP instance)
290 this->instance = instance;
291 this->moonlight_type = Type::INVALID;
292 this->event_listener_proxies = g_hash_table_new (g_direct_hash, g_direct_equal);
295 virtual void Invalidate () { }
296 virtual ~MoonlightObject ();
298 virtual bool HasProperty (NPIdentifier name);
299 virtual bool GetProperty (int id, NPIdentifier name, NPVariant *result);
300 virtual bool SetProperty (int id, NPIdentifier name, const NPVariant *value);
302 virtual bool HasMethod (NPIdentifier unmapped);
303 virtual bool Invoke (int id, NPIdentifier name,
304 const NPVariant *args, guint32 argCount, NPVariant *result);
305 int LookupName (NPIdentifier name) { return ((MoonlightObjectType *)_class)->LookupName (name); }
307 EventListenerProxy *LookupEventProxy (int event_id);
308 void SetEventProxy (EventListenerProxy* proxy);
309 void ClearEventProxy (EventListenerProxy *proxy);
311 static void destroy_proxy (gpointer data);
312 static void invalidate_proxy (gpointer key, gpointer value, gpointer data);
314 NPP instance;
315 Type::Kind moonlight_type;
316 GHashTable *event_listener_proxies;
320 /*** MoonlightEventObjectClass ***************************************************/
321 struct MoonlightEventObjectType : MoonlightObjectType {
322 MoonlightEventObjectType ();
325 extern MoonlightEventObjectType *MoonlightEventObjectClass;
327 struct MoonlightEventObjectObject : MoonlightObject {
328 MoonlightEventObjectObject (NPP instance) : MoonlightObject (instance)
330 moonlight_type = Type::EVENTOBJECT;
331 eo = NULL;
334 virtual ~MoonlightEventObjectObject ();
336 EventObject *eo;
339 extern MoonlightEventObjectObject *EventObjectCreateWrapper (NPP instance, EventObject *obj);
341 /*** MoonlightDependencyObjectClass ***************************************************/
342 struct MoonlightDependencyObjectType : MoonlightEventObjectType {
343 MoonlightDependencyObjectType ();
347 struct MoonlightDependencyObjectObject : MoonlightEventObjectObject {
348 MoonlightDependencyObjectObject (NPP instance) : MoonlightEventObjectObject (instance)
350 moonlight_type = Type::DEPENDENCY_OBJECT;
353 DependencyObject *GetDependencyObject ()
355 if (eo == NULL || !eo->Is (Type::DEPENDENCY_OBJECT)) {
356 g_warning ("MoonlightDependencyObjectObject::GetDependencyObject (): Not a dependency object!");
357 return NULL;
360 return (DependencyObject*) eo;
363 virtual bool HasProperty (NPIdentifier unmapped);
364 virtual bool GetProperty (int id, NPIdentifier unmapped, NPVariant *result);
365 virtual bool SetProperty (int id, NPIdentifier unmapped, const NPVariant *value);
367 virtual bool Invoke (int id, NPIdentifier name,
368 const NPVariant *args, guint32 argCount, NPVariant *result);
372 extern MoonlightDependencyObjectObject *DependencyObjectCreateWrapper (NPP instance, DependencyObject *obj);
375 /*************** AUTO GENERATED CLASSES ****************************/
377 /*MAP_HEADERS*/
379 /*************** END OF AUTO GENERATED CLASSES *********************/
381 /*** MoonlightPointClass **************************************************************/
382 struct MoonlightPointType : MoonlightObjectType {
383 MoonlightPointType ();
386 extern MoonlightPointType *MoonlightPointClass;
388 struct MoonlightPoint : MoonlightObject {
389 MoonlightPoint (NPP instance) : MoonlightObject(instance), point (Point())
391 moonlight_type = Type::POINT;
394 virtual bool GetProperty (int id, NPIdentifier unmapped, NPVariant *result);
395 virtual bool SetProperty (int id, NPIdentifier unmapped, const NPVariant *value);
397 Point point;
400 /*** MoonlightRectClass **************************************************************/
401 struct MoonlightRectType : MoonlightObjectType {
402 MoonlightRectType ();
405 extern MoonlightRectType *MoonlightRectClass;
407 struct MoonlightRect : MoonlightObject {
408 MoonlightRect (NPP instance) : MoonlightObject(instance), rect (Rect())
410 moonlight_type = Type::RECT;
413 virtual bool GetProperty (int id, NPIdentifier unmapped, NPVariant *result);
414 virtual bool SetProperty (int id, NPIdentifier unmapped, const NPVariant *value);
416 Rect rect;
420 /*** MoonlightDurationClass **************************************************************/
421 struct MoonlightDurationType : MoonlightObjectType {
422 MoonlightDurationType ();
425 extern MoonlightDurationType *MoonlightDurationClass;
427 struct MoonlightDuration : MoonlightObject {
428 MoonlightDuration (NPP instance) : MoonlightObject (instance)
430 moonlight_type = Type::DURATION;
431 parent_property = NULL;
432 parent_obj = NULL;
435 virtual ~MoonlightDuration ();
437 void SetParentInfo (DependencyObject *parent_obj, DependencyProperty *parent_property);
439 double GetValue ();
441 virtual bool GetProperty (int id, NPIdentifier unmapped, NPVariant *result);
442 virtual bool SetProperty (int id, NPIdentifier unmapped, const NPVariant *value);
444 DependencyProperty *parent_property;
445 DependencyObject *parent_obj;
448 /*** MoonlightTimeSpanClass **************************************************************/
449 struct MoonlightTimeSpanType : MoonlightObjectType {
450 MoonlightTimeSpanType ();
453 extern MoonlightTimeSpanType *MoonlightTimeSpanClass;
455 struct MoonlightTimeSpan : MoonlightObject {
456 MoonlightTimeSpan (NPP instance) : MoonlightObject (instance)
458 moonlight_type = Type::TIMESPAN;
459 parent_property = NULL;
460 parent_obj = NULL;
463 virtual ~MoonlightTimeSpan ();
465 void SetParentInfo (DependencyObject *parent_obj, DependencyProperty *parent_property);
467 TimeSpan GetValue ();
469 virtual bool GetProperty (int id, NPIdentifier unmapped, NPVariant *result);
470 virtual bool SetProperty (int id, NPIdentifier unmapped, const NPVariant *value);
472 DependencyProperty *parent_property;
473 DependencyObject *parent_obj;
476 /*** MoonlightKeyTimeClass ****************************************************************/
477 struct MoonlightKeyTimeType : MoonlightObjectType {
478 MoonlightKeyTimeType ();
481 extern MoonlightKeyTimeType *MoonlightKeyTimeClass;
483 struct MoonlightKeyTime : MoonlightObject {
484 MoonlightKeyTime (NPP instance) : MoonlightObject (instance)
486 moonlight_type = Type::KEYTIME;
487 parent_property = NULL;
488 parent_obj = NULL;
491 virtual ~MoonlightKeyTime ();
493 void SetParentInfo (DependencyObject *parent_obj, DependencyProperty *parent_property);
495 KeyTime* GetValue ();
497 virtual bool GetProperty (int id, NPIdentifier unmapped, NPVariant *result);
498 virtual bool SetProperty (int id, NPIdentifier unmapped, const NPVariant *value);
500 DependencyProperty *parent_property;
501 DependencyObject *parent_obj;
504 /*** MoonlightThicknessClass ****************************************************************/
505 struct MoonlightThicknessType : MoonlightObjectType {
506 MoonlightThicknessType ();
509 extern MoonlightThicknessType *MoonlightThicknessClass;
511 struct MoonlightThickness : MoonlightObject {
512 MoonlightThickness (NPP instance) : MoonlightObject (instance)
514 moonlight_type = Type::THICKNESS;
515 parent_property = NULL;
516 parent_obj = NULL;
519 virtual ~MoonlightThickness ();
521 void SetParentInfo (DependencyObject *parent_obj, DependencyProperty *parent_property);
523 Thickness* GetValue ();
525 virtual bool GetProperty (int id, NPIdentifier unmapped, NPVariant *result);
526 virtual bool SetProperty (int id, NPIdentifier unmapped, const NPVariant *value);
528 DependencyProperty *parent_property;
529 DependencyObject *parent_obj;
532 /*** MoonlightCornerRadiusClass ****************************************************************/
533 struct MoonlightCornerRadiusType : MoonlightObjectType {
534 MoonlightCornerRadiusType ();
537 extern MoonlightCornerRadiusType *MoonlightCornerRadiusClass;
539 struct MoonlightCornerRadius : MoonlightObject {
540 MoonlightCornerRadius (NPP instance) : MoonlightObject (instance)
542 moonlight_type = Type::CORNERRADIUS;
543 parent_property = NULL;
544 parent_obj = NULL;
547 virtual ~MoonlightCornerRadius ();
549 void SetParentInfo (DependencyObject *parent_obj, DependencyProperty *parent_property);
551 CornerRadius* GetValue ();
553 virtual bool GetProperty (int id, NPIdentifier unmapped, NPVariant *result);
554 virtual bool SetProperty (int id, NPIdentifier unmapped, const NPVariant *value);
556 DependencyProperty *parent_property;
557 DependencyObject *parent_obj;
560 /*** MoonlightGridLengthClass ****************************************************************/
561 struct MoonlightGridLengthType : MoonlightObjectType {
562 MoonlightGridLengthType ();
565 extern MoonlightGridLengthType *MoonlightGridLengthClass;
567 struct MoonlightGridLength : MoonlightObject {
568 MoonlightGridLength (NPP instance) : MoonlightObject (instance)
570 moonlight_type = Type::GRIDLENGTH;
571 parent_property = NULL;
572 parent_obj = NULL;
575 virtual ~MoonlightGridLength ();
577 void SetParentInfo (DependencyObject *parent_obj, DependencyProperty *parent_property);
579 GridLength* GetValue ();
581 virtual bool GetProperty (int id, NPIdentifier unmapped, NPVariant *result);
582 virtual bool SetProperty (int id, NPIdentifier unmapped, const NPVariant *value);
584 DependencyProperty *parent_property;
585 DependencyObject *parent_obj;
588 /*** MoonlightSettingsClass ***********************************************************/
590 struct MoonlightSettingsType : MoonlightObjectType {
591 MoonlightSettingsType ();
594 extern MoonlightSettingsType *MoonlightSettingsClass;
596 struct MoonlightSettingsObject : MoonlightObject {
597 MoonlightSettingsObject (NPP instance) : MoonlightObject (instance)
601 virtual bool GetProperty (int id, NPIdentifier unmapped, NPVariant *result);
602 virtual bool SetProperty (int id, NPIdentifier unmapped, const NPVariant *value);
604 virtual bool Invoke (int id, NPIdentifier name,
605 const NPVariant *args, guint32 argCount, NPVariant *result);
609 /*** MoonlightContentClass ************************************************************/
611 struct MoonlightContentType : MoonlightObjectType {
612 MoonlightContentType ();
615 extern MoonlightContentType *MoonlightContentClass;
617 struct MoonlightContentObject : MoonlightObject {
618 MoonlightContentObject (NPP instance) : MoonlightObject (instance)
620 registered_scriptable_objects = g_hash_table_new (g_direct_hash, g_direct_equal);
621 accessibility = NULL;
624 virtual ~MoonlightContentObject ();
626 virtual bool HasProperty (NPIdentifier unmapped);
627 virtual bool GetProperty (int id, NPIdentifier unmapped, NPVariant *result);
628 virtual bool SetProperty (int id, NPIdentifier unmapped, const NPVariant *value);
630 virtual bool Invoke (int id, NPIdentifier name,
631 const NPVariant *args, guint32 argCount, NPVariant *result);
633 DependencyObject *accessibility;
634 GHashTable *registered_scriptable_objects;
637 /*** MoonlightScriptControlClass **********************************************************/
639 struct MoonlightScriptControlType : MoonlightObjectType {
640 MoonlightScriptControlType ();
643 extern MoonlightScriptControlType *MoonlightScriptControlClass;
645 struct MoonlightScriptControlObject : MoonlightObject {
646 MoonlightScriptControlObject (NPP instance) : MoonlightObject (instance)
648 settings = NPN_CreateObject (instance, MoonlightSettingsClass);
649 content = NPN_CreateObject (instance, MoonlightContentClass);
652 virtual ~MoonlightScriptControlObject ();
654 virtual void Invalidate ();
656 virtual bool GetProperty (int id, NPIdentifier unmapped, NPVariant *result);
657 virtual bool SetProperty (int id, NPIdentifier unmapped, const NPVariant *value);
659 virtual bool Invoke (int id, NPIdentifier name,
660 const NPVariant *args, guint32 argCount, NPVariant *result);
662 NPObject *settings;
663 NPObject *content;
667 /*** MoonlightEventArgsClass ******************************************************/
668 struct MoonlightEventArgsType : MoonlightDependencyObjectType {
669 MoonlightEventArgsType ();
672 struct MoonlightEventArgs : MoonlightDependencyObjectObject {
673 MoonlightEventArgs (NPP instance) : MoonlightDependencyObjectObject (instance)
675 moonlight_type = Type::EVENTARGS;
679 /*** MoonlightEventArgsClass ******************************************************/
680 struct MoonlightRoutedEventArgsType : MoonlightEventArgsType {
681 MoonlightRoutedEventArgsType ();
684 struct MoonlightRoutedEventArgs : MoonlightEventArgs {
685 MoonlightRoutedEventArgs (NPP instance) : MoonlightEventArgs (instance)
687 moonlight_type = Type::ROUTEDEVENTARGS;
690 virtual bool GetProperty (int id, NPIdentifier unmapped, NPVariant *result);
692 RoutedEventArgs *GetRoutedEventArgs () { return (RoutedEventArgs *) eo; }
695 /*** MoonlightMouseEventArgsClass **************************************************************/
696 struct MoonlightMouseEventArgsType : MoonlightRoutedEventArgsType {
697 MoonlightMouseEventArgsType ();
700 struct MoonlightMouseEventArgsObject : MoonlightRoutedEventArgs {
701 MoonlightMouseEventArgsObject (NPP instance) : MoonlightRoutedEventArgs (instance)
703 moonlight_type = Type::MOUSEEVENTARGS;
706 virtual bool GetProperty (int id, NPIdentifier unmapped, NPVariant *result);
707 virtual bool SetProperty (int id, NPIdentifier unmapped, const NPVariant *value);
708 virtual bool Invoke (int id, NPIdentifier name,
709 const NPVariant *args, guint32 argCount, NPVariant *result);
711 MouseEventArgs *GetMouseEventArgs () { return (MouseEventArgs *) eo; };
714 /*** MoonlightMarkerReachedEventArgsClass ******************************************/
715 struct MoonlightMarkerReachedEventArgsType : MoonlightRoutedEventArgsType {
716 MoonlightMarkerReachedEventArgsType ();
719 extern MoonlightMarkerReachedEventArgsType *MoonlightMarkerReachedEventArgsClass;
721 struct MoonlightMarkerReachedEventArgsObject : MoonlightRoutedEventArgs {
722 MoonlightMarkerReachedEventArgsObject (NPP instance) : MoonlightRoutedEventArgs (instance)
724 moonlight_type = Type::MARKERREACHEDEVENTARGS;
727 virtual bool GetProperty (int id, NPIdentifier unmapped, NPVariant *result);
729 MarkerReachedEventArgs *GetMarkerReachedEventArgs () { return (MarkerReachedEventArgs *) eo; }
732 /*** MoonlightKeyEventArgsClass **************************************************************/
733 struct MoonlightKeyEventArgsType : MoonlightEventArgsType {
734 MoonlightKeyEventArgsType ();
737 struct MoonlightKeyEventArgsObject : MoonlightEventArgs {
738 MoonlightKeyEventArgsObject (NPP instance) : MoonlightEventArgs (instance)
740 moonlight_type = Type::KEYEVENTARGS;
743 virtual bool GetProperty (int id, NPIdentifier unmapped, NPVariant *result);
744 KeyEventArgs *GetKeyEventArgs () { return (KeyEventArgs *) eo; }
747 /*** MoonlightDownloadProgressEventArgsClass ******************************************************/
748 struct MoonlightDownloadProgressEventArgsType : MoonlightEventArgsType {
749 MoonlightDownloadProgressEventArgsType ();
752 struct MoonlightDownloadProgressEventArgs : MoonlightEventArgs {
753 MoonlightDownloadProgressEventArgs (NPP instance) : MoonlightEventArgs (instance)
755 moonlight_type = Type::DOWNLOADPROGRESSEVENTARGS;
758 DownloadProgressEventArgs *GetDownloadProgressEventArgs () { return (DownloadProgressEventArgs *) eo; }
759 virtual bool GetProperty (int id, NPIdentifier unmapped, NPVariant *result);
762 /*** MoonlightErrorEventArgsClass ******************************************************/
763 struct MoonlightErrorEventArgsType : MoonlightEventArgsType {
764 MoonlightErrorEventArgsType ();
767 struct MoonlightErrorEventArgs : MoonlightEventArgs {
768 MoonlightErrorEventArgs (NPP instance) : MoonlightEventArgs (instance)
770 moonlight_type = Type::ERROREVENTARGS;
773 ErrorEventArgs *GetErrorEventArgs () { return (ErrorEventArgs *) eo; }
774 virtual bool GetProperty (int id, NPIdentifier unmapped, NPVariant *result);
777 /*** MoonlightCollectionClass ***************************************************/
779 struct MoonlightCollectionType : MoonlightDependencyObjectType {
780 MoonlightCollectionType ();
783 struct MoonlightCollectionObject : MoonlightDependencyObjectObject {
784 MoonlightCollectionObject (NPP instance) : MoonlightDependencyObjectObject (instance)
786 moonlight_type = Type::COLLECTION;
789 virtual bool GetProperty (int id, NPIdentifier unmapped, NPVariant *result);
791 virtual bool Invoke (int id, NPIdentifier name,
792 const NPVariant *args, guint32 argCount, NPVariant *result);
795 /*** MoonlightStoryboardClass ***************************************************/
797 struct MoonlightStoryboardType : MoonlightDependencyObjectType {
798 MoonlightStoryboardType ();
801 struct MoonlightStoryboardObject : MoonlightDependencyObjectObject {
802 MoonlightStoryboardObject (NPP instance) : MoonlightDependencyObjectObject (instance)
804 moonlight_type = Type::STORYBOARD;
807 virtual bool Invoke (int id, NPIdentifier name,
808 const NPVariant *args, guint32 argCount, NPVariant *result);
811 /*** MoonlightMediaElement ***************************************************/
813 struct MoonlightMediaElementType : MoonlightUIElementType {
814 MoonlightMediaElementType ();
818 struct MoonlightMediaElementObject : MoonlightUIElementObject {
819 MoonlightMediaElementObject (NPP instance) : MoonlightUIElementObject (instance)
821 moonlight_type = Type::MEDIAELEMENT;
824 virtual bool Invoke (int id, NPIdentifier name,
825 const NPVariant *args, guint32 argCount, NPVariant *result);
828 /*** MoonlightMultiScaleImage ***************************************************/
830 struct MoonlightMultiScaleImageType : MoonlightDependencyObjectType {
831 MoonlightMultiScaleImageType ();
834 struct MoonlightMultiScaleImageObject : MoonlightDependencyObjectObject {
835 MoonlightMultiScaleImageObject (NPP instance) : MoonlightDependencyObjectObject (instance)
837 moonlight_type = Type::MULTISCALEIMAGE;
840 virtual bool Invoke (int id, NPIdentifier name,
841 const NPVariant *args, guint32 argCount, NPVariant *result);
843 virtual bool SetProperty (int id, NPIdentifier name, const NPVariant *value);
846 /*** MoonlightImage ***************************************************/
848 struct MoonlightImageType : MoonlightUIElementType {
849 MoonlightImageType ();
853 struct MoonlightImageObject : MoonlightUIElementObject {
854 MoonlightImageObject (NPP instance) : MoonlightUIElementObject (instance)
856 moonlight_type = Type::IMAGE;
859 virtual bool Invoke (int id, NPIdentifier name,
860 const NPVariant *args, guint32 argCount, NPVariant *result);
861 virtual bool GetProperty (int id, NPIdentifier unmapped, NPVariant *result);
864 /*** MoonlightImageBrush ***************************************************/
866 struct MoonlightImageBrushType : MoonlightDependencyObjectType {
867 MoonlightImageBrushType ();
871 struct MoonlightImageBrushObject : MoonlightDependencyObjectObject {
872 MoonlightImageBrushObject (NPP instance) : MoonlightDependencyObjectObject (instance)
874 moonlight_type = Type::IMAGEBRUSH;
877 virtual bool Invoke (int id, NPIdentifier name,
878 const NPVariant *args, guint32 argCount, NPVariant *result);
879 virtual bool GetProperty (int id, NPIdentifier unmapped, NPVariant *result);
882 /*** MoonlightDownloader ***************************************************/
884 struct MoonlightDownloaderType : MoonlightDependencyObjectType {
885 MoonlightDownloaderType ();
889 struct MoonlightDownloaderObject : MoonlightDependencyObjectObject {
890 MoonlightDownloaderObject (NPP instance) : MoonlightDependencyObjectObject (instance)
892 moonlight_type = Type::DOWNLOADER;
895 virtual bool GetProperty (int id, NPIdentifier unmapped, NPVariant *result);
896 virtual bool Invoke (int id, NPIdentifier name,
897 const NPVariant *args, guint32 argCount, NPVariant *result);
900 /*** MoonlightTextBlock ***************************************************/
902 struct MoonlightTextBlockType : MoonlightUIElementType {
903 MoonlightTextBlockType ();
907 struct MoonlightTextBlockObject : MoonlightUIElementObject {
908 MoonlightTextBlockObject (NPP instance) : MoonlightUIElementObject (instance)
910 moonlight_type = Type::TEXTBLOCK;
913 virtual bool Invoke (int id, NPIdentifier name,
914 const NPVariant *args, guint32 argCount, NPVariant *result);
917 /*** MoonlightControl ***************************************************/
919 struct MoonlightControlType : MoonlightUIElementType {
920 MoonlightControlType ();
923 extern MoonlightControlType *MoonlightControlClass;
925 struct MoonlightControlObject : MoonlightUIElementObject {
926 MoonlightControlObject (NPP instance) : MoonlightUIElementObject (instance)
928 moonlight_type = Type::CONTROL;
931 virtual bool Invoke (int id, NPIdentifier name, const NPVariant *args, guint32 argCount, NPVariant *result);
934 /*** MoonlightTextBox ***************************************************/
936 struct MoonlightTextBoxType : MoonlightControlType {
937 MoonlightTextBoxType ();
941 struct MoonlightTextBoxObject : MoonlightControlObject {
942 MoonlightTextBoxObject (NPP instance) : MoonlightControlObject (instance)
944 moonlight_type = Type::TEXTBOX;
947 virtual bool Invoke (int id, NPIdentifier name,
948 const NPVariant *args, guint32 argCount, NPVariant *result);
952 /*** MoonlightPasswordBox ***************************************************/
954 struct MoonlightPasswordBoxType : MoonlightControlType {
955 MoonlightPasswordBoxType ();
959 struct MoonlightPasswordBoxObject : MoonlightControlObject {
960 MoonlightPasswordBoxObject (NPP instance) : MoonlightControlObject (instance)
962 moonlight_type = Type::PASSWORDBOX;
965 virtual bool Invoke (int id, NPIdentifier name,
966 const NPVariant *args, guint32 argCount, NPVariant *result);
969 /*** MoonlightStylusInfoType ***************************************************/
971 struct MoonlightStylusInfoType : MoonlightDependencyObjectType {
972 MoonlightStylusInfoType ();
976 struct MoonlightStylusInfoObject : MoonlightDependencyObjectObject {
977 MoonlightStylusInfoObject (NPP instance) : MoonlightDependencyObjectObject (instance)
979 moonlight_type = Type::STYLUSINFO;
982 virtual bool GetProperty (int id, NPIdentifier unmapped, NPVariant *result);
985 /*** MoonlightStylusPointCollectionType *************************************/
987 struct MoonlightStylusPointCollectionType : MoonlightCollectionType {
988 MoonlightStylusPointCollectionType ();
992 struct MoonlightStylusPointCollectionObject : MoonlightCollectionObject {
993 MoonlightStylusPointCollectionObject (NPP instance) : MoonlightCollectionObject (instance)
995 moonlight_type = Type::STYLUSPOINT_COLLECTION;
998 virtual bool Invoke (int id, NPIdentifier name,
999 const NPVariant *args, guint32 argCount, NPVariant *result);
1003 /*** MoonlightStrokeCollectionType *************************************/
1005 struct MoonlightStrokeCollectionType : MoonlightCollectionType {
1006 MoonlightStrokeCollectionType ();
1010 struct MoonlightStrokeCollectionObject : MoonlightCollectionObject {
1012 MoonlightStrokeCollectionObject (NPP instance)
1013 : MoonlightCollectionObject (instance)
1015 moonlight_type = Type::STROKE_COLLECTION;
1018 virtual bool Invoke (int id, NPIdentifier name,
1019 const NPVariant *args, guint32 argCount, NPVariant *result);
1023 /*** MoonlightStrokeType *************************************/
1025 struct MoonlightStrokeType : MoonlightDependencyObjectType {
1026 MoonlightStrokeType ();
1030 struct MoonlightStrokeObject : MoonlightDependencyObjectObject {
1032 MoonlightStrokeObject (NPP instance)
1033 : MoonlightDependencyObjectObject (instance)
1035 moonlight_type = Type::STROKE;
1038 virtual bool Invoke (int id, NPIdentifier name,
1039 const NPVariant *args, guint32 argCount, NPVariant *result);
1042 /*** MoonlightScriptableObject ***************************************************/
1044 struct MoonlightScriptableObjectObject;
1046 typedef void (*InvokeDelegate) (gpointer managed_obj_handle, gpointer method_handle, char* name, Value** args, int arg_count, Value* return_value);
1047 typedef void (*SetPropertyDelegate) (gpointer managed_obj_handle, char* name, Value *value);
1048 typedef void (*GetPropertyDelegate) (gpointer managed_obj_handle, char* name, Value *value);
1049 typedef void (*EventHandlerDelegate) (gpointer managed_obj_handle, gpointer event_handle, MoonlightScriptableObjectObject* scriptable_obj, gpointer closure);
1051 struct MoonlightScriptableObjectType : MoonlightObjectType {
1052 MoonlightScriptableObjectType ();
1055 extern MoonlightScriptableObjectType *MoonlightScriptableObjectClass;
1057 struct MoonlightScriptableObjectObject : MoonlightObject {
1058 MoonlightScriptableObjectObject (NPP instance) : MoonlightObject (instance)
1060 managed_scriptable = NULL;
1061 properties = g_hash_table_new (g_direct_hash, g_direct_equal);
1062 methods = g_hash_table_new (g_direct_hash, g_direct_equal);
1063 events = g_hash_table_new (g_direct_hash, g_direct_equal);
1066 virtual ~MoonlightScriptableObjectObject ();
1068 virtual bool HasProperty (NPIdentifier name);
1069 virtual bool GetProperty (int id, NPIdentifier unmapped, NPVariant *result);
1070 virtual bool SetProperty (int id, NPIdentifier unmapped, const NPVariant *value);
1072 virtual bool HasMethod (NPIdentifier name);
1073 virtual bool Invoke (int id, NPIdentifier name,
1074 const NPVariant *args, guint32 argCount, NPVariant *result);
1076 gpointer managed_scriptable;
1077 GHashTable *properties;
1078 GHashTable *methods;
1079 GHashTable *events;
1081 InvokeDelegate invoke;
1082 SetPropertyDelegate setprop;
1083 GetPropertyDelegate getprop;
1084 EventHandlerDelegate addevent;
1085 EventHandlerDelegate removeevent;
1089 G_BEGIN_DECLS
1091 // These are meant to be called by System.Silverlight.dll
1092 /* @GeneratePInvoke */
1093 NPObject * moonlight_object_to_npobject (MoonlightObject *obj);
1094 MoonlightObject * npobject_to_moonlight_object (NPObject *npobj);
1096 /* @GeneratePInvoke */
1097 MoonlightScriptableObjectObject *moonlight_scriptable_object_wrapper_create_root (PluginInstance *plugin, gpointer scriptable,
1098 InvokeDelegate invoke,
1099 SetPropertyDelegate setprop,
1100 GetPropertyDelegate getprop,
1101 EventHandlerDelegate addevent,
1102 EventHandlerDelegate removeevent);
1104 /* @GeneratePInvoke */
1105 MoonlightScriptableObjectObject *moonlight_scriptable_object_wrapper_create (NPObject *parent, gpointer scriptable,
1106 InvokeDelegate invoke,
1107 SetPropertyDelegate setprop,
1108 GetPropertyDelegate getprop,
1109 EventHandlerDelegate addevent,
1110 EventHandlerDelegate removeevent);
1112 /* @GeneratePInvoke */
1113 void moonlight_scriptable_object_add_property (PluginInstance *plugin,
1114 MoonlightScriptableObjectObject *obj,
1115 gpointer property_handle,
1116 char *property_name,
1117 /* @MarshalAs=TypeCode */ int property_type,
1118 bool can_read,
1119 bool can_write);
1121 /* @GeneratePInvoke */
1122 void moonlight_scriptable_object_add_event (PluginInstance *plugin,
1123 MoonlightScriptableObjectObject *obj,
1124 gpointer event_handle,
1125 char *event_name);
1127 /* @GeneratePInvoke */
1128 void moonlight_scriptable_object_add_method (PluginInstance *plugin,
1129 MoonlightScriptableObjectObject *obj,
1130 gpointer method_handle,
1131 char *method_name,
1132 /* @MarshalAs=TypeCode */ int method_return_type,
1133 /* @MarshalAs=TypeCode[] */ int *method_parameter_types,
1134 int parameter_count);
1136 /* @GeneratePInvoke */
1137 void moonlight_scriptable_object_register (PluginInstance *plugin,
1138 char *name,
1139 MoonlightScriptableObjectObject *obj);
1141 /* @GeneratePInvoke */
1142 void moonlight_scriptable_object_emit_event (PluginInstance *plugin,
1143 MoonlightScriptableObjectObject *obj,
1144 MoonlightScriptableObjectObject *event_args,
1145 NPObject *cb_obj);
1147 /*** HtmlObject ***************************************************/
1149 // int clientX, int clientY,
1151 typedef void callback_dom_event (gpointer context, char *name, int client_x, int client_y, int offset_x, int offset_y, gboolean alt_key,
1152 gboolean ctrl_key, gboolean shift_key, int mouse_button,
1153 int key_code, int char_code,
1154 gpointer domEvent);
1156 const char *html_get_element_text (PluginInstance *plugin, const char *element_id);
1158 // These are meant to be called by System.Silverlight.dll
1159 /* @GeneratePInvoke */
1160 bool html_object_has_property (PluginInstance *plugin, NPObject *npobj, char *name);
1161 /* @GeneratePInvoke */
1162 void html_object_get_property (PluginInstance *plugin, NPObject *npobj, char *name, /* @MarshalAs=Mono.Value,IsOut */ Value *result);
1163 /* @GeneratePInvoke */
1164 void html_object_set_property (PluginInstance *plugin, NPObject *npobj, char *name, Value *value);
1165 /* @GeneratePInvoke */
1166 bool html_object_invoke (PluginInstance *plugin, NPObject *npobj, char *name, /* @MarshalAs=Mono.Value[] */ Value *args, guint32 arg_count, /* @MarshalAs=Mono.Value,IsOut */ Value *result);
1167 /* @GeneratePInvoke */
1168 bool html_object_invoke_self (PluginInstance *plugin, NPObject *npobj, /* @MarshalAs=Mono.Value[] */ Value *args, guint32 arg_count, /* @MarshalAs=Mono.Value,IsOut */ Value *result);
1169 /* @GeneratePInvoke */
1170 gpointer html_object_attach_event (PluginInstance *plugin, NPObject *npobj, char *name, callback_dom_event *cb, gpointer context);
1171 /* @GeneratePInvoke */
1172 void html_object_detach_event (PluginInstance *plugin, const char *name, gpointer listener);
1173 /* @GeneratePInvoke */
1174 void html_object_release (PluginInstance *plugin, NPObject *npobj);
1175 /* @GeneratePInvoke */
1176 void html_object_retain (PluginInstance *plugin, NPObject *npobj);
1178 /*** Browser interaction utility classes ***/
1179 void browser_do_alert (PluginInstance *plugin, char *msg);
1182 G_END_DECLS
1184 #endif /* __PLUGIN_CLASS_H__ */