Sciter; PB 5.42 LTS; Any prototypes available?

Windows specific forum
HanPBF
Enthusiast
Enthusiast
Posts: 563
Joined: Fri Feb 19, 2010 3:42 am

Sciter; PB 5.42 LTS; Any prototypes available?

Post by HanPBF »

Below are the files to check Sciter.

You additionally need Sciter32.dll.

Are the protoypes defined somewhere?

Anybody made Sciter running with PB incl. callbacks?

Thanks a lot!



Main.pb:

Code: Select all



EnableExplicit



define NrLibSciter
define FName.s

declare		getWindowNrFromHandle										(Handle)
declare.q	PeekUI																	(*addr.Long)
declare		PokeUI																	(*addr.Long, number.q)


Structure SciterRect
	Left			.i
	Top				.i
	Right			.i
	Bottom		.i
EndStructure


Prototype SciterAPIPrototype()
Prototype	SciterClassNamePrototype()
Prototype SciterLoadFilePrototype(hWndSciter, *Filename) ; BOOL    SCAPI SciterLoadFile (HWINDOW hWndSciter, LPCWSTR filename) { return SAPI()->SciterLoadFile (hWndSciter,filename); }
Prototype SciterProcNDPrototype(hwnd, msg, wParam, lParam, *Handled) ;	LRESULT SCAPI SciterProcND (HWINDOW hwnd, UINT msg, WPARAM wParam, LPARAM lParam, BOOL* pbHandled) 
Prototype SciterVersionPrototype(Major)

Prototype SciterWindowDelegate(hwnd, msg, wParam, lParam, pParam, *handled);
Prototype SciterCreateWindowPrototype(CreationFlags, *Frame.Rect, delegate.SciterWindowDelegate, delegateParam, parent) ; HWINDOW SCFN( SciterCreateWindow )( UINT creationFlags,LPRECT frame, SciterWindowDelegate* delegate, LPVOID delegateParam, HWINDOW parent);



