├── .gitattributes ├── .gitignore ├── LICENSE.md ├── README.md ├── dub.json ├── samples ├── gtkminimal │ ├── dub.json │ ├── minimal.html │ └── source │ │ └── main.d ├── host-client-post-idiom │ ├── dub.json │ ├── minimal.html │ └── source │ │ └── main.d └── uminimal │ ├── dub.json │ ├── minimal.html │ └── source │ └── main.d ├── sciter32-import-lib.lib └── source ├── gtkkit └── gtkc │ ├── Loader.d │ ├── atk.d │ ├── atktypes.d │ ├── cairo.d │ ├── cairotypes.d │ ├── gdk.d │ ├── gdkpixbuf.d │ ├── gdkpixbuftypes.d │ ├── gdktypes.d │ ├── gio.d │ ├── giotypes.d │ ├── glib.d │ ├── glibtypes.d │ ├── gobject.d │ ├── gobjecttypes.d │ ├── gthread.d │ ├── gthreadtypes.d │ ├── gtk.d │ ├── gtktypes.d │ ├── pango.d │ ├── pangotypes.d │ └── paths.d ├── sciter ├── SciterGraphics.d ├── api.d ├── behavior.d ├── behaviors │ └── behavior_tabs.d ├── dbg.d ├── host.d ├── interop │ ├── sciter_x.d │ ├── sciter_x_api.d │ ├── sciter_x_behaviors.d │ ├── sciter_x_def.d │ ├── sciter_x_dom.d │ ├── sciter_x_graphics.d │ ├── sciter_x_types.d │ ├── sciter_x_value.d │ └── tiscript.d ├── sciter_dom.d ├── sciter_value.d ├── types.d └── unittests.d └── winkit ├── DropFileTarget.d ├── GDI.d ├── MessageBox.d ├── WinAPI.d ├── Window.d └── WindowImplMixin.d /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Temporary things 2 | READMElinux.md 3 | 4 | 5 | 6 | # Garbage 7 | .vs 8 | *.exe 9 | sciter32.dll 10 | 11 | /source_trash 12 | /include-reference 13 | /include-referenceOLD 14 | 15 | sciter-dport.lib 16 | libsciter-dport.a 17 | 18 | docs.json 19 | __dummy.html 20 | *.o 21 | *.obj 22 | 23 | 24 | 25 | #DUB things 26 | .dub 27 | dub.selections.json 28 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2015 MISoftware 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ACTUAL SCITER VERSION: 3.3.0.7 2 | 3 | OctodeskDesk app made with this lib: https://github.com/midiway/OctoDeskdex 4 | 5 | For quick starting, download a [Sciter Bootstrap](http://misoftware.rs/Bootstrap/Download) package for the D language, which comes with this library already configured. 6 | 7 | **Status**: after I started writing the [C# bindings](https://github.com/MISoftware/SciterSharp) for Sciter, I realized how a 100% object-orient wrapper around Sciter API is the best way to go for creating a user friendly abstraction. When I started this D-port, in my mind I would be making the equivalent of the C++ classes found in Sciter SDK which is OO btw but the naming of things is very confusing. So the next step for this D-port is to convert it to equivalent classes and names found in the C# port, however I am prioritizing the C# version which is getting Mono cross-platform support. This port will eventually get more attention for improvements and for having GTK support, but right now I am focusing the C# version. 8 | 9 | ## About 10 | 11 | This library is a port of Sciter headers to the D language. [Sciter](http://sciter.com/download/) is a multi-platform HTML engine. So with this library you can create D desktop application using not just HTML, but all the features of Sciter: CSS3, SVG, scripintg, AJAX, ... 12 | 13 | The code is very well tested, and constantly used in real world applications, so be assured that it will save you hours and hours of debugging time, AVs and data corruptions (all which I had to face myself =D). Has unittest coverage so, in DMD, compile it with the -unittest flag to run them. 14 | 15 | For more Sciter related content visit my site at: http://misoftware.rs/ 16 | 17 | Platforms supported until now: **Windows 32bits only** 18 | *(Linux GTX support is on the way)* 19 | 20 | License: MIT License 21 | 22 | 23 | ## Structs and classes 24 | 25 | This is a table of the available D classes/structs and their mapping over the types of the official SDK C++ headers: 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 39 | 40 | 45 | 46 | 47 | 48 | 52 | 53 | 57 | 58 | 59 | 60 | 64 | 65 | 69 | 70 | 71 | 72 | 77 | 78 | 83 | 84 | 85 | 86 | 90 | 91 | 95 | 96 |
D typeC++ equivalent type
35 | module sciter.sciter_dom;
36 | struct node
37 | struct element 38 |
41 | #include "sciter-x-dom.hpp"
42 | class sciter::dom::node
43 | class sciter::dom::element 44 |
49 | module sciter.sciter_value;
50 | struct json_value 51 |
54 | #include "value.hpp"
55 | sciter::value or VALUE 56 |
61 | module sciter.dbg;
62 | abstract class debug_output
63 |
66 | #include "sciter-x-debug.h"
67 | class sciter::debug_output
68 |
73 | module sciter.host;
74 | class SciterArchive
75 | abstract class SciterWindowHost 76 |
79 | #include "sciter-x-host-callback.h"
80 | class sciter::archive
81 | class sciter::host<BASE> 82 |
87 | module sciter.behavior;
88 | abstract class EventHandler 89 |
92 | #include "sciter-x-behavior.h"
93 | class sciter::event_handler 94 |
97 | 98 | ## Package content 99 | 100 | ``` 101 | dub.json -> DUB package manifest 102 | sciter32-import-lib.lib -> **win32** only: DLL import lib 103 | /samples -> contains sample of complete GUI aplications making use of this library; samples starting with 'u' are universal ones and the same source code should compile in all supported platforms 104 | /source -> source code of this library, you should add this path to the compiler 'include path' 105 | /source/sciter -> D definitions of classes wraping the Sciter API 106 | /source/sciter/interop -> D types for Sciter ABI 107 | /source/winkit -> **win32** only: this are helper classes forming a basic WIN32 user GUI toolkit wrapping common things, like creating and manipulating HWND, message loops, and so on.. 108 | ``` 109 | 110 | ## Features 111 | 112 | **host <-> UI communication idioms support** 113 | 114 | As can be read [here](http://sciter.com/sciter-ui-application-architecture/), there are 3 commons idioms for information flow between the host application and TIScript UI code, all of which are supported in this D port. Here is how you would implement each one: 115 | 116 | *1. get-requests* 117 | 118 | To handle UI-to-logic calls you first define/extend a `EventHandler` class in the native side and attaches it to your `SciterWindowHost` native implementation. 119 | 120 | The `Setup()` function below first creates the `SciterWindowHost` instance and calls `host.setup_callback()` to identify the native HWINDOW attached to it. Then it simply instantiates the `EventHandler` and uses `host.attach_evh()` to attach it to the host in order to start receiving events. 121 | 122 | ```D 123 | import sciter.host; 124 | 125 | class MyHost : SciterWindowHost { ... } 126 | 127 | void Setup(HWINDOW wnd) 128 | { 129 | auto host = new MyHost(); 130 | host.setup_callback(wnd); 131 | 132 | auto evh = new MyHostEvh(); 133 | host.attach_evh(evh); 134 | } 135 | 136 | ``` 137 | 138 | Each time script executes code like this: 139 | 140 | ```JavaScript 141 | var ret = view.Host_DoSomething(param1, param2); 142 | ``` 143 | 144 | it will invoke the `on_script_call()` method of your native `EventHandler`: 145 | 146 | 147 | ```D 148 | import std.conv; 149 | import sciter.behavior; 150 | import sciter.behavior; 151 | 152 | class MyHostEvh : EventHandler 153 | { 154 | override bool on_script_call(HELEMENT he, SCRIPTING_METHOD_PARAMS* prms) 155 | { 156 | switch(to!string(prms.name)) 157 | { 158 | case "Host_DoSomething": 159 | // TIScript values passed by UI side 160 | json_value param1 = json_value(prms.argv[0]); 161 | json_value param2 = json_value(prms.argv[1]); 162 | 163 | prms.result = json_value("Meow!");// TIScript return value for UI side 164 | return true; 165 | } 166 | } 167 | } 168 | ``` 169 | 170 | *2. application events* 171 | 172 | Application can generate some events by itself to the UI script layer. With your native `SciterWindowHost` in place, you simply call it's `call_function()` method: 173 | 174 | ```D 175 | MyHost host = ...; 176 | json_value ret = host.call_function("View_DoSomething", json_value(true), json_value(1234), json_value("from native side"));// call_function() is a variadic function 177 | ``` 178 | 179 | *3. post-requests* 180 | 181 | UI-to-logic post/asynchronous request allows script to call native side method and receive the result in a later time, asynchronously, preventing the UI thread from blocking. Call to native code includes reference to script function that will be executed when the requested data is available. 182 | 183 | Your script side: 184 | 185 | ```JavaScript 186 | view.Host_AsyncProcess(function(meow) { 187 | $(body).text = "Host processing done: " + meow; 188 | }); 189 | ``` 190 | 191 | Your native `EventHandler` shaw be something like: 192 | 193 | ```D 194 | class PostEvh : EventHandler 195 | { 196 | override bool on_script_call(HELEMENT he, SCRIPTING_METHOD_PARAMS* prms) 197 | { 198 | json_value jv_callback = prms.argv[0]; 199 | 200 | // TODO: 201 | // do expensive work in another thread 202 | // or you can save the jv_callback in a global variable and call it in a later time 203 | 204 | jv_callback.call( 205 | json_value("Meow! from host") 206 | ); 207 | return true; 208 | } 209 | } 210 | ``` 211 | 212 | 213 | **`json_value` supports construction through associative arrays, for example:** 214 | 215 | ```D 216 | void Foo() 217 | { 218 | json_value jassoc1 = [ 219 | "key1" : 1, 220 | "key2" : 2, 221 | ]; 222 | 223 | json_value jassoc2 = [ 224 | "key1" : json_value(1), 225 | "key2" : json_value(2), 226 | ]; 227 | } 228 | ``` 229 | 230 | **`json_value` multi-threading guidelines:** 231 | 232 | Be aware that `json_value` is a struct type, and it's destructor clears the associated Sciter VALUE. So if you need a `json_value` to survive when it goes out of scope (mainly in multi-threading scenarios), you must put it in the heap, not it the stack, so instead of: 233 | 234 | ```D 235 | json_value jv = json_value(1234); 236 | ``` 237 | 238 | ..you must: 239 | 240 | ```D 241 | json_value* jv = new json_value(1234); 242 | ``` 243 | 244 | That's D my friend. 245 | 246 | 247 | # Library usage - Win32 248 | 249 | ## 1. Configuring linker: sciter32-import-lib.lib import lib 250 | 251 | You need to add the file 'sciter32-import-lib.lib' to the linker input in order to it find the functions definitions of the Sciter DLL. This is the import lib that you pass to the linker for making your executable statically link to the sciter32.dll exports. 252 | 253 | This file was generated using 'coffimplib' app (ftp://ftp.digitalmars.com/coffimplib.zip and http://www.digitalmars.com/ctg/coffimplib.html). 254 | 255 | 256 | ## 2. Compiling your code 257 | 258 | Requirements: 259 | 260 | - add every .d files under /source/sciter directory to the compiler input, that is, compile them together with your app others .d files 261 | - add /source to the compiler include path 262 | - add needed import statements like: ```import sciter.api``` 263 | 264 | 265 | Minimal code for creating a Sciter based HWND and loading a external .html file: 266 | 267 | ```D 268 | import sciter.interop.sciter_x_types; 269 | import sciter.api; 270 | 271 | void main() 272 | { 273 | RECT frame; 274 | frame.right = 800; 275 | frame.bottom = 600; 276 | 277 | HWINDOW wnd = SciterCreateWindow( 278 | SCITER_CREATE_WINDOW_FLAGS.SW_TITLEBAR | 279 | SCITER_CREATE_WINDOW_FLAGS.SW_RESIZEABLE | 280 | SCITER_CREATE_WINDOW_FLAGS.SW_MAIN | 281 | SCITER_CREATE_WINDOW_FLAGS.SW_CONTROLS, 282 | &frame, null, null, null); 283 | 284 | SciterLoadFile(wnd, "minimal.html"); 285 | 286 | 287 | version(Windows) 288 | { 289 | import core.sys.windows.windows; 290 | 291 | ShowWindow(wnd, 1); 292 | 293 | MSG msg; 294 | while( GetMessageA(&msg, null, 0, 0) ) 295 | { 296 | TranslateMessage(&msg); 297 | DispatchMessageA(&msg); 298 | } 299 | } 300 | } 301 | ``` 302 | 303 | # Library usage - Linux 304 | 305 | Requirements: 306 | 307 | Sciter for Linux requires GTK+3 and libcurl. Just make sure to install GTK+3 developer package: 308 | 309 | ```bash 310 | sudo apt-get install libgtk-3-dev 311 | ``` 312 | -------------------------------------------------------------------------------- /dub.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "sciter-dport", 3 | "license": "GPL-3.0", 4 | "description": "Port of Sciter headers for D.", 5 | "copyright": "Copyright © 2015, midi", 6 | "authors": ["midi"], 7 | 8 | "excludedSourceFiles": ["source/winkit/*"], 9 | "importPaths": ["source", "source/gtkkit"], 10 | 11 | "configurations": [ 12 | { 13 | "name": "linux-library", 14 | "platforms": ["linux"], 15 | "libs": ["dl"] 16 | }, 17 | 18 | { 19 | "name": "windows-library", 20 | "platforms": ["windows"], 21 | "libs": ["$PACKAGE_DIR/sciter32-import-lib"], 22 | } 23 | ] 24 | } -------------------------------------------------------------------------------- /samples/gtkminimal/dub.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "uminimal", 3 | "description": "Minimal demonstration of usage of sciter-dport to create an universal Sciter window (the same source code for the three supported platforms: Windows, Linux GTX and Mac OSX)", 4 | "authors": ["midi"], 5 | 6 | "dependencies": { 7 | "sciter-dport": { 8 | "version": "~master", 9 | "path": "../../" 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /samples/gtkminimal/minimal.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | Sciter/D 4 | 18 | 19 | 20 |
21 | D language and the Sciter 22 |
23 | 24 | -------------------------------------------------------------------------------- /samples/gtkminimal/source/main.d: -------------------------------------------------------------------------------- 1 | import sciter.interop.sciter_x_types; 2 | import sciter.api; 3 | import gtkc.gtk; 4 | 5 | void main() 6 | { 7 | gtk_init(null, null); 8 | 9 | RECT frame; 10 | frame.right = 800; 11 | frame.bottom = 600; 12 | 13 | HWINDOW wnd = SciterCreateWindow( 14 | SCITER_CREATE_WINDOW_FLAGS.SW_TITLEBAR | 15 | SCITER_CREATE_WINDOW_FLAGS.SW_RESIZEABLE | 16 | SCITER_CREATE_WINDOW_FLAGS.SW_MAIN | 17 | SCITER_CREATE_WINDOW_FLAGS.SW_CONTROLS, 18 | &frame, null, null, null); 19 | 20 | SciterLoadFile(wnd, "minimal.html"); 21 | 22 | gtk_main(); 23 | } -------------------------------------------------------------------------------- /samples/host-client-post-idiom/dub.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "host-client-post-idiom", 3 | "license": "GPL-3.0", 4 | "copyright": "Copyright © 2015, midi", 5 | "authors": ["midi"], 6 | 7 | "dependencies": { 8 | "sciter-dport": { 9 | "version": "~master", 10 | "path": "../../" 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /samples/host-client-post-idiom/minimal.html: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | Processing... 10 | 11 | -------------------------------------------------------------------------------- /samples/host-client-post-idiom/source/main.d: -------------------------------------------------------------------------------- 1 | import std.stdio; 2 | 3 | import sciter.interop.sciter_x_types; 4 | import sciter.api; 5 | import sciter.host; 6 | import sciter.behavior; 7 | import sciter.sciter_value; 8 | 9 | 10 | class PostHost : SciterWindowHost 11 | { 12 | } 13 | 14 | class PostEvh : EventHandler 15 | { 16 | override bool on_script_call(HELEMENT he, SCRIPTING_METHOD_PARAMS* prms) 17 | { 18 | json_value jv_callback = prms.argv[0]; 19 | 20 | // TODO: 21 | // do expensive work in another thread 22 | // or you can save the jv_callback in a global variable and call it in a later time 23 | 24 | jv_callback.call( 25 | json_value("Meow! from host") 26 | ); 27 | return true; 28 | } 29 | } 30 | 31 | void main() 32 | { 33 | RECT frame; 34 | frame.right = 800; 35 | frame.bottom = 600; 36 | 37 | HWINDOW wnd = SciterCreateWindow( 38 | SCITER_CREATE_WINDOW_FLAGS.SW_TITLEBAR | 39 | SCITER_CREATE_WINDOW_FLAGS.SW_RESIZEABLE | 40 | SCITER_CREATE_WINDOW_FLAGS.SW_MAIN | 41 | SCITER_CREATE_WINDOW_FLAGS.SW_CONTROLS, 42 | &frame, null, null, null); 43 | 44 | auto host = new PostHost(); 45 | host.setup_callback(wnd); 46 | 47 | auto evh = new PostEvh(); 48 | host.attach_evh(evh); 49 | 50 | SciterLoadFile(wnd, "minimal.html"); 51 | 52 | 53 | version(Windows) 54 | { 55 | import core.sys.windows.windows; 56 | 57 | ShowWindow(wnd, 1); 58 | 59 | MSG msg; 60 | while( GetMessageA(&msg, null, 0, 0) ) 61 | { 62 | TranslateMessage(&msg); 63 | DispatchMessageA(&msg); 64 | } 65 | } 66 | } -------------------------------------------------------------------------------- /samples/uminimal/dub.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "uminimal", 3 | "description": "Minimal demonstration of usage of sciter-dport to create an universal Sciter window (the same source code for the three supported platforms: Windows, Linux GTX and Mac OSX)", 4 | "authors": ["midi"], 5 | 6 | "dependencies": { 7 | "sciter-dport": { 8 | "version": "~master", 9 | "path": "../../" 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /samples/uminimal/minimal.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 19 | 20 | 21 |
22 | D language and the Sciter 23 |
24 | 25 | -------------------------------------------------------------------------------- /samples/uminimal/source/main.d: -------------------------------------------------------------------------------- 1 | import sciter.interop.sciter_x_types; 2 | import sciter.api; 3 | 4 | void main() 5 | { 6 | RECT frame; 7 | frame.right = 800; 8 | frame.bottom = 600; 9 | 10 | HWINDOW wnd = SciterCreateWindow( 11 | SCITER_CREATE_WINDOW_FLAGS.SW_TITLEBAR | 12 | SCITER_CREATE_WINDOW_FLAGS.SW_RESIZEABLE | 13 | SCITER_CREATE_WINDOW_FLAGS.SW_MAIN | 14 | SCITER_CREATE_WINDOW_FLAGS.SW_CONTROLS, 15 | &frame, null, null, null); 16 | 17 | SciterLoadFile(wnd, "minimal.html"); 18 | 19 | 20 | version(Windows) 21 | { 22 | import winkit.WinAPI; 23 | 24 | ShowWindow(wnd, 1); 25 | 26 | MSG msg; 27 | while( GetMessageW(&msg, null, 0, 0) ) 28 | { 29 | TranslateMessage(&msg); 30 | DispatchMessageW(&msg); 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /sciter32-import-lib.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sciter-sdk/Sciter-Dport/34f177a9bb513feb40f41d7a0e198c531b517d6f/sciter32-import-lib.lib -------------------------------------------------------------------------------- /source/gtkkit/gtkc/Loader.d: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of gtkD. 3 | * 4 | * gtkD is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License 6 | * as published by the Free Software Foundation; either version 3 7 | * of the License, or (at your option) any later version, with 8 | * some exceptions, please read the COPYING file. 9 | * 10 | * gtkD is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with gtkD; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 | */ 19 | 20 | module gtkc.Loader; 21 | 22 | import std.stdio; 23 | import std.string; 24 | 25 | import gtkc.paths; 26 | 27 | public struct Linker 28 | { 29 | private static void*[string] loadedLibraries; 30 | private static string[][string] loadFailures; 31 | 32 | extern(C) static void unsupportedSymbol() 33 | { 34 | throw new Error("The function you are calling is not pressent in your version of GTK+."); 35 | } 36 | 37 | /* 38 | * Links the provided symbol 39 | * Params: 40 | * funct = The function we are linking 41 | * symbol = The name of the symbol to link 42 | * libraries = One or more libraries to search for the symbol 43 | */ 44 | public static void link(T)(ref T funct, string symbol, LIBRARY[] libraries ...) 45 | { 46 | funct = cast(T)getSymbol(symbol, libraries); 47 | } 48 | 49 | /* 50 | * Links the provided symbol 51 | * Params: 52 | * funct = The function we are linking 53 | * symbol = The name of the symbol to link 54 | * libraries = One or more libraries to search for the symbol 55 | */ 56 | public static void link(T)(ref T funct, string symbol, string[] libraries ...) 57 | { 58 | funct = cast(T)getSymbol(symbol, libraries); 59 | } 60 | 61 | /* 62 | * Gets a simbol from one of the provided libraries 63 | * Params: 64 | * symbol = The name of the symbol to link 65 | * libraries = One or more libraries to search for the symbol 66 | */ 67 | public static void* getSymbol(string symbol, LIBRARY[] libraries ...) 68 | { 69 | string[] libStr = new string[libraries.length]; 70 | 71 | foreach (i, library; libraries ) 72 | { 73 | libStr[i] = importLibs[library]; 74 | } 75 | 76 | return getSymbol(symbol, libStr); 77 | } 78 | 79 | /* 80 | * Gets a simbol from one of the provided libraries 81 | * Params: 82 | * symbol = The name of the symbol to link 83 | * libraries = One or more libraries to search for the symbol 84 | */ 85 | public static void* getSymbol(string symbol, string[] libraries ...) 86 | { 87 | void* handle; 88 | 89 | foreach ( library; libraries ) 90 | { 91 | if( !(library in loadedLibraries) ) 92 | loadLibrary(library); 93 | 94 | handle = pGetSymbol(loadedLibraries[library], symbol); 95 | 96 | if ( handle !is null ) 97 | break; 98 | } 99 | 100 | if ( handle is null ) 101 | { 102 | foreach ( library; libraries ) 103 | loadFailures[library] ~= symbol; 104 | 105 | handle = &unsupportedSymbol; 106 | } 107 | 108 | return handle; 109 | } 110 | 111 | /* 112 | * Loads a library 113 | */ 114 | public static void loadLibrary(string library) 115 | { 116 | void* handle = pLoadLibrary(library); 117 | 118 | //TODO: A more general way to try more than one version. 119 | if ( handle is null && library == importLibs[LIBRARY.GSV] ) 120 | handle = pLoadLibrary(importLibs[LIBRARY.GSV1]); 121 | 122 | if ( handle is null ) 123 | throw new Exception("Library load failed: " ~ library); 124 | 125 | loadedLibraries[library] = handle; 126 | } 127 | 128 | /* 129 | * Unload a library 130 | */ 131 | public static void unloadLibrary(LIBRARY library) 132 | { 133 | unloadLibrary( importLibs[library] ); 134 | } 135 | 136 | /* 137 | * Unload a library 138 | */ 139 | public static void unloadLibrary(string library) 140 | { 141 | pUnloadLibrary(loadedLibraries[library]); 142 | 143 | loadedLibraries.remove(library); 144 | } 145 | 146 | /** 147 | * Checks if any symbol failed to load 148 | * Returns: true if ALL symbols are loaded 149 | */ 150 | public static bool isPerfectLoad() 151 | { 152 | return loadFailures.keys.length == 0; 153 | } 154 | 155 | /** 156 | * Gets all libraries loaded. 157 | * returns: An array with the loaded libraries 158 | */ 159 | public static string[] getLoadLibraries() 160 | { 161 | return loadedLibraries.keys; 162 | } 163 | 164 | /** 165 | * Print all libraries loaded. 166 | */ 167 | public static void dumpLoadLibraries() 168 | { 169 | foreach ( lib; getLoadLibraries() ) 170 | { 171 | writefln("Loaded lib = %s", lib); 172 | } 173 | } 174 | 175 | /** 176 | * Checks if a library is loaded. 177 | * Returns: true is the library was loaded sucsessfully. 178 | */ 179 | public static bool isLoaded(LIBRARY library) 180 | { 181 | return isLoaded(importLibs[library]); 182 | } 183 | 184 | /** 185 | * Checks if a library is loaded. 186 | * Returns: true is the library was loaded sucsessfully. 187 | */ 188 | public static bool isLoaded(string library) 189 | { 190 | if ( library in loadedLibraries ) 191 | return true; 192 | else 193 | return false; 194 | } 195 | 196 | /** 197 | * Gets all the failed loads for a specific library. 198 | * returns: An array of the names hat failed to load for a specific library 199 | * or null if none was found 200 | */ 201 | public static string[] getLoadFailures(LIBRARY library) 202 | { 203 | return getLoadFailures(importLibs[library]); 204 | } 205 | 206 | /** 207 | * Gets all the failed loads for a specific library. 208 | * returns: An array of the names hat failed to load for a specific library 209 | * or null if none was found 210 | */ 211 | public static string[] getLoadFailures(string library) 212 | { 213 | if ( library in loadFailures ) 214 | return loadFailures[library]; 215 | else 216 | return null; 217 | } 218 | 219 | /** 220 | * Print all symbols that failed to load 221 | */ 222 | public static void dumpFailedLoads() 223 | { 224 | foreach ( library; loadedLibraries.keys ) 225 | { 226 | foreach ( symbol; getLoadFailures(library) ) 227 | { 228 | writefln("failed (%s) %s", library, symbol); 229 | } 230 | } 231 | } 232 | 233 | static ~this() 234 | { 235 | foreach ( library; loadedLibraries.keys ) 236 | unloadLibrary(library); 237 | } 238 | } 239 | 240 | // Platform specific implementation below. 241 | 242 | version(Windows) 243 | { 244 | extern(Windows) 245 | { 246 | void* LoadLibraryA(char*); 247 | void* GetProcAddress(void*, char*); 248 | void FreeLibrary(void*); 249 | 250 | int SetDllDirectoryA(const(char)* path); 251 | 252 | enum MachineType : ushort 253 | { 254 | UNKNOWN = 0x0, 255 | AM33 = 0x1d3, 256 | AMD64 = 0x8664, 257 | ARM = 0x1c0, 258 | EBC = 0xebc, 259 | I386 = 0x14c, 260 | IA64 = 0x200, 261 | M32R = 0x9041, 262 | MIPS16 = 0x266, 263 | MIPSFPU = 0x366, 264 | MIPSFPU16 = 0x466, 265 | POWERPC = 0x1f0, 266 | POWERPCFP = 0x1f1, 267 | R4000 = 0x166, 268 | SH3 = 0x1a2, 269 | SH3DSP = 0x1a3, 270 | SH4 = 0x1a6, 271 | SH5 = 0x1a8, 272 | THUMB = 0x1c2, 273 | WCEMIPSV2 = 0x169, 274 | } 275 | } 276 | 277 | private void* pLoadLibrary(string libraryName) 278 | { 279 | setDllPath(); 280 | 281 | return LoadLibraryA(cast(char*)toStringz(libraryName)); 282 | } 283 | 284 | private void* pGetSymbol(void* handle, string symbol) 285 | { 286 | return GetProcAddress(handle, cast(char*)toStringz(symbol)); 287 | } 288 | 289 | private alias FreeLibrary pUnloadLibrary; 290 | 291 | private void setDllPath() 292 | { 293 | static bool isSet; 294 | 295 | if ( isSet ) 296 | return; 297 | 298 | string gtkPath = getGtkPath(); 299 | 300 | if ( gtkPath.length > 0 ) 301 | SetDllDirectoryA((gtkPath~'\0').ptr); 302 | 303 | isSet = true; 304 | } 305 | 306 | private string getGtkPath() 307 | { 308 | import std.algorithm; 309 | import std.path; 310 | import std.process; 311 | import std.file; 312 | 313 | foreach (path; splitter(environment.get("PATH"), ';')) 314 | { 315 | string dllPath = buildNormalizedPath(path, "libgtk-3-0.dll"); 316 | 317 | if ( !exists(dllPath) ) 318 | continue; 319 | 320 | if ( checkArchitecture(dllPath) ) 321 | return path; 322 | } 323 | 324 | return null; 325 | } 326 | 327 | private bool checkArchitecture(string dllPath) 328 | { 329 | import std.stdio; 330 | 331 | File dll = File(dllPath); 332 | 333 | dll.seek(0x3c); 334 | int offset = dll.rawRead(new int[1])[0]; 335 | 336 | dll.seek(offset); 337 | uint peHead = dll.rawRead(new uint[1])[0]; 338 | 339 | //Not a PE Header. 340 | if( peHead != 0x00004550) 341 | return false; 342 | 343 | MachineType type = dll.rawRead(new MachineType[1])[0]; 344 | 345 | version(Win32) 346 | { 347 | if ( type == MachineType.I386 ) 348 | return true; 349 | } 350 | else version(Win64) 351 | { 352 | if ( type == MachineType.AMD64 ) 353 | return true; 354 | } 355 | 356 | return false; 357 | } 358 | } 359 | else 360 | { 361 | extern(C) 362 | { 363 | void* dlopen(char*, int); 364 | char* dlerror(); 365 | void* dlsym(void*,char*); 366 | int dlclose(void*); 367 | } 368 | 369 | enum RTLD 370 | { 371 | LAZY = 0x00001, // Lazy function call binding 372 | NOW = 0x00002, // Immediate function call binding 373 | NOLOAD = 0x00004, // No object load 374 | DEEPBIND = 0x00008, // 375 | GLOBAL = 0x00100 // Make object available to whole program 376 | } 377 | 378 | private void* pLoadLibrary(string libraryName, RTLD flag = RTLD.NOW) 379 | { 380 | void* handle = dlopen(cast(char*)toStringz(libraryName), flag); 381 | 382 | // clear the error buffer 383 | dlerror(); 384 | 385 | return handle; 386 | } 387 | 388 | private void* pGetSymbol(void* libraryHandle, string symbol) 389 | { 390 | void* symbolHandle = dlsym(libraryHandle, cast(char*)toStringz(symbol)); 391 | 392 | // clear the error buffer 393 | dlerror(); 394 | 395 | return symbolHandle; 396 | } 397 | 398 | private int pUnloadLibrary(void* libraryHandle) 399 | { 400 | return dlclose(libraryHandle); 401 | } 402 | } -------------------------------------------------------------------------------- /source/gtkkit/gtkc/gdkpixbuftypes.d: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of gtkD. 3 | * 4 | * gtkD is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License 6 | * as published by the Free Software Foundation; either version 3 7 | * of the License, or (at your option) any later version, with 8 | * some exceptions, please read the COPYING file. 9 | * 10 | * gtkD is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with gtkD; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 | */ 19 | 20 | // generated automatically - do not change 21 | // find conversion definition on APILookup.txt 22 | // implement new conversion functionalities on the wrap.utils pakage 23 | 24 | 25 | module gtkc.gdkpixbuftypes; 26 | 27 | public import gtkc.glibtypes; 28 | public import gtkc.gobjecttypes; 29 | public import gtkc.gdktypes; 30 | public import gtkc.atktypes; 31 | private import std.stdio; 32 | 33 | public alias void* GdkPixbufAnimationIterAutoptr; 34 | 35 | public alias void* GdkPixbufAnimationAutoptr; 36 | 37 | public alias void* GdkPixbufLoaderAutoptr; 38 | 39 | public alias void* GdkPixbufSimpleAnimAutoptr; 40 | 41 | public alias void* GdkPixbufAutoptr; 42 | 43 | /** 44 | * This enumeration defines the color spaces that are supported by 45 | * the gdk-pixbuf library. Currently only RGB is supported. 46 | */ 47 | public enum GdkColorspace 48 | { 49 | /** 50 | * Indicates a red/green/blue additive color space. 51 | */ 52 | RGB = 0, 53 | } 54 | alias GdkColorspace Colorspace; 55 | 56 | /** 57 | * This enumeration describes the different interpolation modes that 58 | * can be used with the scaling functions. @GDK_INTERP_NEAREST is 59 | * the fastest scaling method, but has horrible quality when 60 | * scaling down. @GDK_INTERP_BILINEAR is the best choice if you 61 | * aren't sure what to choose, it has a good speed/quality balance. 62 | * 63 | * 64 | * Cubic filtering is missing from the list; hyperbolic 65 | * interpolation is just as fast and results in higher quality. 66 | * 67 | */ 68 | public enum GdkInterpType 69 | { 70 | /** 71 | * Nearest neighbor sampling; this is the fastest 72 | * and lowest quality mode. Quality is normally unacceptable when scaling 73 | * down, but may be OK when scaling up. 74 | */ 75 | NEAREST = 0, 76 | /** 77 | * This is an accurate simulation of the PostScript 78 | * image operator without any interpolation enabled. Each pixel is 79 | * rendered as a tiny parallelogram of solid color, the edges of which 80 | * are implemented with antialiasing. It resembles nearest neighbor for 81 | * enlargement, and bilinear for reduction. 82 | */ 83 | TILES = 1, 84 | /** 85 | * Best quality/speed balance; use this mode by 86 | * default. Bilinear interpolation. For enlargement, it is 87 | * equivalent to point-sampling the ideal bilinear-interpolated image. 88 | * For reduction, it is equivalent to laying down small tiles and 89 | * integrating over the coverage area. 90 | */ 91 | BILINEAR = 2, 92 | /** 93 | * This is the slowest and highest quality 94 | * reconstruction function. It is derived from the hyperbolic filters in 95 | * Wolberg's "Digital Image Warping", and is formally defined as the 96 | * hyperbolic-filter sampling the ideal hyperbolic-filter interpolated 97 | * image (the filter is designed to be idempotent for 1:1 pixel mapping). 98 | */ 99 | HYPER = 3, 100 | } 101 | alias GdkInterpType InterpType; 102 | 103 | /** 104 | * These values can be passed to 105 | * gdk_pixbuf_render_to_drawable_alpha() to control how the alpha 106 | * channel of an image should be handled. This function can create a 107 | * bilevel clipping mask (black and white) and use it while painting 108 | * the image. In the future, when the X Window System gets an alpha 109 | * channel extension, it will be possible to do full alpha 110 | * compositing onto arbitrary drawables. For now both cases fall 111 | * back to a bilevel clipping mask. 112 | */ 113 | public enum GdkPixbufAlphaMode 114 | { 115 | /** 116 | * A bilevel clipping mask (black and white) 117 | * will be created and used to draw the image. Pixels below 0.5 opacity 118 | * will be considered fully transparent, and all others will be 119 | * considered fully opaque. 120 | */ 121 | BILEVEL = 0, 122 | /** 123 | * For now falls back to #GDK_PIXBUF_ALPHA_BILEVEL. 124 | * In the future it will do full alpha compositing. 125 | */ 126 | FULL = 1, 127 | } 128 | alias GdkPixbufAlphaMode PixbufAlphaMode; 129 | 130 | /** 131 | * An error code in the #GDK_PIXBUF_ERROR domain. Many gdk-pixbuf 132 | * operations can cause errors in this domain, or in the #G_FILE_ERROR 133 | * domain. 134 | */ 135 | public enum GdkPixbufError 136 | { 137 | /** 138 | * An image file was broken somehow. 139 | */ 140 | CORRUPT_IMAGE = 0, 141 | /** 142 | * Not enough memory. 143 | */ 144 | INSUFFICIENT_MEMORY = 1, 145 | /** 146 | * A bad option was passed to a pixbuf save module. 147 | */ 148 | BAD_OPTION = 2, 149 | /** 150 | * Unknown image type. 151 | */ 152 | UNKNOWN_TYPE = 3, 153 | /** 154 | * Don't know how to perform the 155 | * given operation on the type of image at hand. 156 | */ 157 | UNSUPPORTED_OPERATION = 4, 158 | /** 159 | * Generic failure code, something went wrong. 160 | */ 161 | FAILED = 5, 162 | } 163 | alias GdkPixbufError PixbufError; 164 | 165 | /** 166 | * The possible rotations which can be passed to gdk_pixbuf_rotate_simple(). 167 | * To make them easier to use, their numerical values are the actual degrees. 168 | */ 169 | public enum GdkPixbufRotation 170 | { 171 | /** 172 | * No rotation. 173 | */ 174 | NONE = 0, 175 | /** 176 | * Rotate by 90 degrees. 177 | */ 178 | COUNTERCLOCKWISE = 90, 179 | /** 180 | * Rotate by 180 degrees. 181 | */ 182 | UPSIDEDOWN = 180, 183 | /** 184 | * Rotate by 270 degrees. 185 | */ 186 | CLOCKWISE = 270, 187 | } 188 | alias GdkPixbufRotation PixbufRotation; 189 | 190 | /** 191 | * An enumeration which is used by gdk_pixdata_to_csource() to 192 | * determine the form of C source to be generated. The three values 193 | * @GDK_PIXDATA_DUMP_PIXDATA_STREAM, @GDK_PIXDATA_DUMP_PIXDATA_STRUCT 194 | * and @GDK_PIXDATA_DUMP_MACROS are mutually exclusive, as are 195 | * @GDK_PIXBUF_DUMP_GTYPES and @GDK_PIXBUF_DUMP_CTYPES. The remaining 196 | * elements are optional flags that can be freely added. 197 | */ 198 | public enum GdkPixdataDumpType 199 | { 200 | /** 201 | * Generate pixbuf data stream (a single 202 | * string containing a serialized #GdkPixdata structure in network byte 203 | * order). 204 | */ 205 | PIXDATA_STREAM = 0, 206 | /** 207 | * Generate #GdkPixdata structure (needs 208 | * the #GdkPixdata structure definition from gdk-pixdata.h). 209 | */ 210 | PIXDATA_STRUCT = 1, 211 | /** 212 | * Generate *_ROWSTRIDE, 213 | * *_WIDTH, *_HEIGHT, 214 | * *_BYTES_PER_PIXEL and 215 | * *_RLE_PIXEL_DATA or *_PIXEL_DATA 216 | * macro definitions for the image. 217 | */ 218 | MACROS = 2, 219 | /** 220 | * Generate GLib data types instead of 221 | * standard C data types. 222 | */ 223 | GTYPES = 0, 224 | /** 225 | * Generate standard C data types instead of 226 | * GLib data types. 227 | */ 228 | CTYPES = 256, 229 | /** 230 | * Generate static symbols. 231 | */ 232 | STATIC = 512, 233 | /** 234 | * Generate const symbols. 235 | */ 236 | CONST = 1024, 237 | /** 238 | * Provide a *_RUN_LENGTH_DECODE(image_buf, rle_data, size, bpp) 239 | * macro definition to decode run-length encoded image data. 240 | */ 241 | RLE_DECODER = 65536, 242 | } 243 | alias GdkPixdataDumpType PixdataDumpType; 244 | 245 | /** 246 | * An enumeration containing three sets of flags for a #GdkPixdata struct: 247 | * one for the used colorspace, one for the width of the samples and one 248 | * for the encoding of the pixel data. 249 | */ 250 | public enum GdkPixdataType 251 | { 252 | /** 253 | * each pixel has red, green and blue samples. 254 | */ 255 | COLOR_TYPE_RGB = 1, 256 | /** 257 | * each pixel has red, green and blue samples 258 | * and an alpha value. 259 | */ 260 | COLOR_TYPE_RGBA = 2, 261 | /** 262 | * mask for the colortype flags of the enum. 263 | */ 264 | COLOR_TYPE_MASK = 255, 265 | /** 266 | * each sample has 8 bits. 267 | */ 268 | SAMPLE_WIDTH_8 = 65536, 269 | /** 270 | * mask for the sample width flags of the enum. 271 | */ 272 | SAMPLE_WIDTH_MASK = 983040, 273 | /** 274 | * the pixel data is in raw form. 275 | */ 276 | ENCODING_RAW = 16777216, 277 | /** 278 | * the pixel data is run-length encoded. Runs may 279 | * be up to 127 bytes long; their length is stored in a single byte 280 | * preceding the pixel data for the run. If a run is constant, its length 281 | * byte has the high bit set and the pixel data consists of a single pixel 282 | * which must be repeated. 283 | */ 284 | ENCODING_RLE = 33554432, 285 | /** 286 | * mask for the encoding flags of the enum. 287 | */ 288 | ENCODING_MASK = 251658240, 289 | } 290 | alias GdkPixdataType PixdataType; 291 | 292 | struct GdkPixbuf; 293 | 294 | struct GdkPixbufAnimation; 295 | 296 | struct GdkPixbufAnimationIter; 297 | 298 | struct GdkPixbufFormat; 299 | 300 | struct GdkPixbufLoader 301 | { 302 | GObject parentInstance; 303 | void* priv; 304 | } 305 | 306 | struct GdkPixbufLoaderClass 307 | { 308 | GObjectClass parentClass; 309 | extern(C) void function(GdkPixbufLoader* loader, int width, int height) sizePrepared; 310 | extern(C) void function(GdkPixbufLoader* loader) areaPrepared; 311 | extern(C) void function(GdkPixbufLoader* loader, int x, int y, int width, int height) areaUpdated; 312 | extern(C) void function(GdkPixbufLoader* loader) closed; 313 | } 314 | 315 | struct GdkPixbufSimpleAnim; 316 | 317 | struct GdkPixbufSimpleAnimClass; 318 | 319 | 320 | struct GdkPixdata 321 | { 322 | /** 323 | * magic number. A valid #GdkPixdata structure must have 324 | * #GDK_PIXBUF_MAGIC_NUMBER here. 325 | */ 326 | uint magic; 327 | /** 328 | * less than 1 to disable length checks, otherwise 329 | * #GDK_PIXDATA_HEADER_LENGTH + length of @pixel_data. 330 | */ 331 | int length; 332 | /** 333 | * information about colorspace, sample width and 334 | * encoding, in a #GdkPixdataType. 335 | */ 336 | uint pixdataType; 337 | /** 338 | * Distance in bytes between rows. 339 | */ 340 | uint rowstride; 341 | /** 342 | * Width of the image in pixels. 343 | */ 344 | uint width; 345 | /** 346 | * Height of the image in pixels. 347 | */ 348 | uint height; 349 | /** 350 | * @width x @height pixels, encoded according to @pixdata_type 351 | * and @rowstride. 352 | */ 353 | ubyte* pixelData; 354 | } 355 | 356 | /** 357 | * A function of this type is responsible for freeing the pixel array 358 | * of a pixbuf. The gdk_pixbuf_new_from_data() function lets you 359 | * pass in a pre-allocated pixel array so that a pixbuf can be 360 | * created from it; in this case you will need to pass in a function 361 | * of #GdkPixbufDestroyNotify so that the pixel data can be freed 362 | * when the pixbuf is finalized. 363 | * 364 | * Params: 365 | * pixels = The pixel array of the pixbuf 366 | * that is being finalized. 367 | * data = User closure data. 368 | */ 369 | public alias extern(C) void function(char* pixels, void* data) GdkPixbufDestroyNotify; 370 | 371 | /** 372 | * Specifies the type of the function passed to 373 | * gdk_pixbuf_save_to_callback(). It is called once for each block of 374 | * bytes that is "written" by gdk_pixbuf_save_to_callback(). If 375 | * successful it should return %TRUE. If an error occurs it should set 376 | * @error and return %FALSE, in which case gdk_pixbuf_save_to_callback() 377 | * will fail with the same error. 378 | * 379 | * Params: 380 | * buf = bytes to be written. 381 | * count = number of bytes in @buf. 382 | * error = A location to return an error. 383 | * data = user data passed to gdk_pixbuf_save_to_callback(). 384 | * 385 | * Return: %TRUE if successful, %FALSE (with @error set) if failed. 386 | * 387 | * Since: 2.4 388 | */ 389 | public alias extern(C) int function(char* buf, size_t count, GError** error, void* data) GdkPixbufSaveFunc; 390 | -------------------------------------------------------------------------------- /source/gtkkit/gtkc/gthread.d: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of gtkD. 3 | * 4 | * gtkD is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License 6 | * as published by the Free Software Foundation; either version 3 7 | * of the License, or (at your option) any later version, with 8 | * some exceptions, please read the COPYING file. 9 | * 10 | * gtkD is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with gtkD; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 | */ 19 | 20 | // generated automatically - do not change 21 | // find conversion definition on APILookup.txt 22 | // implement new conversion functionalities on the wrap.utils pakage 23 | 24 | 25 | module gtkc.gthread; 26 | 27 | import std.stdio; 28 | import gtkc.gthreadtypes; 29 | import gtkc.Loader; 30 | import gtkc.paths; 31 | 32 | shared static this() 33 | {} 34 | 35 | __gshared extern(C) 36 | { 37 | } 38 | 39 | -------------------------------------------------------------------------------- /source/gtkkit/gtkc/gthreadtypes.d: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of gtkD. 3 | * 4 | * gtkD is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU Lesser General Public License 6 | * as published by the Free Software Foundation; either version 3 7 | * of the License, or (at your option) any later version, with 8 | * some exceptions, please read the COPYING file. 9 | * 10 | * gtkD is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public License 16 | * along with gtkD; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 | */ 19 | 20 | // generated automatically - do not change 21 | // find conversion definition on APILookup.txt 22 | // implement new conversion functionalities on the wrap.utils pakage 23 | 24 | 25 | module gtkc.gthreadtypes; 26 | 27 | -------------------------------------------------------------------------------- /source/gtkkit/gtkc/paths.d: -------------------------------------------------------------------------------- 1 | /* 2 | * gtkD is free software; you can redistribute it and/or modify 3 | * it under the terms of the GNU Lesser General Public License 4 | * as published by the Free Software Foundation; either version 3 5 | * of the License, or (at your option) any later version, with 6 | * some exceptions, please read the COPYING file. 7 | * 8 | * gtkD is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU Lesser General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU Lesser General Public License 14 | * along with gtkD; if not, write to the Free Software 15 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 16 | * 17 | * paths.d -- list of libraries that will be dynamically linked with gtkD 18 | * 19 | * Added: John Reimer -- 2004-12-20 20 | * Updated: 2005-02-21 changed names; added version(linux) 21 | * Updated: 2005-05-05 updated Linux support 22 | * Updated: 2008-02-16 Tango support 23 | */ 24 | 25 | module gtkc.paths; 26 | 27 | /* 28 | * Define the Libraries that gtkD will be using. 29 | * This is a growable list, as long as the programmer 30 | * also adds to the importLibs list. 31 | */ 32 | 33 | enum LIBRARY 34 | { 35 | ATK, 36 | CAIRO, 37 | GDK, 38 | GDKPIXBUF, 39 | GLIB, 40 | GMODULE, 41 | GOBJECT, 42 | GIO, 43 | GTHREAD, 44 | GTK, 45 | PANGO, 46 | PANGOCAIRO, 47 | GLGDK, 48 | GLGTK, 49 | GDA, 50 | GSV, 51 | GSV1, 52 | GSTREAMER, 53 | GSTINTERFACES, 54 | VTE, 55 | } 56 | 57 | version (Windows) 58 | { 59 | const string[LIBRARY.max+1] importLibs = 60 | [ 61 | LIBRARY.ATK: "libatk-1.0-0.dll", 62 | LIBRARY.CAIRO: "libcairo-2.dll", 63 | LIBRARY.GDK: "libgdk-3-0.dll", 64 | LIBRARY.GDKPIXBUF: "libgdk_pixbuf-2.0-0.dll", 65 | LIBRARY.GLIB: "libglib-2.0-0.dll", 66 | LIBRARY.GMODULE: "libgmodule-2.0-0.dll", 67 | LIBRARY.GOBJECT: "libgobject-2.0-0.dll", 68 | LIBRARY.GIO: "libgio-2.0-0.dll", 69 | LIBRARY.GTHREAD: "libgthread-2.0-0.dll", 70 | LIBRARY.GTK: "libgtk-3-0.dll", 71 | LIBRARY.PANGO: "libpango-1.0-0.dll", 72 | LIBRARY.PANGOCAIRO: "libpangocairo-1.0-0.dll", 73 | LIBRARY.GLGDK: "libgdkglext-3.0-0.dll", 74 | LIBRARY.GLGTK: "libgtkglext-3.0-0.dll", 75 | LIBRARY.GDA: "libgda-4.0-4.dll", 76 | LIBRARY.GSV: "libgtksourceview-3.0-0.dll", 77 | LIBRARY.GSV1: "libgtksourceview-3.0-1.dll", 78 | LIBRARY.GSTREAMER: "libgstreamer-1.0.dll", 79 | LIBRARY.GSTINTERFACES: "libgstvideo-1.0.dll", 80 | LIBRARY.VTE: "libvte2_90.dll", 81 | ]; 82 | } 83 | else version(darwin) 84 | { 85 | const string[LIBRARY.max+1] importLibs = 86 | [ 87 | LIBRARY.ATK: "libatk-1.0.dylib", 88 | LIBRARY.CAIRO: "libcairo.dylib", 89 | LIBRARY.GDK: "libgdk-3.0.dylib", 90 | LIBRARY.GDKPIXBUF: "libgdk_pixbuf-2.0.dylib", 91 | LIBRARY.GLIB: "libglib-2.0.dylib", 92 | LIBRARY.GMODULE: "libgmodule-2.0.dylib", 93 | LIBRARY.GOBJECT: "libgobject-2.0.dylib", 94 | LIBRARY.GIO: "libgio-2.0.dylib", 95 | LIBRARY.GTHREAD: "libgthread-2.0.dylib", 96 | LIBRARY.GTK: "libgtk-3.0.dylib", 97 | LIBRARY.PANGO: "libpango-1.0.dylib", 98 | LIBRARY.PANGOCAIRO: "libpangocairo-1.0.dylib", 99 | LIBRARY.GLGDK: "libgdkglext-3.0.dylib", 100 | LIBRARY.GLGTK: "libgtkglext-3.0.dylib", 101 | LIBRARY.GDA: "libgda-2.dylib", 102 | LIBRARY.GSV: "libgtksourceview-3.0.dylib", 103 | LIBRARY.GSV1: "libgtksourceview-3.0.dylib", 104 | LIBRARY.GSTREAMER: "libgstreamer-1.0.dylib", 105 | LIBRARY.GSTINTERFACES: "libgstvideo-1.0.dylib", 106 | LIBRARY.VTE: "libvte2_90.dylib" 107 | ]; 108 | } 109 | else 110 | { 111 | const string[LIBRARY.max+1] importLibs = 112 | [ 113 | LIBRARY.ATK: "libatk-1.0.so.0", 114 | LIBRARY.CAIRO: "libcairo.so.2", 115 | LIBRARY.GDK: "libgdk-3.so.0", 116 | LIBRARY.GDKPIXBUF: "libgdk_pixbuf-2.0.so.0", 117 | LIBRARY.GLIB: "libglib-2.0.so.0", 118 | LIBRARY.GMODULE: "libgmodule-2.0.so.0", 119 | LIBRARY.GOBJECT: "libgobject-2.0.so.0", 120 | LIBRARY.GIO: "libgio-2.0.so.0", 121 | LIBRARY.GTHREAD: "libgthread-2.0.so.0", 122 | LIBRARY.GTK: "libgtk-3.so.0", 123 | LIBRARY.PANGO: "libpango-1.0.so.0", 124 | LIBRARY.PANGOCAIRO: "libpangocairo-1.0.so.0", 125 | LIBRARY.GLGDK: "libgdkglext-3.0.so.0", 126 | LIBRARY.GLGTK: "libgtkglext-3.0.so.0", 127 | LIBRARY.GDA: "libgda-4.0.so.4", 128 | LIBRARY.GSV: "libgtksourceview-3.0.so.0", 129 | LIBRARY.GSV1: "libgtksourceview-3.0.so.1", 130 | LIBRARY.GSTREAMER: "libgstreamer-1.0.so.0", 131 | LIBRARY.GSTINTERFACES: "libgstvideo-1.0.so.0", 132 | LIBRARY.VTE: "libvte2_90.so", 133 | ]; 134 | } -------------------------------------------------------------------------------- /source/sciter/SciterGraphics.d: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Ramon F. Mendes 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | module sciter.SciterGraphics; 22 | -------------------------------------------------------------------------------- /source/sciter/api.d: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Ramon F. Mendes 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | module sciter.api; 22 | 23 | /*version(Win64) 24 | { 25 | pragma(lib, r"sciter64-import-lib.lib"); 26 | } else { 27 | pragma(lib, r"sciter32-import-lib.lib"); 28 | }*/ 29 | 30 | public import sciter.interop.sciter_x; 31 | public import sciter.types; 32 | import sciter.interop.sciter_x_types; 33 | import sciter.interop.sciter_x_behaviors; 34 | import sciter.interop.tiscript; 35 | 36 | 37 | unittest 38 | { 39 | // from time to time, Sciter changes its ABI; here we test the minimum Sciter version this library is compatible with 40 | uint major = SciterVersion(true); 41 | uint minor = SciterVersion(false); 42 | assert(major==0x00030003); 43 | assert(minor>=0x00000006); 44 | assert(SAPI()._version==0); 45 | } 46 | 47 | 48 | 49 | __gshared ISciterAPI* _SAPI; 50 | 51 | shared static this() 52 | { 53 | version(Windows) 54 | { 55 | _SAPI = SciterAPI(); 56 | } 57 | version(linux) 58 | { 59 | import core.sys.posix.dlfcn; 60 | import core.stdc.stdio; 61 | import core.stdc.stdlib; 62 | 63 | void* lib_sciter_handle = dlopen("./sciter-gtk-64.so", RTLD_LOCAL|RTLD_LAZY);// there is not 32bits .so version in the SDK 64 | if(!lib_sciter_handle) 65 | { 66 | fprintf(stderr, "dlopen error: %s\n", dlerror()); 67 | exit(1); 68 | } 69 | 70 | ISciterAPI* function() sapi = cast(ISciterAPI* function()) dlsym(lib_sciter_handle, "SciterAPI"); 71 | char* error = dlerror(); 72 | if(error) 73 | { 74 | fprintf(stderr, "dlsym error: %s\n", error); 75 | exit(1); 76 | } 77 | 78 | _SAPI = sapi(); 79 | } 80 | } 81 | 82 | ISciterAPI* SAPI() 83 | { 84 | return _SAPI; 85 | } 86 | 87 | 88 | 89 | // defining "official" API functions: 90 | LPCWSTR SciterClassName () { return SAPI().SciterClassName(); } 91 | uint SciterVersion (BOOL major) { return SAPI().SciterVersion (major); } 92 | BOOL SciterDataReady (HWINDOW hwnd,LPCWSTR uri,LPCBYTE data, uint dataLength) { return SAPI().SciterDataReady (hwnd,uri,data,dataLength); } 93 | BOOL SciterDataReadyAsync (HWINDOW hwnd,LPCWSTR uri, LPCBYTE data, uint dataLength, void* requestId) { return SAPI().SciterDataReadyAsync (hwnd,uri, data, dataLength, requestId); } 94 | version(Windows) 95 | { 96 | LRESULT SciterProc (HWINDOW hwnd, uint msg, WPARAM wParam, LPARAM lParam) { return SAPI().SciterProc (hwnd,msg,wParam,lParam); } 97 | LRESULT SciterProcND (HWINDOW hwnd, uint msg, WPARAM wParam, LPARAM lParam, BOOL* pbHandled) { return SAPI().SciterProcND (hwnd,msg,wParam,lParam,pbHandled); } 98 | } 99 | BOOL SciterLoadFile (HWINDOW hWndSciter, LPCWSTR filename) { return SAPI().SciterLoadFile (hWndSciter,filename); } 100 | BOOL SciterLoadHtml (HWINDOW hWndSciter, LPCBYTE html, uint htmlSize, LPCWSTR baseUrl) { return SAPI().SciterLoadHtml (hWndSciter,html,htmlSize,baseUrl); } 101 | void SciterSetCallback (HWINDOW hWndSciter, LPSciterHostCallback cb, void* cbParam) { SAPI().SciterSetCallback (hWndSciter,cb,cbParam); } 102 | BOOL SciterSetMasterCSS (LPCBYTE utf8, uint numBytes) { return SAPI().SciterSetMasterCSS (utf8,numBytes); } 103 | BOOL SciterAppendMasterCSS (LPCBYTE utf8, uint numBytes) { return SAPI().SciterAppendMasterCSS (utf8,numBytes); } 104 | BOOL SciterSetCSS (HWINDOW hWndSciter, LPCBYTE utf8, uint numBytes, LPCWSTR baseUrl, LPCWSTR mediaType) { return SAPI().SciterSetCSS (hWndSciter,utf8,numBytes,baseUrl,mediaType); } 105 | BOOL SciterSetMediaType (HWINDOW hWndSciter, LPCWSTR mediaType) { return SAPI().SciterSetMediaType (hWndSciter,mediaType); } 106 | BOOL SciterSetMediaVars (HWINDOW hWndSciter, const VALUE *mediaVars) { return SAPI().SciterSetMediaVars (hWndSciter,mediaVars); } 107 | uint SciterGetMinWidth (HWINDOW hWndSciter) { return SAPI().SciterGetMinWidth (hWndSciter); } 108 | uint SciterGetMinHeight (HWINDOW hWndSciter, uint width) { return SAPI().SciterGetMinHeight (hWndSciter,width); } 109 | BOOL SciterCall (HWINDOW hWnd, LPCSTR functionName, uint argc, const VALUE* argv, VALUE* retval) { return SAPI().SciterCall (hWnd,functionName, argc,argv,retval); } 110 | BOOL SciterEval (HWINDOW hwnd, LPCWSTR script, uint scriptLength, VALUE* pretval) { return SAPI().SciterEval ( hwnd, script, scriptLength, pretval); } 111 | void SciterUpdateWindow(HWINDOW hwnd) { SAPI().SciterUpdateWindow(hwnd); } 112 | version(Windows) 113 | { 114 | BOOL SciterTranslateMessage (MSG* lpMsg) { return SAPI().SciterTranslateMessage (lpMsg); } 115 | } 116 | BOOL SciterSetOption (HWINDOW hWnd, SCITER_RT_OPTIONS option, UINT_PTR value ) { return SAPI().SciterSetOption (hWnd,option,value ); } 117 | void SciterGetPPI (HWINDOW hWndSciter, uint* px, uint* py) { SAPI().SciterGetPPI (hWndSciter,px,py); } 118 | BOOL SciterGetViewExpando ( HWINDOW hwnd, VALUE* pval ) { return SAPI().SciterGetViewExpando ( hwnd, pval ); } 119 | version(Windows) 120 | { 121 | BOOL SciterRenderD2D (HWINDOW hWndSciter, ID2D1RenderTarget* prt) { return SAPI().SciterRenderD2D (hWndSciter,prt); } 122 | BOOL SciterD2DFactory (ID2D1Factory ** ppf) { return SAPI().SciterD2DFactory (ppf); } 123 | BOOL SciterDWFactory (IDWriteFactory ** ppf) { return SAPI().SciterDWFactory (ppf); } 124 | } 125 | BOOL SciterGraphicsCaps (uint* pcaps) { return SAPI().SciterGraphicsCaps (pcaps); } 126 | BOOL SciterSetHomeURL (HWINDOW hWndSciter, LPCWSTR baseUrl) { return SAPI().SciterSetHomeURL (hWndSciter,baseUrl); } 127 | version(OSX) 128 | { 129 | HWINDOW SciterCreateNSView ( LPRECT frame ) { return SAPI().SciterCreateNSView ( frame ); } 130 | } 131 | HWINDOW SciterCreateWindow( uint creationFlags /*SCITER_CREATE_WINDOW_FLAGS*/, RECT* frame = null, SciterWindowDelegate delegate_ = null, void* delegateParam = null, HWINDOW parent = null) { return SAPI().SciterCreateWindow (creationFlags, frame, delegate_, delegateParam, parent); } 132 | 133 | SCDOM_RESULT Sciter_UseElement(HELEMENT he) { return SAPI().Sciter_UseElement(he); } 134 | SCDOM_RESULT Sciter_UnuseElement(HELEMENT he) { return SAPI().Sciter_UnuseElement(he); } 135 | SCDOM_RESULT SciterGetRootElement(HWINDOW hwnd, HELEMENT *phe) { return SAPI().SciterGetRootElement(hwnd, phe); } 136 | SCDOM_RESULT SciterGetFocusElement(HWINDOW hwnd, HELEMENT *phe) { return SAPI().SciterGetFocusElement(hwnd, phe); } 137 | SCDOM_RESULT SciterFindElement(HWINDOW hwnd, POINT pt, HELEMENT* phe) { return SAPI().SciterFindElement(hwnd,pt,phe); } 138 | SCDOM_RESULT SciterGetChildrenCount(HELEMENT he, uint* count) { return SAPI().SciterGetChildrenCount(he, count); } 139 | SCDOM_RESULT SciterGetNthChild(HELEMENT he, uint n, HELEMENT* phe) { return SAPI().SciterGetNthChild(he,n,phe); } 140 | SCDOM_RESULT SciterGetParentElement(HELEMENT he, HELEMENT* p_parent_he) { return SAPI().SciterGetParentElement(he,p_parent_he); } 141 | SCDOM_RESULT SciterGetElementHtmlCB(HELEMENT he, BOOL outer, LPCBYTE_RECEIVER rcv, void* rcv_param) { return SAPI().SciterGetElementHtmlCB( he, outer, rcv, rcv_param); } 142 | SCDOM_RESULT SciterGetElementTextCB(HELEMENT he, LPCWSTR_RECEIVER rcv, void* rcv_param) { return SAPI().SciterGetElementTextCB(he, rcv, rcv_param); } 143 | SCDOM_RESULT SciterSetElementText(HELEMENT he, LPCWSTR utf16, uint length) { return SAPI().SciterSetElementText(he, utf16, length); } 144 | SCDOM_RESULT SciterGetAttributeCount(HELEMENT he, uint* p_count) { return SAPI().SciterGetAttributeCount(he, p_count); } 145 | SCDOM_RESULT SciterGetNthAttributeNameCB(HELEMENT he, uint n, LPCSTR_RECEIVER rcv, void* rcv_param) { return SAPI().SciterGetNthAttributeNameCB(he,n,rcv,rcv_param); } 146 | SCDOM_RESULT SciterGetNthAttributeValueCB(HELEMENT he, uint n, LPCWSTR_RECEIVER rcv, void* rcv_param) { return SAPI().SciterGetNthAttributeValueCB(he, n, rcv, rcv_param); } 147 | SCDOM_RESULT SciterGetAttributeByNameCB(HELEMENT he, LPCSTR name, LPCWSTR_RECEIVER rcv, void* rcv_param) { return SAPI().SciterGetAttributeByNameCB(he,name,rcv,rcv_param); } 148 | SCDOM_RESULT SciterSetAttributeByName(HELEMENT he, LPCSTR name, LPCWSTR value) { return SAPI().SciterSetAttributeByName(he,name,value); } 149 | SCDOM_RESULT SciterClearAttributes(HELEMENT he) { return SAPI().SciterClearAttributes(he); } 150 | SCDOM_RESULT SciterGetElementIndex(HELEMENT he, uint* p_index) { return SAPI().SciterGetElementIndex(he,p_index); } 151 | SCDOM_RESULT SciterGetElementType(HELEMENT he, LPCSTR* p_type) { return SAPI().SciterGetElementType(he,p_type); } 152 | SCDOM_RESULT SciterGetElementTypeCB(HELEMENT he, LPCSTR_RECEIVER rcv, void* rcv_param) { return SAPI().SciterGetElementTypeCB(he,rcv,rcv_param); } 153 | SCDOM_RESULT SciterGetStyleAttributeCB(HELEMENT he, LPCSTR name, LPCWSTR_RECEIVER rcv, void* rcv_param) { return SAPI().SciterGetStyleAttributeCB(he,name,rcv,rcv_param); } 154 | SCDOM_RESULT SciterSetStyleAttribute(HELEMENT he, LPCSTR name, LPCWSTR value) { return SAPI().SciterSetStyleAttribute(he,name,value); } 155 | SCDOM_RESULT SciterGetElementLocation(HELEMENT he, RECT* p_location, uint areas /*ELEMENT_AREAS*/) { return SAPI().SciterGetElementLocation(he,p_location,areas); } 156 | SCDOM_RESULT SciterScrollToView(HELEMENT he, uint SciterScrollFlags) { return SAPI().SciterScrollToView(he,SciterScrollFlags); } 157 | SCDOM_RESULT SciterUpdateElement(HELEMENT he, BOOL andForceRender) { return SAPI().SciterUpdateElement(he,andForceRender); } 158 | SCDOM_RESULT SciterRefreshElementArea(HELEMENT he, RECT rc) { return SAPI().SciterRefreshElementArea(he,rc); } 159 | SCDOM_RESULT SciterSetCapture(HELEMENT he) { return SAPI().SciterSetCapture(he); } 160 | SCDOM_RESULT SciterReleaseCapture(HELEMENT he) { return SAPI().SciterReleaseCapture(he); } 161 | SCDOM_RESULT SciterGetElementHwnd(HELEMENT he, HWINDOW* p_hwnd, BOOL rootWindow) { return SAPI().SciterGetElementHwnd(he,p_hwnd,rootWindow); } 162 | SCDOM_RESULT SciterCombineURL(HELEMENT he, LPWSTR szUrlBuffer, uint UrlBufferSize) { return SAPI().SciterCombineURL(he,szUrlBuffer,UrlBufferSize); } 163 | SCDOM_RESULT SciterSelectElements(HELEMENT he, LPCSTR CSS_selectors, SciterElementCallback callback, void* param) { return SAPI().SciterSelectElements(he,CSS_selectors,callback,param); } 164 | SCDOM_RESULT SciterSelectElementsW(HELEMENT he, LPCWSTR CSS_selectors, SciterElementCallback callback, void* param) { return SAPI().SciterSelectElementsW(he,CSS_selectors,callback,param); } 165 | SCDOM_RESULT SciterSelectParent(HELEMENT he, LPCSTR selector, uint depth, HELEMENT* heFound) { return SAPI().SciterSelectParent(he,selector,depth,heFound); } 166 | SCDOM_RESULT SciterSelectParentW(HELEMENT he, LPCWSTR selector, uint depth, HELEMENT* heFound) { return SAPI().SciterSelectParentW(he,selector,depth,heFound); } 167 | SCDOM_RESULT SciterSetElementHtml(HELEMENT he, const BYTE* html, uint htmlLength, uint where) { return SAPI().SciterSetElementHtml(he,html,htmlLength,where); } 168 | SCDOM_RESULT SciterGetElementUID(HELEMENT he, uint* puid) { return SAPI().SciterGetElementUID(he,puid); } 169 | SCDOM_RESULT SciterGetElementByUID(HWINDOW hwnd, uint uid, HELEMENT* phe) { return SAPI().SciterGetElementByUID(hwnd,uid,phe); } 170 | SCDOM_RESULT SciterShowPopup(HELEMENT hePopup, HELEMENT heAnchor, uint placement) { return SAPI().SciterShowPopup(hePopup,heAnchor,placement); } 171 | SCDOM_RESULT SciterShowPopupAt(HELEMENT hePopup, POINT pos, BOOL animate) { return SAPI().SciterShowPopupAt(hePopup,pos,animate); } 172 | SCDOM_RESULT SciterHidePopup(HELEMENT he) { return SAPI().SciterHidePopup(he); } 173 | SCDOM_RESULT SciterGetElementState( HELEMENT he, uint* pstateBits) { return SAPI().SciterGetElementState(he,pstateBits); } 174 | SCDOM_RESULT SciterSetElementState( HELEMENT he, uint stateBitsToSet, uint stateBitsToClear, BOOL updateView) { return SAPI().SciterSetElementState(he,stateBitsToSet,stateBitsToClear,updateView); } 175 | SCDOM_RESULT SciterCreateElement( LPCSTR tagname, LPCWSTR textOrNull, /*out*/ HELEMENT *phe ) { return SAPI().SciterCreateElement(tagname,textOrNull,phe ); } 176 | SCDOM_RESULT SciterCloneElement( HELEMENT he, /*out*/ HELEMENT *phe ) { return SAPI().SciterCloneElement(he,phe ); } 177 | SCDOM_RESULT SciterInsertElement( HELEMENT he, HELEMENT hparent, uint index ) { return SAPI().SciterInsertElement(he,hparent,index ); } 178 | SCDOM_RESULT SciterDetachElement( HELEMENT he ) { return SAPI().SciterDetachElement( he ); } 179 | SCDOM_RESULT SciterDeleteElement(HELEMENT he) { return SAPI().SciterDeleteElement(he); } 180 | SCDOM_RESULT SciterSetTimer( HELEMENT he, uint milliseconds, UINT_PTR timer_id ) { return SAPI().SciterSetTimer(he,milliseconds,timer_id ); } 181 | SCDOM_RESULT SciterDetachEventHandler( HELEMENT he, LPELEMENT_EVENT_PROC pep, void* tag ) { return SAPI().SciterDetachEventHandler(he,pep,tag ); } 182 | SCDOM_RESULT SciterAttachEventHandler( HELEMENT he, LPELEMENT_EVENT_PROC pep, void* tag ) { return SAPI().SciterAttachEventHandler( he,pep,tag ); } 183 | SCDOM_RESULT SciterWindowAttachEventHandler( HWINDOW hwndLayout, LPELEMENT_EVENT_PROC pep, void* tag, uint subscription ) { return SAPI().SciterWindowAttachEventHandler(hwndLayout,pep,tag,subscription ); } 184 | SCDOM_RESULT SciterWindowDetachEventHandler( HWINDOW hwndLayout, LPELEMENT_EVENT_PROC pep, void* tag ) { return SAPI().SciterWindowDetachEventHandler(hwndLayout,pep,tag ); } 185 | SCDOM_RESULT SciterSendEvent( HELEMENT he, uint appEventCode, HELEMENT heSource, uint reason, /*out*/ BOOL* handled) { return SAPI().SciterSendEvent( he,appEventCode,heSource,reason,handled); } 186 | SCDOM_RESULT SciterPostEvent( HELEMENT he, uint appEventCode, HELEMENT heSource, uint reason) { return SAPI().SciterPostEvent(he,appEventCode,heSource,reason); } 187 | SCDOM_RESULT SciterFireEvent( const BEHAVIOR_EVENT_PARAMS* evt, BOOL post, BOOL *handled) { return SAPI().SciterFireEvent( evt, post, handled ); } 188 | SCDOM_RESULT SciterCallBehaviorMethod(HELEMENT he, METHOD_PARAMS* params) { return SAPI().SciterCallBehaviorMethod(he,params); } 189 | SCDOM_RESULT SciterRequestElementData( HELEMENT he, LPCWSTR url, uint dataType, HELEMENT initiator ) { return SAPI().SciterRequestElementData(he,url,dataType,initiator ); } 190 | SCDOM_RESULT SciterHttpRequest( HELEMENT he, LPCWSTR url, uint dataType, uint requestType, REQUEST_PARAM* requestParams, uint nParams) { return SAPI().SciterHttpRequest(he,url,dataType,requestType,requestParams,nParams); } 191 | SCDOM_RESULT SciterGetScrollInfo( HELEMENT he, POINT* scrollPos, RECT* viewRect, SIZE* contentSize ) { return SAPI().SciterGetScrollInfo( he,scrollPos,viewRect,contentSize ); } 192 | SCDOM_RESULT SciterSetScrollPos( HELEMENT he, POINT scrollPos, BOOL smooth ) { return SAPI().SciterSetScrollPos( he,scrollPos,smooth ); } 193 | SCDOM_RESULT SciterGetElementIntrinsicWidths( HELEMENT he, int* pMinWidth, int* pMaxWidth ) { return SAPI().SciterGetElementIntrinsicWidths(he,pMinWidth,pMaxWidth ); } 194 | SCDOM_RESULT SciterGetElementIntrinsicHeight( HELEMENT he, int forWidth, int* pHeight ) { return SAPI().SciterGetElementIntrinsicHeight( he,forWidth,pHeight ); } 195 | SCDOM_RESULT SciterIsElementVisible( HELEMENT he, BOOL* pVisible) { return SAPI().SciterIsElementVisible( he,pVisible); } 196 | SCDOM_RESULT SciterIsElementEnabled( HELEMENT he, BOOL* pEnabled ) { return SAPI().SciterIsElementEnabled( he, pEnabled ); } 197 | SCDOM_RESULT SciterSortElements( HELEMENT he, uint firstIndex, uint lastIndex, ELEMENT_COMPARATOR* cmpFunc, void* cmpFuncParam ) { return SAPI().SciterSortElements( he, firstIndex, lastIndex, cmpFunc, cmpFuncParam ); } 198 | SCDOM_RESULT SciterSwapElements( HELEMENT he1, HELEMENT he2 ) { return SAPI().SciterSwapElements( he1,he2 ); } 199 | SCDOM_RESULT SciterTraverseUIEvent( uint evt, void* eventCtlStruct, BOOL* bOutProcessed ) { return SAPI().SciterTraverseUIEvent( evt,eventCtlStruct,bOutProcessed ); } 200 | SCDOM_RESULT SciterCallScriptingMethod( HELEMENT he, LPCSTR name, const VALUE* argv, uint argc, VALUE* retval ) { return SAPI().SciterCallScriptingMethod( he,name,argv,argc,retval ); } 201 | SCDOM_RESULT SciterCallScriptingFunction( HELEMENT he, LPCSTR name, const VALUE* argv, uint argc, VALUE* retval ) { return SAPI().SciterCallScriptingFunction( he,name,argv,argc,retval ); } 202 | SCDOM_RESULT SciterEvalElementScript( HELEMENT he, LPCWSTR script, uint scriptLength, VALUE* retval ) { return SAPI().SciterEvalElementScript( he, script, scriptLength, retval ); } 203 | SCDOM_RESULT SciterAttachHwndToElement(HELEMENT he, HWINDOW hwnd) { return SAPI().SciterAttachHwndToElement(he,hwnd); } 204 | SCDOM_RESULT SciterControlGetType( HELEMENT he, /*CTL_TYPE*/ uint *pType ) { return SAPI().SciterControlGetType( he, pType ); } 205 | SCDOM_RESULT SciterGetValue( HELEMENT he, VALUE* pval ) { return SAPI().SciterGetValue( he,pval ); } 206 | SCDOM_RESULT SciterSetValue( HELEMENT he, const VALUE* pval ) { return SAPI().SciterSetValue( he, pval ); } 207 | SCDOM_RESULT SciterGetExpando( HELEMENT he, VALUE* pval, BOOL forceCreation ) { return SAPI().SciterGetExpando( he, pval, forceCreation ); } 208 | SCDOM_RESULT SciterGetObject( HELEMENT he, tiscript_value* pval, BOOL forceCreation ) { return SAPI().SciterGetObject( he, pval, forceCreation ); } 209 | SCDOM_RESULT SciterGetElementNamespace( HELEMENT he, tiscript_value* pval) { return SAPI().SciterGetElementNamespace( he,pval); } 210 | SCDOM_RESULT SciterGetHighlightedElement(HWINDOW hwnd, HELEMENT* phe) { return SAPI().SciterGetHighlightedElement(hwnd, phe); } 211 | SCDOM_RESULT SciterSetHighlightedElement(HWINDOW hwnd, HELEMENT he) { return SAPI().SciterSetHighlightedElement(hwnd,he); } 212 | SCDOM_RESULT SciterNodeAddRef(HNODE hn) { return SAPI().SciterNodeAddRef(hn); } 213 | SCDOM_RESULT SciterNodeRelease(HNODE hn) { return SAPI().SciterNodeRelease(hn); } 214 | SCDOM_RESULT SciterNodeCastFromElement(HELEMENT he, HNODE* phn) { return SAPI().SciterNodeCastFromElement(he,phn); } 215 | SCDOM_RESULT SciterNodeCastToElement(HNODE hn, HELEMENT* he) { return SAPI().SciterNodeCastToElement(hn,he); } 216 | SCDOM_RESULT SciterNodeFirstChild(HNODE hn, HNODE* phn) { return SAPI().SciterNodeFirstChild(hn,phn); } 217 | SCDOM_RESULT SciterNodeLastChild(HNODE hn, HNODE* phn) { return SAPI().SciterNodeLastChild(hn, phn); } 218 | SCDOM_RESULT SciterNodeNextSibling(HNODE hn, HNODE* phn) { return SAPI().SciterNodeNextSibling(hn, phn); } 219 | SCDOM_RESULT SciterNodePrevSibling(HNODE hn, HNODE* phn) { return SAPI().SciterNodePrevSibling(hn,phn); } 220 | SCDOM_RESULT SciterNodeParent(HNODE hnode, HELEMENT* pheParent) { return SAPI().SciterNodeParent(hnode,pheParent) ; } 221 | SCDOM_RESULT SciterNodeNthChild(HNODE hnode, uint n, HNODE* phn) { return SAPI().SciterNodeNthChild(hnode,n,phn); } 222 | SCDOM_RESULT SciterNodeChildrenCount(HNODE hnode, uint* pn) { return SAPI().SciterNodeChildrenCount(hnode, pn); } 223 | SCDOM_RESULT SciterNodeType(HNODE hnode, uint* pNodeType /*NODE_TYPE*/) { return SAPI().SciterNodeType(hnode,pNodeType); } 224 | SCDOM_RESULT SciterNodeGetText(HNODE hnode, LPCWSTR_RECEIVER rcv, void* rcv_param) { return SAPI().SciterNodeGetText(hnode,rcv,rcv_param); } 225 | SCDOM_RESULT SciterNodeSetText(HNODE hnode, LPCWSTR text, uint textLength) { return SAPI().SciterNodeSetText(hnode,text,textLength); } 226 | SCDOM_RESULT SciterNodeInsert(HNODE hnode, uint where /*NODE_INS_TARGET*/, HNODE what) { return SAPI().SciterNodeInsert(hnode,where,what); } 227 | SCDOM_RESULT SciterNodeRemove(HNODE hnode, BOOL finalize) { return SAPI().SciterNodeRemove(hnode,finalize); } 228 | SCDOM_RESULT SciterCreateTextNode(LPCWSTR text, uint textLength, HNODE* phnode) { return SAPI().SciterCreateTextNode(text,textLength,phnode); } 229 | SCDOM_RESULT SciterCreateCommentNode(LPCWSTR text, uint textLength, HNODE* phnode) { return SAPI().SciterCreateCommentNode(text,textLength,phnode); } 230 | 231 | HVM SciterGetVM( HWINDOW hwnd ) { return SAPI().SciterGetVM(hwnd); } 232 | 233 | uint ValueInit ( VALUE* pval ) { return SAPI().ValueInit(pval); } 234 | uint ValueClear ( VALUE* pval ) { return SAPI().ValueClear(pval); } 235 | uint ValueCompare ( const VALUE* pval1, const VALUE* pval2 ) { return SAPI().ValueCompare(pval1,pval2); } 236 | uint ValueCopy ( VALUE* pdst, const VALUE* psrc ) { return SAPI().ValueCopy(pdst, psrc); } 237 | uint ValueIsolate ( VALUE* pdst ) { return SAPI().ValueIsolate(pdst); } 238 | uint ValueType ( const VALUE* pval, uint* pType, uint* pUnits ) { return SAPI().ValueType(pval,pType,pUnits); } 239 | uint ValueStringData ( const VALUE* pval, LPCWSTR* pChars, uint* pNumChars ) { return SAPI().ValueStringData(pval,pChars,pNumChars); } 240 | uint ValueStringDataSet ( VALUE* pval, LPCWSTR chars, uint numChars, uint units ) { return SAPI().ValueStringDataSet(pval, chars, numChars, units); } 241 | uint ValueIntData ( const VALUE* pval, int* pData ) { return SAPI().ValueIntData ( pval, pData ); } 242 | uint ValueIntDataSet ( VALUE* pval, int data, uint type, uint units ) { return SAPI().ValueIntDataSet ( pval, data,type,units ); } 243 | uint ValueInt64Data ( const VALUE* pval, long* pData ) { return SAPI().ValueInt64Data ( pval,pData ); } 244 | uint ValueInt64DataSet ( VALUE* pval, long data, uint type, uint units ) { return SAPI().ValueInt64DataSet ( pval,data,type,units ); } 245 | uint ValueFloatData ( const VALUE* pval, FLOAT_VALUE* pData ) { return SAPI().ValueFloatData ( pval,pData ); } 246 | uint ValueFloatDataSet ( VALUE* pval, FLOAT_VALUE data, uint type, uint units ) { return SAPI().ValueFloatDataSet ( pval,data,type,units ); } 247 | uint ValueBinaryData ( const VALUE* pval, LPCBYTE* pBytes, uint* pnBytes ) { return SAPI().ValueBinaryData ( pval,pBytes,pnBytes ); } 248 | uint ValueBinaryDataSet ( VALUE* pval, LPCBYTE pBytes, uint nBytes, uint type, uint units ) { return SAPI().ValueBinaryDataSet ( pval,pBytes,nBytes,type,units ); } 249 | uint ValueElementsCount ( const VALUE* pval, int* pn) { return SAPI().ValueElementsCount ( pval,pn); } 250 | uint ValueNthElementValue ( const VALUE* pval, int n, VALUE* pretval) { return SAPI().ValueNthElementValue ( pval, n, pretval); } 251 | uint ValueNthElementValueSet ( VALUE* pval, int n, const VALUE* pval_to_set) { return SAPI().ValueNthElementValueSet ( pval,n,pval_to_set); } 252 | uint ValueNthElementKey ( const VALUE* pval, int n, VALUE* pretval) { return SAPI().ValueNthElementKey ( pval,n,pretval); } 253 | uint ValueEnumElements ( VALUE* pval, KeyValueCallback* penum, void* param) { return SAPI().ValueEnumElements (pval,penum,param); } 254 | uint ValueSetValueToKey ( VALUE* pval, const VALUE* pkey, const VALUE* pval_to_set) { return SAPI().ValueSetValueToKey ( pval, pkey, pval_to_set); } 255 | uint ValueGetValueOfKey ( const VALUE* pval, const VALUE* pkey, VALUE* pretval) { return SAPI().ValueGetValueOfKey ( pval, pkey,pretval); } 256 | uint ValueToString ( VALUE* pval, uint how ) { return SAPI().ValueToString ( pval,how ); } 257 | uint ValueFromString ( VALUE* pval, LPCWSTR str, uint strLength, uint how ) { return SAPI().ValueFromString ( pval, str,strLength,how ); } 258 | uint ValueInvoke ( const VALUE* pval, const VALUE* pthis, uint argc, const VALUE* argv, VALUE* pretval, LPCWSTR url) { return SAPI().ValueInvoke ( pval, pthis, argc, argv, pretval, url); } 259 | uint ValueNativeFunctorSet ( VALUE* pval, NATIVE_FUNCTOR_INVOKE* pinvoke, NATIVE_FUNCTOR_RELEASE* prelease, void* tag) { return SAPI().ValueNativeFunctorSet (pval, pinvoke, prelease, tag); } 260 | BOOL ValueIsNativeFunctor ( const VALUE* pval) { return SAPI().ValueIsNativeFunctor (pval); } 261 | 262 | // conversion between script (managed) value and the VALUE ( com::variant alike thing ) 263 | BOOL Sciter_v2V(HVM vm, const tiscript_value script_value, VALUE* out_value, BOOL isolate) { return SAPI().Sciter_v2V(vm,script_value,out_value, isolate); } 264 | BOOL Sciter_V2v(HVM vm, const VALUE* value, tiscript_value* out_script_value) { return SAPI().Sciter_V2v(vm,value,out_script_value); } 265 | 266 | UINT_PTR SciterPostCallback(HWINDOW hwnd, UINT_PTR wparam, UINT_PTR lparam, uint timeoutms) { return SAPI().SciterPostCallback(hwnd, wparam, lparam, timeoutms); } 267 | -------------------------------------------------------------------------------- /source/sciter/behavior.d: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Ramon F. Mendes 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | module sciter.behavior; 22 | 23 | import sciter.interop.sciter_x; 24 | import sciter.interop.sciter_x_types; 25 | import sciter.interop.tiscript; 26 | public import sciter.interop.sciter_x_behaviors; 27 | public import sciter.types; 28 | 29 | 30 | abstract class EventHandler 31 | { 32 | debug 33 | { 34 | static bool terminating; 35 | static ~this() { terminating = true; } 36 | ~this() 37 | { 38 | assert(is_attached==false || terminating==true, "Destroying an EventHandler which is attached!"); 39 | } 40 | 41 | private bool is_attached; 42 | void attached(HELEMENT) { is_attached = true; } 43 | void detached(HELEMENT) { is_attached = false; } 44 | } else { 45 | void attached(HELEMENT) { } 46 | void detached(HELEMENT) { } 47 | } 48 | 49 | bool subscription(HELEMENT he, ref uint event_groups) 50 | { 51 | event_groups = EVENT_GROUPS.HANDLE_ALL; 52 | return true; 53 | } 54 | 55 | bool on_mouse (HELEMENT he, MOUSE_PARAMS* prms ) { return false; } 56 | bool on_key (HELEMENT he, KEY_PARAMS* prms ) { return false; } 57 | bool on_focus (HELEMENT he, FOCUS_PARAMS* prms ) { return false; } 58 | bool on_draw (HELEMENT he, DRAW_PARAMS* prms ) { return false; /*do default draw*/ } 59 | 60 | bool on_timer (HELEMENT he ) { return false; /*stop this timer*/ } 61 | bool on_timer (HELEMENT he, UINT_PTR extTimerId ) { return false; /*stop this timer*/ } 62 | void on_size (HELEMENT he ) { } 63 | 64 | bool on_method_call (HELEMENT he, uint methodID) { return false; /*not handled*/ } 65 | 66 | // calls from CSSS! script and TIScript (if it was not handled by method below). Override this if you want your own methods to the CSSS! namespace. 67 | // Follwing declaration: 68 | // #my-active-on { 69 | // when-click: r = self.my-method(1,"one"); 70 | // } 71 | // will end up with on_script_call(he, "my-method" , 2, argv, retval ); 72 | // where argv[0] will be 1 and argv[1] will be "one". 73 | bool on_script_call(HELEMENT he, SCRIPTING_METHOD_PARAMS* prms) { return false; } 74 | 75 | // Calls from TIScript. Override this if you want your own methods accessible directly from tiscript engine. 76 | // Use tiscript::args to access parameters. 77 | bool on_script_call(HELEMENT he, TISCRIPT_METHOD_PARAMS* prms) { return false; } 78 | 79 | // notification events from builtin behaviors - synthesized events: BUTTON_CLICK, VALUE_CHANGED 80 | // see enum BEHAVIOR_EVENTS 81 | bool on_event(HELEMENT he, BEHAVIOR_EVENT_PARAMS* prms) { return false; } 82 | 83 | // notification event: data requested by HTMLayoutRequestData just delivered 84 | bool on_data_arrived (HELEMENT he, DATA_ARRIVED_PARAMS* prms) { return false; } 85 | 86 | bool on_scroll(HELEMENT he, SCROLL_PARAMS* prms) { return false; } 87 | 88 | bool on_gesture(HELEMENT he, GESTURE_PARAMS* prms ) { return false; } 89 | 90 | extern(Windows) static BOOL element_proc(void* tag, HELEMENT he, uint evtg, void* prms) 91 | { 92 | EventHandler evh = cast(EventHandler)tag; 93 | 94 | /*debug 95 | { 96 | static i = 0; 97 | import std.stdio; 98 | stderr.writeln("element_proc ", i++); 99 | }*/ 100 | 101 | switch( cast(EVENT_GROUPS)evtg ) 102 | { 103 | case EVENT_GROUPS.SUBSCRIPTIONS_REQUEST: 104 | { 105 | uint* p = cast(uint*) prms; 106 | return evh.subscription( he, *p ); 107 | } 108 | 109 | case EVENT_GROUPS.HANDLE_INITIALIZATION: 110 | { 111 | INITIALIZATION_PARAMS* p = cast(INITIALIZATION_PARAMS*)prms; 112 | if(p.cmd == INITIALIZATION_EVENTS.BEHAVIOR_DETACH) 113 | evh.detached(he); 114 | else if(p.cmd == INITIALIZATION_EVENTS.BEHAVIOR_ATTACH) 115 | evh.attached(he); 116 | return true; 117 | } 118 | 119 | case EVENT_GROUPS.HANDLE_MOUSE: { MOUSE_PARAMS* p = cast(MOUSE_PARAMS*)prms; return evh.on_mouse( he, p ); } 120 | case EVENT_GROUPS.HANDLE_KEY: { KEY_PARAMS* p = cast(KEY_PARAMS*)prms; return evh.on_key( he, p ); } 121 | case EVENT_GROUPS.HANDLE_FOCUS: { FOCUS_PARAMS* p = cast(FOCUS_PARAMS*)prms; return evh.on_focus( he, p ); } 122 | case EVENT_GROUPS.HANDLE_DRAW: { DRAW_PARAMS* p = cast(DRAW_PARAMS*)prms; return evh.on_draw( he, p ); } 123 | case EVENT_GROUPS.HANDLE_TIMER: 124 | { 125 | TIMER_PARAMS* p = cast(TIMER_PARAMS*)prms; 126 | if(p.timerId) 127 | return evh.on_timer( he, p.timerId ); 128 | return evh.on_timer( he ); 129 | } 130 | 131 | case EVENT_GROUPS.HANDLE_BEHAVIOR_EVENT: { BEHAVIOR_EVENT_PARAMS* p = cast(BEHAVIOR_EVENT_PARAMS*)prms; return evh.on_event(he, p); } 132 | case EVENT_GROUPS.HANDLE_METHOD_CALL: { METHOD_PARAMS* p = cast(METHOD_PARAMS*)prms; return evh.on_method_call(he, p.methodID); } 133 | case EVENT_GROUPS.HANDLE_DATA_ARRIVED: { DATA_ARRIVED_PARAMS* p = cast(DATA_ARRIVED_PARAMS*)prms; return evh.on_data_arrived(he, p); } 134 | case EVENT_GROUPS.HANDLE_SCROLL: { SCROLL_PARAMS* p = cast(SCROLL_PARAMS*)prms; return evh.on_scroll(he, p); } 135 | case EVENT_GROUPS.HANDLE_SIZE: { evh.on_size(he); return false; } 136 | 137 | // call using json::value's (from CSSS!) 138 | case EVENT_GROUPS.HANDLE_SCRIPTING_METHOD_CALL: { SCRIPTING_METHOD_PARAMS* p = cast(SCRIPTING_METHOD_PARAMS*)prms; return evh.on_script_call(he, p); } 139 | // call using tiscript::value's (from the script) 140 | case EVENT_GROUPS.HANDLE_TISCRIPT_METHOD_CALL: { TISCRIPT_METHOD_PARAMS* p = cast(TISCRIPT_METHOD_PARAMS*)prms; return evh.on_script_call(he, p); } 141 | 142 | case EVENT_GROUPS.HANDLE_GESTURE: { GESTURE_PARAMS* p = cast(GESTURE_PARAMS*)prms; return evh.on_gesture(he, p); } 143 | 144 | default: assert(false); 145 | } 146 | //return TRUE; 147 | } 148 | } -------------------------------------------------------------------------------- /source/sciter/behaviors/behavior_tabs.d: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Ramon F. Mendes 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | module sciter.behaviors.behavior_tabs; 22 | 23 | 24 | import sciter.behavior; 25 | 26 | -------------------------------------------------------------------------------- /source/sciter/dbg.d: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Ramon F. Mendes 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | // port of 'sciter-x-debug.h' 22 | module sciter.dbg; 23 | 24 | public import sciter.interop.sciter_x; 25 | import sciter.interop.sciter_x_types; 26 | import sciter.api; 27 | 28 | 29 | void SciterSetupDebugOutput ( HWINDOW hwndOrNull, void* param, DEBUG_OUTPUT_PROC pfOutput) { return SAPI().SciterSetupDebugOutput(hwndOrNull,param,pfOutput); } 30 | 31 | 32 | abstract class debug_output 33 | { 34 | public this(HWINDOW hwnd = HWINDOW.init) 35 | { 36 | SciterSetupDebugOutput(hwnd, cast(void*) this, &_output_debug); 37 | } 38 | 39 | public void setup(HWINDOW hwnd = HWINDOW.init) 40 | { 41 | SciterSetupDebugOutput(hwnd, cast(void*) this, &_output_debug); 42 | } 43 | 44 | abstract void output(OUTPUT_SUBSYTEM subsystem, OUTPUT_SEVERITY severity, wstring text); 45 | 46 | extern(Windows) static void _output_debug(void* param, uint subsystem, uint severity, LPCWSTR text, uint text_length) 47 | { 48 | debug_output _this = cast(debug_output) param; 49 | _this.output(cast(OUTPUT_SUBSYTEM) subsystem, cast(OUTPUT_SEVERITY) severity, text[0..text_length].idup); 50 | } 51 | } 52 | 53 | version(Windows) 54 | { 55 | class debug_output_console : debug_output 56 | { 57 | import winkit.WinAPI; 58 | 59 | private HANDLE m_trace_out; 60 | 61 | override void output(OUTPUT_SUBSYTEM subsystem, OUTPUT_SEVERITY severity, wstring text) 62 | { 63 | import std.conv; 64 | 65 | if(!m_trace_out) 66 | { 67 | AllocConsole(); 68 | m_trace_out = GetStdHandle(STD_OUTPUT_HANDLE); 69 | } 70 | 71 | assert(m_trace_out); 72 | 73 | string msg = to!string(text); // ~ "\n"; 74 | DWORD written; 75 | WriteFile(m_trace_out, msg.ptr, msg.length, &written, null); 76 | } 77 | } 78 | } -------------------------------------------------------------------------------- /source/sciter/host.d: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Ramon F. Mendes 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | module sciter.host; 22 | 23 | import sciter.interop.sciter_x_types; 24 | import sciter.api; 25 | import sciter.behavior; 26 | import sciter.sciter_value; 27 | 28 | 29 | class SciterArchive 30 | { 31 | unittest 32 | { 33 | ubyte[] resources = [// contains a single file 'test.txt' with its content == 'I see dead people' 34 | 0x53,0x41,0x72,0x00,0x09,0x00,0x00,0x00,0x74,0x00,0xff,0xff,0x01,0x00,0xff,0xff,0x65,0x00,0xff,0xff,0x02,0x00,0xff,0xff,0x73,0x00,0xff,0xff,0x03,0x00,0xff,0xff,0x74,0x00,0xff,0xff,0x04,0x00,0xff,0xff,0x2e, 35 | 0x00,0xff,0xff,0x05,0x00,0xff,0xff,0x74,0x00,0xff,0xff,0x06,0x00,0xff,0xff,0x78,0x00,0xff,0xff,0x07,0x00,0xff,0xff,0x74,0x00,0xff,0xff,0x08,0x00,0xff,0xff,0x00,0x00,0xff,0xff,0x01,0x00,0xff,0xff,0x01,0x00, 36 | 0x00,0x00,0x60,0x00,0x00,0x00,0x11,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x49,0x20,0x73,0x65,0x65,0x20,0x64,0x65,0x61,0x64,0x20,0x70,0x65,0x6f,0x70,0x6c,0x65, ]; 37 | 38 | SciterArchive arch = new SciterArchive; 39 | arch.open(resources); 40 | 41 | auto file_buff = arch.get("test.txt"); 42 | string file_str = cast(string)(file_buff); 43 | assert(file_str=="I see dead people"); 44 | } 45 | 46 | private: 47 | HSARCHIVE har; 48 | 49 | public: 50 | // open archive blob: 51 | void open(const(ubyte)[] data) 52 | { 53 | close(); 54 | har = SAPI().SciterOpenArchive(data.ptr, cast(uint/*x64 issue*/) data.length); 55 | assert(har); 56 | } 57 | 58 | void close() 59 | { 60 | if(har) 61 | SAPI().SciterCloseArchive(har); 62 | har = 0; 63 | } 64 | 65 | // get archive item: 66 | const(ubyte)[] get(wstring path) 67 | { 68 | assert(har); 69 | LPCBYTE pb; 70 | uint blen; 71 | 72 | path ~= '\0'; 73 | bool found = !!SAPI().SciterGetArchiveItem(har, path.ptr, &pb, &blen); 74 | //debug assert(found); 75 | 76 | if(found==false) 77 | return null; 78 | return pb[0..blen]; 79 | } 80 | } 81 | 82 | abstract class SciterWindowHost 83 | { 84 | void setup_callback(HWINDOW hwnd) 85 | { 86 | assert(hwnd); 87 | assert(m_hwnd==HWINDOW.init, "You already called setup_callback()"); 88 | m_hwnd = hwnd; 89 | .SciterSetCallback(hwnd, &callback, cast(void*)this); 90 | } 91 | 92 | void attach_evh(EventHandler evh) 93 | { 94 | assert(m_hwnd, "Call setup_callback() first"); 95 | .SciterWindowAttachEventHandler(m_hwnd, &EventHandler.element_proc, cast(void*) evh, EVENT_GROUPS.HANDLE_ALL) == SCDOM_OK || assert(false); 96 | } 97 | 98 | json_value call_function(string name, VALUE[] params...) 99 | { 100 | assert(m_hwnd, "Call setup_callback() first"); 101 | 102 | VALUE ret; 103 | .SciterCall(m_hwnd, (name ~ '\0').ptr, cast(uint/*x64 issue*/) params.length, params.ptr, &ret) || assert(false); 104 | return json_value(ret); 105 | } 106 | 107 | json_value eval_script(wstring script) 108 | { 109 | assert(m_hwnd, "Call setup_callback() first"); 110 | 111 | VALUE ret; 112 | .SciterEval(m_hwnd, script.ptr, cast(uint/*x64 issue*/) script.length, &ret) || assert(false); 113 | return json_value(ret); 114 | } 115 | 116 | public: 117 | // overridable 118 | uint on_load_data(LPSCN_LOAD_DATA pnmld) { return 0; } 119 | uint on_data_loaded(LPSCN_DATA_LOADED pnmld) { return 0; } 120 | uint on_attach_behavior(LPSCN_ATTACH_BEHAVIOR lpab) { return 0; } 121 | uint on_engine_destroyed() { return 0; } 122 | uint on_posted_notification(LPSCN_POSTED_NOTIFICATION lpab) { return 0; } 123 | 124 | protected: 125 | HWINDOW m_hwnd; 126 | 127 | static extern(Windows) uint callback(LPSCITER_CALLBACK_NOTIFICATION pnm, void* param) 128 | { 129 | assert(param); 130 | SciterWindowHost self = cast(SciterWindowHost)(param); 131 | return self.handle_notification(pnm); 132 | } 133 | 134 | uint handle_notification(LPSCITER_CALLBACK_NOTIFICATION pnm) 135 | { 136 | switch(pnm.code) 137 | { 138 | case SC_LOAD_DATA: return this.on_load_data(cast(LPSCN_LOAD_DATA) pnm); 139 | case SC_DATA_LOADED: return this.on_data_loaded(cast(LPSCN_DATA_LOADED)pnm); 140 | case SC_ATTACH_BEHAVIOR: return this.on_attach_behavior(cast(LPSCN_ATTACH_BEHAVIOR)pnm); 141 | case SC_ENGINE_DESTROYED: return this.on_engine_destroyed(); 142 | case SC_POSTED_NOTIFICATION: return this.on_posted_notification(cast(LPSCN_POSTED_NOTIFICATION)pnm); 143 | default: 144 | } 145 | return 0; 146 | } 147 | } -------------------------------------------------------------------------------- /source/sciter/interop/sciter_x.d: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Ramon F. Mendes 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | module sciter.interop.sciter_x; 22 | 23 | public import sciter.interop.sciter_x_def; 24 | public import sciter.interop.sciter_x_api; -------------------------------------------------------------------------------- /source/sciter/interop/sciter_x_api.d: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Ramon F. Mendes 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | module sciter.interop.sciter_x_api; 22 | 23 | import sciter.interop.sciter_x_types; 24 | import sciter.interop.sciter_x_def; 25 | import sciter.interop.sciter_x_behaviors; 26 | import sciter.interop.tiscript; 27 | 28 | extern(Windows) 29 | { 30 | ISciterAPI* SciterAPI(); 31 | 32 | struct ISciterAPI 33 | { 34 | uint _version; 35 | 36 | LPCWSTR function() SciterClassName; 37 | uint function(BOOL major) SciterVersion; 38 | BOOL function(HWINDOW hwnd, LPCWSTR uri, LPCBYTE data, uint dataLength) SciterDataReady; 39 | BOOL function(HWINDOW hwnd, LPCWSTR uri, LPCBYTE data, uint dataLength, void* requestId) SciterDataReadyAsync; 40 | version(Windows) 41 | { 42 | LRESULT function(HWINDOW hwnd, uint msg, WPARAM wParam, LPARAM lParam) SciterProc; 43 | LRESULT function(HWINDOW hwnd, uint msg, WPARAM wParam, LPARAM lParam, BOOL* pbHandled) SciterProcND; 44 | } 45 | BOOL function(HWINDOW hWndSciter, LPCWSTR filename) SciterLoadFile; 46 | BOOL function(HWINDOW hWndSciter, LPCBYTE html, uint htmlSize, LPCWSTR baseUrl) SciterLoadHtml; 47 | void function(HWINDOW hWndSciter, LPSciterHostCallback cb, void* cbParam) SciterSetCallback; 48 | BOOL function(LPCBYTE utf8, uint numBytes) SciterSetMasterCSS; 49 | BOOL function(LPCBYTE utf8, uint numBytes) SciterAppendMasterCSS; 50 | BOOL function(HWINDOW hWndSciter, LPCBYTE utf8, uint numBytes, LPCWSTR baseUrl, LPCWSTR mediaType) SciterSetCSS; 51 | BOOL function(HWINDOW hWndSciter, LPCWSTR mediaType) SciterSetMediaType; 52 | BOOL function(HWINDOW hWndSciter, const VALUE* mediaVars) SciterSetMediaVars; 53 | uint function(HWINDOW hWndSciter) SciterGetMinWidth; 54 | uint function(HWINDOW hWndSciter, uint width) SciterGetMinHeight; 55 | BOOL function(HWINDOW hWnd, LPCSTR functionName, uint argc, const VALUE* argv, VALUE* retval) SciterCall; 56 | BOOL function(HWINDOW hwnd, LPCWSTR script, uint scriptLength, VALUE* pretval) SciterEval; 57 | void function(HWINDOW hwnd) SciterUpdateWindow; 58 | version(Windows) 59 | BOOL function(MSG* lpMsg) SciterTranslateMessage; 60 | BOOL function(HWINDOW hWnd, uint option, UINT_PTR value ) SciterSetOption; 61 | void function(HWINDOW hWndSciter, uint* px, uint* py) SciterGetPPI; 62 | BOOL function(HWINDOW hwnd, VALUE* pval ) SciterGetViewExpando; 63 | version(Windows) 64 | { 65 | BOOL function(HWINDOW hWndSciter, ID2D1RenderTarget* prt) SciterRenderD2D; 66 | BOOL function(ID2D1Factory ** ppf) SciterD2DFactory; 67 | BOOL function(IDWriteFactory ** ppf) SciterDWFactory; 68 | } 69 | BOOL function(uint* pcaps) SciterGraphicsCaps; 70 | BOOL function(HWINDOW hWndSciter, LPCWSTR baseUrl) SciterSetHomeURL; 71 | version(OSX) 72 | HWINDOW function( LPRECT frame ) SciterCreateNSView;// returns NSView* 73 | HWINDOW function(uint creationFlags, RECT* frame, SciterWindowDelegate delegt, void* delegateParam, HWINDOW parent) SciterCreateWindow; 74 | void function( 75 | HWINDOW hwndOrNull,// HWINDOW or null if this is global output handler 76 | void* param, // param to be passed "as is" to the pfOutput 77 | DEBUG_OUTPUT_PROC pfOutput // output function, output stream alike thing. 78 | ) SciterSetupDebugOutput; 79 | 80 | //| 81 | //| DOM Element API 82 | //| 83 | SCDOM_RESULT function(HELEMENT he) Sciter_UseElement; 84 | SCDOM_RESULT function(HELEMENT he) Sciter_UnuseElement; 85 | SCDOM_RESULT function(HWINDOW hwnd, HELEMENT *phe) SciterGetRootElement; 86 | SCDOM_RESULT function(HWINDOW hwnd, HELEMENT *phe) SciterGetFocusElement; 87 | SCDOM_RESULT function(HWINDOW hwnd, POINT pt, HELEMENT* phe) SciterFindElement; 88 | SCDOM_RESULT function(HELEMENT he, uint* count) SciterGetChildrenCount; 89 | SCDOM_RESULT function(HELEMENT he, uint n, HELEMENT* phe) SciterGetNthChild; 90 | SCDOM_RESULT function(HELEMENT he, HELEMENT* p_parent_he) SciterGetParentElement; 91 | SCDOM_RESULT function(HELEMENT he, BOOL outer, LPCBYTE_RECEIVER rcv, void* rcv_param) SciterGetElementHtmlCB; 92 | SCDOM_RESULT function(HELEMENT he, LPCWSTR_RECEIVER rcv, void* rcv_param) SciterGetElementTextCB; 93 | SCDOM_RESULT function(HELEMENT he, LPCWSTR utf16, uint length) SciterSetElementText; 94 | SCDOM_RESULT function(HELEMENT he, uint* p_count) SciterGetAttributeCount; 95 | SCDOM_RESULT function(HELEMENT he, uint n, LPCSTR_RECEIVER rcv, void* rcv_param) SciterGetNthAttributeNameCB; 96 | SCDOM_RESULT function(HELEMENT he, uint n, LPCWSTR_RECEIVER rcv, void* rcv_param) SciterGetNthAttributeValueCB; 97 | SCDOM_RESULT function(HELEMENT he, LPCSTR name, LPCWSTR_RECEIVER rcv, void* rcv_param) SciterGetAttributeByNameCB; 98 | SCDOM_RESULT function(HELEMENT he, LPCSTR name, LPCWSTR value) SciterSetAttributeByName; 99 | SCDOM_RESULT function(HELEMENT he) SciterClearAttributes; 100 | SCDOM_RESULT function(HELEMENT he, uint* p_index) SciterGetElementIndex; 101 | SCDOM_RESULT function(HELEMENT he, LPCSTR* p_type) SciterGetElementType; 102 | SCDOM_RESULT function(HELEMENT he, LPCSTR_RECEIVER rcv, void* rcv_param) SciterGetElementTypeCB; 103 | SCDOM_RESULT function(HELEMENT he, LPCSTR name, LPCWSTR_RECEIVER rcv, void* rcv_param) SciterGetStyleAttributeCB; 104 | SCDOM_RESULT function(HELEMENT he, LPCSTR name, LPCWSTR value) SciterSetStyleAttribute; 105 | SCDOM_RESULT function(HELEMENT he, RECT* p_location, uint areas /*ELEMENT_AREAS*/) SciterGetElementLocation; 106 | SCDOM_RESULT function(HELEMENT he, uint SciterScrollFlags) SciterScrollToView; 107 | SCDOM_RESULT function(HELEMENT he, BOOL andForceRender) SciterUpdateElement; 108 | SCDOM_RESULT function(HELEMENT he, RECT rc) SciterRefreshElementArea; 109 | SCDOM_RESULT function(HELEMENT he) SciterSetCapture; 110 | SCDOM_RESULT function(HELEMENT he) SciterReleaseCapture; 111 | SCDOM_RESULT function(HELEMENT he, HWINDOW* p_hwnd, BOOL rootWindow) SciterGetElementHwnd; 112 | SCDOM_RESULT function(HELEMENT he, LPWSTR szUrlBuffer, uint UrlBufferSize) SciterCombineURL; 113 | SCDOM_RESULT function(HELEMENT he, LPCSTR CSS_selectors, SciterElementCallback callback, void* param) SciterSelectElements; 114 | SCDOM_RESULT function(HELEMENT he, LPCWSTR CSS_selectors, SciterElementCallback callback, void* param) SciterSelectElementsW; 115 | SCDOM_RESULT function(HELEMENT he, LPCSTR selector, uint depth, HELEMENT* heFound) SciterSelectParent; 116 | SCDOM_RESULT function(HELEMENT he, LPCWSTR selector, uint depth, HELEMENT* heFound) SciterSelectParentW; 117 | SCDOM_RESULT function(HELEMENT he, const BYTE* html, uint htmlLength, uint where) SciterSetElementHtml; 118 | SCDOM_RESULT function(HELEMENT he, uint* puid) SciterGetElementUID; 119 | SCDOM_RESULT function(HWINDOW hwnd, uint uid, HELEMENT* phe) SciterGetElementByUID; 120 | SCDOM_RESULT function(HELEMENT hePopup, HELEMENT heAnchor, uint placement) SciterShowPopup; 121 | SCDOM_RESULT function(HELEMENT hePopup, POINT pos, BOOL animate) SciterShowPopupAt; 122 | SCDOM_RESULT function(HELEMENT he) SciterHidePopup; 123 | SCDOM_RESULT function( HELEMENT he, uint* pstateBits) SciterGetElementState; 124 | SCDOM_RESULT function( HELEMENT he, uint stateBitsToSet, uint stateBitsToClear, BOOL updateView) SciterSetElementState; 125 | SCDOM_RESULT function( LPCSTR tagname, LPCWSTR textOrNull, /*out*/ HELEMENT *phe ) SciterCreateElement; 126 | SCDOM_RESULT function( HELEMENT he, /*out*/ HELEMENT *phe ) SciterCloneElement; 127 | SCDOM_RESULT function( HELEMENT he, HELEMENT hparent, uint index ) SciterInsertElement; 128 | SCDOM_RESULT function( HELEMENT he ) SciterDetachElement; 129 | SCDOM_RESULT function(HELEMENT he) SciterDeleteElement; 130 | SCDOM_RESULT function( HELEMENT he, uint milliseconds, UINT_PTR timer_id ) SciterSetTimer; 131 | SCDOM_RESULT function( HELEMENT he, LPELEMENT_EVENT_PROC pep, void* tag ) SciterDetachEventHandler; 132 | SCDOM_RESULT function( HELEMENT he, LPELEMENT_EVENT_PROC pep, void* tag ) SciterAttachEventHandler; 133 | SCDOM_RESULT function( HWINDOW hwndLayout, LPELEMENT_EVENT_PROC pep, void* tag, uint subscription ) SciterWindowAttachEventHandler; 134 | SCDOM_RESULT function( HWINDOW hwndLayout, LPELEMENT_EVENT_PROC pep, void* tag ) SciterWindowDetachEventHandler; 135 | SCDOM_RESULT function( HELEMENT he, uint appEventCode, HELEMENT heSource, UINT_PTR reason, /*out*/ BOOL* handled) SciterSendEvent; 136 | SCDOM_RESULT function( HELEMENT he, uint appEventCode, HELEMENT heSource, UINT_PTR reason) SciterPostEvent; 137 | SCDOM_RESULT function(HELEMENT he, METHOD_PARAMS* params) SciterCallBehaviorMethod; 138 | SCDOM_RESULT function( HELEMENT he, LPCWSTR url, uint dataType, HELEMENT initiator ) SciterRequestElementData; 139 | SCDOM_RESULT function( HELEMENT he, // element to deliver data 140 | LPCWSTR url, // url 141 | uint dataType, // data type, see SciterResourceType. 142 | uint requestType, // one of REQUEST_TYPE values 143 | REQUEST_PARAM* requestParams, // parameters 144 | uint nParams // number of parameters 145 | ) SciterHttpRequest; 146 | SCDOM_RESULT function( HELEMENT he, POINT* scrollPos, RECT* viewRect, SIZE* contentSize ) SciterGetScrollInfo; 147 | SCDOM_RESULT function( HELEMENT he, POINT scrollPos, BOOL smooth ) SciterSetScrollPos; 148 | SCDOM_RESULT function( HELEMENT he, int* pMinWidth, int* pMaxWidth ) SciterGetElementIntrinsicWidths; 149 | SCDOM_RESULT function( HELEMENT he, int forWidth, int* pHeight ) SciterGetElementIntrinsicHeight; 150 | SCDOM_RESULT function( HELEMENT he, BOOL* pVisible) SciterIsElementVisible; 151 | SCDOM_RESULT function( HELEMENT he, BOOL* pEnabled ) SciterIsElementEnabled; 152 | SCDOM_RESULT function( HELEMENT he, uint firstIndex, uint lastIndex, ELEMENT_COMPARATOR* cmpFunc, void* cmpFuncParam ) SciterSortElements; 153 | SCDOM_RESULT function( HELEMENT he1, HELEMENT he2 ) SciterSwapElements; 154 | SCDOM_RESULT function( uint evt, void* eventCtlStruct, BOOL* bOutProcessed ) SciterTraverseUIEvent; 155 | SCDOM_RESULT function( HELEMENT he, LPCSTR name, const VALUE* argv, uint argc, VALUE* retval ) SciterCallScriptingMethod; 156 | SCDOM_RESULT function( HELEMENT he, LPCSTR name, const VALUE* argv, uint argc, VALUE* retval ) SciterCallScriptingFunction; 157 | SCDOM_RESULT function( HELEMENT he, LPCWSTR script, uint scriptLength, VALUE* retval ) SciterEvalElementScript; 158 | SCDOM_RESULT function( HELEMENT he, HWINDOW hwnd) SciterAttachHwndToElement; 159 | SCDOM_RESULT function( HELEMENT he, /*CTL_TYPE*/ uint *pType ) SciterControlGetType; 160 | SCDOM_RESULT function( HELEMENT he, VALUE* pval ) SciterGetValue; 161 | SCDOM_RESULT function( HELEMENT he, const VALUE* pval ) SciterSetValue; 162 | SCDOM_RESULT function( HELEMENT he, VALUE* pval, BOOL forceCreation ) SciterGetExpando; 163 | SCDOM_RESULT function( HELEMENT he, tiscript_value* pval, BOOL forceCreation ) SciterGetObject; 164 | SCDOM_RESULT function( HELEMENT he, tiscript_value* pval) SciterGetElementNamespace; 165 | SCDOM_RESULT function( HWINDOW hwnd, HELEMENT* phe) SciterGetHighlightedElement; 166 | SCDOM_RESULT function( HWINDOW hwnd, HELEMENT he) SciterSetHighlightedElement; 167 | //| 168 | //| DOM Node API 169 | //| 170 | SCDOM_RESULT function(HNODE hn) SciterNodeAddRef; 171 | SCDOM_RESULT function(HNODE hn) SciterNodeRelease; 172 | SCDOM_RESULT function(HELEMENT he, HNODE* phn) SciterNodeCastFromElement; 173 | SCDOM_RESULT function(HNODE hn, HELEMENT* he) SciterNodeCastToElement; 174 | SCDOM_RESULT function(HNODE hn, HNODE* phn) SciterNodeFirstChild; 175 | SCDOM_RESULT function(HNODE hn, HNODE* phn) SciterNodeLastChild; 176 | SCDOM_RESULT function(HNODE hn, HNODE* phn) SciterNodeNextSibling; 177 | SCDOM_RESULT function(HNODE hn, HNODE* phn) SciterNodePrevSibling; 178 | SCDOM_RESULT function(HNODE hnode, HELEMENT* pheParent) SciterNodeParent; 179 | SCDOM_RESULT function(HNODE hnode, uint n, HNODE* phn) SciterNodeNthChild; 180 | SCDOM_RESULT function(HNODE hnode, uint* pn) SciterNodeChildrenCount; 181 | SCDOM_RESULT function(HNODE hnode, uint* pNodeType /*NODE_TYPE*/) SciterNodeType; 182 | SCDOM_RESULT function(HNODE hnode, LPCWSTR_RECEIVER rcv, void* rcv_param) SciterNodeGetText; 183 | SCDOM_RESULT function(HNODE hnode, LPCWSTR text, uint textLength) SciterNodeSetText; 184 | SCDOM_RESULT function(HNODE hnode, uint where /*NODE_INS_TARGET*/, HNODE what) SciterNodeInsert; 185 | SCDOM_RESULT function(HNODE hnode, BOOL finalize) SciterNodeRemove; 186 | SCDOM_RESULT function(LPCWSTR text, uint textLength, HNODE* phnode) SciterCreateTextNode; 187 | SCDOM_RESULT function(LPCWSTR text, uint textLength, HNODE* phnode) SciterCreateCommentNode; 188 | //| 189 | //| Value API 190 | //| 191 | uint function( VALUE* pval ) ValueInit; 192 | uint function( VALUE* pval ) ValueClear; 193 | uint function( const VALUE* pval1, const VALUE* pval2 ) ValueCompare; 194 | uint function( VALUE* pdst, const VALUE* psrc ) ValueCopy; 195 | uint function( VALUE* pdst ) ValueIsolate; 196 | uint function( const VALUE* pval, uint* pType, uint* pUnits ) ValueType; 197 | uint function( const VALUE* pval, LPCWSTR* pChars, uint* pNumChars ) ValueStringData; 198 | uint function( VALUE* pval, LPCWSTR chars, uint numChars, uint units ) ValueStringDataSet; 199 | uint function( const VALUE* pval, int* pData ) ValueIntData; 200 | uint function( VALUE* pval, int data, uint type, uint units ) ValueIntDataSet; 201 | uint function( const VALUE* pval, long* pData ) ValueInt64Data; 202 | uint function( VALUE* pval, long data, uint type, uint units ) ValueInt64DataSet; 203 | uint function( const VALUE* pval, FLOAT_VALUE* pData ) ValueFloatData; 204 | uint function( VALUE* pval, FLOAT_VALUE data, uint type, uint units ) ValueFloatDataSet; 205 | uint function( const VALUE* pval, LPCBYTE* pBytes, uint* pnBytes ) ValueBinaryData; 206 | uint function( VALUE* pval, LPCBYTE pBytes, uint nBytes, uint type, uint units ) ValueBinaryDataSet; 207 | uint function( const VALUE* pval, int* pn) ValueElementsCount; 208 | uint function( const VALUE* pval, int n, VALUE* pretval) ValueNthElementValue; 209 | uint function( VALUE* pval, int n, const VALUE* pval_to_set) ValueNthElementValueSet; 210 | uint function( const VALUE* pval, int n, VALUE* pretval) ValueNthElementKey; 211 | uint function( VALUE* pval, KeyValueCallback* penum, void* param) ValueEnumElements; 212 | uint function( VALUE* pval, const VALUE* pkey, const VALUE* pval_to_set) ValueSetValueToKey; 213 | uint function( const VALUE* pval, const VALUE* pkey, VALUE* pretval) ValueGetValueOfKey; 214 | uint function( VALUE* pval, /*VALUE_STRING_CVT_TYPE*/ uint how ) ValueToString; 215 | uint function( VALUE* pval, LPCWSTR str, uint strLength, /*VALUE_STRING_CVT_TYPE*/ uint how ) ValueFromString; 216 | uint function( const VALUE* pval, const VALUE* pthis, uint argc, const VALUE* argv, VALUE* pretval, LPCWSTR url) ValueInvoke; 217 | uint function( VALUE* pval, NATIVE_FUNCTOR_INVOKE* pinvoke, NATIVE_FUNCTOR_RELEASE* prelease, void* tag) ValueNativeFunctorSet; 218 | BOOL function( const VALUE* pval) ValueIsNativeFunctor; 219 | 220 | // tiscript VM API 221 | tiscript_native_interface* function() TIScriptAPI; 222 | HVM function(HWINDOW hwnd) SciterGetVM; 223 | 224 | BOOL function(HVM vm, tiscript_value script_value, VALUE* value, BOOL isolate) Sciter_v2V; 225 | BOOL function(HVM vm, const VALUE* valuev, tiscript_value* script_value) Sciter_V2v; 226 | 227 | HSARCHIVE function(LPCBYTE archiveData, uint archiveDataLength) SciterOpenArchive; 228 | BOOL function(HSARCHIVE harc, LPCWSTR path, LPCBYTE* pdata, uint* pdataLength) SciterGetArchiveItem; 229 | BOOL function(HSARCHIVE harc) SciterCloseArchive; 230 | 231 | SCDOM_RESULT function( const BEHAVIOR_EVENT_PARAMS* evt, BOOL post, BOOL *handled ) SciterFireEvent; 232 | 233 | void* function(HWINDOW hwnd) SciterGetCallbackParam; 234 | UINT_PTR function(HWINDOW hwnd, UINT_PTR wparam, UINT_PTR lparam, uint timeoutms) SciterPostCallback;// if timeoutms>0 then it is a send, not a post 235 | 236 | void* function() GetSciterGraphicsAPI; 237 | } 238 | } 239 | 240 | // added 241 | struct NATIVE_FUNCTOR_VALUE; -------------------------------------------------------------------------------- /source/sciter/interop/sciter_x_behaviors.d: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Ramon F. Mendes 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | module sciter.interop.sciter_x_behaviors; 22 | 23 | /* 24 | From: sciter-x-behavior.h 25 | only the top part 26 | */ 27 | 28 | import sciter.interop.sciter_x_types; 29 | import sciter.interop.sciter_x_dom; 30 | import sciter.interop.sciter_x_value; 31 | import sciter.interop.tiscript; 32 | 33 | 34 | extern(Windows) 35 | { 36 | enum EVENT_GROUPS : uint 37 | { 38 | HANDLE_INITIALIZATION = 0x0000, /** attached/detached */ 39 | HANDLE_MOUSE = 0x0001, /** mouse events */ 40 | HANDLE_KEY = 0x0002, /** key events */ 41 | HANDLE_FOCUS = 0x0004, /** focus events, if this flag is set it also means that element it attached to is focusable */ 42 | HANDLE_SCROLL = 0x0008, /** scroll events */ 43 | HANDLE_TIMER = 0x0010, /** timer event */ 44 | HANDLE_SIZE = 0x0020, /** size changed event */ 45 | HANDLE_DRAW = 0x0040, /** drawing request (event) */ 46 | HANDLE_DATA_ARRIVED = 0x080, /** requested data () has been delivered */ 47 | HANDLE_BEHAVIOR_EVENT = 0x0100, /** logical, synthetic events: 48 | BUTTON_CLICK, HYPERLINK_CLICK, etc., 49 | a.k.a. notifications from intrinsic behaviors */ 50 | HANDLE_METHOD_CALL = 0x0200, /** behavior specific methods */ 51 | HANDLE_SCRIPTING_METHOD_CALL = 0x0400, /** behavior specific methods */ 52 | HANDLE_TISCRIPT_METHOD_CALL = 0x0800, /** behavior specific methods using direct tiscript::value's */ 53 | 54 | HANDLE_EXCHANGE = 0x1000, /** system drag-n-drop */ 55 | HANDLE_GESTURE = 0x2000, /** touch input events */ 56 | 57 | HANDLE_ALL = 0xFFFF, /* all of them */ 58 | 59 | SUBSCRIPTIONS_REQUEST = 0xFFFFFFFF, /** special value for getting subscription flags */ 60 | } 61 | 62 | alias BOOL /*__stdcall*/ function(void* tag, HELEMENT he, uint evtg, void* prms) LPElementEventProc; 63 | alias BOOL /*__stdcall*/ function(LPCSTR, HELEMENT, LPElementEventProc*, void**) SciterBehaviorFactory; 64 | 65 | enum PHASE_MASK : uint 66 | { 67 | BUBBLING = 0, 68 | SINKING = 0x8000, 69 | HANDLED = 0x10000 70 | } 71 | 72 | enum MOUSE_BUTTONS : uint 73 | { 74 | MAIN_MOUSE_BUTTON = 1, 75 | PROP_MOUSE_BUTTON = 2, 76 | MIDDLE_MOUSE_BUTTON = 4, 77 | } 78 | 79 | enum KEYBOARD_STATES : uint 80 | { 81 | CONTROL_KEY_PRESSED = 0x1, 82 | SHIFT_KEY_PRESSED = 0x2, 83 | ALT_KEY_PRESSED = 0x4 84 | } 85 | 86 | enum INITIALIZATION_EVENTS : uint 87 | { 88 | BEHAVIOR_DETACH = 0, 89 | BEHAVIOR_ATTACH = 1 90 | } 91 | 92 | struct INITIALIZATION_PARAMS 93 | { 94 | /*UINT*/INITIALIZATION_EVENTS cmd; 95 | } 96 | 97 | enum DRAGGING_TYPE : uint 98 | { 99 | NO_DRAGGING, 100 | DRAGGING_MOVE, 101 | DRAGGING_COPY, 102 | } 103 | 104 | enum MOUSE_EVENTS : uint 105 | { 106 | MOUSE_ENTER = 0, 107 | MOUSE_LEAVE, 108 | MOUSE_MOVE, 109 | MOUSE_UP, 110 | MOUSE_DOWN, 111 | MOUSE_DCLICK, 112 | MOUSE_WHEEL, 113 | MOUSE_TICK, 114 | MOUSE_IDLE, 115 | DROP = 9, 116 | DRAG_ENTER = 0xA, 117 | DRAG_LEAVE = 0xB, 118 | DRAG_REQUEST = 0xC, 119 | MOUSE_CLICK = 0xFF, 120 | DRAGGING = 0x100, 121 | } 122 | 123 | struct MOUSE_PARAMS 124 | { 125 | uint cmd; 126 | HELEMENT target; 127 | POINT pos; 128 | POINT pos_view; 129 | uint button_state; 130 | uint alt_state; 131 | uint cursor_type; 132 | BOOL is_on_icon; 133 | HELEMENT dragging; 134 | uint dragging_mode; 135 | } 136 | 137 | enum CURSOR_TYPE : uint 138 | { 139 | CURSOR_ARROW, 140 | CURSOR_IBEAM, 141 | CURSOR_WAIT, 142 | CURSOR_CROSS, 143 | CURSOR_UPARROW, 144 | CURSOR_SIZENWSE, 145 | CURSOR_SIZENESW, 146 | CURSOR_SIZEWE, 147 | CURSOR_SIZENS, 148 | CURSOR_SIZEALL, 149 | CURSOR_NO, 150 | CURSOR_APPSTARTING, 151 | CURSOR_HELP, 152 | CURSOR_HAND, 153 | CURSOR_DRAG_MOVE, 154 | CURSOR_DRAG_COPY, 155 | } 156 | 157 | enum KEY_EVENTS : uint 158 | { 159 | KEY_DOWN = 0, 160 | KEY_UP, 161 | KEY_CHAR 162 | } 163 | 164 | struct KEY_PARAMS 165 | { 166 | uint cmd; 167 | HELEMENT target; 168 | uint key_code; 169 | uint alt_state; 170 | } 171 | 172 | enum FOCUS_EVENTS : uint 173 | { 174 | FOCUS_LOST = 0, // non-bubbling event, target is new focus element 175 | FOCUS_GOT = 1, // non-bubbling event, target is old focus element 176 | FOCUS_IN = 2, // bubbling event/notification, target is an element that got focus 177 | FOCUS_OUT = 3, // bubbling event/notification, target is an element that lost focus 178 | } 179 | 180 | struct FOCUS_PARAMS 181 | { 182 | uint cmd; 183 | HELEMENT target; 184 | BOOL by_mouse_click; 185 | BOOL cancel; 186 | } 187 | 188 | enum SCROLL_EVENTS : uint 189 | { 190 | SCROLL_HOME = 0, 191 | SCROLL_END, 192 | SCROLL_STEP_PLUS, 193 | SCROLL_STEP_MINUS, 194 | SCROLL_PAGE_PLUS, 195 | SCROLL_PAGE_MINUS, 196 | SCROLL_POS, 197 | SCROLL_SLIDER_RELEASED, 198 | SCROLL_CORNER_PRESSED, 199 | SCROLL_CORNER_RELEASED, 200 | } 201 | 202 | struct SCROLL_PARAMS 203 | { 204 | uint cmd; 205 | HELEMENT target; 206 | int pos; 207 | BOOL vertical; 208 | } 209 | 210 | enum GESTURE_CMD : uint 211 | { 212 | GESTURE_REQUEST = 0, 213 | GESTURE_ZOOM, 214 | GESTURE_PAN, 215 | GESTURE_ROTATE, 216 | GESTURE_TAP1, 217 | GESTURE_TAP2, 218 | } 219 | 220 | enum GESTURE_STATE : uint 221 | { 222 | GESTURE_STATE_BEGIN = 1, 223 | GESTURE_STATE_INERTIA = 2, 224 | GESTURE_STATE_END = 4, 225 | } 226 | 227 | enum GESTURE_TYPE_FLAGS : uint 228 | { 229 | GESTURE_FLAG_ZOOM = 0x0001, 230 | GESTURE_FLAG_ROTATE = 0x0002, 231 | GESTURE_FLAG_PAN_VERTICAL = 0x0004, 232 | GESTURE_FLAG_PAN_HORIZONTAL = 0x0008, 233 | GESTURE_FLAG_TAP1 = 0x0010, 234 | GESTURE_FLAG_TAP2 = 0x0020, 235 | GESTURE_FLAG_PAN_WITH_GUTTER = 0x4000, 236 | GESTURE_FLAG_PAN_WITH_INERTIA = 0x8000, 237 | GESTURE_FLAGS_ALL = 0xFFFF, 238 | } 239 | 240 | struct GESTURE_PARAMS 241 | { 242 | uint cmd; 243 | HELEMENT target; 244 | POINT pos; 245 | POINT pos_view; 246 | uint flags; 247 | uint delta_time; 248 | SIZE delta_xy; 249 | double delta_v; 250 | } 251 | 252 | enum DRAW_EVENTS : uint 253 | { 254 | DRAW_BACKGROUND = 0, 255 | DRAW_CONTENT = 1, 256 | DRAW_FOREGROUND = 2, 257 | } 258 | 259 | struct SCITER_GRAPHICS; 260 | 261 | struct DRAW_PARAMS 262 | { 263 | uint cmd; 264 | HGFX gfx; 265 | RECT area; 266 | uint reserved; 267 | } 268 | 269 | enum CONTENT_CHANGE_BITS : uint // for CONTENT_CHANGED reason 270 | { 271 | CONTENT_ADDED = 0x01, 272 | CONTENT_REMOVED = 0x02, 273 | } 274 | 275 | enum BEHAVIOR_EVENTS : uint 276 | { 277 | BUTTON_CLICK = 0, // click on button 278 | BUTTON_PRESS = 1, // mouse down or key down in button 279 | BUTTON_STATE_CHANGED = 2, // checkbox/radio/slider changed its state/value 280 | EDIT_VALUE_CHANGING = 3, // before text change 281 | EDIT_VALUE_CHANGED = 4, // after text change 282 | SELECT_SELECTION_CHANGED = 5, // selection in