// 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); } }
protected virtual bool OnGesture(SciterElement se, SciterXBehaviors.GESTURE_PARAMS prms) { return(false); }