Structure Sciter
	PVersion																.i
	ClassName																.SciterClassNamePrototype
	Version																	.SciterVersionPrototype
	DataReady																.i
	DataReadyAsync                          .i
	Proc                                    .i
	ProcND                                  .SciterProcNDPrototype
	LoadFile                                .SciterLoadFilePrototype
	LoadHtml                                .i
	SetCallback                             .i
	SetMasterCSS                            .i
	AppendMasterCSS                         .i
	SetCSS                                  .i
	SetMediaType                            .i
	SetMediaVars                            .i
	GetMinWidth                             .i
	GetMinHeight                            .i
	Call                                    .i
	Eval                                    .i
	UpdateWindow                            .i
	TranslateMessage                        .i
	SetOption                               .i
	GetPPI                                  .i
	GetViewExpando                          .i
	RenderD2D                               .i
	D2DFactory                              .i
	DWFactory                               .i
	GraphicsCaps                            .i
	SetHomeURL                              .i
	CreateWindow                            .SciterCreateWindowPrototype
	SetupDebugOutput                        .i
	_UseElement                             .i
	_UnuseElement                           .i
	GetRootElement                          .i
	GetFocusElement                         .i
	FindElement                             .i
	GetChildrenCount                        .i
	GetNthChild                             .i
	GetParentElement                        .i
	GetElementHtmlCB                        .i
	GetElementTextCB                        .i
	SetElementText                          .i
	GetAttributeCount                       .i
	GetNthAttributeNameCB                   .i
	GetNthAttributeValueCB                  .i
	GetAttributeByNameCB                    .i
	SetAttributeByName                      .i
	ClearAttributes                         .i
	GetElementIndex                         .i
	GetElementType                          .i
	GetElementTypeCB                        .i
	GetStyleAttributeCB                     .i
	SetStyleAttribute                       .i
	GetElementLocation                      .i
	ScrollToView                            .i
	UpdateElement                           .i
	RefreshElementArea                      .i
	SetCapture                              .i
	ReleaseCapture                          .i
	GetElementHwnd                          .i
	CombineURL                              .i
	SelectElements                          .i
	SelectElementsW                         .i
	SelectParent                            .i
	SelectParentW                           .i
	SetElementHtml                          .i
	GetElementUID                           .i
	GetElementByUID                         .i
	ShowPopup                               .i
	ShowPopupAt                             .i
	HidePopup                               .i
	GetElementState                         .i
	SetElementState                         .i
	CreateElement                           .i
	CloneElement                            .i
	InsertElement                           .i
	DetachElement                           .i
	DeleteElement                           .i
	SetTimer                                .i
	DetachEventHandler                      .i
	AttachEventHandler                      .i
	WindowAttachEventHandler                .i
	WindowDetachEventHandler                .i
	SendEvent                               .i
	PostEvent                               .i
	CallBehaviorMethod                      .i
	RequestElementData                      .i
	HttpRequest                             .i
	GetScrollInfo                           .i
	SetScrollPos                            .i
	GetElementIntrinsicWidths               .i
	GetElementIntrinsicHeight               .i
	IsElementVisible                        .i
	IsElementEnabled                        .i
	SortElements                            .i
	SwapElements                            .i
	TraverseUIEvent                         .i
	CallScriptingMethod                     .i
	CallScriptingFunction                   .i
	EvalElementScript                       .i
	AttachHwndToElement                     .i
	ControlGetType                          .i
	GetValue                                .i
	SetValue                                .i
	GetExpando                              .i
	GetObject                               .i
	GetElementNamespace                     .i
	GetHighlightedElement                   .i
	SetHighlightedElement                   .i
	NodeAddRef                              .i
	NodeRelease                             .i
	NodeCastFromElement                     .i
	NodeCastToElement                       .i
	NodeFirstChild                          .i
	NodeLastChild                           .i
	NodeNextSibling                         .i
	NodePrevSibling                         .i
	NodeParent                              .i
	NodeNthChild                            .i
	NodeChildrenCount                       .i
	NodeType                                .i
	NodeGetText                             .i
	NodeSetText                             .i
	NodeInsert                              .i
	NodeRemove                              .i
	CreateTextNode                          .i
	CreateCommentNode                       .i
	ValueInit                               .i
	ValueClear                              .i
	ValueCompare                            .i
	ValueCopy                               .i
	ValueIsolate                            .i
	ValueType                               .i
	ValueStringData                         .i
	ValueStringDataSet                      .i
	ValueIntData                            .i
	ValueIntDataSet                         .i
	ValueInt64Data                          .i
	ValueInt64DataSet                       .i
	ValueFloatData                          .i
	ValueFloatDataSet                       .i
	ValueBinaryData                         .i
	ValueBinaryDataSet                      .i
	ValueElementsCount                      .i
	ValueNthElementValue                    .i
	ValueNthElementValueSet                 .i
	ValueNthElementKey                      .i
	ValueEnumElements                       .i
	ValueSetValueToKey                      .i
	ValueGetValueOfKey                      .i
	ValueToString                           .i
	ValueFromString                         .i
	ValueInvoke                             .i
	ValueNativeFunctorSet                   .i
	ValueIsNativeFunctor                    .i
	TIScriptAPI                             .i
	GetVM                                   .i
	_v2V                                    .i		; (HVM vm, tiscript_value script_value, VALUE* value, BOOL isolate)
	_v2vV                                   .i		; (HVM vm, const VALUE* valuev, tiscript_value* script_value)
	OpenArchive                             .i
	GetArchiveItem                          .i
	CloseArchive                            .i
	FireEvent                               .i
	GetCallbackParam                        .i
	PostCallback                            .i
	GetSciterGraphicsAPI                    .i
	GetSciterRequestAPI                     .i
	CreateOnDirectXWindow                   .i
	RenderOnDirectXWindow                   .i
	RenderOnDirectXTexture									.i
EndStructure



global *Sciter.Sciter


Procedure SciterCallback(hwnd, msg, wParam, lParam);, pParam, *handled)
	Protected R
	Protected	bHandled	.b
	
	R = *Sciter\ProcND(hwnd, msg, wParam, lParam, @bHandled)
	
	if bHandled
		procedurereturn R
	endif
	
	select msg
		case #WM_CREATE
			*Sciter\LoadFile(hwnd, @"test-inputs.html");
			
		default
		
	endSelect
	
	ProcedureReturn #PB_ProcessPureBasicEvents
endProcedure ; SciterCallback(hwnd, msg, wParam, lParam);, pParam, *handled)




define SciterAPI.SciterAPIPrototype


