protected override bool OnDraw(SciterElement se, SciterXBehaviors.DRAW_PARAMS prms)
        {
            if(prms.cmd == SciterXBehaviors.DRAW_EVENTS.DRAW_CONTENT)
            {
                using(SciterGraphics g = new SciterGraphics(prms.gfx))
                {
                    g.StateSave();
                    g.Translate(prms.area.left, prms.area.top);

                    List<Tuple<float, float>> points = new List<Tuple<float, float>>
                    {
                        Tuple.Create(100.0f, 0.0f),
                        Tuple.Create(150.0f, 150.0f),
                        Tuple.Create(50.0f, 150.0f)
                    };

                    g.LineColor = Color.Blue;
                    g.FillColor = Color.Red;
                    g.LineWidth = 5;
                    g.Polygon(points);
                    g.Ellipse(200, 50, 50, 50);

                    g.StateRestore();
                }

                return true;
            }
            return false;
        }
Esempio n. 2
0
        public bool SendEvent(uint event_code, uint reason = 0, SciterElement heSource = null)
        {
            bool handled;

            _api.SciterSendEvent(_he, event_code, heSource == null ? IntPtr.Zero : heSource._he, new IntPtr(reason), out handled);
            return(handled);
        }
Esempio n. 3
0
        protected virtual bool OnScriptCall(SciterElement se, string name, SciterValue[] args, out SciterValue result)
        {
            var method = this.GetType().GetMethod(name);

            if (method != null)
            {
                // This base class tries to handle it by searching for a method with the same 'name'
                object[] call_parameters = new object[] { se, args, null };
                Debug.Assert(call_parameters.Length == 3);

                // Signature of that method should be:
                // bool MethodName(SciterElement el, SciterValue[] args, out SciterValue result)
                //
                // Verify correct signature:
                Debug.Assert(method.ReturnType == typeof(Boolean));
                Debug.Assert(method.GetParameters().Length == 3);
                Debug.Assert(method.GetParameters()[0].ParameterType.Name == "SciterElement");
                Debug.Assert(method.GetParameters()[1].ParameterType.Name == "SciterValue[]");
                Debug.Assert(method.GetParameters()[2].ParameterType.Name == "SciterValue&");

                // invoke method and verify return
                bool res = (bool)method.Invoke(this, call_parameters);
                Debug.Assert(call_parameters[2] == null || call_parameters[2].GetType().IsAssignableFrom(typeof(SciterValue)));

                result = call_parameters[2] as SciterValue;
                return(res);
            }

            // not handled
            result = null;
            return(false);
        }
Esempio n. 4
0
 protected virtual bool OnAttachBehavior(SciterElement el, string behaviorName, out SciterEventHandler elementEvh)
 {
     // returns a new SciterEventHandler if the behaviorName was registered by a previous RegisterBehaviorHandler() call
     if (_behaviorMap.ContainsKey(behaviorName))
     {
         elementEvh = (SciterEventHandler)Activator.CreateInstance(_behaviorMap[behaviorName]);
         return(true);
     }
     elementEvh = null;
     return(false);
 }
Esempio n. 5
0
        public SciterElement SelectFirst(string selector)
        {
            SciterElement se = null;

            SciterXDom.FPTR_SciterElementCallback cbk = (IntPtr he, IntPtr param) =>
            {
                se = new SciterElement(he);
                return(true);               // true stops enumeration
            };
            _api.SciterSelectElementsW(_he, selector, cbk, IntPtr.Zero);
            return(se);
        }
Esempio n. 6
0
        public static SciterText CreateForElement(string text, SciterElement element)
        {
            IntPtr htext;
            var    r = _gapi.textCreateForElement(out htext, text, (uint)text.Length, element._he);

            Debug.Assert(r == SciterXGraphics.GRAPHIN_RESULT.GRAPHIN_OK);
            Debug.Assert(htext != IntPtr.Zero);

            SciterText st = new SciterText();

            st._htext = htext;
            return(st);
        }
        protected override bool OnDraw(SciterElement se, SciterXBehaviors.DRAW_PARAMS prms)
        {
            var b = new Bitmap(406, 400);
            using(var g = Graphics.FromImage(b))
            {
                LinearGradientBrush linGrBrush = new LinearGradientBrush(
                    new Point(0, 10),
                    new Point(200, 10),
                    Color.FromArgb(255, 255, 0, 0),   // Opaque red
                    Color.FromArgb(255, 0, 0, 255));  // Opaque blue
                g.SmoothingMode = SmoothingMode.AntiAlias;
                g.FillEllipse(linGrBrush, 0, 30, 200, 100);
            }

            var img = new SciterImage(b);
            var gfx = new SciterGraphics(prms.gfx);
            gfx.BlendImage(img, 0, 0);
            return true;
        }
