mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
move rust-sciter in
This commit is contained in:
14
libs/rust-sciter/src/capi/mod.rs
Normal file
14
libs/rust-sciter/src/capi/mod.rs
Normal file
@@ -0,0 +1,14 @@
|
||||
/*! C interface headers */
|
||||
|
||||
pub mod scapi;
|
||||
pub mod scbehavior;
|
||||
pub mod scdef;
|
||||
pub mod scdom;
|
||||
pub mod scgraphics;
|
||||
pub mod screquest;
|
||||
pub mod sctiscript;
|
||||
pub mod sctypes;
|
||||
pub mod scvalue;
|
||||
pub mod schandler;
|
||||
pub mod scmsg;
|
||||
pub mod scom;
|
||||
279
libs/rust-sciter/src/capi/scapi.rs
Normal file
279
libs/rust-sciter/src/capi/scapi.rs
Normal file
@@ -0,0 +1,279 @@
|
||||
//! Sciter C API interface.
|
||||
|
||||
#![allow(non_snake_case, non_camel_case_types)]
|
||||
|
||||
use capi::sctypes::*;
|
||||
use capi::scdef::*;
|
||||
use capi::scdom::*;
|
||||
use capi::scvalue::*;
|
||||
use capi::sctiscript::{HVM, tiscript_value, tiscript_native_interface};
|
||||
use capi::scbehavior::*;
|
||||
use capi::scgraphics::SciterGraphicsAPI;
|
||||
use capi::screquest::{SciterRequestAPI, HREQUEST, REQUEST_PARAM};
|
||||
use capi::scmsg::{SCITER_X_MSG};
|
||||
use capi::scom::som_asset_t;
|
||||
|
||||
|
||||
/// Sciter API functions.
|
||||
#[repr(C)]
|
||||
#[allow(missing_docs)]
|
||||
#[doc(hidden)]
|
||||
pub struct ISciterAPI
|
||||
{
|
||||
pub version: UINT,
|
||||
|
||||
pub SciterClassName: extern "system" fn () -> LPCWSTR,
|
||||
pub SciterVersion: extern "system" fn (major: BOOL) -> UINT,
|
||||
|
||||
pub SciterDataReady: extern "system" fn (hwnd: HWINDOW, uri: LPCWSTR, data: LPCBYTE, dataLength: UINT) -> BOOL,
|
||||
pub SciterDataReadyAsync: extern "system" fn (hwnd: HWINDOW, uri: LPCWSTR, data: LPCBYTE, dataLength: UINT, requestId: HREQUEST) -> BOOL,
|
||||
|
||||
// #ifdef WINDOWS
|
||||
#[cfg(all(windows, not(feature = "windowless")))]
|
||||
pub SciterProc: extern "system" fn (hwnd: HWINDOW, msg: UINT, wParam: WPARAM, lParam: LPARAM) -> LRESULT,
|
||||
#[cfg(all(windows, not(feature = "windowless")))]
|
||||
pub SciterProcND: extern "system" fn (hwnd: HWINDOW, msg: UINT, wParam: WPARAM, lParam: LPARAM, pbHandled: * mut BOOL) -> LRESULT,
|
||||
// #endif
|
||||
|
||||
pub SciterLoadFile: extern "system" fn (hWndSciter: HWINDOW, filename: LPCWSTR) -> BOOL,
|
||||
|
||||
pub SciterLoadHtml: extern "system" fn (hWndSciter: HWINDOW, html: LPCBYTE, htmlSize: UINT, baseUrl: LPCWSTR) -> BOOL,
|
||||
pub SciterSetCallback: extern "system" fn (hWndSciter: HWINDOW, cb: SciterHostCallback, cbParam: LPVOID) -> VOID,
|
||||
pub SciterSetMasterCSS: extern "system" fn (utf8: LPCBYTE, numBytes: UINT) -> BOOL,
|
||||
pub SciterAppendMasterCSS: extern "system" fn (utf8: LPCBYTE, numBytes: UINT) -> BOOL,
|
||||
pub SciterSetCSS: extern "system" fn (hWndSciter: HWINDOW, utf8: LPCBYTE, numBytes: UINT, baseUrl: LPCWSTR, mediaType: LPCWSTR) -> BOOL,
|
||||
pub SciterSetMediaType: extern "system" fn (hWndSciter: HWINDOW, mediaType: LPCWSTR) -> BOOL,
|
||||
pub SciterSetMediaVars: extern "system" fn (hWndSciter: HWINDOW, mediaVars: * const VALUE) -> BOOL,
|
||||
pub SciterGetMinWidth: extern "system" fn (hWndSciter: HWINDOW) -> UINT,
|
||||
pub SciterGetMinHeight: extern "system" fn (hWndSciter: HWINDOW, width: UINT) -> UINT,
|
||||
pub SciterCall: extern "system" fn (hWnd: HWINDOW, functionName: LPCSTR, argc: UINT, argv: * const VALUE, retval: * mut VALUE) -> BOOL,
|
||||
pub SciterEval: extern "system" fn (hwnd: HWINDOW, script: LPCWSTR, scriptLength: UINT, pretval: * mut VALUE) -> BOOL,
|
||||
pub SciterUpdateWindow: extern "system" fn (hwnd: HWINDOW) -> VOID,
|
||||
|
||||
// #ifdef WINDOWS
|
||||
#[cfg(all(windows, not(feature = "windowless")))]
|
||||
pub SciterTranslateMessage: extern "system" fn (lpMsg: * mut MSG) -> BOOL,
|
||||
// #endif
|
||||
|
||||
pub SciterSetOption: extern "system" fn (hWnd: HWINDOW, option: SCITER_RT_OPTIONS, value: UINT_PTR) -> BOOL,
|
||||
pub SciterGetPPI: extern "system" fn (hWndSciter: HWINDOW, px: * mut UINT, py: * mut UINT) -> VOID,
|
||||
pub SciterGetViewExpando: extern "system" fn (hwnd: HWINDOW, pval: * mut VALUE) -> BOOL,
|
||||
|
||||
// #ifdef WINDOWS
|
||||
#[cfg(all(windows, not(feature = "windowless")))]
|
||||
pub SciterRenderD2D: extern "system" fn (hWndSciter: HWINDOW, prt: * mut ID2D1RenderTarget) -> BOOL,
|
||||
#[cfg(all(windows, not(feature = "windowless")))]
|
||||
pub SciterD2DFactory: extern "system" fn (ppf: * mut* mut ID2D1Factory) -> BOOL,
|
||||
#[cfg(all(windows, not(feature = "windowless")))]
|
||||
pub SciterDWFactory: extern "system" fn (ppf: * mut* mut IDWriteFactory) -> BOOL,
|
||||
// #endif
|
||||
|
||||
pub SciterGraphicsCaps: extern "system" fn (pcaps: LPUINT) -> BOOL,
|
||||
pub SciterSetHomeURL: extern "system" fn (hWndSciter: HWINDOW, baseUrl: LPCWSTR) -> BOOL,
|
||||
|
||||
// #if defined(OSX)
|
||||
#[cfg(all(target_os="macos", not(feature = "windowless")))]
|
||||
pub SciterCreateNSView: extern "system" fn (frame: LPRECT) -> HWINDOW, // returns NSView*
|
||||
// #endif
|
||||
|
||||
// #if defined(LINUX)
|
||||
#[cfg(all(target_os="linux", not(feature = "windowless")))]
|
||||
pub SciterCreateWidget: extern "system" fn (frame: LPRECT) -> HWINDOW, // returns GtkWidget
|
||||
// #endif
|
||||
|
||||
#[cfg(not(feature = "windowless"))]
|
||||
pub SciterCreateWindow: extern "system" fn (creationFlags: UINT, frame: LPCRECT, delegate: * const SciterWindowDelegate, delegateParam: LPVOID, parent: HWINDOW) -> HWINDOW,
|
||||
|
||||
pub SciterSetupDebugOutput: extern "system" fn (hwndOrNull: HWINDOW, param: LPVOID, pfOutput: DEBUG_OUTPUT_PROC),
|
||||
|
||||
//|
|
||||
//| DOM Element API
|
||||
//|
|
||||
pub Sciter_UseElement: extern "system" fn (he: HELEMENT) -> SCDOM_RESULT,
|
||||
pub Sciter_UnuseElement: extern "system" fn (he: HELEMENT) -> SCDOM_RESULT,
|
||||
pub SciterGetRootElement: extern "system" fn (hwnd: HWINDOW, phe: * mut HELEMENT) -> SCDOM_RESULT,
|
||||
pub SciterGetFocusElement: extern "system" fn (hwnd: HWINDOW, phe: * mut HELEMENT) -> SCDOM_RESULT,
|
||||
pub SciterFindElement: extern "system" fn (hwnd: HWINDOW, pt: POINT, phe: * mut HELEMENT) -> SCDOM_RESULT,
|
||||
pub SciterGetChildrenCount: extern "system" fn (he: HELEMENT, count: * mut UINT) -> SCDOM_RESULT,
|
||||
pub SciterGetNthChild: extern "system" fn (he: HELEMENT, n: UINT, phe: * mut HELEMENT) -> SCDOM_RESULT,
|
||||
pub SciterGetParentElement: extern "system" fn (he: HELEMENT, p_parent_he: * mut HELEMENT) -> SCDOM_RESULT,
|
||||
pub SciterGetElementHtmlCB: extern "system" fn (he: HELEMENT, outer: BOOL, rcv: LPCBYTE_RECEIVER, rcv_param: LPVOID) -> SCDOM_RESULT,
|
||||
pub SciterGetElementTextCB: extern "system" fn (he: HELEMENT, rcv: LPCWSTR_RECEIVER, rcv_param: LPVOID) -> SCDOM_RESULT,
|
||||
pub SciterSetElementText: extern "system" fn (he: HELEMENT, utf16: LPCWSTR, length: UINT) -> SCDOM_RESULT,
|
||||
pub SciterGetAttributeCount: extern "system" fn (he: HELEMENT, p_count: LPUINT) -> SCDOM_RESULT,
|
||||
pub SciterGetNthAttributeNameCB: extern "system" fn (he: HELEMENT, n: UINT, rcv: LPCSTR_RECEIVER, rcv_param: LPVOID) -> SCDOM_RESULT,
|
||||
pub SciterGetNthAttributeValueCB: extern "system" fn (he: HELEMENT, n: UINT, rcv: LPCWSTR_RECEIVER, rcv_param: LPVOID) -> SCDOM_RESULT,
|
||||
pub SciterGetAttributeByNameCB: extern "system" fn (he: HELEMENT, name: LPCSTR, rcv: LPCWSTR_RECEIVER, rcv_param: LPVOID) -> SCDOM_RESULT,
|
||||
pub SciterSetAttributeByName: extern "system" fn (he: HELEMENT, name: LPCSTR, value: LPCWSTR) -> SCDOM_RESULT,
|
||||
pub SciterClearAttributes: extern "system" fn (he: HELEMENT) -> SCDOM_RESULT,
|
||||
pub SciterGetElementIndex: extern "system" fn (he: HELEMENT, p_index: LPUINT) -> SCDOM_RESULT,
|
||||
pub SciterGetElementType: extern "system" fn (he: HELEMENT, p_type: * mut LPCSTR) -> SCDOM_RESULT,
|
||||
pub SciterGetElementTypeCB: extern "system" fn (he: HELEMENT, rcv: LPCSTR_RECEIVER, rcv_param: LPVOID) -> SCDOM_RESULT,
|
||||
pub SciterGetStyleAttributeCB: extern "system" fn (he: HELEMENT, name: LPCSTR, rcv: LPCWSTR_RECEIVER, rcv_param: LPVOID) -> SCDOM_RESULT,
|
||||
pub SciterSetStyleAttribute: extern "system" fn (he: HELEMENT, name: LPCSTR, value: LPCWSTR) -> SCDOM_RESULT,
|
||||
pub SciterGetElementLocation: extern "system" fn (he: HELEMENT, p_location: LPRECT, areas: UINT /*ELEMENT_AREAS*/) -> SCDOM_RESULT,
|
||||
pub SciterScrollToView: extern "system" fn (he: HELEMENT, SciterScrollFlags: UINT) -> SCDOM_RESULT,
|
||||
pub SciterUpdateElement: extern "system" fn (he: HELEMENT, andForceRender: BOOL) -> SCDOM_RESULT,
|
||||
pub SciterRefreshElementArea: extern "system" fn (he: HELEMENT, rc: RECT) -> SCDOM_RESULT,
|
||||
pub SciterSetCapture: extern "system" fn (he: HELEMENT) -> SCDOM_RESULT,
|
||||
pub SciterReleaseCapture: extern "system" fn (he: HELEMENT) -> SCDOM_RESULT,
|
||||
pub SciterGetElementHwnd: extern "system" fn (he: HELEMENT, p_hwnd: * mut HWINDOW, rootWindow: BOOL) -> SCDOM_RESULT,
|
||||
pub SciterCombineURL: extern "system" fn (he: HELEMENT, szUrlBuffer: LPWSTR, UrlBufferSize: UINT) -> SCDOM_RESULT,
|
||||
pub SciterSelectElements: extern "system" fn (he: HELEMENT, CSS_selectors: LPCSTR, callback: SciterElementCallback, param: LPVOID) -> SCDOM_RESULT,
|
||||
pub SciterSelectElementsW: extern "system" fn (he: HELEMENT, CSS_selectors: LPCWSTR, callback: SciterElementCallback, param: LPVOID) -> SCDOM_RESULT,
|
||||
pub SciterSelectParent: extern "system" fn (he: HELEMENT, selector: LPCSTR, depth: UINT, heFound: * mut HELEMENT) -> SCDOM_RESULT,
|
||||
pub SciterSelectParentW: extern "system" fn (he: HELEMENT, selector: LPCWSTR, depth: UINT, heFound: * mut HELEMENT) -> SCDOM_RESULT,
|
||||
pub SciterSetElementHtml: extern "system" fn (he: HELEMENT, html: * const BYTE, htmlLength: UINT, how: UINT) -> SCDOM_RESULT,
|
||||
pub SciterGetElementUID: extern "system" fn (he: HELEMENT, puid: * mut UINT) -> SCDOM_RESULT,
|
||||
pub SciterGetElementByUID: extern "system" fn (hwnd: HWINDOW, uid: UINT, phe: * mut HELEMENT) -> SCDOM_RESULT,
|
||||
pub SciterShowPopup: extern "system" fn (hePopup: HELEMENT, heAnchor: HELEMENT, placement: UINT) -> SCDOM_RESULT,
|
||||
pub SciterShowPopupAt: extern "system" fn (hePopup: HELEMENT, pos: POINT, placement: UINT) -> SCDOM_RESULT,
|
||||
pub SciterHidePopup: extern "system" fn (he: HELEMENT) -> SCDOM_RESULT,
|
||||
pub SciterGetElementState: extern "system" fn (he: HELEMENT, pstateBits: * mut UINT) -> SCDOM_RESULT,
|
||||
pub SciterSetElementState: extern "system" fn (he: HELEMENT, stateBitsToSet: UINT, stateBitsToClear: UINT, updateView: BOOL) -> SCDOM_RESULT,
|
||||
pub SciterCreateElement: extern "system" fn (tagname: LPCSTR, textOrNull: LPCWSTR, /*out*/ phe: * mut HELEMENT) -> SCDOM_RESULT,
|
||||
pub SciterCloneElement: extern "system" fn (he: HELEMENT, /*out*/ phe: * mut HELEMENT) -> SCDOM_RESULT,
|
||||
pub SciterInsertElement: extern "system" fn (he: HELEMENT, hparent: HELEMENT, index: UINT) -> SCDOM_RESULT,
|
||||
pub SciterDetachElement: extern "system" fn (he: HELEMENT) -> SCDOM_RESULT,
|
||||
pub SciterDeleteElement: extern "system" fn (he: HELEMENT) -> SCDOM_RESULT,
|
||||
pub SciterSetTimer: extern "system" fn (he: HELEMENT, milliseconds: UINT, timer_id: UINT_PTR) -> SCDOM_RESULT,
|
||||
pub SciterDetachEventHandler: extern "system" fn (he: HELEMENT, pep: ElementEventProc, tag: LPVOID) -> SCDOM_RESULT,
|
||||
pub SciterAttachEventHandler: extern "system" fn (he: HELEMENT, pep: ElementEventProc, tag: LPVOID) -> SCDOM_RESULT,
|
||||
pub SciterWindowAttachEventHandler: extern "system" fn (hwndLayout: HWINDOW, pep: ElementEventProc, tag: LPVOID, subscription: UINT) -> SCDOM_RESULT,
|
||||
pub SciterWindowDetachEventHandler: extern "system" fn (hwndLayout: HWINDOW, pep: ElementEventProc, tag: LPVOID) -> SCDOM_RESULT,
|
||||
pub SciterSendEvent: extern "system" fn (he: HELEMENT, appEventCode: UINT, heSource: HELEMENT, reason: UINT_PTR, /*out*/ handled: * mut BOOL) -> SCDOM_RESULT,
|
||||
pub SciterPostEvent: extern "system" fn (he: HELEMENT, appEventCode: UINT, heSource: HELEMENT, reason: UINT_PTR) -> SCDOM_RESULT,
|
||||
pub SciterCallBehaviorMethod: extern "system" fn (he: HELEMENT, params: * const METHOD_PARAMS) -> SCDOM_RESULT,
|
||||
pub SciterRequestElementData: extern "system" fn (he: HELEMENT, url: LPCWSTR, dataType: UINT, initiator: HELEMENT) -> SCDOM_RESULT,
|
||||
pub SciterHttpRequest: extern "system" fn (he: HELEMENT, url: LPCWSTR, dataType: UINT, requestType: UINT, requestParams: * const REQUEST_PARAM, nParams: UINT) -> SCDOM_RESULT,
|
||||
pub SciterGetScrollInfo: extern "system" fn (he: HELEMENT, scrollPos: LPPOINT, viewRect: LPRECT, contentSize: LPSIZE) -> SCDOM_RESULT,
|
||||
pub SciterSetScrollPos: extern "system" fn (he: HELEMENT, scrollPos: POINT, smooth: BOOL) -> SCDOM_RESULT,
|
||||
pub SciterGetElementIntrinsicWidths: extern "system" fn (he: HELEMENT, pMinWidth: * mut INT, pMaxWidth: * mut INT) -> SCDOM_RESULT,
|
||||
pub SciterGetElementIntrinsicHeight: extern "system" fn (he: HELEMENT, forWidth: INT, pHeight: * mut INT) -> SCDOM_RESULT,
|
||||
pub SciterIsElementVisible: extern "system" fn (he: HELEMENT, pVisible: * mut BOOL) -> SCDOM_RESULT,
|
||||
pub SciterIsElementEnabled: extern "system" fn (he: HELEMENT, pEnabled: * mut BOOL) -> SCDOM_RESULT,
|
||||
pub SciterSortElements: extern "system" fn (he: HELEMENT, firstIndex: UINT, lastIndex: UINT, cmpFunc: * mut ELEMENT_COMPARATOR, cmpFuncParam: LPVOID) -> SCDOM_RESULT,
|
||||
pub SciterSwapElements: extern "system" fn (he1: HELEMENT, he2: HELEMENT) -> SCDOM_RESULT,
|
||||
pub SciterTraverseUIEvent: extern "system" fn (evt: UINT, eventCtlStruct: LPVOID, bOutProcessed: * mut BOOL) -> SCDOM_RESULT,
|
||||
pub SciterCallScriptingMethod: extern "system" fn (he: HELEMENT, name: LPCSTR, argv: * const VALUE, argc: UINT, retval: * mut VALUE) -> SCDOM_RESULT,
|
||||
pub SciterCallScriptingFunction: extern "system" fn (he: HELEMENT, name: LPCSTR, argv: * const VALUE, argc: UINT, retval: * mut VALUE) -> SCDOM_RESULT,
|
||||
pub SciterEvalElementScript: extern "system" fn (he: HELEMENT, script: LPCWSTR, scriptLength: UINT, retval: * mut VALUE) -> SCDOM_RESULT,
|
||||
pub SciterAttachHwndToElement: extern "system" fn (he: HELEMENT, hwnd: HWINDOW) -> SCDOM_RESULT,
|
||||
pub SciterControlGetType: extern "system" fn (he: HELEMENT, /*CTL_TYPE*/ pType: * mut UINT) -> SCDOM_RESULT,
|
||||
pub SciterGetValue: extern "system" fn (he: HELEMENT, pval: * mut VALUE) -> SCDOM_RESULT,
|
||||
pub SciterSetValue: extern "system" fn (he: HELEMENT, pval: * const VALUE) -> SCDOM_RESULT,
|
||||
pub SciterGetExpando: extern "system" fn (he: HELEMENT, pval: * mut VALUE, forceCreation: BOOL) -> SCDOM_RESULT,
|
||||
|
||||
#[deprecated(since="Sciter 4.4.3.24", note="TIScript native API is gone, use SOM instead.")]
|
||||
pub SciterGetObject: extern "system" fn (he: HELEMENT, pval: * mut tiscript_value, forceCreation: BOOL) -> SCDOM_RESULT,
|
||||
|
||||
#[deprecated(since="Sciter 4.4.3.24", note="TIScript native API is gone, use SOM instead.")]
|
||||
pub SciterGetElementNamespace: extern "system" fn (he: HELEMENT, pval: * mut tiscript_value) -> SCDOM_RESULT,
|
||||
|
||||
pub SciterGetHighlightedElement: extern "system" fn (hwnd: HWINDOW, phe: * mut HELEMENT) -> SCDOM_RESULT,
|
||||
pub SciterSetHighlightedElement: extern "system" fn (hwnd: HWINDOW, he: HELEMENT) -> SCDOM_RESULT,
|
||||
//|
|
||||
//| DOM Node API
|
||||
//|
|
||||
pub SciterNodeAddRef: extern "system" fn (hn: HNODE) -> SCDOM_RESULT,
|
||||
pub SciterNodeRelease: extern "system" fn (hn: HNODE) -> SCDOM_RESULT,
|
||||
pub SciterNodeCastFromElement: extern "system" fn (he: HELEMENT, phn: * mut HNODE) -> SCDOM_RESULT,
|
||||
pub SciterNodeCastToElement: extern "system" fn (hn: HNODE, he: * mut HELEMENT) -> SCDOM_RESULT,
|
||||
pub SciterNodeFirstChild: extern "system" fn (hn: HNODE, phn: * mut HNODE) -> SCDOM_RESULT,
|
||||
pub SciterNodeLastChild: extern "system" fn (hn: HNODE, phn: * mut HNODE) -> SCDOM_RESULT,
|
||||
pub SciterNodeNextSibling: extern "system" fn (hn: HNODE, phn: * mut HNODE) -> SCDOM_RESULT,
|
||||
pub SciterNodePrevSibling: extern "system" fn (hn: HNODE, phn: * mut HNODE) -> SCDOM_RESULT,
|
||||
pub SciterNodeParent: extern "system" fn (hnode: HNODE, pheParent: * mut HELEMENT) -> SCDOM_RESULT,
|
||||
pub SciterNodeNthChild: extern "system" fn (hnode: HNODE, n: UINT, phn: * mut HNODE) -> SCDOM_RESULT,
|
||||
pub SciterNodeChildrenCount: extern "system" fn (hnode: HNODE, pn: * mut UINT) -> SCDOM_RESULT,
|
||||
pub SciterNodeType: extern "system" fn (hnode: HNODE, pNodeType: * mut UINT /*NODE_TYPE*/) -> SCDOM_RESULT,
|
||||
pub SciterNodeGetText: extern "system" fn (hnode: HNODE, rcv: * mut LPCWSTR_RECEIVER, rcv_param: LPVOID) -> SCDOM_RESULT,
|
||||
pub SciterNodeSetText: extern "system" fn (hnode: HNODE, text: LPCWSTR, textLength: UINT) -> SCDOM_RESULT,
|
||||
pub SciterNodeInsert: extern "system" fn (hnode: HNODE, how: UINT /*NODE_INS_TARGET*/, what: HNODE) -> SCDOM_RESULT,
|
||||
pub SciterNodeRemove: extern "system" fn (hnode: HNODE, finalize: BOOL) -> SCDOM_RESULT,
|
||||
pub SciterCreateTextNode: extern "system" fn (text: LPCWSTR, textLength: UINT, phnode: * mut HNODE) -> SCDOM_RESULT,
|
||||
pub SciterCreateCommentNode: extern "system" fn (text: LPCWSTR, textLength: UINT, phnode: * mut HNODE) -> SCDOM_RESULT,
|
||||
//|
|
||||
//| Value API
|
||||
//|
|
||||
pub ValueInit: extern "system" fn (pval: * mut VALUE) -> VALUE_RESULT,
|
||||
pub ValueClear: extern "system" fn (pval: * mut VALUE) -> VALUE_RESULT,
|
||||
pub ValueCompare: extern "system" fn (pval1: * const VALUE, pval2: * const VALUE) -> VALUE_RESULT,
|
||||
pub ValueCopy: extern "system" fn (pdst: * mut VALUE, psrc: * const VALUE) -> VALUE_RESULT,
|
||||
pub ValueIsolate: extern "system" fn (pdst: * mut VALUE) -> VALUE_RESULT,
|
||||
pub ValueType: extern "system" fn (pval: * const VALUE, pType: * mut UINT, pUnits: * mut UINT) -> VALUE_RESULT,
|
||||
pub ValueStringData: extern "system" fn (pval: * const VALUE, pChars: * mut LPCWSTR, pNumChars: * mut UINT) -> VALUE_RESULT,
|
||||
pub ValueStringDataSet: extern "system" fn (pval: * mut VALUE, chars: LPCWSTR, numChars: UINT, units: UINT) -> VALUE_RESULT,
|
||||
pub ValueIntData: extern "system" fn (pval: * const VALUE, pData: * mut INT) -> VALUE_RESULT,
|
||||
pub ValueIntDataSet: extern "system" fn (pval: * mut VALUE, data: INT, vtype: UINT, units: UINT) -> VALUE_RESULT,
|
||||
pub ValueInt64Data: extern "system" fn (pval: * const VALUE, pData: * mut INT64) -> VALUE_RESULT,
|
||||
pub ValueInt64DataSet: extern "system" fn (pval: * mut VALUE, data: INT64, vtype: UINT, units: UINT) -> VALUE_RESULT,
|
||||
pub ValueFloatData: extern "system" fn (pval: * const VALUE, pData: * mut FLOAT_VALUE) -> VALUE_RESULT,
|
||||
pub ValueFloatDataSet: extern "system" fn (pval: * mut VALUE, data: FLOAT_VALUE, vtype: UINT, units: UINT) -> VALUE_RESULT,
|
||||
pub ValueBinaryData: extern "system" fn (pval: * const VALUE, pBytes: * mut LPCBYTE, pnBytes: * mut UINT) -> VALUE_RESULT,
|
||||
pub ValueBinaryDataSet: extern "system" fn (pval: * mut VALUE, pBytes: LPCBYTE, nBytes: UINT, vtype: UINT, units: UINT) -> VALUE_RESULT,
|
||||
pub ValueElementsCount: extern "system" fn (pval: * const VALUE, pn: * mut INT) -> VALUE_RESULT,
|
||||
pub ValueNthElementValue: extern "system" fn (pval: * const VALUE, n: INT, pretval: * mut VALUE) -> VALUE_RESULT,
|
||||
pub ValueNthElementValueSet: extern "system" fn (pval: * mut VALUE, n: INT, pval_to_set: * const VALUE) -> VALUE_RESULT,
|
||||
pub ValueNthElementKey: extern "system" fn (pval: * const VALUE, n: INT, pretval: * mut VALUE) -> VALUE_RESULT,
|
||||
pub ValueEnumElements: extern "system" fn (pval: * const VALUE, penum: KeyValueCallback, param: LPVOID) -> VALUE_RESULT,
|
||||
pub ValueSetValueToKey: extern "system" fn (pval: * mut VALUE, pkey: * const VALUE, pval_to_set: * const VALUE) -> VALUE_RESULT,
|
||||
pub ValueGetValueOfKey: extern "system" fn (pval: * const VALUE, pkey: * const VALUE, pretval: * mut VALUE) -> VALUE_RESULT,
|
||||
pub ValueToString: extern "system" fn (pval: * mut VALUE, how: VALUE_STRING_CVT_TYPE) -> VALUE_RESULT,
|
||||
pub ValueFromString: extern "system" fn (pval: * mut VALUE, str: LPCWSTR, strLength: UINT, how: VALUE_STRING_CVT_TYPE) -> UINT,
|
||||
pub ValueInvoke: extern "system" fn (pval: * const VALUE, pthis: * mut VALUE, argc: UINT, argv: * const VALUE, pretval: * mut VALUE, url: LPCWSTR) -> VALUE_RESULT,
|
||||
pub ValueNativeFunctorSet: extern "system" fn (pval: * mut VALUE, pinvoke: NATIVE_FUNCTOR_INVOKE, prelease: NATIVE_FUNCTOR_RELEASE, tag: LPVOID) -> VALUE_RESULT,
|
||||
pub ValueIsNativeFunctor: extern "system" fn (pval: * const VALUE) -> BOOL,
|
||||
|
||||
// tiscript VM API
|
||||
|
||||
#[deprecated(since="Sciter 4.4.3.24", note="TIScript native API is gone, use SOM instead.")]
|
||||
pub TIScriptAPI: extern "system" fn () -> * mut tiscript_native_interface,
|
||||
|
||||
#[deprecated(since="Sciter 4.4.3.24", note="TIScript native API is gone, use SOM instead.")]
|
||||
pub SciterGetVM: extern "system" fn (hwnd: HWINDOW) -> HVM,
|
||||
|
||||
// since 3.1.0.12
|
||||
#[deprecated(since="Sciter 4.4.3.24", note="TIScript native API is gone, use SOM instead.")]
|
||||
pub Sciter_v2V: extern "system" fn (vm: HVM, script_value: tiscript_value, value: * mut VALUE, isolate: BOOL) -> BOOL,
|
||||
|
||||
#[deprecated(since="Sciter 4.4.3.24", note="TIScript native API is gone, use SOM instead.")]
|
||||
pub Sciter_V2v: extern "system" fn (vm: HVM, valuev: * const VALUE, script_value: * mut tiscript_value) -> BOOL,
|
||||
|
||||
// since 3.1.0.18
|
||||
pub SciterOpenArchive: extern "system" fn (archiveData: LPCBYTE, archiveDataLength: UINT) -> HSARCHIVE,
|
||||
pub SciterGetArchiveItem: extern "system" fn (harc: HSARCHIVE, path: LPCWSTR, pdata: * mut LPCBYTE, pdataLength: * mut UINT) -> BOOL,
|
||||
pub SciterCloseArchive: extern "system" fn (harc: HSARCHIVE) -> BOOL,
|
||||
|
||||
// since 3.2.0.0
|
||||
pub SciterFireEvent: extern "system" fn (evt: * const BEHAVIOR_EVENT_PARAMS, post: BOOL, handled: * mut BOOL) -> SCDOM_RESULT,
|
||||
|
||||
pub SciterGetCallbackParam: extern "system" fn (hwnd: HWINDOW) -> LPVOID,
|
||||
pub SciterPostCallback: extern "system" fn (hwnd: HWINDOW, wparam: UINT_PTR, lparam: UINT_PTR, timeoutms: UINT) -> UINT_PTR,
|
||||
|
||||
// since 3.3.1.0
|
||||
pub GetSciterGraphicsAPI: extern "system" fn () -> * const SciterGraphicsAPI,
|
||||
|
||||
// since 3.3.1.6
|
||||
pub GetSciterRequestAPI: extern "system" fn () -> * const SciterRequestAPI,
|
||||
|
||||
// #ifdef WINDOWS
|
||||
// since 3.3.1.4
|
||||
#[cfg(all(windows, not(feature = "windowless")))]
|
||||
pub SciterCreateOnDirectXWindow: extern "system" fn (hwnd: HWINDOW, pSwapChain: * mut IDXGISwapChain) -> BOOL,
|
||||
#[cfg(all(windows, not(feature = "windowless")))]
|
||||
pub SciterRenderOnDirectXWindow: extern "system" fn (hwnd: HWINDOW, elementToRenderOrNull: HELEMENT, frontLayer: BOOL) -> BOOL,
|
||||
#[cfg(all(windows, not(feature = "windowless")))]
|
||||
pub SciterRenderOnDirectXTexture: extern "system" fn (hwnd: HWINDOW, elementToRenderOrNull: HELEMENT, surface: * mut IDXGISurface) -> BOOL,
|
||||
// #endif
|
||||
|
||||
// since 4.0.0.0
|
||||
pub SciterProcX: extern "system" fn(hwnd: HWINDOW, msg: * const SCITER_X_MSG) -> BOOL,
|
||||
|
||||
// since 4.4.2.14
|
||||
pub SciterAtomValue: extern "system" fn(name: LPCSTR) -> UINT64,
|
||||
pub SciterAtomNameCB: extern "system" fn(atomv: UINT64, rcv: LPCSTR_RECEIVER, rcv_param: LPVOID) -> BOOL,
|
||||
|
||||
// since 4.4.2.16
|
||||
pub SciterSetGlobalAsset: extern "system" fn(pass: *mut som_asset_t) -> BOOL,
|
||||
}
|
||||
0
libs/rust-sciter/src/capi/scarchive.rs
Normal file
0
libs/rust-sciter/src/capi/scarchive.rs
Normal file
543
libs/rust-sciter/src/capi/scbehavior.rs
Normal file
543
libs/rust-sciter/src/capi/scbehavior.rs
Normal file
@@ -0,0 +1,543 @@
|
||||
//! C interface for behaviors support (a.k.a windowless controls).
|
||||
|
||||
#![allow(non_camel_case_types, non_snake_case)]
|
||||
#![allow(dead_code)]
|
||||
|
||||
use capi::sctypes::*;
|
||||
use capi::scdom::*;
|
||||
use capi::scvalue::{VALUE};
|
||||
use capi::scgraphics::{HGFX};
|
||||
use capi::scom::{som_asset_t, som_passport_t};
|
||||
|
||||
#[repr(C)]
|
||||
pub struct BEHAVIOR_EVENT_PARAMS
|
||||
{
|
||||
/// Behavior event code. See [`BEHAVIOR_EVENTS`](enum.BEHAVIOR_EVENTS.html).
|
||||
pub cmd: UINT,
|
||||
|
||||
/// Target element handler.
|
||||
pub heTarget: HELEMENT,
|
||||
|
||||
/// Source element.
|
||||
pub he: HELEMENT,
|
||||
|
||||
/// UI action causing change.
|
||||
pub reason: UINT_PTR,
|
||||
|
||||
/// Auxiliary data accompanied with the event.
|
||||
pub data: VALUE,
|
||||
|
||||
/// Name of the custom event (when `cmd` is [`BEHAVIOR_EVENTS::CUSTOM`](enum.BEHAVIOR_EVENTS.html#variant.CUSTOM)).
|
||||
/// Since 4.2.8.
|
||||
pub name: LPCWSTR,
|
||||
}
|
||||
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone)]
|
||||
#[derive(Debug, PartialOrd, PartialEq)]
|
||||
pub enum INITIALIZATION_EVENTS
|
||||
{
|
||||
BEHAVIOR_DETACH = 0,
|
||||
BEHAVIOR_ATTACH = 1,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct INITIALIZATION_PARAMS
|
||||
{
|
||||
pub cmd: INITIALIZATION_EVENTS,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone)]
|
||||
#[derive(Debug, PartialOrd, PartialEq)]
|
||||
pub enum SOM_EVENTS
|
||||
{
|
||||
SOM_GET_PASSPORT = 0,
|
||||
SOM_GET_ASSET = 1,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub union SOM_PARAMS_DATA
|
||||
{
|
||||
pub asset: *const som_asset_t,
|
||||
pub passport: *const som_passport_t,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct SOM_PARAMS
|
||||
{
|
||||
pub cmd: SOM_EVENTS,
|
||||
pub result: SOM_PARAMS_DATA,
|
||||
}
|
||||
|
||||
/// Identifiers of methods currently supported by intrinsic behaviors.
|
||||
#[repr(C)]
|
||||
#[derive(Debug)]
|
||||
pub enum BEHAVIOR_METHOD_IDENTIFIERS {
|
||||
/// Raise a click event.
|
||||
DO_CLICK = 1,
|
||||
|
||||
/// `IS_EMPTY_PARAMS::is_empty` reflects the `:empty` state of the element.
|
||||
IS_EMPTY = 0xFC,
|
||||
|
||||
/// `VALUE_PARAMS`
|
||||
GET_VALUE = 0xFD,
|
||||
/// `VALUE_PARAMS`
|
||||
SET_VALUE = 0xFE,
|
||||
|
||||
/// User method identifier used in custom behaviors.
|
||||
///
|
||||
/// 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
|
||||
/// `SciterCallBehaviorMethod` API.
|
||||
FIRST_APPLICATION_METHOD_ID = 0x100,
|
||||
}
|
||||
|
||||
/// Method arguments used in `SciterCallBehaviorMethod()` or `HANDLE_METHOD_CALL`.
|
||||
#[repr(C)]
|
||||
pub struct METHOD_PARAMS {
|
||||
/// [`BEHAVIOR_METHOD_IDENTIFIERS`](enum.BEHAVIOR_METHOD_IDENTIFIERS.html) or user identifiers.
|
||||
pub method: UINT,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct IS_EMPTY_PARAMS {
|
||||
pub method: UINT,
|
||||
pub is_empty: UINT,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct VALUE_PARAMS {
|
||||
pub method: UINT,
|
||||
pub value: VALUE,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct SCRIPTING_METHOD_PARAMS
|
||||
{
|
||||
pub name: LPCSTR,
|
||||
pub argv: *const VALUE,
|
||||
pub argc: UINT,
|
||||
pub result: VALUE,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct TIMER_PARAMS
|
||||
{
|
||||
pub timerId: UINT_PTR,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct DRAW_PARAMS {
|
||||
/// Element layer to draw.
|
||||
pub layer: DRAW_EVENTS,
|
||||
|
||||
/// Graphics context.
|
||||
pub gfx: HGFX,
|
||||
|
||||
/// Element area.
|
||||
pub area: RECT,
|
||||
|
||||
/// Zero at the moment.
|
||||
pub reserved: UINT,
|
||||
}
|
||||
|
||||
/// Layer to draw.
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum DRAW_EVENTS {
|
||||
DRAW_BACKGROUND = 0,
|
||||
DRAW_CONTENT,
|
||||
DRAW_FOREGROUND,
|
||||
/// Note: since 4.2.3.
|
||||
DRAW_OUTLINE,
|
||||
}
|
||||
|
||||
|
||||
/// Event groups for subscription.
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone)]
|
||||
#[derive(Debug, PartialOrd, PartialEq)]
|
||||
pub enum EVENT_GROUPS
|
||||
{ /// Attached/detached.
|
||||
HANDLE_INITIALIZATION = 0x0000,
|
||||
/// Mouse events.
|
||||
HANDLE_MOUSE = 0x0001,
|
||||
/// Key events.
|
||||
HANDLE_KEY = 0x0002,
|
||||
/// Focus events, if this flag is set it also means that element it attached to is focusable.
|
||||
HANDLE_FOCUS = 0x0004,
|
||||
/// Scroll events.
|
||||
HANDLE_SCROLL = 0x0008,
|
||||
/// Timer event.
|
||||
HANDLE_TIMER = 0x0010,
|
||||
/// Size changed event.
|
||||
HANDLE_SIZE = 0x0020,
|
||||
/// Drawing request (event).
|
||||
HANDLE_DRAW = 0x0040,
|
||||
/// Requested data has been delivered.
|
||||
HANDLE_DATA_ARRIVED = 0x080,
|
||||
|
||||
/// Logical, synthetic events:
|
||||
/// `BUTTON_CLICK`, `HYPERLINK_CLICK`, etc.,
|
||||
/// a.k.a. notifications from intrinsic behaviors.
|
||||
HANDLE_BEHAVIOR_EVENT = 0x0100,
|
||||
/// Behavior specific methods.
|
||||
HANDLE_METHOD_CALL = 0x0200,
|
||||
/// Behavior specific methods.
|
||||
HANDLE_SCRIPTING_METHOD_CALL = 0x0400,
|
||||
|
||||
/// Behavior specific methods using direct `tiscript::value`'s.
|
||||
#[deprecated(since="Sciter 4.4.3.24", note="TIScript native API is gone, use SOM instead.")]
|
||||
HANDLE_TISCRIPT_METHOD_CALL = 0x0800,
|
||||
|
||||
/// System drag-n-drop.
|
||||
HANDLE_EXCHANGE = 0x1000,
|
||||
/// Touch input events.
|
||||
HANDLE_GESTURE = 0x2000,
|
||||
/// SOM passport and asset requests.
|
||||
HANDLE_SOM = 0x8000,
|
||||
|
||||
/// All of them.
|
||||
HANDLE_ALL = 0xFFFF,
|
||||
|
||||
/// Special value for getting subscription flags.
|
||||
SUBSCRIPTIONS_REQUEST = -1,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone)]
|
||||
#[derive(Debug, PartialOrd, PartialEq)]
|
||||
/// Event propagation schema.
|
||||
pub enum PHASE_MASK
|
||||
{
|
||||
/// Bubbling phase – direction: from a child element to all its containers.
|
||||
BUBBLING = 0,
|
||||
/// Sinking phase – direction: from containers to target child element.
|
||||
SINKING = 0x0_8000,
|
||||
/// Bubbling event consumed by some child.
|
||||
BUBBLING_HANDLED= 0x1_0000,
|
||||
/// Sinking event consumed by some child.
|
||||
SINKING_HANDLED = 0x1_8000,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone)]
|
||||
#[derive(Debug, PartialOrd, PartialEq)]
|
||||
/// Mouse buttons.
|
||||
pub enum MOUSE_BUTTONS
|
||||
{
|
||||
NONE = 0,
|
||||
|
||||
/// Left button.
|
||||
MAIN = 1,
|
||||
/// Right button.
|
||||
PROP = 2,
|
||||
/// Middle button.
|
||||
MIDDLE = 3,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone)]
|
||||
#[derive(Debug, PartialOrd, PartialEq)]
|
||||
/// Keyboard modifier buttons state.
|
||||
pub enum KEYBOARD_STATES
|
||||
{
|
||||
CONTROL_KEY_PRESSED = 0x01,
|
||||
SHIFT_KEY_PRESSED = 0x02,
|
||||
ALT_KEY_PRESSED = 0x04,
|
||||
}
|
||||
|
||||
impl std::convert::From<u32> for KEYBOARD_STATES {
|
||||
fn from(u: u32) -> Self {
|
||||
unsafe { std::mem::transmute(u) }
|
||||
}
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone)]
|
||||
#[derive(Debug, PartialOrd, PartialEq)]
|
||||
/// Keyboard input events.
|
||||
pub enum KEY_EVENTS
|
||||
{
|
||||
KEY_DOWN = 0,
|
||||
KEY_UP,
|
||||
KEY_CHAR,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone)]
|
||||
#[derive(Debug, PartialOrd, PartialEq)]
|
||||
/// Mouse events.
|
||||
pub enum MOUSE_EVENTS
|
||||
{
|
||||
MOUSE_ENTER = 0,
|
||||
MOUSE_LEAVE,
|
||||
MOUSE_MOVE,
|
||||
MOUSE_UP,
|
||||
MOUSE_DOWN,
|
||||
MOUSE_DCLICK,
|
||||
MOUSE_WHEEL,
|
||||
/// mouse pressed ticks
|
||||
MOUSE_TICK,
|
||||
/// mouse stay idle for some time
|
||||
MOUSE_IDLE,
|
||||
|
||||
/// item dropped, target is that dropped item
|
||||
DROP = 9,
|
||||
/// drag arrived to the target element that is one of current drop targets.
|
||||
DRAG_ENTER = 0xA,
|
||||
/// drag left one of current drop targets. target is the drop target element.
|
||||
DRAG_LEAVE = 0xB,
|
||||
/// drag src notification before drag start. To cancel - return true from handler.
|
||||
DRAG_REQUEST = 0xC,
|
||||
|
||||
/// mouse click event
|
||||
MOUSE_CLICK = 0xFF,
|
||||
|
||||
/// This flag is `OR`ed with `MOUSE_ENTER..MOUSE_DOWN` codes if dragging operation is in effect.
|
||||
/// E.g. event `DRAGGING | MOUSE_MOVE` is sent to underlying DOM elements while dragging.
|
||||
DRAGGING = 0x100,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone)]
|
||||
#[derive(Debug, PartialOrd, PartialEq)]
|
||||
#[allow(missing_docs)]
|
||||
/// General event source triggers
|
||||
pub enum CLICK_REASON
|
||||
{
|
||||
/// By mouse button.
|
||||
BY_MOUSE_CLICK,
|
||||
/// By keyboard (e.g. spacebar).
|
||||
BY_KEY_CLICK,
|
||||
/// Synthesized, by code.
|
||||
SYNTHESIZED,
|
||||
/// Icon click, e.g. arrow icon on drop-down select.
|
||||
BY_MOUSE_ON_ICON,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone)]
|
||||
#[derive(Debug, PartialOrd, PartialEq)]
|
||||
/// Edit control change trigger.
|
||||
pub enum EDIT_CHANGED_REASON
|
||||
{
|
||||
/// Single char insertion.
|
||||
BY_INS_CHAR,
|
||||
/// Character range insertion, clipboard.
|
||||
BY_INS_CHARS,
|
||||
/// Single char deletion.
|
||||
BY_DEL_CHAR,
|
||||
/// Character range (selection) deletion.
|
||||
BY_DEL_CHARS,
|
||||
/// Undo/redo.
|
||||
BY_UNDO_REDO,
|
||||
/// Single char insertion, previous character was inserted in previous position.
|
||||
CHANGE_BY_INS_CONSECUTIVE_CHAR,
|
||||
/// Single char removal, previous character was removed in previous position
|
||||
CHANGE_BY_DEL_CONSECUTIVE_CHAR,
|
||||
CHANGE_BY_CODE,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone)]
|
||||
#[derive(Debug, PartialOrd, PartialEq)]
|
||||
/// Behavior event codes.
|
||||
pub enum BEHAVIOR_EVENTS
|
||||
{
|
||||
/// click on button
|
||||
BUTTON_CLICK = 0,
|
||||
/// mouse down or key down in button
|
||||
BUTTON_PRESS,
|
||||
/// checkbox/radio/slider changed its state/value
|
||||
BUTTON_STATE_CHANGED,
|
||||
/// before text change
|
||||
EDIT_VALUE_CHANGING,
|
||||
/// after text change
|
||||
EDIT_VALUE_CHANGED,
|
||||
/// selection in `<select>` changed
|
||||
SELECT_SELECTION_CHANGED,
|
||||
/// node in select expanded/collapsed, heTarget is the node
|
||||
SELECT_STATE_CHANGED,
|
||||
|
||||
/// request to show popup just received,
|
||||
/// here DOM of popup element can be modifed.
|
||||
POPUP_REQUEST,
|
||||
|
||||
/// popup element has been measured and ready to be shown on screen,
|
||||
/// here you can use functions like `ScrollToView`.
|
||||
POPUP_READY,
|
||||
|
||||
/// popup element is closed,
|
||||
/// here DOM of popup element can be modifed again - e.g. some items can be removed to free memory.
|
||||
POPUP_DISMISSED,
|
||||
|
||||
/// menu item activated by mouse hover or by keyboard,
|
||||
MENU_ITEM_ACTIVE,
|
||||
|
||||
/// menu item click,
|
||||
/// BEHAVIOR_EVENT_PARAMS structure layout
|
||||
/// BEHAVIOR_EVENT_PARAMS.cmd - MENU_ITEM_CLICK/MENU_ITEM_ACTIVE
|
||||
/// BEHAVIOR_EVENT_PARAMS.heTarget - owner(anchor) of the menu
|
||||
/// BEHAVIOR_EVENT_PARAMS.he - the menu item, presumably `<li>` element
|
||||
/// BEHAVIOR_EVENT_PARAMS.reason - BY_MOUSE_CLICK | BY_KEY_CLICK
|
||||
MENU_ITEM_CLICK,
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/// "right-click", BEHAVIOR_EVENT_PARAMS::he is current popup menu `HELEMENT` being processed or `NULL`.
|
||||
/// application can provide its own `HELEMENT` here (if it is `NULL`) or modify current menu element.
|
||||
CONTEXT_MENU_REQUEST = 0x10,
|
||||
|
||||
|
||||
/// broadcast notification, sent to all elements of some container being shown or hidden
|
||||
VISIUAL_STATUS_CHANGED,
|
||||
/// broadcast notification, sent to all elements of some container that got new value of `:disabled` state
|
||||
DISABLED_STATUS_CHANGED,
|
||||
|
||||
/// popup is about to be closed
|
||||
POPUP_DISMISSING,
|
||||
|
||||
/// content has been changed, is posted to the element that gets content changed, reason is combination of `CONTENT_CHANGE_BITS`.
|
||||
/// `target == NULL` means the window got new document and this event is dispatched only to the window.
|
||||
CONTENT_CHANGED = 0x15,
|
||||
|
||||
|
||||
/// generic click
|
||||
CLICK = 0x16,
|
||||
/// generic change
|
||||
CHANGE = 0x17,
|
||||
|
||||
/// media changed (screen resolution, number of displays, etc.)
|
||||
MEDIA_CHANGED = 0x18,
|
||||
/// input language has changed, data is iso lang-country string
|
||||
INPUT_LANGUAGE_CHANGED = 0x19,
|
||||
/// editable content has changed
|
||||
CONTENT_MODIFIED = 0x1A,
|
||||
/// a broadcast notification being posted to all elements of some container
|
||||
/// that changes its `:read-only` state.
|
||||
READONLY_STATUS_CHANGED = 0x1B,
|
||||
/// change in `aria-live="polite|assertive"`
|
||||
ARIA_LIVE_AREA_CHANGED = 0x1C,
|
||||
|
||||
// "grey" event codes - notfications from behaviors from this SDK
|
||||
/// hyperlink click
|
||||
HYPERLINK_CLICK = 0x80,
|
||||
|
||||
PASTE_TEXT = 0x8E,
|
||||
PASTE_HTML = 0x8F,
|
||||
|
||||
/// element was collapsed, so far only `behavior:tabs` is sending these two to the panels
|
||||
ELEMENT_COLLAPSED = 0x90,
|
||||
/// element was expanded,
|
||||
ELEMENT_EXPANDED,
|
||||
|
||||
/// activate (select) child,
|
||||
/// used, for example, by `accesskeys` behaviors to send activation request, e.g. tab on `behavior:tabs`.
|
||||
ACTIVATE_CHILD,
|
||||
|
||||
/// ui state changed, observers shall update their visual states.
|
||||
/// is sent, for example, by `behavior:richtext` when caret position/selection has changed.
|
||||
UI_STATE_CHANGED = 0x95,
|
||||
|
||||
|
||||
/// `behavior:form` detected submission event. `BEHAVIOR_EVENT_PARAMS::data` field contains data to be posted.
|
||||
/// `BEHAVIOR_EVENT_PARAMS::data` is of type `T_MAP` in this case key/value pairs of data that is about
|
||||
/// to be submitted. You can modify the data or discard submission by returning true from the handler.
|
||||
FORM_SUBMIT,
|
||||
|
||||
|
||||
/// `behavior:form` detected reset event (from `button type=reset`). `BEHAVIOR_EVENT_PARAMS::data` field contains data to be reset.
|
||||
/// `BEHAVIOR_EVENT_PARAMS::data` is of type `T_MAP` in this case key/value pairs of data that is about
|
||||
/// to be rest. You can modify the data or discard reset by returning true from the handler.
|
||||
FORM_RESET,
|
||||
|
||||
|
||||
|
||||
/// document in `behavior:frame` or root document is complete.
|
||||
DOCUMENT_COMPLETE,
|
||||
|
||||
/// requests to `behavior:history` (commands)
|
||||
HISTORY_PUSH,
|
||||
HISTORY_DROP,
|
||||
HISTORY_PRIOR,
|
||||
HISTORY_NEXT,
|
||||
/// `behavior:history` notification - history stack has changed
|
||||
HISTORY_STATE_CHANGED,
|
||||
|
||||
/// close popup request,
|
||||
CLOSE_POPUP,
|
||||
/// request tooltip, `evt.source` <- is the tooltip element.
|
||||
TOOLTIP_REQUEST,
|
||||
|
||||
/// animation started (`reason=1`) or ended(`reason=0`) on the element.
|
||||
ANIMATION = 0xA0,
|
||||
|
||||
/// document created, script namespace initialized. `target` -> the document
|
||||
DOCUMENT_CREATED = 0xC0,
|
||||
/// document is about to be closed, to cancel closing do: `evt.data = sciter::Value("cancel")`;
|
||||
DOCUMENT_CLOSE_REQUEST,
|
||||
/// last notification before document removal from the DOM
|
||||
DOCUMENT_CLOSE,
|
||||
/// document has got DOM structure, styles and behaviors of DOM elements. Script loading run is complete at this moment.
|
||||
DOCUMENT_READY,
|
||||
/// document just finished parsing - has got DOM structure. This event is generated before the `DOCUMENT_READY`.
|
||||
/// Since 4.0.3.
|
||||
DOCUMENT_PARSED = 0xC4,
|
||||
|
||||
/// `<video>` "ready" notification
|
||||
VIDEO_INITIALIZED = 0xD1,
|
||||
/// `<video>` playback started notification
|
||||
VIDEO_STARTED,
|
||||
/// `<video>` playback stoped/paused notification
|
||||
VIDEO_STOPPED,
|
||||
/// `<video>` request for frame source binding,
|
||||
/// If you want to provide your own video frames source for the given target `<video>` element do the following:
|
||||
///
|
||||
/// 1. Handle and consume this `VIDEO_BIND_RQ` request
|
||||
/// 2. You will receive second `VIDEO_BIND_RQ` request/event for the same `<video>` element
|
||||
/// but this time with the `reason` field set to an instance of `sciter::video_destination` interface.
|
||||
/// 3. `add_ref()` it and store it, for example, in a worker thread producing video frames.
|
||||
/// 4. call `sciter::video_destination::start_streaming(...)` providing needed parameters
|
||||
/// call `sciter::video_destination::render_frame(...)` as soon as they are available
|
||||
/// call `sciter::video_destination::stop_streaming()` to stop the rendering (a.k.a. end of movie reached)
|
||||
VIDEO_BIND_RQ,
|
||||
|
||||
|
||||
/// `behavior:pager` starts pagination
|
||||
PAGINATION_STARTS = 0xE0,
|
||||
/// `behavior:pager` paginated page no, reason -> page no
|
||||
PAGINATION_PAGE,
|
||||
/// `behavior:pager` end pagination, reason -> total pages
|
||||
PAGINATION_ENDS,
|
||||
|
||||
/// event with custom name.
|
||||
/// Since 4.2.8.
|
||||
CUSTOM = 0xF0,
|
||||
|
||||
/// SSX, delayed mount_component
|
||||
MOUNT_COMPONENT = 0xF1,
|
||||
|
||||
/// 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,
|
||||
|
||||
}
|
||||
|
||||
|
||||
impl ::std::ops::BitOr for EVENT_GROUPS {
|
||||
type Output = EVENT_GROUPS;
|
||||
fn bitor(self, rhs: Self::Output) -> Self::Output {
|
||||
let rn = (self as UINT) | (rhs as UINT);
|
||||
unsafe { ::std::mem::transmute(rn) }
|
||||
}
|
||||
}
|
||||
388
libs/rust-sciter/src/capi/scdef.rs
Normal file
388
libs/rust-sciter/src/capi/scdef.rs
Normal file
@@ -0,0 +1,388 @@
|
||||
//! Common Sciter declarations.
|
||||
|
||||
#![allow(non_camel_case_types, non_snake_case)]
|
||||
#![allow(dead_code)]
|
||||
|
||||
use capi::sctypes::*;
|
||||
use capi::scvalue::{VALUE};
|
||||
use capi::screquest::{HREQUEST};
|
||||
use capi::scdom::{HELEMENT};
|
||||
use capi::scapi::ISciterAPI;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////
|
||||
pub enum ID2D1RenderTarget {}
|
||||
pub enum ID2D1Factory {}
|
||||
pub enum IDWriteFactory {}
|
||||
pub enum IDXGISwapChain {}
|
||||
pub enum IDXGISurface {}
|
||||
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Debug, PartialOrd, PartialEq)]
|
||||
/// `HostHandler::on_data_load()` result code.
|
||||
///
|
||||
/// This notification gives application a chance to override built-in loader and
|
||||
/// implement loading of resources in its own way (for example, images can be loaded from
|
||||
/// a database or other resource).
|
||||
pub enum LOAD_RESULT {
|
||||
/// Do the default loading if data is not set.
|
||||
LOAD_DEFAULT,
|
||||
/// Discard the request completely (data will not be loaded at the document).
|
||||
LOAD_DISCARD,
|
||||
/// Data will be delivered later by the host application.
|
||||
LOAD_DELAYED,
|
||||
/// You return this result to indicate that your (the host) application took or
|
||||
/// will take care about `HREQUEST` in your code completely.
|
||||
LOAD_MYSELF,
|
||||
}
|
||||
|
||||
/// Script runtime options.
|
||||
#[repr(C)]
|
||||
#[derive(Debug)]
|
||||
#[allow(missing_docs)]
|
||||
pub enum SCRIPT_RUNTIME_FEATURES
|
||||
{
|
||||
ALLOW_FILE_IO = 0x1,
|
||||
ALLOW_SOCKET_IO = 0x2,
|
||||
ALLOW_EVAL = 0x4,
|
||||
ALLOW_SYSINFO = 0x8,
|
||||
}
|
||||
|
||||
/// Sciter graphics rendering backend.
|
||||
#[repr(C)]
|
||||
#[derive(Debug)]
|
||||
#[derive(Copy, Clone)]
|
||||
#[allow(missing_docs)]
|
||||
pub enum GFX_LAYER
|
||||
{
|
||||
/// An auto-selected backend.
|
||||
AUTO = 0xFFFF,
|
||||
|
||||
/// Depends on OS: GDI, Cairo or CoreGraphics.
|
||||
CPU = 1,
|
||||
|
||||
/// A software rasterizer for Direct2D (Windows only).
|
||||
#[cfg(windows)]
|
||||
WARP = 2,
|
||||
|
||||
/// A hardware Direct2D mode (Windows only).
|
||||
#[cfg(windows)]
|
||||
D2D = 3,
|
||||
|
||||
/// Skia backend with CPU rasterization mode.
|
||||
SKIA_CPU = 4,
|
||||
|
||||
/// Skia backend with OpenGL rendering.
|
||||
SKIA_OPENGL = 5,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Debug, PartialOrd, PartialEq)]
|
||||
/// Various Sciter engine options (global or per-window).
|
||||
pub enum SCITER_RT_OPTIONS
|
||||
{
|
||||
/// value:TRUE - enable, value:FALSE - disable, enabled by default.
|
||||
SCITER_SMOOTH_SCROLL = 1,
|
||||
/// global; value: milliseconds, connection timeout of http client.
|
||||
SCITER_CONNECTION_TIMEOUT = 2,
|
||||
/// global; value: 0 - drop connection, 1 - use builtin dialog, 2 - accept connection silently.
|
||||
SCITER_HTTPS_ERROR = 3,
|
||||
/// value: 0 - system default, 1 - no smoothing, 2 - std smoothing, 3 - clear type.
|
||||
SCITER_FONT_SMOOTHING = 4,
|
||||
/// Windows Aero support, value:
|
||||
/// 0 - normal drawing,
|
||||
/// 1 - window has transparent background after calls `DwmExtendFrameIntoClientArea()` or `DwmEnableBlurBehindWindow()`.
|
||||
SCITER_TRANSPARENT_WINDOW = 6,
|
||||
/// global; value = LPCBYTE, json - GPU black list, see: gpu-blacklist.json resource.
|
||||
/// Note: is not used since Sciter 4.
|
||||
#[deprecated(since="4.0.1", note="This option isn't working since Sciter 4.0.1.1.")]
|
||||
SCITER_SET_GPU_BLACKLIST = 7,
|
||||
/// global or per-window; value - combination of [SCRIPT_RUNTIME_FEATURES](enum.SCRIPT_RUNTIME_FEATURES.html) flags.
|
||||
SCITER_SET_SCRIPT_RUNTIME_FEATURES = 8,
|
||||
/// global (must be called before any window creation); value - [GFX_LAYER](enum.GFX_LAYER.html).
|
||||
SCITER_SET_GFX_LAYER = 9,
|
||||
/// global or per-window; value - TRUE/FALSE
|
||||
SCITER_SET_DEBUG_MODE = 10,
|
||||
/// global; value - BOOL, TRUE - the engine will use "unisex" theme that is common for all platforms.
|
||||
/// That UX theme is not using OS primitives for rendering input elements.
|
||||
/// Use it if you want exactly the same (modulo fonts) look-n-feel on all platforms.
|
||||
SCITER_SET_UX_THEMING = 11,
|
||||
/// value - TRUE/FALSE - window uses per pixel alpha (e.g. `WS_EX_LAYERED`/`UpdateLayeredWindow()` window).
|
||||
SCITER_ALPHA_WINDOW = 12,
|
||||
/// global; value: UTF-8 encoded script source to be loaded into each view before any other script execution.
|
||||
SCITER_SET_INIT_SCRIPT = 13,
|
||||
/// per-window; value - TRUE/FALSE - window is main, will destroy all other dependent windows on close.
|
||||
SCITER_SET_MAIN_WINDOW = 14,
|
||||
/// global; value - max request length in megabytes (1024*1024 bytes).
|
||||
SCITER_SET_MAX_HTTP_DATA_LENGTH = 15,
|
||||
}
|
||||
|
||||
/// Window flags
|
||||
#[repr(C)]
|
||||
pub enum SCITER_CREATE_WINDOW_FLAGS {
|
||||
/// child window only, if this flag is set all other flags ignored.
|
||||
SW_CHILD = 1,
|
||||
/// toplevel window, has titlebar.
|
||||
SW_TITLEBAR = 1 << 1,
|
||||
/// has resizeable frame.
|
||||
SW_RESIZEABLE = 1 << 2,
|
||||
/// is tool window.
|
||||
SW_TOOL = 1 << 3,
|
||||
/// has minimize / maximize buttons.
|
||||
SW_CONTROLS = 1 << 4,
|
||||
/// glassy window - "Acrylic" on Windows and "Vibrant" on macOS.
|
||||
SW_GLASSY = 1 << 5,
|
||||
/// transparent window (e.g. `WS_EX_LAYERED` on Windows, macOS is supported too).
|
||||
SW_ALPHA = 1 << 6,
|
||||
/// main window of the app, will terminate the app on close.
|
||||
SW_MAIN = 1 << 7,
|
||||
/// the window is created as topmost window.
|
||||
SW_POPUP = 1 << 8,
|
||||
/// make this window inspector ready.
|
||||
SW_ENABLE_DEBUG = 1 << 9,
|
||||
/// it has its own script VM.
|
||||
SW_OWNS_VM = 1 << 10,
|
||||
}
|
||||
|
||||
impl Default for SCITER_CREATE_WINDOW_FLAGS {
|
||||
fn default() -> Self {
|
||||
SCITER_CREATE_WINDOW_FLAGS::SW_CHILD
|
||||
}
|
||||
}
|
||||
|
||||
/// Flags can be OR'ed as `SW_MAIN|SW_ALPHA`.
|
||||
impl ::std::ops::BitOr for SCITER_CREATE_WINDOW_FLAGS {
|
||||
type Output = SCITER_CREATE_WINDOW_FLAGS;
|
||||
fn bitor(self, rhs: Self::Output) -> Self::Output {
|
||||
let rn = (self as UINT) | (rhs as UINT);
|
||||
unsafe { ::std::mem::transmute(rn) }
|
||||
}
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Debug, PartialOrd, PartialEq)]
|
||||
pub enum SCITER_NOTIFICATION {
|
||||
SC_LOAD_DATA = 1,
|
||||
SC_DATA_LOADED = 2,
|
||||
SC_ATTACH_BEHAVIOR = 4,
|
||||
SC_ENGINE_DESTROYED = 5,
|
||||
SC_POSTED_NOTIFICATION = 6,
|
||||
SC_GRAPHICS_CRITICAL_FAILURE = 7,
|
||||
SC_KEYBOARD_REQUEST = 8,
|
||||
SC_INVALIDATE_RECT = 9,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
/// The type of a loaded resource.
|
||||
pub enum RESOURCE_TYPE {
|
||||
/// HTML document.
|
||||
HTML = 0,
|
||||
/// Image.
|
||||
IMAGE = 1,
|
||||
/// CSS.
|
||||
STYLE = 2,
|
||||
/// Mouse cursor image.
|
||||
CURSOR = 3,
|
||||
/// TIScript document.
|
||||
SCRIPT = 4,
|
||||
/// Any data.
|
||||
RAW = 5,
|
||||
/// Font.
|
||||
FONT,
|
||||
/// Sound (wav bytes).
|
||||
SOUND,
|
||||
}
|
||||
|
||||
/// The type of a loaded resource.
|
||||
pub type SCITER_RESOURCE_TYPE = RESOURCE_TYPE;
|
||||
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Debug)]
|
||||
/// Notifies that Sciter is about to download a referred resource.
|
||||
pub struct SCN_LOAD_DATA
|
||||
{
|
||||
/// `SC_LOAD_DATA` here.
|
||||
pub code: UINT,
|
||||
/// `HWINDOW` of the window this callback was attached to.
|
||||
pub hwnd: HWINDOW,
|
||||
|
||||
/// [in] Zero terminated string, fully qualified uri, for example, "http://server/folder/file.ext".
|
||||
pub uri: LPCWSTR,
|
||||
|
||||
/// [in,out] pointer to loaded data to return. If data exists in the cache then this field contain pointer to it.
|
||||
pub outData: LPCBYTE,
|
||||
/// [in,out] loaded data size to return.
|
||||
pub outDataSize: UINT,
|
||||
|
||||
/// [in] resource type category
|
||||
pub dataType: RESOURCE_TYPE,
|
||||
|
||||
/// [in] request handle that can be used with Sciter request API.
|
||||
pub request_id: HREQUEST,
|
||||
|
||||
/// [in] destination element for request.
|
||||
pub principal: HELEMENT,
|
||||
/// [in] source element for request.
|
||||
pub initiator: HELEMENT,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Debug)]
|
||||
/// This notification indicates that external data (for example, image) download process has been completed.
|
||||
pub struct SCN_DATA_LOADED
|
||||
{
|
||||
/// `SC_DATA_LOADED` here.
|
||||
pub code: UINT,
|
||||
/// `HWINDOW` of the window this callback was attached to.
|
||||
pub hwnd: HWINDOW,
|
||||
/// [in] zero terminated string, fully qualified uri, for example, "http://server/folder/file.ext".
|
||||
pub uri: LPCWSTR,
|
||||
/// [in] pointer to loaded data.
|
||||
pub data: LPCBYTE,
|
||||
/// [in] loaded data size (in bytes).
|
||||
pub dataSize: UINT,
|
||||
/// [in] resource type category
|
||||
pub dataType: RESOURCE_TYPE,
|
||||
/// Download status code:
|
||||
///
|
||||
/// * status = 0 and `dataSize == 0` - unknown error.
|
||||
/// * status = 100..505 - http response status, note: 200 - OK!
|
||||
/// * status > 12000 - wininet error code, see `ERROR_INTERNET_***` in wininet.h
|
||||
pub status: UINT,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
/// This notification is sent on parsing the document and while processing elements
|
||||
/// having non empty `behavior: ` style attribute value.
|
||||
pub struct SCN_ATTACH_BEHAVIOR
|
||||
{
|
||||
/// `SC_ATTACH_BEHAVIOR` here.
|
||||
pub code: UINT,
|
||||
/// `HWINDOW` of the window this callback was attached to.
|
||||
pub hwnd: HWINDOW,
|
||||
|
||||
/// [in] target DOM element handle
|
||||
pub element: HELEMENT,
|
||||
/// [in] zero terminated string, string appears as value of CSS `behavior: ` attribute.
|
||||
pub name: LPCSTR,
|
||||
/// [out] pointer to ElementEventProc function.
|
||||
pub elementProc: ElementEventProc,
|
||||
/// [out] tag value, passed as is into pointer ElementEventProc function.
|
||||
pub elementTag: LPVOID,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
/// This notification is issued when keyboard needs to be shown –
|
||||
/// mobiles can show soft keyboard by handling it.
|
||||
pub struct SCN_KEYBOARD_REQUEST
|
||||
{
|
||||
/// `SC_KEYBOARD_REQUEST` here.
|
||||
pub code: UINT,
|
||||
/// `HWINDOW` of the window this callback was attached to.
|
||||
pub hwnd: HWINDOW,
|
||||
|
||||
pub keyboard_mode: UINT,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
/// This notification is sent when a specific window area
|
||||
/// needs to be redrawn.
|
||||
pub struct SCN_INVALIDATE_RECT
|
||||
{
|
||||
/// `SC_INVALIDATE_RECT` here.
|
||||
pub code: UINT,
|
||||
/// `HWINDOW` of the window this callback was attached to.
|
||||
pub hwnd: HWINDOW,
|
||||
|
||||
/// Coordinates of the invalidated area.
|
||||
pub invalid_rect: RECT,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub struct SCITER_CALLBACK_NOTIFICATION
|
||||
{
|
||||
pub code: UINT,
|
||||
pub hwnd: HWINDOW,
|
||||
}
|
||||
pub type LPSCITER_CALLBACK_NOTIFICATION = *mut SCITER_CALLBACK_NOTIFICATION;
|
||||
|
||||
pub type SciterHostCallback = extern "system" fn (pns: LPSCITER_CALLBACK_NOTIFICATION, callbackParam: LPVOID) -> UINT;
|
||||
|
||||
pub type SciterWindowDelegate = extern "system" fn (hwnd: HWINDOW, msg: UINT, wParam: WPARAM, lParam: LPARAM, pParam: LPVOID, handled: * mut BOOL) -> LRESULT;
|
||||
|
||||
pub type ElementEventProc = extern "system" fn (tag: LPVOID, he: HELEMENT, evtg: UINT, prms: LPVOID) -> BOOL;
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Debug, PartialOrd, PartialEq)]
|
||||
/// Debug output categories.
|
||||
pub enum OUTPUT_SUBSYTEMS
|
||||
{
|
||||
/// html parser & runtime
|
||||
DOM = 0,
|
||||
/// csss! parser & runtime
|
||||
CSSS,
|
||||
/// css parser
|
||||
CSS,
|
||||
/// TIS parser & runtime
|
||||
TIS,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Debug, PartialOrd, PartialEq)]
|
||||
#[allow(missing_docs)]
|
||||
/// Debug output severity.
|
||||
pub enum OUTPUT_SEVERITY
|
||||
{
|
||||
INFO,
|
||||
WARNING,
|
||||
ERROR,
|
||||
}
|
||||
|
||||
pub type DEBUG_OUTPUT_PROC = extern "system" fn (param: LPVOID, subsystem: OUTPUT_SUBSYTEMS, severity: OUTPUT_SEVERITY, text: LPCWSTR, text_length: UINT);
|
||||
|
||||
pub type LPCWSTR_RECEIVER = extern "system" fn (szstr: LPCWSTR, str_length: UINT, param: LPVOID);
|
||||
pub type LPCSTR_RECEIVER = extern "system" fn (szstr: LPCSTR, str_length: UINT, param: LPVOID);
|
||||
pub type LPCBYTE_RECEIVER = extern "system" fn (szstr: LPCBYTE, str_length: UINT, param: LPVOID);
|
||||
|
||||
pub type ELEMENT_BITMAP_RECEIVER = extern "system" fn (rgba: LPCBYTE, x: INT, y: INT, width: UINT, height: UINT, param: LPVOID);
|
||||
|
||||
pub type KeyValueCallback = extern "system" fn (param: LPVOID, pkey: *const VALUE, pval: *const VALUE) -> BOOL;
|
||||
|
||||
/// Signature of Sciter extension library.
|
||||
///
|
||||
/// * `api` - Sciter API to be used inside the extension.
|
||||
/// * `exported` - extension object, it can be [asset](https://sciter.com/developers/for-native-gui-programmers/sciter-object-model/),
|
||||
/// function, or other `sciter::Value` supported type.
|
||||
///
|
||||
/// Return `true` if the `exported` object was initialized.
|
||||
///
|
||||
/// The extension should be placed in the same folder as "sciter.dll"
|
||||
/// and export a `SciterLibraryInit` function:
|
||||
///
|
||||
/// ```rust,no_run
|
||||
/// use sciter::types::{BOOL, VALUE};
|
||||
/// use sciter::Value;
|
||||
///
|
||||
/// #[no_mangle]
|
||||
/// pub extern "system"
|
||||
/// fn SciterLibraryInit(api: &'static sciter::ISciterAPI, exported: &mut VALUE) -> BOOL
|
||||
/// {
|
||||
/// sciter::set_host_api(api);
|
||||
///
|
||||
/// unimplemented!("export some extension functions");
|
||||
///
|
||||
/// true as BOOL
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// In script such extension library can be imported as:
|
||||
///
|
||||
/// ```javascript
|
||||
/// const exported = include library "library-name";
|
||||
/// ```
|
||||
///
|
||||
/// See the [blog post](https://sciter.com/include-library-name-native-extensions/) for more details.
|
||||
///
|
||||
pub type SciterLibraryInit = extern "system" fn (api: &'static ISciterAPI, exported: &mut VALUE) -> BOOL;
|
||||
233
libs/rust-sciter/src/capi/scdom.rs
Normal file
233
libs/rust-sciter/src/capi/scdom.rs
Normal file
@@ -0,0 +1,233 @@
|
||||
//! DOM access methods, C interface.
|
||||
|
||||
#![allow(non_camel_case_types, non_snake_case)]
|
||||
|
||||
use capi::sctypes::*;
|
||||
|
||||
MAKE_HANDLE!(#[doc = "Element native handle."] HELEMENT, _HELEMENT);
|
||||
MAKE_HANDLE!(#[doc = "Node native handle."] HNODE, _HNODE);
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Debug, PartialOrd, PartialEq)]
|
||||
/// Type of the result value for Sciter DOM functions.
|
||||
pub enum SCDOM_RESULT {
|
||||
/// Function completed successfully.
|
||||
OK = 0,
|
||||
/// Invalid `HWINDOW`.
|
||||
INVALID_HWND = 1,
|
||||
/// Invalid `HELEMENT`.
|
||||
INVALID_HANDLE = 2,
|
||||
/// Attempt to use `HELEMENT` which is not attached to document.
|
||||
PASSIVE_HANDLE = 3,
|
||||
/// Parameter is invalid, e.g. pointer is null.
|
||||
INVALID_PARAMETER = 4,
|
||||
/// Operation failed, e.g. invalid html passed.
|
||||
OPERATION_FAILED = 5,
|
||||
/// Function completed successfully, but no result (e.g. no such attribute at element).
|
||||
OK_NOT_HANDLED = -1,
|
||||
}
|
||||
|
||||
impl std::error::Error for SCDOM_RESULT {}
|
||||
|
||||
impl std::fmt::Display for SCDOM_RESULT {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
write!(f, "{:?}", self)
|
||||
}
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Debug, PartialOrd, PartialEq)]
|
||||
/// `dom::Element.set_html()` options.
|
||||
pub enum SET_ELEMENT_HTML
|
||||
{
|
||||
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,
|
||||
}
|
||||
|
||||
/// Bounding rectangle of the element.
|
||||
#[repr(C)]
|
||||
#[derive(Debug, PartialOrd, PartialEq)]
|
||||
pub enum ELEMENT_AREAS {
|
||||
|
||||
/// `or` this flag if you want to get Sciter window relative coordinates,
|
||||
/// otherwise it will use nearest windowed container e.g. popup window.
|
||||
ROOT_RELATIVE = 0x01,
|
||||
|
||||
/// `or` this flag if you want to get coordinates relative to the origin of element iself.
|
||||
SELF_RELATIVE = 0x02,
|
||||
|
||||
/// Position inside immediate container.
|
||||
CONTAINER_RELATIVE = 0x03,
|
||||
|
||||
/// Position relative to view - Sciter window.
|
||||
VIEW_RELATIVE = 0x04,
|
||||
|
||||
/// Content (inner) box.
|
||||
CONTENT_BOX = 0x00,
|
||||
|
||||
/// Content + paddings.
|
||||
PADDING_BOX = 0x10,
|
||||
|
||||
/// Content + paddings + border.
|
||||
BORDER_BOX = 0x20,
|
||||
|
||||
/// Content + paddings + border + margins.
|
||||
MARGIN_BOX = 0x30,
|
||||
|
||||
/// Relative to content origin - location of background image (if it set `no-repeat`).
|
||||
BACK_IMAGE_AREA = 0x40,
|
||||
|
||||
/// Relative to content origin - location of foreground image (if it set `no-repeat`).
|
||||
FORE_IMAGE_AREA = 0x50,
|
||||
|
||||
/// Scroll_area - scrollable area in content box.
|
||||
SCROLLABLE_AREA = 0x60,
|
||||
}
|
||||
|
||||
impl ELEMENT_AREAS {
|
||||
/// Size of content (i.e `(0, 0, width, height)`).
|
||||
pub fn self_content() -> u32 {
|
||||
ELEMENT_AREAS::SELF_RELATIVE as u32
|
||||
}
|
||||
|
||||
/// Size of rect (i.e `(left, top, width, height)`)
|
||||
pub fn self_rect() -> u32 {
|
||||
ELEMENT_AREAS::ROOT_RELATIVE as u32
|
||||
}
|
||||
}
|
||||
|
||||
/// Collection of states (runtime flags) of a DOM element.
|
||||
///
|
||||
/// They reflect CSS pseudo-classes that are used in selectors,
|
||||
/// e.g. `STATE_HOVER` is `:hover`, `STATE_ACTIVE` is `:active`, and so on.
|
||||
///
|
||||
/// Implements `|` and `&` bitwise operators.
|
||||
#[repr(C)]
|
||||
#[derive(Debug, PartialOrd, PartialEq)]
|
||||
pub enum ELEMENT_STATE_BITS
|
||||
{
|
||||
/// Zero state.
|
||||
STATE_NONE = 0x00000000,
|
||||
|
||||
/// Element is a link.
|
||||
///
|
||||
/// E.g. `<a href`.
|
||||
STATE_LINK = 0x00000001,
|
||||
|
||||
/// Mouse over the element at the moment.
|
||||
STATE_HOVER = 0x00000002,
|
||||
/// Element is pressed.
|
||||
///
|
||||
/// Commonly used by `<button>` or `<a>` elements.
|
||||
STATE_ACTIVE = 0x00000004,
|
||||
/// Element is focused.
|
||||
STATE_FOCUS = 0x00000008,
|
||||
|
||||
/// Element was visited.
|
||||
///
|
||||
/// For example, a link that was clicked.
|
||||
STATE_VISITED = 0x00000010,
|
||||
/// Current (hot) item.
|
||||
STATE_CURRENT = 0x00000020,
|
||||
/// Element is checked (or selected).
|
||||
STATE_CHECKED = 0x00000040,
|
||||
/// Element is disabled.
|
||||
STATE_DISABLED = 0x00000080,
|
||||
/// Readonly input element.
|
||||
STATE_READONLY = 0x00000100,
|
||||
|
||||
/// Expanded state - e.g. nodes in tree view.
|
||||
///
|
||||
/// Mutually exclusive with `STATE_COLLAPSED`.
|
||||
STATE_EXPANDED = 0x00000200,
|
||||
|
||||
/// Collapsed state - e.g. nodes in tree view.
|
||||
///
|
||||
/// Mutually exclusive with `STATE_EXPANDED`.
|
||||
STATE_COLLAPSED = 0x00000400,
|
||||
|
||||
/// One of fore/back images was requested but is not delivered.
|
||||
STATE_INCOMPLETE = 0x00000800,
|
||||
/// Is animating currently.
|
||||
STATE_ANIMATING = 0x00001000,
|
||||
/// Will accept focus.
|
||||
STATE_FOCUSABLE = 0x00002000,
|
||||
|
||||
/// Anchor in selection (used with current in selects).
|
||||
STATE_ANCHOR = 0x00004000,
|
||||
/// This is a synthetic element - i.e. don't emit it's head/tail.
|
||||
STATE_SYNTHETIC = 0x00008000,
|
||||
/// A popup element is shown for this particular element.
|
||||
STATE_OWNS_POPUP = 0x00010000,
|
||||
|
||||
/// Focus gained by tab traversal.
|
||||
STATE_TABFOCUS = 0x00020000,
|
||||
|
||||
/// Element is empty.
|
||||
///
|
||||
/// i.e. the element has no text content nor children nodes.
|
||||
///
|
||||
/// If element has a behavior attached then the behavior is responsible for the value of this flag.
|
||||
STATE_EMPTY = 0x00040000,
|
||||
|
||||
/// Busy or loading.
|
||||
STATE_BUSY = 0x00080000,
|
||||
|
||||
/// Drag over the block that can accept it (so is a current drop target).
|
||||
///
|
||||
/// Flag is set for the drop target block.
|
||||
STATE_DRAG_OVER = 0x00100000,
|
||||
/// Active drop target.
|
||||
STATE_DROP_TARGET = 0x00200000,
|
||||
/// Dragging/moving - the flag is set for the moving block.
|
||||
STATE_MOVING = 0x00400000,
|
||||
/// Dragging/copying - the flag is set for the copying block.
|
||||
STATE_COPYING = 0x00800000,
|
||||
/// Element that is a drag source.
|
||||
STATE_DRAG_SOURCE = 0x01000000,
|
||||
/// Element is drop marker.
|
||||
STATE_DROP_MARKER = 0x02000000,
|
||||
|
||||
/// Close to `STATE_ACTIVE` but has wider life span.
|
||||
///
|
||||
/// E.g. in `MOUSE_UP` it is still on;
|
||||
/// so behavior can check it in `MOUSE_UP` to discover the `CLICK` condition.
|
||||
STATE_PRESSED = 0x04000000,
|
||||
|
||||
/// This element is out of flow.
|
||||
STATE_POPUP = 0x08000000,
|
||||
|
||||
/// The element or one of its containers has `dir=ltr` declared.
|
||||
STATE_IS_LTR = 0x10000000,
|
||||
/// The element or one of its containers has `dir=rtl` declared.
|
||||
STATE_IS_RTL = 0x20000000,
|
||||
|
||||
/// Element is ready (behavior has finished initialization).
|
||||
STATE_READY = 0x40000000,
|
||||
}
|
||||
|
||||
/// Flags can be OR'ed.
|
||||
impl ::std::ops::BitOr for ELEMENT_STATE_BITS {
|
||||
type Output = ELEMENT_STATE_BITS;
|
||||
fn bitor(self, rhs: Self::Output) -> Self::Output {
|
||||
let rn = (self as UINT) | (rhs as UINT);
|
||||
unsafe { ::std::mem::transmute(rn) }
|
||||
}
|
||||
}
|
||||
|
||||
/// Flags can be AND'ed.
|
||||
impl ::std::ops::BitAnd for ELEMENT_STATE_BITS {
|
||||
type Output = ELEMENT_STATE_BITS;
|
||||
fn bitand(self, rhs: Self::Output) -> Self::Output {
|
||||
let rn = (self as UINT) & (rhs as UINT);
|
||||
unsafe { ::std::mem::transmute(rn) }
|
||||
}
|
||||
}
|
||||
|
||||
pub type SciterElementCallback = extern "system" fn (he: HELEMENT, param: LPVOID) -> BOOL;
|
||||
|
||||
pub type ELEMENT_COMPARATOR = extern "system" fn (he1: HELEMENT, he2: HELEMENT, param: LPVOID) -> INT;
|
||||
353
libs/rust-sciter/src/capi/scgraphics.rs
Normal file
353
libs/rust-sciter/src/capi/scgraphics.rs
Normal file
@@ -0,0 +1,353 @@
|
||||
//! Sciter's platform independent graphics interface.
|
||||
|
||||
#![allow(non_camel_case_types, non_snake_case)]
|
||||
#![allow(dead_code)]
|
||||
|
||||
use capi::scdom::HELEMENT;
|
||||
use capi::sctypes::{BOOL, LPCBYTE, LPCWSTR, LPVOID, UINT};
|
||||
use capi::scvalue::VALUE;
|
||||
|
||||
MAKE_HANDLE!(#[doc = "Graphics native handle."] HGFX, _HGFX);
|
||||
MAKE_HANDLE!(#[doc = "Image native handle."] HIMG, _HIMG);
|
||||
MAKE_HANDLE!(#[doc = "Path native handle."] HPATH, _HPATH);
|
||||
MAKE_HANDLE!(#[doc = "Text native handle."] HTEXT, _HTEXT);
|
||||
|
||||
pub type SC_REAL = f32;
|
||||
pub type SC_POS = SC_REAL;
|
||||
pub type SC_DIM = SC_REAL;
|
||||
pub type SC_ANGLE = SC_REAL;
|
||||
|
||||
pub type SC_COLOR = u32;
|
||||
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
/// Type of the result value for Sciter Graphics functions.
|
||||
pub enum GRAPHIN_RESULT {
|
||||
/// E.g. not enough memory.
|
||||
PANIC = -1,
|
||||
/// Success.
|
||||
OK = 0,
|
||||
/// Bad parameter.
|
||||
BAD_PARAM = 1,
|
||||
/// Operation failed, e.g. `restore()` without `save()`.
|
||||
FAILURE = 2,
|
||||
/// Platform does not support the requested feature.
|
||||
NOTSUPPORTED = 3,
|
||||
}
|
||||
|
||||
impl std::error::Error for GRAPHIN_RESULT {}
|
||||
|
||||
impl std::fmt::Display for GRAPHIN_RESULT {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
write!(f, "{:?}", self)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Path drawing mode.
|
||||
#[repr(C)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum DRAW_PATH {
|
||||
/// Draw without outline line.
|
||||
FILL_ONLY = 1,
|
||||
/// Draw outline without fill.
|
||||
STROKE_ONLY = 2,
|
||||
/// Draw outlined and filled path.
|
||||
FILL_AND_STROKE = 3,
|
||||
}
|
||||
|
||||
/// Line drawing join mode.
|
||||
#[repr(C)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum LINE_JOIN {
|
||||
/// Specifies a mitered join. This produces a sharp corner or a clipped corner,
|
||||
/// depending on whether the length of the miter exceeds the miter limit (`10.0`).
|
||||
MITER = 0,
|
||||
/// Specifies a circular join. This produces a smooth, circular arc between the lines.
|
||||
ROUND = 1,
|
||||
/// Specifies a beveled join. This produces a diagonal corner.
|
||||
BEVEL = 2,
|
||||
/// Specifies a mitered join. This produces a sharp corner or a beveled corner,
|
||||
/// depending on whether the length of the miter exceeds the miter limit (`10.0`).
|
||||
MITER_OR_BEVEL = 3,
|
||||
}
|
||||
|
||||
/// Line drawing cap mode.
|
||||
#[repr(C)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum LINE_CAP {
|
||||
/// The ends of lines are squared off at the endpoints.
|
||||
BUTT = 0,
|
||||
/// The ends of lines are squared off by adding a box with an equal width
|
||||
/// and half the height of the line's thickness.
|
||||
SQUARE = 1,
|
||||
/// The ends of lines are rounded.
|
||||
ROUND = 2,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum IMAGE_ENCODING {
|
||||
RAW, // [a,b,g,r,a,b,g,r,...] vector
|
||||
PNG,
|
||||
JPG,
|
||||
WEBP,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Debug)]
|
||||
pub struct SC_COLOR_STOP {
|
||||
pub color: SC_COLOR,
|
||||
pub offset: f32,
|
||||
}
|
||||
|
||||
|
||||
#[repr(C)]
|
||||
#[allow(missing_docs)]
|
||||
pub struct SciterGraphicsAPI {
|
||||
// image primitives
|
||||
pub imageCreate: extern "system" fn(poutImg: &mut HIMG, width: UINT, height: UINT, withAlpha: BOOL) -> GRAPHIN_RESULT,
|
||||
|
||||
// construct image from B[n+0],G[n+1],R[n+2],A[n+3] data.
|
||||
// Size of pixmap data is pixmapWidth*pixmapHeight*4
|
||||
pub imageCreateFromPixmap:
|
||||
extern "system" fn(poutImg: &mut HIMG, pixmapWidth: UINT, pixmapHeight: UINT, withAlpha: BOOL, pixmap: LPCBYTE) -> GRAPHIN_RESULT,
|
||||
|
||||
pub imageAddRef: extern "system" fn(himg: HIMG) -> GRAPHIN_RESULT,
|
||||
|
||||
pub imageRelease: extern "system" fn(himg: HIMG) -> GRAPHIN_RESULT,
|
||||
|
||||
pub imageGetInfo: extern "system" fn(himg: HIMG, width: &mut UINT, height: &mut UINT, usesAlpha: &mut BOOL) -> GRAPHIN_RESULT,
|
||||
|
||||
pub imageClear: extern "system" fn(himg: HIMG, byColor: SC_COLOR) -> GRAPHIN_RESULT,
|
||||
|
||||
pub imageLoad: extern "system" fn(bytes: LPCBYTE, num_bytes: UINT, pout_img: &mut HIMG) -> GRAPHIN_RESULT, // load png/jpeg/etc. image from stream of bytes
|
||||
|
||||
pub imageSave: extern "system" fn(himg: HIMG, pfn: ImageWriteFunction, prm: LPVOID, encoding: IMAGE_ENCODING, quality: UINT) -> GRAPHIN_RESULT,
|
||||
|
||||
// SECTION: graphics primitives and drawing operations
|
||||
|
||||
// create SC_COLOR value
|
||||
pub RGBA: extern "system" fn(red: UINT, green: UINT, blue: UINT, alpha: UINT) -> SC_COLOR,
|
||||
|
||||
pub gCreate: extern "system" fn(img: HIMG, pout_gfx: &mut HGFX) -> GRAPHIN_RESULT,
|
||||
|
||||
pub gAddRef: extern "system" fn(gfx: HGFX) -> GRAPHIN_RESULT,
|
||||
|
||||
pub gRelease: extern "system" fn(gfx: HGFX) -> GRAPHIN_RESULT,
|
||||
|
||||
// Draws line from x1,y1 to x2,y2 using current lineColor and lineGradient.
|
||||
pub gLine: extern "system" fn(hgfx: HGFX, x1: SC_POS, y1: SC_POS, x2: SC_POS, y2: SC_POS) -> GRAPHIN_RESULT,
|
||||
|
||||
// Draws rectangle using current lineColor/lineGradient and fillColor/fillGradient with (optional) rounded corners.
|
||||
pub gRectangle: extern "system" fn(hgfx: HGFX, x1: SC_POS, y1: SC_POS, x2: SC_POS, y2: SC_POS) -> GRAPHIN_RESULT,
|
||||
|
||||
// Draws rounded rectangle using current lineColor/lineGradient and fillColor/fillGradient with (optional) rounded corners.
|
||||
pub gRoundedRectangle: extern "system" fn(
|
||||
hgfx: HGFX,
|
||||
x1: SC_POS,
|
||||
y1: SC_POS,
|
||||
x2: SC_POS,
|
||||
y2: SC_POS,
|
||||
radii8: *const SC_DIM,
|
||||
) -> GRAPHIN_RESULT,
|
||||
|
||||
// Draws circle or ellipse using current lineColor/lineGradient and fillColor/fillGradient.
|
||||
pub gEllipse: extern "system" fn(hgfx: HGFX, x: SC_POS, y: SC_POS, rx: SC_DIM, ry: SC_DIM) -> GRAPHIN_RESULT,
|
||||
|
||||
// Draws closed arc using current lineColor/lineGradient and fillColor/fillGradient.
|
||||
pub gArc:
|
||||
extern "system" fn(hgfx: HGFX, x: SC_POS, y: SC_POS, rx: SC_POS, ry: SC_POS, start: SC_ANGLE, sweep: SC_ANGLE) -> GRAPHIN_RESULT,
|
||||
|
||||
// Draws star.
|
||||
pub gStar: extern "system" fn(hgfx: HGFX, x: SC_POS, y: SC_POS, r1: SC_DIM, r2: SC_DIM, start: SC_ANGLE, rays: UINT) -> GRAPHIN_RESULT,
|
||||
|
||||
// Closed polygon.
|
||||
pub gPolygon: extern "system" fn(hgfx: HGFX, xy: *const SC_POS, num_points: UINT) -> GRAPHIN_RESULT,
|
||||
|
||||
// Polyline.
|
||||
pub gPolyline: extern "system" fn(hgfx: HGFX, xy: *const SC_POS, num_points: UINT) -> GRAPHIN_RESULT,
|
||||
|
||||
// SECTION: Path operations
|
||||
pub pathCreate: extern "system" fn(path: &mut HPATH) -> GRAPHIN_RESULT,
|
||||
|
||||
pub pathAddRef: extern "system" fn(path: HPATH) -> GRAPHIN_RESULT,
|
||||
|
||||
pub pathRelease: extern "system" fn(path: HPATH) -> GRAPHIN_RESULT,
|
||||
|
||||
pub pathMoveTo: extern "system" fn(path: HPATH, x: SC_POS, y: SC_POS, relative: BOOL) -> GRAPHIN_RESULT,
|
||||
|
||||
pub pathLineTo: extern "system" fn(path: HPATH, x: SC_POS, y: SC_POS, relative: BOOL) -> GRAPHIN_RESULT,
|
||||
|
||||
pub pathArcTo: extern "system" fn(
|
||||
path: HPATH,
|
||||
x: SC_POS,
|
||||
y: SC_POS,
|
||||
angle: SC_ANGLE,
|
||||
rx: SC_DIM,
|
||||
ry: SC_DIM,
|
||||
is_large_arc: BOOL,
|
||||
clockwise: BOOL,
|
||||
relative: BOOL,
|
||||
) -> GRAPHIN_RESULT,
|
||||
|
||||
pub pathQuadraticCurveTo: extern "system" fn(path: HPATH, xc: SC_POS, yc: SC_POS, x: SC_POS, y: SC_POS, relative: BOOL) -> GRAPHIN_RESULT,
|
||||
|
||||
pub pathBezierCurveTo:
|
||||
extern "system" fn(path: HPATH, xc1: SC_POS, yc1: SC_POS, xc2: SC_POS, yc2: SC_POS, x: SC_POS, y: SC_POS, relative: BOOL)
|
||||
-> GRAPHIN_RESULT,
|
||||
|
||||
pub pathClosePath: extern "system" fn(path: HPATH) -> GRAPHIN_RESULT,
|
||||
|
||||
pub gDrawPath: extern "system" fn(hgfx: HGFX, path: HPATH, dpm: DRAW_PATH) -> GRAPHIN_RESULT,
|
||||
|
||||
// end of path opearations
|
||||
|
||||
// SECTION: affine tranformations:
|
||||
pub gRotate: extern "system" fn(hgfx: HGFX, radians: SC_ANGLE, cx: Option<&SC_POS>, cy: Option<&SC_POS>) -> GRAPHIN_RESULT,
|
||||
|
||||
pub gTranslate: extern "system" fn(hgfx: HGFX, cx: SC_POS, cy: SC_POS) -> GRAPHIN_RESULT,
|
||||
|
||||
pub gScale: extern "system" fn(hgfx: HGFX, x: SC_DIM, y: SC_DIM) -> GRAPHIN_RESULT,
|
||||
|
||||
pub gSkew: extern "system" fn(hgfx: HGFX, dx: SC_DIM, dy: SC_DIM) -> GRAPHIN_RESULT,
|
||||
|
||||
// all above in one shot
|
||||
pub gTransform:
|
||||
extern "system" fn(hgfx: HGFX, m11: SC_POS, m12: SC_POS, m21: SC_POS, m22: SC_POS, dx: SC_POS, dy: SC_POS) -> GRAPHIN_RESULT,
|
||||
|
||||
// end of affine tranformations.
|
||||
|
||||
// SECTION: state save/restore
|
||||
pub gStateSave: extern "system" fn(hgfx: HGFX) -> GRAPHIN_RESULT,
|
||||
|
||||
pub gStateRestore: extern "system" fn(hgfx: HGFX) -> GRAPHIN_RESULT,
|
||||
|
||||
// end of state save/restore
|
||||
|
||||
// SECTION: drawing attributes
|
||||
|
||||
// set line width for subsequent drawings.
|
||||
pub gLineWidth: extern "system" fn(hgfx: HGFX, width: SC_DIM) -> GRAPHIN_RESULT,
|
||||
|
||||
pub gLineJoin: extern "system" fn(hgfx: HGFX, join_type: LINE_JOIN) -> GRAPHIN_RESULT,
|
||||
|
||||
pub gLineCap: extern "system" fn(hgfx: HGFX, cap_type: LINE_CAP) -> GRAPHIN_RESULT,
|
||||
|
||||
// SC_COLOR for solid lines/strokes
|
||||
pub gLineColor: extern "system" fn(hgfx: HGFX, color: SC_COLOR) -> GRAPHIN_RESULT,
|
||||
|
||||
// SC_COLOR for solid fills
|
||||
pub gFillColor: extern "system" fn(hgfx: HGFX, color: SC_COLOR) -> GRAPHIN_RESULT,
|
||||
|
||||
// setup parameters of linear gradient of lines.
|
||||
pub gLineGradientLinear:
|
||||
extern "system" fn(hgfx: HGFX, x1: SC_POS, y1: SC_POS, x2: SC_POS, y2: SC_POS, stops: *const SC_COLOR_STOP, nstops: UINT)
|
||||
-> GRAPHIN_RESULT,
|
||||
|
||||
// setup parameters of linear gradient of fills.
|
||||
pub gFillGradientLinear:
|
||||
extern "system" fn(hgfx: HGFX, x1: SC_POS, y1: SC_POS, x2: SC_POS, y2: SC_POS, stops: *const SC_COLOR_STOP, nstops: UINT)
|
||||
-> GRAPHIN_RESULT,
|
||||
|
||||
// setup parameters of line gradient radial fills.
|
||||
pub gLineGradientRadial:
|
||||
extern "system" fn(hgfx: HGFX, x: SC_POS, y: SC_POS, rx: SC_DIM, ry: SC_DIM, stops: *const SC_COLOR_STOP, nstops: UINT)
|
||||
-> GRAPHIN_RESULT,
|
||||
|
||||
// setup parameters of gradient radial fills.
|
||||
pub gFillGradientRadial:
|
||||
extern "system" fn(hgfx: HGFX, x: SC_POS, y: SC_POS, rx: SC_DIM, ry: SC_DIM, stops: *const SC_COLOR_STOP, nstops: UINT)
|
||||
-> GRAPHIN_RESULT,
|
||||
|
||||
pub gFillMode: extern "system" fn(hgfx: HGFX, even_odd: BOOL) -> GRAPHIN_RESULT,
|
||||
|
||||
// SECTION: text
|
||||
|
||||
// create text layout for host element
|
||||
pub textCreateForElement: extern "system" fn(ptext: &mut HTEXT, text: LPCWSTR, textLength: UINT, he: HELEMENT, classNameOrNull: LPCWSTR) -> GRAPHIN_RESULT,
|
||||
|
||||
// create text layout using explicit style declaration
|
||||
pub textCreateForElementAndStyle:
|
||||
extern "system" fn(ptext: &mut HTEXT, text: LPCWSTR, textLength: UINT, he: HELEMENT, style: LPCWSTR, styleLength: UINT) -> GRAPHIN_RESULT,
|
||||
|
||||
// since 4.1.10
|
||||
pub textAddRef: extern "system" fn(text: HTEXT) -> GRAPHIN_RESULT,
|
||||
|
||||
// since 4.1.10
|
||||
pub textRelease: extern "system" fn(text: HTEXT) -> GRAPHIN_RESULT,
|
||||
|
||||
pub textGetMetrics: extern "system" fn(
|
||||
text: HTEXT,
|
||||
minWidth: &mut SC_DIM,
|
||||
maxWidth: &mut SC_DIM,
|
||||
height: &mut SC_DIM,
|
||||
ascent: &mut SC_DIM,
|
||||
descent: &mut SC_DIM,
|
||||
nLines: &mut UINT,
|
||||
) -> GRAPHIN_RESULT,
|
||||
|
||||
pub textSetBox: extern "system" fn(text: HTEXT, width: SC_DIM, height: SC_DIM) -> GRAPHIN_RESULT,
|
||||
|
||||
// draw text with position (1..9 on MUMPAD) at px,py
|
||||
// Ex: gDrawText(100,100,5) will draw text box with its center at 100,100 px
|
||||
pub gDrawText: extern "system" fn(hgfx: HGFX, text: HTEXT, px: SC_POS, py: SC_POS, position: UINT) -> GRAPHIN_RESULT,
|
||||
|
||||
// SECTION: image rendering
|
||||
|
||||
// draws img onto the graphics surface with current transformation applied (scale, rotation).
|
||||
#[allow(clippy::type_complexity)]
|
||||
pub gDrawImage: extern "system" fn(
|
||||
hgfx: HGFX,
|
||||
himg: HIMG,
|
||||
x: SC_POS,
|
||||
y: SC_POS,
|
||||
w: Option<&SC_DIM>,
|
||||
h: Option<&SC_DIM>,
|
||||
ix: Option<&UINT>,
|
||||
iy: Option<&UINT>,
|
||||
iw: Option<&UINT>,
|
||||
ih: Option<&UINT>,
|
||||
opacity: Option<&f32>,
|
||||
) -> GRAPHIN_RESULT,
|
||||
|
||||
// SECTION: coordinate space
|
||||
pub gWorldToScreen: extern "system" fn(hgfx: HGFX, inout_x: &mut SC_POS, inout_y: &mut SC_POS) -> GRAPHIN_RESULT,
|
||||
|
||||
pub gScreenToWorld: extern "system" fn(hgfx: HGFX, inout_x: &mut SC_POS, inout_y: &mut SC_POS) -> GRAPHIN_RESULT,
|
||||
|
||||
// SECTION: clipping
|
||||
pub gPushClipBox: extern "system" fn(hgfx: HGFX, x1: SC_POS, y1: SC_POS, x2: SC_POS, y2: SC_POS, opacity: f32) -> GRAPHIN_RESULT,
|
||||
|
||||
pub gPushClipPath: extern "system" fn(hgfx: HGFX, hpath: HPATH, opacity: f32) -> GRAPHIN_RESULT,
|
||||
|
||||
// pop clip layer previously set by gPushClipBox or gPushClipPath
|
||||
pub gPopClip: extern "system" fn(hgfx: HGFX) -> GRAPHIN_RESULT,
|
||||
|
||||
// image painter
|
||||
pub imagePaint: extern "system" fn(himg: HIMG, pPainter: ImagePaintFunction, prm: LPVOID) -> GRAPHIN_RESULT, // paint on image using graphics
|
||||
|
||||
// VALUE interface
|
||||
pub vWrapGfx: extern "system" fn(hgfx: HGFX, toValue: *mut VALUE) -> GRAPHIN_RESULT,
|
||||
|
||||
pub vWrapImage: extern "system" fn(himg: HIMG, toValue: *mut VALUE) -> GRAPHIN_RESULT,
|
||||
|
||||
pub vWrapPath: extern "system" fn(hpath: HPATH, toValue: *mut VALUE) -> GRAPHIN_RESULT,
|
||||
|
||||
pub vWrapText: extern "system" fn(htext: HTEXT, toValue: *mut VALUE) -> GRAPHIN_RESULT,
|
||||
|
||||
pub vUnWrapGfx: extern "system" fn(fromValue: *const VALUE, phgfx: &mut HGFX) -> GRAPHIN_RESULT,
|
||||
|
||||
pub vUnWrapImage: extern "system" fn(fromValue: *const VALUE, phimg: &mut HIMG) -> GRAPHIN_RESULT,
|
||||
|
||||
pub vUnWrapPath: extern "system" fn(fromValue: *const VALUE, phpath: &mut HPATH) -> GRAPHIN_RESULT,
|
||||
|
||||
pub vUnWrapText: extern "system" fn(fromValue: *const VALUE, phtext: &mut HTEXT) -> GRAPHIN_RESULT,
|
||||
|
||||
// since 4.4.3.20
|
||||
pub gFlush: extern "system" fn(hgfx: HGFX) -> GRAPHIN_RESULT,
|
||||
}
|
||||
|
||||
pub type ImageWriteFunction = extern "system" fn(prm: LPVOID, data: LPCBYTE, data_length: UINT);
|
||||
pub type ImagePaintFunction = extern "system" fn(prm: LPVOID, hgfx: HGFX, width: UINT, height: UINT);
|
||||
118
libs/rust-sciter/src/capi/schandler.rs
Normal file
118
libs/rust-sciter/src/capi/schandler.rs
Normal file
@@ -0,0 +1,118 @@
|
||||
//! Native handler wrappers.
|
||||
|
||||
#![allow(dead_code)]
|
||||
|
||||
use capi::sctypes::{LPCVOID, LPVOID};
|
||||
|
||||
type Opaque = LPCVOID;
|
||||
|
||||
|
||||
/// Native wrapper for handlers which can be passed to foreign functions.
|
||||
#[repr(C)]
|
||||
#[derive(Debug)]
|
||||
pub struct NativeHandler {
|
||||
// pointer to handler
|
||||
handler: Opaque,
|
||||
|
||||
// pointer to handler destructor
|
||||
dtor: fn(param: Opaque),
|
||||
}
|
||||
|
||||
impl Drop for NativeHandler {
|
||||
fn drop(&mut self) {
|
||||
if !self.handler.is_null() {
|
||||
(self.dtor)(self.handler);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for NativeHandler {
|
||||
fn default() -> Self {
|
||||
NativeHandler { handler: ::std::ptr::null(), dtor: NativeHandler::drop_it::<i32> }
|
||||
}
|
||||
}
|
||||
|
||||
impl NativeHandler {
|
||||
|
||||
/// Construct boxed wrapper from handler object.
|
||||
pub fn from<T>(handler: T) -> NativeHandler {
|
||||
let boxed = Box::new(handler);
|
||||
let ptr = Box::into_raw(boxed);
|
||||
let dtor = NativeHandler::drop_it::<T>;
|
||||
return NativeHandler { handler: ptr as Opaque, dtor: dtor };
|
||||
}
|
||||
|
||||
/// Return a native pointer to handler wrapper.
|
||||
pub fn as_ptr(&self) -> LPCVOID {
|
||||
self.handler as LPCVOID
|
||||
}
|
||||
|
||||
/// Return a native pointer to handler wrapper.
|
||||
pub fn as_mut_ptr(&self) -> LPVOID {
|
||||
self.handler as LPVOID
|
||||
}
|
||||
|
||||
/// Access handler by reference.
|
||||
pub fn as_ref<T>(&self) -> &T {
|
||||
let pobj = self.handler as *const T;
|
||||
let boxed = unsafe { &*pobj };
|
||||
return boxed;
|
||||
}
|
||||
|
||||
/// Access handler by mutable reference.
|
||||
pub fn as_mut<T>(&mut self) -> &mut T {
|
||||
let pobj = self.handler as *mut T;
|
||||
let boxed = unsafe { &mut *pobj };
|
||||
return boxed;
|
||||
}
|
||||
|
||||
#[allow(clippy::mut_from_ref)]
|
||||
pub fn get_data<T>(ptr: &LPVOID) -> &mut T {
|
||||
assert!(!ptr.is_null());
|
||||
let obj = *ptr as *mut T;
|
||||
unsafe { &mut *obj}
|
||||
}
|
||||
|
||||
// Call destructor of handler.
|
||||
fn drop_it<T>(param: Opaque) {
|
||||
// reconstruct pointer to Box
|
||||
let pobj = param as *mut T;
|
||||
if !pobj.is_null() {
|
||||
// and drop it
|
||||
unsafe { Box::from_raw(pobj) };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::NativeHandler;
|
||||
|
||||
struct Handler {
|
||||
pub i: i32,
|
||||
}
|
||||
|
||||
impl Drop for Handler {
|
||||
fn drop(&mut self) {
|
||||
println!("Handler::drop");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#[test]
|
||||
fn test1() {
|
||||
{
|
||||
println!("\ncreate");
|
||||
let h = Handler { i: 7 };
|
||||
let p = NativeHandler::from(h);
|
||||
|
||||
println!("handler i {:?}", p.as_ref::<Handler>().i);
|
||||
println!("quit");
|
||||
}
|
||||
println!("done.");
|
||||
|
||||
// assert!(false);
|
||||
}
|
||||
|
||||
}
|
||||
462
libs/rust-sciter/src/capi/scmsg.rs
Normal file
462
libs/rust-sciter/src/capi/scmsg.rs
Normal file
@@ -0,0 +1,462 @@
|
||||
//! Sciter.Lite interface.
|
||||
|
||||
#![allow(non_camel_case_types, non_snake_case)]
|
||||
#![allow(dead_code)]
|
||||
|
||||
use capi::sctypes::*;
|
||||
use capi::scdef::{GFX_LAYER, ELEMENT_BITMAP_RECEIVER};
|
||||
use capi::scdom::HELEMENT;
|
||||
use capi::scbehavior::{MOUSE_BUTTONS, MOUSE_EVENTS, KEY_EVENTS};
|
||||
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone)]
|
||||
#[derive(Debug, PartialOrd, PartialEq)]
|
||||
pub enum SCITER_X_MSG_CODE
|
||||
{
|
||||
SXM_CREATE = 0,
|
||||
SXM_DESTROY = 1,
|
||||
SXM_SIZE = 2,
|
||||
SXM_PAINT = 3,
|
||||
SXM_RESOLUTION = 4,
|
||||
SXM_HEARTBIT = 5,
|
||||
SXM_MOUSE = 6,
|
||||
SXM_KEY = 7,
|
||||
SXM_FOCUS = 8,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Debug)]
|
||||
/// Common header of message structures passed to `SciterProcX`.
|
||||
pub struct SCITER_X_MSG
|
||||
{
|
||||
pub msg: SCITER_X_MSG_CODE,
|
||||
}
|
||||
|
||||
impl From<SCITER_X_MSG_CODE> for SCITER_X_MSG {
|
||||
fn from(code: SCITER_X_MSG_CODE) -> Self {
|
||||
Self { msg: code }
|
||||
}
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Debug)]
|
||||
/// Message to create the specific Sciter backend.
|
||||
pub struct SCITER_X_MSG_CREATE
|
||||
{
|
||||
pub header: SCITER_X_MSG,
|
||||
pub backend: GFX_LAYER,
|
||||
pub transparent: BOOL,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Debug)]
|
||||
/// Message to destroy the current Sciter backend.
|
||||
pub struct SCITER_X_MSG_DESTROY
|
||||
{
|
||||
pub header: SCITER_X_MSG,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Debug)]
|
||||
/// Message to notify Sciter about view resize.
|
||||
pub struct SCITER_X_MSG_SIZE
|
||||
{
|
||||
pub header: SCITER_X_MSG,
|
||||
pub width: UINT,
|
||||
pub height: UINT,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Debug)]
|
||||
/// Message to notify Sciter about screen resolution change.
|
||||
pub struct SCITER_X_MSG_RESOLUTION
|
||||
{
|
||||
pub header: SCITER_X_MSG,
|
||||
|
||||
/// Pixels per inch.
|
||||
pub ppi: UINT,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Debug)]
|
||||
/// Message to notify Sciter about mouse input.
|
||||
pub struct SCITER_X_MSG_MOUSE
|
||||
{
|
||||
pub header: SCITER_X_MSG,
|
||||
|
||||
pub event: MOUSE_EVENTS,
|
||||
pub button: MOUSE_BUTTONS,
|
||||
pub modifiers: UINT,
|
||||
pub pos: POINT,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Debug)]
|
||||
/// Message to notify Sciter about keyboard input.
|
||||
pub struct SCITER_X_MSG_KEY
|
||||
{
|
||||
pub header: SCITER_X_MSG,
|
||||
|
||||
pub event: KEY_EVENTS,
|
||||
pub code: UINT,
|
||||
pub modifiers: UINT,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Debug)]
|
||||
/// Message to notify Sciter about window focus change.
|
||||
pub struct SCITER_X_MSG_FOCUS
|
||||
{
|
||||
pub header: SCITER_X_MSG,
|
||||
|
||||
pub enter: BOOL,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Debug)]
|
||||
/// Give Sciter a chance to process animations, timers and other timed things.
|
||||
pub struct SCITER_X_MSG_HEARTBIT
|
||||
{
|
||||
pub header: SCITER_X_MSG,
|
||||
|
||||
/// Absolute time in milliseconds.
|
||||
pub time: UINT,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone)]
|
||||
#[derive(Debug, PartialOrd, PartialEq)]
|
||||
/// `SCITER_X_MSG_PAINT` rendering targets.
|
||||
pub enum SCITER_PAINT_TARGET_TYPE
|
||||
{
|
||||
/// Default target - OpenGL window surface.
|
||||
SPT_DEFAULT = 0,
|
||||
|
||||
/// Bitmap target.
|
||||
SPT_RECEIVER = 1,
|
||||
|
||||
/// `IDXGISurface` target (since 4.4.3.27).
|
||||
SPT_SURFACE = 2,
|
||||
}
|
||||
|
||||
/// Message to paint view to the provided target (HDC or callback).
|
||||
#[repr(C)]
|
||||
pub struct SCITER_X_MSG_PAINT
|
||||
{
|
||||
pub header: SCITER_X_MSG,
|
||||
pub element: HELEMENT,
|
||||
pub isFore: BOOL,
|
||||
pub targetType: SCITER_PAINT_TARGET_TYPE,
|
||||
|
||||
// union {
|
||||
// HDC or LPVOID
|
||||
pub context: LPVOID,
|
||||
pub callback: Option<ELEMENT_BITMAP_RECEIVER>,
|
||||
// }
|
||||
}
|
||||
|
||||
/// Sciter.Lite key codes.
|
||||
///
|
||||
/// The table matches the [GLFW keyboard keys](https://www.glfw.org/docs/3.3/group__keys.html).
|
||||
pub mod key_codes
|
||||
{
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone)]
|
||||
#[derive(Debug, PartialOrd, PartialEq)]
|
||||
/// The same keys, but wrapped as a enum.
|
||||
pub enum KEYBOARD_CODES {
|
||||
KB_SPACE = 32,
|
||||
KB_APOSTROPHE = 39, /* ' */
|
||||
KB_COMMA = 44, /* , */
|
||||
// KB_QUOTE = KB_COMMA,
|
||||
KB_MINUS = 45, /* - */
|
||||
KB_PERIOD = 46, /* . */
|
||||
KB_SLASH = 47, /* / */
|
||||
KB_0 = 48,
|
||||
KB_1 = 49,
|
||||
KB_2 = 50,
|
||||
KB_3 = 51,
|
||||
KB_4 = 52,
|
||||
KB_5 = 53,
|
||||
KB_6 = 54,
|
||||
KB_7 = 55,
|
||||
KB_8 = 56,
|
||||
KB_9 = 57,
|
||||
KB_SEMICOLON = 59, /* ; */
|
||||
KB_EQUAL = 61, /* = */
|
||||
KB_A = 65,
|
||||
KB_B = 66,
|
||||
KB_C = 67,
|
||||
KB_D = 68,
|
||||
KB_E = 69,
|
||||
KB_F = 70,
|
||||
KB_G = 71,
|
||||
KB_H = 72,
|
||||
KB_I = 73,
|
||||
KB_J = 74,
|
||||
KB_K = 75,
|
||||
KB_L = 76,
|
||||
KB_M = 77,
|
||||
KB_N = 78,
|
||||
KB_O = 79,
|
||||
KB_P = 80,
|
||||
KB_Q = 81,
|
||||
KB_R = 82,
|
||||
KB_S = 83,
|
||||
KB_T = 84,
|
||||
KB_U = 85,
|
||||
KB_V = 86,
|
||||
KB_W = 87,
|
||||
KB_X = 88,
|
||||
KB_Y = 89,
|
||||
KB_Z = 90,
|
||||
KB_LEFT_BRACKET = 91, /* [ */
|
||||
// KB_LEFTBRACKET = KB_LEFT_BRACKET,
|
||||
KB_BACKSLASH = 92, /* \ */
|
||||
KB_RIGHT_BRACKET = 93, /* ] */
|
||||
// KB_RIGHTBRACKET = KB_RIGHT_BRACKET,
|
||||
KB_GRAVE_ACCENT = 96, /* ` */
|
||||
KB_WORLD_1 = 161, /* non-US #1 */
|
||||
// KB_DOT = KB_WORLD_1,
|
||||
KB_WORLD_2 = 162, /* non-US #2 */
|
||||
|
||||
/* Function keys */
|
||||
KB_ESCAPE = 256,
|
||||
KB_ENTER = 257,
|
||||
// KB_RETURN = KB_ENTER,
|
||||
KB_TAB = 258,
|
||||
KB_BACKSPACE = 259,
|
||||
// KB_BACK = KB_BACKSPACE,
|
||||
KB_INSERT = 260,
|
||||
KB_DELETE = 261,
|
||||
KB_RIGHT = 262,
|
||||
KB_LEFT = 263,
|
||||
KB_DOWN = 264,
|
||||
KB_UP = 265,
|
||||
KB_PAGE_UP = 266,
|
||||
// KB_PRIOR = KB_PAGE_UP,
|
||||
KB_PAGE_DOWN = 267,
|
||||
// KB_NEXT = KB_PAGE_DOWN,
|
||||
KB_HOME = 268,
|
||||
KB_END = 269,
|
||||
KB_CAPS_LOCK = 280,
|
||||
// KB_CAPITAL = KB_CAPS_LOCK,
|
||||
KB_SCROLL_LOCK = 281,
|
||||
// KB_SCROLL = KB_SCROLL_LOCK,
|
||||
KB_NUM_LOCK = 282,
|
||||
// KB_NUMLOCK = KB_NUM_LOCK,
|
||||
KB_PRINT_SCREEN = 283,
|
||||
KB_PAUSE = 284,
|
||||
KB_F1 = 290,
|
||||
KB_F2 = 291,
|
||||
KB_F3 = 292,
|
||||
KB_F4 = 293,
|
||||
KB_F5 = 294,
|
||||
KB_F6 = 295,
|
||||
KB_F7 = 296,
|
||||
KB_F8 = 297,
|
||||
KB_F9 = 298,
|
||||
KB_F10 = 299,
|
||||
KB_F11 = 300,
|
||||
KB_F12 = 301,
|
||||
KB_F13 = 302,
|
||||
KB_F14 = 303,
|
||||
KB_F15 = 304,
|
||||
KB_F16 = 305,
|
||||
KB_F17 = 306,
|
||||
KB_F18 = 307,
|
||||
KB_F19 = 308,
|
||||
KB_F20 = 309,
|
||||
KB_F21 = 310,
|
||||
KB_F22 = 311,
|
||||
KB_F23 = 312,
|
||||
KB_F24 = 313,
|
||||
KB_F25 = 314,
|
||||
KB_NUMPAD0 = 320,
|
||||
KB_NUMPAD1 = 321,
|
||||
KB_NUMPAD2 = 322,
|
||||
KB_NUMPAD3 = 323,
|
||||
KB_NUMPAD4 = 324,
|
||||
KB_NUMPAD5 = 325,
|
||||
KB_NUMPAD6 = 326,
|
||||
KB_NUMPAD7 = 327,
|
||||
KB_NUMPAD8 = 328,
|
||||
KB_NUMPAD9 = 329,
|
||||
KB_NUMPAD_DECIMAL = 330,
|
||||
// KB_DECIMAL = KB_NUMPAD_DECIMAL, KB_SEPARATOR = KB_DECIMAL,
|
||||
KB_NUMPAD_DIVIDE = 331,
|
||||
// KB_DIVIDE = KB_NUMPAD_DIVIDE,
|
||||
KB_NUMPAD_MULTIPLY = 332,
|
||||
// KB_MULTIPLY = KB_NUMPAD_MULTIPLY,
|
||||
KB_NUMPAD_SUBTRACT = 333,
|
||||
// KB_SUBTRACT = KB_NUMPAD_SUBTRACT,
|
||||
KB_NUMPAD_ADD = 334,
|
||||
// KB_ADD = KB_NUMPAD_ADD, KB_PLUS = KB_ADD,
|
||||
KB_NUMPAD_ENTER = 335,
|
||||
KB_NUMPAD_EQUAL = 336,
|
||||
KB_LEFT_SHIFT = 340,
|
||||
// KB_SHIFT = KB_LEFT_SHIFT,
|
||||
KB_LEFT_CONTROL = 341,
|
||||
// KB_CONTROL = KB_LEFT_CONTROL, KB_SHORTCUT = KB_CONTROL,
|
||||
KB_LEFT_ALT = 342,
|
||||
KB_LEFT_SUPER = 343,
|
||||
KB_RIGHT_SHIFT = 344,
|
||||
KB_RIGHT_CONTROL = 345,
|
||||
KB_RIGHT_ALT = 346,
|
||||
KB_RIGHT_SUPER = 347,
|
||||
KB_MENU = 348,
|
||||
}
|
||||
|
||||
pub const KB_SPACE : u32 = 32;
|
||||
pub const KB_APOSTROPHE : u32 = 39; /* ' */
|
||||
pub const KB_COMMA : u32 = 44; /* , */
|
||||
pub const KB_QUOTE : u32 = KB_COMMA;
|
||||
pub const KB_MINUS : u32 = 45; /* - */
|
||||
pub const KB_PERIOD : u32 = 46; /* . */
|
||||
pub const KB_SLASH : u32 = 47; /* / */
|
||||
|
||||
pub const KB_0 : u32 = 48;
|
||||
pub const KB_1 : u32 = 49;
|
||||
pub const KB_2 : u32 = 50;
|
||||
pub const KB_3 : u32 = 51;
|
||||
pub const KB_4 : u32 = 52;
|
||||
pub const KB_5 : u32 = 53;
|
||||
pub const KB_6 : u32 = 54;
|
||||
pub const KB_7 : u32 = 55;
|
||||
pub const KB_8 : u32 = 56;
|
||||
pub const KB_9 : u32 = 57;
|
||||
|
||||
pub const KB_SEMICOLON : u32 = 59; /* ; */
|
||||
pub const KB_EQUAL : u32 = 61; /* = */
|
||||
|
||||
pub const KB_A : u32 = 65;
|
||||
pub const KB_B : u32 = 66;
|
||||
pub const KB_C : u32 = 67;
|
||||
pub const KB_D : u32 = 68;
|
||||
pub const KB_E : u32 = 69;
|
||||
pub const KB_F : u32 = 70;
|
||||
pub const KB_G : u32 = 71;
|
||||
pub const KB_H : u32 = 72;
|
||||
pub const KB_I : u32 = 73;
|
||||
pub const KB_J : u32 = 74;
|
||||
pub const KB_K : u32 = 75;
|
||||
pub const KB_L : u32 = 76;
|
||||
pub const KB_M : u32 = 77;
|
||||
pub const KB_N : u32 = 78;
|
||||
pub const KB_O : u32 = 79;
|
||||
pub const KB_P : u32 = 80;
|
||||
pub const KB_Q : u32 = 81;
|
||||
pub const KB_R : u32 = 82;
|
||||
pub const KB_S : u32 = 83;
|
||||
pub const KB_T : u32 = 84;
|
||||
pub const KB_U : u32 = 85;
|
||||
pub const KB_V : u32 = 86;
|
||||
pub const KB_W : u32 = 87;
|
||||
pub const KB_X : u32 = 88;
|
||||
pub const KB_Y : u32 = 89;
|
||||
pub const KB_Z : u32 = 90;
|
||||
|
||||
pub const KB_LEFT_BRACKET : u32 = 91; /* [ */
|
||||
pub const KB_LEFTBRACKET : u32 = KB_LEFT_BRACKET;
|
||||
pub const KB_BACKSLASH : u32 = 92; /* \ */
|
||||
pub const KB_RIGHT_BRACKET : u32 = 93; /* ] */
|
||||
pub const KB_RIGHTBRACKET : u32 = KB_RIGHT_BRACKET;
|
||||
pub const KB_GRAVE_ACCENT : u32 = 96; /* ` */
|
||||
pub const KB_WORLD_1 : u32 = 161; /* non-US #1 */
|
||||
pub const KB_DOT : u32 = KB_WORLD_1;
|
||||
pub const KB_WORLD_2 : u32 = 162; /* non-US #2 */
|
||||
|
||||
/* Function keys */
|
||||
pub const KB_ESCAPE : u32 = 256;
|
||||
pub const KB_ENTER : u32 = 257;
|
||||
pub const KB_RETURN : u32 = KB_ENTER;
|
||||
pub const KB_TAB : u32 = 258;
|
||||
pub const KB_BACKSPACE : u32 = 259;
|
||||
pub const KB_BACK : u32 = KB_BACKSPACE;
|
||||
pub const KB_INSERT : u32 = 260;
|
||||
pub const KB_DELETE : u32 = 261;
|
||||
pub const KB_RIGHT : u32 = 262;
|
||||
pub const KB_LEFT : u32 = 263;
|
||||
pub const KB_DOWN : u32 = 264;
|
||||
pub const KB_UP : u32 = 265;
|
||||
pub const KB_PAGE_UP : u32 = 266;
|
||||
pub const KB_PRIOR : u32 = KB_PAGE_UP;
|
||||
pub const KB_PAGE_DOWN : u32 = 267;
|
||||
pub const KB_NEXT : u32 = KB_PAGE_DOWN;
|
||||
pub const KB_HOME : u32 = 268;
|
||||
pub const KB_END : u32 = 269;
|
||||
pub const KB_CAPS_LOCK : u32 = 280;
|
||||
pub const KB_CAPITAL : u32 = KB_CAPS_LOCK;
|
||||
pub const KB_SCROLL_LOCK : u32 = 281;
|
||||
pub const KB_SCROLL : u32 = KB_SCROLL_LOCK;
|
||||
pub const KB_NUM_LOCK : u32 = 282;
|
||||
pub const KB_NUMLOCK : u32 = KB_NUM_LOCK;
|
||||
pub const KB_PRINT_SCREEN : u32 = 283;
|
||||
pub const KB_PAUSE : u32 = 284;
|
||||
|
||||
pub const KB_F1 : u32 = 290;
|
||||
pub const KB_F2 : u32 = 291;
|
||||
pub const KB_F3 : u32 = 292;
|
||||
pub const KB_F4 : u32 = 293;
|
||||
pub const KB_F5 : u32 = 294;
|
||||
pub const KB_F6 : u32 = 295;
|
||||
pub const KB_F7 : u32 = 296;
|
||||
pub const KB_F8 : u32 = 297;
|
||||
pub const KB_F9 : u32 = 298;
|
||||
pub const KB_F10 : u32 = 299;
|
||||
pub const KB_F11 : u32 = 300;
|
||||
pub const KB_F12 : u32 = 301;
|
||||
pub const KB_F13 : u32 = 302;
|
||||
pub const KB_F14 : u32 = 303;
|
||||
pub const KB_F15 : u32 = 304;
|
||||
pub const KB_F16 : u32 = 305;
|
||||
pub const KB_F17 : u32 = 306;
|
||||
pub const KB_F18 : u32 = 307;
|
||||
pub const KB_F19 : u32 = 308;
|
||||
pub const KB_F20 : u32 = 309;
|
||||
pub const KB_F21 : u32 = 310;
|
||||
pub const KB_F22 : u32 = 311;
|
||||
pub const KB_F23 : u32 = 312;
|
||||
pub const KB_F24 : u32 = 313;
|
||||
pub const KB_F25 : u32 = 314;
|
||||
|
||||
pub const KB_NUMPAD0 : u32 = 320;
|
||||
pub const KB_NUMPAD1 : u32 = 321;
|
||||
pub const KB_NUMPAD2 : u32 = 322;
|
||||
pub const KB_NUMPAD3 : u32 = 323;
|
||||
pub const KB_NUMPAD4 : u32 = 324;
|
||||
pub const KB_NUMPAD5 : u32 = 325;
|
||||
pub const KB_NUMPAD6 : u32 = 326;
|
||||
pub const KB_NUMPAD7 : u32 = 327;
|
||||
pub const KB_NUMPAD8 : u32 = 328;
|
||||
pub const KB_NUMPAD9 : u32 = 329;
|
||||
|
||||
pub const KB_NUMPAD_DECIMAL : u32 = 330;
|
||||
pub const KB_DECIMAL : u32 = KB_NUMPAD_DECIMAL;
|
||||
pub const KB_SEPARATOR : u32 = KB_DECIMAL;
|
||||
pub const KB_NUMPAD_DIVIDE : u32 = 331;
|
||||
pub const KB_DIVIDE : u32 = KB_NUMPAD_DIVIDE;
|
||||
pub const KB_NUMPAD_MULTIPLY : u32 = 332;
|
||||
pub const KB_MULTIPLY : u32 = KB_NUMPAD_MULTIPLY;
|
||||
pub const KB_NUMPAD_SUBTRACT : u32 = 333;
|
||||
pub const KB_SUBTRACT : u32 = KB_NUMPAD_SUBTRACT;
|
||||
pub const KB_NUMPAD_ADD : u32 = 334;
|
||||
pub const KB_ADD : u32 = KB_NUMPAD_ADD;
|
||||
pub const KB_PLUS : u32 = KB_ADD;
|
||||
pub const KB_NUMPAD_ENTER : u32 = 335;
|
||||
pub const KB_NUMPAD_EQUAL : u32 = 336;
|
||||
|
||||
pub const KB_LEFT_SHIFT : u32 = 340;
|
||||
pub const KB_SHIFT : u32 = KB_LEFT_SHIFT;
|
||||
pub const KB_LEFT_CONTROL : u32 = 341;
|
||||
pub const KB_CONTROL : u32 = KB_LEFT_CONTROL;
|
||||
pub const KB_SHORTCUT : u32 = KB_CONTROL;
|
||||
pub const KB_LEFT_ALT : u32 = 342;
|
||||
pub const KB_LEFT_SUPER : u32 = 343;
|
||||
pub const KB_RIGHT_SHIFT : u32 = 344;
|
||||
pub const KB_RIGHT_CONTROL : u32 = 345;
|
||||
pub const KB_RIGHT_ALT : u32 = 346;
|
||||
pub const KB_RIGHT_SUPER : u32 = 347;
|
||||
pub const KB_MENU : u32 = 348;
|
||||
}
|
||||
223
libs/rust-sciter/src/capi/scom.rs
Normal file
223
libs/rust-sciter/src/capi/scom.rs
Normal file
@@ -0,0 +1,223 @@
|
||||
/*! Sciter Object Model (SOM passport), native C interface.
|
||||
|
||||
See https://sciter.com/native-code-exposure-to-script/
|
||||
and https://sciter.com/developers/for-native-gui-programmers/sciter-object-model/.
|
||||
|
||||
*/
|
||||
|
||||
#![allow(non_snake_case, non_camel_case_types)]
|
||||
#![allow(dead_code)]
|
||||
|
||||
use capi::sctypes::*;
|
||||
use capi::scvalue::VALUE;
|
||||
|
||||
/// An atom value that uniquely identifies the name being registered.
|
||||
pub type som_atom_t = u64;
|
||||
|
||||
|
||||
/// `som_asset_t` is a structure that a custom native object must be derived from.
|
||||
#[repr(C)]
|
||||
#[derive(Debug)]
|
||||
pub struct som_asset_t {
|
||||
pub(crate) isa: &'static som_asset_class_t,
|
||||
}
|
||||
|
||||
impl som_asset_t {
|
||||
pub(crate) fn get_passport(&self) -> *const som_passport_t {
|
||||
(self.isa.get_passport)(self as *const _ as *mut _)
|
||||
}
|
||||
}
|
||||
|
||||
/// Is a pack of 4 pointers to functions that define the life time of an asset.
|
||||
#[repr(C)]
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct som_asset_class_t {
|
||||
/// Increments the reference count for an interface on an object.
|
||||
pub add_ref: extern "C" fn(thing: *mut som_asset_t) -> i32,
|
||||
|
||||
/// Decrements the reference count for an interface on an object.
|
||||
pub release: extern "C" fn(thing: *mut som_asset_t) -> i32,
|
||||
|
||||
/// Retrieves a pointer to a supported interface of an object.
|
||||
pub get_interface: extern "C" fn(thing: *mut som_asset_t, name: LPCSTR, out: *mut *mut som_asset_t) -> bool,
|
||||
|
||||
/// Retrieves a pointer to the passport declaration of an object.
|
||||
pub get_passport: extern "C" fn(thing: *mut som_asset_t) -> *const som_passport_t,
|
||||
}
|
||||
|
||||
|
||||
/// Defines properties and methods of an asset.
|
||||
#[repr(C)]
|
||||
pub struct som_passport_t {
|
||||
/// Flags of an asset, see [`som_passport_flags`](enum.som_passport_flags.html).
|
||||
pub flags: u64,
|
||||
|
||||
/// The name of the class (asset type).
|
||||
pub name: som_atom_t,
|
||||
|
||||
/// Properties: `asset.prop`.
|
||||
///
|
||||
/// Must be a pointer to an array of structures:
|
||||
///
|
||||
/// ```rust,no_run
|
||||
/// # use sciter::om::*;
|
||||
/// let mut pst = Box::new(som_passport_t::default());
|
||||
///
|
||||
/// type ObjectProps = [som_property_def_t; 2];
|
||||
/// let mut props = Box::new(ObjectProps::default());
|
||||
///
|
||||
/// let mut prop1 = &mut props[0];
|
||||
/// prop1.name = atom("age");
|
||||
///
|
||||
/// let mut prop2 = &mut props[1];
|
||||
/// prop2.name = atom("name");
|
||||
///
|
||||
/// pst.n_properties = 2;
|
||||
/// pst.properties = Box::into_raw(props) as *const _;
|
||||
/// ```
|
||||
|
||||
pub properties: *const som_property_def_t,
|
||||
|
||||
/// Properties count.
|
||||
pub n_properties: usize,
|
||||
|
||||
/// Methods: `asset.func()`
|
||||
///
|
||||
/// Must be a pointer to an array of structures,
|
||||
/// see [`properties`](struct.som_passport_t.html#structfield.properties) for an example.
|
||||
pub methods: *const som_method_def_t,
|
||||
|
||||
/// Methods count.
|
||||
pub n_methods: usize,
|
||||
|
||||
/// Index access: `var item = asset[key]`.
|
||||
pub item_getter: Option<som_item_getter_t>,
|
||||
|
||||
/// Index access: `asset[key] = item`.
|
||||
pub item_setter: Option<som_item_setter_t>,
|
||||
|
||||
/// Enumeration: `for(var item in asset)`.
|
||||
pub item_next: Option<som_item_next_t>,
|
||||
|
||||
/// Property access interceptor: `var val = asset.prop`.
|
||||
pub prop_getter: Option<som_any_prop_getter_t>,
|
||||
|
||||
/// Property set interceptor: `asset.prop = val`.
|
||||
pub prop_setter: Option<som_any_prop_setter_t>,
|
||||
}
|
||||
|
||||
/// Empty passport.
|
||||
impl Default for som_passport_t {
|
||||
fn default() -> Self {
|
||||
use std::ptr;
|
||||
Self {
|
||||
flags: 0,
|
||||
name: 0,
|
||||
|
||||
prop_getter: None,
|
||||
prop_setter: None,
|
||||
|
||||
item_getter: None,
|
||||
item_setter: None,
|
||||
item_next: None,
|
||||
|
||||
properties: ptr::null(),
|
||||
n_properties: 0,
|
||||
|
||||
methods: ptr::null(),
|
||||
n_methods: 0,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// [`som_passport_t`](struct.som_passport_t.html#structfield.flags) flags.
|
||||
#[repr(u64)]
|
||||
#[derive(Debug, PartialOrd, PartialEq)]
|
||||
pub enum som_passport_flags {
|
||||
/// Not extendable.
|
||||
SEALED = 0,
|
||||
|
||||
/// Extendable.
|
||||
///
|
||||
/// An asset may have new properties added by script.
|
||||
EXTENDABLE = 1,
|
||||
}
|
||||
|
||||
|
||||
/// Property of an asset.
|
||||
#[repr(C)]
|
||||
pub struct som_property_def_t {
|
||||
pub reserved: LPVOID,
|
||||
|
||||
/// Property name.
|
||||
pub name: som_atom_t,
|
||||
|
||||
/// Property getter: `var val = asset.prop`.
|
||||
pub getter: Option<som_prop_getter_t>,
|
||||
|
||||
/// Property setter: `asset.prop = val`.
|
||||
pub setter: Option<som_prop_setter_t>,
|
||||
}
|
||||
|
||||
/// Empty property.
|
||||
impl Default for som_property_def_t {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
reserved: std::ptr::null_mut(),
|
||||
name: 0,
|
||||
getter: None,
|
||||
setter: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Method of an asset.
|
||||
#[repr(C)]
|
||||
pub struct som_method_def_t {
|
||||
pub reserved: LPVOID,
|
||||
|
||||
/// Method name.
|
||||
pub name: som_atom_t,
|
||||
|
||||
/// Parameters count.
|
||||
///
|
||||
/// The actual arguments count can be lesser then specified here:
|
||||
///
|
||||
/// ```tiscript,ignore
|
||||
/// function asset.func(a,b,c); // native asset method accepts 3 parameters
|
||||
///
|
||||
/// asset.func("one"); // call with only one parameter.
|
||||
/// ```
|
||||
pub params: usize,
|
||||
|
||||
/// Method body.
|
||||
pub func: Option<som_method_t>,
|
||||
}
|
||||
|
||||
/// Empty method.
|
||||
impl Default for som_method_def_t {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
reserved: std::ptr::null_mut(),
|
||||
name: 0,
|
||||
params: 0,
|
||||
func: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
type som_dispose_t = extern "C" fn(thing: *mut som_asset_t);
|
||||
|
||||
type som_prop_getter_t = extern "C" fn(thing: *mut som_asset_t, p_value: &mut VALUE) -> BOOL;
|
||||
type som_prop_setter_t = extern "C" fn(thing: *mut som_asset_t, p_value: &VALUE) -> BOOL;
|
||||
|
||||
type som_any_prop_getter_t = extern "C" fn(thing: *mut som_asset_t, propSymbol: som_atom_t, p_value: &mut VALUE) -> BOOL;
|
||||
type som_any_prop_setter_t = extern "C" fn(thing: *mut som_asset_t, propSymbol: som_atom_t, p_value: &VALUE) -> BOOL;
|
||||
|
||||
type som_item_getter_t = extern "C" fn(thing: *mut som_asset_t, p_key: &VALUE, p_value: &mut VALUE) -> BOOL;
|
||||
type som_item_setter_t = extern "C" fn(thing: *mut som_asset_t, p_key: &VALUE, p_value: &VALUE) -> BOOL;
|
||||
|
||||
type som_item_next_t = extern "C" fn(thing: *mut som_asset_t, p_idx: &mut VALUE, p_value: &mut VALUE) -> BOOL;
|
||||
|
||||
type som_method_t = extern "C" fn(thing: *mut som_asset_t, argc: u32, argv: *const VALUE, p_result: &mut VALUE) -> BOOL;
|
||||
184
libs/rust-sciter/src/capi/screquest.rs
Normal file
184
libs/rust-sciter/src/capi/screquest.rs
Normal file
@@ -0,0 +1,184 @@
|
||||
/*! Handling all attributes of requests (GET/POST/PUT/DELETE) sent by
|
||||
[`Element.request()`](https://sciter.com/docs/content/sciter/Element.htm) and
|
||||
[`View.request()`](https://sciter.com/docs/content/sciter/View.htm)
|
||||
functions and other load requests.
|
||||
|
||||
*/
|
||||
|
||||
#![allow(non_camel_case_types, non_snake_case)]
|
||||
|
||||
use capi::sctypes::{UINT, LPVOID, LPCBYTE, LPCSTR, LPCWSTR};
|
||||
use capi::scdef::{LPCSTR_RECEIVER, LPCWSTR_RECEIVER, LPCBYTE_RECEIVER};
|
||||
pub use capi::scdef::RESOURCE_TYPE;
|
||||
|
||||
MAKE_HANDLE!(#[doc = "Request native handle."] HREQUEST, _HREQUEST);
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
/// Type of the result value for Sciter Request functions.
|
||||
pub enum REQUEST_RESULT {
|
||||
/// E.g. not enough memory.
|
||||
PANIC = -1,
|
||||
/// Success.
|
||||
OK = 0,
|
||||
/// Bad parameter.
|
||||
BAD_PARAM = 1,
|
||||
/// Operation failed, e.g. index out of bounds.
|
||||
FAILURE = 2,
|
||||
/// The platform does not support requested feature.
|
||||
NOTSUPPORTED = 3,
|
||||
}
|
||||
|
||||
impl std::error::Error for REQUEST_RESULT {}
|
||||
|
||||
impl std::fmt::Display for REQUEST_RESULT {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
write!(f, "{:?}", self)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
/// Request methods.
|
||||
pub enum REQUEST_METHOD {
|
||||
/// Sends a plain HTTP GET request.
|
||||
///
|
||||
/// Url-encoded params (if any) are appended to the url in order to form the request.
|
||||
GET = 1,
|
||||
/// Sends an HTTP POST request.
|
||||
///
|
||||
/// The params are serialized as `Content-Type: application/x-www-form-urlencoded;charset=utf-8`.
|
||||
POST = 2,
|
||||
/// Sends an HTTP PUT request.
|
||||
///
|
||||
/// The params are serialized as `Content-Type: multipart/form-data; boundary= ...`.
|
||||
PUT = 3,
|
||||
/// Sends an HTTP DELETE request.
|
||||
DELETE = 4,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
/// HTTP methods for the [`Element::send_request`](../dom/struct.Element.html#method.send_request).
|
||||
pub enum REQUEST_TYPE {
|
||||
/// Asynchronous GET.
|
||||
AsyncGet,
|
||||
/// Asynchronous POST.
|
||||
AsyncPost,
|
||||
/// Synchronous GET.
|
||||
Get,
|
||||
/// Synchronous POST.
|
||||
Post,
|
||||
}
|
||||
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Debug, PartialEq)]
|
||||
/// Completion state of a request.
|
||||
pub enum REQUEST_STATE {
|
||||
/// The request is pending.
|
||||
PENDING = 0,
|
||||
/// Completed successfully.
|
||||
SUCCESS = 1,
|
||||
/// Completed with failure.
|
||||
FAILURE = 2,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Debug)]
|
||||
pub struct REQUEST_PARAM {
|
||||
pub name: LPCWSTR,
|
||||
pub value: LPCWSTR,
|
||||
}
|
||||
|
||||
|
||||
#[repr(C)]
|
||||
#[allow(missing_docs)]
|
||||
pub struct SciterRequestAPI
|
||||
{
|
||||
/// a.k.a AddRef()
|
||||
pub RequestUse: extern "system" fn (rq: HREQUEST) -> REQUEST_RESULT,
|
||||
|
||||
/// a.k.a Release()
|
||||
pub RequestUnUse: extern "system" fn (rq: HREQUEST) -> REQUEST_RESULT,
|
||||
|
||||
/// get requested URL
|
||||
pub RequestUrl: extern "system" fn (rq: HREQUEST, rcv: LPCSTR_RECEIVER, rcv_param: LPVOID) -> REQUEST_RESULT,
|
||||
|
||||
/// get real, content URL (after possible redirection)
|
||||
pub RequestContentUrl: extern "system" fn (rq: HREQUEST, rcv: LPCSTR_RECEIVER, rcv_param: LPVOID) -> REQUEST_RESULT,
|
||||
|
||||
/// get requested data type
|
||||
pub RequestGetRequestType: extern "system" fn (rq: HREQUEST, pType: &mut REQUEST_METHOD) -> REQUEST_RESULT,
|
||||
|
||||
/// get requested data type
|
||||
pub RequestGetRequestedDataType: extern "system" fn (rq: HREQUEST, pData: &mut RESOURCE_TYPE) -> REQUEST_RESULT,
|
||||
|
||||
/// get received data type, string, mime type
|
||||
pub RequestGetReceivedDataType: extern "system" fn (rq: HREQUEST, rcv: LPCSTR_RECEIVER, rcv_param: LPVOID) -> REQUEST_RESULT,
|
||||
|
||||
|
||||
/// get number of request parameters passed
|
||||
pub RequestGetNumberOfParameters: extern "system" fn (rq: HREQUEST, pNumber: &mut UINT) -> REQUEST_RESULT,
|
||||
|
||||
/// get nth request parameter name
|
||||
pub RequestGetNthParameterName: extern "system" fn (rq: HREQUEST, n: UINT, rcv: LPCWSTR_RECEIVER, rcv_param: LPVOID) -> REQUEST_RESULT,
|
||||
|
||||
/// get nth request parameter value
|
||||
pub RequestGetNthParameterValue: extern "system" fn (rq: HREQUEST, n: UINT, rcv: LPCWSTR_RECEIVER, rcv_param: LPVOID) -> REQUEST_RESULT,
|
||||
|
||||
/// get request times , ended - started = milliseconds to get the requst
|
||||
pub RequestGetTimes: extern "system" fn (rq: HREQUEST, pStarted: &mut UINT, pEnded: &mut UINT) -> REQUEST_RESULT,
|
||||
|
||||
/// get number of request headers
|
||||
pub RequestGetNumberOfRqHeaders: extern "system" fn (rq: HREQUEST, pNumber: &mut UINT) -> REQUEST_RESULT,
|
||||
|
||||
/// get nth request header name
|
||||
pub RequestGetNthRqHeaderName: extern "system" fn (rq: HREQUEST, n: UINT, rcv: LPCWSTR_RECEIVER, rcv_param: LPVOID) -> REQUEST_RESULT,
|
||||
|
||||
/// get nth request header value
|
||||
pub RequestGetNthRqHeaderValue: extern "system" fn (rq: HREQUEST, n: UINT, rcv: LPCWSTR_RECEIVER, rcv_param: LPVOID) -> REQUEST_RESULT,
|
||||
|
||||
/// get number of response headers
|
||||
pub RequestGetNumberOfRspHeaders: extern "system" fn (rq: HREQUEST, pNumber: &mut UINT) -> REQUEST_RESULT,
|
||||
|
||||
/// get nth response header name
|
||||
pub RequestGetNthRspHeaderName: extern "system" fn (rq: HREQUEST, n: UINT, rcv: LPCWSTR_RECEIVER, rcv_param: LPVOID) -> REQUEST_RESULT,
|
||||
|
||||
/// get nth response header value
|
||||
pub RequestGetNthRspHeaderValue: extern "system" fn (rq: HREQUEST, n: UINT, rcv: LPCWSTR_RECEIVER, rcv_param: LPVOID) -> REQUEST_RESULT,
|
||||
|
||||
/// get completion status (CompletionStatus - http response code : 200, 404, etc.)
|
||||
pub RequestGetCompletionStatus: extern "system" fn (rq: HREQUEST, pState: &mut REQUEST_STATE, pCompletionStatus: &mut UINT) -> REQUEST_RESULT,
|
||||
|
||||
/// get proxy host
|
||||
pub RequestGetProxyHost: extern "system" fn (rq: HREQUEST, rcv: LPCSTR_RECEIVER, rcv_param: LPVOID) -> REQUEST_RESULT,
|
||||
|
||||
/// get proxy port
|
||||
pub RequestGetProxyPort: extern "system" fn (rq: HREQUEST, pPort: &mut UINT) -> REQUEST_RESULT,
|
||||
|
||||
/// mark reequest as complete with status and data
|
||||
pub RequestSetSucceeded: extern "system" fn (rq: HREQUEST, status: UINT, dataOrNull: LPCBYTE, dataLength: UINT) -> REQUEST_RESULT,
|
||||
|
||||
/// mark reequest as complete with failure and optional data
|
||||
pub RequestSetFailed: extern "system" fn (rq: HREQUEST, status: UINT, dataOrNull: LPCBYTE, dataLength: UINT) -> REQUEST_RESULT,
|
||||
|
||||
/// append received data chunk
|
||||
pub RequestAppendDataChunk: extern "system" fn (rq: HREQUEST, data: LPCBYTE, dataLength: UINT) -> REQUEST_RESULT,
|
||||
|
||||
/// set request header (single item)
|
||||
pub RequestSetRqHeader: extern "system" fn (rq: HREQUEST, name: LPCWSTR, value: LPCWSTR) -> REQUEST_RESULT,
|
||||
|
||||
/// set respone header (single item)
|
||||
pub RequestSetRspHeader: extern "system" fn (rq: HREQUEST, name: LPCWSTR, value: LPCWSTR) -> REQUEST_RESULT,
|
||||
|
||||
/// set received data type, string, mime type
|
||||
pub RequestSetReceivedDataType: extern "system" fn (rq: HREQUEST, _type: LPCSTR) -> REQUEST_RESULT,
|
||||
|
||||
/// set received data encoding, string
|
||||
pub RequestSetReceivedDataEncoding: extern "system" fn (rq: HREQUEST, encoding: LPCSTR) -> REQUEST_RESULT,
|
||||
|
||||
/// get received (so far) data
|
||||
pub RequestGetData: extern "system" fn (rq: HREQUEST, rcv: LPCBYTE_RECEIVER, rcv_param: LPVOID) -> REQUEST_RESULT,
|
||||
}
|
||||
15
libs/rust-sciter/src/capi/sctiscript.rs
Normal file
15
libs/rust-sciter/src/capi/sctiscript.rs
Normal file
@@ -0,0 +1,15 @@
|
||||
//! TIScript Virtual Machine Runtime.
|
||||
|
||||
#![allow(non_camel_case_types, non_snake_case)]
|
||||
|
||||
use capi::sctypes::{LPVOID, UINT64};
|
||||
|
||||
MAKE_HANDLE!(#[doc = "TIScript VM native handle."] HVM, _HVM);
|
||||
|
||||
pub type tiscript_value = UINT64;
|
||||
|
||||
#[repr(C)]
|
||||
pub struct tiscript_native_interface
|
||||
{
|
||||
create_vm: LPVOID,
|
||||
}
|
||||
127
libs/rust-sciter/src/capi/sctypes.rs
Normal file
127
libs/rust-sciter/src/capi/sctypes.rs
Normal file
@@ -0,0 +1,127 @@
|
||||
//! Sciter platform-dependent types.
|
||||
|
||||
#![allow(non_camel_case_types, non_snake_case)]
|
||||
|
||||
extern crate libc;
|
||||
|
||||
use self::libc::*;
|
||||
|
||||
|
||||
// common
|
||||
MAKE_HANDLE!(#[doc = "Window native handle."] HWINDOW, _HWINDOW); // HWND or NSView* or GtkWidget*
|
||||
MAKE_HANDLE!(#[doc = "Archive native handle."] HSARCHIVE, _HSARCHIVE);
|
||||
|
||||
pub type BYTE = u8;
|
||||
pub type INT = i32;
|
||||
pub type LONG = i32;
|
||||
pub type UINT = u32;
|
||||
pub type INT64 = i64;
|
||||
pub type UINT64 = u64;
|
||||
|
||||
pub type FLOAT_VALUE = f64;
|
||||
|
||||
pub type WPARAM = size_t;
|
||||
pub type LPARAM = ssize_t;
|
||||
|
||||
pub type UINT_PTR = uintptr_t;
|
||||
pub type LRESULT = ssize_t;
|
||||
|
||||
pub type CHAR = c_char;
|
||||
pub type LPSTR = *mut CHAR;
|
||||
pub type LPCSTR = *const CHAR;
|
||||
|
||||
pub type WCHAR = u16;
|
||||
pub type LPWSTR = *mut WCHAR;
|
||||
pub type LPCWSTR = *const WCHAR;
|
||||
|
||||
pub type LPCBYTE = *const BYTE;
|
||||
pub type LPUINT = *mut UINT;
|
||||
|
||||
pub type VOID = c_void;
|
||||
pub type LPVOID = *mut VOID;
|
||||
pub type LPCVOID = *const VOID;
|
||||
|
||||
#[cfg(windows)]
|
||||
pub type BOOL = i32;
|
||||
|
||||
#[cfg(not(windows))]
|
||||
pub type BOOL = i8;
|
||||
|
||||
pub type PBOOL = *mut BOOL;
|
||||
|
||||
/// Defines the coordinates of the upper-left and lower-right corners of a rectangle.
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy, PartialEq)]
|
||||
#[derive(Default, Debug)]
|
||||
pub struct RECT {
|
||||
pub left: LONG,
|
||||
pub top: LONG,
|
||||
pub right: LONG,
|
||||
pub bottom: LONG,
|
||||
}
|
||||
pub type LPRECT = *mut RECT;
|
||||
pub type LPCRECT = *const RECT;
|
||||
|
||||
impl RECT {
|
||||
/// Calculate the height of the rect.
|
||||
pub fn height(&self) -> LONG {
|
||||
self.bottom - self.top
|
||||
}
|
||||
|
||||
/// Calculate the width of the rect.
|
||||
pub fn width(&self) -> LONG {
|
||||
self.right - self.left
|
||||
}
|
||||
|
||||
/// Return the size of the rect in width and height form.
|
||||
pub fn size(&self) -> SIZE {
|
||||
SIZE {
|
||||
cx: self.width(),
|
||||
cy: self.height(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the top-left point of the rect.
|
||||
pub fn topleft(&self) -> POINT {
|
||||
POINT {
|
||||
x: self.left,
|
||||
y: self.top,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Defines the `x` and `y` coordinates of a point.
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy, PartialEq)]
|
||||
#[derive(Default, Debug)]
|
||||
pub struct POINT {
|
||||
pub x: LONG,
|
||||
pub y: LONG,
|
||||
}
|
||||
pub type LPPOINT = *mut POINT;
|
||||
|
||||
/// Specifies the width and height of a rectangle.
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy, PartialEq)]
|
||||
#[derive(Default, Debug)]
|
||||
pub struct SIZE {
|
||||
pub cx: LONG,
|
||||
pub cy: LONG,
|
||||
}
|
||||
pub type LPSIZE = *mut SIZE;
|
||||
|
||||
|
||||
#[cfg(windows)]
|
||||
#[repr(C)]
|
||||
#[derive(Debug)]
|
||||
pub struct MSG {
|
||||
pub hwnd: HWINDOW,
|
||||
pub message: UINT,
|
||||
pub wParam: WPARAM,
|
||||
pub lParam: LPARAM,
|
||||
pub time: UINT,
|
||||
pub pt: POINT,
|
||||
}
|
||||
#[cfg(windows)]
|
||||
pub type LPMSG = *mut MSG;
|
||||
|
||||
124
libs/rust-sciter/src/capi/scvalue.rs
Normal file
124
libs/rust-sciter/src/capi/scvalue.rs
Normal file
@@ -0,0 +1,124 @@
|
||||
//! Sciter value, native C interface.
|
||||
|
||||
#![allow(non_snake_case, non_camel_case_types)]
|
||||
#![allow(dead_code)]
|
||||
|
||||
use capi::sctypes::*;
|
||||
|
||||
/// A JSON value.
|
||||
///
|
||||
/// An opaque union that can hold different types of values: numbers, strings, arrays, objects, etc.
|
||||
#[repr(C)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct VALUE
|
||||
{
|
||||
/// Value type.
|
||||
pub t: VALUE_TYPE,
|
||||
|
||||
/// Value unit type.
|
||||
pub u: UINT,
|
||||
|
||||
/// Value data.
|
||||
pub d: UINT64,
|
||||
}
|
||||
|
||||
impl Default for VALUE {
|
||||
fn default() -> Self {
|
||||
VALUE { t: VALUE_TYPE::T_UNDEFINED, u: 0, d: 0 }
|
||||
}
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Debug, PartialOrd, PartialEq)]
|
||||
pub enum VALUE_RESULT
|
||||
{
|
||||
OK_TRUE = -1,
|
||||
OK = 0,
|
||||
BAD_PARAMETER = 1,
|
||||
INCOMPATIBLE_TYPE = 2,
|
||||
}
|
||||
|
||||
impl std::error::Error for VALUE_RESULT {}
|
||||
|
||||
impl std::fmt::Display for VALUE_RESULT {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
write!(f, "{:?}", self)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Debug, PartialOrd, PartialEq)]
|
||||
pub enum VALUE_STRING_CVT_TYPE {
|
||||
SIMPLE = 0,
|
||||
JSON_LITERAL = 1,
|
||||
JSON_MAP = 2,
|
||||
XJSON_LITERAL = 3,
|
||||
}
|
||||
|
||||
|
||||
/// Type identifier of the value.
|
||||
#[repr(C)]
|
||||
#[derive(Debug, Copy, Clone, PartialOrd, PartialEq)]
|
||||
pub enum VALUE_TYPE {
|
||||
T_UNDEFINED = 0,
|
||||
T_NULL = 1,
|
||||
T_BOOL,
|
||||
T_INT,
|
||||
T_FLOAT,
|
||||
T_STRING,
|
||||
T_DATE,
|
||||
T_CURRENCY,
|
||||
T_LENGTH,
|
||||
T_ARRAY,
|
||||
T_MAP,
|
||||
T_FUNCTION,
|
||||
T_BYTES,
|
||||
T_OBJECT,
|
||||
T_DOM_OBJECT,
|
||||
T_RESOURCE,
|
||||
T_RANGE,
|
||||
T_DURATION,
|
||||
T_ANGLE,
|
||||
T_COLOR,
|
||||
T_ENUM,
|
||||
T_ASSET,
|
||||
|
||||
T_UNKNOWN,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Debug, PartialOrd, PartialEq)]
|
||||
pub enum VALUE_UNIT_UNDEFINED
|
||||
{
|
||||
UT_NOTHING = 1,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Debug, PartialOrd, PartialEq)]
|
||||
pub enum VALUE_UNIT_TYPE_STRING
|
||||
{
|
||||
STRING = 0, // string
|
||||
ERROR = 1, // is an error string
|
||||
SECURE = 2, // secure string ("wiped" on destroy)
|
||||
URL = 3, // url(...)
|
||||
SELECTOR = 4, // selector(...)
|
||||
FILE = 0xfffe, // file name
|
||||
SYMBOL = 0xffff, // symbol in tiscript sense
|
||||
}
|
||||
|
||||
// Sciter or TIScript specific
|
||||
#[repr(C)]
|
||||
#[derive(Debug, PartialOrd, PartialEq)]
|
||||
pub enum VALUE_UNIT_TYPE_OBJECT
|
||||
{
|
||||
ARRAY = 0, // type T_OBJECT of type Array
|
||||
OBJECT = 1, // type T_OBJECT of type Object
|
||||
CLASS = 2, // type T_OBJECT of type Class (class or namespace)
|
||||
NATIVE = 3, // type T_OBJECT of native Type with data slot (LPVOID)
|
||||
FUNCTION = 4, // type T_OBJECT of type Function
|
||||
ERROR = 5, // type T_OBJECT of type Error
|
||||
}
|
||||
|
||||
pub type NATIVE_FUNCTOR_INVOKE = extern "C" fn (tag: LPVOID, argc: UINT, argv: *const VALUE, retval: * mut VALUE);
|
||||
pub type NATIVE_FUNCTOR_RELEASE = extern "C" fn (tag: LPVOID);
|
||||
Reference in New Issue
Block a user