diff --git a/.gitattributes b/.gitattributes index b634d85..38a6487 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1,2 @@ +*.dll filter=lfs diff=lfs merge=lfs -text *.pdf filter=lfs diff=lfs merge=lfs -text diff --git a/.gitignore b/.gitignore index 19892e4..d8c8979 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ .zig-cache +zig-out diff --git a/packages/sciter/build.zig b/packages/sciter/build.zig new file mode 100644 index 0000000..be0f7a0 --- /dev/null +++ b/packages/sciter/build.zig @@ -0,0 +1,40 @@ +const std = @import("std"); + +pub fn build(b: *std.Build) void { + const target = b.resolveTargetQuery(.{ + .cpu_arch = .x86_64, + .os_tag = .windows, + .abi = .msvc, + }); + const optimize = b.standardOptimizeOption(.{}); + + const zigwin32 = b.dependency("zigwin32", .{}); + const zigwin32_mod = zigwin32.module("win32"); + zigwin32_mod.resolved_target = target; + zigwin32_mod.optimize = optimize; + + const exe_mod = b.createModule(.{ + .root_source_file = b.path("src/main.zig"), + .target = target, + .optimize = optimize, + }); + + exe_mod.addImport("win32", zigwin32_mod); + + const exe = b.addExecutable(.{ + .name = "sciter", + .root_module = exe_mod, + }); + + b.installArtifact(exe); + b.getInstallStep().dependOn(&b.addInstallBinFile(b.path("vendor/sciter.dll"), "sciter.dll").step); + + const run_cmd = b.addRunArtifact(exe); + run_cmd.step.dependOn(b.getInstallStep()); + if (b.args) |args| { + run_cmd.addArgs(args); + } + + const run_step = b.step("run", "Run the app"); + run_step.dependOn(&run_cmd.step); +} diff --git a/packages/sciter/build.zig.zon b/packages/sciter/build.zig.zon new file mode 100644 index 0000000..4cffc88 --- /dev/null +++ b/packages/sciter/build.zig.zon @@ -0,0 +1,18 @@ +.{ + .name = .sciter, + .version = "0.0.0", + .minimum_zig_version = "0.15.1", + .paths = .{ + "src", + "vendor", + "build.zig", + "build.zig.zon", + }, + .fingerprint = 0x51b124a630f074d7, + .dependencies = .{ + .zigwin32 = .{ + .url = "https://github.com/marlersoft/zigwin32/archive/5587b16fa040573846a6bf531301f6206d31a6bf.zip", + .hash = "zigwin32-25.0.28-preview-AAAAAICM5AMResOGQnQ85mfe60TTOQeMtt7GRATUOKoP", + }, + }, +} diff --git a/packages/sciter/src/index.html b/packages/sciter/src/index.html new file mode 100644 index 0000000..d5ca6f2 --- /dev/null +++ b/packages/sciter/src/index.html @@ -0,0 +1,39 @@ + + +
+ +Hello, World!
+ + diff --git a/packages/sciter/src/main.zig b/packages/sciter/src/main.zig new file mode 100644 index 0000000..538acf7 --- /dev/null +++ b/packages/sciter/src/main.zig @@ -0,0 +1,115 @@ +const sciter = @import("sciter.zig"); +const std = @import("std"); +const wam = @import("win32").ui.windows_and_messaging; +const win32 = @import("win32").foundation; + +const L = std.unicode.utf8ToUtf16LeStringLiteral; +const WINAPI = @import("std").builtin.CallingConvention.winapi; + +const html = @embedFile("index.html"); + +const min_track_size: win32.POINT = .{ .x = 640, .y = 480 }; + +var sciter_api: *sciter.API = undefined; + +pub fn wWinMain( + hInstance: std.os.windows.HINSTANCE, + hPrevInstance: ?std.os.windows.HINSTANCE, + lpCmdLine: [*:0]u16, + nCmdShow: i32, +) i32 { + _ = hPrevInstance; + _ = lpCmdLine; + + const sciter_module = std.os.windows.LoadLibraryW(L("sciter.dll")) catch |err| { + _ = wam.MessageBoxW( + null, + switch (err) { + error.FileNotFound => L("Couldn't find sciter.dll."), + else => L("An unknown error occured while trying to load sciter.dll."), + }, + L("Critical error"), + wam.MB_ICONHAND, + ); + std.posix.exit(1); + }; + + const sciter_api_fn: *const fn () ?*sciter.API = @ptrCast(std.os.windows.kernel32.GetProcAddress(sciter_module, "SciterAPI") orelse { + _ = wam.MessageBoxW(null, L("Couldn't load Sciter API."), L("Critical error"), wam.MB_ICONHAND); + std.posix.exit(1); + }); + + sciter_api = sciter_api_fn() orelse { + _ = wam.MessageBoxW(null, L("Couldn't load Sciter API."), L("Critical error"), wam.MB_ICONHAND); + std.posix.exit(1); + }; + + std.debug.print("Sciter API version is: 0x{X:0>8}\n", .{sciter_api.version}); + + const wc = std.mem.zeroInit(wam.WNDCLASSEXW, .{ + .cbSize = @sizeOf(wam.WNDCLASSEXW), + .lpfnWndProc = &WindowProc, + .hInstance = hInstance, + .hIcon = wam.LoadIconW(null, wam.IDI_APPLICATION), + .hCursor = wam.LoadCursorW(null, wam.IDC_ARROW), + .lpszClassName = L("SCITER_WINDOW"), + }); + + const atom = wam.RegisterClassExW(&wc); + std.debug.assert(atom != 0); + + const hwnd = wam.CreateWindowExW( + wam.WS_EX_APPWINDOW, + wc.lpszClassName, + L("Sciter Demo"), + wam.WS_OVERLAPPEDWINDOW, + -1, + -1, + -1, + -1, + null, + null, + wc.hInstance, + null, + ) orelse { + _ = wam.MessageBoxW(null, L("Couldn't create window."), L("Critical error"), wam.MB_ICONHAND); + std.posix.exit(1); + }; + + _ = sciter_api.SciterLoadHtml(hwnd, html, html.len, L("/")); + _ = wam.ShowWindow(hwnd, @bitCast(nCmdShow)); + + var msg = std.mem.zeroes(wam.MSG); + while (wam.GetMessageW(&msg, null, 0, 0) > 0) { + _ = wam.TranslateMessage(&msg); + _ = wam.DispatchMessageW(&msg); + } + + return @bitCast(@as(u32, @truncate(msg.wParam))); +} + +fn WindowProc( + hwnd: win32.HWND, + uMsg: u32, + wParam: win32.WPARAM, + lParam: win32.LPARAM, +) callconv(WINAPI) win32.LRESULT { + switch (uMsg) { + wam.WM_DESTROY => { + wam.PostQuitMessage(0); + }, + wam.WM_GETMINMAXINFO => { + const mmi: *wam.MINMAXINFO = @ptrFromInt(@as(usize, @bitCast(lParam))); + mmi.ptMinTrackSize = min_track_size; + }, + else => {}, + } + + var handled: sciter.Bool = .FALSE; + const result = sciter_api.SciterProcND(hwnd, uMsg, wParam, lParam, &handled); + if (handled != .FALSE) { + return result; + } + + return wam.DefWindowProcW(hwnd, uMsg, wParam, lParam); +} diff --git a/packages/sciter/src/sciter.zig b/packages/sciter/src/sciter.zig new file mode 100644 index 0000000..c32cf80 --- /dev/null +++ b/packages/sciter/src/sciter.zig @@ -0,0 +1,641 @@ +pub const CStr = [*:0]const u8; +pub const CWStr = [*:0]const u16; + +pub const Element = opaque {}; +pub const HElement = *Element; + +pub const Node = opaque {}; +pub const HNode = *Node; + +pub const SArchive = opaque {}; +pub const HSArchive = *SArchive; + +/// - Windows: `HWND` +/// - OS X: `NSView*` +/// - Linux/GTK: `GtkWidget*` +pub const HWindow = *anyopaque; + +pub const BehaviorEventParams = extern struct { + cmd: BehaviorEvents, + he_target: ?HElement, + he: ?HElement, + reason: extern union { + click: enum(usize) { BY_MOUSE_CLICK, BY_KEY_CLICK, SYNTHESIZED, BY_MOUSE_ON_ICON }, + edit_changed: enum(usize) { BY_INS_CHAR, BY_INS_CHARS, BY_DEL_CHAR, BY_DEL_CHARS, BY_UNDO_REDO }, + custom: usize, + }, + data: Value, + name: ?CWStr, +}; + +const BehaviorEvents = enum(u32) { + BUTTON_CLICK = 0, + BUTTON_PRESS = 1, + + VALUE_CHANGED = 2, + VALUE_CHANGING = 3, + + SELECTION_CHANGED = 5, + SELECTION_CHANGING = 0xC, + + POPUP_REQUEST = 7, + POPUP_READY = 8, + POPUP_DISMISSED = 9, + + MENU_ITEM_ACTIVE = 0xA, + MENU_ITEM_CLICK = 0xB, + + CONTEXT_MENU_REQUEST = 0x10, + + VISUAL_STATUS_CHANGED = 0x11, + DISABLED_STATUS_CHANGED = 0x12, + + POPUP_DISMISSING = 0x13, + + CONTENT_CHANGED = 0x15, + + HYPERLINK_CLICK = 0x80, + + ELEMENT_COLLAPSED = 0x90, + ELEMENT_EXPANDED = 0x91, + + ACTIVATE_CHILD = 0x92, + + FORM_SUBMIT = 0x96, + FORM_RESET = 0x97, + + DOCUMENT_COMPLETE = 0x98, + + HISTORY_PUSH = 0x99, + HISTORY_DROP = 0x9A, + HISTORY_PRIOR = 0x9B, + HISTORY_NEXT = 0x9C, + HISTORY_STATE_CHANGED = 0x9D, + + CLOSE_POPUP = 0x9E, + REQUEST_TOOLTIP = 0x9F, + + ANIMATION = 0xA0, + TRANSITION = 0xA1, + SWIPE = 0xB0, + + DOCUMENT_CREATED = 0xC0, + DOCUMENT_CLOSE_REQUEST = 0xC1, + DOCUMENT_CLOSE = 0xC2, + DOCUMENT_READY = 0xC3, + DOCUMENT_PARSED = 0xC4, + //DOCUMENT_RELOAD = 0xC5, + DOCUMENT_CLOSING = 0xC6, + CONTAINER_CLOSE_REQUEST = 0xC7, + CONTAINER_CLOSING = 0xC8, + + VIDEO_INITIALIZED = 0xD1, + VIDEO_STARTED = 0xD2, + VIDEO_STOPPED = 0xD3, + VIDEO_BIND_RQ = 0xD4, + + VIDEO_FRAME_REQUEST = 0xD8, + + PAGINATION_STARTS = 0xE0, + PAGINATION_PAGE = 0xE1, + PAGINATION_ENDS = 0xE2, + + CUSTOM = 0xF0, + + EGL_RENDER = 0x20, + + /// All custom event codes shall be greater than this number. All codes + /// below this will be used solely by application - Sciter will not + /// intrepret it and will do just dispatching. To send event notifications + /// with these codes use SciterSend/PostEvent API. + FIRST_APPLICATION_EVENT_CODE = 0x100, + _, +}; + +pub const Bool = enum(u32) { + FALSE = 0, + TRUE = 1, + _, +}; + +pub const DomResult = enum(i32) { + OK = 0, + INVALID_HWND = 1, + INVALID_HANDLE = 2, + PASSIVE_HANDLE = 3, + INVALID_PARAMETER = 4, + OPERATION_FAILED = 5, + OK_NOT_HANDLED = -1, +}; + +pub const CtlType = enum(u32) { + NO = 0, + UNKNOWN = 1, + + EDIT = 2, + NUMERIC = 3, + CLICKABLE = 4, + BUTTON = 5, + CHECKBOX = 6, + RADIO = 7, + SELECT_SINGLE = 8, + SELECT_MULTIPLE = 9, + DD_SELECT = 10, + TEXTAREA = 11, + HTMLAREA = 12, + PASSWORD = 13, + PROGRESS = 14, + SLIDER = 15, + DECIMAL = 16, + CURRENCY = 17, + SCROLLBAR = 18, + LIST = 19, + RICHTEXT = 20, + CALENDAR = 21, + DATE = 22, + TIME = 23, + FILE = 24, + PATH = 25, + + HYPERLINK = 26, + FORM = 27, + + MENUBAR = 28, + MENU = 29, + MENUBUTTON = 30, + + FRAME = 31, + FRAMESET = 32, + + TOOLTIP = 33, + + HIDDEN = 34, + URL = 35, + TOOLBAR = 36, + + WINDOW = 37, + + LABEL = 38, + IMAGE = 39, + PLAINTEXT = 40, + + SELECT_TREE = 41, +}; + +pub const ElementAreas = packed struct { + relative: enum(u4) { + ROOT = 0x1, + SELF = 0x2, + CONTAINER = 0x3, + VIEW = 0x4, + _, + } = @enumFromInt(0x0), + + area: enum(u4) { + CONTENT_BOX = 0x0, + PADDING_BOX = 0x1, + BORDER_BOX = 0x2, + MARGIN_BOX = 0x3, + + BACK_IMAGE_AREA = 0x4, + FORE_IMAGE_AREA = 0x5, + + SCROLLABLE_AREA = 0x6, + _, + } = .CONTENT_BOX, + + _pad8: u8 = 0, + + as_ppx: bool = false, + + _pad17: u15 = 0, +}; + +pub const MethodParams = extern struct { + method_id: u32, +}; + +pub const NodeType = enum(u32) { ELEMENT, TEXT, COMMENT }; + +pub const NodeInsTarget = enum(u32) { BEFORE, AFTER, APPEND, PREPEND }; + +pub const Point = extern struct { + x: i32, + y: i32, +}; + +pub const Rect = extern struct { + left: i32, + top: i32, + right: i32, + bottom: u32, +}; + +pub const RequestParam = extern struct { + name: CWStr, + value: CWStr, +}; + +pub const RequestType = enum(u32) { + GET_ASYNC, + POST_ASYNC, + GET_SYNC, + POST_SYNC, +}; + +pub const ResourceType = enum(u32) { + HTML = 0, + IMAGE = 1, + STYLE = 2, + CURSOR = 3, + SCRIPT = 4, + RAW = 5, + FONT, + SOUND, + FORCE_DWORD = 0xFFFFFFFF, +}; + +pub const SetElementHtml = enum(u32) { + SIH_REPLACE_CONTENT = 0, + SIH_INSERT_AT_START = 1, + SIH_APPEND_AFTER_LAST = 2, + SOH_REPLACE = 3, + SOH_INSERT_BEFORE = 4, + SOH_INSERT_AFTER = 5, +}; + +pub const Size = extern struct { + cx: i32, + cy: i32, +}; + +pub const Value = extern struct { + type: ValueType, + unit: extern union { + value: ValueUnit, + /// For when `Value.type == .OBJECT` + object: ValueUnitObject, + }, + data: u64, +}; + +pub const ValueType = enum(u32) { + UNDEFINED = 0, + NULL = 1, + BOOL = 2, + i32 = 3, + FLOAT = 4, + STRING = 5, + DATE = 6, + BIG_INT = 7, + LENGTH = 8, + ARRAY = 9, + MAP = 10, + FUNCTION = 11, + BYTES = 12, + OBJECT = 13, + RESOURCE = 15, + DURATION = 17, + ANGLE = 18, + COLOR = 19, + ASSET = 21, +}; + +pub const ValueUnit = enum(u32) { + EM = 1, + EX = 2, + PR = 3, + SP = 4, + + PX = 7, + IN = 8, + CM = 9, + MM = 10, + PT = 11, + PC = 12, + DIP = 13, + + PR_WIDTH = 16, + PR_HEIGHT = 17, + PR_VIEW_WIDTH = 18, + PR_VIEW_HEIGHT = 19, + PR_VIEW_MIN = 20, + PR_VIEW_MAX = 21, + + REM = 22, + PPX = 23, + CH = 24, +}; + +pub const ValueUnitObject = enum(u32) { + ARRAY = 0, + OBJECT = 1, + CLASS = 2, + NATIVE = 3, + FUNCTION = 4, + ERROR = 5, + BUFFER = 6, +}; + +pub const ValueResult = enum(i32) { + OK_TRUE = -1, + OK = 0, + BAD_PARAMETER = 1, + INCOMPATIBLE_TYPE = 2, +}; + +pub const OutputSubsystems = enum(u32) { + DOM = 0, + CSSS, + CSS, + TIS, +}; + +pub const CallbackNotification = extern struct { + code: u32, + hwnd: HWindow, +}; + +pub const XMsgCode = enum(u32) { + CREATE = 0, + DESTROY = 1, + SIZE = 2, + PAINT = 3, + RESOLUTION = 4, + HEARTBIT = 5, + MOUSE = 6, + KEY = 7, + FOCUS = 8, +}; + +pub const XMsg = extern struct { + msg: XMsgCode, +}; + +pub const OmAsset = extern struct { + isa: *OmAssetClass, +}; + +pub const OmAssetClass = extern struct { + asset_add_ref: *const fn (thing: *OmAsset) callconv(.c) c_long, + asset_release: *const fn (thing: *OmAsset) callconv(.c) c_long, + asset_get_interface: *const fn (thing: *OmAsset, name: CStr, out: *?*anyopaque) callconv(.c) c_long, + asset_get_passport: *const fn (thins: *OmAsset) callconv(.c) ?*OmPassport, +}; + +pub const OmPassport = opaque {}; + +pub const ValueStringCvtType = enum(u32) { + CVT_SIMPLE, + CVT_JSON_LITERAL, + CVT_JSON_MAP, + CVT_XJSON_LITERAL, +}; + +const ByteReceiver = fn (str: [*]const u8, num_bytes: u32, param: ?*anyopaque) callconv(.c) void; +const DebugOutputProc = fn (param: ?*anyopaque, subsystem: OutputSubsystems, severity: u32, text: [*]const u16, text_length: u32) callconv(.c) void; +const ElementCallback = fn (he: HElement, param: ?*anyopaque) callconv(.c) Bool; +const ElementComparator = fn (he1: HElement, he2: HElement, param: ?*anyopaque) callconv(.c) i32; +const ElementEventProc = fn (tag: ?*anyopaque, he: HElement, evtg: u32, prms: ?*anyopaque) callconv(.c) Bool; +const HostCallback = fn (pns: *CallbackNotification, callback_param: ?*anyopaque) callconv(.c) u32; +const KeyValueCallback = fn (param: ?*anyopaque, pkey: *const Value, pval: *const Value) callconv(.c) Bool; +const NativeFunctorInvoke = fn (tag: ?*anyopaque, argc: u32, argv: [*]const Value, retval: *Value) callconv(.c) void; +const NativeFunctorRelease = fn (tag: ?*anyopaque) callconv(.c) void; +const StrReceiver = fn (str: [*]const u8, num_bytes: u32, param: ?*anyopaque) callconv(.c) void; +const WindowDelegate = fn (hwnd: HWindow, msg: u32, wParam: usize, lParam: isize, pbHandled: *Bool) callconv(.c) isize; +const WStrReceiver = fn (str: [*]const u16, num_bytes: u32, param: ?*anyopaque) callconv(.c) void; + +pub const API = extern struct { + version: u32, + + SciterClassName: *const fn () callconv(.c) CWStr, + SciterVersion: *const fn (n: u32) callconv(.c) u32, + SciterDataReady: *const fn (hwnd: HWindow, uri: CWStr, data: [*]const u8, dataLength: u32) callconv(.c) Bool, + SciterDataReadyAsync: *const fn (hwnd: HWindow, uri: CWStr, data: [*]const u8, dataLength: u32, requestId: ?*anyopaque) callconv(.c) Bool, + + SciterProc: *const fn (hwnd: HWindow, msg: u32, wParam: usize, lParam: isize) callconv(.c) isize, + SciterProcND: *const fn (hwnd: HWindow, msg: u32, wParam: usize, lParam: isize, pbHandled: *Bool) callconv(.c) isize, + + SciterLoadFile: *const fn (hwnd: HWindow, filename: CWStr) callconv(.c) Bool, + SciterLoadHtml: *const fn (hwnd: HWindow, html: [*]const u8, htmlSize: u32, baseUrl: CWStr) callconv(.c) Bool, + + SciterSetCallback: *const fn (hwnd: HWindow, cb: ?*HostCallback, cbParam: ?*anyopaque) callconv(.c) void, + SciterSetMasterCSS: *const fn (utf8: [*]const u8, numBytes: u32) callconv(.c) Bool, + SciterAppendMasterCSS: *const fn (utf8: [*]const u8, numBytes: u32) callconv(.c) Bool, + SciterSetCSS: *const fn (hwnd: HWindow, utf8: [*]const u8, numBytes: u32, baseUrl: CWStr, mediaType: CWStr) callconv(.c) Bool, + SciterSetMediaType: *const fn (hwnd: HWindow, mediaType: CWStr) callconv(.c) Bool, + SciterSetMediaVars: *const fn (hwnd: HWindow, mediaVars: *const Value) callconv(.c) Bool, + SciterGetMinWidth: *const fn (hwnd: HWindow) callconv(.c) u32, + SciterGetMinHeight: *const fn (hwnd: HWindow, width: u32) callconv(.c) u32, + SciterCall: *const fn (hWnd: HWindow, functionName: CStr, argc: u32, argv: [*]const Value, retval: *Value) callconv(.c) Bool, + SciterEval: *const fn (hwnd: HWindow, script: [*]const u16, scriptLength: u32, pretval: *Value) callconv(.c) Bool, + SciterUpdateWindow: *const fn (hwnd: HWindow) callconv(.c) void, + /// Win32 MSG + SciterTranslateMessage: *const fn (lpMsg: *anyopaque) callconv(.c) Bool, + SciterSetOption: *const fn (hWnd: HWindow, option: u32, value: usize) callconv(.c) Bool, + SciterGetPPI: *const fn (hwnd: HWindow, px: *u32, py: *u32) callconv(.c) void, + SciterGetViewExpando: *const fn (hwnd: HWindow, pval: *Value) callconv(.c) Bool, + /// ID2D1RenderTarget + SciterRenderD2D: *const fn (hwnd: HWindow, prt: *anyopaque) callconv(.c) Bool, + /// ID2D1Factory + SciterD2DFactory: *const fn (ppf: *anyopaque) callconv(.c) Bool, + /// IDWriteFactory + SciterDWFactory: *const fn (ppf: *anyopaque) callconv(.c) Bool, + SciterGraphicsCaps: *const fn (pcaps: *u32) callconv(.c) Bool, + SciterSetHomeURL: *const fn (hwnd: HWindow, baseUrl: CWStr) callconv(.c) Bool, + SciterCreateNSView: *anyopaque, + SciterCreateWidget: *anyopaque, + SciterCreateWindow: *const fn (creationFlags: u32, frame: *Rect, delegate: *const WindowDelegate, delegateParam: ?*anyopaque, parent: HWindow) callconv(.c) HWindow, + + SciterSetupDebugOutput: *const fn (hwndOrNull: ?HWindow, param: ?*anyopaque, pfOutput: ?*DebugOutputProc) callconv(.c) void, + + // --- DOM API ------------------------------------------------------------- + + Sciter_UseElement: *const fn (he: HElement) callconv(.c) DomResult, + Sciter_UnuseElement: *const fn (he: HElement) callconv(.c) DomResult, + SciterGetRootElement: *const fn (hwnd: HWindow, phe: *HElement) callconv(.c) DomResult, + SciterGetFocusElement: *const fn (hwnd: HWindow, phe: *HElement) callconv(.c) DomResult, + SciterFindElement: *const fn (hwnd: HWindow, pt: Point, phe: *HElement) callconv(.c) DomResult, + SciterGetChildrenCount: *const fn (he: HElement, count: *u32) callconv(.c) DomResult, + SciterGetNthChild: *const fn (he: HElement, n: u32, phe: *HElement) callconv(.c) DomResult, + SciterGetParentElement: *const fn (he: HElement, p_parent_he: *HElement) callconv(.c) DomResult, + SciterGetElementHtmlCB: *const fn (he: HElement, outer: Bool, rcv: *const ByteReceiver, rcv_param: ?*anyopaque) callconv(.c) DomResult, + SciterGetElementTextCB: *const fn (he: HElement, rcv: *const WStrReceiver, rcv_param: ?*anyopaque) callconv(.c) DomResult, + SciterSetElementText: *const fn (he: HElement, utf16: [*]const u16, length: u32) callconv(.c) DomResult, + SciterGetAttributeCount: *const fn (he: HElement, p_count: *u32) callconv(.c) DomResult, + SciterGetNthAttributeNameCB: *const fn (he: HElement, n: u32, rcv: *const StrReceiver, rcv_param: ?*anyopaque) callconv(.c) DomResult, + SciterGetNthAttributeValueCB: *const fn (he: HElement, n: u32, rcv: *const WStrReceiver, rcv_param: ?*anyopaque) callconv(.c) DomResult, + SciterGetAttributeByNameCB: *const fn (he: HElement, name: CStr, rcv: *const WStrReceiver, rcv_param: ?*anyopaque) callconv(.c) DomResult, + SciterSetAttributeByName: *const fn (he: HElement, name: CStr, value: CWStr) callconv(.c) DomResult, + SciterClearAttributes: *const fn (he: HElement) callconv(.c) DomResult, + SciterGetElementIndex: *const fn (he: HElement, p_index: *u32) callconv(.c) DomResult, + SciterGetElementType: *const fn (he: HElement, p_type: *CStr) callconv(.c) DomResult, + SciterGetElementTypeCB: *const fn (he: HElement, rcv: *const StrReceiver, rcv_param: ?*anyopaque) callconv(.c) DomResult, + SciterGetStyleAttributeCB: *const fn (he: HElement, name: CStr, rcv: *const WStrReceiver, rcv_param: ?*anyopaque) callconv(.c) DomResult, + SciterSetStyleAttribute: *const fn (he: HElement, name: CStr, value: CWStr) callconv(.c) DomResult, + SciterGetElementLocation: *const fn (he: HElement, p_location: *Rect, areas: ElementAreas) callconv(.c) DomResult, + SciterScrollToView: *const fn (he: HElement, SciterScrollFlags: u32) callconv(.c) DomResult, + SciterUpdateElement: *const fn (he: HElement, andForceRender: Bool) callconv(.c) DomResult, + SciterRefreshElementArea: *const fn (he: HElement, rc: Rect) callconv(.c) DomResult, + SciterSetCapture: *const fn (he: HElement) callconv(.c) DomResult, + SciterReleaseCapture: *const fn (he: HElement) callconv(.c) DomResult, + SciterGetElementHwnd: *const fn (he: HElement, p_hwnd: *HWindow, rootWindow: Bool) callconv(.c) DomResult, + SciterCombineURL: *const fn (he: HElement, szUrlBuffer: [*]u16, UrlBufferSize: u32) callconv(.c) DomResult, + SciterSelectElements: *const fn (he: HElement, CSS_selectors: CStr, callback: *const ElementCallback, param: ?*anyopaque) callconv(.c) DomResult, + SciterSelectElementsW: *const fn (he: HElement, CSS_selectors: CWStr, callback: *const ElementCallback, param: ?*anyopaque) callconv(.c) DomResult, + SciterSelectParent: *const fn (he: HElement, selector: CStr, depth: u32, heFound: *HElement) callconv(.c) DomResult, + SciterSelectParentW: *const fn (he: HElement, selector: CWStr, depth: u32, heFound: *HElement) callconv(.c) DomResult, + SciterSetElementHtml: *const fn (he: HElement, html: [*]const u8, htmlLength: u32, where: SetElementHtml) callconv(.c) DomResult, + SciterGetElementUID: *const fn (he: HElement, puid: *u32) callconv(.c) DomResult, + SciterGetElementByUID: *const fn (hwnd: HWindow, uid: u32, phe: *HElement) callconv(.c) DomResult, + SciterShowPopup: *const fn (hePopup: HElement, heAnchor: HElement, placement: u32) callconv(.c) DomResult, + SciterShowPopupAt: *const fn (hePopup: HElement, pos: Point, placement: u32) callconv(.c) DomResult, + SciterHidePopup: *const fn (he: HElement) callconv(.c) DomResult, + SciterGetElementState: *const fn (he: HElement, pstateBits: *u32) callconv(.c) DomResult, + SciterSetElementState: *const fn (he: HElement, stateBitsToSet: u32, stateBitsToClear: u32, updateView: Bool) callconv(.c) DomResult, + SciterCreateElement: *const fn (tagname: CStr, textOrNull: ?CWStr, phe: *HElement) callconv(.c) DomResult, + SciterCloneElement: *const fn (he: HElement, phe: *HElement) callconv(.c) DomResult, + SciterInsertElement: *const fn (he: HElement, hparent: HElement, index: u32) callconv(.c) DomResult, + SciterDetachElement: *const fn (he: HElement) callconv(.c) DomResult, + SciterDeleteElement: *const fn (he: HElement) callconv(.c) DomResult, + SciterSetTimer: *const fn (he: HElement, milliseconds: u32, timer_id: usize) callconv(.c) DomResult, + SciterDetachEventHandler: *const fn (he: HElement, pep: *const ElementEventProc, tag: ?*anyopaque) callconv(.c) DomResult, + SciterAttachEventHandler: *const fn (he: HElement, pep: *const ElementEventProc, tag: ?*anyopaque) callconv(.c) DomResult, + SciterWindowAttachEventHandler: *const fn (hwndLayout: HWindow, pep: *const ElementEventProc, tag: ?*anyopaque, subscription: u32) callconv(.c) DomResult, + SciterWindowDetachEventHandler: *const fn (hwndLayout: HWindow, pep: *const ElementEventProc, tag: ?*anyopaque) callconv(.c) DomResult, + SciterSendEvent: *const fn (he: HElement, appEventCode: u32, heSource: HElement, reason: usize, handled: *Bool) callconv(.c) DomResult, + SciterPostEvent: *const fn (he: HElement, appEventCode: u32, heSource: HElement, reason: usize) callconv(.c) DomResult, + SciterCallBehaviorMethod: *const fn (he: HElement, params: *MethodParams) callconv(.c) DomResult, + SciterRequestElementData: *const fn (he: HElement, url: CWStr, dataType: u32, initiator: HElement) callconv(.c) DomResult, + SciterHttpRequest: *const fn (he: HElement, url: CWStr, dataType: ResourceType, requestType: RequestType, requestParams: [*]RequestParam, nParams: u32) callconv(.c) DomResult, + SciterGetScrollInfo: *const fn (he: HElement, scrollPos: *Point, viewRect: *Rect, contentSize: *Size) callconv(.c) DomResult, + SciterSetScrollPos: *const fn (he: HElement, scrollPos: Point, smooth: Bool) callconv(.c) DomResult, + SciterGetElementIntrinsicWidths: *const fn (he: HElement, pMinWidth: *i32, pMaxWidth: *i32) callconv(.c) DomResult, + SciterGetElementIntrinsicHeight: *const fn (he: HElement, forWidth: i32, pHeight: *i32) callconv(.c) DomResult, + SciterIsElementVisible: *const fn (he: HElement, pVisible: *Bool) callconv(.c) DomResult, + SciterIsElementEnabled: *const fn (he: HElement, pEnabled: *Bool) callconv(.c) DomResult, + SciterSortElements: *const fn (he: HElement, firstIndex: u32, lastIndex: u32, cmpFunc: *const ElementComparator, cmpFuncParam: ?*anyopaque) callconv(.c) DomResult, + SciterSwapElements: *const fn (he1: HElement, he2: HElement) callconv(.c) DomResult, + SciterTraverseUIEvent: *const fn (evt: u32, eventCtlStruct: ?*anyopaque, bOutProcessed: *Bool) callconv(.c) DomResult, + SciterCallScriptingMethod: *const fn (he: HElement, name: CStr, argv: [*]const Value, argc: u32, retval: *Value) callconv(.c) DomResult, + SciterCallScriptingFunction: *const fn (he: HElement, name: CStr, argv: [*]const Value, argc: u32, retval: *Value) callconv(.c) DomResult, + SciterEvalElementScript: *const fn (he: HElement, script: [*]const u16, scriptLength: u32, retval: *Value) callconv(.c) DomResult, + SciterAttachHwndToElement: *const fn (he: HElement, hwnd: HWindow) callconv(.c) DomResult, + SciterControlGetType: *const fn (he: HElement, pType: *CtlType) callconv(.c) DomResult, + SciterGetValue: *const fn (he: HElement, pval: *Value) callconv(.c) DomResult, + SciterSetValue: *const fn (he: HElement, pval: *const Value) callconv(.c) DomResult, + SciterGetExpando: *const fn (he: HElement, pval: *Value, forceCreation: Bool) callconv(.c) DomResult, + SciterGetObject: *const fn (he: HElement, pval: *void, forceCreation: Bool) callconv(.c) DomResult, + SciterGetElementNamespace: *const fn (he: HElement, pval: *void) callconv(.c) DomResult, + SciterGetHighlightedElement: *const fn (hwnd: HWindow, phe: *HElement) callconv(.c) DomResult, + SciterSetHighlightedElement: *const fn (hwnd: HWindow, he: HElement) callconv(.c) DomResult, + + // --- DOM NODE API -------------------------------------------------------- + + SciterNodeAddRef: *const fn (hn: HNode) callconv(.c) DomResult, + SciterNodeRelease: *const fn (hn: HNode) callconv(.c) DomResult, + SciterNodeCastFromElement: *const fn (he: HElement, phn: *HNode) callconv(.c) DomResult, + SciterNodeCastToElement: *const fn (hn: HNode, he: *HElement) callconv(.c) DomResult, + SciterNodeFirstChild: *const fn (hn: HNode, phn: *HNode) callconv(.c) DomResult, + SciterNodeLastChild: *const fn (hn: HNode, phn: *HNode) callconv(.c) DomResult, + SciterNodeNextSibling: *const fn (hn: HNode, phn: *HNode) callconv(.c) DomResult, + SciterNodePrevSibling: *const fn (hn: HNode, phn: *HNode) callconv(.c) DomResult, + SciterNodeParent: *const fn (hnode: HNode, pheParent: *HElement) callconv(.c) DomResult, + SciterNodeNthChild: *const fn (hnode: HNode, n: u32, phn: *HNode) callconv(.c) DomResult, + SciterNodeChildrenCount: *const fn (hnode: HNode, pn: *u32) callconv(.c) DomResult, + SciterNodeType: *const fn (hnode: HNode, pNodeType: *NodeType) callconv(.c) DomResult, + SciterNodeGetText: *const fn (hnode: HNode, rcv: *const WStrReceiver, rcv_param: ?*anyopaque) callconv(.c) DomResult, + SciterNodeSetText: *const fn (hnode: HNode, text: [*]const u16, textLength: u32) callconv(.c) DomResult, + SciterNodeInsert: *const fn (hnode: HNode, where: NodeInsTarget, what: HNode) callconv(.c) DomResult, + SciterNodeRemove: *const fn (hnode: HNode, finalize: Bool) callconv(.c) DomResult, + SciterCreateTextNode: *const fn (text: [*]const u16, textLength: u32, phnode: *HNode) callconv(.c) DomResult, + SciterCreateCommentNode: *const fn (text: [*]const u16, textLength: u32, phnode: *HNode) callconv(.c) DomResult, + + // --- Value API ----------------------------------------------------------- + + ValueInit: *const fn (pval: *Value) callconv(.c) u32, + ValueClear: *const fn (pval: *Value) callconv(.c) u32, + ValueCompare: *const fn (pval1: *const Value, pval2: *const Value) callconv(.c) u32, + ValueCopy: *const fn (pdst: *Value, psrc: *const Value) callconv(.c) u32, + ValueIsolate: *const fn (pdst: *Value) callconv(.c) u32, + ValueType: *const fn (pval: *const Value, pType: *u32, pUnits: *u32) callconv(.c) u32, + ValueStringData: *const fn (pval: *const Value, pChars: *[*]const u16, pNumChars: *u32) callconv(.c) u32, + ValueStringDataSet: *const fn (pval: *Value, chars: [*]const u16, numChars: u32, units: u32) callconv(.c) u32, + ValueIntData: *const fn (pval: *const Value, pData: *i32) callconv(.c) u32, + ValueIntDataSet: *const fn (pval: *Value, data: i32, type: u32, units: u32) callconv(.c) u32, + ValueInt64Data: *const fn (pval: *const Value, pData: *i64) callconv(.c) u32, + ValueInt64DataSet: *const fn (pval: *Value, data: i64, type: u32, units: u32) callconv(.c) u32, + ValueFloatData: *const fn (pval: *const Value, pData: *f64) callconv(.c) u32, + ValueFloatDataSet: *const fn (pval: *Value, data: f64, type: u32, units: u32) callconv(.c) u32, + ValueBinaryData: *const fn (pval: *const Value, pBytes: *[*]const u8, pnBytes: *u32) callconv(.c) u32, + ValueBinaryDataSet: *const fn (pval: *Value, pBytes: [*]const u8, nBytes: u32, type: u32, units: u32) callconv(.c) u32, + ValueElementsCount: *const fn (pval: *const Value, pn: *i32) callconv(.c) u32, + ValueNthElementValue: *const fn (pval: *const Value, n: i32, pretval: *Value) callconv(.c) u32, + ValueNthElementValueSet: *const fn (pval: *Value, n: i32, pval_to_set: *const Value) callconv(.c) u32, + ValueNthElementKey: *const fn (pval: *const Value, n: i32, pretval: *Value) callconv(.c) u32, + ValueEnumElements: *const fn (pval: *const Value, penum: *const KeyValueCallback, param: ?*anyopaque) callconv(.c) u32, + ValueSetValueToKey: *const fn (pval: *Value, pkey: *const Value, pval_to_set: *const Value) callconv(.c) u32, + ValueGetValueOfKey: *const fn (pval: *const Value, pkey: *const Value, pretval: *Value) callconv(.c) u32, + ValueToString: *const fn (pval: *Value, how: ValueStringCvtType) callconv(.c) u32, + ValueFromString: *const fn (pval: *Value, str: [*]const u16, strLength: u32, how: ValueStringCvtType) callconv(.c) u32, + ValueInvoke: *const fn (pval: *const Value, pthis: *Value, argc: u32, argv: *const Value, pretval: *Value, url: CWStr) callconv(.c) u32, + ValueNativeFunctorSet: *const fn (pval: *Value, pinvoke: *const NativeFunctorInvoke, prelease: *const NativeFunctorRelease, tag: *void) callconv(.c) u32, + ValueIsNativeFunctor: *const fn (pval: *const Value) callconv(.c) Bool, + + // Used to be script VM API + + reserved1: *anyopaque, + reserved2: *anyopaque, + reserved3: *anyopaque, + reserved4: *anyopaque, + + SciterOpenArchive: *const fn (archiveData: [*]const u8, archiveDataLength: u32) callconv(.c) HSArchive, + SciterGetArchiveItem: *const fn (harc: HSArchive, path: CWStr, pdata: *[*]const u8, pdataLength: *u32) callconv(.c) Bool, + SciterCloseArchive: *const fn (harc: HSArchive) callconv(.c) Bool, + + SciterFireEvent: *const fn (evt: *const BehaviorEventParams, post: Bool, handled: *Bool) callconv(.c) DomResult, + + SciterGetCallbackParam: *const fn (hwnd: HWindow) callconv(.c) ?*anyopaque, + SciterPostCallback: *const fn (hwnd: HWindow, wparam: isize, lparam: usize, timeoutms: u32) callconv(.c) isize, + + GetSciterGraphicsAPI: *const fn () callconv(.c) *GraphicsAPI, + GetSciterRequestAPI: *const fn () callconv(.c) *RequestAPI, + + /// IDXGISwapChain + SciterCreateOnDirectXWindow: *const fn (hwnd: HWindow, pSwapChain: *anyopaque) callconv(.c) Bool, + SciterRenderOnDirectXWindow: *const fn (hwnd: HWindow, elementToRenderOrNull: HElement, frontLayer: Bool) callconv(.c) Bool, + /// IDXGISurface + SciterRenderOnDirectXTexture: *const fn (hwnd: HWindow, elementToRenderOrNull: HElement, surface: *anyopaque) callconv(.c) Bool, + + SciterProcX: *const fn (hwnd: HWindow, pMsg: *XMsg) callconv(.c) Bool, + + SciterAtomValue: *const fn (name: CStr) callconv(.c) u64, + SciterAtomNameCB: *const fn (atomv: u64, rcv: *const StrReceiver, rcv_param: ?*anyopaque) callconv(.c) Bool, + + SciterSetGlobalAsset: *const fn (pass: *OmAsset) callconv(.c) Bool, + SciterGetElementAsset: *const fn (el: HElement, nameAtom: u64, ppass: *?*OmAsset) callconv(.c) DomResult, + + SciterSetVariable: *const fn (hwndOrNull: HWindow, name: CStr, pvalToSet: *const Value) callconv(.c) u32, + SciterGetVariable: *const fn (hwndOrNull: HWindow, name: CStr, pvalToGet: *Value) callconv(.c) u32, + + SciterElementUnwrap: *const fn (pval: *const Value, ppElement: *HElement) callconv(.c) u32, + SciterElementWrap: *const fn (pval: *Value, pElement: HElement) callconv(.c) u32, + + SciterNodeUnwrap: *const fn (pval: *const Value, ppNode: *HNode) callconv(.c) u32, + SciterNodeWrap: *const fn (pval: *Value, pNode: HNode) callconv(.c) u32, + + SciterReleaseGlobalAsset: *const fn (pass: *OmAsset) callconv(.c) Bool, + + SciterExec: *const fn (appCmd: u32, p1: usize, p2: usize) callconv(.c) isize, + SciterWindowExec: *const fn (hwnd: HWindow, windowCmd: u32, p1: usize, p2: usize) callconv(.c) isize, + + SciterEGLGetProcAddress: *const fn (procName: CStr) callconv(.c) ?*anyopaque, + SciterEGLSendEvent: *const fn (he: HElement, eventCode: u32, reason: usize) callconv(.c) DomResult, + SciterRequestAnimationFrameEvent: *const fn (he: HElement, eventCode: u32, reason: usize) callconv(.c) DomResult, +}; + +// TODO These APIs are actually well-known structs with function pointers in +// them, which may provide useful functionality + +pub const GraphicsAPI = opaque {}; +pub const RequestAPI = opaque {}; diff --git a/packages/sciter/vendor/sciter.dll b/packages/sciter/vendor/sciter.dll new file mode 100644 index 0000000..d1ae272 --- /dev/null +++ b/packages/sciter/vendor/sciter.dll @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e3975ac6263058493486be85d5e48401a07507743e715b32cca925b3cf4c0375 +size 18819584