Esempio n. 8
0
        public bool IsChildOf(SciterElement parent_test)
        {
            SciterElement el_it = this;

            while (true)
            {
                if (el_it._he == parent_test._he)
                {
                    return(true);
                }

                el_it = el_it.Parent;
                if (el_it == null)
                {
                    break;
                }
            }
            return(false);
        }
Esempio n. 9
0
        protected override bool OnDraw(SciterElement se, SciterXBehaviors.DRAW_PARAMS prms)
        {
            if(prms.cmd == SciterXBehaviors.DRAW_EVENTS.DRAW_CONTENT)
            {
                SciterText txt = SciterText.Create("hi", new SciterXGraphics.SCITER_TEXT_FORMAT
                {
                    fontFamily = "Arial",
                    fontSize = 15,
                    fontWeight = 400,
                    lineHeight = 30
                });

                using(SciterGraphics g = new SciterGraphics(prms.gfx))
                {
                    g.DrawText(txt, 0, 0, 7);
                }

                return true;
            }
            return false;
        }
Esempio n. 10
0
 public void PostEvent(uint event_code, uint reason = 0, SciterElement heSource = null)
 {
     _api.SciterPostEvent(_he, event_code, heSource == null ? IntPtr.Zero : heSource._he, new IntPtr(reason));
 }
Esempio n. 11
0
 protected virtual bool OnDraw(SciterElement se, SciterXBehaviors.DRAW_PARAMS prms)
 {
     return(false);
 }
Esempio n. 12
0
 public SciterElement SelectFirst(string selector)
 {
     SciterElement se = null;
     SciterXDom.FPTR_SciterElementCallback cbk = (IntPtr he, IntPtr param) =>
     {
         se = new SciterElement(he);
         return true;// true stops enumeration
     };
     _api.SciterSelectElementsW(_he, selector, cbk, IntPtr.Zero);
     return se;
 }
Esempio n. 13
0
 public void Append(SciterElement se)
 {
     _api.SciterInsertElement(se._he, _he, int.MaxValue);
 }
Esempio n. 14
0
 protected virtual bool OnDataArrived(SciterElement se, SciterXBehaviors.DATA_ARRIVED_PARAMS prms)
 {
     return false;
 }
Esempio n. 15
0
 public void TestSciterElement()
 {
     SciterElement el = SciterElement.Create("div");
     SciterElement el2 = new SciterElement(el._he);
     Assert.IsTrue(el == el2);
 }
Esempio n. 16
0
        protected virtual bool OnScriptCall(SciterElement se, string name, SciterValue[] args, out SciterValue result)
        {
            var method = this.GetType().GetMethod(name);
            if(method != null)
            {
                // This base class tries to handle it by searching for a method with the same 'name'
                object[] call_parameters = new object[] { se, args, null };
                Debug.Assert(call_parameters.Length == 3);

                // Signature of that method should be:
                // bool MethodName(SciterElement el, SciterValue[] args, out SciterValue result)
                //
                // Verify correct signature:
                Debug.Assert(method.ReturnType == typeof(Boolean));
                Debug.Assert(method.GetParameters().Length == 3);
                Debug.Assert(method.GetParameters()[0].ParameterType.Name == "SciterElement");
                Debug.Assert(method.GetParameters()[1].ParameterType.Name == "SciterValue[]");
                Debug.Assert(method.GetParameters()[2].ParameterType.Name == "SciterValue&");

                // invoke method and verify return
                bool res = (bool)method.Invoke(this, call_parameters);
                Debug.Assert(call_parameters[2] == null || call_parameters[2].GetType().IsAssignableFrom(typeof(SciterValue)));

                result = call_parameters[2] as SciterValue;
                return res;
            }

            // not handled
            result = null;
            return false;
        }
Esempio n. 17
0
 protected virtual bool OnTimer(SciterElement se, IntPtr extTimerId)
 {
     return false;
 }
Esempio n. 18
0
 protected override bool OnScriptCall(SciterElement se, string name, SciterValue[] args, out SciterValue result)
 {
     result = null;
     return false;
 }
