コード例 #1
0
        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;
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #4
0
ファイル: SciterHost.cs プロジェクト: 623442733/SciterSharp
 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);
 }
コード例 #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);
        }
コード例 #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);
        }
コード例 #7
0
        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;
        }
コード例 #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);
        }
コード例 #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;
        }
コード例 #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));
 }
コード例 #11
0
 protected virtual bool OnDraw(SciterElement se, SciterXBehaviors.DRAW_PARAMS prms)
 {
     return(false);
 }
コード例 #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;
 }
コード例 #13
0
 public void Append(SciterElement se)
 {
     _api.SciterInsertElement(se._he, _he, int.MaxValue);
 }
コード例 #14
0
 protected virtual bool OnDataArrived(SciterElement se, SciterXBehaviors.DATA_ARRIVED_PARAMS prms)
 {
     return false;
 }
コード例 #15
0
ファイル: UnitTests.cs プロジェクト: MISoftware/SciterSharp
 public void TestSciterElement()
 {
     SciterElement el = SciterElement.Create("div");
     SciterElement el2 = new SciterElement(el._he);
     Assert.IsTrue(el == el2);
 }
コード例 #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;
        }
コード例 #17
0
 protected virtual bool OnTimer(SciterElement se, IntPtr extTimerId)
 {
     return false;
 }
コード例 #18
0
ファイル: Host.cs プロジェクト: MISoftware/SciterSharp
 protected override bool OnScriptCall(SciterElement se, string name, SciterValue[] args, out SciterValue result)
 {
     result = null;
     return false;
 }
コード例 #19
0
 protected virtual bool OnGesture(SciterElement se, SciterXBehaviors.GESTURE_PARAMS prms)
 {
     return false;
 }
コード例 #20
0
 protected virtual bool OnScriptCall(SciterElement se, string name, SciterValue[] args, out SciterValue result)
 {
     result = null; return(false);
 }
コード例 #21
0
ファイル: Host.cs プロジェクト: midiway/FontLister
        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;
        }
コード例 #22
0
 protected virtual bool OnExchange(SciterElement se, SciterXBehaviors.EXCHANGE_PARAMS prms)
 {
     return(false);
 }
コード例 #23
0
ファイル: Host.cs プロジェクト: MISoftware/SciterSharp
 public bool OnWhat(SciterElement el, SciterValue[] args, out SciterValue result)
 {
     result = null;
     return true;
 }
コード例 #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;
 }
コード例 #25
0
 protected virtual bool OnMethodCall(SciterElement se, SciterXBehaviors.BEHAVIOR_METHOD_IDENTIFIERS methodID)
 {
     return false;
 }
コード例 #26
0
 protected virtual bool OnMethodCall(SciterElement se, SciterXBehaviors.BEHAVIOR_METHOD_IDENTIFIERS methodID)
 {
     return(false);
 }
コード例 #27
0
 protected virtual bool OnSize(SciterElement se)
 {
     return false;
 }
コード例 #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);
        }
コード例 #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;
            }
        }
コード例 #30
0
 protected virtual bool OnEvent(SciterElement elSource, SciterElement elTarget, SciterXBehaviors.BEHAVIOR_EVENTS type, IntPtr reason, SciterValue data)
 {
     return(false);
 }
コード例 #31
0
 protected virtual bool OnEvent(SciterElement elSource, SciterElement elTarget, SciterXBehaviors.BEHAVIOR_EVENTS type, IntPtr reason, SciterValue data)
 {
     return false;
 }
コード例 #32
0
 protected virtual bool OnDataArrived(SciterElement se, SciterXBehaviors.DATA_ARRIVED_PARAMS prms)
 {
     return(false);
 }
コード例 #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;
        }
コード例 #34
0
 protected virtual bool OnScroll(SciterElement se, SciterXBehaviors.SCROLL_PARAMS prms)
 {
     return(false);
 }
コード例 #35
0
 public void Insert(SciterElement se, uint index = 0)
 {
     _api.SciterInsertElement(se._he, _he, index);
 }
コード例 #36
0
 protected virtual bool OnGesture(SciterElement se, SciterXBehaviors.GESTURE_PARAMS prms)
 {
     return(false);
 }
コード例 #37
0
 public void Swap(SciterElement sewith)
 {
     _api.SciterSwapElements(_he, sewith._he);
 }
コード例 #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);
            }
        }
コード例 #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));
 }
コード例 #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;
        }
コード例 #41
0
 protected virtual bool OnFocus(SciterElement se, SciterXBehaviors.FOCUS_PARAMS prms)
 {
     return false;
 }
コード例 #42
0
 protected virtual void Detached(SciterElement se)
 {
 }
コード例 #43
0
 protected virtual bool OnKey(SciterElement se, SciterXBehaviors.KEY_PARAMS prms)
 {
     return false;
 }
コード例 #44
0
 protected virtual bool OnMouse(SciterElement se, SciterXBehaviors.MOUSE_PARAMS prms)
 {
     return(false);
 }
コード例 #45
0
 protected virtual bool OnMouse(SciterElement se, SciterXBehaviors.MOUSE_PARAMS prms)
 {
     return false;
 }
コード例 #46
0
 protected virtual bool OnKey(SciterElement se, SciterXBehaviors.KEY_PARAMS prms)
 {
     return(false);
 }
コード例 #47
0
 protected virtual bool OnScroll(SciterElement se, SciterXBehaviors.SCROLL_PARAMS prms)
 {
     return false;
 }
コード例 #48
0
 protected virtual bool OnFocus(SciterElement se, SciterXBehaviors.FOCUS_PARAMS prms)
 {
     return(false);
 }
コード例 #49
0
 protected virtual bool OnTimer(SciterElement se)
 {
     return false;
 }
コード例 #50
0
 protected virtual bool OnTimer(SciterElement se)
 {
     return(false);
 }
コード例 #51
0
 // Overridables
 protected virtual void Subscription(SciterElement se, out SciterXBehaviors.EVENT_GROUPS event_groups)
 {
     event_groups = SciterXBehaviors.EVENT_GROUPS.HANDLE_ALL;
 }
コード例 #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;
        }
コード例 #53
0
 protected virtual void Detached(SciterElement se)
 {
 }
コード例 #54
0
 protected virtual bool OnSize(SciterElement se)
 {
     return(false);
 }
コード例 #55
0
 protected virtual bool OnDraw(SciterElement se, SciterXBehaviors.DRAW_PARAMS prms)
 {
     return false;
 }
コード例 #56
0
ファイル: Host.cs プロジェクト: MISoftware/SciterSharp
        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;
        }
コード例 #57
0
 protected virtual bool OnTimer(SciterElement se, IntPtr extTimerId)
 {
     return(false);
 }
コード例 #58
0
 public void Swap(SciterElement sewith)
 {
     _api.SciterSwapElements(_he, sewith._he);
 }