NrLibSciter = OpenLibrary(#PB_Any, "Sciter32.dll")

if NrLibSciter
	SciterAPI = GetFunctionEntry(NrLibSciter, 1)
	
	*Sciter = SciterAPI()
	
		
	define *Rect.Rect = AllocateStructure(Rect)
	with *Rect
		\left		= 16
		\top		= 16
		\right	= 16 + 480
		\bottom = 16 + 320
	endWith
	
	SetWindowCallback(@SciterCallback());, NrWindow)
	
	define NrWindow = openWindow(#PB_Any, 16, 16, 480, 320, "Test Sciter", #PB_Window_SizeGadget | #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget)
	
	
	
	if NrWindow
		repeat
			define Event = WaitWindowEvent()
			
			if Event = #PB_Event_CloseWindow
				break
			endif
		forever	
	endif

else
	Debug "OpenLibrary('Sciter32.dll') not successful"
	
endif



end



procedure getWindowNrFromHandle(Handle)
	define R = GetProp_(Handle, "PB_WindowID") - 1
	
	procedureReturn R
endProcedure
	
Procedure.q PeekUI(*addr.Long)
   ;-- Reads 4 bytes from the specified memory address,
   ;   and returns the value as *unsigned* integer
   ;   (minimum = 0, maximum = 4294967295).

   If *addr\l < 0
      ProcedureReturn *addr\l + $100000000
   Else
      ProcedureReturn *addr\l
   EndIf
EndProcedure ; .q PeekUI(*addr.Long)

Procedure PokeUI(*addr.Long, number.q)
   ;-- Writes an *unsigned* integer of 4 bytes size
   ;   to the specified memory address.

   If number >= 0 And number <= $FFFFFFFF
      If number > $7FFFFFFF
         *addr\l = number - $100000000
      Else
         *addr\l = number
      EndIf
   EndIf
EndProcedure ; PokeUI(*addr.Long, number.q)
test-inputs.html:

Code: Select all

<html>
  <head>
    <title>Basic set of inputs</title>
    <style>
      div.h-flow
      {
        flow:horizontal-flow;
        padding:0;
        border-spacing:10px;
      }
      div.h-flow > *
      {
        //display:block;
        height:*;
        min-height:100px;
      }
      select { vertical-align:baseline; }
      
      button {
        font:system;
        font-rendering-mode:snap-pixel;
      }
      
      //*:focus { background:yellow; }*/
      
    
    </style>
    <script type="text/tiscript"></script>
  </head>
<body>
  <h2>Standard HTML4 inputs</h2>
  
  <h3>Inline-block versions</h3>
  select:
  <select size=4>
    <optgroup label="First quater">
      <option>One</option>
      <option selected>Two</option>
      <option>Three</option>
      <option>Four</option>
    </optgroup>
    <option>Five</option>
    <option>Six</option>
    <option>Seven</option>
    <option>Eight</option>
    <option>Nine</option>
    <option>Ten</option>
    <option>Eleven</option>
    <option>Twelve</option>
  </select>
  
  combobox <select>
    <option>One</option>
    <option>Two</option>
    <option>Three</option>
    <option selected>Four</option>
    <option>Five</option>
    <option>Six</option>
    <option>Seven</option>
    <option>Eight</option>
    <option>Nine</option>
    <option>Ten</option>
    <option>Eleven</option>
    <option>Twelve</option>
  </select>

  textarea <textarea cols=40 rows=4>Sample</textarea>
  edit <input type="text" value="" />
  <button type="checkbox">Checkbox</button>
  <button type="radio" name="rg1" checked>radio 1</button>
         <button type="radio" name="rg1">radio 2</button>
         <button type="radio" name="rg1">radio 3</button>
  
  <h2>HTML5 + HSMILE inputs</h2>  
  <p>Date: <input type="date" value="today" /> 
    Time: <input type="time" value="now" />
  </p> 
  
  <p>input type=number:<input!number step=10 min=40 max=160/></p>
  <p>input type=decimal:<input!decimal step=10 min=40 max=160/></p>
  
  <p>Calendar: <input type="calendar" value="today" /></p>
  
  <h2>Block versions</h2>
  <div .h-flow>
    <select size=4 .block>
      <optgroup label="First quarter">
        <option>One</option>
        <option>Two</option>
        <option>Three</option>
        <option>Four</option>
      </optgroup>
      <optgroup label="Second quarter">
        <option>Five</option>
        <option>Six</option>
        <option>Seven</option>
        <option>Eight</option>
      </optgroup>
      <optgroup label="Third quarter">
        <option>Nine</option>
        <option>Ten</option>
        <option>Eleven</option>
        <option>Twelve</option>
      </optgroup>
    </select>
    <textarea cols=40 rows=4>Sample</textarea>
  </div>

</body>
</html>
LuckyLuke
Enthusiast
Enthusiast
Posts: 181
Joined: Fri Jun 06, 2003 2:41 pm
Location: Belgium

Re: Sciter; PB 5.42 LTS; Any prototypes available?

Post by LuckyLuke »

Hi,

Just wondering if someone managed to made Sciter running with PB incl. callbacks ?
Maybe we can start a community project for this ?

Thanks.

LuckyLuke
privetamerica
New User
New User
Posts: 1
Joined: Sat Jul 21, 2018 5:33 pm

Re: Sciter; PB 5.42 LTS; Any prototypes available?

Post by privetamerica »

LuckyLuke wrote:Hi,

Just wondering if someone managed to made Sciter running with PB incl. callbacks ?
Maybe we can start a community project for this ?

Thanks.

Code: Select all

Define SCDOM_RESULT.l=0
Define SCDOM_OK= 0
Define SCDOM_INVALID_HWND= 1
Define SCDOM_INVALID_HANDLE= 2
Define SCDOM_PASSIVE_HANDLE= 3
Define SCDOM_INVALID_PARAMETER= 4
Define SCDOM_OPERATION_FAILED= 5
Define SCDOM_OK_NOT_HANDLED= (-1)

Define NrLibSciter
Define FName.s

Declare     getWindowNrFromHandle(Handle)
Declare.q   PeekUI(*addr.Long)
Declare     PokeUI(*addr.Long, number.q)


Structure SciterRect
   Left         .i
   Top            .i
   Right         .i
   Bottom      .i
EndStructure


Prototype SciterAPIPrototype()
Prototype SciterClassNamePrototype()
Prototype SciterLoadFilePrototype(hWndSciter, *Filename) ; BOOL    SCAPI SciterLoadFile (HWINDOW hWndSciter, LPCWSTR filename) { return SAPI()->SciterLoadFile (hWndSciter,filename); }
Prototype SciterProcNDPrototype(hwnd, msg, wParam, lParam, *Handled) ;   LRESULT SCAPI SciterProcND (HWINDOW hwnd, UINT msg, WPARAM wParam, LPARAM lParam, BOOL* pbHandled) 
Prototype SciterVersionPrototype(Major)

Prototype SciterWindowDelegate(hwnd, msg, wParam, lParam, pParam, *handled);
Prototype SciterCreateWindowPrototype(CreationFlags, *Frame.Rect, delegate.SciterWindowDelegate, delegateParam, parent) ; HWINDOW SCFN( SciterCreateWindow )( UINT creationFlags,LPRECT frame, SciterWindowDelegate* delegate, LPVOID delegateParam, HWINDOW parent);

Prototype SciterFunc()
Prototype SelectElements(hElem, *cssSelector, *callBackFunctiouForFound, *paramForCallBack)
Prototype SelectElementsW(hElem, *cssSelector, *callBackFunctionForFound, paramForCallBack$)
Prototype GetRootElement(hwnd, hElem)
Prototype SciterAttachEventHandler(hElem, *serverFunction, *tag) 
Prototype DetachEventHandler(hElem, *serverFunction, *tag)
Prototype DetachElement(hElem)
;Interface FIFOProcessor Extends FIFOSamplePipe


Structure Sciter
   PVersion.i
   ClassName.SciterClassNamePrototype
   Version.SciterVersionPrototype
   DataReady.i
   DataReadyAsync.i
   Proc                                    .i
   ProcND                                  .SciterProcNDPrototype
   LoadFile                                .SciterLoadFilePrototype
   LoadHtml                                .i
   SetCallback                             .i
   SetMasterCSS                            .i
   AppendMasterCSS                         .i
   SetCSS                                  .i
   SetMediaType                            .i
   SetMediaVars                            .i
   GetMinWidth                             .i
   GetMinHeight                            .i
   Call                                    .i
   Eval                                    .i
   UpdateWindow                            .i
   TranslateMessage                        .i
   SetOption                               .i
   GetPPI                                  .i
   GetViewExpando                          .i
   RenderD2D                               .i
   D2DFactory                              .i
   DWFactory                               .i
   GraphicsCaps                            .i
   SetHomeURL                              .i
   CreateWindow                            .SciterCreateWindowPrototype
   SetupDebugOutput                        .i
   _UseElement                             .i
   _UnuseElement                           .i
   GetRootElement.GetRootElement
   GetFocusElement.SciterFunc;GetFocusElement()
   FindElement                             .i
   GetChildrenCount                        .i
   GetNthChild                             .i
   GetParentElement                        .i
   GetElementHtmlCB                        .i
   GetElementTextCB                        .i
   SetElementText                          .i
   GetAttributeCount                       .i
   GetNthAttributeNameCB                   .i
   GetNthAttributeValueCB                  .i
   GetAttributeByNameCB                    .i
   SetAttributeByName                      .i
   ClearAttributes                         .i
   GetElementIndex                         .i
   GetElementType                          .i
   GetElementTypeCB                        .i
   GetStyleAttributeCB                     .i
   SetStyleAttribute                       .i
   GetElementLocation                      .i
   ScrollToView                            .i
   UpdateElement                           .i
   RefreshElementArea                      .i
   SetCapture                              .i
   ReleaseCapture                          .i
   GetElementHwnd                          .i
   CombineURL                              .i
   SelectElements                          .SelectElements
   SelectElementsW                         .SelectElementsW
   SelectParent                            .i
   SelectParentW                           .i
   SetElementHtml                          .i
   GetElementUID                           .i
   GetElementByUID                         .i
   ShowPopup                               .i
   ShowPopupAt                             .i
   HidePopup                               .i
   GetElementState                         .i
   SetElementState                         .i
   CreateElement                           .i
   CloneElement                            .i
   InsertElement                           .i
   DetachElement.DetachElement
   DeleteElement                           .i
   SetTimer                                .i
   DetachEventHandler.DetachEventHandler
   AttachEventHandler.SciterAttachEventHandler
   WindowAttachEventHandler                .i
   WindowDetachEventHandler                .i
   SendEvent                               .i
   PostEvent                               .i
   CallBehaviorMethod                      .i
   RequestElementData                      .i
   HttpRequest                             .i
   GetScrollInfo                           .i
   SetScrollPos                            .i
   GetElementIntrinsicWidths               .i
   GetElementIntrinsicHeight               .i
   IsElementVisible                        .i
   IsElementEnabled                        .i
   SortElements                            .i
   SwapElements                            .i
   TraverseUIEvent                         .i
   CallScriptingMethod                     .i
   CallScriptingFunction                   .i
   EvalElementScript                       .i
   AttachHwndToElement                     .i
   ControlGetType                          .i
   GetValue                                .i
   SetValue                                .i
   GetExpando                              .i
   GetObject                               .i
   GetElementNamespace                     .i
   GetHighlightedElement                   .i
   SetHighlightedElement                   .i
   NodeAddRef                              .i
   NodeRelease                             .i
   NodeCastFromElement                     .i
   NodeCastToElement                       .i
   NodeFirstChild                          .i
   NodeLastChild                           .i
   NodeNextSibling                         .i
   NodePrevSibling                         .i
   NodeParent                              .i
   NodeNthChild                            .i
   NodeChildrenCount                       .i
   NodeType                                .i
   NodeGetText                             .i
   NodeSetText                             .i
   NodeInsert                              .i
   NodeRemove                              .i
   CreateTextNode                          .i
   CreateCommentNode                       .i
   ValueInit                               .i
   ValueClear                              .i
   ValueCompare                            .i
   ValueCopy                               .i
   ValueIsolate                            .i
   ValueType                               .i
   ValueStringData                         .i
   ValueStringDataSet                      .i
   ValueIntData                            .i
   ValueIntDataSet                         .i
   ValueInt64Data                          .i
   ValueInt64DataSet                       .i
   ValueFloatData                          .i
   ValueFloatDataSet                       .i
   ValueBinaryData                         .i
   ValueBinaryDataSet                      .i
   ValueElementsCount                      .i
   ValueNthElementValue                    .i
   ValueNthElementValueSet                 .i
   ValueNthElementKey                      .i
   ValueEnumElements                       .i
   ValueSetValueToKey                      .i
   ValueGetValueOfKey                      .i
   ValueToString                           .i
   ValueFromString                         .i
   ValueInvoke                             .i
   ValueNativeFunctorSet                   .i
   ValueIsNativeFunctor                    .i
   TIScriptAPI                             .i
   GetVM                                   .i
   _v2V                                    .i      ; (HVM vm, tiscript_value script_value, VALUE* value, BOOL isolate)
   _v2vV                                   .i      ; (HVM vm, const VALUE* valuev, tiscript_value* script_value)
   OpenArchive                             .i
   GetArchiveItem                          .i
   CloseArchive                            .i
   FireEvent                               .i
   GetCallbackParam                        .i
   PostCallback                            .i
   GetSciterGraphicsAPI                    .i
   GetSciterRequestAPI                     .i
   CreateOnDirectXWindow                   .i
   RenderOnDirectXWindow                   .i
   RenderOnDirectXTexture                           .i
EndStructure



Global *Sciter.Sciter


Procedure SciterCallback(hwnd, msg, wParam, lParam);, pParam, *handled)
   Protected R
   Protected bHandled.b
   
   R = *Sciter\ProcND(hwnd, msg, wParam, lParam, @bHandled)
   If bHandled
      ProcedureReturn R; сейчас все обрабатывает sciter
   EndIf
   
   Select msg
      Case #WM_CREATE
      	*Sciter\LoadFile(hwnd, @"test.html");
      Default
      
   EndSelect
   
   ProcedureReturn #PB_ProcessPureBasicEvents