Esempio n. 19
0
 protected virtual bool OnGesture(SciterElement se, SciterXBehaviors.GESTURE_PARAMS prms)
 {
     return false;
 }
Esempio n. 20
0
 protected virtual bool OnScriptCall(SciterElement se, string name, SciterValue[] args, out SciterValue result)
 {
     result = null; return(false);
 }
Esempio n. 21
0
        protected override bool OnScriptCall(SciterElement se, string name, SciterValue[] args, out SciterValue result)
        {
            result = null;
            switch(name)
            {
                case "Host_DownloadFont":
                    string savefolder = args[0].Get("");
                    string family = args[1].Get("");
                    SciterValue async_cbk = args[2];
                    string str = async_cbk.ToString();

                    Task.Run(() =>
                    {
                        bool res;
                        try
                        {
                            GAPI.DownloadFont(family, savefolder);
                            res = true;
                        }
                        catch(Exception)
                        {
                            res = false;
                        }

                        Program.HostInstance.InvokePost(() =>
                        {
                            async_cbk.Call(new SciterValue(res));
                        });
                    });

                    return true;
            }
            return false;
        }
 protected virtual bool OnExchange(SciterElement se, SciterXBehaviors.EXCHANGE_PARAMS prms)
 {
     return(false);
 }
Esempio n. 23
0
 public bool OnWhat(SciterElement el, SciterValue[] args, out SciterValue result)
 {
     result = null;
     return true;
 }
Esempio n. 24
0
 public bool SendEvent(uint event_code, uint reason = 0, SciterElement heSource = null)
 {
     bool handled;
     _api.SciterSendEvent(_he, event_code, heSource == null ? IntPtr.Zero : heSource._he, new IntPtr(reason), out handled);
     return handled;
 }
Esempio n. 25
0
 protected virtual bool OnMethodCall(SciterElement se, SciterXBehaviors.BEHAVIOR_METHOD_IDENTIFIERS methodID)
 {
     return false;
 }
Esempio n. 26
0
 protected virtual bool OnMethodCall(SciterElement se, SciterXBehaviors.BEHAVIOR_METHOD_IDENTIFIERS methodID)
 {
     return(false);
 }
Esempio n. 27
0
 protected virtual bool OnSize(SciterElement se)
 {
     return false;
 }
Esempio n. 28
0
        protected virtual bool OnScriptCall(SciterElement se, string name, SciterValue[] args, out SciterValue result)
        {
            result = null;

            var method = GetType().GetMethod(name);

            if (method != null)
            {
                // This base class tries to handle it by searching for a method with the same 'name'
                var mparams = method.GetParameters();

                // match signature:
                // 'void MethodName()' or 'SciterValue MethodName()'
                {
                    if (mparams.Length == 0 &&
                        (method.ReturnType == typeof(void) || method.ReturnType == typeof(SciterValue)))
                    {
                        var ret = method.Invoke(this, null);
                        if (method.ReturnType == typeof(SciterValue))
                        {
                            result = (SciterValue)ret;
                        }
                        return(true);
                    }
                }

                // match signature:
                // 'void MethodName(SciterValue[] args)' or 'SciterValue MethodName(SciterValue[] args)'
                {
                    if (mparams.Length == 1 && mparams[0].ParameterType.Name == "SciterValue[]" &&
                        (method.ReturnType == typeof(void) || method.ReturnType == typeof(SciterValue)))
                    {
                        object[] call_parameters = new object[] { args };
                        var      ret             = method.Invoke(this, call_parameters);
                        if (method.ReturnType == typeof(SciterValue))
                        {
                            result = (SciterValue)ret;
                        }
                        return(true);
                    }
                }

                // match signature:
                // bool MethodName(SciterElement el, SciterValue[] args, out SciterValue result)
                {
                    if (method.ReturnType == typeof(bool) && mparams.Length == 3 &&
                        mparams[0].ParameterType.Name == "SciterElement" &&
                        mparams[1].ParameterType.Name == "SciterValue[]" &&
                        mparams[2].ParameterType.Name == "SciterValue&")
                    {
                        object[] call_parameters = new object[] { se, args, null };
                        bool     res             = (bool)method.Invoke(this, call_parameters);
                        Debug.Assert(call_parameters[2] == null || call_parameters[2].GetType().IsAssignableFrom(typeof(SciterValue)));
                        result = call_parameters[2] as SciterValue;
                        return(res);
                    }
                }
            }

            // not handled
            return(false);
        }
