-
Notifications
You must be signed in to change notification settings - Fork 268
/
types.go
1422 lines (1213 loc) · 50.9 KB
/
types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
package sciter
/*
#include "sciter-x.h"
*/
import "C"
import (
"fmt"
"unsafe"
)
// enum SCITER_CREATE_WINDOW_FLAGS {
// SW_CHILD = (1 << 0), // child window only, if this flag is set all other flags ignored
// SW_TITLEBAR = (1 << 1), // toplevel window, has titlebar
// SW_RESIZEABLE = (1 << 2), // has resizeable frame
// SW_TOOL = (1 << 3), // is tool window
// SW_CONTROLS = (1 << 4), // has minimize / maximize buttons
// SW_GLASSY = (1 << 5), // glassy window ( DwmExtendFrameIntoClientArea on windows )
// SW_ALPHA = (1 << 6), // transparent window ( e.g. WS_EX_LAYERED on Windows )
// SW_MAIN = (1 << 7), // main window of the app, will terminate the app on close
// SW_POPUP = (1 << 8), // the window is created as topmost window.
// SW_ENABLE_DEBUG = (1 << 9), // make this window inspector ready
// SW_OWNS_VM = (1 << 10), // it has its own script VM
// };
type WindowCreationFlag uint32
const (
SW_CHILD WindowCreationFlag = (1 << iota) // child window only, if this flag is set all other flags ignored
SW_TITLEBAR // toplevel window, has titlebar
SW_RESIZEABLE // has resizeable frame
SW_TOOL // is tool window
SW_CONTROLS // has minimize / maximize buttons
SW_GLASSY // glassy window ( DwmExtendFrameIntoClientArea on windows )
SW_ALPHA // transparent window ( e.g. WS_EX_LAYERED on Windows )
SW_MAIN // main window of the app, will terminate the app on close
SW_POPUP // the window is created as topmost window.
SW_ENABLE_DEBUG // make this window inspector ready
SW_OWNS_VM // it has its own script VM
)
var (
// create an resizable main window with minimize/maximize controls
// linux must use this combination to create the main window correctly
DefaultWindowCreateFlag = SW_TITLEBAR | SW_RESIZEABLE | SW_CONTROLS | SW_MAIN | SW_ENABLE_DEBUG
)
// enum OUTPUT_SUBSYTEMS
const (
OT_DOM = iota // html parser & runtime
OT_CSSS // csss! parser & runtime
OT_CSS // css parser
OT_TIS // TIS parser & runtime
)
// enum OUTPUT_SEVERITY
const (
OS_INFO = iota
OS_WARNING
OS_ERROR
)
// enum EVENT_GROUPS
const (
HANDLE_INITIALIZATION = 0x0000 /** attached/detached */
HANDLE_MOUSE = 0x0001 /** mouse events */
HANDLE_KEY = 0x0002 /** key events */
HANDLE_FOCUS = 0x0004 /** focus events if this flag is set it also means that element it attached to is focusable */
HANDLE_SCROLL = 0x0008 /** scroll events */
HANDLE_TIMER = 0x0010 /** timer event */
HANDLE_SIZE = 0x0020 /** size changed event */
HANDLE_DRAW = 0x0040 /** drawing request (event) */
HANDLE_DATA_ARRIVED = 0x080 /** requested data () has been delivered */
HANDLE_BEHAVIOR_EVENT = 0x0100 /** logical synthetic events:
BUTTON_CLICK HYPERLINK_CLICK etc.
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_EXCHANGE = 0x1000 /** system drag-n-drop */
HANDLE_GESTURE = 0x2000 /** touch input events */
HANDLE_SOM = 0x8000 /** som_asset_t request */
HANDLE_ALL = 0xFFFF /* all of them */
SUBSCRIPTIONS_REQUEST = 0xFFFFFFFF /** special value for getting subscription flags */
)
type PhaseMask uint32
// enum PHASE_MASK
const (
BUBBLING = 0 // bubbling (emersion) phase
SINKING = 0x8000 // capture (immersion) phase, this flag is or'ed with EVENTS codes below
HANDLED = 0x10000 // a bubbling event consumed by some element
SINKING_HANDLED = 0x18000 // a sinking event consumed by some child element
// see: http://www.w3.org/TR/xml-events/Overview.html#s_intro
)
type MouseButton uint32
// enum MOUSE_BUTTONS
const (
MAIN_MOUSE_BUTTON MouseButton = 1 //aka left button
PROP_MOUSE_BUTTON MouseButton = 2 //aka right button
MIDDLE_MOUSE_BUTTON MouseButton = 4
)
type KeyboardState uint32
// enum KEYBOARD_STATES
const (
CONTROL_KEY_PRESSED KeyboardState = 0x1
SHIFT_KEY_PRESSED KeyboardState = 0x2
ALT_KEY_PRESSED KeyboardState = 0x4
)
// parameters of evtg == HANDLE_INITIALIZATION
// enum INITIALIZATION_EVENTS
const (
BEHAVIOR_DETACH = 0
BEHAVIOR_ATTACH = 1
)
type DraggingType uint32
// enum DRAGGING_TYPE
const (
NO_DRAGGING = iota
DRAGGING_MOVE
DRAGGING_COPY
)
type MouseEvent uint32
// parameters of evtg == HANDLE_MOUSE
// enum MOUSE_EVENTS
const (
MOUSE_ENTER MouseEvent = iota
MOUSE_LEAVE
MOUSE_MOVE
MOUSE_UP
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 MouseEvent = 0xFF // mouse click event
DRAGGING MouseEvent = 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.
)
type CursorType uint32
// enum CURSOR_TYPE
const (
CURSOR_ARROW CursorType = iota //0
CURSOR_IBEAM //1
CURSOR_WAIT //2
CURSOR_CROSS //3
CURSOR_UPARROW //4
CURSOR_SIZENWSE //5
CURSOR_SIZENESW //6
CURSOR_SIZEWE //7
CURSOR_SIZENS //8
CURSOR_SIZEALL //9
CURSOR_NO //10
CURSOR_APPSTARTING //11
CURSOR_HELP //12
CURSOR_HAND //13
CURSOR_DRAG_MOVE //14
CURSOR_DRAG_COPY //15
)
type KeyEvent uint32
// enum KEY_EVENTS
const (
KEY_DOWN KeyEvent = iota
KEY_UP
KEY_CHAR
)
type FocusEvent uint32
// enum FOCUS_EVENTS
const (
FOCUS_LOST FocusEvent = iota
FOCUS_GOT
)
type ScrollEvent uint32
// enum SCROLL_EVENTS
const (
SCROLL_HOME ScrollEvent = iota
SCROLL_END
SCROLL_STEP_PLUS
SCROLL_STEP_MINUS
SCROLL_PAGE_PLUS
SCROLL_PAGE_MINUS
SCROLL_POS
SCROLL_SLIDER_RELEASED
SCROLL_CORNER_PRESSED
SCROLL_CORNER_RELEASED
)
type GestureCmd uint32
// enum GESTURE_CMD
const (
GESTURE_REQUEST GestureCmd = iota // 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.
)
type GestureState uint32
// enum GESTURE_STATE
const (
GESTURE_STATE_BEGIN GestureState = 1 // starts
GESTURE_STATE_INERTIA GestureState = 2 // events generated by inertia processor
GESTURE_STATE_END GestureState = 4 // end last event of the gesture sequence
)
type GestureTypeFlag uint32
// enum GESTURE_TYPE_FLAGS // requested
const (
GESTURE_FLAG_ZOOM GestureTypeFlag = 0x0001
GESTURE_FLAG_ROTATE GestureTypeFlag = 0x0002
GESTURE_FLAG_PAN_VERTICAL GestureTypeFlag = 0x0004
GESTURE_FLAG_PAN_HORIZONTALGestureTypeFlag = 0x0008
GESTURE_FLAG_TAP1 GestureTypeFlag = 0x0010 // press & tap
GESTURE_FLAG_TAP2 GestureTypeFlag = 0x0020 // two fingers tap
GESTURE_FLAG_PAN_WITH_GUTTER GestureTypeFlag = 0x4000 // PAN_VERTICAL and PAN_HORIZONTAL modifiers
GESTURE_FLAG_PAN_WITH_INERTIA GestureTypeFlag = 0x8000 //
GESTURE_FLAGS_ALL GestureTypeFlag = 0xFFFF //
)
type DrawEvent uint32
// enum DRAW_EVENTS
const (
DRAW_CONTENT DrawEvent = 1
DRAW_FOREGROUND DrawEvent = 2
)
// enum CONTENT_CHANGE_BITS { // for CONTENT_CHANGED reason
const (
CONTENT_ADDED = 0x01
CONTENT_REMOVED = 0x02
)
type BehaviorEvent uint32
// enum BEHAVIOR_EVENTS
const (
BUTTON_CLICK BehaviorEvent = 0 // click on button
BUTTON_PRESS BehaviorEvent = 1 // mouse down or key down in button
BUTTON_STATE_CHANGED BehaviorEvent = 2 // checkbox/radio/slider changed its state/value
EDIT_VALUE_CHANGING BehaviorEvent = 3 // before text change
EDIT_VALUE_CHANGED BehaviorEvent = 4 // after text change
SELECT_SELECTION_CHANGED BehaviorEvent = 5 // selection in <select> changed
SELECT_STATE_CHANGED BehaviorEvent = 6 // node in select expanded/collapsed heTarget is the node
POPUP_REQUEST BehaviorEvent = 7 // request to show popup just received
// here DOM of popup element can be modifed.
POPUP_READY BehaviorEvent = 8 // popup element has been measured and ready to be shown on screen
// here you can use functions like ScrollToView.
POPUP_DISMISSED BehaviorEvent = 9 // popup element is closed
// here DOM of popup element can be modifed again - e.g. some items can be removed
// to free memory.
MENU_ITEM_ACTIVE BehaviorEvent = 0xA // menu item activated by mouse hover or by keyboard
MENU_ITEM_CLICK BehaviorEvent = 0xB // menu item click
// BEHAVIOR_EVENT_PARAMS structure layout
// BEHAVIOR_EVENT_PARAMS.cmd - MENU_ITEM_CLICK/MENU_ITEM_ACTIVE
// BEHAVIOR_EVENT_PARAMS.heTarget - owner(anchor) of the menu
// BEHAVIOR_EVENT_PARAMS.he - the menu item presumably <li> element
// BEHAVIOR_EVENT_PARAMS.reason - BY_MOUSE_CLICK | BY_KEY_CLICK
CONTEXT_MENU_REQUEST BehaviorEvent = 0x10 // "right-click" BEHAVIOR_EVENT_PARAMS::he is current popup menu HELEMENT being processed or NULL.
// application can provide its own HELEMENT here (if it is NULL) or modify current menu element.
VISIUAL_STATUS_CHANGED BehaviorEvent = 0x11 // broadcast notification sent to all elements of some container being shown or hidden
DISABLED_STATUS_CHANGED BehaviorEvent = 0x12 // broadcast notification sent to all elements of some container that got new value of :disabled state
POPUP_DISMISSING BehaviorEvent = 0x13 // popup is about to be closed
CONTENT_CHANGED BehaviorEvent = 0x15 // content has been changed is posted to the element that gets content changed reason is combination of CONTENT_CHANGE_BITS.
// target == NULL means the window got new document and this event is dispatched only to the window.
// "grey" event codes - notfications from behaviors from this SDK
HYPERLINK_CLICK BehaviorEvent = 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)
)
const (
ELEMENT_COLLAPSED BehaviorEvent = iota + 0x90 // element was collapsed so far only behavior:tabs is sending these two to the panels
ELEMENT_EXPANDED // element was expanded
ACTIVATE_CHILD // 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 HTMLayoutPostEvent(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 // ui state changed observers shall update their visual states.
// is sent for example by behavior:richtext when caret position/selection has changed.
FORM_SUBMIT // behavior:form detected submission event. BEHAVIOR_EVENT_PARAMS::data field contains data to be posted.
// BEHAVIOR_EVENT_PARAMS::data is of type T_MAP in this case key/value pairs of data that is about
// to be submitted. You can modify the data or discard submission by returning true from the handler.
FORM_RESET // behavior:form detected reset event (from button type=reset). BEHAVIOR_EVENT_PARAMS::data field contains data to be reset.
// BEHAVIOR_EVENT_PARAMS::data is of type T_MAP in this case key/value pairs of data that is about
// to be rest. You can modify the data or discard reset by returning true from the handler.
DOCUMENT_COMPLETE // document in behavior:frame or root document is complete.
HISTORY_PUSH // requests to behavior:history (commands)
HISTORY_DROP
HISTORY_PRIOR
HISTORY_NEXT
HISTORY_STATE_CHANGED // behavior:history notification - history stack has changed
CLOSE_POPUP // close popup request
REQUEST_TOOLTIP // request tooltip evt.source <- is the tooltip element.
ANIMATION BehaviorEvent = 0xA0 // animation started (reason=1) or ended(reason=0) on the element.
DOCUMENT_CREATED BehaviorEvent = 0xC0 // document created script namespace initialized. target -> the document
DOCUMENT_CLOSE_REQUEST BehaviorEvent = 0xC1 // document is about to be closed to cancel closing do: evt.data = sciter::value("cancel");
DOCUMENT_CLOSE BehaviorEvent = 0xC2 // last notification before document removal from the DOM
DOCUMENT_READY BehaviorEvent = 0xC3 // document has got DOM structure styles and behaviors of DOM elements. Script loading run is complete at this moment.
VIDEO_INITIALIZED BehaviorEvent = 0xD1 // <video> "ready" notification
VIDEO_STARTED BehaviorEvent = 0xD2 // <video> playback started notification
VIDEO_STOPPED BehaviorEvent = 0xD3 // <video> playback stoped/paused notification
VIDEO_BIND_RQ BehaviorEvent = 0xD4 // <video> request for frame source binding
// If you want to provide your own video frames source for the given target <video> element do the following:
// 1. Handle and consume this VIDEO_BIND_RQ request
// 2. You will receive second VIDEO_BIND_RQ request/event for the same <video> element
// but this time with the 'reason' field set to an instance of sciter::video_destination interface.
// 3. add_ref() it and store it for example in worker thread producing video frames.
// 4. call sciter::video_destination::start_streaming(...) providing needed parameters
// call sciter::video_destination::render_frame(...) as soon as they are available
// call sciter::video_destination::stop_streaming() to stop the rendering (a.k.a. end of movie reached)
FIRST_APPLICATION_EVENT_CODE = 0x100
// all custom event codes shall be greater
// than this number. All codes below this will be used
// solely by application - HTMLayout will not intrepret it
// and will do just dispatching.
// To send event notifications with these codes use
// HTMLayoutSend/PostEvent API.
)
type EventReason uint
// enum EVENT_REASON
const (
BY_MOUSE_CLICK EventReason = iota
BY_KEY_CLICK
SYNTHESIZED // synthesized programmatically generated.
BY_MOUSE_ON_ICON
)
type EditChangedReason uint
// enum EDIT_CHANGED_REASON
const (
BY_INS_CHAR EditChangedReason = iota // single char insertion
BY_INS_CHARS // character range insertion clipboard
BY_DEL_CHAR // single char deletion
BY_DEL_CHARS // character range deletion (selection)
BY_UNDO_REDO // undo/redo
)
type BehaviorMethodIdentifier uint32
// enum BEHAVIOR_METHOD_IDENTIFIERS
const (
DO_CLICK BehaviorMethodIdentifier = iota
GET_TEXT_VALUE
SET_TEXT_VALUE
// p - TEXT_VALUE_PARAMS
TEXT_EDIT_GET_SELECTION
// p - TEXT_EDIT_SELECTION_PARAMS
TEXT_EDIT_SET_SELECTION
// p - TEXT_EDIT_SELECTION_PARAMS
// Replace selection content or insert text at current caret position.
// Replaced text will be selected.
TEXT_EDIT_REPLACE_SELECTION
// p - TEXT_EDIT_REPLACE_SELECTION_PARAMS
// Set value of type="vscrollbar"/"hscrollbar"
SCROLL_BAR_GET_VALUE
SCROLL_BAR_SET_VALUE
TEXT_EDIT_GET_CARET_POSITION
TEXT_EDIT_GET_SELECTION_TEXT // p - TEXT_SELECTION_PARAMS
TEXT_EDIT_GET_SELECTION_HTML // p - TEXT_SELECTION_PARAMS
TEXT_EDIT_CHAR_POS_AT_XY // p - TEXT_EDIT_CHAR_POS_AT_XY_PARAMS
IS_EMPTY BehaviorMethodIdentifier = 0xFC // p - IS_EMPTY_PARAMS // set VALUE_PARAMS::is_empty (false/true) reflects :empty state of the element.
GET_VALUE BehaviorMethodIdentifier = 0xFD // p - VALUE_PARAMS
SET_VALUE BehaviorMethodIdentifier = 0xFE // p - VALUE_PARAMS
FIRST_APPLICATION_METHOD_ID BehaviorMethodIdentifier = 0x100
)
// enum VALUE_TYPE
const (
T_UNDEFINED = iota
T_NULL
T_BOOL
T_INT
T_FLOAT
T_STRING
T_DATE // INT64 - contains a 64-bit value representing the number of 100-nanosecond intervals since January 1 1601 (UTC) a.k.a. FILETIME on Windows
T_CURRENCY // INT64 - 14.4 fixed number. E.g. dollars = int64 / 10000;
T_LENGTH // length units value is int or float units are VALUE_UNIT_TYPE
T_ARRAY
T_MAP
T_FUNCTION
T_BYTES // sequence of bytes - e.g. image data
T_OBJECT // scripting object proxy (TISCRIPT/SCITER)
T_DOM_OBJECT // DOM object (CSSS!) use get_object_data to get HELEMENT
T_RESOURCE // 15 - other thing derived from tool::resource
T_RANGE // 16 - N..M, integer range.
T_DURATION // double, seconds
T_ANGLE // double, radians
T_COLOR // [unsigned] INT, ABGR
T_ENUM
T_ASSET // sciter::om::iasset* add_ref'ed pointer
)
// enum VALUE_UNIT_TYPE
const (
UT_EM = 1 //height of the element's font.
UT_EX = 2 //height of letter 'x'
UT_PR = 3 //%
UT_SP = 4 //%% "springs" a.k.a. flex units
reserved1 = 5
reserved2 = 6
UT_PX = 7 //pixels
UT_IN = 8 //inches (1 inch = 2.54 centimeters).
UT_CM = 9 //centimeters.
UT_MM = 10 //millimeters.
UT_PT = 11 //points (1 point = 1/72 inches).
UT_PC = 12 //picas (1 pica = 12 points).
UT_DIP = 13
reserved3 = 14
UT_COLOR = 15 // color in int
UT_URL = 16 // url in string
UT_SYMBOL = 0xFFFF // for T_STRINGs designates symbol string ( so called NAME_TOKEN - CSS or JS identifier )
)
// enum VALUE_UNIT_TYPE_DATE
const (
DT_HAS_DATE = 0x01 // date contains date portion
DT_HAS_TIME = 0x02 // date contains time portion HH:MM
DT_HAS_SECONDS = 0x04 // date contains time and seconds HH:MM:SS
DT_UTC = 0x10 // T_DATE is known to be UTC. Otherwise it is local date/time
)
// Sciter or TIScript specific
// enum VALUE_UNIT_TYPE_OBJECT
const (
UT_OBJECT_ARRAY = 0 // type T_OBJECT of type Array
UT_OBJECT_OBJECT = 1 // type T_OBJECT of type Object
UT_OBJECT_CLASS = 2 // type T_OBJECT of type Type (class or namespace)
UT_OBJECT_NATIVE = 3 // type T_OBJECT of native Type with data slot (LPVOID)
UT_OBJECT_FUNCTION = 4 // type T_OBJECT of type Function
UT_OBJECT_ERROR = 5 // type T_OBJECT of type Error
)
// enum VALUE_UNIT_UNDEFINED
const (
UT_NOTHING = 1
)
type ValueStringConvertType uint32
// enum VALUE_STRING_CVT_TYPE
const (
CVT_SIMPLE ValueStringConvertType = iota ///< simple conversion of terminal values
CVT_JSON_LITERAL ///< json literal parsing/emission
CVT_JSON_MAP ///< json parsing/emission it parses as if token '{' already recognized
CVT_XJSON_LITERAL ///< x-json parsing/emission, date is emitted as ISO8601 date literal, currency is emitted in the form DDDD$CCC
)
type SET_ELEMENT_HTML int32
// enum SET_ELEMENT_HTML
const (
SIH_REPLACE_CONTENT SET_ELEMENT_HTML = 0
SIH_INSERT_AT_START SET_ELEMENT_HTML = 1
SIH_APPEND_AFTER_LAST SET_ELEMENT_HTML = 2
SOH_REPLACE SET_ELEMENT_HTML = 3
SOH_INSERT_BEFORE SET_ELEMENT_HTML = 4
SOH_INSERT_AFTER SET_ELEMENT_HTML = 5
)
type InitializationParams struct {
Cmd uint32
}
type MouseParams struct {
Cmd MouseEvent // MouseEvents
Target C.HELEMENT
Pos Point
DocumentPos Point
ButtonState MouseButton
AltState KeyboardState
CursorType CursorType
IsOnIcon int32
Dragging C.HELEMENT
DraggingMode DraggingType
}
type KeyParams struct {
Cmd KeyEvent // KeyEvents
Target C.HELEMENT
KeyCode uint32
AltState KeyboardState
}
type FocusParams struct {
Cmd FocusEvent // FocusEvents
Target C.HELEMENT
ByMouseClick int32 // boolean // true if focus is being set by mouse click
Cancel int32 // boolean // in FOCUS_LOST phase setting this field to true will cancel transfer focus from old element to the new one.
}
type DrawParams struct {
Cmd DrawEvent // DrawEvents
Hdc uintptr
Area Rect
reserved uint32
}
type TimerParams struct {
TimerId uintptr
}
// typedef struct BEHAVIOR_EVENT_PARAMS
// {
// UINT cmd; // BEHAVIOR_EVENTS
// HELEMENT heTarget; // target element handler, in MENU_ITEM_CLICK this is owner element that caused this menu - e.g. context menu owner
// // In scripting this field named as Event.owner
// HELEMENT he; // source element e.g. in SELECTION_CHANGED it is new selected <option>, in MENU_ITEM_CLICK it is menu item (LI) element
// UINT_PTR reason; // EVENT_REASON or EDIT_CHANGED_REASON - UI action causing change.
// // In case of custom event notifications this may be any
// // application specific value.
// SCITER_VALUE
// data; // auxiliary data accompanied with the event. E.g. FORM_SUBMIT event is using this field to pass collection of values.
// } BEHAVIOR_EVENT_PARAMS;
type BehaviorEventParams C.BEHAVIOR_EVENT_PARAMS
func (b *BehaviorEventParams) Cmd() BehaviorEvent {
return BehaviorEvent(b.cmd & 0xFFF)
}
func (b *BehaviorEventParams) Phase() PhaseMask {
return PhaseMask(b.cmd & 0xFFFFF000)
}
type MethodParams struct {
MethodId BehaviorMethodIdentifier
// Text *uint16
// Length uint32
}
// typedef struct SCRIPTING_METHOD_PARAMS
// {
// LPCSTR name; //< method name
// SCITER_VALUE* argv; //< vector of arguments
// UINT argc; //< argument count
// SCITER_VALUE result; //< return value
// } SCRIPTING_METHOD_PARAMS;
type ScriptingMethodParams C.SCRIPTING_METHOD_PARAMS
func (s *ScriptingMethodParams) Name() string {
return C.GoString(s.name)
}
func (s *ScriptingMethodParams) Argc() int {
return int(s.argc)
}
func (r *ScriptingMethodParams) Args() []*Value {
args := make([]*Value, 0)
step := unsafe.Sizeof(r.result)
for i := 0; i < int(r.Argc()); i++ {
p := uintptr(unsafe.Pointer(r.argv)) + uintptr(i)*step
args = append(args, (*Value)(unsafe.Pointer(p)))
}
return args
}
func (r *ScriptingMethodParams) Arg(i int) *Value {
if i >= int(r.Argc()) {
panic("ScriptingMethodParams arg index out of range")
}
p := uintptr(unsafe.Pointer(r.argv)) + uintptr(i)*unsafe.Sizeof(r.result)
return (*Value)(unsafe.Pointer(p))
}
// set the return val for the scripting func
// if not set return undefined
func (s *ScriptingMethodParams) Return(val interface{}) {
v := (*Value)(unsafe.Pointer(&(s.result)))
v.init()
v.Assign(val)
}
type PTiscriptVM uintptr
type HVM PTiscriptVM
// // tiscript_value
// typedef UINT64 tiscript_value;
type TiscriptValue uint64
// // pinned tiscript_value, val here will survive GC.
// typedef struct tiscript_pvalue
// {
// tiscript_value val;
// struct tiscript_VM* vm;
// void *d1,*d2;
// } tiscript_pvalue;
type TiscriptPvalue struct {
Val TiscriptValue
VM HVM
d1, d2 uintptr
}
// typedef struct TISCRIPT_METHOD_PARAMS
// {
// tiscript_VM* vm;
// tiscript_value tag; //< method id (symbol)
// tiscript_value result; //< return value
// // parameters are accessible through tiscript::args.
// } TISCRIPT_METHOD_PARAMS;
type TiscriptMethodParams struct {
// tiscript_VM *vm
VM HVM
// tiscript_value tag //< method id (symbol)
Tag TiscriptValue
// tiscript_value result //< return value
Result TiscriptValue
}
// typedef struct DATA_ARRIVED_PARAMS
// {
// HELEMENT initiator; // element intiator of HTMLayoutRequestElementData request,
// LPCBYTE data; // data buffer
// UINT dataSize; // size of data
// UINT dataType; // data type passed "as is" from HTMLayoutRequestElementData
// UINT status; // status = 0 (dataSize == 0) - unknown error.
// // status = 100..505 - http response status, Note: 200 - OK!
// // status > 12000 - wininet error code, see ERROR_INTERNET_*** in wininet.h
// LPCWSTR uri; // requested url
// } DATA_ARRIVED_PARAMS;
type DataArrivedParams C.DATA_ARRIVED_PARAMS
// type DataArrivedParams struct {
// Initiator C.HELEMENT
// data *byte
// DataSize uint32
// DataType uint32
// Status uint32
// uri *uint16 // Wide character string
// }
func (d *DataArrivedParams) Uri() string {
return Utf16ToString((*uint16)(unsafe.Pointer(d.uri)))
}
func (d *DataArrivedParams) Data() []byte {
return BytePtrToBytes((*byte)(unsafe.Pointer(d.data)), uint(d.dataSize))
}
// struct SCROLL_PARAMS
// {
// UINT cmd; // SCROLL_EVENTS
// HELEMENT target; // target element
// INT pos; // scroll position if SCROLL_POS
// BOOL vertical; // true if from vertical scrollbar
// };
type ScrollParams struct {
Cmd ScrollEvent
Target C.HELEMENT
Pos int32
Vertical int32 // bool
}
// enum EXCHANGE_CMD {
// X_DRAG_ENTER = 0, // drag enters 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_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
// };
type ExchangeCmd uint32
const (
X_DRAG_ENTER ExchangeCmd = iota
X_DRAG_LEAVE
X_DRAG
X_DROP
X_PASTE
X_DRAG_REQUEST
X_DRAG_CANCEL
X_WILL_ACCEPT_DROP
)
// enum DD_MODES {
// DD_MODE_NONE = 0, // DROPEFFECT_NONE ( 0 )
// DD_MODE_COPY = 1, // DROPEFFECT_COPY ( 1 )
// DD_MODE_MOVE = 2, // DROPEFFECT_MOVE ( 2 )
// DD_MODE_COPY_OR_MOVE = 3, // DROPEFFECT_COPY ( 1 ) | DROPEFFECT_MOVE ( 2 )
// DD_MODE_LINK = 4, // DROPEFFECT_LINK ( 4 )
// };
type DDMode uint32
const (
DD_MODE_NONE DDMode = 0
DD_MODE_COPY
DD_MODE_MOVE
DD_MODE_COPY_OR_MOVE
DD_MODE_LINK
)
// struct EXCHANGE_PARAMS
// {
// UINT cmd; // EXCHANGE_EVENTS
// HELEMENT target; // target element
// 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
// SCITER_VALUE data; // packaged drag data
// };
type ExchangeParams struct {
Cmd ExchangeCmd
Target C.HELEMENT
Source C.HELEMENT
Pos Point
PosView Point
Mode DDMode
Data Value
}
// struct GESTURE_PARAMS
// {
// UINT cmd; // GESTURE_EVENTS
// 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.
// // 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
// };
type GestureParams struct {
Cmd GestureCmd
Target C.HELEMENT
Pos Point
PosView Point
Flags uint32
DeltaTime uint32
DeltaXY Size
DeltaV float64
}
type SomEvents uint32
const (
SOM_GET_PASSPORT = 0
SOM_GET_ASSET = 1
)
type SomParams C.SOM_PARAMS
const (
LOAD_OK = 0 // do default loading if data not set
LOAD_DISCARD = 1 // discard request completely
LOAD_DELAYED = 2 // data will be delivered later by the host application.
)
const (
/**Notifies that Sciter is about to download a referred resource.
*
* \param lParam #LPSCN_LOAD_DATA.
* \return #LOAD_OK or #LOAD_DISCARD
*
* This notification gives application a chance to override built-in loader and
* implement loading of resources in its own way (for example images can be loaded from
* database or other resource). To do this set #SCN_LOAD_DATA::outData and
* #SCN_LOAD_DATA::outDataSize members of SCN_LOAD_DATA. Sciter does not
* store pointer to this data. You can call #SciterDataReady() function instead
* of filling these fields. This allows you to free your outData buffer
* immediately.
**/
SC_LOAD_DATA = 0x01
/**This notification indicates that external data (for example image) download process
* completed.
*
* \param lParam #LPSCN_DATA_LOADED
*
* This notifiaction is sent for each external resource used by document when
* this resource has been completely downloaded. Sciter will send this
* notification asynchronously.
**/
SC_DATA_LOADED = 0x02
/**This notification is sent when all external data (for example image) has been downloaded.
*
* This notification is sent when all external resources required by document
* have been completely downloaded. Sciter will send this notification
* asynchronously.
**/
/* obsolete #define SC_DOCUMENT_COMPLETE 0x03
use DOCUMENT_COMPLETE DOM event.
*/
/**This notification is sent on parsing the document and while processing
* elements having non empty style.behavior attribute value.
*
* \param lParam #LPSCN_ATTACH_BEHAVIOR
*
* Application has to provide implementation of #sciter::behavior interface.
* Set #SCN_ATTACH_BEHAVIOR::impl to address of this implementation.
**/
SC_ATTACH_BEHAVIOR = 0x04
/**This notification is sent when instance of the engine is destroyed.
* It is always final notification.
*
* \param lParam #LPSCN_ENGINE_DESTROYED
*
**/
SC_ENGINE_DESTROYED = 0x05
/**Posted notification.
* \param lParam #LPSCN_POSTED_NOTIFICATION
*
**/
SC_POSTED_NOTIFICATION = 0x06
/**This notification is sent when the engine encounters critical rendering error: e.g. DirectX gfx driver error.
Most probably bad gfx drivers.
* \param lParam #LPSCN_GRAPHICS_CRITICAL_FAILURE
*
**/
SC_GRAPHICS_CRITICAL_FAILURE = 0x07
/**This notification is sent when the engine needs keyboard to be present on screen
E.g. when <input|text> gets focus
* \param lParam #LPSCN_KEYBOARD_REQUEST
*
**/
SC_KEYBOARD_REQUEST = 0x08
/**This notification is sent when the engine needs some area to be redrawn
* \param lParam #LPSCN_INVLIDATE_RECT
*
**/
SC_INVALIDATE_RECT = 0x09
)
// Notify structures
/**Notification callback structure.
**/
// typedef struct SCITER_CALLBACK_NOTIFICATION
// {
// UINT code; /**< [in] one of the codes above.*/
// HWINDOW hwnd; /**< [in] HWINDOW of the window this callback was attached to.*/
// } SCITER_CALLBACK_NOTIFICATION;
type SciterCallbackNotification struct {
Code uint32
Hwnd C.HWINDOW
}
/**This structure is used by #SC_ENGINE_DESTROYED notification.
*\copydoc SCN_ENGINE_DESTROYED **/
// typedef struct SCN_ENGINE_DESTROYED
// {
// UINT code; /**< [in] one of the codes above.*/
// HWINDOW hwnd; /**< [in] HWINDOW of the window this callback was attached to.*/
// } SCN_ENGINE_DESTROYED;
type ScnEngineDestroyed SciterCallbackNotification
/**This structure is used by #SC_ENGINE_DESTROYED notification.
*\copydoc SCN_ENGINE_DESTROYED **/
//typedef struct SCN_POSTED_NOTIFICATION
//{
// UINT code; /**< [in] one of the codes above.*/
// HWINDOW hwnd; /**< [in] HWINDOW of the window this callback was attached to.*/
// UINT_PTR wparam;
// UINT_PTR lparam;
// UINT_PTR lreturn;
//} SCN_POSTED_NOTIFICATION;
type ScnPostedNotification struct {
SciterCallbackNotification
Wparam *uint
Lparam *uint
Lreturn *uint
}
/**This structure is used by #SC_GRAPHICS_CRITICAL_FAILURE notification.
*\copydoc SC_GRAPHICS_CRITICAL_FAILURE **/
type ScnGraphicsCriticalFailure SciterCallbackNotification
/**This structure is used by #SC_KEYBOARD_REQUEST notification.
*\copydoc SC_KEYBOARD_REQUEST **/
type ScnKeyboardRequest struct {
SciterCallbackNotification
// 0 - hide keyboard, 1 ... - type of keyboard
keyboardMode uint
}
/**This structure is used by #SC_INVALIDATE_RECT notification.
*\copydoc SC_INVALIDATE_RECT **/
type ScnInvalidateRect struct {
SciterCallbackNotification
// cumulative invalid rect
invalidRect Rect
}
/**This structure is used by #SCN_LOAD_DATA notification.
*\copydoc SCN_LOAD_DATA
**/
//typedef struct SCN_LOAD_DATA
//{
// UINT code; /**< [in] one of the codes above.*/
// HWINDOW hwnd; /**< [in] HWINDOW of the window this callback was attached to.*/
//
// LPCWSTR uri; /**< [in] Zero terminated string, fully qualified uri, for example "http://server/folder/file.ext".*/
//
// LPCBYTE outData; /**< [in,out] pointer to loaded data to return. if data exists in the cache then this field contain pointer to it*/
// UINT outDataSize; /**< [in,out] loaded data size to return.*/
// UINT dataType; /**< [in] SciterResourceType */
//
// LPVOID requestId; /**< [in] request id that needs to be passed as is to the SciterDataReadyAsync call */
//
// HELEMENT principal;
// HELEMENT initiator;
//} SCN_LOAD_DATA;
type ScnLoadData C.SCN_LOAD_DATA
// type ScnLoadData struct {
// SciterCallbackNotification
// uri *uint16
// outData *byte
// outDataSize uint