sciter/capi/scdef.rs
1//! Common Sciter declarations.
2
3#![allow(non_camel_case_types, non_snake_case)]
4#![allow(dead_code)]
5
6use capi::sctypes::*;
7use capi::scvalue::{VALUE};
8use capi::screquest::{HREQUEST};
9use capi::scdom::{HELEMENT};
10use capi::scapi::ISciterAPI;
11
12//////////////////////////////////////////////////////////////////////////////////
13pub enum ID2D1RenderTarget {}
14pub enum ID2D1Factory {}
15pub enum IDWriteFactory {}
16pub enum IDXGISwapChain {}
17pub enum IDXGISurface {}
18
19
20#[repr(C)]
21#[derive(Debug, PartialOrd, PartialEq)]
22/// `HostHandler::on_data_load()` result code.
23///
24/// This notification gives application a chance to override built-in loader and
25/// implement loading of resources in its own way (for example, images can be loaded from
26/// a database or other resource).
27pub enum LOAD_RESULT {
28 /// Do the default loading if data is not set.
29 LOAD_DEFAULT,
30 /// Discard the request completely (data will not be loaded at the document).
31 LOAD_DISCARD,
32 /// Data will be delivered later by the host application.
33 LOAD_DELAYED,
34 /// You return this result to indicate that your (the host) application took or
35 /// will take care about `HREQUEST` in your code completely.
36 LOAD_MYSELF,
37}
38
39/// Script runtime options.
40#[repr(C)]
41#[derive(Debug)]
42#[allow(missing_docs)]
43pub enum SCRIPT_RUNTIME_FEATURES
44{
45 ALLOW_FILE_IO = 0x1,
46 ALLOW_SOCKET_IO = 0x2,
47 ALLOW_EVAL = 0x4,
48 ALLOW_SYSINFO = 0x8,
49}
50
51/// Sciter graphics rendering backend.
52#[repr(C)]
53#[derive(Debug)]
54#[derive(Copy, Clone)]
55#[allow(missing_docs)]
56pub enum GFX_LAYER
57{
58 /// An auto-selected backend.
59 AUTO = 0xFFFF,
60
61 /// Depends on OS: GDI, Cairo or CoreGraphics.
62 CPU = 1,
63
64 /// A software rasterizer for Direct2D (Windows only).
65 #[cfg(windows)]
66 WARP = 2,
67
68 /// A hardware Direct2D mode (Windows only).
69 #[cfg(windows)]
70 D2D = 3,
71
72 /// Skia backend with CPU rasterization mode.
73 SKIA_CPU = 4,
74
75 /// Skia backend with OpenGL rendering.
76 SKIA_OPENGL = 5,
77}
78
79#[repr(C)]
80#[derive(Debug, PartialOrd, PartialEq)]
81/// Various Sciter engine options (global or per-window).
82pub enum SCITER_RT_OPTIONS
83{
84 /// value:TRUE - enable, value:FALSE - disable, enabled by default.
85 SCITER_SMOOTH_SCROLL = 1,
86 /// global; value: milliseconds, connection timeout of http client.
87 SCITER_CONNECTION_TIMEOUT = 2,
88 /// global; value: 0 - drop connection, 1 - use builtin dialog, 2 - accept connection silently.
89 SCITER_HTTPS_ERROR = 3,
90 /// value: 0 - system default, 1 - no smoothing, 2 - std smoothing, 3 - clear type.
91 SCITER_FONT_SMOOTHING = 4,
92 /// Windows Aero support, value:
93 /// 0 - normal drawing,
94 /// 1 - window has transparent background after calls `DwmExtendFrameIntoClientArea()` or `DwmEnableBlurBehindWindow()`.
95 SCITER_TRANSPARENT_WINDOW = 6,
96 /// global; value = LPCBYTE, json - GPU black list, see: gpu-blacklist.json resource.
97 /// Note: is not used since Sciter 4.
98 #[deprecated(since="4.0.1", note="This option isn't working since Sciter 4.0.1.1.")]
99 SCITER_SET_GPU_BLACKLIST = 7,
100 /// global or per-window; value - combination of [SCRIPT_RUNTIME_FEATURES](enum.SCRIPT_RUNTIME_FEATURES.html) flags.
101 SCITER_SET_SCRIPT_RUNTIME_FEATURES = 8,
102 /// global (must be called before any window creation); value - [GFX_LAYER](enum.GFX_LAYER.html).
103 SCITER_SET_GFX_LAYER = 9,
104 /// global or per-window; value - TRUE/FALSE
105 SCITER_SET_DEBUG_MODE = 10,
106 /// global; value - BOOL, TRUE - the engine will use "unisex" theme that is common for all platforms.
107 /// That UX theme is not using OS primitives for rendering input elements.
108 /// Use it if you want exactly the same (modulo fonts) look-n-feel on all platforms.
109 SCITER_SET_UX_THEMING = 11,
110 /// value - TRUE/FALSE - window uses per pixel alpha (e.g. `WS_EX_LAYERED`/`UpdateLayeredWindow()` window).
111 SCITER_ALPHA_WINDOW = 12,
112 /// global; value: UTF-8 encoded script source to be loaded into each view before any other script execution.
113 SCITER_SET_INIT_SCRIPT = 13,
114 /// per-window; value - TRUE/FALSE - window is main, will destroy all other dependent windows on close.
115 SCITER_SET_MAIN_WINDOW = 14,
116 /// global; value - max request length in megabytes (1024*1024 bytes).
117 SCITER_SET_MAX_HTTP_DATA_LENGTH = 15,
118 /// global or per-window; value 1 - 1px in CSS is treated as 1dip, value 0 - default behavior - 1px is a physical pixel.
119 SCITER_SET_PX_AS_DIP = 16,
120}
121
122/// Window flags
123#[repr(C)]
124pub enum SCITER_CREATE_WINDOW_FLAGS {
125 /// child window only, if this flag is set all other flags ignored.
126 SW_CHILD = 1,
127 /// toplevel window, has titlebar.
128 SW_TITLEBAR = 1 << 1,
129 /// has resizeable frame.
130 SW_RESIZEABLE = 1 << 2,
131 /// is tool window.
132 SW_TOOL = 1 << 3,
133 /// has minimize / maximize buttons.
134 SW_CONTROLS = 1 << 4,
135 /// glassy window - "Acrylic" on Windows and "Vibrant" on macOS.
136 SW_GLASSY = 1 << 5,
137 /// transparent window (e.g. `WS_EX_LAYERED` on Windows, macOS is supported too).
138 SW_ALPHA = 1 << 6,
139 /// main window of the app, will terminate the app on close.
140 SW_MAIN = 1 << 7,
141 /// the window is created as topmost window.
142 SW_POPUP = 1 << 8,
143 /// make this window inspector ready.
144 SW_ENABLE_DEBUG = 1 << 9,
145 /// it has its own script VM.
146 SW_OWNS_VM = 1 << 10,
147}
148
149impl Default for SCITER_CREATE_WINDOW_FLAGS {
150 fn default() -> Self {
151 SCITER_CREATE_WINDOW_FLAGS::SW_CHILD
152 }
153}
154
155/// Flags can be OR'ed as `SW_MAIN|SW_ALPHA`.
156impl ::std::ops::BitOr for SCITER_CREATE_WINDOW_FLAGS {
157 type Output = SCITER_CREATE_WINDOW_FLAGS;
158 fn bitor(self, rhs: Self::Output) -> Self::Output {
159 let rn = (self as UINT) | (rhs as UINT);
160 unsafe { ::std::mem::transmute(rn) }
161 }
162}
163
164#[repr(C)]
165#[derive(Debug, PartialOrd, PartialEq)]
166pub enum SCITER_NOTIFICATION {
167 SC_LOAD_DATA = 1,
168 SC_DATA_LOADED = 2,
169 SC_ATTACH_BEHAVIOR = 4,
170 SC_ENGINE_DESTROYED = 5,
171 SC_POSTED_NOTIFICATION = 6,
172 SC_GRAPHICS_CRITICAL_FAILURE = 7,
173 SC_KEYBOARD_REQUEST = 8,
174 SC_INVALIDATE_RECT = 9,
175}
176
177#[repr(C)]
178#[derive(Debug, PartialEq)]
179/// The type of a loaded resource.
180pub enum RESOURCE_TYPE {
181 /// HTML document.
182 HTML = 0,
183 /// Image.
184 IMAGE = 1,
185 /// CSS.
186 STYLE = 2,
187 /// Mouse cursor image.
188 CURSOR = 3,
189 /// TIScript document.
190 SCRIPT = 4,
191 /// Any data.
192 RAW = 5,
193 /// Font.
194 FONT,
195 /// Sound (wav bytes).
196 SOUND,
197}
198
199/// The type of a loaded resource.
200pub type SCITER_RESOURCE_TYPE = RESOURCE_TYPE;
201
202
203#[repr(C)]
204#[derive(Debug)]
205/// Notifies that Sciter is about to download a referred resource.
206pub struct SCN_LOAD_DATA
207{
208 /// `SC_LOAD_DATA` here.
209 pub code: UINT,
210 /// `HWINDOW` of the window this callback was attached to.
211 pub hwnd: HWINDOW,
212
213 /// [in] Zero terminated string, fully qualified uri, for example, "http://server/folder/file.ext".
214 pub uri: LPCWSTR,
215
216 /// [in,out] pointer to loaded data to return. If data exists in the cache then this field contain pointer to it.
217 pub outData: LPCBYTE,
218 /// [in,out] loaded data size to return.
219 pub outDataSize: UINT,
220
221 /// [in] resource type category
222 pub dataType: RESOURCE_TYPE,
223
224 /// [in] request handle that can be used with Sciter request API.
225 pub request_id: HREQUEST,
226
227 /// [in] destination element for request.
228 pub principal: HELEMENT,
229 /// [in] source element for request.
230 pub initiator: HELEMENT,
231}
232
233#[repr(C)]
234#[derive(Debug)]
235/// This notification indicates that external data (for example, image) download process has been completed.
236pub struct SCN_DATA_LOADED
237{
238 /// `SC_DATA_LOADED` here.
239 pub code: UINT,
240 /// `HWINDOW` of the window this callback was attached to.
241 pub hwnd: HWINDOW,
242 /// [in] zero terminated string, fully qualified uri, for example, "http://server/folder/file.ext".
243 pub uri: LPCWSTR,
244 /// [in] pointer to loaded data.
245 pub data: LPCBYTE,
246 /// [in] loaded data size (in bytes).
247 pub dataSize: UINT,
248 /// [in] resource type category
249 pub dataType: RESOURCE_TYPE,
250 /// Download status code:
251 ///
252 /// * status = 0 and `dataSize == 0` - unknown error.
253 /// * status = 100..505 - http response status, note: 200 - OK!
254 /// * status > 12000 - wininet error code, see `ERROR_INTERNET_***` in wininet.h
255 pub status: UINT,
256}
257
258#[repr(C)]
259/// This notification is sent on parsing the document and while processing elements
260/// having non empty `behavior: ` style attribute value.
261pub struct SCN_ATTACH_BEHAVIOR
262{
263 /// `SC_ATTACH_BEHAVIOR` here.
264 pub code: UINT,
265 /// `HWINDOW` of the window this callback was attached to.
266 pub hwnd: HWINDOW,
267
268 /// [in] target DOM element handle
269 pub element: HELEMENT,
270 /// [in] zero terminated string, string appears as value of CSS `behavior: ` attribute.
271 pub name: LPCSTR,
272 /// [out] pointer to ElementEventProc function.
273 pub elementProc: ElementEventProc,
274 /// [out] tag value, passed as is into pointer ElementEventProc function.
275 pub elementTag: LPVOID,
276}
277
278#[repr(C)]
279/// This notification is issued when keyboard needs to be shown –
280/// mobiles can show soft keyboard by handling it.
281pub struct SCN_KEYBOARD_REQUEST
282{
283 /// `SC_KEYBOARD_REQUEST` here.
284 pub code: UINT,
285 /// `HWINDOW` of the window this callback was attached to.
286 pub hwnd: HWINDOW,
287
288 pub keyboard_mode: UINT,
289}
290
291#[repr(C)]
292/// This notification is sent when a specific window area
293/// needs to be redrawn.
294pub struct SCN_INVALIDATE_RECT
295{
296 /// `SC_INVALIDATE_RECT` here.
297 pub code: UINT,
298 /// `HWINDOW` of the window this callback was attached to.
299 pub hwnd: HWINDOW,
300
301 /// Coordinates of the invalidated area.
302 pub invalid_rect: RECT,
303}
304
305#[repr(C)]
306pub struct SCITER_CALLBACK_NOTIFICATION
307{
308 pub code: UINT,
309 pub hwnd: HWINDOW,
310}
311pub type LPSCITER_CALLBACK_NOTIFICATION = *mut SCITER_CALLBACK_NOTIFICATION;
312
313pub type SciterHostCallback = extern "system" fn (pns: LPSCITER_CALLBACK_NOTIFICATION, callbackParam: LPVOID) -> UINT;
314
315pub type SciterWindowDelegate = extern "system" fn (hwnd: HWINDOW, msg: UINT, wParam: WPARAM, lParam: LPARAM, pParam: LPVOID, handled: * mut BOOL) -> LRESULT;
316
317pub type ElementEventProc = extern "system" fn (tag: LPVOID, he: HELEMENT, evtg: UINT, prms: LPVOID) -> BOOL;
318
319#[repr(C)]
320#[derive(Debug, PartialOrd, PartialEq)]
321/// Debug output categories.
322pub enum OUTPUT_SUBSYTEMS
323{
324 /// html parser & runtime
325 DOM = 0,
326 /// csss! parser & runtime
327 CSSS,
328 /// css parser
329 CSS,
330 /// TIS parser & runtime
331 TIS,
332}
333
334#[repr(C)]
335#[derive(Debug, PartialOrd, PartialEq)]
336#[allow(missing_docs)]
337/// Debug output severity.
338pub enum OUTPUT_SEVERITY
339{
340 INFO,
341 WARNING,
342 ERROR,
343}
344
345pub type DEBUG_OUTPUT_PROC = extern "system" fn (param: LPVOID, subsystem: OUTPUT_SUBSYTEMS, severity: OUTPUT_SEVERITY, text: LPCWSTR, text_length: UINT);
346
347pub type LPCWSTR_RECEIVER = extern "system" fn (szstr: LPCWSTR, str_length: UINT, param: LPVOID);
348pub type LPCSTR_RECEIVER = extern "system" fn (szstr: LPCSTR, str_length: UINT, param: LPVOID);
349pub type LPCBYTE_RECEIVER = extern "system" fn (szstr: LPCBYTE, str_length: UINT, param: LPVOID);
350
351pub type ELEMENT_BITMAP_RECEIVER = extern "system" fn (rgba: LPCBYTE, x: INT, y: INT, width: UINT, height: UINT, param: LPVOID);
352
353pub type KeyValueCallback = extern "system" fn (param: LPVOID, pkey: *const VALUE, pval: *const VALUE) -> BOOL;
354
355/// Signature of Sciter extension library.
356///
357/// * `api` - Sciter API to be used inside the extension.
358/// * `exported` - extension object, it can be [asset](https://sciter.com/developers/for-native-gui-programmers/sciter-object-model/),
359/// function, or other `sciter::Value` supported type.
360///
361/// Return `true` if the `exported` object was initialized.
362///
363/// The extension should be placed in the same folder as "sciter.dll"
364/// and export a `SciterLibraryInit` function:
365///
366/// ```rust,no_run
367/// use sciter::types::{BOOL, VALUE};
368/// use sciter::Value;
369///
370/// #[no_mangle]
371/// pub extern "system"
372/// fn SciterLibraryInit(api: &'static sciter::ISciterAPI, exported: &mut VALUE) -> BOOL
373/// {
374/// sciter::set_host_api(api);
375///
376/// unimplemented!("export some extension functions");
377///
378/// true as BOOL
379/// }
380/// ```
381///
382/// In script such extension library can be imported as:
383///
384/// ```javascript
385/// const exported = include library "library-name";
386/// ```
387///
388/// See the [blog post](https://sciter.com/include-library-name-native-extensions/) for more details.
389///
390pub type SciterLibraryInit = extern "system" fn (api: &'static ISciterAPI, exported: &mut VALUE) -> BOOL;