Esempio n. 29
0
        // EventProc
        private bool EventProc(IntPtr tag, IntPtr he, uint evtg, IntPtr prms)
        {
            SciterElement se = null;
            if(he != IntPtr.Zero)
                se = new SciterElement(he);

            switch((SciterXBehaviors.EVENT_GROUPS)evtg)
            {
                case SciterXBehaviors.EVENT_GROUPS.SUBSCRIPTIONS_REQUEST:
                    {
                        SciterXBehaviors.EVENT_GROUPS groups;
                        Subscription(se, out groups);
                        Marshal.WriteInt32(prms, (int)groups);
                        return true;
                    }

                case SciterXBehaviors.EVENT_GROUPS.HANDLE_INITIALIZATION:
                    {
                        SciterXBehaviors.INITIALIZATION_PARAMS p = (SciterXBehaviors.INITIALIZATION_PARAMS)Marshal.PtrToStructure(prms, typeof(SciterXBehaviors.INITIALIZATION_PARAMS));
                        if(p.cmd == SciterXBehaviors.INITIALIZATION_EVENTS.BEHAVIOR_ATTACH)
                        {
            #if DEBUG
                            Debug.Assert(_is_attached == false);
                            _is_attached = true;
            #endif
                            _attached_handlers.Add(this);
                            Attached(se);
                        }
                        else if(p.cmd == SciterXBehaviors.INITIALIZATION_EVENTS.BEHAVIOR_DETACH)
                        {
            #if DEBUG
                            Debug.Assert(_is_attached == true);
                            _is_attached = false;
            #endif
                            _attached_handlers.Remove(this);
                            Detached(se);
                        }
                        return true;
                    }

                case SciterXBehaviors.EVENT_GROUPS.HANDLE_MOUSE:
                    {
                        SciterXBehaviors.MOUSE_PARAMS p = (SciterXBehaviors.MOUSE_PARAMS)Marshal.PtrToStructure(prms, typeof(SciterXBehaviors.MOUSE_PARAMS));
                        return OnMouse(se, p);
                    }

                case SciterXBehaviors.EVENT_GROUPS.HANDLE_KEY:
                    {
                        SciterXBehaviors.KEY_PARAMS p = (SciterXBehaviors.KEY_PARAMS)Marshal.PtrToStructure(prms, typeof(SciterXBehaviors.KEY_PARAMS));
                        return OnKey(se, p);
                    }

                case SciterXBehaviors.EVENT_GROUPS.HANDLE_FOCUS:
                    {
                        SciterXBehaviors.FOCUS_PARAMS p = (SciterXBehaviors.FOCUS_PARAMS)Marshal.PtrToStructure(prms, typeof(SciterXBehaviors.FOCUS_PARAMS));
                        return OnFocus(se, p);
                    }

                case SciterXBehaviors.EVENT_GROUPS.HANDLE_DRAW:
                    {
                        SciterXBehaviors.DRAW_PARAMS p = (SciterXBehaviors.DRAW_PARAMS)Marshal.PtrToStructure(prms, typeof(SciterXBehaviors.DRAW_PARAMS));
                        return OnDraw(se, p);
                    }

                case SciterXBehaviors.EVENT_GROUPS.HANDLE_TIMER:
                    {
                        SciterXBehaviors.TIMER_PARAMS p = (SciterXBehaviors.TIMER_PARAMS)Marshal.PtrToStructure(prms, typeof(SciterXBehaviors.TIMER_PARAMS));
                        if(p.timerId != IntPtr.Zero)
                            return OnTimer(se, p.timerId);
                        return OnTimer(se);
                    }

                case SciterXBehaviors.EVENT_GROUPS.HANDLE_BEHAVIOR_EVENT:
                    {
                        SciterXBehaviors.BEHAVIOR_EVENT_PARAMS p = (SciterXBehaviors.BEHAVIOR_EVENT_PARAMS)Marshal.PtrToStructure(prms, typeof(SciterXBehaviors.BEHAVIOR_EVENT_PARAMS));
                        SciterElement se2 = p.he != IntPtr.Zero ? new SciterElement(p.he) : null;
                        return OnEvent(se, se2, (SciterXBehaviors.BEHAVIOR_EVENTS)p.cmd, p.reason, new SciterValue(p.data));// maybe I should not pass SciterValue to avoid add-refing the VALUE
                    }

                case SciterXBehaviors.EVENT_GROUPS.HANDLE_METHOD_CALL:
                    {
                        SciterXDom.METHOD_PARAMS p = (SciterXDom.METHOD_PARAMS)Marshal.PtrToStructure(prms, typeof(SciterXDom.METHOD_PARAMS));
                        return OnMethodCall(se, p.methodID);
                    }

                case SciterXBehaviors.EVENT_GROUPS.HANDLE_DATA_ARRIVED:
                    {
                        SciterXBehaviors.DATA_ARRIVED_PARAMS p = (SciterXBehaviors.DATA_ARRIVED_PARAMS)Marshal.PtrToStructure(prms, typeof(SciterXBehaviors.DATA_ARRIVED_PARAMS));
                        return OnDataArrived(se, p);
                    }

                case SciterXBehaviors.EVENT_GROUPS.HANDLE_SCROLL:
                    {
                        SciterXBehaviors.SCROLL_PARAMS p = (SciterXBehaviors.SCROLL_PARAMS)Marshal.PtrToStructure(prms, typeof(SciterXBehaviors.SCROLL_PARAMS));
                        return OnScroll(se, p);
                    }

                case SciterXBehaviors.EVENT_GROUPS.HANDLE_SIZE:
                    return OnSize(se);

                case SciterXBehaviors.EVENT_GROUPS.HANDLE_SCRIPTING_METHOD_CALL:
                    {
                        IntPtr RESULT_OFFSET = Marshal.OffsetOf(typeof(SciterXBehaviors.SCRIPTING_METHOD_PARAMS), "result");
            #if OSX
                        if(IntPtr.Size == 4)
                            Debug.Assert(RESULT_OFFSET.ToInt32() == 12);
            #else
                        if(IntPtr.Size == 4)
                            Debug.Assert(RESULT_OFFSET.ToInt32() == 16);// yep 16, strange but is what VS C++ compiler says
            #endif
                        else if(IntPtr.Size == 8)
                            Debug.Assert(RESULT_OFFSET.ToInt32() == 24);

                        SciterXBehaviors.SCRIPTING_METHOD_PARAMS p = (SciterXBehaviors.SCRIPTING_METHOD_PARAMS)Marshal.PtrToStructure(prms, typeof(SciterXBehaviors.SCRIPTING_METHOD_PARAMS));
                        SciterXBehaviors.SCRIPTING_METHOD_PARAMS_Wraper pw = new SciterXBehaviors.SCRIPTING_METHOD_PARAMS_Wraper(p);

                        bool bOK = OnScriptCall(se, pw.name, pw.args, out pw.result);
                        if(bOK && pw.result != null)
                        {
                            SciterXValue.VALUE vres = pw.result.ToVALUE();
                            IntPtr vptr = IntPtr.Add(prms, RESULT_OFFSET.ToInt32());
                            Marshal.StructureToPtr(vres, vptr, false);
                        }

                        return bOK;
                    }

                case SciterXBehaviors.EVENT_GROUPS.HANDLE_TISCRIPT_METHOD_CALL:
                    /*
                    COMMENTED BECAUSE THIS EVENT IS NEVER USED, AND JUST ADDS MORE CONFUSION
                    INSTEAD, IT'S BETTER TO HANDLE EVENT_GROUPS.HANDLE_SCRIPTING_METHOD_CALL/OnScriptCall
                        {
                            SciterXBehaviors.TISCRIPT_METHOD_PARAMS p = Marshal.PtrToStructure<SciterXBehaviors.TISCRIPT_METHOD_PARAMS>(prms);
                            bool res = OnScriptCall(se, p);
                            return res;
                        }
                    */
                    return false;

                case SciterXBehaviors.EVENT_GROUPS.HANDLE_GESTURE:
                    {
                        SciterXBehaviors.GESTURE_PARAMS p = (SciterXBehaviors.GESTURE_PARAMS)Marshal.PtrToStructure(prms, typeof(SciterXBehaviors.GESTURE_PARAMS));
                        return OnGesture(se, p);
                    }

                default:
                    Debug.Assert(false);
                    return false;
            }
        }