EndProcedure ; SciterCallback(hwnd, msg, wParam, lParam);, pParam, *handled)


Enumeration EVENT_GROUPS
      #HANDLE_INITIALIZATION = $0000; 0 /**< attached/detached */
      #HANDLE_MOUSE = $0001;          1 /**< mouse events */
      #HANDLE_KEY = $0002;            2 /**< key events */
      #HANDLE_FOCUS = $0004;          4 /**< focus events, If this flag is set it also means that element it attached To is focusable */
      #HANDLE_SCROLL = $0008;         8 /**< scroll events */
      #HANDLE_TIMER = $0010;          16 /**< timer event */
      #HANDLE_SIZE = $0020;           32 /**< size changed event */
      #HANDLE_DRAW = $0040;           64 /**< drawing request (event) */
      #HANDLE_DATA_ARRIVED = $080;    128 /**< requested Data () has been delivered */
      #HANDLE_BEHAVIOR_EVENT        = $0100; /**< logical, synthetic events:  BUTTON_CLICK, HYPERLINK_CLICK, etc., a.k.a. notifications from intrinsic behaviors */
      #HANDLE_METHOD_CALL           = $0200; /**< behavior specific methods */
      #HANDLE_SCRIPTING_METHOD_CALL = $0400; /**< behavior specific methods */
      #HANDLE_TISCRIPT_METHOD_CALL  = $0800; /**< behavior specific methods using direct tiscript::value's */
      #HANDLE_EXCHANGE              = $1000; /**< system drag-n-drop */
      #HANDLE_GESTURE               = $2000; /**< touch input events */
      #HANDLE_ALL                   = $FFFF; /*< all of them */
      #SUBSCRIPTIONS_REQUEST        = $FFFFFFFF; /**< special value For getting subscription flags */
