revert previous commit
[moon.git] / plugin / plugin-class.h
blob608d843a0555daf43253e120150bc2a45104d533
1 /*
2 * Automatically generated, do not edit this file directly
3 */
5 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
6 /*
7 * plugin-class.h: MoonLight browser plugin - autogenerated header classes
9 * Contact:
10 * Moonlight List (moonlight-list@lists.ximian.com)
12 * Copyright 2007-2009 Novell, Inc. (http://www.novell.com)
14 * See the LICENSE file included with the distribution for details.
18 #ifndef __PLUGIN_CLASS_H__
19 #define __PLUGIN_CLASS_H__
21 #include "moonlight.h"
22 #include "error.h"
23 #include "plugin.h"
25 // debug javascript
26 #define DEBUG_JAVASCRIPT 1
28 #define DEPENDENCY_OBJECT_FROM_VARIANT(obj) (((MoonlightDependencyObjectObject*) NPVARIANT_TO_OBJECT (obj))->GetDependencyObject ())
30 #define THROW_JS_EXCEPTION(meth) \
31 do { \
32 char *message = g_strdup_printf ("Error calling method: %s", meth); \
33 NPN_SetException (this, message); \
34 g_free (message); \
35 return true; \
36 } while (0); \
38 #define THROW_JS_EXCEPTION2(obj, meth) \
39 do { \
40 char *message = g_strdup_printf ("Error calling method: %s", meth); \
41 NPN_SetException (obj, message); \
42 g_free (message); \
43 } while (0); \
46 enum PluginPropertyId {
47 NoMapping = 0,
49 // property names
50 MoonId_ErrorCode = 0x4000,
51 MoonId_ErrorType,
52 MoonId_ErrorMessage,
53 MoonId_LineNumber,
54 MoonId_CharPosition,
55 MoonId_XamlFile,
56 MoonId_MethodName,
57 MoonId_X,
58 MoonId_Y,
59 MoonId_Left,
60 MoonId_Right,
61 MoonId_Top,
62 MoonId_Bottom,
63 MoonId_TopLeft,
64 MoonId_TopRight,
65 MoonId_BottomLeft,
66 MoonId_BottomRight,
67 MoonId_Width,
68 MoonId_Height,
69 MoonId_Seconds,
70 MoonId_Name,
71 MoonId_Shift,
72 MoonId_Ctrl,
73 MoonId_Marker,
74 MoonId_Key,
75 MoonId_PlatformKeyCode,
76 MoonId_Progress,
77 MoonId_Settings,
78 MoonId_Content,
79 MoonId_InitParams,
80 MoonId_Id,
81 MoonId_IsLoaded,
82 MoonId_Source,
83 MoonId_Background,
84 MoonId_EnableFramerateCounter,
85 MoonId_EnableRedrawRegions,
86 MoonId_EnableHtmlAccess,
87 MoonId_MaxFrameRate,
88 MoonId_Version,
89 MoonId_Windowless,
90 MoonId_ActualHeight,
91 MoonId_ActualWidth,
92 MoonId_FullScreen,
93 MoonId_Root,
94 MoonId_Count,
95 MoonId_ResponseText,
96 MoonId_DeviceType,
97 MoonId_IsInverted,
98 MoonId_Handled,
99 MoonId_GridUnitType,
100 MoonId_Value,
101 MoonId_Accessibility,
102 MoonId_MultiScaleImage_Source,
104 // event names (handled by the property setters)
105 MoonId_BufferingProgressChanged,
106 MoonId_Completed,
107 MoonId_CurrentStateChanged,
108 MoonId_DownloadProgressChanged,
109 MoonId_GotFocus,
110 MoonId_ImageFailed,
111 MoonId_KeyDown,
112 MoonId_KeyUp,
113 MoonId_LostFocus,
114 MoonId_Loaded,
115 MoonId_MarkerReached,
116 MoonId_MediaEnded,
117 MoonId_MediaFailed,
118 MoonId_MediaOpened,
119 MoonId_MouseEnter,
120 MoonId_MouseLeave,
121 MoonId_MouseMove,
122 MoonId_MouseLeftButtonDown,
123 MoonId_MouseLeftButtonUp,
124 MoonId_OnResize,
125 MoonId_OnFullScreenChange,
126 MoonId_OnError,
127 MoonId_OnLoad,
128 MoonId_OnSourceDownloadProgressChanged,
129 MoonId_OnSourceDownloadComplete,
131 // method names
132 MoonId_GetPosition = 0x8000,
133 MoonId_CreateObject,
134 MoonId_IsVersionSupported,
135 MoonId_FindName,
136 MoonId_CreateFromXaml,
137 MoonId_CreateFromXamlDownloader,
138 MoonId_Equals,
139 MoonId_GetHost,
140 MoonId_GetParent,
141 MoonId_GetStylusInfo,
142 MoonId_GetStylusPoints,
143 MoonId_CaptureMouse,
144 MoonId_ReleaseMouseCapture,
145 MoonId_AddEventListener,
146 MoonId_RemoveEventListener,
147 MoonId_SetValue,
148 MoonId_GetValue,
149 MoonId_ToString,
150 #if DEBUG_JAVASCRIPT
151 MoonId_Printf,
152 MoonId_DumpNameScope,
153 #endif
154 MoonId_Add,
155 MoonId_Remove,
156 MoonId_RemoveAt,
157 MoonId_Insert,
158 MoonId_Clear,
159 MoonId_GetItem,
160 MoonId_GetItemByName,
161 MoonId_Begin,
162 MoonId_Pause,
163 MoonId_Resume,
164 MoonId_Seek,
165 MoonId_Stop,
166 MoonId_Play,
167 MoonId_SetSource,
168 MoonId_SetFontSource,
169 MoonId_Abort,
170 MoonId_Open,
171 MoonId_GetResponseText,
172 MoonId_Send,
173 MoonId_AddStylusPoints,
174 MoonId_GetBounds,
175 MoonId_HitTest,
176 MoonId_UpdateLayout,
178 MoonId_StopPropagation,
179 MoonId_PreventDefault,
180 MoonId_Detail,
182 MoonId_Focus,
184 MoonId_Select,
185 MoonId_SelectAll,
187 MoonId_MultiScaleImage_GetIthSubImage,
188 MoonId_MultiScaleImage_GetSubImageCount,
189 MoonId_MultiScaleImage_LogicalToElementX,
190 MoonId_MultiScaleImage_LogicalToElementY,
191 MoonId_MultiScaleImage_ZoomAboutLogicalPoint,
192 MoonId_UIElement_CaptureMouse,
193 MoonId_UIElement_TransformToVisual,
194 MoonId_UIElement_ReleaseMouseCapture,
195 MoonId_UIElement_UpdateLayout,
200 #define MAPPING_FLAG_SL1 0x01
201 #define MAPPING_FLAG_SL2 0x02
203 struct MoonNameIdMapping {
204 const char *name;
205 int id;
208 #define IS_METHOD(id) (((id) & 0x8000) != 0)
209 #define IS_PROPERTY(id) (((id) & 0x4000) != 0)
212 G_BEGIN_DECLS
213 G_GNUC_INTERNAL bool npobject_is_dependency_object (NPObject *obj);
215 G_GNUC_INTERNAL bool check_arg_list (const char *arglist, guint32 argc, const NPVariant *argv);
217 G_GNUC_INTERNAL void plugin_init_classes (void);
218 G_GNUC_INTERNAL void plugin_destroy_classes (void);
220 G_GNUC_INTERNAL void event_object_add_xaml_listener (EventObject *obj, PluginInstance *instance, const char *event_name, const char *cb_name);
222 void string_to_npvariant (const char *value, NPVariant *result);
223 G_GNUC_INTERNAL void variant_to_value (const NPVariant *v, Value **result);
224 G_END_DECLS
227 class MoonlightObject;
229 /*** EventListenerProxy */
230 typedef void (*EventArgsWrapper)(NPP instance, EventArgs *calldata, NPVariant *value);
232 class EventListenerProxy : public EventObject {
233 static void on_handler_removed (gpointer closure);
235 EventObject *target_object;
236 MoonlightObject *owner;
238 PluginInstance *plugin;
239 bool is_func;
241 /* if @is_func == true, callback is an NPObject (the function object)
242 if @is_func == false, callback is a char* (the function name)
244 gpointer callback;
246 char *event_name;
247 int event_id;
248 int token;
250 bool one_shot;
252 public:
253 EventListenerProxy (PluginInstance *plugin, const char *event_name, const char *cb_name);
254 EventListenerProxy (PluginInstance *plugin, const char *event_name, const NPVariant *cb);
255 virtual ~EventListenerProxy ();
257 void SetOwner (MoonlightObject *owner);
259 int AddXamlHandler (EventObject *obj);
260 int AddHandler (EventObject *obj);
261 void RemoveHandler ();
262 const char *GetCallbackAsString ();
264 int GetEventId () { return event_id; }
265 int GetEventToken () { return token; }
267 void SetOneShot () { one_shot = true; }
268 gpointer GetCallback () { return callback; }
269 bool IsFunc () { return is_func; }
271 PluginInstance *GetPlugin () { return plugin; }
272 NPP GetInstance () { return plugin->GetInstance (); }
274 static void proxy_listener_to_javascript (EventObject *sender, EventArgs *calldata, gpointer closure);
278 /*** MoonlightObjectClass **************************************************************/
280 struct MoonlightObjectType : NPClass {
281 MoonlightObjectType ();
283 ~MoonlightObjectType() { g_free (mapping); }
285 void AddMapping (const MoonNameIdMapping *mapping, int count);
287 bool Enumerate (NPIdentifier **value, guint32 *count);
289 int LookupName (NPIdentifier name);
291 MoonNameIdMapping *mapping;
292 int mapping_count;
294 NPIdentifier last_lookup;
295 int last_id;
298 extern MoonlightObjectType *MoonlightObjectClass;
300 struct MoonlightObject : NPObject {
301 MoonlightObject (NPP instance)
303 #if SANITY
304 g_assert (instance->pdata != NULL); /* #if SANITY */
305 #endif
306 this->plugin = (PluginInstance *) instance->pdata;
307 if (this->plugin)
308 this->plugin->ref ();
309 this->moonlight_type = Type::INVALID;
310 this->event_listener_proxies = g_hash_table_new (g_direct_hash, g_direct_equal);
313 virtual void Invalidate () { }
314 virtual ~MoonlightObject ();
316 virtual bool HasProperty (NPIdentifier name);
317 virtual bool GetProperty (int id, NPIdentifier name, NPVariant *result);
318 virtual bool SetProperty (int id, NPIdentifier name, const NPVariant *value);
320 virtual bool HasMethod (NPIdentifier unmapped);
321 virtual bool Invoke (int id, NPIdentifier name,
322 const NPVariant *args, guint32 argCount, NPVariant *result);
323 int LookupName (NPIdentifier name) { return ((MoonlightObjectType *)_class)->LookupName (name); }
325 void SetPlugin (PluginInstance *plugin)
327 if (this->plugin)
328 this->plugin->unref ();
329 this->plugin = plugin;
330 this->plugin->ref ();
333 EventListenerProxy *LookupEventProxy (int event_id);
334 void SetEventProxy (EventListenerProxy* proxy);
335 void ClearEventProxy (EventListenerProxy *proxy);
336 void ClearEventProxies ();
337 NPP GetInstance () { return plugin->GetInstance (); }
338 PluginInstance *GetPlugin () { return plugin; }
340 static void destroy_proxy (gpointer data);
341 static void invalidate_proxy (gpointer key, gpointer value, gpointer data);
343 PluginInstance *plugin;
344 Type::Kind moonlight_type;
345 GHashTable *event_listener_proxies;
349 /*** MoonlightEventObjectClass ***************************************************/
350 struct MoonlightEventObjectType : MoonlightObjectType {
351 MoonlightEventObjectType ();
354 extern MoonlightEventObjectType *MoonlightEventObjectClass;
356 struct MoonlightEventObjectObject : MoonlightObject {
357 MoonlightEventObjectObject (NPP instance) : MoonlightObject (instance)
359 moonlight_type = Type::EVENTOBJECT;
360 eo = NULL;
363 virtual ~MoonlightEventObjectObject ();
365 EventObject *eo;
368 extern MoonlightEventObjectObject *EventObjectCreateWrapper (PluginInstance *plugin, EventObject *obj);
370 /*** MoonlightDependencyObjectClass ***************************************************/
371 struct MoonlightDependencyObjectType : MoonlightEventObjectType {
372 MoonlightDependencyObjectType ();
376 struct MoonlightDependencyObjectObject : MoonlightEventObjectObject {
377 MoonlightDependencyObjectObject (NPP instance) : MoonlightEventObjectObject (instance)
379 moonlight_type = Type::DEPENDENCY_OBJECT;
382 DependencyObject *GetDependencyObject ()
384 if (eo == NULL || !eo->Is (Type::DEPENDENCY_OBJECT)) {
385 g_warning ("MoonlightDependencyObjectObject::GetDependencyObject (): Not a dependency object!");
386 return NULL;
389 return (DependencyObject*) eo;
392 virtual bool HasProperty (NPIdentifier unmapped);
393 virtual bool GetProperty (int id, NPIdentifier unmapped, NPVariant *result);
394 virtual bool SetProperty (int id, NPIdentifier unmapped, const NPVariant *value);
396 virtual bool Invoke (int id, NPIdentifier name,
397 const NPVariant *args, guint32 argCount, NPVariant *result);
401 extern MoonlightDependencyObjectObject *DependencyObjectCreateWrapper (NPP instance, DependencyObject *obj);
404 /*************** AUTO GENERATED CLASSES ****************************/
406 /*** MoonlightUIElementClass *********/
407 struct MoonlightUIElementType : MoonlightDependencyObjectType {
408 MoonlightUIElementType ();
411 extern MoonlightUIElementType *MoonlightUIElementClass;
413 struct MoonlightUIElementObject : MoonlightDependencyObjectObject {
414 MoonlightUIElementObject (NPP instance) : MoonlightDependencyObjectObject (instance)
416 moonlight_type = Type::UIELEMENT;
419 virtual bool Invoke (int id, NPIdentifier name,
420 const NPVariant *args, guint32 argCount, NPVariant *result);
425 /*************** END OF AUTO GENERATED CLASSES *********************/
427 /*** MoonlightPointClass **************************************************************/
428 struct MoonlightPointType : MoonlightObjectType {
429 MoonlightPointType ();
432 extern MoonlightPointType *MoonlightPointClass;
434 struct MoonlightPoint : MoonlightObject {
435 MoonlightPoint (NPP instance) : MoonlightObject(instance), point (Point())
437 moonlight_type = Type::POINT;
440 virtual bool GetProperty (int id, NPIdentifier unmapped, NPVariant *result);
441 virtual bool SetProperty (int id, NPIdentifier unmapped, const NPVariant *value);
443 Point point;
446 /*** MoonlightRectClass **************************************************************/
447 struct MoonlightRectType : MoonlightObjectType {
448 MoonlightRectType ();
451 extern MoonlightRectType *MoonlightRectClass;
453 struct MoonlightRect : MoonlightObject {
454 MoonlightRect (NPP instance) : MoonlightObject(instance), rect (Rect())
456 moonlight_type = Type::RECT;
459 virtual bool GetProperty (int id, NPIdentifier unmapped, NPVariant *result);
460 virtual bool SetProperty (int id, NPIdentifier unmapped, const NPVariant *value);
462 Rect rect;
466 /*** MoonlightDurationClass **************************************************************/
467 struct MoonlightDurationType : MoonlightObjectType {
468 MoonlightDurationType ();
471 extern MoonlightDurationType *MoonlightDurationClass;
473 struct MoonlightDuration : MoonlightObject {
474 MoonlightDuration (NPP instance) : MoonlightObject (instance)
476 moonlight_type = Type::DURATION;
477 parent_property = NULL;
478 parent_obj = NULL;
481 virtual ~MoonlightDuration ();
483 void SetParentInfo (DependencyObject *parent_obj, DependencyProperty *parent_property);
485 double GetValue ();
487 virtual bool GetProperty (int id, NPIdentifier unmapped, NPVariant *result);
488 virtual bool SetProperty (int id, NPIdentifier unmapped, const NPVariant *value);
490 DependencyProperty *parent_property;
491 DependencyObject *parent_obj;
494 /*** MoonlightTimeSpanClass **************************************************************/
495 struct MoonlightTimeSpanType : MoonlightObjectType {
496 MoonlightTimeSpanType ();
499 extern MoonlightTimeSpanType *MoonlightTimeSpanClass;
501 struct MoonlightTimeSpan : MoonlightObject {
502 MoonlightTimeSpan (NPP instance) : MoonlightObject (instance)
504 moonlight_type = Type::TIMESPAN;
505 parent_property = NULL;
506 parent_obj = NULL;
509 virtual ~MoonlightTimeSpan ();
511 void SetParentInfo (DependencyObject *parent_obj, DependencyProperty *parent_property);
513 TimeSpan GetValue ();
515 virtual bool GetProperty (int id, NPIdentifier unmapped, NPVariant *result);
516 virtual bool SetProperty (int id, NPIdentifier unmapped, const NPVariant *value);
518 DependencyProperty *parent_property;
519 DependencyObject *parent_obj;
522 /*** MoonlightKeyTimeClass ****************************************************************/
523 struct MoonlightKeyTimeType : MoonlightObjectType {
524 MoonlightKeyTimeType ();
527 extern MoonlightKeyTimeType *MoonlightKeyTimeClass;
529 struct MoonlightKeyTime : MoonlightObject {
530 MoonlightKeyTime (NPP instance) : MoonlightObject (instance)
532 moonlight_type = Type::KEYTIME;
533 parent_property = NULL;
534 parent_obj = NULL;
537 virtual ~MoonlightKeyTime ();
539 void SetParentInfo (DependencyObject *parent_obj, DependencyProperty *parent_property);
541 KeyTime* GetValue ();
543 virtual bool GetProperty (int id, NPIdentifier unmapped, NPVariant *result);
544 virtual bool SetProperty (int id, NPIdentifier unmapped, const NPVariant *value);
546 DependencyProperty *parent_property;
547 DependencyObject *parent_obj;
550 /*** MoonlightThicknessClass ****************************************************************/
551 struct MoonlightThicknessType : MoonlightObjectType {
552 MoonlightThicknessType ();
555 extern MoonlightThicknessType *MoonlightThicknessClass;
557 struct MoonlightThickness : MoonlightObject {
558 MoonlightThickness (NPP instance) : MoonlightObject (instance)
560 moonlight_type = Type::THICKNESS;
561 parent_property = NULL;
562 parent_obj = NULL;
565 virtual ~MoonlightThickness ();
567 void SetParentInfo (DependencyObject *parent_obj, DependencyProperty *parent_property);
569 Thickness* GetValue ();
571 virtual bool GetProperty (int id, NPIdentifier unmapped, NPVariant *result);
572 virtual bool SetProperty (int id, NPIdentifier unmapped, const NPVariant *value);
574 DependencyProperty *parent_property;
575 DependencyObject *parent_obj;
578 /*** MoonlightCornerRadiusClass ****************************************************************/
579 struct MoonlightCornerRadiusType : MoonlightObjectType {
580 MoonlightCornerRadiusType ();
583 extern MoonlightCornerRadiusType *MoonlightCornerRadiusClass;
585 struct MoonlightCornerRadius : MoonlightObject {
586 MoonlightCornerRadius (NPP instance) : MoonlightObject (instance)
588 moonlight_type = Type::CORNERRADIUS;
589 parent_property = NULL;
590 parent_obj = NULL;
593 virtual ~MoonlightCornerRadius ();
595 void SetParentInfo (DependencyObject *parent_obj, DependencyProperty *parent_property);
597 CornerRadius* GetValue ();
599 virtual bool GetProperty (int id, NPIdentifier unmapped, NPVariant *result);
600 virtual bool SetProperty (int id, NPIdentifier unmapped, const NPVariant *value);
602 DependencyProperty *parent_property;
603 DependencyObject *parent_obj;
606 /*** MoonlightGridLengthClass ****************************************************************/
607 struct MoonlightGridLengthType : MoonlightObjectType {
608 MoonlightGridLengthType ();
611 extern MoonlightGridLengthType *MoonlightGridLengthClass;
613 struct MoonlightGridLength : MoonlightObject {
614 MoonlightGridLength (NPP instance) : MoonlightObject (instance)
616 moonlight_type = Type::GRIDLENGTH;
617 parent_property = NULL;
618 parent_obj = NULL;
621 virtual ~MoonlightGridLength ();
623 void SetParentInfo (DependencyObject *parent_obj, DependencyProperty *parent_property);
625 GridLength* GetValue ();
627 virtual bool GetProperty (int id, NPIdentifier unmapped, NPVariant *result);
628 virtual bool SetProperty (int id, NPIdentifier unmapped, const NPVariant *value);
630 DependencyProperty *parent_property;
631 DependencyObject *parent_obj;
634 /*** MoonlightSettingsClass ***********************************************************/
636 struct MoonlightSettingsType : MoonlightObjectType {
637 MoonlightSettingsType ();
640 extern MoonlightSettingsType *MoonlightSettingsClass;
642 struct MoonlightSettingsObject : MoonlightObject {
643 MoonlightSettingsObject (NPP instance) : MoonlightObject (instance)
647 virtual bool GetProperty (int id, NPIdentifier unmapped, NPVariant *result);
648 virtual bool SetProperty (int id, NPIdentifier unmapped, const NPVariant *value);
650 virtual bool Invoke (int id, NPIdentifier name,
651 const NPVariant *args, guint32 argCount, NPVariant *result);
655 /*** MoonlightContentClass ************************************************************/
657 struct MoonlightContentType : MoonlightObjectType {
658 MoonlightContentType ();
661 extern MoonlightContentType *MoonlightContentClass;
663 struct MoonlightContentObject : MoonlightObject {
664 MoonlightContentObject (NPP instance) : MoonlightObject (instance)
666 registered_scriptable_objects = g_hash_table_new (g_direct_hash, g_direct_equal);
667 accessibility = NULL;
670 virtual ~MoonlightContentObject ();
672 virtual bool HasProperty (NPIdentifier unmapped);
673 virtual bool GetProperty (int id, NPIdentifier unmapped, NPVariant *result);
674 virtual bool SetProperty (int id, NPIdentifier unmapped, const NPVariant *value);
676 virtual bool Invoke (int id, NPIdentifier name,
677 const NPVariant *args, guint32 argCount, NPVariant *result);
679 DependencyObject *accessibility;
680 GHashTable *registered_scriptable_objects;
683 /*** MoonlightScriptControlClass **********************************************************/
685 struct MoonlightScriptControlType : MoonlightObjectType {
686 MoonlightScriptControlType ();
689 extern MoonlightScriptControlType *MoonlightScriptControlClass;
691 struct MoonlightScriptControlObject : MoonlightObject {
692 MoonlightScriptControlObject (NPP instance) : MoonlightObject (instance)
694 settings = (MoonlightSettingsObject *) NPN_CreateObject (instance, MoonlightSettingsClass);
695 content = (MoonlightContentObject *) NPN_CreateObject (instance, MoonlightContentClass);
698 virtual ~MoonlightScriptControlObject ();
700 virtual void Invalidate ();
702 virtual bool GetProperty (int id, NPIdentifier unmapped, NPVariant *result);
703 virtual bool SetProperty (int id, NPIdentifier unmapped, const NPVariant *value);
705 virtual bool Invoke (int id, NPIdentifier name,
706 const NPVariant *args, guint32 argCount, NPVariant *result);
708 MoonlightSettingsObject *settings;
709 MoonlightContentObject *content;
711 /* store the current event handlers so that they survive PluginInstance destruction */
712 void PreSwitchPlugin (PluginInstance *old_plugin, PluginInstance *new_plugin);
713 /* restore the stored event handlers into the new PluginInstance */
714 void PostSwitchPlugin (PluginInstance *old_plugin, PluginInstance *new_plugin);
716 private:
717 /* fields for storing the data in PreSwitchPlugin */
718 int events_count;
719 int *events_to_switch;
720 MoonlightObject **events_object;
721 gpointer *events_callbacks;
722 bool *events_is_func;
726 /*** MoonlightEventArgsClass ******************************************************/
727 struct MoonlightEventArgsType : MoonlightDependencyObjectType {
728 MoonlightEventArgsType ();
731 struct MoonlightEventArgs : MoonlightDependencyObjectObject {
732 MoonlightEventArgs (NPP instance) : MoonlightDependencyObjectObject (instance)
734 moonlight_type = Type::EVENTARGS;
738 /*** MoonlightEventArgsClass ******************************************************/
739 struct MoonlightRoutedEventArgsType : MoonlightEventArgsType {
740 MoonlightRoutedEventArgsType ();
743 struct MoonlightRoutedEventArgs : MoonlightEventArgs {
744 MoonlightRoutedEventArgs (NPP instance) : MoonlightEventArgs (instance)
746 moonlight_type = Type::ROUTEDEVENTARGS;
749 virtual bool GetProperty (int id, NPIdentifier unmapped, NPVariant *result);
751 RoutedEventArgs *GetRoutedEventArgs () { return (RoutedEventArgs *) eo; }
754 /*** MoonlightMouseEventArgsClass **************************************************************/
755 struct MoonlightMouseEventArgsType : MoonlightRoutedEventArgsType {
756 MoonlightMouseEventArgsType ();
759 struct MoonlightMouseEventArgsObject : MoonlightRoutedEventArgs {
760 MoonlightMouseEventArgsObject (NPP instance) : MoonlightRoutedEventArgs (instance)
762 moonlight_type = Type::MOUSEEVENTARGS;
765 virtual bool GetProperty (int id, NPIdentifier unmapped, NPVariant *result);
766 virtual bool SetProperty (int id, NPIdentifier unmapped, const NPVariant *value);
767 virtual bool Invoke (int id, NPIdentifier name,
768 const NPVariant *args, guint32 argCount, NPVariant *result);
770 MouseEventArgs *GetMouseEventArgs () { return (MouseEventArgs *) eo; };
773 /*** MoonlightMarkerReachedEventArgsClass ******************************************/
774 struct MoonlightTimelineMarkerRoutedEventArgsType : MoonlightRoutedEventArgsType {
775 MoonlightTimelineMarkerRoutedEventArgsType ();
778 extern MoonlightTimelineMarkerRoutedEventArgsType *MoonlightTimelineMarkerRoutedEventArgsClass;
780 struct MoonlightTimelineMarkerRoutedEventArgsObject : MoonlightRoutedEventArgs {
781 MoonlightTimelineMarkerRoutedEventArgsObject (NPP instance) : MoonlightRoutedEventArgs (instance)
783 moonlight_type = Type::TIMELINEMARKERROUTEDEVENTARGS;
786 virtual bool GetProperty (int id, NPIdentifier unmapped, NPVariant *result);
788 TimelineMarkerRoutedEventArgs *GetTimelineMarkerRoutedEventArgs () { return (TimelineMarkerRoutedEventArgs *) eo; }
791 /*** MoonlightKeyEventArgsClass **************************************************************/
792 struct MoonlightKeyEventArgsType : MoonlightEventArgsType {
793 MoonlightKeyEventArgsType ();
796 struct MoonlightKeyEventArgsObject : MoonlightEventArgs {
797 MoonlightKeyEventArgsObject (NPP instance) : MoonlightEventArgs (instance)
799 moonlight_type = Type::KEYEVENTARGS;
802 virtual bool GetProperty (int id, NPIdentifier unmapped, NPVariant *result);
803 KeyEventArgs *GetKeyEventArgs () { return (KeyEventArgs *) eo; }
806 /*** MoonlightDownloadProgressEventArgsClass ******************************************************/
807 struct MoonlightDownloadProgressEventArgsType : MoonlightEventArgsType {
808 MoonlightDownloadProgressEventArgsType ();
811 struct MoonlightDownloadProgressEventArgs : MoonlightEventArgs {
812 MoonlightDownloadProgressEventArgs (NPP instance) : MoonlightEventArgs (instance)
814 moonlight_type = Type::DOWNLOADPROGRESSEVENTARGS;
817 DownloadProgressEventArgs *GetDownloadProgressEventArgs () { return (DownloadProgressEventArgs *) eo; }
818 virtual bool GetProperty (int id, NPIdentifier unmapped, NPVariant *result);
821 /*** MoonlightErrorEventArgsClass ******************************************************/
822 struct MoonlightErrorEventArgsType : MoonlightEventArgsType {
823 MoonlightErrorEventArgsType ();
826 struct MoonlightErrorEventArgs : MoonlightEventArgs {
827 MoonlightErrorEventArgs (NPP instance) : MoonlightEventArgs (instance)
829 moonlight_type = Type::ERROREVENTARGS;
832 ErrorEventArgs *GetErrorEventArgs () { return (ErrorEventArgs *) eo; }
833 virtual bool GetProperty (int id, NPIdentifier unmapped, NPVariant *result);
836 /*** MoonlightCollectionClass ***************************************************/
838 struct MoonlightCollectionType : MoonlightDependencyObjectType {
839 MoonlightCollectionType ();
842 struct MoonlightCollectionObject : MoonlightDependencyObjectObject {
843 MoonlightCollectionObject (NPP instance) : MoonlightDependencyObjectObject (instance)
845 moonlight_type = Type::COLLECTION;
848 virtual bool GetProperty (int id, NPIdentifier unmapped, NPVariant *result);
850 virtual bool Invoke (int id, NPIdentifier name,
851 const NPVariant *args, guint32 argCount, NPVariant *result);
854 /*** MoonlightStoryboardClass ***************************************************/
856 struct MoonlightStoryboardType : MoonlightDependencyObjectType {
857 MoonlightStoryboardType ();
860 struct MoonlightStoryboardObject : MoonlightDependencyObjectObject {
861 MoonlightStoryboardObject (NPP instance) : MoonlightDependencyObjectObject (instance)
863 moonlight_type = Type::STORYBOARD;
866 virtual bool Invoke (int id, NPIdentifier name,
867 const NPVariant *args, guint32 argCount, NPVariant *result);
870 /*** MoonlightMediaElement ***************************************************/
872 struct MoonlightMediaElementType : MoonlightUIElementType {
873 MoonlightMediaElementType ();
877 struct MoonlightMediaElementObject : MoonlightUIElementObject {
878 MoonlightMediaElementObject (NPP instance) : MoonlightUIElementObject (instance)
880 moonlight_type = Type::MEDIAELEMENT;
883 virtual bool Invoke (int id, NPIdentifier name,
884 const NPVariant *args, guint32 argCount, NPVariant *result);
887 /*** MoonlightMultiScaleImage ***************************************************/
889 struct MoonlightMultiScaleImageType : MoonlightDependencyObjectType {
890 MoonlightMultiScaleImageType ();
893 struct MoonlightMultiScaleImageObject : MoonlightDependencyObjectObject {
894 MoonlightMultiScaleImageObject (NPP instance) : MoonlightDependencyObjectObject (instance)
896 moonlight_type = Type::MULTISCALEIMAGE;
899 virtual bool Invoke (int id, NPIdentifier name,
900 const NPVariant *args, guint32 argCount, NPVariant *result);
902 virtual bool SetProperty (int id, NPIdentifier name, const NPVariant *value);
905 /*** MoonlightImage ***************************************************/
907 struct MoonlightImageType : MoonlightUIElementType {
908 MoonlightImageType ();
912 struct MoonlightImageObject : MoonlightUIElementObject {
913 MoonlightImageObject (NPP instance) : MoonlightUIElementObject (instance)
915 moonlight_type = Type::IMAGE;
918 virtual bool Invoke (int id, NPIdentifier name,
919 const NPVariant *args, guint32 argCount, NPVariant *result);
920 virtual bool GetProperty (int id, NPIdentifier unmapped, NPVariant *result);
923 /*** MoonlightImageBrush ***************************************************/
925 struct MoonlightImageBrushType : MoonlightDependencyObjectType {
926 MoonlightImageBrushType ();
930 struct MoonlightImageBrushObject : MoonlightDependencyObjectObject {
931 MoonlightImageBrushObject (NPP instance) : MoonlightDependencyObjectObject (instance)
933 moonlight_type = Type::IMAGEBRUSH;
936 virtual bool Invoke (int id, NPIdentifier name,
937 const NPVariant *args, guint32 argCount, NPVariant *result);
938 virtual bool GetProperty (int id, NPIdentifier unmapped, NPVariant *result);
941 /*** MoonlightDownloader ***************************************************/
943 struct MoonlightDownloaderType : MoonlightDependencyObjectType {
944 MoonlightDownloaderType ();
948 struct MoonlightDownloaderObject : MoonlightDependencyObjectObject {
949 MoonlightDownloaderObject (NPP instance) : MoonlightDependencyObjectObject (instance)
951 moonlight_type = Type::DOWNLOADER;
954 virtual bool GetProperty (int id, NPIdentifier unmapped, NPVariant *result);
955 virtual bool Invoke (int id, NPIdentifier name,
956 const NPVariant *args, guint32 argCount, NPVariant *result);
959 /*** MoonlightTextBlock ***************************************************/
961 struct MoonlightTextBlockType : MoonlightUIElementType {
962 MoonlightTextBlockType ();
966 struct MoonlightTextBlockObject : MoonlightUIElementObject {
967 MoonlightTextBlockObject (NPP instance) : MoonlightUIElementObject (instance)
969 moonlight_type = Type::TEXTBLOCK;
972 virtual bool Invoke (int id, NPIdentifier name,
973 const NPVariant *args, guint32 argCount, NPVariant *result);
976 /*** MoonlightControl ***************************************************/
978 struct MoonlightControlType : MoonlightUIElementType {
979 MoonlightControlType ();
982 extern MoonlightControlType *MoonlightControlClass;
984 struct MoonlightControlObject : MoonlightUIElementObject {
985 MoonlightControlObject (NPP instance) : MoonlightUIElementObject (instance)
987 moonlight_type = Type::CONTROL;
990 virtual bool Invoke (int id, NPIdentifier name, const NPVariant *args, guint32 argCount, NPVariant *result);
993 /*** MoonlightTextBox ***************************************************/
995 struct MoonlightTextBoxType : MoonlightControlType {
996 MoonlightTextBoxType ();
1000 struct MoonlightTextBoxObject : MoonlightControlObject {
1001 MoonlightTextBoxObject (NPP instance) : MoonlightControlObject (instance)
1003 moonlight_type = Type::TEXTBOX;
1006 virtual bool Invoke (int id, NPIdentifier name,
1007 const NPVariant *args, guint32 argCount, NPVariant *result);
1011 /*** MoonlightPasswordBox ***************************************************/
1013 struct MoonlightPasswordBoxType : MoonlightControlType {
1014 MoonlightPasswordBoxType ();
1018 struct MoonlightPasswordBoxObject : MoonlightControlObject {
1019 MoonlightPasswordBoxObject (NPP instance) : MoonlightControlObject (instance)
1021 moonlight_type = Type::PASSWORDBOX;
1024 virtual bool Invoke (int id, NPIdentifier name,
1025 const NPVariant *args, guint32 argCount, NPVariant *result);
1028 /*** MoonlightStylusInfoType ***************************************************/
1030 struct MoonlightStylusInfoType : MoonlightDependencyObjectType {
1031 MoonlightStylusInfoType ();
1035 struct MoonlightStylusInfoObject : MoonlightDependencyObjectObject {
1036 MoonlightStylusInfoObject (NPP instance) : MoonlightDependencyObjectObject (instance)
1038 moonlight_type = Type::STYLUSINFO;
1041 virtual bool GetProperty (int id, NPIdentifier unmapped, NPVariant *result);
1044 /*** MoonlightStylusPointCollectionType *************************************/
1046 struct MoonlightStylusPointCollectionType : MoonlightCollectionType {
1047 MoonlightStylusPointCollectionType ();
1051 struct MoonlightStylusPointCollectionObject : MoonlightCollectionObject {
1052 MoonlightStylusPointCollectionObject (NPP instance) : MoonlightCollectionObject (instance)
1054 moonlight_type = Type::STYLUSPOINT_COLLECTION;
1057 virtual bool Invoke (int id, NPIdentifier name,
1058 const NPVariant *args, guint32 argCount, NPVariant *result);
1062 /*** MoonlightStrokeCollectionType *************************************/
1064 struct MoonlightStrokeCollectionType : MoonlightCollectionType {
1065 MoonlightStrokeCollectionType ();
1069 struct MoonlightStrokeCollectionObject : MoonlightCollectionObject {
1071 MoonlightStrokeCollectionObject (NPP instance)
1072 : MoonlightCollectionObject (instance)
1074 moonlight_type = Type::STROKE_COLLECTION;
1077 virtual bool Invoke (int id, NPIdentifier name,
1078 const NPVariant *args, guint32 argCount, NPVariant *result);
1082 /*** MoonlightStrokeType *************************************/
1084 struct MoonlightStrokeType : MoonlightDependencyObjectType {
1085 MoonlightStrokeType ();
1089 struct MoonlightStrokeObject : MoonlightDependencyObjectObject {
1091 MoonlightStrokeObject (NPP instance)
1092 : MoonlightDependencyObjectObject (instance)
1094 moonlight_type = Type::STROKE;
1097 virtual bool Invoke (int id, NPIdentifier name,
1098 const NPVariant *args, guint32 argCount, NPVariant *result);
1101 /*** MoonlightScriptableObject ***************************************************/
1103 struct MoonlightScriptableObjectObject;
1105 typedef void (*InvokeDelegate) (gpointer managed_obj_handle, gpointer method_handle, char* name, Value** args, int arg_count, Value* return_value);
1106 typedef void (*SetPropertyDelegate) (gpointer managed_obj_handle, char* name, Value *value);
1107 typedef void (*GetPropertyDelegate) (gpointer managed_obj_handle, char* name, Value *value);
1108 typedef void (*EventHandlerDelegate) (gpointer managed_obj_handle, gpointer event_handle, MoonlightScriptableObjectObject* scriptable_obj, gpointer closure);
1110 struct MoonlightScriptableObjectType : MoonlightObjectType {
1111 MoonlightScriptableObjectType ();
1114 extern MoonlightScriptableObjectType *MoonlightScriptableObjectClass;
1116 struct MoonlightScriptableObjectObject : MoonlightObject {
1117 MoonlightScriptableObjectObject (NPP instance) : MoonlightObject (instance)
1119 managed_scriptable = NULL;
1120 properties = g_hash_table_new (g_direct_hash, g_direct_equal);
1121 methods = g_hash_table_new (g_direct_hash, g_direct_equal);
1122 events = g_hash_table_new (g_direct_hash, g_direct_equal);
1125 virtual ~MoonlightScriptableObjectObject ();
1127 virtual bool HasProperty (NPIdentifier name);
1128 virtual bool GetProperty (int id, NPIdentifier unmapped, NPVariant *result);
1129 virtual bool SetProperty (int id, NPIdentifier unmapped, const NPVariant *value);
1131 virtual bool HasMethod (NPIdentifier name);
1132 virtual bool Invoke (int id, NPIdentifier name,
1133 const NPVariant *args, guint32 argCount, NPVariant *result);
1135 gpointer managed_scriptable;
1136 GHashTable *properties;
1137 GHashTable *methods;
1138 GHashTable *events;
1140 InvokeDelegate invoke;
1141 SetPropertyDelegate setprop;
1142 GetPropertyDelegate getprop;
1143 EventHandlerDelegate addevent;
1144 EventHandlerDelegate removeevent;
1148 G_BEGIN_DECLS
1150 // These are meant to be called by System.Silverlight.dll
1151 /* @GeneratePInvoke */
1152 NPObject * moonlight_object_to_npobject (MoonlightObject *obj);
1153 MoonlightObject * npobject_to_moonlight_object (NPObject *npobj);
1155 /* @GeneratePInvoke */
1156 MoonlightScriptableObjectObject *moonlight_scriptable_object_wrapper_create_root (PluginInstance *plugin, gpointer scriptable,
1157 InvokeDelegate invoke,
1158 SetPropertyDelegate setprop,
1159 GetPropertyDelegate getprop,
1160 EventHandlerDelegate addevent,
1161 EventHandlerDelegate removeevent);
1163 /* @GeneratePInvoke */
1164 MoonlightScriptableObjectObject *moonlight_scriptable_object_wrapper_create (NPObject *parent, gpointer scriptable,
1165 InvokeDelegate invoke,
1166 SetPropertyDelegate setprop,
1167 GetPropertyDelegate getprop,
1168 EventHandlerDelegate addevent,
1169 EventHandlerDelegate removeevent);
1171 /* @GeneratePInvoke */
1172 void moonlight_scriptable_object_add_property (PluginInstance *plugin,
1173 MoonlightScriptableObjectObject *obj,
1174 gpointer property_handle,
1175 char *property_name,
1176 /* @MarshalAs=TypeCode */ int property_type,
1177 bool can_read,
1178 bool can_write);
1180 /* @GeneratePInvoke */
1181 void moonlight_scriptable_object_add_event (PluginInstance *plugin,
1182 MoonlightScriptableObjectObject *obj,
1183 gpointer event_handle,
1184 char *event_name);
1186 /* @GeneratePInvoke */
1187 void moonlight_scriptable_object_add_method (PluginInstance *plugin,
1188 MoonlightScriptableObjectObject *obj,
1189 gpointer method_handle,
1190 char *method_name,
1191 /* @MarshalAs=TypeCode */ int method_return_type,
1192 /* @MarshalAs=TypeCode[] */ int *method_parameter_types,
1193 int parameter_count);
1195 /* @GeneratePInvoke */
1196 void moonlight_scriptable_object_register (PluginInstance *plugin,
1197 char *name,
1198 MoonlightScriptableObjectObject *obj);
1200 /* @GeneratePInvoke */
1201 void moonlight_scriptable_object_emit_event (PluginInstance *plugin,
1202 MoonlightScriptableObjectObject *obj,
1203 MoonlightScriptableObjectObject *event_args,
1204 NPObject *cb_obj);
1206 /*** HtmlObject ***************************************************/
1208 // int clientX, int clientY,
1210 typedef void callback_dom_event (gpointer context, char *name, int client_x, int client_y, int offset_x, int offset_y, gboolean alt_key,
1211 gboolean ctrl_key, gboolean shift_key, int mouse_button,
1212 int key_code, int char_code,
1213 gpointer domEvent);
1215 const char *html_get_element_text (PluginInstance *plugin, const char *element_id);
1217 // These are meant to be called by System.Silverlight.dll
1218 /* @GeneratePInvoke */
1219 bool html_object_has_property (PluginInstance *plugin, NPObject *npobj, char *name);
1220 /* @GeneratePInvoke */
1221 void html_object_get_property (PluginInstance *plugin, NPObject *npobj, char *name, /* @MarshalAs=Mono.Value,IsOut */ Value *result);
1222 /* @GeneratePInvoke */
1223 void html_object_set_property (PluginInstance *plugin, NPObject *npobj, char *name, Value *value);
1224 /* @GeneratePInvoke */
1225 bool html_object_invoke (PluginInstance *plugin, NPObject *npobj, char *name, /* @MarshalAs=Mono.Value[] */ Value *args, guint32 arg_count, /* @MarshalAs=Mono.Value,IsOut */ Value *result);
1226 /* @GeneratePInvoke */
1227 bool html_object_invoke_self (PluginInstance *plugin, NPObject *npobj, /* @MarshalAs=Mono.Value[] */ Value *args, guint32 arg_count, /* @MarshalAs=Mono.Value,IsOut */ Value *result);
1228 /* @GeneratePInvoke */
1229 gpointer html_object_attach_event (PluginInstance *plugin, NPObject *npobj, char *name, callback_dom_event *cb, gpointer context);
1230 /* @GeneratePInvoke */
1231 void html_object_detach_event (PluginInstance *plugin, const char *name, gpointer listener);
1232 /* @GeneratePInvoke */
1233 void html_object_release (PluginInstance *plugin, NPObject *npobj);
1234 /* @GeneratePInvoke */
1235 void html_object_retain (PluginInstance *plugin, NPObject *npobj);
1237 /*** Browser interaction utility classes ***/
1238 void browser_do_alert (PluginInstance *plugin, char *msg);
1241 G_END_DECLS
1243 #endif /* __PLUGIN_CLASS_H__ */