Esempio n. 30
0
 protected virtual bool OnEvent(SciterElement elSource, SciterElement elTarget, SciterXBehaviors.BEHAVIOR_EVENTS type, IntPtr reason, SciterValue data)
 {
     return(false);
 }
Esempio n. 31
0
 protected virtual bool OnEvent(SciterElement elSource, SciterElement elTarget, SciterXBehaviors.BEHAVIOR_EVENTS type, IntPtr reason, SciterValue data)
 {
     return false;
 }
Esempio n. 32
0
 protected virtual bool OnDataArrived(SciterElement se, SciterXBehaviors.DATA_ARRIVED_PARAMS prms)
 {
     return(false);
 }
Esempio n. 33
0
        public static SciterText CreateForElement(string text, SciterElement element)
        {
            IntPtr htext;
            var r = _gapi.textCreateForElement(out htext, text, (uint)text.Length, element._he);
            Debug.Assert(r == SciterXGraphics.GRAPHIN_RESULT.GRAPHIN_OK);
            Debug.Assert(htext != IntPtr.Zero);

            SciterText st = new SciterText();
            st._htext = htext;
            return st;
        }
Esempio n. 34
0
 protected virtual bool OnScroll(SciterElement se, SciterXBehaviors.SCROLL_PARAMS prms)
 {
     return(false);
 }