EndEnumeration

Enumeration MOUSE_EVENTS
      #MOUSE_ENTER = 0
      #MOUSE_LEAVE
      #MOUSE_MOVE
      #MOUSE_UP; for right button and dbclick for left
      #MOUSE_DOWN
      #MOUSE_DCLICK
      #MOUSE_WHEEL
      #MOUSE_TICK ; mouse pressed ticks
      #MOUSE_IDLE ; mouse stay idle For some time
      #DROP;   item dropped, target is that dropped item
      #DRAG_ENTER		; drag arrived To the target element that is one of current drop targets.
      #DRAG_LEAVE		; drag left one of current drop targets. target is the drop target element.
      #DRAG_REQUEST	; drag src notification before drag start. To cancel - Return true from handler.

      #MOUSE_CLICK = $FF; mouse click event
      #DRAGGING = $100;    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_LEFT_BUTTON_DOWN  = 32771
			#MOUSE_LEFT_BUTTON_UP= 65539
EndEnumeration

Enumeration PHASE_MASK
  #BUBBLING = 0;      // bubbling (emersion) phase т.е. всплытие события наверх
  #SINKING  = $8000;  // capture (immersion) phase, т.е. погружение 
  #HANDLED = $10000;  // see: http://www.w3.org/TR/xml-events/Overview.html#s_intro
