From 66278829f2942ac9526146e1bc3e9f441dad9c65 Mon Sep 17 00:00:00 2001 From: pravic Date: Sun, 25 Apr 2021 23:00:43 +0300 Subject: [PATCH 1/4] Sciter 4.4.7.0 headers. --- include/sciter-om-def.h | 271 ++++++++++++----- include/sciter-om.h | 83 +++-- include/sciter-x-api.h | 583 +++++++++++++++++++++++++++++++----- include/sciter-x-behavior.h | 284 ++++++++---------- include/sciter-x-debug.h | 15 +- include/sciter-x-def.h | 266 ++++++++-------- include/sciter-x-dom.h | 114 +++---- include/sciter-x-graphics.h | 42 +-- include/sciter-x-msg.h | 55 ++-- include/sciter-x-types.h | 81 ++--- include/sciter-x-value.h | 8 +- include/sciter-x.h | 67 +++-- include/value.h | 76 ++--- 13 files changed, 1266 insertions(+), 679 deletions(-) diff --git a/include/sciter-om-def.h b/include/sciter-om-def.h index 1b511a0..a59ccd4 100644 --- a/include/sciter-om-def.h +++ b/include/sciter-om-def.h @@ -19,17 +19,17 @@ UINT64 SCAPI SciterAtomValue(const char* name); UINT64 SCAPI SciterAtomNameCB(UINT64 atomv, LPCSTR_RECEIVER* rcv, LPVOID rcv_param); -typedef BOOL(*som_prop_getter_t)(som_asset_t* thing, SOM_VALUE* p_value); -typedef BOOL(*som_prop_setter_t)(som_asset_t* thing, const SOM_VALUE* p_value); -typedef BOOL(*som_item_getter_t)(som_asset_t* thing, const SOM_VALUE* p_key, SOM_VALUE* p_value); -typedef BOOL(*som_item_setter_t)(som_asset_t* thing, const SOM_VALUE* p_key, const SOM_VALUE* p_value); -typedef BOOL(*som_item_next_t)(som_asset_t* thing, SOM_VALUE* p_idx /*in/out*/, SOM_VALUE* p_value); -typedef BOOL(*som_any_prop_getter_t)(som_asset_t* thing, UINT64 propSymbol, SOM_VALUE* p_value); -typedef BOOL(*som_any_prop_setter_t)(som_asset_t* thing, UINT64 propSymbol, const SOM_VALUE* p_value); -typedef BOOL(*som_method_t)(som_asset_t* thing, UINT argc, const SOM_VALUE* argv, SOM_VALUE* p_result); +typedef SBOOL(*som_prop_getter_t)(som_asset_t* thing, SOM_VALUE* p_value); +typedef SBOOL(*som_prop_setter_t)(som_asset_t* thing, const SOM_VALUE* p_value); +typedef SBOOL(*som_item_getter_t)(som_asset_t* thing, const SOM_VALUE* p_key, SOM_VALUE* p_value); +typedef SBOOL(*som_item_setter_t)(som_asset_t* thing, const SOM_VALUE* p_key, const SOM_VALUE* p_value); +typedef SBOOL(*som_item_next_t)(som_asset_t* thing, SOM_VALUE* p_idx /*in/out*/, SOM_VALUE* p_value); +typedef SBOOL(*som_any_prop_getter_t)(som_asset_t* thing, UINT64 propSymbol, SOM_VALUE* p_value); +typedef SBOOL(*som_any_prop_setter_t)(som_asset_t* thing, UINT64 propSymbol, const SOM_VALUE* p_value); +typedef SBOOL(*som_method_t)(som_asset_t* thing, UINT argc, const SOM_VALUE* argv, SOM_VALUE* p_result); typedef void(*som_dispose_t)(som_asset_t* thing); -typedef struct som_property_def_t { +struct som_property_def_t { void* reserved; som_atom_t name; som_prop_getter_t getter; @@ -37,9 +37,9 @@ typedef struct som_property_def_t { #ifdef __cplusplus som_property_def_t(const char* n, som_prop_getter_t pg, som_prop_setter_t ps = nullptr) : name(SciterAtomValue(n)), getter(pg), setter(ps) {} #endif -} som_property_def_t; +}; -typedef struct som_method_def_t { +struct som_method_def_t { void* reserved; som_atom_t name; size_t params; @@ -47,16 +47,16 @@ typedef struct som_method_def_t { #ifdef __cplusplus som_method_def_t(const char* n, size_t p, som_method_t f) : name(SciterAtomValue(n)), params(p), func(f) {} #endif -} som_method_def_t; +}; -typedef enum som_passport_flags { +enum som_passport_flags { SOM_SEALED_OBJECT = 0x00, // not extendable SOM_EXTENDABLE_OBJECT = 0x01 // extendable, asset may have new properties added -} som_passport_flags; +}; // definiton of object (the thing) access interface // this structure should be statically allocated - at least survive last instance of the engine -typedef struct som_passport_t { +struct som_passport_t { UINT64 flags; som_atom_t name; // class name const som_property_def_t* properties; size_t n_properties; // virtual property thunks @@ -67,7 +67,7 @@ typedef struct som_passport_t { // any property "inteceptors" som_any_prop_getter_t prop_getter; // var prop_val = thing.k; som_any_prop_setter_t prop_setter; // thing.k = prop_val; -} som_passport_t; +}; #ifdef CPP11 @@ -148,9 +148,9 @@ namespace sciter { template struct member_property { - static BOOL getter(som_asset_t* thing, SOM_VALUE* p_value) + static SBOOL getter(som_asset_t* thing, SOM_VALUE* p_value) { *p_value = SOM_VALUE((static_cast(thing)->*M)); return TRUE; } - static BOOL setter(som_asset_t* thing, const SOM_VALUE* p_value) + static SBOOL setter(som_asset_t* thing, const SOM_VALUE* p_value) { static_cast(thing)->*M = p_value->get(); return TRUE; } }; @@ -159,111 +159,271 @@ namespace sciter { template struct member_function { enum { n_params = 0 }; - template static BOOL thunk(som_asset_t* thing, UINT argc, const SOM_VALUE* argv, SOM_VALUE* p_result) + template static SBOOL thunk(som_asset_t* thing, UINT argc, const SOM_VALUE* argv, SOM_VALUE* p_result) { try { *p_result = SOM_VALUE((static_cast(thing)->*Func)()); return TRUE; } catch (exception& e) { *p_result = SOM_VALUE::make_error(e.what()); return TRUE; } } }; + template + struct member_function { + enum { n_params = 0 }; + template static SBOOL thunk(som_asset_t* thing, UINT argc, const SOM_VALUE* argv, SOM_VALUE* p_result) + { + try { (static_cast(thing)->*Func)(); *p_result = SOM_VALUE(); return TRUE; } + catch (exception& e) { *p_result = SOM_VALUE::make_error(e.what()); return TRUE; } + } + }; + template struct member_function { enum { n_params = 1 }; - template static BOOL thunk(som_asset_t* thing, UINT argc, const SOM_VALUE* argv, SOM_VALUE* p_result) + template static SBOOL thunk(som_asset_t* thing, UINT argc, const SOM_VALUE* argv, SOM_VALUE* p_result) { try { *p_result = SOM_VALUE((static_cast(thing)->*Func)(argv[0].get())); return TRUE; } catch (exception& e) { *p_result = SOM_VALUE::make_error(e.what()); return TRUE; } } }; + template + struct member_function { + enum { n_params = 1 }; + template static SBOOL thunk(som_asset_t* thing, UINT argc, const SOM_VALUE* argv, SOM_VALUE* p_result) + { + try { (static_cast(thing)->*Func)(argv[0].get()); *p_result = SOM_VALUE(); return TRUE; } + catch (exception& e) { *p_result = SOM_VALUE::make_error(e.what()); return TRUE; } + } + }; + template struct member_function { enum { n_params = 2 }; - template static BOOL thunk(som_asset_t* thing, UINT argc, const SOM_VALUE* argv, SOM_VALUE* p_result) + template static SBOOL thunk(som_asset_t* thing, UINT argc, const SOM_VALUE* argv, SOM_VALUE* p_result) { try { *p_result = SOM_VALUE((static_cast(thing)->*Func)(argv[0].get(), argv[1].get())); return TRUE; } catch (exception& e) { *p_result = SOM_VALUE::make_error(e.what()); return TRUE; } } }; + template + struct member_function { + enum { n_params = 2 }; + template static SBOOL thunk(som_asset_t* thing, UINT argc, const SOM_VALUE* argv, SOM_VALUE* p_result) + { + try { (static_cast(thing)->*Func)(argv[0].get(), argv[1].get()); *p_result = SOM_VALUE(); return TRUE; } + catch (exception& e) { *p_result = SOM_VALUE::make_error(e.what()); return TRUE; } + } + }; + template struct member_function { enum { n_params = 3 }; - template static BOOL thunk(som_asset_t* thing, UINT argc, const SOM_VALUE* argv, SOM_VALUE* p_result) + template static SBOOL thunk(som_asset_t* thing, UINT argc, const SOM_VALUE* argv, SOM_VALUE* p_result) { try { *p_result = SOM_VALUE((static_cast(thing)->*Func)(argv[0].get(), argv[1].get(), argv[2].get())); return TRUE; } catch (exception& e) { *p_result = SOM_VALUE::make_error(e.what()); return TRUE; } } }; + template + struct member_function { + enum { n_params = 3 }; + template static SBOOL thunk(som_asset_t* thing, UINT argc, const SOM_VALUE* argv, SOM_VALUE* p_result) + { + try { (static_cast(thing)->*Func)(argv[0].get(), argv[1].get(), argv[2].get()); *p_result = SOM_VALUE(); return TRUE; } + catch (exception& e) { *p_result = SOM_VALUE::make_error(e.what()); return TRUE; } + } + }; + template struct member_function { enum { n_params = 4 }; - template static BOOL thunk(som_asset_t* thing, UINT argc, const SOM_VALUE* argv, SOM_VALUE* p_result) + template static SBOOL thunk(som_asset_t* thing, UINT argc, const SOM_VALUE* argv, SOM_VALUE* p_result) { try { *p_result = SOM_VALUE((static_cast(thing)->*Func)(argv[0].get(), argv[1].get(), argv[2].get(), argv[3].get())); return TRUE; } catch (exception& e) { *p_result = SOM_VALUE::make_error(e.what()); return TRUE; } } }; - // func() const variants of the above - template + template + struct member_function { + enum { n_params = 4 }; + template static SBOOL thunk(som_asset_t* thing, UINT argc, const SOM_VALUE* argv, SOM_VALUE* p_result) + { + try { (static_cast(thing)->*Func)(argv[0].get(), argv[1].get(), argv[2].get(), argv[3].get()); *p_result = SOM_VALUE(); return TRUE; } + catch (exception& e) { *p_result = SOM_VALUE::make_error(e.what()); return TRUE; } + } + }; + + template + struct member_function { + enum { n_params = 5 }; + template static SBOOL thunk(som_asset_t* thing, UINT argc, const SOM_VALUE* argv, SOM_VALUE* p_result) + { + try { *p_result = SOM_VALUE((static_cast(thing)->*Func)(argv[0].get(), argv[1].get(), argv[2].get(), argv[3].get(), argv[4].get())); return TRUE; } + catch (exception& e) { *p_result = SOM_VALUE::make_error(e.what()); return TRUE; } + } + }; + + template + struct member_function { + enum { n_params = 5 }; + template static SBOOL thunk(som_asset_t* thing, UINT argc, const SOM_VALUE* argv, SOM_VALUE* p_result) + { + try { (static_cast(thing)->*Func)(argv[0].get(), argv[1].get(), argv[2].get(), argv[3].get(), argv[4].get()); *p_result = SOM_VALUE(); return TRUE; } + catch (exception& e) { *p_result = SOM_VALUE::make_error(e.what()); return TRUE; } + } + }; + + template + struct member_function { + enum { n_params = 6 }; + template static SBOOL thunk(som_asset_t* thing, UINT argc, const SOM_VALUE* argv, SOM_VALUE* p_result) + { + try { *p_result = SOM_VALUE((static_cast(thing)->*Func)(argv[0].get(), argv[1].get(), argv[2].get(), argv[3].get(), argv[4].get(), argv[5].get())); return TRUE; } + catch (exception& e) { *p_result = SOM_VALUE::make_error(e.what()); return TRUE; } + } + }; + + template + struct member_function { + enum { n_params = 6 }; + template static SBOOL thunk(som_asset_t* thing, UINT argc, const SOM_VALUE* argv, SOM_VALUE* p_result) + { + try { (static_cast(thing)->*Func)(argv[0].get(), argv[1].get(), argv[2].get(), argv[3].get(), argv[4].get(), argv[5].get()); *p_result = SOM_VALUE(); return TRUE; } + catch (exception& e) { *p_result = SOM_VALUE::make_error(e.what()); return TRUE; } + } + }; + + + // func() const variants of the above + template struct member_function { enum { n_params = 0 }; - template static BOOL thunk(som_asset_t* thing, UINT argc, const SOM_VALUE* argv, SOM_VALUE* p_result) + template static SBOOL thunk(som_asset_t* thing, UINT argc, const SOM_VALUE* argv, SOM_VALUE* p_result) { try { *p_result = SOM_VALUE((static_cast(thing)->*Func)()); return TRUE; } catch (exception& e) { *p_result = SOM_VALUE::make_error(e.what()); return TRUE; } } }; - template + template + struct member_function { + enum { n_params = 0 }; + template static SBOOL thunk(som_asset_t* thing, UINT argc, const SOM_VALUE* argv, SOM_VALUE* p_result) + { + try { (static_cast(thing)->*Func)(); *p_result = SOM_VALUE(); return TRUE; } + catch (exception& e) { *p_result = SOM_VALUE::make_error(e.what()); return TRUE; } + } + }; + + template struct member_function { enum { n_params = 1 }; - template static BOOL thunk(som_asset_t* thing, UINT argc, const SOM_VALUE* argv, SOM_VALUE* p_result) + template static SBOOL thunk(som_asset_t* thing, UINT argc, const SOM_VALUE* argv, SOM_VALUE* p_result) { try { *p_result = SOM_VALUE((static_cast(thing)->*Func)(argv[0].get())); return TRUE; } catch (exception& e) { *p_result = SOM_VALUE::make_error(e.what()); return TRUE; } } }; - template + template + struct member_function { + enum { n_params = 1 }; + template static SBOOL thunk(som_asset_t* thing, UINT argc, const SOM_VALUE* argv, SOM_VALUE* p_result) + { + try { (static_cast(thing)->*Func)(argv[0].get()); *p_result = SOM_VALUE(); return TRUE; } + catch (exception& e) { *p_result = SOM_VALUE::make_error(e.what()); return TRUE; } + } + }; + + template struct member_function { enum { n_params = 2 }; - template static BOOL thunk(som_asset_t* thing, UINT argc, const SOM_VALUE* argv, SOM_VALUE* p_result) + template static SBOOL thunk(som_asset_t* thing, UINT argc, const SOM_VALUE* argv, SOM_VALUE* p_result) { try { *p_result = SOM_VALUE((static_cast(thing)->*Func)(argv[0].get(), argv[1].get())); return TRUE; } catch (exception& e) { *p_result = SOM_VALUE::make_error(e.what()); return TRUE; } } }; - template + template + struct member_function { + enum { n_params = 2 }; + template static SBOOL thunk(som_asset_t* thing, UINT argc, const SOM_VALUE* argv, SOM_VALUE* p_result) + { + try { (static_cast(thing)->*Func)(argv[0].get(), argv[1].get()); *p_result = SOM_VALUE(); return TRUE; } + catch (exception& e) { *p_result = SOM_VALUE::make_error(e.what()); return TRUE; } + } + }; + + template struct member_function { enum { n_params = 3 }; - template static BOOL thunk(som_asset_t* thing, UINT argc, const SOM_VALUE* argv, SOM_VALUE* p_result) + template static SBOOL thunk(som_asset_t* thing, UINT argc, const SOM_VALUE* argv, SOM_VALUE* p_result) { try { *p_result = SOM_VALUE((static_cast(thing)->*Func)(argv[0].get(), argv[1].get(), argv[2].get())); return TRUE; } catch (exception& e) { *p_result = SOM_VALUE::make_error(e.what()); return TRUE; } } }; - template + template + struct member_function { + enum { n_params = 3 }; + template static SBOOL thunk(som_asset_t* thing, UINT argc, const SOM_VALUE* argv, SOM_VALUE* p_result) + { + try { (static_cast(thing)->*Func)(argv[0].get(), argv[1].get(), argv[2].get()); *p_result = SOM_VALUE(); return TRUE; } + catch (exception& e) { *p_result = SOM_VALUE::make_error(e.what()); return TRUE; } + } + }; + + template struct member_function { enum { n_params = 4 }; - template static BOOL thunk(som_asset_t* thing, UINT argc, const SOM_VALUE* argv, SOM_VALUE* p_result) + template static SBOOL thunk(som_asset_t* thing, UINT argc, const SOM_VALUE* argv, SOM_VALUE* p_result) { try { *p_result = SOM_VALUE((static_cast(thing)->*Func)(argv[0].get(), argv[1].get(), argv[2].get(), argv[3].get())); return TRUE; } catch (exception& e) { *p_result = SOM_VALUE::make_error(e.what()); return TRUE; } } }; + template + struct member_function { + enum { n_params = 4 }; + template static SBOOL thunk(som_asset_t* thing, UINT argc, const SOM_VALUE* argv, SOM_VALUE* p_result) + { + try { (static_cast(thing)->*Func)(argv[0].get(), argv[1].get(), argv[2].get(), argv[3].get()); *p_result = SOM_VALUE(); return TRUE; } + catch (exception& e) { *p_result = SOM_VALUE::make_error(e.what()); return TRUE; } + } + }; + + template + struct member_function { + enum { n_params = 5 }; + template static SBOOL thunk(som_asset_t* thing, UINT argc, const SOM_VALUE* argv, SOM_VALUE* p_result) + { + try { *p_result = SOM_VALUE((static_cast(thing)->*Func)(argv[0].get(), argv[1].get(), argv[2].get(), argv[3].get(), argv[4].get())); return TRUE; } + catch (exception& e) { *p_result = SOM_VALUE::make_error(e.what()); return TRUE; } + } + }; + + template + struct member_function { + enum { n_params = 5 }; + template static SBOOL thunk(som_asset_t* thing, UINT argc, const SOM_VALUE* argv, SOM_VALUE* p_result) + { + try { (static_cast(thing)->*Func)(argv[0].get(), argv[1].get(), argv[2].get(), argv[3].get(), argv[4].get()); *p_result = SOM_VALUE(); return TRUE; } + catch (exception& e) { *p_result = SOM_VALUE::make_error(e.what()); return TRUE; } + } + }; template struct item_set_accessor; template struct item_set_accessor { template - static BOOL thunk(som_asset_t* thing, const SOM_VALUE* p_key, const SOM_VALUE* p_value) + static SBOOL thunk(som_asset_t* thing, const SOM_VALUE* p_key, const SOM_VALUE* p_value) { return (static_cast(thing)->*Func)(p_key->get(), p_value->get()) ? TRUE : FALSE; }}; template struct item_get_accessor; @@ -272,7 +432,7 @@ namespace sciter { template struct item_get_accessor { template - static BOOL thunk(som_asset_t* thing, const SOM_VALUE* p_key, SOM_VALUE* p_value) + static SBOOL thunk(som_asset_t* thing, const SOM_VALUE* p_key, SOM_VALUE* p_value) { typename std::remove_reference::type val; if ((static_cast(thing)->*Func)(p_key->get(), val)) { @@ -287,7 +447,7 @@ namespace sciter { template struct item_get_accessor { template - static BOOL thunk(som_asset_t* thing, const SOM_VALUE* p_key, SOM_VALUE* p_value) + static SBOOL thunk(som_asset_t* thing, const SOM_VALUE* p_key, SOM_VALUE* p_value) { typename std::remove_reference::type val; if ((static_cast(thing)->*Func)(p_key->get(), val)) { @@ -304,7 +464,7 @@ namespace sciter { struct item_next_accessor { template - static BOOL thunk(som_asset_t* thing, SOM_VALUE* p_index, SOM_VALUE* p_value) + static SBOOL thunk(som_asset_t* thing, SOM_VALUE* p_index, SOM_VALUE* p_value) { typedef typename std::remove_reference::type TIndex; typedef typename std::remove_reference::type TVal; @@ -324,7 +484,7 @@ namespace sciter { template struct member_getter_function { - template static BOOL thunk(som_asset_t* thing, SOM_VALUE* p_value) + template static SBOOL thunk(som_asset_t* thing, SOM_VALUE* p_value) { try { *p_value = SOM_VALUE((static_cast(thing)->*Func)()); return TRUE; } catch (exception& e) { *p_value = SOM_VALUE::make_error(e.what()); return TRUE; } @@ -333,7 +493,7 @@ namespace sciter { template struct member_getter_function { - template static BOOL thunk(som_asset_t* thing, SOM_VALUE* p_value) + template static SBOOL thunk(som_asset_t* thing, SOM_VALUE* p_value) { //try { *p_value = SOM_VALUE((static_cast(thing)->*Func)()); return TRUE; } //catch (exception& e) { *p_value = SOM_VALUE::make_error(e.what()); return TRUE; } @@ -344,7 +504,7 @@ namespace sciter { template struct member_setter_function { - template static BOOL thunk(som_asset_t* thing, const SOM_VALUE* p_value) + template static SBOOL thunk(som_asset_t* thing, const SOM_VALUE* p_value) { //try { bool r = (static_cast(thing)->*Func)(p_value->get()); return r; } //catch (exception& e) { *p_value = SOM_VALUE::make_error(e.what()); return TRUE; } @@ -361,48 +521,25 @@ namespace sciter { template struct prop_set_accessor; - // bool set_any_prop(som_atom_t name, TV val); - template - struct prop_set_accessor { - template - static BOOL thunk(som_asset_t* thing, som_atom_t name, const SOM_VALUE* p_value) - { - return (static_cast(thing)->*Func)(name, p_value->get()) ? TRUE : FALSE; - } - }; // bool set_any_prop(const std::string& name, TV val); template struct prop_set_accessor { template - static BOOL thunk(som_asset_t* thing, UINT64 name, const SOM_VALUE* p_value) + static SBOOL thunk(som_asset_t* thing, som_atom_t name, const SOM_VALUE* p_value) { return (static_cast(thing)->*Func)(atom_name(name), p_value->get()) ? TRUE : FALSE; } }; template struct prop_get_accessor; - - // bool get_any_prop(som_atom_t name, TV& val); - template - struct prop_get_accessor { - template - static BOOL thunk(som_asset_t* thing, som_atom_t name, SOM_VALUE* p_value) - { - typename std::remove_reference::type val; - if ((static_cast(thing)->*Func)(name, val)) { - *p_value = SOM_VALUE(val); - return TRUE; - } - return FALSE; - } - }; + // bool get_any_prop(const std::string& name, TV& val); template struct prop_get_accessor { template - static BOOL thunk(som_asset_t* thing, som_atom_t name, SOM_VALUE* p_value) + static SBOOL thunk(som_asset_t* thing, som_atom_t name, SOM_VALUE* p_value) { typename std::remove_reference::type val; if ((static_cast(thing)->*Func)(atom_name(name), val)) { diff --git a/include/sciter-om.h b/include/sciter-om.h index b7eb619..de63201 100644 --- a/include/sciter-om.h +++ b/include/sciter-om.h @@ -1,37 +1,55 @@ #pragma once -#include -#include +#ifndef __SCITER_OM_H__ +#define __SCITER_OM_H__ + struct som_passport_t; typedef UINT64 som_atom_t; - -struct som_asset_class_t; - -typedef struct som_asset_t { - struct som_asset_class_t* isa; -} som_asset_t; +struct som_asset_t; struct som_asset_class_t { long(*asset_add_ref)(som_asset_t* thing); long(*asset_release)(som_asset_t* thing); long(*asset_get_interface)(som_asset_t* thing, const char* name, void** out); - struct som_passport_t* (*asset_get_passport)(som_asset_t* thing); + som_passport_t* (*asset_get_passport)(som_asset_t* thing); +}; + +struct som_asset_t { + som_asset_class_t* isa; }; +inline som_asset_class_t* som_asset_get_class(const som_asset_t* pass) +{ + return pass ? pass->isa : nullptr; +} + +som_atom_t SCAPI SciterAtomValue(const char* name); #ifdef CPP11 +#include +#include #include namespace sciter { + class atom { + som_atom_t _atom; + public: + atom(const char* name) { _atom = SciterAtomValue(name); } + atom(const atom& other) { _atom = other._atom; } + operator som_atom_t() const { return _atom; } + }; + namespace om { template class hasset; + // implementation of som_asset_t ISA + // note: does not define asset_add_ref()/asset_release() as they shall be defined in specializations template class iasset : public som_asset_t { @@ -47,8 +65,8 @@ namespace sciter { if (out) { this->asset_add_ref(); *out = this; } return true; } - virtual som_passport_t* asset_get_passport() const { - return nullptr; + virtual som_passport_t* asset_get_passport() const { + return nullptr; } static som_asset_class_t* get_asset_class() { @@ -69,8 +87,7 @@ namespace sciter { static const char* interface_name() { return "asset.sciter.com"; } //template hasset interface_of() { hasset p; get_interface(C::interface_name(), p.target()); return p; } }; - - + inline long asset_add_ref(som_asset_t *ptr) { assert(ptr); assert(ptr->isa); @@ -89,7 +106,7 @@ namespace sciter { assert(ptr->isa->asset_get_interface); return ptr->isa->asset_get_interface(ptr, name, out); } - + inline som_passport_t* asset_get_passport(som_asset_t *ptr) { assert(ptr); assert(ptr->isa); @@ -97,8 +114,13 @@ namespace sciter { return ptr->isa->asset_get_passport(ptr); } + inline som_asset_class_t* asset_get_class(som_asset_t *ptr) { + assert(ptr); + return ptr->isa; + } + //hasset - yet another shared_ptr - // R here is something derived from the iasset (om::iasset) above + // R here is an entity derived from som_asset_t template class hasset { protected: @@ -108,10 +130,10 @@ namespace sciter { typedef R asset_t; hasset() :p(nullptr) {} - hasset(R* lp) :p(nullptr) { if (lp) (p = lp)->asset_add_ref(); } - hasset(const hasset& cp) :p(nullptr) { if (cp.p) (p = cp.p)->asset_add_ref(); } + hasset(R* lp) :p(nullptr) { if (lp) asset_add_ref(p = lp); } + hasset(const hasset& cp) :p(nullptr) { if (cp.p) asset_add_ref(p = cp.p); } - ~hasset() { if (p) p->asset_release(); } + ~hasset() { if (p) asset_release(p); } operator R*() const { return p; } R* operator->() const { assert(p != 0); return p; } @@ -121,7 +143,7 @@ namespace sciter { bool operator==(R* pR) const { return p == pR; } // release the interface and set it to NULL - void release() { if (p) { R* pt = p; p = 0; pt->asset_release(); } } + void release() { if (p) { R* pt = p; p = 0; asset_release(pt); } } // attach to an existing interface (does not AddRef) void attach(R* p2) { asset_release(p); p = p2; } @@ -130,8 +152,8 @@ namespace sciter { static R* assign(R* &pp, R* lp) { - if (lp != 0) lp->asset_add_ref(); - if (pp) pp->asset_release(); + if (lp != 0) asset_add_ref(lp); + if (pp) asset_release(pp); pp = lp; return lp; } @@ -142,11 +164,9 @@ namespace sciter { void** target() { release(); return (void**)&p; } }; - - - // intrusive add_ref/release counter - - template + + // reference counted asset, uses intrusive add_ref/release counter + template class asset : public iasset> { std::atomic _ref_cntr; @@ -179,11 +199,20 @@ namespace sciter { delete static_cast(this); } }; + } - + template + inline AT* value::get_asset() const { + som_asset_t* pass = get_asset(); + if (pass && (som_asset_get_class(pass) == AT::get_asset_class())) + return static_cast(pass); + return nullptr; } + } #endif #include "sciter-om-def.h" + +#endif \ No newline at end of file diff --git a/include/sciter-x-api.h b/include/sciter-x-api.h index d80801e..517e4e0 100644 --- a/include/sciter-x-api.h +++ b/include/sciter-x-api.h @@ -18,7 +18,6 @@ #include "sciter-x-request.h" #include "sciter-x-msg.h" #include "value.h" -#include "tiscript.h" #if !defined(WINDOWS) #include @@ -43,59 +42,71 @@ struct SciterGraphicsAPI; struct SCITER_X_MSG; #ifdef WINDOWLESS - #define SCITER_API_VERSION 0x10005 + #define SCITER_API_VERSION 0x10009 #else - #define SCITER_API_VERSION 5 -#endif // !WINDOWLESS + #define SCITER_API_VERSION 9 +#endif typedef struct _ISciterAPI { UINT version; // API_VERSION LPCWSTR SCFN( SciterClassName )(void); - UINT SCFN( SciterVersion )(BOOL major); - BOOL SCFN( SciterDataReady )(HWINDOW hwnd,LPCWSTR uri,LPCBYTE data, UINT dataLength); - BOOL SCFN( SciterDataReadyAsync )(HWINDOW hwnd,LPCWSTR uri, LPCBYTE data, UINT dataLength, LPVOID requestId); -#if defined(WINDOWS) && !defined(WINDOWLESS) + UINT SCFN( SciterVersion )(SBOOL major); + SBOOL SCFN( SciterDataReady )(HWINDOW hwnd,LPCWSTR uri,LPCBYTE data, UINT dataLength); + SBOOL SCFN( SciterDataReadyAsync )(HWINDOW hwnd,LPCWSTR uri, LPCBYTE data, UINT dataLength, LPVOID requestId); +#if defined(WINDOWS) LRESULT SCFN( SciterProc )(HWINDOW hwnd, UINT msg, WPARAM wParam, LPARAM lParam); - LRESULT SCFN( SciterProcND )(HWINDOW hwnd, UINT msg, WPARAM wParam, LPARAM lParam, BOOL* pbHandled); + LRESULT SCFN( SciterProcND )(HWINDOW hwnd, UINT msg, WPARAM wParam, LPARAM lParam, SBOOL* pbHandled); +#else + LPVOID SciterProc; // NULL + LPVOID SciterProcND; // NULL #endif - BOOL SCFN( SciterLoadFile )(HWINDOW hWndSciter, LPCWSTR filename); - - BOOL SCFN( SciterLoadHtml )(HWINDOW hWndSciter, LPCBYTE html, UINT htmlSize, LPCWSTR baseUrl); - VOID SCFN( SciterSetCallback )(HWINDOW hWndSciter, LPSciterHostCallback cb, LPVOID cbParam); - BOOL SCFN( SciterSetMasterCSS )(LPCBYTE utf8, UINT numBytes); - BOOL SCFN( SciterAppendMasterCSS )(LPCBYTE utf8, UINT numBytes); - BOOL SCFN( SciterSetCSS )(HWINDOW hWndSciter, LPCBYTE utf8, UINT numBytes, LPCWSTR baseUrl, LPCWSTR mediaType); - BOOL SCFN( SciterSetMediaType )(HWINDOW hWndSciter, LPCWSTR mediaType); - BOOL SCFN( SciterSetMediaVars )(HWINDOW hWndSciter, const SCITER_VALUE *mediaVars); - UINT SCFN( SciterGetMinWidth )(HWINDOW hWndSciter); - UINT SCFN( SciterGetMinHeight )(HWINDOW hWndSciter, UINT width); - BOOL SCFN( SciterCall )(HWINDOW hWnd, LPCSTR functionName, UINT argc, const SCITER_VALUE* argv, SCITER_VALUE* retval); - BOOL SCFN( SciterEval )( HWINDOW hwnd, LPCWSTR script, UINT scriptLength, SCITER_VALUE* pretval); - VOID SCFN( SciterUpdateWindow)(HWINDOW hwnd); -#if defined(WINDOWS) && !defined(WINDOWLESS) - BOOL SCFN( SciterTranslateMessage )(MSG* lpMsg); + SBOOL SCFN( SciterLoadFile )(HWINDOW hWndSciter, LPCWSTR filename); + + SBOOL SCFN( SciterLoadHtml )(HWINDOW hWndSciter, LPCBYTE html, UINT htmlSize, LPCWSTR baseUrl); + VOID SCFN( SciterSetCallback )(HWINDOW hWndSciter, LPSciterHostCallback cb, LPVOID cbParam); + SBOOL SCFN( SciterSetMasterCSS )(LPCBYTE utf8, UINT numBytes); + SBOOL SCFN( SciterAppendMasterCSS )(LPCBYTE utf8, UINT numBytes); + SBOOL SCFN( SciterSetCSS )(HWINDOW hWndSciter, LPCBYTE utf8, UINT numBytes, LPCWSTR baseUrl, LPCWSTR mediaType); + SBOOL SCFN( SciterSetMediaType )(HWINDOW hWndSciter, LPCWSTR mediaType); + SBOOL SCFN( SciterSetMediaVars )(HWINDOW hWndSciter, const SCITER_VALUE *mediaVars); + UINT SCFN( SciterGetMinWidth )(HWINDOW hWndSciter); + UINT SCFN( SciterGetMinHeight )(HWINDOW hWndSciter, UINT width); + SBOOL SCFN( SciterCall )(HWINDOW hWnd, LPCSTR functionName, UINT argc, const SCITER_VALUE* argv, SCITER_VALUE* retval); + SBOOL SCFN( SciterEval )( HWINDOW hwnd, LPCWSTR script, UINT scriptLength, SCITER_VALUE* pretval); + VOID SCFN( SciterUpdateWindow)(HWINDOW hwnd); +#if defined(WINDOWS) + SBOOL SCFN(SciterTranslateMessage)(MSG* lpMsg); +#else + LPVOID SciterTranslateMessage; // NULL #endif - BOOL SCFN( SciterSetOption )(HWINDOW hWnd, UINT option, UINT_PTR value ); - VOID SCFN( SciterGetPPI )(HWINDOW hWndSciter, UINT* px, UINT* py); - BOOL SCFN( SciterGetViewExpando )( HWINDOW hwnd, VALUE* pval ); -#if defined(WINDOWS) && !defined(WINDOWLESS) - BOOL SCFN( SciterRenderD2D )(HWINDOW hWndSciter, IUnknown* /*ID2D1RenderTarget**/ prt); - BOOL SCFN( SciterD2DFactory )(void** /*ID2D1Factory ***/ ppf); - BOOL SCFN( SciterDWFactory )(void** /*IDWriteFactory ***/ ppf); + SBOOL SCFN( SciterSetOption )(HWINDOW hWnd, UINT option, UINT_PTR value ); + VOID SCFN( SciterGetPPI )(HWINDOW hWndSciter, UINT* px, UINT* py); + SBOOL SCFN( SciterGetViewExpando )( HWINDOW hwnd, VALUE* pval ); +#if defined(WINDOWS) + SBOOL SCFN( SciterRenderD2D )(HWINDOW hWndSciter, IUnknown* /*ID2D1RenderTarget**/ prt); + SBOOL SCFN( SciterD2DFactory )(IUnknown** /*ID2D1Factory ***/ ppf); + SBOOL SCFN( SciterDWFactory )(IUnknown** /*IDWriteFactory ***/ ppf); +#else + LPVOID SciterRenderD2D; + LPVOID SciterD2DFactory; + LPVOID SciterDWFactory; #endif - BOOL SCFN( SciterGraphicsCaps )(LPUINT pcaps); - BOOL SCFN( SciterSetHomeURL )(HWINDOW hWndSciter, LPCWSTR baseUrl); -#if defined(OSX) && !defined(WINDOWLESS) + SBOOL SCFN( SciterGraphicsCaps )(LPUINT pcaps); + SBOOL SCFN( SciterSetHomeURL )(HWINDOW hWndSciter, LPCWSTR baseUrl); +#if defined(OSX) HWINDOW SCFN( SciterCreateNSView )( LPRECT frame ); // returns NSView* +#else + LPVOID SciterCreateNSView; // NULL #endif -#if defined(LINUX) && !defined(WINDOWLESS) +#if defined(LINUX) HWINDOW SCFN( SciterCreateWidget )( LPRECT frame ); // returns GtkWidget +#else + LPVOID SciterCreateWidget; // NULL #endif -#if !defined(WINDOWLESS) HWINDOW SCFN( SciterCreateWindow )( UINT creationFlags,LPRECT frame, SciterWindowDelegate* delegate, LPVOID delegateParam, HWINDOW parent); -#endif + VOID SCFN( SciterSetupDebugOutput )( HWINDOW hwndOrNull,// HWINDOW or null if this is global output handler LPVOID param, // param to be passed "as is" to the pfOutput @@ -112,7 +123,7 @@ typedef struct _ISciterAPI { SCDOM_RESULT SCFN( SciterGetChildrenCount)(HELEMENT he, UINT* count); SCDOM_RESULT SCFN( SciterGetNthChild)(HELEMENT he, UINT n, HELEMENT* phe); SCDOM_RESULT SCFN( SciterGetParentElement)(HELEMENT he, HELEMENT* p_parent_he); - SCDOM_RESULT SCFN( SciterGetElementHtmlCB)(HELEMENT he, BOOL outer, LPCBYTE_RECEIVER* rcv, LPVOID rcv_param); + SCDOM_RESULT SCFN( SciterGetElementHtmlCB)(HELEMENT he, SBOOL outer, LPCBYTE_RECEIVER* rcv, LPVOID rcv_param); SCDOM_RESULT SCFN( SciterGetElementTextCB)(HELEMENT he, LPCWSTR_RECEIVER* rcv, LPVOID rcv_param); SCDOM_RESULT SCFN( SciterSetElementText)(HELEMENT he, LPCWSTR utf16, UINT length); SCDOM_RESULT SCFN( SciterGetAttributeCount)(HELEMENT he, LPUINT p_count); @@ -128,11 +139,11 @@ typedef struct _ISciterAPI { SCDOM_RESULT SCFN( SciterSetStyleAttribute)(HELEMENT he, LPCSTR name, LPCWSTR value); SCDOM_RESULT SCFN( SciterGetElementLocation)(HELEMENT he, LPRECT p_location, UINT areas /*ELEMENT_AREAS*/); SCDOM_RESULT SCFN( SciterScrollToView)(HELEMENT he, UINT SciterScrollFlags); - SCDOM_RESULT SCFN( SciterUpdateElement)(HELEMENT he, BOOL andForceRender); + SCDOM_RESULT SCFN( SciterUpdateElement)(HELEMENT he, SBOOL andForceRender); SCDOM_RESULT SCFN( SciterRefreshElementArea)(HELEMENT he, RECT rc); SCDOM_RESULT SCFN( SciterSetCapture)(HELEMENT he); SCDOM_RESULT SCFN( SciterReleaseCapture)(HELEMENT he); - SCDOM_RESULT SCFN( SciterGetElementHwnd)(HELEMENT he, HWINDOW* p_hwnd, BOOL rootWindow); + SCDOM_RESULT SCFN( SciterGetElementHwnd)(HELEMENT he, HWINDOW* p_hwnd, SBOOL rootWindow); SCDOM_RESULT SCFN( SciterCombineURL)(HELEMENT he, LPWSTR szUrlBuffer, UINT UrlBufferSize); SCDOM_RESULT SCFN( SciterSelectElements)(HELEMENT he, LPCSTR CSS_selectors, SciterElementCallback* callback, LPVOID param); SCDOM_RESULT SCFN( SciterSelectElementsW)(HELEMENT he, LPCWSTR CSS_selectors, SciterElementCallback* callback, LPVOID param); @@ -145,7 +156,7 @@ typedef struct _ISciterAPI { SCDOM_RESULT SCFN( SciterShowPopupAt)(HELEMENT hePopup, POINT pos, UINT placement); SCDOM_RESULT SCFN( SciterHidePopup)(HELEMENT he); SCDOM_RESULT SCFN( SciterGetElementState)( HELEMENT he, UINT* pstateBits); - SCDOM_RESULT SCFN( SciterSetElementState)( HELEMENT he, UINT stateBitsToSet, UINT stateBitsToClear, BOOL updateView); + SCDOM_RESULT SCFN( SciterSetElementState)( HELEMENT he, UINT stateBitsToSet, UINT stateBitsToClear, SBOOL updateView); SCDOM_RESULT SCFN( SciterCreateElement)( LPCSTR tagname, LPCWSTR textOrNull, /*out*/ HELEMENT *phe ); SCDOM_RESULT SCFN( SciterCloneElement)( HELEMENT he, /*out*/ HELEMENT *phe ); SCDOM_RESULT SCFN( SciterInsertElement)( HELEMENT he, HELEMENT hparent, UINT index ); @@ -156,7 +167,7 @@ typedef struct _ISciterAPI { SCDOM_RESULT SCFN( SciterAttachEventHandler)( HELEMENT he, LPELEMENT_EVENT_PROC pep, LPVOID tag ); SCDOM_RESULT SCFN( SciterWindowAttachEventHandler)( HWINDOW hwndLayout, LPELEMENT_EVENT_PROC pep, LPVOID tag, UINT subscription ); SCDOM_RESULT SCFN( SciterWindowDetachEventHandler)( HWINDOW hwndLayout, LPELEMENT_EVENT_PROC pep, LPVOID tag ); - SCDOM_RESULT SCFN( SciterSendEvent)( HELEMENT he, UINT appEventCode, HELEMENT heSource, UINT_PTR reason, /*out*/ BOOL* handled); + SCDOM_RESULT SCFN( SciterSendEvent)( HELEMENT he, UINT appEventCode, HELEMENT heSource, UINT_PTR reason, /*out*/ SBOOL* handled); SCDOM_RESULT SCFN( SciterPostEvent)( HELEMENT he, UINT appEventCode, HELEMENT heSource, UINT_PTR reason); SCDOM_RESULT SCFN( SciterCallBehaviorMethod)(HELEMENT he, struct METHOD_PARAMS* params); SCDOM_RESULT SCFN( SciterRequestElementData)( HELEMENT he, LPCWSTR url, UINT dataType, HELEMENT initiator ); @@ -168,14 +179,14 @@ typedef struct _ISciterAPI { UINT nParams // number of parameters ); SCDOM_RESULT SCFN( SciterGetScrollInfo)( HELEMENT he, LPPOINT scrollPos, LPRECT viewRect, LPSIZE contentSize ); - SCDOM_RESULT SCFN( SciterSetScrollPos)( HELEMENT he, POINT scrollPos, BOOL smooth ); + SCDOM_RESULT SCFN( SciterSetScrollPos)( HELEMENT he, POINT scrollPos, SBOOL smooth ); SCDOM_RESULT SCFN( SciterGetElementIntrinsicWidths)( HELEMENT he, INT* pMinWidth, INT* pMaxWidth ); SCDOM_RESULT SCFN( SciterGetElementIntrinsicHeight)( HELEMENT he, INT forWidth, INT* pHeight ); - SCDOM_RESULT SCFN( SciterIsElementVisible)( HELEMENT he, BOOL* pVisible); - SCDOM_RESULT SCFN( SciterIsElementEnabled)( HELEMENT he, BOOL* pEnabled ); + SCDOM_RESULT SCFN( SciterIsElementVisible)( HELEMENT he, SBOOL* pVisible); + SCDOM_RESULT SCFN( SciterIsElementEnabled)( HELEMENT he, SBOOL* pEnabled ); SCDOM_RESULT SCFN( SciterSortElements)( HELEMENT he, UINT firstIndex, UINT lastIndex, ELEMENT_COMPARATOR* cmpFunc, LPVOID cmpFuncParam ); SCDOM_RESULT SCFN( SciterSwapElements)( HELEMENT he1, HELEMENT he2 ); - SCDOM_RESULT SCFN( SciterTraverseUIEvent)( UINT evt, LPVOID eventCtlStruct, BOOL* bOutProcessed ); + SCDOM_RESULT SCFN( SciterTraverseUIEvent)( UINT evt, LPVOID eventCtlStruct, SBOOL* bOutProcessed ); SCDOM_RESULT SCFN( SciterCallScriptingMethod)( HELEMENT he, LPCSTR name, const VALUE* argv, UINT argc, VALUE* retval ); SCDOM_RESULT SCFN( SciterCallScriptingFunction)( HELEMENT he, LPCSTR name, const VALUE* argv, UINT argc, VALUE* retval ); SCDOM_RESULT SCFN( SciterEvalElementScript)( HELEMENT he, LPCWSTR script, UINT scriptLength, VALUE* retval ); @@ -183,9 +194,9 @@ typedef struct _ISciterAPI { SCDOM_RESULT SCFN( SciterControlGetType)( HELEMENT he, /*CTL_TYPE*/ UINT *pType ); SCDOM_RESULT SCFN( SciterGetValue)( HELEMENT he, VALUE* pval ); SCDOM_RESULT SCFN( SciterSetValue)( HELEMENT he, const VALUE* pval ); - SCDOM_RESULT SCFN( SciterGetExpando)( HELEMENT he, VALUE* pval, BOOL forceCreation ); - SCDOM_RESULT SCFN( SciterGetObject)( HELEMENT he, tiscript_value* pval, BOOL forceCreation ); - SCDOM_RESULT SCFN( SciterGetElementNamespace)( HELEMENT he, tiscript_value* pval); + SCDOM_RESULT SCFN( SciterGetExpando)( HELEMENT he, VALUE* pval, SBOOL forceCreation ); + SCDOM_RESULT SCFN( SciterGetObject)( HELEMENT he, void* pval, SBOOL forceCreation ); + SCDOM_RESULT SCFN( SciterGetElementNamespace)( HELEMENT he, void* pval); SCDOM_RESULT SCFN( SciterGetHighlightedElement)(HWINDOW hwnd, HELEMENT* phe); SCDOM_RESULT SCFN( SciterSetHighlightedElement)(HWINDOW hwnd, HELEMENT he); //| @@ -206,7 +217,7 @@ typedef struct _ISciterAPI { SCDOM_RESULT SCFN( SciterNodeGetText)(HNODE hnode, LPCWSTR_RECEIVER* rcv, LPVOID rcv_param); SCDOM_RESULT SCFN( SciterNodeSetText)(HNODE hnode, LPCWSTR text, UINT textLength); SCDOM_RESULT SCFN( SciterNodeInsert)(HNODE hnode, UINT where /*NODE_INS_TARGET*/, HNODE what); - SCDOM_RESULT SCFN( SciterNodeRemove)(HNODE hnode, BOOL finalize); + SCDOM_RESULT SCFN( SciterNodeRemove)(HNODE hnode, SBOOL finalize); SCDOM_RESULT SCFN( SciterCreateTextNode)(LPCWSTR text, UINT textLength, HNODE* phnode); SCDOM_RESULT SCFN( SciterCreateCommentNode)(LPCWSTR text, UINT textLength, HNODE* phnode); //| @@ -239,21 +250,18 @@ typedef struct _ISciterAPI { UINT SCFN( ValueFromString )( VALUE* pval, LPCWSTR str, UINT strLength, /*VALUE_STRING_CVT_TYPE*/ UINT how ); UINT SCFN( ValueInvoke )( const VALUE* pval, VALUE* pthis, UINT argc, const VALUE* argv, VALUE* pretval, LPCWSTR url); UINT SCFN( ValueNativeFunctorSet )( VALUE* pval, NATIVE_FUNCTOR_INVOKE* pinvoke, NATIVE_FUNCTOR_RELEASE* prelease, VOID* tag ); - BOOL SCFN( ValueIsNativeFunctor )( const VALUE* pval); - - // tiscript VM API - tiscript_native_interface* SCFN(TIScriptAPI)(); - - HVM SCFN( SciterGetVM )( HWINDOW hwnd ); - - BOOL SCFN( Sciter_v2V ) (HVM vm, tiscript_value script_value, VALUE* value, BOOL isolate); - BOOL SCFN( Sciter_V2v ) (HVM vm, const VALUE* valuev, tiscript_value* script_value); + SBOOL SCFN( ValueIsNativeFunctor )( const VALUE* pval); + // used to be script VM API + LPVOID reserved1; + LPVOID reserved2; + LPVOID reserved3; + LPVOID reserved4; HSARCHIVE SCFN( SciterOpenArchive ) (LPCBYTE archiveData, UINT archiveDataLength); - BOOL SCFN( SciterGetArchiveItem ) (HSARCHIVE harc, LPCWSTR path, LPCBYTE* pdata, UINT* pdataLength); - BOOL SCFN( SciterCloseArchive ) (HSARCHIVE harc); + SBOOL SCFN( SciterGetArchiveItem ) (HSARCHIVE harc, LPCWSTR path, LPCBYTE* pdata, UINT* pdataLength); + SBOOL SCFN( SciterCloseArchive ) (HSARCHIVE harc); - SCDOM_RESULT SCFN( SciterFireEvent)( const BEHAVIOR_EVENT_PARAMS* evt, BOOL post, BOOL *handled ); + SCDOM_RESULT SCFN( SciterFireEvent)( const BEHAVIOR_EVENT_PARAMS* evt, SBOOL post, SBOOL *handled ); LPVOID SCFN( SciterGetCallbackParam )(HWINDOW hwnd); UINT_PTR SCFN( SciterPostCallback )(HWINDOW hwnd, UINT_PTR wparam, UINT_PTR lparam, UINT timeoutms); @@ -261,20 +269,453 @@ typedef struct _ISciterAPI { LPSciterGraphicsAPI SCFN( GetSciterGraphicsAPI )(); LPSciterRequestAPI SCFN( GetSciterRequestAPI )(); -#if defined(WINDOWS) && !defined(WINDOWLESS) - BOOL SCFN( SciterCreateOnDirectXWindow ) (HWINDOW hwnd, IUnknown* pSwapChain); // IDXGISwapChain - BOOL SCFN( SciterRenderOnDirectXWindow ) (HWINDOW hwnd, HELEMENT elementToRenderOrNull, BOOL frontLayer); - BOOL SCFN( SciterRenderOnDirectXTexture ) (HWINDOW hwnd, HELEMENT elementToRenderOrNull, IUnknown* surface); // IDXGISurface +#if defined(WINDOWS) + SBOOL SCFN( SciterCreateOnDirectXWindow ) (HWINDOW hwnd, IUnknown* pSwapChain); // IDXGISwapChain + SBOOL SCFN( SciterRenderOnDirectXWindow ) (HWINDOW hwnd, HELEMENT elementToRenderOrNull, SBOOL frontLayer); + SBOOL SCFN( SciterRenderOnDirectXTexture ) (HWINDOW hwnd, HELEMENT elementToRenderOrNull, IUnknown* surface); // IDXGISurface +#else + LPVOID SciterCreateOnDirectXWindow; + LPVOID SciterRenderOnDirectXWindow; + LPVOID SciterRenderOnDirectXTexture; #endif - BOOL SCFN(SciterProcX)(HWINDOW hwnd, SCITER_X_MSG* pMsg ); // returns TRUE if handled + SBOOL SCFN(SciterProcX)(HWINDOW hwnd, SCITER_X_MSG* pMsg ); // returns TRUE if handled + + UINT64 SCFN(SciterAtomValue)(const char* name); // + SBOOL SCFN(SciterAtomNameCB)(UINT64 atomv, LPCSTR_RECEIVER* rcv, LPVOID rcv_param); + SBOOL SCFN(SciterSetGlobalAsset)(som_asset_t* pass); + + SCDOM_RESULT SCFN(SciterGetElementAsset)(HELEMENT el, UINT64 nameAtom, som_asset_t** ppass); + + UINT SCFN(SciterSetVariable)(HWINDOW hwndOrNull, LPCWSTR path, const VALUE* pvalToSet); + UINT SCFN(SciterGetVariable)(HWINDOW hwndOrNull, LPCWSTR path, VALUE* pvalToGet); + + UINT SCFN(SciterElementUnwrap)(const VALUE* pval, HELEMENT* ppElement); + UINT SCFN(SciterElementWrap)(VALUE* pval, HELEMENT pElement); + + UINT SCFN(SciterNodeUnwrap)(const VALUE* pval, HNODE* ppNode); + UINT SCFN(SciterNodeWrap)(VALUE* pval, HNODE pNode); - UINT64 SCFN(SciterAtomValue)(const char* name); // - BOOL SCFN(SciterAtomNameCB)(UINT64 atomv, LPCSTR_RECEIVER* rcv, LPVOID rcv_param); - BOOL SCFN(SciterSetGlobalAsset)(som_asset_t* pass); } ISciterAPI; typedef ISciterAPI* (SCAPI *SciterAPI_ptr)(); +// getting ISciterAPI reference: + +#if defined(STATIC_LIB) || defined(SCITER_BUILD) + + EXTERN_C ISciterAPI* SCAPI SciterAPI(); + + inline ISciterAPI* _SAPI(ISciterAPI* ext) { + static ISciterAPI* _api = NULL; + if( ext ) _api = ext; + if( !_api ) + { + _api = SciterAPI(); +#if defined(__cplusplus) && !defined(PLAIN_API_ONLY) +// tiscript::ni(_api->TIScriptAPI()); +#endif + } + assert(_api); + return _api; + } + +#elif defined(WINDOWS) + + inline ISciterAPI* _SAPI( ISciterAPI* ext ) { + static ISciterAPI* _api = NULL; + if( ext ) _api = ext; + if( !_api ) + { + HMODULE hm = LoadLibrary( TEXT("sciter.dll") ); + if(hm) { + SciterAPI_ptr sciterAPI = (SciterAPI_ptr) GetProcAddress(hm, "SciterAPI"); + if( sciterAPI ) { + _api = sciterAPI(); +//#if defined(__cplusplus) && !defined(PLAIN_API_ONLY) +// tiscript::ni( _api->TIScriptAPI() ); +//#endif + } else { + FreeLibrary(hm); + } + + } + } + assert(_api); + if( !_api ) { + //::MessageBox(NULL, TEXT("Sciter engine not found, quiting"),TEXT("Error"),MB_OK); + exit(-1); + } + return _api; + } + +#elif defined(OSX) + + //typedef ISciterAPI* SCAPI (*SciterAPI_ptr)(); + + inline ISciterAPI* _SAPI( ISciterAPI* ext ) + { + static ISciterAPI* _api = NULL; + if( ext ) _api = ext; + if( !_api ) { + pid_t pid; + char pathbuf[PROC_PIDPATHINFO_MAXSIZE]; + char folderpath[PROC_PIDPATHINFO_MAXSIZE]; + pid = getpid(); + proc_pidpath (pid, pathbuf, sizeof(pathbuf)); + realpath(pathbuf, folderpath); + *strrchr(folderpath, '/') = '\0'; + + void* lib_sciter_handle = dlopen(SCITER_DLL_NAME, RTLD_LOCAL|RTLD_LAZY); + if( !lib_sciter_handle ) { + const char* lookup_paths[] = + { + "/" SCITER_DLL_NAME, + "/../Frameworks/" SCITER_DLL_NAME, // - (bundle folder)/Contents/Frameworks/ + "/../../../" SCITER_DLL_NAME // aside of bundle folder (SDK samples) + }; + for( int n = 0; !lib_sciter_handle && n < 3; ++n ) { + char tpath[PROC_PIDPATHINFO_MAXSIZE]; + strcpy(tpath,folderpath); + strcat(tpath, lookup_paths[n]); + lib_sciter_handle = dlopen(tpath, RTLD_LOCAL|RTLD_LAZY); + } + } + if (!lib_sciter_handle) { + fprintf(stderr, "[%s] Unable to load library: %s\n", __FILE__, dlerror()); + exit(EXIT_FAILURE); + } + + SciterAPI_ptr sapi = (SciterAPI_ptr) dlsym(lib_sciter_handle, "SciterAPI"); + if (!sapi) { + fprintf(stderr,"[%s] Unable to get symbol: %s\n", __FILE__, dlerror()); + exit(EXIT_FAILURE); + } + _api = sapi(); + //tiscript::ni( _api->TIScriptAPI() ); + } + assert(_api); + return _api; + } + +#elif defined(ANDROID) + +#if 1 + EXTERN_C ISciterAPI *SciterAPI(); + + inline ISciterAPI* _SAPI( ISciterAPI* ext ) + { + static ISciterAPI* _api = NULL; + if( ext ) + _api = ext; + else + _api = SciterAPI(); + assert(_api); + //if (!sapi) { + // fprintf(stderr, "[%s] Unable to get symbol: %s\n", __FILE__, dlerror()); + // exit(EXIT_FAILURE); + //} + return _api; + } + +#else + inline ISciterAPI *_SAPI(ISciterAPI *ext) { + static ISciterAPI *_api = NULL; + if (ext) _api = ext; + if (!_api) { + void *lib_sciter_handle = NULL; + // 1. try to load from the same folder as this executable + lib_sciter_handle = dlopen(SCITER_DLL_NAME, RTLD_LOCAL | RTLD_LAZY); + if (!lib_sciter_handle) { + fprintf(stderr, "[%s] Unable to load library: %s\n", dlerror(), SCITER_DLL_NAME); + } + + SciterAPI_ptr sapi = (SciterAPI_ptr)dlsym(lib_sciter_handle, "SciterAPI"); + if (!sapi) { + fprintf(stderr, "[%s] Unable to get symbol: %s\n", __FILE__, dlerror()); + exit(EXIT_FAILURE); + } + _api = sapi(); + } + assert(_api); + return _api; +} + +#endif + +#elif defined(LINUX) + +#include +#include + +// typedef ISciterAPI* SCAPI (*SciterAPI_ptr)(); + +inline ISciterAPI *_SAPI(ISciterAPI *ext) { + static ISciterAPI *_api = NULL; + if (ext) _api = ext; + if (!_api) { + + char folderpath[2048] = {0}; + + if (readlink("/proc/self/exe", folderpath, sizeof(folderpath)) != -1) { + dirname(folderpath); + // strcat (pathbuf, "/"); + } + + void *lib_sciter_handle = NULL; + + { + // 1. try to load from the same folder as this executable + const char *lookup_paths[] = {"/" SCITER_DLL_NAME, NULL}; + for (int n = 0; !lib_sciter_handle; ++n) { + if (!lookup_paths[n]) break; + char tpath[2048] = {0}; + strcpy(tpath, folderpath); + strcat(tpath, lookup_paths[n]); + // fprintf(stdout, "[%s]\n",tpath); + lib_sciter_handle = dlopen(tpath, RTLD_LOCAL | RTLD_LAZY); + if (!lib_sciter_handle) { + fprintf(stderr, "[%s] Unable to load library: %s\n", dlerror(), + tpath); + } + } + } + + if (!lib_sciter_handle) // 2. no luck, try to load from system paths + lib_sciter_handle = dlopen(SCITER_DLL_NAME, RTLD_LOCAL | RTLD_LAZY); + + if (!lib_sciter_handle) { + fprintf(stderr, "[%s] Unable to load library: %s\n", __FILE__, dlerror()); + exit(EXIT_FAILURE); + } + + SciterAPI_ptr sapi = (SciterAPI_ptr)dlsym(lib_sciter_handle, "SciterAPI"); + if (!sapi) { + fprintf(stderr, "[%s] Unable to get symbol: %s\n", __FILE__, dlerror()); + exit(EXIT_FAILURE); + } + _api = sapi(); + } + assert(_api); + return _api; +} + +#endif + + + inline ISciterAPI* SAPI() { + static ISciterAPI* _api = _SAPI(NULL); + return _api; + } + + inline LPSciterGraphicsAPI gapi() + { + return SAPI()->GetSciterGraphicsAPI(); + } + + inline LPSciterRequestAPI rapi() + { + return SAPI()->GetSciterRequestAPI(); + } + + + // defining "official" API functions: + + inline LPCWSTR SCAPI SciterClassName (void) { return SAPI()->SciterClassName(); } + inline UINT SCAPI SciterVersion (SBOOL major) { return SAPI()->SciterVersion (major); } + inline SBOOL SCAPI SciterDataReady (HWINDOW hwnd,LPCWSTR uri,LPCBYTE data, UINT dataLength) { return SAPI()->SciterDataReady (hwnd,uri,data,dataLength); } + inline SBOOL SCAPI SciterDataReadyAsync (HWINDOW hwnd,LPCWSTR uri, LPCBYTE data, UINT dataLength, LPVOID requestId) { return SAPI()->SciterDataReadyAsync (hwnd,uri, data, dataLength, requestId); } +#if defined(WINDOWS) && !defined(WINDOWLESS) + inline LRESULT SCAPI SciterProc (HWINDOW hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { return SAPI()->SciterProc (hwnd,msg,wParam,lParam); } + inline LRESULT SCAPI SciterProcND (HWINDOW hwnd, UINT msg, WPARAM wParam, LPARAM lParam, SBOOL* pbHandled) { return SAPI()->SciterProcND (hwnd,msg,wParam,lParam,pbHandled); } +#endif + inline SBOOL SCAPI SciterLoadFile (HWINDOW hWndSciter, LPCWSTR filename) { return SAPI()->SciterLoadFile (hWndSciter,filename); } + inline SBOOL SCAPI SciterLoadHtml (HWINDOW hWndSciter, LPCBYTE html, UINT htmlSize, LPCWSTR baseUrl) { return SAPI()->SciterLoadHtml (hWndSciter,html,htmlSize,baseUrl); } + inline VOID SCAPI SciterSetCallback (HWINDOW hWndSciter, LPSciterHostCallback cb, LPVOID cbParam) { SAPI()->SciterSetCallback (hWndSciter,cb,cbParam); } + inline SBOOL SCAPI SciterSetMasterCSS (LPCBYTE utf8, UINT numBytes) { return SAPI()->SciterSetMasterCSS (utf8,numBytes); } + inline SBOOL SCAPI SciterAppendMasterCSS (LPCBYTE utf8, UINT numBytes) { return SAPI()->SciterAppendMasterCSS (utf8,numBytes); } + inline SBOOL SCAPI SciterSetCSS (HWINDOW hWndSciter, LPCBYTE utf8, UINT numBytes, LPCWSTR baseUrl, LPCWSTR mediaType) { return SAPI()->SciterSetCSS (hWndSciter,utf8,numBytes,baseUrl,mediaType); } + inline SBOOL SCAPI SciterSetMediaType (HWINDOW hWndSciter, LPCWSTR mediaType) { return SAPI()->SciterSetMediaType (hWndSciter,mediaType); } + inline SBOOL SCAPI SciterSetMediaVars (HWINDOW hWndSciter, const SCITER_VALUE *mediaVars) { return SAPI()->SciterSetMediaVars (hWndSciter,mediaVars); } + inline UINT SCAPI SciterGetMinWidth (HWINDOW hWndSciter) { return SAPI()->SciterGetMinWidth (hWndSciter); } + inline UINT SCAPI SciterGetMinHeight (HWINDOW hWndSciter, UINT width) { return SAPI()->SciterGetMinHeight (hWndSciter,width); } + inline SBOOL SCAPI SciterCall (HWINDOW hWnd, LPCSTR functionName, UINT argc, const SCITER_VALUE* argv, SCITER_VALUE* retval) { return SAPI()->SciterCall (hWnd,functionName, argc,argv,retval); } + inline SBOOL SCAPI SciterEval ( HWINDOW hwnd, LPCWSTR script, UINT scriptLength, SCITER_VALUE* pretval) { return SAPI()->SciterEval ( hwnd, script, scriptLength, pretval); } + inline VOID SCAPI SciterUpdateWindow(HWINDOW hwnd) { SAPI()->SciterUpdateWindow(hwnd); } +#if defined(WINDOWS) && !defined(WINDOWLESS) + inline SBOOL SCAPI SciterTranslateMessage (MSG* lpMsg) { return SAPI()->SciterTranslateMessage (lpMsg); } +#endif + inline SBOOL SCAPI SciterSetOption (HWINDOW hWnd, UINT option, UINT_PTR value ) { return SAPI()->SciterSetOption (hWnd,option,value ); } + inline VOID SCAPI SciterGetPPI (HWINDOW hWndSciter, UINT* px, UINT* py) { SAPI()->SciterGetPPI (hWndSciter,px,py); } + inline SBOOL SCAPI SciterGetViewExpando ( HWINDOW hwnd, VALUE* pval ) { return SAPI()->SciterGetViewExpando ( hwnd, pval ); } +#if defined(WINDOWS) && !defined(WINDOWLESS) + inline SBOOL SCAPI SciterRenderD2D (HWINDOW hWndSciter, IUnknown* /*ID2D1RenderTarget**/ prt) { return SAPI()->SciterRenderD2D (hWndSciter,prt); } + inline SBOOL SCAPI SciterD2DFactory (IUnknown** /*ID2D1Factory ***/ ppf) { return SAPI()->SciterD2DFactory (ppf); } + inline SBOOL SCAPI SciterDWFactory (IUnknown** /*IDWriteFactory ***/ ppf) { return SAPI()->SciterDWFactory (ppf); } +#endif + inline SBOOL SCAPI SciterGraphicsCaps (LPUINT pcaps) { return SAPI()->SciterGraphicsCaps (pcaps); } + inline SBOOL SCAPI SciterSetHomeURL (HWINDOW hWndSciter, LPCWSTR baseUrl) { return SAPI()->SciterSetHomeURL (hWndSciter,baseUrl); } +#if defined(OSX) && !defined(WINDOWLESS) + inline HWINDOW SCAPI SciterCreateNSView ( LPRECT frame ) { return SAPI()->SciterCreateNSView ( frame ); } +#endif +#if !defined(WINDOWLESS) + inline HWINDOW SCAPI SciterCreateWindow ( UINT creationFlags,LPRECT frame, SciterWindowDelegate* delegate, LPVOID delegateParam, HWINDOW parent) { return SAPI()->SciterCreateWindow (creationFlags,frame,delegate,delegateParam,parent); } +#endif + + inline SCDOM_RESULT SCAPI Sciter_UseElement(HELEMENT he) { return SAPI()->Sciter_UseElement(he); } + inline SCDOM_RESULT SCAPI Sciter_UnuseElement(HELEMENT he) { return SAPI()->Sciter_UnuseElement(he); } + inline SCDOM_RESULT SCAPI SciterGetRootElement(HWINDOW hwnd, HELEMENT *phe) { return SAPI()->SciterGetRootElement(hwnd, phe); } + inline SCDOM_RESULT SCAPI SciterGetFocusElement(HWINDOW hwnd, HELEMENT *phe) { return SAPI()->SciterGetFocusElement(hwnd, phe); } + inline SCDOM_RESULT SCAPI SciterFindElement(HWINDOW hwnd, POINT pt, HELEMENT* phe) { return SAPI()->SciterFindElement(hwnd,pt,phe); } + inline SCDOM_RESULT SCAPI SciterGetChildrenCount(HELEMENT he, UINT* count) { return SAPI()->SciterGetChildrenCount(he, count); } + inline SCDOM_RESULT SCAPI SciterGetNthChild(HELEMENT he, UINT n, HELEMENT* phe) { return SAPI()->SciterGetNthChild(he,n,phe); } + inline SCDOM_RESULT SCAPI SciterGetParentElement(HELEMENT he, HELEMENT* p_parent_he) { return SAPI()->SciterGetParentElement(he,p_parent_he); } + inline SCDOM_RESULT SCAPI SciterGetElementHtmlCB(HELEMENT he, SBOOL outer, LPCBYTE_RECEIVER* rcv, LPVOID rcv_param) { return SAPI()->SciterGetElementHtmlCB( he, outer, rcv, rcv_param); } + inline SCDOM_RESULT SCAPI SciterGetElementTextCB(HELEMENT he, LPCWSTR_RECEIVER* rcv, LPVOID rcv_param) { return SAPI()->SciterGetElementTextCB(he, rcv, rcv_param); } + inline SCDOM_RESULT SCAPI SciterSetElementText(HELEMENT he, LPCWSTR utf16, UINT length) { return SAPI()->SciterSetElementText(he, utf16, length); } + inline SCDOM_RESULT SCAPI SciterGetAttributeCount(HELEMENT he, LPUINT p_count) { return SAPI()->SciterGetAttributeCount(he, p_count); } + inline SCDOM_RESULT SCAPI SciterGetNthAttributeNameCB(HELEMENT he, UINT n, LPCSTR_RECEIVER* rcv, LPVOID rcv_param) { return SAPI()->SciterGetNthAttributeNameCB(he,n,rcv,rcv_param); } + inline SCDOM_RESULT SCAPI SciterGetNthAttributeValueCB(HELEMENT he, UINT n, LPCWSTR_RECEIVER* rcv, LPVOID rcv_param) { return SAPI()->SciterGetNthAttributeValueCB(he, n, rcv, rcv_param); } + inline SCDOM_RESULT SCAPI SciterGetAttributeByNameCB(HELEMENT he, LPCSTR name, LPCWSTR_RECEIVER* rcv, LPVOID rcv_param) { return SAPI()->SciterGetAttributeByNameCB(he,name,rcv,rcv_param); } + inline SCDOM_RESULT SCAPI SciterSetAttributeByName(HELEMENT he, LPCSTR name, LPCWSTR value) { return SAPI()->SciterSetAttributeByName(he,name,value); } + inline SCDOM_RESULT SCAPI SciterClearAttributes(HELEMENT he) { return SAPI()->SciterClearAttributes(he); } + inline SCDOM_RESULT SCAPI SciterGetElementIndex(HELEMENT he, LPUINT p_index) { return SAPI()->SciterGetElementIndex(he,p_index); } + inline SCDOM_RESULT SCAPI SciterGetElementType(HELEMENT he, LPCSTR* p_type) { return SAPI()->SciterGetElementType(he,p_type); } + inline SCDOM_RESULT SCAPI SciterGetElementTypeCB(HELEMENT he, LPCSTR_RECEIVER* rcv, LPVOID rcv_param) { return SAPI()->SciterGetElementTypeCB(he,rcv,rcv_param); } + inline SCDOM_RESULT SCAPI SciterGetStyleAttributeCB(HELEMENT he, LPCSTR name, LPCWSTR_RECEIVER* rcv, LPVOID rcv_param) { return SAPI()->SciterGetStyleAttributeCB(he,name,rcv,rcv_param); } + inline SCDOM_RESULT SCAPI SciterSetStyleAttribute(HELEMENT he, LPCSTR name, LPCWSTR value) { return SAPI()->SciterSetStyleAttribute(he,name,value); } + inline SCDOM_RESULT SCAPI SciterGetElementLocation(HELEMENT he, LPRECT p_location, UINT areas /*ELEMENT_AREAS*/) { return SAPI()->SciterGetElementLocation(he,p_location,areas); } + inline SCDOM_RESULT SCAPI SciterScrollToView(HELEMENT he, UINT SciterScrollFlags) { return SAPI()->SciterScrollToView(he,SciterScrollFlags); } + inline SCDOM_RESULT SCAPI SciterUpdateElement(HELEMENT he, SBOOL andForceRender) { return SAPI()->SciterUpdateElement(he,andForceRender); } + inline SCDOM_RESULT SCAPI SciterRefreshElementArea(HELEMENT he, RECT rc) { return SAPI()->SciterRefreshElementArea(he,rc); } + inline SCDOM_RESULT SCAPI SciterSetCapture(HELEMENT he) { return SAPI()->SciterSetCapture(he); } + inline SCDOM_RESULT SCAPI SciterReleaseCapture(HELEMENT he) { return SAPI()->SciterReleaseCapture(he); } + inline SCDOM_RESULT SCAPI SciterGetElementHwnd(HELEMENT he, HWINDOW* p_hwnd, SBOOL rootWindow) { return SAPI()->SciterGetElementHwnd(he,p_hwnd,rootWindow); } + inline SCDOM_RESULT SCAPI SciterCombineURL(HELEMENT he, LPWSTR szUrlBuffer, UINT UrlBufferSize) { return SAPI()->SciterCombineURL(he,szUrlBuffer,UrlBufferSize); } + inline SCDOM_RESULT SCAPI SciterSelectElements(HELEMENT he, LPCSTR CSS_selectors, SciterElementCallback* callback, LPVOID param) { return SAPI()->SciterSelectElements(he,CSS_selectors,callback,param); } + inline SCDOM_RESULT SCAPI SciterSelectElementsW(HELEMENT he, LPCWSTR CSS_selectors, SciterElementCallback* callback, LPVOID param) { return SAPI()->SciterSelectElementsW(he,CSS_selectors,callback,param); } + inline SCDOM_RESULT SCAPI SciterSelectParent(HELEMENT he, LPCSTR selector, UINT depth, HELEMENT* heFound) { return SAPI()->SciterSelectParent(he,selector,depth,heFound); } + inline SCDOM_RESULT SCAPI SciterSelectParentW(HELEMENT he, LPCWSTR selector, UINT depth, HELEMENT* heFound) { return SAPI()->SciterSelectParentW(he,selector,depth,heFound); } + inline SCDOM_RESULT SCAPI SciterSetElementHtml(HELEMENT he, const BYTE* html, UINT htmlLength, UINT where) { return SAPI()->SciterSetElementHtml(he,html,htmlLength,where); } + inline SCDOM_RESULT SCAPI SciterGetElementUID(HELEMENT he, UINT* puid) { return SAPI()->SciterGetElementUID(he,puid); } + inline SCDOM_RESULT SCAPI SciterGetElementByUID(HWINDOW hwnd, UINT uid, HELEMENT* phe) { return SAPI()->SciterGetElementByUID(hwnd,uid,phe); } + inline SCDOM_RESULT SCAPI SciterShowPopup(HELEMENT hePopup, HELEMENT heAnchor, UINT placement) { return SAPI()->SciterShowPopup(hePopup,heAnchor,placement); } + inline SCDOM_RESULT SCAPI SciterShowPopupAt(HELEMENT hePopup, POINT pos, UINT placement) { return SAPI()->SciterShowPopupAt(hePopup,pos,placement); } + inline SCDOM_RESULT SCAPI SciterHidePopup(HELEMENT he) { return SAPI()->SciterHidePopup(he); } + inline SCDOM_RESULT SCAPI SciterGetElementState( HELEMENT he, UINT* pstateBits) { return SAPI()->SciterGetElementState(he,pstateBits); } + inline SCDOM_RESULT SCAPI SciterSetElementState( HELEMENT he, UINT stateBitsToSet, UINT stateBitsToClear, SBOOL updateView) { return SAPI()->SciterSetElementState(he,stateBitsToSet,stateBitsToClear,updateView); } + inline SCDOM_RESULT SCAPI SciterCreateElement( LPCSTR tagname, LPCWSTR textOrNull, /*out*/ HELEMENT *phe ) { return SAPI()->SciterCreateElement(tagname,textOrNull,phe ); } + inline SCDOM_RESULT SCAPI SciterCloneElement( HELEMENT he, /*out*/ HELEMENT *phe ) { return SAPI()->SciterCloneElement(he,phe ); } + inline SCDOM_RESULT SCAPI SciterInsertElement( HELEMENT he, HELEMENT hparent, UINT index ) { return SAPI()->SciterInsertElement(he,hparent,index ); } + inline SCDOM_RESULT SCAPI SciterDetachElement( HELEMENT he ) { return SAPI()->SciterDetachElement( he ); } + inline SCDOM_RESULT SCAPI SciterDeleteElement(HELEMENT he) { return SAPI()->SciterDeleteElement(he); } + inline SCDOM_RESULT SCAPI SciterSetTimer( HELEMENT he, UINT milliseconds, UINT_PTR timer_id ) { return SAPI()->SciterSetTimer(he,milliseconds,timer_id ); } + inline SCDOM_RESULT SCAPI SciterDetachEventHandler( HELEMENT he, LPELEMENT_EVENT_PROC pep, LPVOID tag ) { return SAPI()->SciterDetachEventHandler(he,pep,tag ); } + inline SCDOM_RESULT SCAPI SciterAttachEventHandler( HELEMENT he, LPELEMENT_EVENT_PROC pep, LPVOID tag ) { return SAPI()->SciterAttachEventHandler( he,pep,tag ); } + inline SCDOM_RESULT SCAPI SciterWindowAttachEventHandler( HWINDOW hwndLayout, LPELEMENT_EVENT_PROC pep, LPVOID tag, UINT subscription ) { return SAPI()->SciterWindowAttachEventHandler(hwndLayout,pep,tag,subscription ); } + inline SCDOM_RESULT SCAPI SciterWindowDetachEventHandler( HWINDOW hwndLayout, LPELEMENT_EVENT_PROC pep, LPVOID tag ) { return SAPI()->SciterWindowDetachEventHandler(hwndLayout,pep,tag ); } + inline SCDOM_RESULT SCAPI SciterSendEvent( HELEMENT he, UINT appEventCode, HELEMENT heSource, UINT_PTR reason, /*out*/ SBOOL* handled) { return SAPI()->SciterSendEvent( he,appEventCode,heSource,reason,handled); } + inline SCDOM_RESULT SCAPI SciterPostEvent( HELEMENT he, UINT appEventCode, HELEMENT heSource, UINT_PTR reason) { return SAPI()->SciterPostEvent(he,appEventCode,heSource,reason); } + inline SCDOM_RESULT SCAPI SciterFireEvent( const BEHAVIOR_EVENT_PARAMS* evt, SBOOL post, SBOOL *handled) { return SAPI()->SciterFireEvent( evt, post, handled ); } + inline SCDOM_RESULT SCAPI SciterCallBehaviorMethod(HELEMENT he, struct METHOD_PARAMS* params) { return SAPI()->SciterCallBehaviorMethod(he,params); } + inline SCDOM_RESULT SCAPI SciterRequestElementData( HELEMENT he, LPCWSTR url, UINT dataType, HELEMENT initiator ) { return SAPI()->SciterRequestElementData(he,url,dataType,initiator ); } + inline SCDOM_RESULT SCAPI SciterHttpRequest( HELEMENT he, LPCWSTR url, UINT dataType, UINT requestType, struct REQUEST_PARAM* requestParams, UINT nParams) { return SAPI()->SciterHttpRequest(he,url,dataType,requestType,requestParams,nParams); } + inline SCDOM_RESULT SCAPI SciterGetScrollInfo( HELEMENT he, LPPOINT scrollPos, LPRECT viewRect, LPSIZE contentSize ) { return SAPI()->SciterGetScrollInfo( he,scrollPos,viewRect,contentSize ); } + inline SCDOM_RESULT SCAPI SciterSetScrollPos( HELEMENT he, POINT scrollPos, SBOOL smooth ) { return SAPI()->SciterSetScrollPos( he,scrollPos,smooth ); } + inline SCDOM_RESULT SCAPI SciterGetElementIntrinsicWidths( HELEMENT he, INT* pMinWidth, INT* pMaxWidth ) { return SAPI()->SciterGetElementIntrinsicWidths(he,pMinWidth,pMaxWidth ); } + inline SCDOM_RESULT SCAPI SciterGetElementIntrinsicHeight( HELEMENT he, INT forWidth, INT* pHeight ) { return SAPI()->SciterGetElementIntrinsicHeight( he,forWidth,pHeight ); } + inline SCDOM_RESULT SCAPI SciterIsElementVisible( HELEMENT he, SBOOL* pVisible) { return SAPI()->SciterIsElementVisible( he,pVisible); } + inline SCDOM_RESULT SCAPI SciterIsElementEnabled( HELEMENT he, SBOOL* pEnabled ) { return SAPI()->SciterIsElementEnabled( he, pEnabled ); } + inline SCDOM_RESULT SCAPI SciterSortElements( HELEMENT he, UINT firstIndex, UINT lastIndex, ELEMENT_COMPARATOR* cmpFunc, LPVOID cmpFuncParam ) { return SAPI()->SciterSortElements( he, firstIndex, lastIndex, cmpFunc, cmpFuncParam ); } + inline SCDOM_RESULT SCAPI SciterSwapElements( HELEMENT he1, HELEMENT he2 ) { return SAPI()->SciterSwapElements( he1,he2 ); } + inline SCDOM_RESULT SCAPI SciterTraverseUIEvent( UINT evt, LPVOID eventCtlStruct, SBOOL* bOutProcessed ) { return SAPI()->SciterTraverseUIEvent( evt,eventCtlStruct,bOutProcessed ); } + inline SCDOM_RESULT SCAPI SciterCallScriptingMethod( HELEMENT he, LPCSTR name, const VALUE* argv, UINT argc, VALUE* retval ) { return SAPI()->SciterCallScriptingMethod( he,name,argv,argc,retval ); } + inline SCDOM_RESULT SCAPI SciterCallScriptingFunction( HELEMENT he, LPCSTR name, const VALUE* argv, UINT argc, VALUE* retval ) { return SAPI()->SciterCallScriptingFunction( he,name,argv,argc,retval ); } + inline SCDOM_RESULT SCAPI SciterEvalElementScript( HELEMENT he, LPCWSTR script, UINT scriptLength, VALUE* retval ) { return SAPI()->SciterEvalElementScript( he, script, scriptLength, retval ); } + inline SCDOM_RESULT SCAPI SciterAttachHwndToElement(HELEMENT he, HWINDOW hwnd) { return SAPI()->SciterAttachHwndToElement(he,hwnd); } + inline SCDOM_RESULT SCAPI SciterControlGetType( HELEMENT he, /*CTL_TYPE*/ UINT *pType ) { return SAPI()->SciterControlGetType( he, pType ); } + inline SCDOM_RESULT SCAPI SciterGetValue( HELEMENT he, VALUE* pval ) { return SAPI()->SciterGetValue( he,pval ); } + inline SCDOM_RESULT SCAPI SciterSetValue( HELEMENT he, const VALUE* pval ) { return SAPI()->SciterSetValue( he, pval ); } + inline SCDOM_RESULT SCAPI SciterGetExpando( HELEMENT he, VALUE* pval, SBOOL forceCreation ) { return SAPI()->SciterGetExpando( he, pval, forceCreation ); } + //inline SCDOM_RESULT SCAPI SciterGetObject( HELEMENT he, void* pval, SBOOL forceCreation ) { return SAPI()->SciterGetObject( he, pval, forceCreation ); } + //inline SCDOM_RESULT SCAPI SciterGetElementNamespace( HELEMENT he, void* pval) { return SAPI()->SciterGetElementNamespace( he,pval); } + inline SCDOM_RESULT SCAPI SciterGetHighlightedElement(HWINDOW hwnd, HELEMENT* phe) { return SAPI()->SciterGetHighlightedElement(hwnd, phe); } + inline SCDOM_RESULT SCAPI SciterSetHighlightedElement(HWINDOW hwnd, HELEMENT he) { return SAPI()->SciterSetHighlightedElement(hwnd,he); } + inline SCDOM_RESULT SCAPI SciterNodeAddRef(HNODE hn) { return SAPI()->SciterNodeAddRef(hn); } + inline SCDOM_RESULT SCAPI SciterNodeRelease(HNODE hn) { return SAPI()->SciterNodeRelease(hn); } + inline SCDOM_RESULT SCAPI SciterNodeCastFromElement(HELEMENT he, HNODE* phn) { return SAPI()->SciterNodeCastFromElement(he,phn); } + inline SCDOM_RESULT SCAPI SciterNodeCastToElement(HNODE hn, HELEMENT* he) { return SAPI()->SciterNodeCastToElement(hn,he); } + inline SCDOM_RESULT SCAPI SciterNodeFirstChild(HNODE hn, HNODE* phn) { return SAPI()->SciterNodeFirstChild(hn,phn); } + inline SCDOM_RESULT SCAPI SciterNodeLastChild(HNODE hn, HNODE* phn) { return SAPI()->SciterNodeLastChild(hn, phn); } + inline SCDOM_RESULT SCAPI SciterNodeNextSibling(HNODE hn, HNODE* phn) { return SAPI()->SciterNodeNextSibling(hn, phn); } + inline SCDOM_RESULT SCAPI SciterNodePrevSibling(HNODE hn, HNODE* phn) { return SAPI()->SciterNodePrevSibling(hn,phn); } + inline SCDOM_RESULT SCAPI SciterNodeParent(HNODE hnode, HELEMENT* pheParent) { return SAPI()->SciterNodeParent(hnode,pheParent) ; } + inline SCDOM_RESULT SCAPI SciterNodeNthChild(HNODE hnode, UINT n, HNODE* phn) { return SAPI()->SciterNodeNthChild(hnode,n,phn); } + inline SCDOM_RESULT SCAPI SciterNodeChildrenCount(HNODE hnode, UINT* pn) { return SAPI()->SciterNodeChildrenCount(hnode, pn); } + inline SCDOM_RESULT SCAPI SciterNodeType(HNODE hnode, UINT* pNodeType /*NODE_TYPE*/) { return SAPI()->SciterNodeType(hnode,pNodeType); } + inline SCDOM_RESULT SCAPI SciterNodeGetText(HNODE hnode, LPCWSTR_RECEIVER* rcv, LPVOID rcv_param) { return SAPI()->SciterNodeGetText(hnode,rcv,rcv_param); } + inline SCDOM_RESULT SCAPI SciterNodeSetText(HNODE hnode, LPCWSTR text, UINT textLength) { return SAPI()->SciterNodeSetText(hnode,text,textLength); } + inline SCDOM_RESULT SCAPI SciterNodeInsert(HNODE hnode, UINT where /*NODE_INS_TARGET*/, HNODE what) { return SAPI()->SciterNodeInsert(hnode,where,what); } + inline SCDOM_RESULT SCAPI SciterNodeRemove(HNODE hnode, SBOOL finalize) { return SAPI()->SciterNodeRemove(hnode,finalize); } + inline SCDOM_RESULT SCAPI SciterCreateTextNode(LPCWSTR text, UINT textLength, HNODE* phnode) { return SAPI()->SciterCreateTextNode(text,textLength,phnode); } + inline SCDOM_RESULT SCAPI SciterCreateCommentNode(LPCWSTR text, UINT textLength, HNODE* phnode) { return SAPI()->SciterCreateCommentNode(text,textLength,phnode); } + + //inline HVM SCAPI SciterGetVM( HWINDOW hwnd ) { return SAPI()->SciterGetVM(hwnd); } + + inline UINT SCAPI ValueInit ( VALUE* pval ) { return SAPI()->ValueInit(pval); } + inline UINT SCAPI ValueClear ( VALUE* pval ) { return SAPI()->ValueClear(pval); } + inline UINT SCAPI ValueCompare ( const VALUE* pval1, const VALUE* pval2 ) { return SAPI()->ValueCompare(pval1,pval2); } + inline UINT SCAPI ValueCopy ( VALUE* pdst, const VALUE* psrc ) { return SAPI()->ValueCopy(pdst, psrc); } + inline UINT SCAPI ValueIsolate ( VALUE* pdst ) { return SAPI()->ValueIsolate(pdst); } + inline UINT SCAPI ValueType ( const VALUE* pval, UINT* pType, UINT* pUnits ) { return SAPI()->ValueType(pval,pType,pUnits); } + inline UINT SCAPI ValueStringData ( const VALUE* pval, LPCWSTR* pChars, UINT* pNumChars ) { return SAPI()->ValueStringData(pval,pChars,pNumChars); } + inline UINT SCAPI ValueStringDataSet ( VALUE* pval, LPCWSTR chars, UINT numChars, UINT units ) { return SAPI()->ValueStringDataSet(pval, chars, numChars, units); } + inline UINT SCAPI ValueIntData ( const VALUE* pval, INT* pData ) { return SAPI()->ValueIntData ( pval, pData ); } + inline UINT SCAPI ValueIntDataSet ( VALUE* pval, INT data, UINT type, UINT units ) { return SAPI()->ValueIntDataSet ( pval, data,type,units ); } + inline UINT SCAPI ValueInt64Data ( const VALUE* pval, INT64* pData ) { return SAPI()->ValueInt64Data ( pval,pData ); } + inline UINT SCAPI ValueInt64DataSet ( VALUE* pval, INT64 data, UINT type, UINT units ) { return SAPI()->ValueInt64DataSet ( pval,data,type,units ); } + inline UINT SCAPI ValueFloatData ( const VALUE* pval, FLOAT_VALUE* pData ) { return SAPI()->ValueFloatData ( pval,pData ); } + inline UINT SCAPI ValueFloatDataSet ( VALUE* pval, FLOAT_VALUE data, UINT type, UINT units ) { return SAPI()->ValueFloatDataSet ( pval,data,type,units ); } + inline UINT SCAPI ValueBinaryData ( const VALUE* pval, LPCBYTE* pBytes, UINT* pnBytes ) { return SAPI()->ValueBinaryData ( pval,pBytes,pnBytes ); } + inline UINT SCAPI ValueBinaryDataSet ( VALUE* pval, LPCBYTE pBytes, UINT nBytes, UINT type, UINT units ) { return SAPI()->ValueBinaryDataSet ( pval,pBytes,nBytes,type,units ); } + inline UINT SCAPI ValueElementsCount ( const VALUE* pval, INT* pn) { return SAPI()->ValueElementsCount ( pval,pn); } + inline UINT SCAPI ValueNthElementValue ( const VALUE* pval, INT n, VALUE* pretval) { return SAPI()->ValueNthElementValue ( pval, n, pretval); } + inline UINT SCAPI ValueNthElementValueSet ( VALUE* pval, INT n, const VALUE* pval_to_set) { return SAPI()->ValueNthElementValueSet ( pval,n,pval_to_set); } + inline UINT SCAPI ValueNthElementKey ( const VALUE* pval, INT n, VALUE* pretval) { return SAPI()->ValueNthElementKey ( pval,n,pretval); } + inline UINT SCAPI ValueEnumElements ( const VALUE* pval, KeyValueCallback* penum, LPVOID param) { return SAPI()->ValueEnumElements (pval,penum,param); } + inline UINT SCAPI ValueSetValueToKey ( VALUE* pval, const VALUE* pkey, const VALUE* pval_to_set) { return SAPI()->ValueSetValueToKey ( pval, pkey, pval_to_set); } + inline UINT SCAPI ValueGetValueOfKey ( const VALUE* pval, const VALUE* pkey, VALUE* pretval) { return SAPI()->ValueGetValueOfKey ( pval, pkey,pretval); } + inline UINT SCAPI ValueToString ( VALUE* pval, UINT how ) { return SAPI()->ValueToString ( pval,how ); } + inline UINT SCAPI ValueFromString ( VALUE* pval, LPCWSTR str, UINT strLength, UINT how ) { return SAPI()->ValueFromString ( pval, str,strLength,how ); } + inline UINT SCAPI ValueInvoke ( const VALUE* pval, VALUE* pthis, UINT argc, const VALUE* argv, VALUE* pretval, LPCWSTR url) { return SAPI()->ValueInvoke ( pval, pthis, argc, argv, pretval, url); } + inline UINT SCAPI ValueNativeFunctorSet (VALUE* pval, NATIVE_FUNCTOR_INVOKE* pinvoke, NATIVE_FUNCTOR_RELEASE* prelease, VOID* tag ) { return SAPI()->ValueNativeFunctorSet ( pval, pinvoke,prelease,tag); } + inline SBOOL SCAPI ValueIsNativeFunctor ( const VALUE* pval) { return SAPI()->ValueIsNativeFunctor (pval); } + +#if defined(WINDOWS) && !defined(WINDOWLESS) + inline SBOOL SCAPI SciterCreateOnDirectXWindow(HWINDOW hwnd, IUnknown* pSwapChain) { return SAPI()->SciterCreateOnDirectXWindow(hwnd,pSwapChain); } + inline SBOOL SCAPI SciterRenderOnDirectXWindow(HWINDOW hwnd, HELEMENT elementToRenderOrNull, SBOOL frontLayer) { return SAPI()->SciterRenderOnDirectXWindow(hwnd,elementToRenderOrNull,frontLayer); } + inline SBOOL SCAPI SciterRenderOnDirectXTexture(HWINDOW hwnd, HELEMENT elementToRenderOrNull, IUnknown* surface) { return SAPI()->SciterRenderOnDirectXTexture(hwnd,elementToRenderOrNull,surface); } +#endif + + inline SBOOL SCAPI SciterProcX(HWINDOW hwnd, SCITER_X_MSG* pMsg) { return SAPI()->SciterProcX(hwnd, pMsg); } +#ifdef __cplusplus + template + inline SBOOL SCAPI SciterProcX(HWINDOW hwnd, const MSG &msg) { + static_assert(offsetof(MSG, header) == 0, "must contain SCITER_X_MSG as first memeber"); + static_assert(std::is_same::value, "must contain SCITER_X_MSG"); + return SAPI()->SciterProcX(hwnd, (SCITER_X_MSG*)(&msg)); + } +#endif + + inline UINT64 SCAPI SciterAtomValue(const char* name) { return SAPI()->SciterAtomValue(name); } + inline UINT64 SCAPI SciterAtomNameCB(UINT64 atomv, LPCSTR_RECEIVER* rcv, LPVOID rcv_param) { return SAPI()->SciterAtomNameCB(atomv, rcv, rcv_param); } + inline SBOOL SCAPI SciterSetGlobalAsset(som_asset_t* pass) { return SAPI()->SciterSetGlobalAsset(pass); } + + inline UINT SCAPI SciterElementUnwrap(const VALUE* pval, HELEMENT* ppElement) { return SAPI()->SciterElementUnwrap(pval, ppElement); } + inline UINT SCAPI SciterElementWrap(VALUE* pval, HELEMENT pElement) { return SAPI()->SciterElementWrap(pval, pElement); } + + inline UINT SCAPI SciterNodeUnwrap(const VALUE* pval, HNODE* ppNode) { return SAPI()->SciterNodeUnwrap(pval, ppNode); } + inline UINT SCAPI SciterNodeWrap(VALUE* pval, HNODE pNode) { return SAPI()->SciterNodeWrap(pval, pNode); } + #endif diff --git a/include/sciter-x-behavior.h b/include/sciter-x-behavior.h index 5841eaf..dbc95c1 100644 --- a/include/sciter-x-behavior.h +++ b/include/sciter-x-behavior.h @@ -1,10 +1,10 @@ /* * The Sciter Engine of Terra Informatica Software, Inc. * http://sciter.com - * + * * The code and information provided "as-is" without * warranty of any kind, either expressed or implied. - * + * * (C) 2003-2015, Terra Informatica Software, Inc. */ @@ -45,7 +45,7 @@ a.k.a. notifications from intrinsic behaviors */ HANDLE_METHOD_CALL = 0x0200, /**< behavior specific methods */ HANDLE_SCRIPTING_METHOD_CALL = 0x0400, /**< behavior specific methods */ - HANDLE_TISCRIPT_METHOD_CALL = 0x0800, /**< behavior specific methods using direct tiscript::value's */ + //HANDLE_TISCRIPT_METHOD_CALL = 0x0800, /**< behavior specific methods using direct tiscript::value's */ HANDLE_EXCHANGE = 0x1000, /**< system drag-n-drop */ HANDLE_GESTURE = 0x2000, /**< touch input events */ @@ -65,10 +65,10 @@ * \return true if event was handled, false otherwise. **/ -typedef BOOL SC_CALLBACK ElementEventProc(LPVOID tag, HELEMENT he, UINT evtg, LPVOID prms ); +typedef SBOOL SC_CALLBACK ElementEventProc(LPVOID tag, HELEMENT he, UINT evtg, LPVOID prms ); typedef ElementEventProc * LPElementEventProc; // signature of the function exported from external behavior/dll. -typedef BOOL SC_CALLBACK SciterBehaviorFactory( LPCSTR, HELEMENT, LPElementEventProc*, LPVOID* ); +typedef SBOOL SC_CALLBACK SciterBehaviorFactory( LPCSTR, HELEMENT, LPElementEventProc*, LPVOID* ); enum PHASE_MASK { @@ -105,13 +105,13 @@ typedef BOOL SC_CALLBACK SciterBehaviorFactory( LPCSTR, HELEMENT, LPElementEvent UINT cmd; // INITIALIZATION_EVENTS }; - typedef enum SOM_EVENTS + enum SOM_EVENTS { SOM_GET_PASSPORT = 0, SOM_GET_ASSET = 1 - } SOM_EVENTS; + }; - typedef struct SOM_PARAMS + struct SOM_PARAMS { UINT cmd; // SOM_EVENTS union { @@ -121,7 +121,7 @@ typedef BOOL SC_CALLBACK SciterBehaviorFactory( LPCSTR, HELEMENT, LPElementEvent #ifdef __cplusplus SOM_PARAMS() : data() {} #endif - } SOM_PARAMS; + }; enum DRAGGING_TYPE { @@ -139,20 +139,28 @@ typedef BOOL SC_CALLBACK SciterBehaviorFactory( LPCSTR, HELEMENT, LPElementEvent MOUSE_MOVE, MOUSE_UP, MOUSE_DOWN, - MOUSE_DCLICK, + MOUSE_DCLICK, // double click MOUSE_WHEEL, MOUSE_TICK, // mouse pressed ticks MOUSE_IDLE, // mouse stay idle for some time - DROP = 9, // item dropped, target is that dropped item - DRAG_ENTER = 0xA, // drag arrived to the target element that is one of current drop targets. - DRAG_LEAVE = 0xB, // drag left one of current drop targets. target is the drop target element. - DRAG_REQUEST = 0xC, // drag src notification before drag start. To cancel - return true from handler. + /*OBSOLETE*/ DROP = 9, // item dropped, target is that dropped item + /*OBSOLETE*/ DRAG_ENTER = 0xA, // drag arrived to the target element that is one of current drop targets. + /*OBSOLETE*/ DRAG_LEAVE = 0xB, // drag left one of current drop targets. target is the drop target element. + /*OBSOLETE*/ DRAG_REQUEST = 0xC, // drag src notification before drag start. To cancel - return true from handler. + + MOUSE_TCLICK = 0xF, // tripple click + + MOUSE_TOUCH_START = 0xFC, // touch device pressed somehow + MOUSE_TOUCH_END = 0xFD, // touch device depressed - clear, nothing on it - MOUSE_CLICK = 0xFF, // mouse click event + MOUSE_DRAG_REQUEST = 0xFE, // mouse drag start detected event - DRAGGING = 0x100, // This flag is 'ORed' 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. + MOUSE_CLICK = 0xFF, // mouse click event + + /*OBSOLETE*/ DRAGGING = 0x100, // ORed with MOUSE_ENTER...MOUSE_DOWN codes above + + MOUSE_HIT_TEST = 0xFFE, // sent to element, allows to handle elements with non-trivial shapes. }; @@ -165,10 +173,10 @@ typedef BOOL SC_CALLBACK SciterBehaviorFactory( LPCSTR, HELEMENT, LPElementEvent UINT button_state; // MOUSE_BUTTONS UINT alt_state; // KEYBOARD_STATES UINT cursor_type; // CURSOR_TYPE to set, see CURSOR_TYPE - BOOL is_on_icon; // mouse is over icon (foreground-image, foreground-repeat:no-repeat) + SBOOL is_on_icon; // mouse is over icon (foreground-image, foreground-repeat:no-repeat) HELEMENT dragging; // element that is being dragged over, this field is not NULL if (cmd & DRAGGING) != 0 - UINT dragging_mode;// see DRAGGING_TYPE. + UINT dragging_mode;// see DRAGGING_TYPE. }; @@ -243,7 +251,7 @@ typedef BOOL SC_CALLBACK SciterBehaviorFactory( LPCSTR, HELEMENT, LPElementEvent HELEMENT target; /**< target element, for #FOCUS_LOST it is a handle of new focus element and for #FOCUS_GOT it is a handle of old focus element, can be NULL */ UINT cause; /**< focus cause params or FOCUS_CMD_TYPE for FOCUS_ADVANCE_REQUEST */ - BOOL cancel; /**< in #FOCUS_REQUEST and #FOCUS_LOST phase setting this field to true will cancel transfer focus from old element to the new one. */ + SBOOL cancel; /**< in #FOCUS_REQUEST and #FOCUS_LOST phase setting this field to true will cancel transfer focus from old element to the new one. */ }; // parameters of evtg == HANDLE_SCROLL @@ -261,24 +269,27 @@ typedef BOOL SC_CALLBACK SciterBehaviorFactory( LPCSTR, HELEMENT, LPElementEvent SCROLL_CORNER_PRESSED, SCROLL_CORNER_RELEASED, SCROLL_SLIDER_PRESSED, + + SCROLL_ANIMATION_START, + SCROLL_ANIMATION_END, }; enum SCROLL_SOURCE { SCROLL_SOURCE_UNKNOWN, SCROLL_SOURCE_KEYBOARD, // SCROLL_PARAMS::reason <- keyCode - SCROLL_SOURCE_SCROLLBAR, // SCROLL_PARAMS::reason <- SCROLLBAR_PART + SCROLL_SOURCE_SCROLLBAR, // SCROLL_PARAMS::reason <- SCROLLBAR_PART SCROLL_SOURCE_ANIMATOR, SCROLL_SOURCE_WHEEL, }; enum SCROLLBAR_PART { - SCROLLBAR_BASE, - SCROLLBAR_PLUS, - SCROLLBAR_MINUS, - SCROLLBAR_SLIDER, - SCROLLBAR_PAGE_MINUS, - SCROLLBAR_PAGE_PLUS, - SCROLLBAR_CORNER, + SCROLLBAR_BASE, + SCROLLBAR_PLUS, + SCROLLBAR_MINUS, + SCROLLBAR_SLIDER, + SCROLLBAR_PAGE_MINUS, + SCROLLBAR_PAGE_PLUS, + SCROLLBAR_CORNER, }; @@ -287,28 +298,33 @@ typedef BOOL SC_CALLBACK SciterBehaviorFactory( LPCSTR, HELEMENT, LPElementEvent UINT cmd; // SCROLL_EVENTS HELEMENT target; // target element INT pos; // scroll position if SCROLL_POS - BOOL vertical; // true if from vertical scrollbar + SBOOL vertical; // true if from vertical scrollbar UINT source; // SCROLL_SOURCE UINT reason; // key or scrollbar part }; enum GESTURE_CMD { - GESTURE_REQUEST = 0, // return true and fill flags if it will handle gestures. - GESTURE_ZOOM, // The zoom gesture. - GESTURE_PAN, // The pan gesture. - GESTURE_ROTATE, // The rotation gesture. - GESTURE_TAP1, // The tap gesture. - GESTURE_TAP2, // The two-finger tap gesture. + GESTURE_START = 0, + GESTURE_MOVE = 1, + GESTURE_END = 2, + + // logical events + GESTURE_PAN, // The pan gesture. + GESTURE_ZOOM, // The zoom gesture. + GESTURE_ROTATE, // The rotation gesture. + GESTURE_TAP1, // The tap gesture, a.k.a. click + GESTURE_TAP2, // The two-finger tap gesture, a.k.a. right-click + GESTURE_DOUBLE_TAP }; - enum GESTURE_STATE + enum GESTURE_STATE { GESTURE_STATE_BEGIN = 1, // starts GESTURE_STATE_INERTIA = 2, // events generated by inertia processor GESTURE_STATE_END = 4, // end, last event of the gesture sequence }; - enum GESTURE_TYPE_FLAGS // requested + enum GESTURE_TYPE_FLAGS // requested { GESTURE_FLAG_ZOOM = 0x0001, GESTURE_FLAG_ROTATE = 0x0002, @@ -328,23 +344,23 @@ typedef BOOL SC_CALLBACK SciterBehaviorFactory( LPCSTR, HELEMENT, LPElementEvent HELEMENT target; // target element POINT pos; // position of cursor, element relative POINT pos_view; // position of cursor, view relative - UINT flags; // for GESTURE_REQUEST combination of GESTURE_FLAGs. + UINT flags; // for GESTURE_REQUEST combination of GESTURE_FLAGs. // for others it is a combination of GESTURE_STATe's UINT delta_time; // period of time from previous event. - SIZE delta_xy; // for GESTURE_PAN it is a direction vector - double delta_v; // for GESTURE_ROTATE - delta angle (radians) - // for GESTURE_ZOOM - zoom value, is less or greater than 1.0 + SIZE delta_xy; // for GESTURE_PAN it is a direction vector + double delta_v; // for GESTURE_ROTATE - delta angle (radians) + // for GESTURE_ZOOM - zoom value, is less or greater than 1.0 }; enum EXCHANGE_CMD { X_DRAG_ENTER = 0, // drag enters the element - X_DRAG_LEAVE = 1, // drag leaves the element + X_DRAG_LEAVE = 1, // drag leaves the element X_DRAG = 2, // drag over the element - X_DROP = 3, // data dropped on the element + X_DROP = 3, // data dropped on the element X_PASTE = 4, // N/A X_DRAG_REQUEST = 5, // N/A X_DRAG_CANCEL = 6, // drag cancelled (e.g. by pressing VK_ESCAPE) - X_WILL_ACCEPT_DROP = 7, // drop target element shall consume this event in order to receive X_DROP + X_WILL_ACCEPT_DROP = 7, // drop target element shall consume this event in order to receive X_DROP }; enum DD_MODES { @@ -354,7 +370,7 @@ typedef BOOL SC_CALLBACK SciterBehaviorFactory( LPCSTR, HELEMENT, LPElementEvent DD_MODE_COPY_OR_MOVE = 3, // DROPEFFECT_COPY ( 1 ) | DROPEFFECT_MOVE ( 2 ) DD_MODE_LINK = 4, // DROPEFFECT_LINK ( 4 ) }; - + struct EXCHANGE_PARAMS { UINT cmd; // EXCHANGE_EVENTS @@ -362,7 +378,7 @@ typedef BOOL SC_CALLBACK SciterBehaviorFactory( LPCSTR, HELEMENT, LPElementEvent HELEMENT source; // source element (can be null if D&D from external window) POINT pos; // position of cursor, element relative POINT pos_view; // position of cursor, view relative - UINT mode; // DD_MODE + UINT mode; // DD_MODE SCITER_VALUE data; // packaged drag data }; @@ -399,7 +415,8 @@ typedef BOOL SC_CALLBACK SciterBehaviorFactory( LPCSTR, HELEMENT, LPElementEvent EDIT_VALUE_CHANGING = 3, // before text change EDIT_VALUE_CHANGED = 4, // after text change SELECT_SELECTION_CHANGED = 5, // selection in changed + SELECT_STATE_CHANGED = SELECT_VALUE_CHANGED, // OBSOLETE, alias of SELECT_VALUE_CHANGED POPUP_REQUEST = 7, // request to show popup just received, // here DOM of popup element can be modifed. @@ -435,38 +452,20 @@ typedef BOOL SC_CALLBACK SciterBehaviorFactory( LPCSTR, HELEMENT, LPElementEvent // "grey" event codes - notfications from behaviors from this SDK HYPERLINK_CLICK = 0x80, // hyperlink click - //TABLE_HEADER_CLICK, // click on some cell in table header, - // // target = the cell, - // // reason = index of the cell (column number, 0..n) - //TABLE_ROW_CLICK, // click on data row in the table, target is the row - // // target = the row, - // // reason = index of the row (fixed_rows..n) - //TABLE_ROW_DBL_CLICK, // mouse dbl click on data row in the table, target is the row - // // target = the row, - // // reason = index of the row (fixed_rows..n) - ELEMENT_COLLAPSED = 0x90, // element was collapsed, so far only behavior:tabs is sending these two to the panels ELEMENT_EXPANDED = 0x91, // element was expanded, ACTIVATE_CHILD = 0x92, // activate (select) child, // used for example by accesskeys behaviors to send activation request, e.g. tab on behavior:tabs. - //DO_SWITCH_TAB = ACTIVATE_CHILD,// command to switch tab programmatically, handled by behavior:tabs - // // use it as SciterPostEvent(tabsElementOrItsChild, DO_SWITCH_TAB, tabElementToShow, 0); - - //INIT_DATA_VIEW, // request to virtual grid to initialize its view - - //ROWS_DATA_REQUEST, // request from virtual grid to data source behavior to fill data in the table - // // parameters passed throug DATA_ROWS_PARAMS structure. - UI_STATE_CHANGED = 0x95, // ui state changed, observers shall update their visual states. // is sent for example by behavior:richtext when caret position/selection has changed. FORM_SUBMIT = 0x96, // 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 + // 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_RESET = 0x97, // 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 + // 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. DOCUMENT_COMPLETE = 0x98, // document in behavior:frame or root document is complete. @@ -476,7 +475,7 @@ typedef BOOL SC_CALLBACK SciterBehaviorFactory( LPCSTR, HELEMENT, LPElementEvent HISTORY_PRIOR = 0x9B, HISTORY_NEXT = 0x9C, HISTORY_STATE_CHANGED = 0x9D, // behavior:history notification - history stack has changed - + CLOSE_POPUP = 0x9E, // close popup request, REQUEST_TOOLTIP = 0x9F, // request tooltip, evt.source <- is the tooltip element. @@ -485,15 +484,15 @@ typedef BOOL SC_CALLBACK SciterBehaviorFactory( LPCSTR, HELEMENT, LPElementEvent DOCUMENT_CREATED = 0xC0, // document created, script namespace initialized. target -> the document DOCUMENT_CLOSE_REQUEST = 0xC1, // document is about to be closed, to cancel closing do: evt.data = sciter::value("cancel"); DOCUMENT_CLOSE = 0xC2, // last notification before document removal from the DOM - DOCUMENT_READY = 0xC3, // document has got DOM structure, styles and behaviors of DOM elements. Script loading run is complete at this moment. + DOCUMENT_READY = 0xC3, // document has got DOM structure, styles and behaviors of DOM elements. Script loading run is complete at this moment. DOCUMENT_PARSED = 0xC4, // document just finished parsing - has got DOM structure. This event is generated before DOCUMENT_READY - VIDEO_INITIALIZED = 0xD1, //