Esempio n. 35
0
 public void Insert(SciterElement se, uint index = 0)
 {
     _api.SciterInsertElement(se._he, _he, index);
 }
Esempio n. 36
0
 protected virtual bool OnGesture(SciterElement se, SciterXBehaviors.GESTURE_PARAMS prms)
 {
     return(false);
 }
Esempio n. 37
0
 public void Swap(SciterElement sewith)
 {
     _api.SciterSwapElements(_he, sewith._he);
 }
Esempio n. 38
0
        // EventProc
        private bool EventProc(IntPtr tag, IntPtr he, uint evtg, IntPtr prms)
        {
            SciterElement se = null;

            if (he != IntPtr.Zero)
            {
                se = new SciterElement(he);
            }

            switch ((SciterXBehaviors.EVENT_GROUPS)evtg)
            {
            case SciterXBehaviors.EVENT_GROUPS.SUBSCRIPTIONS_REQUEST:
            {
                SciterXBehaviors.EVENT_GROUPS groups;
                Subscription(se, out groups);
                Marshal.WriteInt32(prms, (int)groups);
                return(true);
            }

            case SciterXBehaviors.EVENT_GROUPS.HANDLE_INITIALIZATION:
            {
                SciterXBehaviors.INITIALIZATION_PARAMS p = (SciterXBehaviors.INITIALIZATION_PARAMS)Marshal.PtrToStructure(prms, typeof(SciterXBehaviors.INITIALIZATION_PARAMS));
                if (p.cmd == SciterXBehaviors.INITIALIZATION_EVENTS.BEHAVIOR_ATTACH)
                {
#if DEBUG
                    Debug.Assert(_is_attached == false);
                    _is_attached = true;
#endif
                    _attached_handlers.Add(this);
                    Attached(se);
                }
                else if (p.cmd == SciterXBehaviors.INITIALIZATION_EVENTS.BEHAVIOR_DETACH)
                {
#if DEBUG
                    Debug.Assert(_is_attached == true);
                    _is_attached = false;
#endif
                    _attached_handlers.Remove(this);
                    Detached(se);
                }
                return(true);
            }

            case SciterXBehaviors.EVENT_GROUPS.HANDLE_MOUSE:
            {
                SciterXBehaviors.MOUSE_PARAMS p = (SciterXBehaviors.MOUSE_PARAMS)Marshal.PtrToStructure(prms, typeof(SciterXBehaviors.MOUSE_PARAMS));
                return(OnMouse(se, p));
            }

            case SciterXBehaviors.EVENT_GROUPS.HANDLE_KEY:
            {
                SciterXBehaviors.KEY_PARAMS p = (SciterXBehaviors.KEY_PARAMS)Marshal.PtrToStructure(prms, typeof(SciterXBehaviors.KEY_PARAMS));
                return(OnKey(se, p));
            }

            case SciterXBehaviors.EVENT_GROUPS.HANDLE_FOCUS:
            {
                SciterXBehaviors.FOCUS_PARAMS p = (SciterXBehaviors.FOCUS_PARAMS)Marshal.PtrToStructure(prms, typeof(SciterXBehaviors.FOCUS_PARAMS));
                return(OnFocus(se, p));
            }

            case SciterXBehaviors.EVENT_GROUPS.HANDLE_DRAW:
            {
                SciterXBehaviors.DRAW_PARAMS p = (SciterXBehaviors.DRAW_PARAMS)Marshal.PtrToStructure(prms, typeof(SciterXBehaviors.DRAW_PARAMS));
                return(OnDraw(se, p));
            }

            case SciterXBehaviors.EVENT_GROUPS.HANDLE_TIMER:
            {
                SciterXBehaviors.TIMER_PARAMS p = (SciterXBehaviors.TIMER_PARAMS)Marshal.PtrToStructure(prms, typeof(SciterXBehaviors.TIMER_PARAMS));
                if (p.timerId != IntPtr.Zero)
                {
                    return(OnTimer(se, p.timerId));
                }
                return(OnTimer(se));
            }

            case SciterXBehaviors.EVENT_GROUPS.HANDLE_BEHAVIOR_EVENT:
            {
                SciterXBehaviors.BEHAVIOR_EVENT_PARAMS p = (SciterXBehaviors.BEHAVIOR_EVENT_PARAMS)Marshal.PtrToStructure(prms, typeof(SciterXBehaviors.BEHAVIOR_EVENT_PARAMS));
                SciterElement se2 = p.he != IntPtr.Zero ? new SciterElement(p.he) : null;
                return(OnEvent(se, se2, p.cmd, p.reason, new SciterValue(p.data)));
            }

            case SciterXBehaviors.EVENT_GROUPS.HANDLE_METHOD_CALL:
            {
                SciterXDom.METHOD_PARAMS p = (SciterXDom.METHOD_PARAMS)Marshal.PtrToStructure(prms, typeof(SciterXDom.METHOD_PARAMS));
                return(OnMethodCall(se, p.methodID));
            }

            case SciterXBehaviors.EVENT_GROUPS.HANDLE_DATA_ARRIVED:
            {
                SciterXBehaviors.DATA_ARRIVED_PARAMS p = (SciterXBehaviors.DATA_ARRIVED_PARAMS)Marshal.PtrToStructure(prms, typeof(SciterXBehaviors.DATA_ARRIVED_PARAMS));
                return(OnDataArrived(se, p));
            }

            case SciterXBehaviors.EVENT_GROUPS.HANDLE_SCROLL:
            {
                SciterXBehaviors.SCROLL_PARAMS p = (SciterXBehaviors.SCROLL_PARAMS)Marshal.PtrToStructure(prms, typeof(SciterXBehaviors.SCROLL_PARAMS));
                return(OnScroll(se, p));
            }

            case SciterXBehaviors.EVENT_GROUPS.HANDLE_SIZE:
                return(OnSize(se));

            case SciterXBehaviors.EVENT_GROUPS.HANDLE_SCRIPTING_METHOD_CALL:
            {
                IntPtr RESULT_OFFSET = Marshal.OffsetOf(typeof(SciterXBehaviors.SCRIPTING_METHOD_PARAMS), "result");
#if OSX
                if (IntPtr.Size == 4)
                {
                    Debug.Assert(RESULT_OFFSET.ToInt32() == 12);
                }
#else
                if (IntPtr.Size == 4)
                {
                    Debug.Assert(RESULT_OFFSET.ToInt32() == 16);                                    // yep 16, strange but is what VS C++ compiler says
                }
#endif
                else if (IntPtr.Size == 8)
                {
                    Debug.Assert(RESULT_OFFSET.ToInt32() == 24);
                }

                SciterXBehaviors.SCRIPTING_METHOD_PARAMS        p  = (SciterXBehaviors.SCRIPTING_METHOD_PARAMS)Marshal.PtrToStructure(prms, typeof(SciterXBehaviors.SCRIPTING_METHOD_PARAMS));
                SciterXBehaviors.SCRIPTING_METHOD_PARAMS_Wraper pw = new SciterXBehaviors.SCRIPTING_METHOD_PARAMS_Wraper(p);

                bool bOK = OnScriptCall(se, pw.name, pw.args, out pw.result);
                if (bOK && pw.result != null)
                {
                    SciterXValue.VALUE vres = pw.result.ToVALUE();
                    IntPtr             vptr = IntPtr.Add(prms, RESULT_OFFSET.ToInt32());
                    Marshal.StructureToPtr(vres, vptr, false);
                }

                return(bOK);
            }

            case SciterXBehaviors.EVENT_GROUPS.HANDLE_TISCRIPT_METHOD_CALL:
                /*
                 * COMMENTED BECAUSE THIS EVENT IS NEVER USED, AND JUST ADDS MORE CONFUSION
                 * INSTEAD, IT'S BETTER TO HANDLE EVENT_GROUPS.HANDLE_SCRIPTING_METHOD_CALL/OnScriptCall
                 *      {
                 *              SciterXBehaviors.TISCRIPT_METHOD_PARAMS p = Marshal.PtrToStructure<SciterXBehaviors.TISCRIPT_METHOD_PARAMS>(prms);
                 *              bool res = OnScriptCall(se, p);
                 *              return res;
                 *      }
                 */
                return(false);

            case SciterXBehaviors.EVENT_GROUPS.HANDLE_GESTURE:
            {
                SciterXBehaviors.GESTURE_PARAMS p = (SciterXBehaviors.GESTURE_PARAMS)Marshal.PtrToStructure(prms, typeof(SciterXBehaviors.GESTURE_PARAMS));
                return(OnGesture(se, p));
            }

            default:
                Debug.Assert(false);
                return(false);
            }
        }