EndEnumeration

Enumeration MOUSE_BUTTONS
      #MAIN_MOUSE_BUTTON = 1; //aka left button
      #PROP_MOUSE_BUTTON = 2; //aka right button
      #MIDDLE_MOUSE_BUTTON = 4
EndEnumeration
Enumeration KEYBOARD_STATES
      #CONTROL_KEY_PRESSED = 1
      #SHIFT_KEY_PRESSED = 2
      #ALT_KEY_PRESSED = 4
EndEnumeration

Structure MOUSE_PARAMS
      cmd.l;int       MOUSE_EVENTS UINT
      target.l;       target element HELEMENT
      pos.POINT;          position of cursor, element relative
      pos_view.POINT;     position of cursor, view relative
      button_state.l; MOUSE_BUTTONS UINT
      alt_state.l;    KEYBOARD_STATES UINT
      cursor_type.l;  CURSOR_TYPE to set, see CURSOR_TYPE UINT
      is_on_icon.l;   mouse is over icon (foreground-image, foreground-repeat:no-repeat) BOOL

      dragging.l  ;   element that is being dragged over, this field is not NULL if (cmd & DRAGGING) != 0 HELEMENT  
      dragging_mode.l;see DRAGGING_TYPE. UINT
EndStructure
    
;ElementEventProc(LPVOID tag, HELEMENT he, evtg, *EVENT_GR)
Procedure MyEventHandler(tag,Elem.l, evtg, *EVENT_GR.MOUSE_PARAMS); tag - это то, что задано при определении AttachEventHandler(Elem,@MyEventHandler(),tag) 
	If evtg=#HANDLE_MOUSE
		Protected cmd.l=*EVENT_GR\cmd
		If *EVENT_GR\button_state=1 And *EVENT_GR\cmd<>#MOUSE_IDLE
			Protected isBUBBLING=#BUBBLING & cmd
			Protected isSINKING= #SINKING & cmd
			Protected isHANDLED= #HANDLED & cmd
			Protected hMessage$="";
			If isBUBBLING
				hMessage$=hMessage$+" BUBBLING"
			EndIf	
			If isSINKING
				hMessage$=hMessage$+" #SINKING"
			EndIf	
			If isHANDLED
				hMessage$=hMessage$+" HANDLED"
			EndIf	
			Debug "cmd="+Str(cmd&$FF)+" button="+Str(*EVENT_GR\button_state)+hMessage$
