Struct Host

Source
pub struct Host { /* private fields */ }
Expand description

Sciter host runtime support.

Implementations§

Source§

impl Host

Source

pub fn attach(hwnd: HWINDOW) -> Host

Attach Sciter host to an existing window.

Usually Sciter window is created by sciter::Window::create(), but you can attach Sciter to an existing native window. In this case you need to mix-in window events processing with SciterProcND (Windows only). Sciter engine will be initialized either on WM_CREATE or WM_INITDIALOG response or by calling SciterCreateOnDirectXWindow (again, Windows only).

Source

pub fn attach_with<Handler: HostHandler>( hwnd: HWINDOW, handler: Handler, ) -> Host

Attach Sciter host to an existing window with the given Host handler.

Source

pub fn event_handler<Handler: EventHandler>(&self, handler: Handler)

Attach dom::EventHandler to the Sciter window.

Source

pub fn register_behavior<Factory>(&self, name: &str, factory: Factory)
where Factory: Fn() -> Box<dyn EventHandler> + 'static,

Register a native event handler for the specified behavior name.

See the Window::register_behavior for an example.

Source

pub fn register_archive(&self, resource: &[u8]) -> Result<()>

Register an archive produced by packfolder.

See documentation of the Archive.

Source

pub fn enable_debug(&self, enable: bool)

Set debug mode for this window.

Source

pub fn get_hwnd(&self) -> HWINDOW

Get native window handle.

Source

pub fn get_root(&self) -> Option<Element>

Get window root DOM element.

Source

pub fn load_file(&self, uri: &str) -> bool

Load an HTML document from file.

Source

pub fn load_html(&self, html: &[u8], uri: Option<&str>) -> bool

Load an HTML document from memory.

Source

pub fn data_ready(&self, uri: &str, data: &[u8])

This function is used as response to HostHandler::on_data_load request.

Source

pub fn data_ready_async( &self, uri: &str, data: &[u8], request_id: Option<HREQUEST>, )

Use this function outside of HostHandler::on_data_load request.

It can be used for two purposes:

  1. Asynchronious resource loading in respect of on_data_load requests (you must use request_id in this case).
  2. Refresh of an already loaded resource (for example, dynamic image updates).
Source

pub fn eval_script(&self, script: &str) -> Result<Value, Value>

Evaluate the given script in context of the current document.

This function returns Result<Value,Value> with script function result value or with Sciter script error.

Source

pub fn call_function(&self, name: &str, args: &[Value]) -> Result<Value, Value>

Call a script function defined in the global namespace.

This function returns Result<Value,Value> with script function result value or with Sciter script error.

You can use the &make_args!(args...) macro which helps you to construct script arguments from Rust types.

Source

pub fn set_home_url(&self, url: &str) -> Result<()>

Set home url for Sciter resources.

If you set it like set_home_url("https://sciter.com/modules/") then

<script src="sciter:lib/root-extender.tis"> will load root-extender.tis from

https://sciter.com/modules/lib/root-extender.tis.

Source

pub fn set_media_type(&self, media_type: &str) -> Result<()>

Set media type of this Sciter instance.

For example, media type can be “handheld”, “projection”, “screen”, “screen-hires”, etc. By default, Sciter window has the "screen" media type.

Media type name is used while loading and parsing style sheets in the engine, so you should call this function before loading document in it.

Source

pub fn set_media_vars(&self, media: &Value) -> Result<()>

Set media variables (dictionary) for this Sciter instance.

By default Sciter window has "screen:true" and "desktop:true"/"handheld:true" media variables.

Media variables can be changed in runtime. This will cause styles of the document to be reset.

§Example
host.set_media_vars( &vmap! {
  "screen" => true,
  "handheld" => true,
}).unwrap();
Source

pub fn set_master_css(&self, css: &str, append: bool) -> Result<()>

Set or append the master style sheet styles (globally, for all windows).

Source

pub fn set_window_css( &self, css: &str, base_url: &str, media_type: &str, ) -> Result<()>

Set (reset) style sheet of the current document.

Will reset styles for all elements according to given CSS.

Auto Trait Implementations§

§

impl !Freeze for Host

§

impl !RefUnwindSafe for Host

§

impl !Send for Host

§

impl !Sync for Host

§

impl Unpin for Host

§

impl !UnwindSafe for Host

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.