Esempio n. 39
0
 public void PostEvent(uint event_code, uint reason = 0, SciterElement heSource = null)
 {
     _api.SciterPostEvent(_he, event_code, heSource == null ? IntPtr.Zero : heSource._he, new IntPtr(reason));
 }
Esempio n. 40
0
        public readonly SciterXBehaviors.FPTR_ElementEventProc _proc;        // keep a copy of the delegate so it survives GC


        // Overridables
        protected virtual void Subscription(SciterElement se, out SciterXBehaviors.EVENT_GROUPS event_groups)
        {
            event_groups = SciterXBehaviors.EVENT_GROUPS.HANDLE_ALL;
        }
Esempio n. 41
0
 protected virtual bool OnFocus(SciterElement se, SciterXBehaviors.FOCUS_PARAMS prms)
 {
     return false;
 }
Esempio n. 42
0
 protected virtual void Detached(SciterElement se)
 {
 }
Esempio n. 43
0
 protected virtual bool OnKey(SciterElement se, SciterXBehaviors.KEY_PARAMS prms)
 {
     return false;
 }
Esempio n. 44
0
 protected virtual bool OnMouse(SciterElement se, SciterXBehaviors.MOUSE_PARAMS prms)
 {
     return(false);
 }
Esempio n. 45
0
 protected virtual bool OnMouse(SciterElement se, SciterXBehaviors.MOUSE_PARAMS prms)
 {
     return false;
 }
