Ejemplo n.º 1
0
        }                                // non-user usable

        public SciterImage(SciterValue sv)
        {
            SciterXValue.VALUE v = sv.ToVALUE();
            IntPtr             himg;
            var r = _gapi.vUnWrapImage(ref v, out himg);

            Debug.Assert(r == SciterXGraphics.GRAPHIN_RESULT.GRAPHIN_OK);
            _himg = himg;
        }
Ejemplo n.º 2
0
        public SciterValue EvalScript(string script)
        {
            Debug.Assert(_hwnd != IntPtr.Zero, "Create the window first");
            Debug.Assert(script != null);

            SciterXValue.VALUE vret = new SciterXValue.VALUE();
            _api.SciterEval(_hwnd, script, (uint)script.Length, out vret);
            return(new SciterValue(vret));
        }
Ejemplo n.º 3
0
        public SciterValue CallFunction(string name, params SciterValue[] args)
        {
            Debug.Assert(_hwnd != IntPtr.Zero, "Create the window first");
            Debug.Assert(name != null);

            SciterXValue.VALUE vret = new SciterXValue.VALUE();
            _api.SciterCall(_hwnd, name, (uint)args.Length, SciterValue.ToVALUEArray(args), out vret);
            return(new SciterValue(vret));
        }
Ejemplo n.º 4
0
        public static SciterGraphics FromSV(SciterValue sv)
        {
            IntPtr hgfx;

            SciterXValue.VALUE v = sv.ToVALUE();
            var r = _gapi.vUnWrapGfx(ref v, out hgfx);

            Debug.Assert(r == SciterXGraphics.GRAPHIN_RESULT.GRAPHIN_OK);

            return(new SciterGraphics(hgfx));
        }
Ejemplo n.º 5
0
        public static SciterText FromSV(SciterValue sv)
        {
            IntPtr htext;

            SciterXValue.VALUE v = sv.ToVALUE();
            var r = _gapi.vUnWrapText(ref v, out htext);

            Debug.Assert(r == SciterXGraphics.GRAPHIN_RESULT.GRAPHIN_OK);

            SciterText st = new SciterText();

            st._htext = htext;
            return(st);
        }
Ejemplo n.º 6
0
        public static SciterPath FromSV(SciterValue sv)
        {
            IntPtr hpath;

            SciterXValue.VALUE v = sv.ToVALUE();
            var r = _gapi.vUnWrapPath(ref v, out hpath);

            Debug.Assert(r == SciterXGraphics.GRAPHIN_RESULT.GRAPHIN_OK);

            SciterPath st = new SciterPath();

            st._hpath = hpath;
            return(st);
        }
Ejemplo n.º 7
0
        public SciterValue(Action <SciterValue[]> func)
        {
            SciterXValue.FPTR_NATIVE_FUNCTOR_INVOKE  fnfi;
            SciterXValue.FPTR_NATIVE_FUNCTOR_RELEASE fnfr;
            GCHandle fnfi_gch = new GCHandle();
            GCHandle fnfr_gch = new GCHandle();
            GCHandle func_gch = GCHandle.Alloc(func);

            fnfi = (IntPtr tag, uint argc, IntPtr argv, out SciterXValue.VALUE retval) =>
            {
                // Get the list of SciterXValue.VALUE from the ptr
                SciterValue[] args = new SciterValue[argc];
                for (int i = 0; i < argc; i++)
                {
                    args[i] = new SciterValue((SciterXValue.VALUE)Marshal.PtrToStructure(IntPtr.Add(argv, i * Marshal.SizeOf(typeof(SciterXValue.VALUE))), typeof(SciterXValue.VALUE)));
                }

                func(args);
                retval = new SciterXValue.VALUE();
                return(true);
            };

            fnfr = (IntPtr tag) =>
            {
                // seems to never be called -> Sciter engine bug
                fnfi_gch.Free();
                fnfr_gch.Free();
                func_gch.Free();
                return(true);
            };

            fnfi_gch = GCHandle.Alloc(fnfi, GCHandleType.Normal);
            fnfr_gch = GCHandle.Alloc(fnfr, GCHandleType.Normal);
            func_gch = GCHandle.Alloc(func, GCHandleType.Normal);

            _api.ValueInit(out _data);
            _api.ValueNativeFunctorSet(ref _data, fnfi, fnfr, IntPtr.Zero);
        }
Ejemplo n.º 8
0
 /// <summary>
 /// For example media type can be "handheld:true", "projection:true", "screen:true", etc.
 /// By default sciter window has "screen:true" and "desktop:true"/"handheld:true" media variables.
 /// Media variables can be changed in runtime. This will cause styles of the document to be reset.
 /// </summary>
 /// <param name="mediaVars">Map that contains name/value pairs - media variables to be set</param>
 public bool SetMediaVars(SciterValue mediaVars)
 {
     SciterXValue.VALUE v = mediaVars.ToVALUE();
     return(_api.SciterSetMediaVars(_hwnd, ref v));
 }
Ejemplo n.º 9
0
 public SciterValue(SciterXValue.VALUE srcv)
 {
     _api.ValueInit(out data);
     _api.ValueCopy(out data, ref srcv);
 }
Ejemplo n.º 10
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);
            }
        }