; 			If *EVENT_GR\cmd=#MOUSE_DOWN;#MOUSE_UP;#MOUSE_LEFT_BUTTON_UP
; 				MessageRequester("", "MyEventHandler el="+Str(Elem)+" tag="+Str(tag)+" cmd="+Str(*EVENT_GR\cmd)+" button="+Str(*EVENT_GR\button_state))
; 			EndIf
			ProcedureReturn	true;event was handled	
		Else
			ProcedureReturn	true;false;event was not handled	
		EndIf
	Else
		ProcedureReturn	false;event was not handled	
	EndIf
EndProcedure

Procedure MySelectHandler(Elem,param$)
	Protected    fcall=@MyEventHandler()
	MessageRequester("", "MySelectHandler el="+Str(Elem)+" param="+param$)
  SCDOM_RESULT = *Sciter\AttachEventHandler(Elem,fcall,123)
   If SCDOM_RESULT<>0; SCDOM_OK=0
 			MessageRequester("scDom", "Error="+Str(SCDOM_RESULT))
   EndIf
EndProcedure

Define SciterAPI.SciterAPIPrototype


;NrLibSciter = OpenLibrary(#PB_Any, "Sciter32.dll")
NrLibSciter = OpenLibrary(#PB_Any, "Sciter.dll")

If NrLibSciter
   SciterAPI = GetFunctionEntry(NrLibSciter, 1)
   
   *Sciter = SciterAPI()
   
      
   Define *Rect.Rect = AllocateStructure(Rect)
   With *Rect
      \left      = 16
      \top      = 16
      \right   = 16 + 480
      \bottom = 16 + 320
   EndWith
   
   SetWindowCallback(@SciterCallback());, NrWindow)
   
   Define NrWindow = OpenWindow(#PB_Any, 16, 16, 480, 320, "Test Sciter", #PB_Window_SizeGadget | #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget)
   hwind=WindowID(NrWindow)
   Elem.i=-1
   SCDOM_RESULT=*Sciter\GetRootElement(hwind,@Elem)
   If SCDOM_RESULT<>0; SCDOM_OK=0
			MessageRequester("scDom", "Error="+Str(SCDOM_RESULT))
   EndIf
  
   fcall=@MySelectHandler()
   selector$="textarea"
   param=123
   SCDOM_RESULT = *Sciter\SelectElementsW(Elem, @selector$,fcall, selector$);
   If SCDOM_RESULT<>0; SCDOM_OK=0
			MessageRequester("scDom", "Error="+Str(SCDOM_RESULT))
   EndIf
   
   If NrWindow
      Repeat
         Define Event = WaitWindowEvent()
         
         If Event = #PB_Event_CloseWindow
            Break
         EndIf
      ForEver   
   EndIf

Else
   Debug "OpenLibrary('Sciter32.dll') not successful"
   
EndIf



End



Procedure getWindowNrFromHandle(Handle)
   Define R = GetProp_(Handle, "PB_WindowID") - 1
   
   ProcedureReturn R
EndProcedure
   
Procedure.q PeekUI(*addr.Long) ; прочитать адрес
   ;-- Reads 4 bytes from the specified memory address,
   ;   and returns the value as *unsigned* integer
   ;   (minimum = 0, maximum = 4294967295).

   If *addr\l < 0
      ProcedureReturn *addr\l + $100000000
   Else
      ProcedureReturn *addr\l
   EndIf
EndProcedure ; .q PeekUI(*addr.Long)

Procedure PokeUI(*addr.Long, number.q) ;записать адрес
   ;-- Writes an *unsigned* integer of 4 bytes size
   ;   to the specified memory address.

   If number >= 0 And number <= $FFFFFFFF
      If number > $7FFFFFFF
         *addr\l = number - $100000000
      Else
         *addr\l = number
      EndIf
   EndIf
EndProcedure ; PokeUI(*addr.Long, number.q)
HanPBF
Enthusiast
Enthusiast
Posts: 563
Joined: Fri Feb 19, 2010 3:42 am

Re: Sciter; PB 5.42 LTS; Any prototypes available?

Post by HanPBF »

Thanks a lot for sharing!

Finally, a modern web engine for PureBasic!!!
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5342
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Sciter; PB 5.42 LTS; Any prototypes available?

Post by Kwai chang caine »

Thanks privetamerica for sharing 8)
I have msgbox "scDom error=2" with W10 x64 / v5.61 x86 :|
ImageThe happiness is a road...
Not a destination
Fred
Administrator
Administrator
Posts: 16619
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Sciter; PB 5.42 LTS; Any prototypes available?

Post by Fred »

Just tried it, and works great (don't forget to change the *Sciter\LoadFile(hwnd, @"test.html") to a file which exists on your disk).
LuckyLuke
Enthusiast
Enthusiast
Posts: 181
Joined: Fri Jun 06, 2003 2:41 pm
Location: Belgium

Re: Sciter; PB 5.42 LTS; Any prototypes available?

Post by LuckyLuke »

@privetamerica:
Thanks a lot ! 8)

@fred:
Any chance that PureBasic would include a sciter gadget in the near future ?

LuckyLuke
Fred
Administrator
Administrator
Posts: 16619
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Sciter; PB 5.42 LTS; Any prototypes available?

Post by Fred »

It will need more than a gadget (as it needs tight integration to get events from button and so), but it mitgh happen if there is some demand for it. I need to explore more about it, and see all the possibilties (HTML5 compatibility etc.). The DLL itself is fast and small, free to use, which is a good start.
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5342
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Sciter; PB 5.42 LTS; Any prototypes available?

Post by Kwai chang caine »

FRED wrote:don't forget to change the *Sciter\LoadFile(hwnd, @"test.html") to a file which exists on your disk
Thanks FRED :oops:

And obvioulsy thanks a lot Privetamerica for sharing 8)
ImageThe happiness is a road...
Not a destination
Post Reply