Esempio n. 46
0
 protected virtual bool OnKey(SciterElement se, SciterXBehaviors.KEY_PARAMS prms)
 {
     return(false);
 }
Esempio n. 47
0
 protected virtual bool OnScroll(SciterElement se, SciterXBehaviors.SCROLL_PARAMS prms)
 {
     return false;
 }
Esempio n. 48
0
 protected virtual bool OnFocus(SciterElement se, SciterXBehaviors.FOCUS_PARAMS prms)
 {
     return(false);
 }
Esempio n. 49
0
 protected virtual bool OnTimer(SciterElement se)
 {
     return false;
 }
Esempio n. 50
0
 protected virtual bool OnTimer(SciterElement se)
 {
     return(false);
 }
Esempio n. 51
0
 // Overridables
 protected virtual void Subscription(SciterElement se, out SciterXBehaviors.EVENT_GROUPS event_groups)
 {
     event_groups = SciterXBehaviors.EVENT_GROUPS.HANDLE_ALL;
 }
Esempio n. 52
0
        public bool IsChildOf(SciterElement parent_test)
        {
            SciterElement el_it = this;
            while(true)
            {
                if(el_it._he == parent_test._he)
                    return true;

                el_it = el_it.Parent;
                if(el_it == null)
                    break;
            }
            return false;
        }
Esempio n. 53
0
 protected virtual void Detached(SciterElement se)
 {
 }
Esempio n. 54
0
 protected virtual bool OnSize(SciterElement se)
 {
     return(false);
 }
Esempio n. 55
0
 protected virtual bool OnDraw(SciterElement se, SciterXBehaviors.DRAW_PARAMS prms)
 {
     return false;
 }
Esempio n. 56
0
        protected override bool OnScriptCall(SciterElement se, string name, SciterValue[] args, out SciterValue result)
        {
            switch(name)
            {
            case "Host_HelloWorld":
                result = new SciterValue("Hello World! (from native side)");
                return true;
            }

            result = null;
            return false;
        }
Esempio n. 57
0
 protected virtual bool OnTimer(SciterElement se, IntPtr extTimerId)
 {
     return(false);
 }
Esempio n. 58
0
 public void Swap(SciterElement sewith)
 {
     _api.SciterSwapElements(_he, sewith._he);
 }