├── .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 | D type
30 | C++ equivalent type
31 |
32 |
33 |
34 |
35 | module sciter.sciter_dom;
36 | struct node
37 | struct element
38 |
39 |
40 |
41 | #include "sciter-x-dom.hpp"
42 | class sciter::dom::node
43 | class sciter::dom::element
44 |
45 |
46 |
47 |
48 |
49 | module sciter.sciter_value;
50 | struct json_value
51 |
52 |
53 |
54 | #include "value.hpp"
55 | sciter::value or VALUE
56 |
57 |
58 |
59 |
60 |
61 | module sciter.dbg;
62 | abstract class debug_output
63 |
64 |
65 |
66 | #include "sciter-x-debug.h"
67 | class sciter::debug_output
68 |
69 |
70 |
71 |
72 |
73 | module sciter.host;
74 | class SciterArchive
75 | abstract class SciterWindowHost
76 |
77 |
78 |
79 | #include "sciter-x-host-callback.h"
80 | class sciter::archive
81 | class sciter::host<BASE>
82 |
83 |
84 |
85 |
86 |
87 | module sciter.behavior;
88 | abstract class EventHandler
89 |
90 |
91 |
92 | #include "sciter-x-behavior.h"
93 | class sciter::event_handler
94 |
95 |
96 |
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 changed
283 | SELECT_STATE_CHANGED = 6, // node in select expanded/collapsed, heTarget is the node
284 |
285 | POPUP_REQUEST = 7, // request to show popup just received,
286 | // here DOM of popup element can be modifed.
287 | POPUP_READY = 8, // popup element has been measured and ready to be shown on screen,
288 | // here you can use functions like ScrollToView.
289 | POPUP_DISMISSED = 9, // popup element is closed,
290 | // here DOM of popup element can be modifed again - e.g. some items can be removed
291 | // to free memory.
292 |
293 | MENU_ITEM_ACTIVE = 0xA, // menu item activated by mouse hover or by keyboard,
294 | MENU_ITEM_CLICK = 0xB, // menu item click,
295 | // BEHAVIOR_EVENT_PARAMS structure layout
296 | // BEHAVIOR_EVENT_PARAMS.cmd - MENU_ITEM_CLICK/MENU_ITEM_ACTIVE
297 | // BEHAVIOR_EVENT_PARAMS.heTarget - owner(anchor) of the menu
298 | // BEHAVIOR_EVENT_PARAMS.he - the menu item, presumably element
299 | // BEHAVIOR_EVENT_PARAMS.reason - BY_MOUSE_CLICK | BY_KEY_CLICK
300 |
301 |
302 | CONTEXT_MENU_REQUEST = 0x10, // "right-click", BEHAVIOR_EVENT_PARAMS::he is current popup menu HELEMENT being processed or NULL.
303 | // application can provide its own HELEMENT here (if it is NULL) or modify current menu element.
304 |
305 | VISIUAL_STATUS_CHANGED = 0x11, // broadcast notification, sent to all elements of some container being shown or hidden
306 | DISABLED_STATUS_CHANGED = 0x12,// broadcast notification, sent to all elements of some container that got new value of :disabled state
307 |
308 | POPUP_DISMISSING = 0x13, // popup is about to be closed
309 |
310 | CONTENT_CHANGED = 0x15, // content has been changed, is posted to the element that gets content changed, reason is combination of CONTENT_CHANGE_BITS.
311 | // target == NULL means the window got new document and this event is dispatched only to the window.
312 | CLICK = 0x16, // generic click
313 | CHANGE = 0x17, // generic change
314 |
315 | // "grey" event codes - notfications from behaviors from this SDK
316 | HYPERLINK_CLICK = 0x80, // hyperlink click
317 |
318 | //TABLE_HEADER_CLICK, // click on some cell in table header,
319 | // // target = the cell,
320 | // // reason = index of the cell (column number, 0..n)
321 | //TABLE_ROW_CLICK, // click on data row in the table, target is the row
322 | // // target = the row,
323 | // // reason = index of the row (fixed_rows..n)
324 | //TABLE_ROW_DBL_CLICK, // mouse dbl click on data row in the table, target is the row
325 | // // target = the row,
326 | // // reason = index of the row (fixed_rows..n)
327 |
328 | ELEMENT_COLLAPSED = 0x90, // element was collapsed, so far only behavior:tabs is sending these two to the panels
329 | ELEMENT_EXPANDED, // element was expanded,
330 |
331 | ACTIVATE_CHILD, // activate (select) child,
332 | // used for example by accesskeys behaviors to send activation request, e.g. tab on behavior:tabs.
333 |
334 | //DO_SWITCH_TAB = ACTIVATE_CHILD,// command to switch tab programmatically, handled by behavior:tabs
335 | // // use it as HTMLayoutPostEvent(tabsElementOrItsChild, DO_SWITCH_TAB, tabElementToShow, 0);
336 |
337 | INIT_DATA_VIEW, // request to virtual grid to initialize its view
338 |
339 | ROWS_DATA_REQUEST, // request from virtual grid to data source behavior to fill data in the table
340 | // parameters passed throug DATA_ROWS_PARAMS structure.
341 |
342 | UI_STATE_CHANGED, // ui state changed, observers shall update their visual states.
343 | // is sent for example by behavior:richtext when caret position/selection has changed.
344 |
345 | FORM_SUBMIT, // behavior:form detected submission event. BEHAVIOR_EVENT_PARAMS::data field contains data to be posted.
346 | // BEHAVIOR_EVENT_PARAMS::data is of type T_MAP in this case key/value pairs of data that is about
347 | // to be submitted. You can modify the data or discard submission by returning true from the handler.
348 | FORM_RESET, // behavior:form detected reset event (from button type=reset). BEHAVIOR_EVENT_PARAMS::data field contains data to be reset.
349 | // BEHAVIOR_EVENT_PARAMS::data is of type T_MAP in this case key/value pairs of data that is about
350 | // to be rest. You can modify the data or discard reset by returning true from the handler.
351 |
352 | DOCUMENT_COMPLETE, // document in behavior:frame or root document is complete.
353 |
354 | HISTORY_PUSH, // requests to behavior:history (commands)
355 | HISTORY_DROP,
356 | HISTORY_PRIOR,
357 | HISTORY_NEXT,
358 | HISTORY_STATE_CHANGED, // behavior:history notification - history stack has changed
359 |
360 | CLOSE_POPUP, // close popup request,
361 | REQUEST_TOOLTIP, // request tooltip, evt.source <- is the tooltip element.
362 |
363 | ANIMATION = 0xA0, // animation started (reason=1) or ended(reason=0) on the element.
364 | DOCUMENT_CREATED = 0xC0, // document created, script namespace initialized. target -> the document
365 | DOCUMENT_CLOSE_REQUEST = 0xC1, // document is about to be closed, to cancel closing do: evt.data = sciter::value("cancel");
366 | DOCUMENT_CLOSE = 0xC2, // last notification before document removal from the DOM
367 | DOCUMENT_READY = 0xC3, // document has got DOM structure, styles and behaviors of DOM elements. Script loading run is complete at this moment.
368 |
369 |
370 | VIDEO_INITIALIZED = 0xD1, // "ready" notification
371 | VIDEO_STARTED = 0xD2, // playback started notification
372 | VIDEO_STOPPED = 0xD3, // playback stoped/paused notification
373 | VIDEO_BIND_RQ = 0xD4, // request for frame source binding,
374 | // If you want to provide your own video frames source for the given target element do the following:
375 | // 1. Handle and consume this VIDEO_BIND_RQ request
376 | // 2. You will receive second VIDEO_BIND_RQ request/event for the same element
377 | // but this time with the 'reason' field set to an instance of sciter::video_destination interface.
378 | // 3. add_ref() it and store it for example in worker thread producing video frames.
379 | // 4. call sciter::video_destination::start_streaming(...) providing needed parameters
380 | // call sciter::video_destination::render_frame(...) as soon as they are available
381 | // call sciter::video_destination::stop_streaming() to stop the rendering (a.k.a. end of movie reached)
382 |
383 | PAGINATION_STARTS = 0xE0, // behavior:pager starts pagination
384 | PAGINATION_PAGE = 0xE1, // behavior:pager paginated page no, reason -> page no
385 | PAGINATION_ENDS = 0xE2, // behavior:pager end pagination, reason -> total pages
386 |
387 | FIRST_APPLICATION_EVENT_CODE = 0x100
388 | // all custom event codes shall be greater
389 | // than this number. All codes below this will be used
390 | // solely by application - HTMLayout will not intrepret it
391 | // and will do just dispatching.
392 | // To send event notifications with these codes use
393 | // HTMLayoutSend/PostEvent API.
394 | }
395 |
396 | enum EVENT_REASON : uint
397 | {
398 | BY_MOUSE_CLICK,
399 | BY_KEY_CLICK,
400 | SYNTHESIZED,
401 | }
402 |
403 | enum EDIT_CHANGED_REASON : uint
404 | {
405 | BY_INS_CHAR,
406 | BY_INS_CHARS,
407 | BY_DEL_CHAR,
408 | BY_DEL_CHARS,
409 | }
410 |
411 | struct BEHAVIOR_EVENT_PARAMS
412 | {
413 | uint cmd;
414 | HELEMENT heTarget;
415 | HELEMENT he;
416 | UINT_PTR reason;
417 | VALUE data;
418 | }
419 |
420 | struct TIMER_PARAMS
421 | {
422 | UINT_PTR timerId;
423 | }
424 |
425 | enum BEHAVIOR_METHOD_IDENTIFIERS : uint
426 | {
427 | DO_CLICK = 0,
428 | GET_TEXT_VALUE = 1,
429 | SET_TEXT_VALUE,
430 | TEXT_EDIT_GET_SELECTION,
431 | TEXT_EDIT_SET_SELECTION,
432 | TEXT_EDIT_REPLACE_SELECTION,
433 | SCROLL_BAR_GET_VALUE,
434 | SCROLL_BAR_SET_VALUE,
435 | TEXT_EDIT_GET_CARET_POSITION,
436 | TEXT_EDIT_GET_SELECTION_TEXT,
437 | TEXT_EDIT_GET_SELECTION_HTML,
438 | TEXT_EDIT_CHAR_POS_AT_XY,
439 | IS_EMPTY = 0xFC,
440 | GET_VALUE = 0xFD,
441 | SET_VALUE = 0xFE,
442 | FIRST_APPLICATION_METHOD_ID = 0x100
443 | }
444 |
445 | alias BEHAVIOR_METHOD_IDENTIFIERS eBehaviorMethodIdentifiers;
446 |
447 |
448 | struct SCRIPTING_METHOD_PARAMS
449 | {
450 | LPCSTR name;
451 | VALUE* argv;
452 | uint argc;
453 | VALUE result; // plz note, Sciter will internally call ValueClear to this VALUE,
454 | // that is, it own this data, so always assign a copy with a positive ref-count of your VALUE to this variable
455 | // you will know that if you get an "Access Violation" error
456 | // see json_value.copy() - midi
457 | }
458 |
459 | struct TISCRIPT_METHOD_PARAMS
460 | {
461 | tiscript_VM* vm;
462 | tiscript_value tag;
463 | tiscript_value result;
464 | }
465 |
466 | // GET_VALUE/SET_VALUE methods params
467 | struct VALUE_PARAMS
468 | {
469 | uint methodID;
470 | VALUE val;
471 | }
472 | // IS_EMPTY method params
473 | struct IS_EMPTY_PARAMS
474 | {
475 | uint methodID;
476 | uint is_empty; // !0 - is empty
477 | }
478 |
479 | struct DATA_ARRIVED_PARAMS
480 | {
481 | HELEMENT initiator;
482 | LPCBYTE data;
483 | uint dataSize;
484 | uint dataType;
485 | uint status;
486 | LPCWSTR uri;
487 | }
488 | }
489 |
--------------------------------------------------------------------------------
/source/sciter/interop/sciter_x_def.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_def;
22 |
23 | import sciter.interop.sciter_x_types;
24 |
25 | public import sciter.interop.sciter_x_value;
26 | public import sciter.interop.sciter_x_dom;
27 |
28 |
29 | extern(Windows)// needed for the functions alias'es
30 | {
31 | enum SciterResourceType : uint
32 | {
33 | RT_DATA_HTML = 0,
34 | RT_DATA_IMAGE = 1,
35 | RT_DATA_STYLE = 2,
36 | RT_DATA_CURSOR = 3,
37 | RT_DATA_SCRIPT = 4,
38 | RT_DATA_RAW = 5,
39 | }
40 |
41 | //EXTERN_C LPCWSTR SCAPI SciterClassName();
42 | //EXTERN_C uint SCAPI SciterVersion(BOOL major);
43 |
44 |
45 | enum
46 | {
47 | LOAD_OK = 0, // do default loading if data not set
48 | LOAD_DISCARD = 1, // discard request completely
49 | LOAD_DELAYED = 2, // data will be delivered later by the host
50 | // Host application must call SciterDataReadyAsync(,,, requestId) on each LOAD_DELAYED request to avoid memory leaks.
51 | }
52 |
53 | const int SC_LOAD_DATA = 0x01;
54 | const int SC_DATA_LOADED = 0x02;
55 | const int SC_ATTACH_BEHAVIOR = 0x04;
56 | const int SC_ENGINE_DESTROYED = 0x05;
57 | const int SC_POSTED_NOTIFICATION = 0x06;
58 |
59 | struct SCITER_CALLBACK_NOTIFICATION
60 | {
61 | uint code;// SC_LOAD_DATA or SC_DATA_LOADED or ..
62 | HWINDOW hwnd;
63 | }
64 | alias SCITER_CALLBACK_NOTIFICATION* LPSCITER_CALLBACK_NOTIFICATION;
65 | alias LPSciterHostCallback = uint function(LPSCITER_CALLBACK_NOTIFICATION pns, void* callbackParam);
66 |
67 |
68 | struct SCN_LOAD_DATA
69 | {
70 | uint code; /**< [in] one of the codes above.*/
71 | HWINDOW hwnd; /**< [in] HWINDOW of the window this callback was attached to.*/
72 |
73 | LPCWSTR uri; /**< [in] Zero terminated string, fully qualified uri, for example "http://server/folder/file.ext".*/
74 |
75 | LPCBYTE outData; /**< [in,out] pointer to loaded data to return. if data exists in the cache then this field contain pointer to it*/
76 | uint outDataSize; /**< [in,out] loaded data size to return.*/
77 | uint dataType; /**< [in] SciterResourceType */
78 |
79 | void* requestId; /**< [in] request id that needs to be passed as is to the SciterDataReadyAsync call */
80 |
81 | HELEMENT principal;
82 | HELEMENT initiator;
83 | }
84 | alias SCN_LOAD_DATA* LPSCN_LOAD_DATA;
85 |
86 | struct SCN_DATA_LOADED
87 | {
88 | uint code; /**< [in] one of the codes above.*/
89 | HWINDOW hwnd; /**< [in] HWINDOW of the window this callback was attached to.*/
90 |
91 | LPCWSTR uri; /**< [in] zero terminated string, fully qualified uri, for example "http://server/folder/file.ext".*/
92 | LPCBYTE data; /**< [in] pointer to loaded data.*/
93 | uint dataSize; /**< [in] loaded data size (in bytes).*/
94 | uint dataType; /**< [in] SciterResourceType */
95 | uint status; /**< [in]
96 | status = 0 (dataSize == 0) - unknown error.
97 | status = 100..505 - http response status, Note: 200 - OK!
98 | status > 12000 - wininet error code, see ERROR_INTERNET_*** in wininet.h
99 | */
100 | }
101 | alias SCN_DATA_LOADED* LPSCN_DATA_LOADED;
102 |
103 | struct SCN_ATTACH_BEHAVIOR
104 | {
105 | uint code; /**< [in] one of the codes above.*/
106 | HWINDOW hwnd; /**< [in] HWINDOW of the window this callback was attached to.*/
107 |
108 | HELEMENT elem; /**< [in] target DOM element handle*/
109 | LPCSTR behaviorName; /**< [in] zero terminated string, string appears as value of CSS behavior:"???" attribute.*/
110 |
111 | ElementEventProc* elementProc; /**< [out] pointer to ElementEventProc function.*/
112 | void* elementTag; /**< [out] tag value, passed as is into pointer ElementEventProc function.*/
113 | }
114 | alias SCN_ATTACH_BEHAVIOR* LPSCN_ATTACH_BEHAVIOR;
115 |
116 | struct SCN_ENGINE_DESTROYED
117 | {
118 | uint code; /**< [in] one of the codes above.*/
119 | HWINDOW hwnd; /**< [in] HWINDOW of the window this callback was attached to.*/
120 | }
121 | alias SCN_ENGINE_DESTROYED* LPSCN_ENGINE_DESTROYED;
122 |
123 | struct SCN_POSTED_NOTIFICATION
124 | {
125 | uint code; /**< [in] one of the codes above.*/
126 | HWINDOW hwnd; /**< [in] HWINDOW of the window this callback was attached to.*/
127 | UINT_PTR wparam;
128 | UINT_PTR lparam;
129 | UINT_PTR lreturn;
130 | }
131 |
132 | alias SCN_POSTED_NOTIFICATION* LPSCN_POSTED_NOTIFICATION;
133 |
134 |
135 | //EXTERN_C BOOL SCAPI SciterDataReady(HWINDOW hwnd,LPCWSTR uri,LPCBYTE data, uint dataLength);
136 | //EXTERN_C BOOL SCAPI SciterDataReadyAsync(HWINDOW hwnd,LPCWSTR uri, LPCBYTE data, uint dataLength, void* requestId);
137 | //EXTERN_C LRESULT SCAPI SciterProc(HWINDOW hwnd, uint msg, WPARAM wParam, LPARAM lParam);
138 | //EXTERN_C LRESULT SCAPI SciterProcND(HWINDOW hwnd, uint msg, WPARAM wParam, LPARAM lParam, BOOL* pbHandled);
139 | //EXTERN_C BOOL SCAPI SciterLoadFile(HWINDOW hWndSciter, LPCWSTR filename);
140 | //EXTERN_C BOOL SCAPI SciterLoadHtml(HWINDOW hWndSciter, LPCBYTE html, uint htmlSize, LPCWSTR baseUrl);
141 | //EXTERN_C VOID SCAPI SciterSetCallback(HWINDOW hWndSciter, LPSciterHostCallback cb, void* cbParam);
142 | //EXTERN_C BOOL SCAPI SciterSetMasterCSS(LPCBYTE utf8, uint numBytes);
143 | //EXTERN_C BOOL SCAPI SciterAppendMasterCSS(LPCBYTE utf8, uint numBytes);
144 | //EXTERN_C BOOL SCAPI SciterSetCSS(HWINDOW hWndSciter, LPCBYTE utf8, uint numBytes, LPCWSTR baseUrl, LPCWSTR mediaType);
145 | //EXTERN_C BOOL SCAPI SciterSetMediaType(HWINDOW hWndSciter, LPCWSTR mediaType);
146 | //EXTERN_C BOOL SCAPI SciterSetMediaVars(HWINDOW hWndSciter, const SCITER_VALUE *mediaVars);
147 | //EXTERN_C uint SCAPI SciterGetMinWidth(HWINDOW hWndSciter);
148 | //EXTERN_C uint SCAPI SciterGetMinHeight(HWINDOW hWndSciter, uint width);
149 | //EXTERN_C BOOL SCAPI SciterCall(HWINDOW hWnd, LPCSTR functionName, uint argc, const SCITER_VALUE* argv, SCITER_VALUE* retval);
150 | //EXTERN_C BOOL SCAPI SciterEval( HWINDOW hwnd, LPCWSTR script, uint scriptLength, SCITER_VALUE* pretval);
151 | //EXTERN_C VOID SCAPI SciterUpdateWindow(HWINDOW hwnd);
152 | //EXTERN_C BOOL SCAPI SciterTranslateMessage(MSG* lpMsg);
153 |
154 | enum SCRIPT_RUNTIME_FEATURES : uint
155 | {
156 | ALLOW_FILE_IO = 0x00000001,
157 | ALLOW_SOCKET_IO = 0x00000002,
158 | ALLOW_EVAL = 0x00000004,
159 | ALLOW_SYSINFO = 0x00000008
160 | }
161 |
162 | enum GFX_LAYER : uint
163 | {
164 | GFX_LAYER_GDI = 1,
165 | GFX_LAYER_WARP = 2,
166 | GFX_LAYER_D2D = 3,
167 | GFX_LAYER_AUTO = 0xFFFF,
168 | }
169 |
170 | enum SCITER_RT_OPTIONS : uint
171 | {
172 | SCITER_SMOOTH_SCROLL = 1, // value:TRUE - enable, value:FALSE - disable, enabled by default
173 | SCITER_CONNECTION_TIMEOUT = 2, // value: milliseconds, connection timeout of http client
174 | SCITER_HTTPS_ERROR = 3, // value: 0 - drop connection, 1 - use builtin dialog, 2 - accept connection silently
175 | SCITER_FONT_SMOOTHING = 4, // value: 0 - system default, 1 - no smoothing, 2 - std smoothing, 3 - clear type
176 |
177 | SCITER_TRANSPARENT_WINDOW = 6, // Windows Aero support, value:
178 | // 0 - normal drawing,
179 | // 1 - window has transparent background after calls DwmExtendFrameIntoClientArea() or DwmEnableBlurBehindWindow().
180 | SCITER_SET_GPU_BLACKLIST = 7, // hWnd = NULL,
181 | // value = LPCBYTE, json - GPU black list, see: gpu-blacklist.json resource.
182 | SCITER_SET_SCRIPT_RUNTIME_FEATURES = 8, // value - combination of SCRIPT_RUNTIME_FEATURES flags.
183 | SCITER_SET_GFX_LAYER = 9, // hWnd = NULL, value - GFX_LAYER
184 | SCITER_SET_DEBUG_MODE = 10, // hWnd, value - TRUE/FALSE
185 | SCITER_SET_UX_THEMING = 11, // hWnd = NULL, value - BOOL, TRUE - the engine will use "unisex" theme that is common for all platforms.
186 | // That UX theme is not using OS primitives for rendering input elements. Use it if you want exactly
187 | // the same (modulo fonts) look-n-feel on all platforms.
188 |
189 | SCITER_ALPHA_WINDOW = 12, // hWnd, value - TRUE/FALSE - window uses per pixel alpha (e.g. WS_EX_LAYERED/UpdateLayeredWindow() window)
190 | }
191 | //EXTERN_C BOOL SCAPI SciterSetOption(HWINDOW hWnd, uint option, UINT_PTR value );
192 | //EXTERN_C VOID SCAPI SciterGetPPI(HWINDOW hWndSciter, uint* px, uint* py);
193 | //EXTERN_C BOOL SCAPI SciterGetViewExpando( HWINDOW hwnd, VALUE* pval );
194 | //EXTERN_C BOOL SCAPI SciterRenderD2D(HWINDOW hWndSciter, ID2D1RenderTarget* prt);
195 | //EXTERN_C BOOL SCAPI SciterD2DFactory(ID2D1Factory ** ppf);
196 | //EXTERN_C BOOL SCAPI SciterDWFactory(IDWriteFactory ** ppf);
197 | //EXTERN_C BOOL SCAPI SciterGraphicsCaps(LPuint pcaps);
198 | //EXTERN_C BOOL SCAPI SciterSetHomeURL(HWINDOW hWndSciter, LPCWSTR baseUrl);
199 |
200 |
201 | version(Windows)
202 | alias SciterWindowDelegate = LRESULT function(HWINDOW hwnd, uint msg, WPARAM wParam, LPARAM lParam, void* pParam, BOOL* handled);
203 | version(linux)
204 | alias SciterWindowDelegate = void*;
205 | version(OSX)
206 | alias SciterWindowDelegate = void*;
207 |
208 |
209 | enum SCITER_CREATE_WINDOW_FLAGS : uint
210 | {
211 | SW_CHILD = (1 << 0), // child window only, if this flag is set all other flags ignored
212 | SW_TITLEBAR = (1 << 1), // toplevel window, has titlebar
213 | SW_RESIZEABLE = (1 << 2), // has resizeable frame
214 | SW_TOOL = (1 << 3), // is tool window
215 | SW_CONTROLS = (1 << 4), // has minimize / maximize buttons
216 | SW_GLASSY = (1 << 5), // glassy window ( DwmExtendFrameIntoClientArea on windows )
217 | SW_ALPHA = (1 << 6), // transparent window ( e.g. WS_EX_LAYERED on Windows )
218 | SW_MAIN = (1 << 7), // main window of the app, will terminate app on close
219 | SW_POPUP = (1 << 8), // the window is created as topmost.
220 | SW_ENABLE_DEBUG = (1 << 9), // make this window inspector ready
221 | SW_OWNS_VM = (1 << 10), // it has its own script VM
222 | }
223 |
224 | //EXTERN_C HWINDOW SCAPI SciterCreateWindow( uint creationFlags, LPRECT frame, SciterWindowDelegate* delegate, void* delegateParam, HWINDOW parent);
225 |
226 |
227 | enum OUTPUT_SUBSYTEM : uint
228 | {
229 | OT_DOM = 0, // html parser & runtime
230 | OT_CSSS, // csss! parser & runtime
231 | OT_CSS, // css parser
232 | OT_TIS, // TIS parser & runtime
233 | }
234 | enum OUTPUT_SEVERITY : uint
235 | {
236 | OS_INFO,
237 | OS_WARNING,
238 | OS_ERROR,
239 | }
240 |
241 | alias DEBUG_OUTPUT_PROC = void function(void* param, uint subsystem /*OUTPUT_SUBSYTEMS*/, uint severity /*OUTPUT_SEVERITY*/, LPCWSTR text, uint text_length);
242 |
243 | //EXTERN_C VOID SCAPI SciterSetupDebugOutput(
244 | // HWINDOW hwndOrNull,// HWINDOW or null if this is global output handler
245 | // void* param, // param to be passed "as is" to the pfOutput
246 | // DEBUG_OUTPUT_PROC pfOutput // output function, output stream alike thing.
247 | // );
248 | }
--------------------------------------------------------------------------------
/source/sciter/interop/sciter_x_dom.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_dom;
22 |
23 | import sciter.interop.sciter_x_types;
24 |
25 |
26 | extern(Windows)
27 | {
28 | /* Following types are strongly typedefed at 'sciter.types'
29 | HELEMENT
30 | HNODE
31 | HRANGE
32 | HSARCHIVE
33 | */
34 | struct HPOSITION { HNODE hn; int pos; }
35 |
36 |
37 | alias int SCDOM_RESULT;
38 | const int SCDOM_OK = 0;
39 | const int SCDOM_INVALID_HWND = 1;
40 | const int SCDOM_INVALID_HANDLE = 2;
41 | const int SCDOM_PASSIVE_HANDLE = 3;
42 | const int SCDOM_INVALID_PARAMETER = 4;
43 | const int SCDOM_OPERATION_FAILED = 5;
44 | const int SCDOM_OK_NOT_HANDLED = (-1);
45 |
46 | struct METHOD_PARAMS
47 | {
48 | uint methodID;
49 | }
50 | struct REQUEST_PARAM
51 | {
52 | LPCWSTR name;
53 | LPCWSTR value;
54 | }
55 |
56 |
57 | /+SCDOM_RESULT SCAPI Sciter_UseElement(HELEMENT he);
58 | SCDOM_RESULT SCAPI Sciter_UnuseElement(HELEMENT he);
59 | SCDOM_RESULT SCAPI SciterGetRootElement(HWINDOW hwnd, HELEMENT *phe);
60 | SCDOM_RESULT SCAPI SciterGetFocusElement(HWINDOW hwnd, HELEMENT *phe);
61 | SCDOM_RESULT SCAPI SciterFindElement(HWINDOW hwnd, POINT pt, HELEMENT* phe);
62 | SCDOM_RESULT SCAPI SciterGetChildrenCount(HELEMENT he, uint* count);
63 | SCDOM_RESULT SCAPI SciterGetNthChild(HELEMENT he, uint n, HELEMENT* phe);
64 | SCDOM_RESULT SCAPI SciterGetParentElement(HELEMENT he, HELEMENT* p_parent_he);
65 | //OBSOLETE SCDOM_RESULT SCAPI SciterGetElementHtml(HELEMENT he, LPCBYTE* utf8bytes, BOOL outer);+/
66 | alias LPCBYTE_RECEIVER = void function(LPCBYTE bytes, uint num_bytes, void* param);
67 | /+SCDOM_RESULT SCAPI SciterGetElementHtmlCB(HELEMENT he, BOOL outer, LPCBYTE_RECEIVER* rcv, void* rcv_param);
68 | //OBSOLETE SCDOM_RESULT SCAPI SciterGetElementText(HELEMENT he, LPWSTR* utf16);+/
69 | alias LPCWSTR_RECEIVER = void function(LPCWSTR str, uint str_length, void* param);
70 | alias LPCSTR_RECEIVER = void function(LPCSTR str, uint str_length, void* param);
71 | /+SCDOM_RESULT SCAPI SciterGetElementTextCB(HELEMENT he, LPCWSTR_RECEIVER* rcv, void* rcv_param);
72 | SCDOM_RESULT SCAPI SciterSetElementText(HELEMENT he, LPCWSTR utf16, uint length);
73 | SCDOM_RESULT SCAPI SciterGetAttributeCount(HELEMENT he, LPuint p_count);
74 | SCDOM_RESULT SCAPI SciterGetNthAttributeNameCB(HELEMENT he, uint n, LPCSTR_RECEIVER* rcv, void* rcv_param);
75 | SCDOM_RESULT SCAPI SciterGetNthAttributeValueCB(HELEMENT he, uint n, LPCWSTR_RECEIVER* rcv, void* rcv_param);
76 | SCDOM_RESULT SCAPI SciterGetAttributeByNameCB(HELEMENT he, LPCSTR name, LPCWSTR_RECEIVER* rcv, void* rcv_param);
77 | SCDOM_RESULT SCAPI SciterSetAttributeByName(HELEMENT he, LPCSTR name, LPCWSTR value);
78 | SCDOM_RESULT SCAPI SciterClearAttributes(HELEMENT he);
79 | SCDOM_RESULT SCAPI SciterGetElementIndex(HELEMENT he, LPuint p_index);
80 | SCDOM_RESULT SCAPI SciterGetElementType(HELEMENT he, LPCSTR* p_type);
81 | SCDOM_RESULT SCAPI SciterGetElementTypeCB(HELEMENT he, LPCSTR_RECEIVER* rcv, void* rcv_param);
82 | SCDOM_RESULT SCAPI SciterGetStyleAttributeCB(HELEMENT he, LPCSTR name, LPCWSTR_RECEIVER* rcv, void* rcv_param);
83 | SCDOM_RESULT SCAPI SciterSetStyleAttribute(HELEMENT he, LPCSTR name, LPCWSTR value);+/
84 |
85 |
86 | enum ELEMENT_AREAS : uint
87 | {
88 | ROOT_RELATIVE = 0x01, // - or this flag if you want to get HTMLayout window relative coordinates,
89 | // otherwise it will use nearest windowed container e.g. popup window.
90 | SELF_RELATIVE = 0x02, // - "or" this flag if you want to get coordinates relative to the origin
91 | // of element iself.
92 | CONTAINER_RELATIVE = 0x03, // - position inside immediate container.
93 | VIEW_RELATIVE = 0x04, // - position relative to view - HTMLayout window
94 |
95 | CONTENT_BOX = 0x00, // content (inner) box
96 | PADDING_BOX = 0x10, // content + paddings
97 | BORDER_BOX = 0x20, // content + paddings + border
98 | MARGIN_BOX = 0x30, // content + paddings + border + margins
99 |
100 | BACK_IMAGE_AREA = 0x40, // relative to content origin - location of background image (if it set no-repeat)
101 | FORE_IMAGE_AREA = 0x50, // relative to content origin - location of foreground image (if it set no-repeat)
102 |
103 | SCROLLABLE_AREA = 0x60, // scroll_area - scrollable area in content box
104 | }
105 | //SCDOM_RESULT SCAPI SciterGetElementLocation(HELEMENT he, LPRECT p_location, uint areas /*ELEMENT_AREAS*/);
106 |
107 |
108 |
109 | enum SCITER_SCROLL_FLAGS : uint
110 | {
111 | SCROLL_TO_TOP = 0x01,
112 | SCROLL_SMOOTH = 0x10,
113 | }
114 |
115 |
116 | /+SCDOM_RESULT SCAPI SciterScrollToView(HELEMENT he, uint SciterScrollFlags);
117 | SCDOM_RESULT SCAPI SciterUpdateElement(HELEMENT he, BOOL andForceRender);
118 | SCDOM_RESULT SCAPI SciterRefreshElementArea(HELEMENT he, RECT rc);
119 | SCDOM_RESULT SCAPI SciterSetCapture(HELEMENT he);
120 | SCDOM_RESULT SCAPI SciterReleaseCapture(HELEMENT he);
121 | SCDOM_RESULT SCAPI SciterGetElementHwnd(HELEMENT he, HWINDOW* p_hwnd, BOOL rootWindow);
122 | SCDOM_RESULT SCAPI SciterCombineURL(HELEMENT he, LPWSTR szUrlBuffer, uint UrlBufferSize);+/
123 | alias BOOL function(HELEMENT he, void* param) SciterElementCallback;
124 |
125 | /+SCDOM_RESULT SCAPI SciterSelectElements(
126 | HELEMENT he,
127 | LPCSTR CSS_selectors,
128 | SciterElementCallback*
129 | callback,
130 | void* param);
131 |
132 | SCDOM_RESULT SCAPI SciterSelectElementsW(
133 | HELEMENT he,
134 | LPCWSTR CSS_selectors,
135 | SciterElementCallback*
136 | callback,
137 | void* param);
138 |
139 | SCDOM_RESULT SCAPI SciterSelectParent(
140 | HELEMENT he,
141 | LPCSTR selector,
142 | uint depth,
143 | /*out*/ HELEMENT* heFound);
144 |
145 | SCDOM_RESULT SCAPI SciterSelectParentW(
146 | HELEMENT he,
147 | LPCWSTR selector,
148 | uint depth,
149 | /*out*/ HELEMENT* heFound);+/
150 |
151 | enum SET_ELEMENT_HTML : uint
152 | {
153 | SIH_REPLACE_CONTENT = 0,
154 | SIH_INSERT_AT_START = 1,
155 | SIH_APPEND_AFTER_LAST = 2,
156 | SOH_REPLACE = 3,
157 | SOH_INSERT_BEFORE = 4,
158 | SOH_INSERT_AFTER = 5
159 | }
160 |
161 |
162 | /+SCDOM_RESULT SCAPI SciterSetElementHtml(HELEMENT he, const BYTE* html, uint htmlLength, uint where);
163 | SCDOM_RESULT SCAPI SciterGetElementUID(HELEMENT he, uint* puid);
164 | SCDOM_RESULT SCAPI SciterGetElementByUID(HWINDOW hwnd, uint uid, HELEMENT* phe);
165 | SCDOM_RESULT SCAPI SciterShowPopup(HELEMENT hePopup, HELEMENT heAnchor, uint placement);
166 | SCDOM_RESULT SCAPI SciterShowPopupAt(HELEMENT hePopup, POINT pos, BOOL animate);
167 | SCDOM_RESULT SCAPI SciterHidePopup(HELEMENT he);+/
168 | alias BOOL function(void* tag, HELEMENT he, uint evtg, void* prms) ElementEventProc;
169 | alias ElementEventProc LPELEMENT_EVENT_PROC;
170 |
171 | enum ELEMENT_STATE_BITS : uint
172 | {
173 | STATE_LINK = 0x00000001,
174 | STATE_HOVER = 0x00000002,
175 | STATE_ACTIVE = 0x00000004,
176 | STATE_FOCUS = 0x00000008,
177 | STATE_VISITED = 0x00000010,
178 | STATE_CURRENT = 0x00000020, // current (hot) item
179 | STATE_CHECKED = 0x00000040, // element is checked (or selected)
180 | STATE_DISABLED = 0x00000080, // element is disabled
181 | STATE_READONLY = 0x00000100, // readonly input element
182 | STATE_EXPANDED = 0x00000200, // expanded state - nodes in tree view
183 | STATE_COLLAPSED = 0x00000400, // collapsed state - nodes in tree view - mutually exclusive with
184 | STATE_INCOMPLETE = 0x00000800, // one of fore/back images requested but not delivered
185 | STATE_ANIMATING = 0x00001000, // is animating currently
186 | STATE_FOCUSABLE = 0x00002000, // will accept focus
187 | STATE_ANCHOR = 0x00004000, // anchor in selection (used with current in selects)
188 | STATE_SYNTHETIC = 0x00008000, // this is a synthetic element - don't emit it's head/tail
189 | STATE_OWNS_POPUP = 0x00010000, // this is a synthetic element - don't emit it's head/tail
190 | STATE_TABFOCUS = 0x00020000, // focus gained by tab traversal
191 | STATE_EMPTY = 0x00040000, // empty - element is empty (text.size() == 0 && subs.size() == 0)
192 | // if element has behavior attached then the behavior is responsible for the value of this flag.
193 | STATE_BUSY = 0x00080000, // busy; loading
194 |
195 | STATE_DRAG_OVER = 0x00100000, // drag over the block that can accept it (so is current drop target). Flag is set for the drop target block
196 | STATE_DROP_TARGET = 0x00200000, // active drop target.
197 | STATE_MOVING = 0x00400000, // dragging/moving - the flag is set for the moving block.
198 | STATE_COPYING = 0x00800000, // dragging/copying - the flag is set for the copying block.
199 | STATE_DRAG_SOURCE = 0x01000000, // element that is a drag source.
200 | STATE_DROP_MARKER = 0x02000000, // element is drop marker
201 |
202 | STATE_PRESSED = 0x04000000, // pressed - close to active but has wider life span - e.g. in MOUSE_UP it
203 | // is still on; so behavior can check it in MOUSE_UP to discover CLICK condition.
204 | STATE_POPUP = 0x08000000, // this element is out of flow - popup
205 |
206 | STATE_IS_LTR = 0x10000000, // the element or one of its containers has dir=ltr declared
207 | STATE_IS_RTL = 0x20000000, // the element or one of its containers has dir=rtl declared
208 | }
209 |
210 | /+SCDOM_RESULT SCAPI SciterGetElementState( HELEMENT he, uint* pstateBits);
211 | SCDOM_RESULT SCAPI SciterSetElementState( HELEMENT he, uint stateBitsToSet, uint stateBitsToClear, BOOL updateView);
212 | SCDOM_RESULT SCAPI SciterCreateElement( LPCSTR tagname, LPCWSTR textOrNull, /*out*/ HELEMENT *phe );
213 | SCDOM_RESULT SCAPI SciterCloneElement( HELEMENT he, /*out*/ HELEMENT *phe );
214 | SCDOM_RESULT SCAPI SciterInsertElement( HELEMENT he, HELEMENT hparent, uint index );
215 | SCDOM_RESULT SCAPI SciterDetachElement( HELEMENT he );
216 | SCDOM_RESULT SCAPI SciterDeleteElement(HELEMENT he);
217 | SCDOM_RESULT SCAPI SciterSetTimer( HELEMENT he, uint milliseconds, uint_PTR timer_id );
218 | SCDOM_RESULT SCAPI SciterDetachEventHandler( HELEMENT he, LPELEMENT_EVENT_PROC pep, void* tag );
219 | SCDOM_RESULT SCAPI SciterAttachEventHandler( HELEMENT he, LPELEMENT_EVENT_PROC pep, void* tag );
220 | SCDOM_RESULT SCAPI SciterWindowAttachEventHandler( HWINDOW hwndLayout, LPELEMENT_EVENT_PROC pep, void* tag, uint subscription );
221 | SCDOM_RESULT SCAPI SciterWindowDetachEventHandler( HWINDOW hwndLayout, LPELEMENT_EVENT_PROC pep, void* tag );
222 | SCDOM_RESULT SCAPI SciterSendEvent(HELEMENT he, uint appEventCode, HELEMENT heSource, uint reason, /*out*/ BOOL* handled);
223 | SCDOM_RESULT SCAPI SciterPostEvent( HELEMENT he, uint appEventCode, HELEMENT heSource, uint reason);
224 | SCDOM_RESULT SCAPI SciterFireEvent( const struct BEHAVIOR_EVENT_PARAMS* evt, BOOL post, BOOL *handled);
225 | SCDOM_RESULT SCAPI SciterCallBehaviorMethod(HELEMENT he, struct METHOD_PARAMS* params);
226 | SCDOM_RESULT SCAPI SciterRequestElementData( HELEMENT he, LPCWSTR url, uint dataType, HELEMENT initiator );+/
227 |
228 | enum REQUEST_TYPE
229 | {
230 | GET_ASYNC, // async GET
231 | POST_ASYNC, // async POST
232 | GET_SYNC, // synchronous GET
233 | POST_SYNC // synchronous POST
234 | }
235 |
236 | /+SCDOM_RESULT SCAPI SciterHttpRequest(
237 | HELEMENT he, // element to deliver data
238 | LPCWSTR url, // url
239 | uint dataType, // data type, see SciterResourceType.
240 | uint requestType, // one of REQUEST_TYPE values
241 | struct REQUEST_PARAM* requestParams,// parameters
242 | uint nParams // number of parameters
243 | );
244 |
245 | SCDOM_RESULT SCAPI SciterGetScrollInfo(HELEMENT he, LPPOINT scrollPos, LPRECT viewRect, LPSIZE contentSize );
246 | SCDOM_RESULT SCAPI SciterSetScrollPos(HELEMENT he, POINT scrollPos, BOOL smooth );
247 | SCDOM_RESULT SCAPI SciterGetElementIntrinsicWidths( HELEMENT he, INT* pMinWidth, INT* pMaxWidth );
248 | SCDOM_RESULT SCAPI SciterGetElementIntrinsicHeight( HELEMENT he, INT forWidth, INT* pHeight );
249 | SCDOM_RESULT SCAPI SciterIsElementVisible( HELEMENT he, BOOL* pVisible);
250 | SCDOM_RESULT SCAPI SciterIsElementEnabled( HELEMENT he, BOOL* pEnabled);+/
251 | alias int function(HELEMENT he1, HELEMENT he2, void* param) ELEMENT_COMPARATOR;
252 | /+SCDOM_RESULT SCAPI SciterSortElements(HELEMENT he, uint firstIndex, uint lastIndex, ELEMENT_COMPARATOR* cmpFunc, void* cmpFuncParam);
253 | SCDOM_RESULT SCAPI SciterSwapElements(HELEMENT he1, HELEMENT he2);
254 | SCDOM_RESULT SCAPI SciterTraverseUIEvent(uint evt, void* eventCtlStruct, BOOL* bOutProcessed );
255 | SCDOM_RESULT SCAPI SciterCallScriptingMethod( HELEMENT he, LPCSTR name, const VALUE* argv, uint argc, VALUE* retval );
256 | SCDOM_RESULT SCAPI SciterCallScriptingFunction( HELEMENT he, LPCSTR name, const VALUE* argv, uint argc, VALUE* retval );
257 | SCDOM_RESULT SCAPI SciterEvalElementScript( HELEMENT he, LPCWSTR script, uint scriptLength, VALUE* retval );
258 | SCDOM_RESULT SCAPI SciterAttachHwndToElement(HELEMENT he, HWINDOW hwnd);+/
259 |
260 | enum CTL_TYPE : uint
261 | {
262 | CTL_NO, ///< This dom element has no behavior at all.
263 | CTL_UNKNOWN = 1, ///< This dom element has behavior but its type is unknown.
264 | CTL_EDIT, ///< Single line edit box.
265 | CTL_NUMERIC, ///< Numeric input with optional spin buttons.
266 | CTL_CLICKABLE, ///< toolbar button, behavior:clickable.
267 | CTL_BUTTON, ///< Command button.
268 | CTL_CHECKBOX, ///< CheckBox (button).
269 | CTL_RADIO, ///< OptionBox (button).
270 | CTL_SELECT_SINGLE, ///< Single select, ListBox or TreeView.
271 | CTL_SELECT_MULTIPLE, ///< Multiselectable select, ListBox or TreeView.
272 | CTL_DD_SELECT, ///< Dropdown single select.
273 | CTL_TEXTAREA, ///< Multiline TextBox.
274 | CTL_HTMLAREA, ///< WYSIWYG HTML editor.
275 | CTL_PASSWORD, ///< Password input element.
276 | CTL_PROGRESS, ///< Progress element.
277 | CTL_SLIDER, ///< Slider input element.
278 | CTL_DECIMAL, ///< Decimal number input element.
279 | CTL_CURRENCY, ///< Currency input element.
280 | CTL_SCROLLBAR,
281 |
282 | CTL_HYPERLINK,
283 |
284 | CTL_MENUBAR,
285 | CTL_MENU,
286 | CTL_MENUBUTTON,
287 |
288 | CTL_CALENDAR,
289 | CTL_DATE,
290 | CTL_TIME,
291 |
292 | CTL_FRAME,
293 | CTL_FRAMESET,
294 |
295 | CTL_GRAPHICS,
296 | CTL_SPRITE,
297 |
298 | CTL_LIST,
299 | CTL_RICHTEXT,
300 | CTL_TOOLTIP,
301 |
302 | CTL_HIDDEN,
303 | CTL_URL, ///< URL input element.
304 | CTL_TOOLBAR,
305 |
306 | CTL_FORM,
307 | CTL_FILE, ///< file input element.
308 | CTL_PATH, ///< path input element.
309 | CTL_WINDOW, ///< has HWND attached to it
310 |
311 | CTL_LABEL,
312 | CTL_IMAGE, ///< image/object.
313 | }
314 |
315 | /+SCDOM_RESULT SCAPI SciterControlGetType( HELEMENT he, /*CTL_TYPE*/ uint *pType );
316 | SCDOM_RESULT SCAPI SciterGetValue( HELEMENT he, VALUE* pval );
317 | SCDOM_RESULT SCAPI SciterSetValue( HELEMENT he, const VALUE* pval );
318 | SCDOM_RESULT SCAPI SciterGetExpando( HELEMENT he, VALUE* pval, BOOL forceCreation );
319 | SCDOM_RESULT SCAPI SciterGetObject( HELEMENT he, tiscript_value* pval, BOOL forceCreation );
320 | SCDOM_RESULT SCAPI SciterGetElementNamespace( HELEMENT he, tiscript_value* pval);
321 | SCDOM_RESULT SCAPI SciterGetHighlightedElement(HWINDOW hwnd, HELEMENT* phe);
322 | SCDOM_RESULT SCAPI SciterSetHighlightedElement(HWINDOW hwnd, HELEMENT he);
323 | SCDOM_RESULT SCAPI SciterNodeAddRef(HNODE hn);
324 | SCDOM_RESULT SCAPI SciterNodeRelease(HNODE hn);
325 | SCDOM_RESULT SCAPI SciterNodeCastFromElement(HELEMENT he, HNODE* phn);
326 | SCDOM_RESULT SCAPI SciterNodeCastToElement(HNODE hn, HELEMENT* he);
327 | SCDOM_RESULT SCAPI SciterNodeFirstChild(HNODE hn, HNODE* phn);
328 | SCDOM_RESULT SCAPI SciterNodeLastChild(HNODE hn, HNODE* phn);
329 | SCDOM_RESULT SCAPI SciterNodeNextSibling(HNODE hn, HNODE* phn);
330 | SCDOM_RESULT SCAPI SciterNodePrevSibling(HNODE hn, HNODE* phn);
331 | SCDOM_RESULT SCAPI SciterNodeParent(HNODE hnode, HELEMENT* pheParent);
332 | SCDOM_RESULT SCAPI SciterNodeNthChild(HNODE hnode, uint n, HNODE* phn);
333 | SCDOM_RESULT SCAPI SciterNodeChildrenCount(HNODE hnode, uint* pn);+/
334 |
335 | enum NODE_TYPE : uint
336 | {
337 | NT_ELEMENT,
338 | NT_TEXT,
339 | NT_COMMENT
340 | }
341 |
342 | /+SCDOM_RESULT SCAPI SciterNodeType(HNODE hnode, uint* pNodeType /*NODE_TYPE*/);
343 | SCDOM_RESULT SCAPI SciterNodeGetText(HNODE hnode, LPCWSTR_RECEIVER* rcv, void* rcv_param);
344 | SCDOM_RESULT SCAPI SciterNodeSetText(HNODE hnode, LPCWSTR text, uint textLength);+/
345 |
346 | enum NODE_INS_TARGET : uint
347 | {
348 | NIT_BEFORE,
349 | NIT_AFTER,
350 | NIT_APPEND,
351 | NIT_PREPEND,
352 | }
353 |
354 | /+SCDOM_RESULT SCAPI SciterNodeInsert(HNODE hnode, uint where /*NODE_INS_TARGET*/, HNODE what);
355 | SCDOM_RESULT SCAPI SciterNodeRemove(HNODE hnode, BOOL finalize);
356 | SCDOM_RESULT SCAPI SciterCreateTextNode(LPCWSTR text, uint textLength, HNODE* phnode);
357 | SCDOM_RESULT SCAPI SciterCreateCommentNode(LPCWSTR text, uint textLength, HNODE* phnode);+/
358 | }
--------------------------------------------------------------------------------
/source/sciter/interop/sciter_x_graphics.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_graphics;
22 |
23 | public import sciter.types;
24 |
25 |
--------------------------------------------------------------------------------
/source/sciter/interop/sciter_x_types.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_types;
22 |
23 | public import sciter.types;
24 |
25 |
26 | version(all)
27 | {
28 | alias ubyte BYTE;
29 | alias int BOOL;
30 | alias const(BYTE)* LPCBYTE;
31 | alias size_t UINT_PTR;
32 |
33 | alias wchar WCHAR;
34 | alias wchar* LPWSTR;
35 | alias const(wchar*) LPCWSTR;
36 | alias const(char*) LPCSTR;
37 |
38 | struct POINT
39 | {
40 | int x;
41 | int y;
42 | }
43 |
44 | struct SIZE
45 | {
46 | int cx;
47 | int cy;
48 | }
49 |
50 | struct RECT
51 | {
52 | int left;
53 | int top;
54 | int right;
55 | int bottom;
56 | }
57 | }
58 |
59 |
60 | version(Windows)
61 | {
62 | alias void* HWND;
63 | alias HWND HWINDOW;
64 |
65 | alias size_t WPARAM;
66 | alias size_t LPARAM;
67 | alias size_t LRESULT;
68 |
69 | alias void* ID2D1RenderTarget;
70 | alias void* ID2D1Factory;
71 | alias void* IDWriteFactory;
72 |
73 | struct MSG
74 | {
75 | HWND hwnd;
76 | uint message;
77 | WPARAM wParam;
78 | LPARAM lParam;
79 | uint time;
80 | POINT pt;
81 | }
82 |
83 | struct FILETIME
84 | {
85 | uint dwLowDateTime;
86 | uint dwHighDateTime;
87 | }
88 | }
89 | version(OSX)
90 | {
91 | alias void* HWINDOW;// NSView*
92 | }
93 | version(linux)
94 | {
95 | import gtkc.gtktypes;
96 | alias GtkWidget* HWINDOW;
97 | }
--------------------------------------------------------------------------------
/source/sciter/interop/sciter_x_value.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_value;
22 |
23 | // Contents:
24 | // sciter-x-value.h - ported here
25 | // value.h - ported here the extern declarations, there is no value.di file, its all located here
26 | //
27 | // This port has no json::value, but rather an equivalent 'struct json_value' at 'sciter.sciter_value'
28 |
29 | import sciter.interop.sciter_x_types;
30 |
31 |
32 | extern(Windows)
33 | {
34 | enum VALUE_RESULT
35 | {
36 | HV_OK_TRUE = -1,
37 | HV_OK = 0,
38 | HV_BAD_PARAMETER = 1,
39 | HV_INCOMPATIBLE_TYPE = 2
40 | }
41 |
42 | struct VALUE
43 | {
44 | uint t;// enum VALUE_TYPE
45 | uint u;
46 | long d;
47 | }
48 |
49 | alias double FLOAT_VALUE;
50 | alias LPCBYTE LPCBYTES;
51 |
52 |
53 | enum VALUE_TYPE : uint
54 | {
55 | T_UNDEFINED = 0,
56 | T_NULL = 1,
57 | T_BOOL,
58 | T_INT,
59 | T_FLOAT,
60 | T_STRING,
61 | T_DATE, // INT64 - contains a 64-bit value representing the number of 100-nanosecond intervals since January 1, 1601 (UTC), a.k.a. FILETIME on Windows
62 | T_CURRENCY, // INT64 - 14.4 fixed number. E.g. dollars = int64 / 10000;
63 | T_LENGTH, // length units, value is int or float, units are VALUE_UNIT_TYPE
64 | T_ARRAY,
65 | T_MAP,
66 | T_FUNCTION,
67 | T_BYTES, // sequence of bytes - e.g. image data
68 | T_OBJECT, // scripting object proxy (TISCRIPT/SCITER)
69 | T_DOM_OBJECT // DOM object (CSSS!), use get_object_data to get HELEMENT
70 | }
71 |
72 | enum VALUE_UNIT_TYPE
73 | {
74 | UT_EM = 1, //height of the element's font.
75 | UT_EX = 2, //height of letter 'x'
76 | UT_PR = 3, //%
77 | UT_SP = 4, //%% "springs", a.k.a. flex units
78 | reserved1 = 5,
79 | reserved2 = 6,
80 | UT_PX = 7, //pixels
81 | UT_IN = 8, //inches (1 inch = 2.54 centimeters).
82 | UT_CM = 9, //centimeters.
83 | UT_MM = 10, //millimeters.
84 | UT_PT = 11, //points (1 point = 1/72 inches).
85 | UT_PC = 12, //picas (1 pica = 12 points).
86 | UT_DIP = 13,
87 | reserved3 = 14,
88 | UT_COLOR = 15, // color in int
89 | UT_URL = 16, // url in string
90 | }
91 |
92 | enum VALUE_UNIT_TYPE_DATE
93 | {
94 | DT_HAS_DATE = 0x01, // date contains date portion
95 | DT_HAS_TIME = 0x02, // date contains time portion HH:MM
96 | DT_HAS_SECONDS = 0x04, // date contains time and seconds HH:MM:SS
97 | DT_UTC = 0x10, // T_DATE is known to be UTC. Otherwise it is local date/time
98 | }
99 |
100 | enum VALUE_UNIT_TYPE_OBJECT
101 | {
102 | UT_OBJECT_ARRAY = 0, // type T_OBJECT of type Array
103 | UT_OBJECT_OBJECT = 1, // type T_OBJECT of type Object
104 | UT_OBJECT_CLASS = 2, // type T_OBJECT of type Type (class or namespace)
105 | UT_OBJECT_NATIVE = 3, // type T_OBJECT of native Type with data slot (void*)
106 | UT_OBJECT_FUNCTION = 4, // type T_OBJECT of type Function
107 | UT_OBJECT_ERROR = 5, // type T_OBJECT of type Error
108 | }
109 |
110 | // Sciter or TIScript specific
111 | enum VALUE_UNIT_TYPE_STRING
112 | {
113 | UT_STRING_STRING = 0, // string
114 | UT_STRING_ERROR = 1, // is an error string
115 | UT_STRING_SECURE = 2, // secure string ("wiped" on destroy)
116 | UT_STRING_SYMBOL = 0xffff // symbol in tiscript sense
117 | }
118 |
119 | // Native functor
120 | alias NATIVE_FUNCTOR_INVOKE = void function(void* tag, uint argc, const VALUE* argv, VALUE* retval);// retval may contain error definition
121 | alias NATIVE_FUNCTOR_RELEASE = void function(void* tag);
122 |
123 |
124 | // we should NOT impose here enum types in place of uints cause the above enum's dont defines all the possible values (mainly 0)
125 | /+EXTERN_C uint VALAPI ValueInit( VALUE* pval );
126 | EXTERN_C uint VALAPI ValueClear( VALUE* pval );
127 | EXTERN_C uint VALAPI ValueCompare( const VALUE* pval1, const VALUE* pval2 );
128 | EXTERN_C uint VALAPI ValueCopy( VALUE* pdst, const VALUE* psrc );
129 | EXTERN_C uint VALAPI ValueIsolate( VALUE* pdst );
130 | EXTERN_C uint VALAPI ValueType( const VALUE* pval, uint* pType, uint* pUnits );
131 | EXTERN_C uint VALAPI ValueStringData( const VALUE* pval, LPCWSTR* pChars, uint* pNumChars );
132 | EXTERN_C uint VALAPI ValueStringDataSet( VALUE* pval, LPCWSTR chars, uint numChars, uint units );
133 | EXTERN_C uint VALAPI ValueIntData( const VALUE* pval, INT* pData );
134 | EXTERN_C uint VALAPI ValueIntDataSet( VALUE* pval, INT data, uint type, uint units );
135 | EXTERN_C uint VALAPI ValueInt64Data( const VALUE* pval, INT64* pData );
136 | EXTERN_C uint VALAPI ValueInt64DataSet( VALUE* pval, INT64 data, uint type, uint units );
137 | EXTERN_C uint VALAPI ValueFloatData( const VALUE* pval, FLOAT_VALUE* pData );
138 | EXTERN_C uint VALAPI ValueFloatDataSet( VALUE* pval, FLOAT_VALUE data, uint type, uint units );
139 | EXTERN_C uint VALAPI ValueBinaryData( const VALUE* pval, LPCBYTE* pBytes, uint* pnBytes );
140 | EXTERN_C uint VALAPI ValueBinaryDataSet( VALUE* pval, LPCBYTE pBytes, uint nBytes, uint type, uint units );
141 | EXTERN_C uint VALAPI ValueElementsCount( const VALUE* pval, INT* pn);
142 | EXTERN_C uint VALAPI ValueNthElementValue( const VALUE* pval, INT n, VALUE* pretval);
143 | EXTERN_C uint VALAPI ValueNthElementValueSet( VALUE* pval, INT n, const VALUE* pval_to_set);+/
144 | alias BOOL function(void* param, const VALUE* pkey, const VALUE* pval) KeyValueCallback;
145 | /+EXTERN_C uint VALAPI ValueNthElementKey( const VALUE* pval, INT n, VALUE* pretval);
146 | EXTERN_C uint VALAPI ValueEnumElements( VALUE* pval, KeyValueCallback* penum, void* param);
147 | EXTERN_C uint VALAPI ValueSetValueToKey( VALUE* pval, const VALUE* pkey, const VALUE* pval_to_set);
148 | EXTERN_C uint VALAPI ValueGetValueOfKey( const VALUE* pval, const VALUE* pkey, VALUE* pretval);+/
149 |
150 | enum VALUE_STRING_CVT_TYPE : uint
151 | {
152 | CVT_SIMPLE, ///< simple conversion of terminal values
153 | CVT_JSON_LITERAL, ///< json literal parsing/emission
154 | CVT_JSON_MAP, ///< json parsing/emission, it parses as if token '{' already recognized
155 | CVT_XJSON_LITERAL, ///< x-json parsing/emission, date is emitted as ISO8601 date literal, currency is emitted in the form DDDD$CCC
156 | }
157 |
158 | /+EXTERN_C uint VALAPI ValueToString( VALUE* pval, /*VALUE_STRING_CVT_TYPE*/ uint how );
159 | EXTERN_C uint VALAPI ValueFromString( VALUE* pval, LPCWSTR str, uint strLength, /*VALUE_STRING_CVT_TYPE*/ uint how );
160 | EXTERN_C uint VALAPI ValueInvoke( VALUE* pval, VALUE* pthis, uint argc, const VALUE* argv, VALUE* pretval, LPCWSTR url);
161 | EXTERN_C uint VALAPI ValueNativeFunctorSet( VALUE* pval, struct NATIVE_FUNCTOR_VALUE* pnfv);
162 | EXTERN_C BOOL VALAPI ValueIsNativeFunctor( const VALUE* pval);+/
163 | }
164 |
--------------------------------------------------------------------------------
/source/sciter/interop/tiscript.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.tiscript;
22 |
23 | import sciter.interop.sciter_x_types;
24 |
25 |
26 | struct tiscript_VM;
27 | alias tiscript_value = ulong;
28 | alias HVM = tiscript_VM*;
29 | //alias value = tiscript_value;// do not use these, instead use the original names
30 | //alias VM = tiscript_VM;
31 |
32 |
33 | struct tiscript_pvalue
34 | {
35 | tiscript_value val;
36 | tiscript_VM* vm;
37 | void* d1;
38 | void* d2;
39 | }
40 |
41 |
42 | // to be completed ..
43 | struct tiscript_native_interface;
--------------------------------------------------------------------------------
/source/sciter/sciter_value.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.sciter_value;
22 |
23 | import std.conv;
24 |
25 | import sciter.interop.sciter_x;
26 | import sciter.interop.sciter_x_types;
27 | import sciter.api;
28 | public import sciter.interop.sciter_x_value;
29 |
30 |
31 | unittest
32 | {
33 | json_value jv = json_value(3);
34 | assert(jv.to_json_string()=="3");
35 |
36 | json_value jarr = json_value.from_array([1,2,3]);
37 | assert(jarr.to_json_string(VALUE_STRING_CVT_TYPE.CVT_JSON_LITERAL)=="[1, 2, 3]");
38 | assert(jarr.get_item(2).get(0)==3);
39 |
40 | json_value jassoc1 = [
41 | "key1"w : 1,
42 | "key2"w : 2,
43 | ];
44 | json_value jassoc2 = [
45 | "key1"w : json_value(1),
46 | "key2"w : json_value(2),
47 | ];
48 | assert(jassoc1.to_json_string() == jassoc2.to_json_string());
49 | }
50 |
51 |
52 | /*
53 | Obs:
54 | .ValueXXX() functions return uint type, result code is VALUE_RESULT enumeration
55 | */
56 |
57 | struct json_value
58 | {
59 | private:
60 | VALUE data;// don't directly access this, instead use the implicit cast operators
61 |
62 | public:
63 | alias toVALUE this;// a.k.a. implicit cast operator to VALUE
64 |
65 | @property VALUE toVALUE()
66 | {
67 | // increase ref-count for converting json_value to VALUE
68 | VALUE vcopy;
69 | .ValueInit(&vcopy);
70 | .ValueCopy(&vcopy, &data);
71 | return vcopy;
72 | }
73 |
74 | @property const(VALUE*) toVALUEptr()
75 | {
76 | return &data;
77 | }
78 |
79 | this(this)
80 | {
81 | VALUE copy = data;
82 | .ValueInit(&data);
83 | .ValueCopy(&data, ©);
84 | }
85 | this(json_value* src) { .ValueInit(&data); .ValueCopy(&data, &src.data); }
86 | this(ref json_value src){ .ValueInit(&data); .ValueCopy(&data, &src.data); }
87 | this(ref VALUE srcv) { .ValueInit(&data); .ValueCopy(&data, &srcv); }// move semantics? dont know, so better not even mess with it, cause this is working fine
88 | this(VALUE srcv) { .ValueInit(&data); .ValueCopy(&data, &srcv); }
89 | ~this() { .ValueClear(&data); }
90 |
91 | // TODO: port assignment operator (operation not very fitted for D?)
92 | //value& operator = (const value& src) { ValueCopy(this,&src); return *this; }
93 | //value& operator = (const VALUE& src) { ValueCopy(this,&src); return *this; }
94 |
95 | this(bool v) { .ValueInit(&data); .ValueIntDataSet(&data, v?1:0, VALUE_TYPE.T_BOOL, 0); }
96 | this(int v) { .ValueInit(&data); .ValueIntDataSet(&data, v, VALUE_TYPE.T_INT, 0); }
97 | this(double v) { .ValueInit(&data); .ValueFloatDataSet(&data, v, VALUE_TYPE.T_FLOAT, 0); }
98 |
99 | this(wstring str) { .ValueInit(&data); .ValueStringDataSet(&data, str.ptr, cast(uint) str.length, VALUE_UNIT_TYPE_STRING.UT_STRING_STRING); }
100 | this(in BYTE[] bs) { .ValueInit(&data); .ValueBinaryDataSet(&data, bs.ptr, cast(uint) bs.length, VALUE_TYPE.T_BYTES, 0); }
101 |
102 | this(in json_value[] arr) { .ValueInit(&data); foreach(i, ref a; arr) set_item(cast(uint)i, a); }
103 | this(T)(in T[wstring] assocarr)
104 | {
105 | .ValueInit(&data);
106 | foreach(key; assocarr.keys)
107 | set_item( make_symbol(key), json_value(assocarr[key]) );
108 | }
109 | this(in json_value[wstring] assocarr)
110 | {
111 | .ValueInit(&data);
112 | foreach(key; assocarr.keys)
113 | set_item( make_symbol(key), assocarr[key] );
114 | }
115 |
116 | static json_value from_array(T)(in T[] arr)// could not make it a this() constructor because of ambiguity - midi
117 | {
118 | json_value jv;
119 | foreach(i, ref a; arr)
120 | jv.set_item(i, json_value(a));
121 | return jv;
122 | }
123 |
124 | // new replacement: toVALUE() + implicity cast operator see line 49
125 | /*VALUE copy()// added by sciter-dport - midi
126 | {
127 | VALUE vcopy;
128 | .ValueInit(&vcopy);
129 | .ValueCopy(&vcopy, &data);
130 | return vcopy;
131 | }*/
132 |
133 | /*override bool opEquals(Object o) const
134 | {
135 | auto cv = cast(const value) o;
136 | return this==cv.data;
137 | }
138 |
139 | bool opEquals(VALUE v) const
140 | {
141 | switch( .ValueCompare(&data, &v) )
142 | {
143 | case VALUE_RESULT.HV_OK: return false;
144 | case VALUE_RESULT.HV_OK_TRUE: return true;
145 | default: assert(false);
146 | }
147 | return false;
148 | }*/
149 |
150 |
151 |
152 | /*static value currency( INT64 v ) { value t = new value; .ValueInt64DataSet(&t.data, v, VALUE_TYPE.T_CURRENCY, 0); return t; }
153 | static value date( INT64 v ) { value t = new value; .ValueInt64DataSet(&t.data, v, VALUE_TYPE.T_DATE, 0); return t; }
154 | static value date( FILETIME ft ) { value t = new value; .ValueInt64DataSet(&t.data, *cast(INT64*)&ft, VALUE_TYPE.T_DATE, 0); return t; }
155 | static value symbol( wstring s ) { value t = new value; .ValueInit(&t.data); .ValueStringDataSet(&t.data, s.ptr, s.length, VALUE_UNIT_TYPE.UT_SYMBOL); return t; }
156 | */
157 |
158 | static json_value secure_string(wstring s)// what is a secure string? - midi
159 | {
160 | json_value jv;
161 | .ValueStringDataSet(&jv.data, s.ptr, cast(uint) s.length, VALUE_UNIT_TYPE_STRING.UT_STRING_SECURE);
162 | return jv;
163 | }
164 |
165 |
166 | /+
167 | Returns json_value representing error.
168 | If such value is used as a return value from native function the script runtime will throw an error in script rather than returning that value.
169 | +/
170 | static json_value make_error(wstring s)
171 | {
172 | json_value jv;
173 | if(!s)
174 | return jv;
175 | .ValueStringDataSet(&jv.data, s.ptr, cast(uint) s.length, VALUE_UNIT_TYPE_STRING.UT_STRING_ERROR);
176 | return jv;
177 | }
178 |
179 | static json_value make_symbol(wstring s)
180 | {
181 | json_value jv;
182 | if(!s)
183 | return jv;
184 | .ValueStringDataSet(&jv.data, s.ptr, cast(uint) s.length, VALUE_UNIT_TYPE_STRING.UT_STRING_SYMBOL);
185 | return jv;
186 | }
187 |
188 | bool is_undefined() const { return data.t == VALUE_TYPE.T_UNDEFINED; }
189 | bool is_bool() const { return data.t == VALUE_TYPE.T_BOOL; }
190 | bool is_int() const { return data.t == VALUE_TYPE.T_INT; }
191 | bool is_float() const { return data.t == VALUE_TYPE.T_FLOAT; }
192 | bool is_string() const { return data.t == VALUE_TYPE.T_STRING; }
193 | bool is_symbol() const { return data.t == VALUE_TYPE.T_STRING && data.u == VALUE_UNIT_TYPE_STRING.UT_STRING_SYMBOL; }
194 | bool is_error_string() const { return data.t == VALUE_TYPE.T_STRING && data.u == VALUE_UNIT_TYPE_STRING.UT_STRING_ERROR; }
195 | bool is_date() const { return data.t == VALUE_TYPE.T_DATE; }
196 | bool is_currency() const { return data.t == VALUE_TYPE.T_CURRENCY; }
197 | bool is_map() const { return data.t == VALUE_TYPE.T_MAP; }
198 | bool is_array() const { return data.t == VALUE_TYPE.T_ARRAY; }
199 | bool is_function() const { return data.t == VALUE_TYPE.T_FUNCTION; }
200 | bool is_bytes() const { return data.t == VALUE_TYPE.T_BYTES; }
201 | bool is_object() const { return data.t == VALUE_TYPE.T_OBJECT; }
202 | bool is_dom_element() const { return data.t == VALUE_TYPE.T_DOM_OBJECT; }
203 | bool is_native_function() const { return !!ValueIsNativeFunctor(&data); }
204 | bool is_null() const { return data.t == VALUE_TYPE.T_NULL; }
205 |
206 | static json_value nullval() { json_value t; t.data.t = VALUE_TYPE.T_NULL; return t; } // sciter-dport: null is a reserved D identifier,
207 | // so I renamed this functions from null() to nullval() - midi
208 |
209 | bool get(bool defv)
210 | {
211 | int v;
212 | if(.ValueIntData(&data,&v) == VALUE_RESULT.HV_OK) return v != 0;
213 | return defv;
214 | }
215 | int get(int defv)
216 | {
217 | int v;
218 | if(.ValueIntData(&data,&v) == VALUE_RESULT.HV_OK) return v;
219 | return defv;
220 | }
221 | double get(double defv)
222 | {
223 | double v;
224 | if(.ValueFloatData(&data,&v) == VALUE_RESULT.HV_OK) return v;
225 | return defv;
226 | }
227 | wstring get(wstring defv)
228 | {
229 | LPCWSTR ret_pstr;
230 | uint ret_length;
231 | if(.ValueStringData(&data, &ret_pstr, &ret_length) == VALUE_RESULT.HV_OK)
232 | return ret_pstr[0..ret_length].idup;
233 | return defv;
234 | }
235 | wchar[] get_chars()// tested and you do can use this to modify the internal buffer of the string maintained by Sciter
236 | {
237 | LPCWSTR ret_pstr;
238 | uint ret_length;
239 | .ValueStringData(&data, &ret_pstr, &ret_length) == VALUE_RESULT.HV_OK || assert(false);
240 | return (cast(LPWSTR)ret_pstr) [0..ret_length];
241 | }
242 | const(BYTE[]) get_bytes()// same as get_chars()
243 | {
244 | LPCBYTE ret_ptr;
245 | uint ret_length;
246 | .ValueBinaryData(&data, &ret_ptr, &ret_length);
247 | return (ret_ptr)[0..ret_length];
248 | }
249 |
250 | version(Windows)
251 | {
252 | FILETIME get_date()
253 | {
254 | FILETIME v;
255 | .ValueInt64Data(&data,cast(long*) &v);
256 | return v;
257 | }
258 | }
259 |
260 | static VALUE from_json_string(wstring s, VALUE_STRING_CVT_TYPE ct = VALUE_STRING_CVT_TYPE.CVT_SIMPLE)
261 | {
262 | VALUE v;
263 | .ValueFromString(&v, s.ptr, cast(uint)s.length, ct);
264 | return v;
265 | }
266 |
267 | wstring to_json_string(VALUE_STRING_CVT_TYPE ct_how = VALUE_STRING_CVT_TYPE.CVT_JSON_LITERAL)
268 | {
269 | if( ct_how == VALUE_STRING_CVT_TYPE.CVT_SIMPLE && is_string() )
270 | return get_chars().idup;
271 |
272 | json_value v = data;
273 | .ValueToString(&v.data, ct_how);// as in SDK: ValueToString converts value to T_STRING inplace
274 | // trickie thing, grr, who owns this VALUE now? guess me
275 | return v.get_chars().idup;
276 | }
277 |
278 | void clear()
279 | {
280 | .ValueClear(&data);
281 | }
282 |
283 | int length()
284 | {
285 | int n;
286 | .ValueElementsCount(&data, &n);
287 | return n;
288 | }
289 |
290 |
291 | json_value get_item(int n)
292 | {
293 | json_value val;
294 | .ValueNthElementValue(&data, n, &val.data);
295 | return val;
296 | }
297 |
298 | /*
299 | const value operator[](int n) const { return get_item(n); }
300 | value_idx_a operator[](int n);
301 |
302 | const value operator[](const value& key) const { return get_item(key); }
303 | value_key_a operator[](const value& key);
304 | */
305 |
306 | /*struct enum_cb
307 | {
308 | // return true to continue enumeration
309 | virtual bool on(const value& key, const value& val) = 0;
310 | static BOOL CALLBACK _callback( void* param, const VALUE* pkey, const VALUE* pval )
311 | {
312 | enum_cb* cb = (enum_cb*)param;
313 | return cb->on( *(value*)pkey, *(value*)pval );
314 | }
315 | };
316 |
317 | // enum
318 | void enum_elements(enum_cb& cb) const
319 | {
320 | ValueEnumElements(const_cast(this), &enum_cb::_callback, &cb);
321 | }*/
322 |
323 | /*value key(int n)
324 | {
325 | value r = new value;
326 | .ValueNthElementKey(&data, n, &r.data);
327 | return r;
328 | }*/
329 |
330 | void set_item(int n, immutable json_value v)
331 | {
332 | .ValueNthElementValueSet(&data, n, &v.data);
333 | }
334 |
335 | void append(immutable json_value v)
336 | {
337 | .ValueNthElementValueSet(&data, length(), &v.data);
338 | }
339 |
340 | void set_item(immutable json_value key, immutable json_value v)
341 | {
342 | .ValueSetValueToKey(&data, &key.data, &v.data);
343 | }
344 |
345 | VALUE get_item(json_value key)
346 | {
347 | VALUE r;
348 | .ValueGetValueOfKey(&data, &key.data, &r);
349 | return r;
350 | }
351 |
352 | void set_object_data(void* pv)
353 | {
354 | assert(data.u == VALUE_UNIT_TYPE_OBJECT.UT_OBJECT_NATIVE);
355 | .ValueBinaryDataSet(&data, cast(LPCBYTES)pv, 1, VALUE_TYPE.T_OBJECT, 0);//shouldnt be dereferencing pv?
356 | }
357 | void* get_object_data()
358 | {
359 | LPCBYTES pv; uint dummy;
360 | .ValueBinaryData(&data,&pv,&dummy) == VALUE_RESULT.HV_OK || assert(false);
361 | return cast(void*)pv;
362 | }
363 |
364 |
365 | bool is_object_native() const { return data.t == VALUE_TYPE.T_OBJECT && data.u == VALUE_UNIT_TYPE_OBJECT.UT_OBJECT_NATIVE; }
366 | bool is_object_array() const { return data.t == VALUE_TYPE.T_OBJECT && data.u == VALUE_UNIT_TYPE_OBJECT.UT_OBJECT_ARRAY; }
367 | bool is_object_function() const { return data.t == VALUE_TYPE.T_OBJECT && data.u == VALUE_UNIT_TYPE_OBJECT.UT_OBJECT_FUNCTION; }
368 | bool is_object_object() const { return data.t == VALUE_TYPE.T_OBJECT && data.u == VALUE_UNIT_TYPE_OBJECT.UT_OBJECT_OBJECT; }
369 | bool is_object_class() const { return data.t == VALUE_TYPE.T_OBJECT && data.u == VALUE_UNIT_TYPE_OBJECT.UT_OBJECT_CLASS; }
370 | bool is_object_error() const { return data.t == VALUE_TYPE.T_OBJECT && data.u == VALUE_UNIT_TYPE_OBJECT.UT_OBJECT_ERROR; }
371 |
372 |
373 | // T_OBJECT/UT_OBJECT_FUNCTION only, call TS function
374 | // 'self' here is what will be known as 'this' inside the function, can be undefined for invocations of global functions
375 | VALUE call(const(VALUE)[] args, json_value self = json_value.init, wstring url_or_script_name = null) const
376 | {
377 | assert(is_function() || is_object_function());
378 |
379 | VALUE rv;
380 | .ValueInvoke(&data /*this VALUE*/, &self.data, cast(uint)args.length, args.ptr, &rv, (url_or_script_name ~ '\0').ptr);
381 | return rv;
382 | }
383 | VALUE call(const(json_value)[] args...) const
384 | {
385 | assert(is_function() || is_object_function());
386 | return call(cast(VALUE[])args);
387 | }
388 |
389 | void isolate()
390 | {
391 | .ValueIsolate(&data);
392 | }
393 |
394 | /*static bool equal(in value v1, in value v2)
395 | {
396 | if( v1 == v2 ) return true; // strict comparison
397 | switch ( v1.t > v2.t? v1.t: v2.t )
398 | {
399 | case T_BOOL:
400 | {
401 | bool const r1 = v1.get(false);
402 | bool const r2 = v2.get(!r1);
403 | return r1 == r2;
404 | }
405 | case T_INT:
406 | {
407 | int const r1 = v1.get(0);
408 | int const r2 = v2.get(-r1);
409 | return r1 == r2;
410 | }
411 | case T_FLOAT:
412 | {
413 | double const r1 = v1.get(0.0);
414 | double const r2 = v2.get(-r1);
415 | return r1 == r2;
416 | }
417 | }
418 | return false;
419 | }*/
420 |
421 |
422 | // TODO: port proxy acessors classes (what are they for?)
423 | }
--------------------------------------------------------------------------------
/source/sciter/types.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.types;
22 |
23 | import std.typecons;
24 | version(Linux)
25 | {
26 | public import sciter.sciter_x_types;
27 | }
28 |
29 |
30 | alias HELEMENT = Typedef!(size_t, 0, "HELEMENT");
31 | alias HNODE = Typedef!(size_t, 0, "HNODE");
32 | alias HRANGE = Typedef!(size_t, 0, "HRANGE");
33 | alias HSARCHIVE = Typedef!(size_t, 0, "HSARCHIVE");
34 |
35 | alias HGFX = Typedef!(size_t, 0, "HGFX");
36 | alias HIMG = Typedef!(size_t, 0, "HIMG");
37 | alias HPATH = Typedef!(size_t, 0, "HPATH");
38 | alias HTEXT = Typedef!(size_t, 0, "HTEXT");
39 |
--------------------------------------------------------------------------------
/source/sciter/unittests.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 | /+
22 | Module exclusive for complex unitesting Sciter features
23 | +/
24 | module sciter.unittests;
25 |
26 | import sciter.interop.sciter_x_types;
27 | import sciter.api;
28 |
29 |
30 | version(Windows)
31 | void UnittestWindow(void function(HWINDOW) cbk, string html = null)// add html string parameter
32 | {
33 | // test window creation
34 | RECT frame;
35 | frame.right = 800;
36 | frame.bottom = 600;
37 |
38 | HWINDOW wnd = SciterCreateWindow(
39 | SCITER_CREATE_WINDOW_FLAGS.SW_TITLEBAR |
40 | SCITER_CREATE_WINDOW_FLAGS.SW_RESIZEABLE |
41 | SCITER_CREATE_WINDOW_FLAGS.SW_MAIN |
42 | SCITER_CREATE_WINDOW_FLAGS.SW_CONTROLS,
43 | &frame, null, null, null);
44 |
45 | if(html)
46 | .SciterLoadHtml(wnd, cast(ubyte*)html.ptr, cast(int)html.length, null) || assert(false);
47 |
48 | import core.sys.windows.windows;
49 | cbk(wnd);
50 | ShowWindow(wnd, 1);
51 | PostQuitMessage(0);
52 |
53 | MSG msg;
54 | while( GetMessageA(&msg, null, 0, 0) )
55 | {
56 | TranslateMessage(&msg);
57 | DispatchMessageA(&msg);
58 | }
59 | }
--------------------------------------------------------------------------------
/source/winkit/DropFileTarget.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 winkit.DropFileTarget;
22 |
23 |
24 | mixin template DropFileTarget()
25 | {
26 | public:
27 | //-----------------------------------------------------------------------------
28 | // Function name : RegisterDropTarget
29 | // Description : Registers whether a window accepts dropped files
30 | // Return type : None
31 | // Parameter : boolean indicator
32 | // TRUE - window accepts dropped files
33 | // FALSE - window does not accept dropped files
34 | //-----------------------------------------------------------------------------
35 | void RegisterDropTarget(BOOL bAccept = TRUE)
36 | {
37 | import winkit.WinAPI;
38 |
39 | assert(IsWindow(wnd));
40 |
41 | // Turn the WS_EX_ACCEPTFILES style on or off based on the value of the
42 | // bAccept parameter
43 | DragAcceptFiles(wnd, bAccept);
44 |
45 | /*version(Windows7)
46 | {
47 | ChangeWindowMessageFilter(WM_DROPFILES, 1);
48 | ChangeWindowMessageFilter(WM_COPYDATA, 1);
49 | ChangeWindowMessageFilter(0x0049, 1);
50 | }*/
51 | }
52 |
53 |
54 | private:
55 |
56 | //-----------------------------------------------------------------------------
57 | // Function name : OnDropFiles
58 | // Description : Handler for WM_DROPFILES message
59 | // Return type : LRESULT
60 | // Parameter :
61 | //-----------------------------------------------------------------------------
62 | void OnDropFiles(HDROP hDropInfo)
63 | {
64 | import winkit.WinAPI;
65 |
66 | // Get the count of the files dropped
67 | int nNumFiles = DragQueryFileW(hDropInfo, 0xFFFFFFFF, null, 0);
68 |
69 | // Get the path size
70 | UINT sz = DragQueryFileW(hDropInfo, 0, null, 0)+1;
71 |
72 | // Get the path of a single file that has been dropped
73 | wchar[] buffFilename = new wchar[sz];
74 | DragQueryFileW(hDropInfo, 0, buffFilename.ptr, sz);
75 | buffFilename.length = sz-1;// removes the \0
76 |
77 | // Release the memory that the system allocated for use in transferring file
78 | // names to the application
79 | DragFinish(hDropInfo);
80 |
81 | // Call the function to process the file name
82 | string filepath = to!string(buffFilename.idup);
83 | ProcessFile(filepath, nNumFiles);
84 | }
85 | }
--------------------------------------------------------------------------------
/source/winkit/GDI.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 winkit.GDI;
22 |
23 | import core.sys.windows.windows;
24 |
25 |
26 | int Width(RECT rc)
27 | { return rc.right - rc.left; }
28 | int Height(RECT rc)
29 | { return rc.bottom - rc.top; }
--------------------------------------------------------------------------------
/source/winkit/MessageBox.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 winkit.MessageBox;
22 |
23 | import winkit.Window;
24 | import winkit.WinAPI;
25 |
26 |
27 | public void Show(wstring msg, Window wnd_owner)
28 | {
29 | MessageBoxW(wnd_owner, (msg ~ '\0').ptr, null, MB_OK | MB_ICONEXCLAMATION);
30 | }
--------------------------------------------------------------------------------
/source/winkit/WinAPI.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 winkit.WinAPI;
22 |
23 |
24 | // This is Windows API declarations
25 | // I am declaring here just the stuff needed for Sciter-DPort in a more strongly typed way, i.e., auto-completion friendly
26 | // It is basically a copy and paste from the druntime 'core.sys.windows.*'
27 | public import core.sys.windows.windows;
28 |
29 |
30 | alias HWND = HANDLE;
31 | alias HDROP = HANDLE;
32 | alias HMONITOR = HANDLE;
33 |
34 | alias HRESULT = size_t;
35 | alias DWORD = uint;
36 | alias BOOL = int;
37 | alias PCVOID = const(void)*;
38 | alias LPCVOID = PCVOID;
39 |
40 | enum NULL = null;
41 | enum GWL_EXSTYLE = -20;
42 | enum GWL_STYLE = -16;
43 | enum GWLP_WNDPROC = -4;
44 | enum SC_KEYMENU = 0xF100;
45 |
46 |
47 | enum : uint
48 | {
49 | WM_NULL = 0x0000,
50 | WM_CREATE = 0x0001,
51 | WM_DESTROY = 0x0002,
52 | WM_MOVE = 0x0003,
53 | WM_SIZE = 0x0005,
54 | WM_ACTIVATE = 0x0006,
55 | WM_SETFOCUS = 0x0007,
56 | WM_KILLFOCUS = 0x0008,
57 | WM_ENABLE = 0x000A,
58 | WM_SETREDRAW = 0x000B,
59 | WM_SETTEXT = 0x000C,
60 | WM_GETTEXT = 0x000D,
61 | WM_GETTEXTLENGTH = 0x000E,
62 | WM_PAINT = 0x000F,
63 | WM_CLOSE = 0x0010,
64 | WM_QUERYENDSESSION = 0x0011,
65 | WM_QUERYOPEN = 0x0013,
66 | WM_ENDSESSION = 0x0016,
67 | WM_QUIT = 0x0012,
68 | WM_ERASEBKGND = 0x0014,
69 | WM_SYSCOLORCHANGE = 0x0015,
70 | WM_SHOWWINDOW = 0x0018,
71 | WM_WININICHANGE = 0x001A,
72 | WM_SETTINGCHANGE = WM_WININICHANGE,
73 | WM_DEVMODECHANGE = 0x001B,
74 | WM_ACTIVATEAPP = 0x001C,
75 | WM_FONTCHANGE = 0x001D,
76 | WM_TIMECHANGE = 0x001E,
77 | WM_CANCELMODE = 0x001F,
78 | WM_SETCURSOR = 0x0020,
79 | WM_MOUSEACTIVATE = 0x0021,
80 | WM_CHILDACTIVATE = 0x0022,
81 | WM_QUEUESYNC = 0x0023,
82 | WM_GETMINMAXINFO = 0x0024,
83 | WM_PAINTICON = 0x0026,
84 | WM_ICONERASEBKGND = 0x0027,
85 | WM_NEXTDLGCTL = 0x0028,
86 | WM_SPOOLERSTATUS = 0x002A,
87 | WM_DRAWITEM = 0x002B,
88 | WM_MEASUREITEM = 0x002C,
89 | WM_DELETEITEM = 0x002D,
90 | WM_VKEYTOITEM = 0x002E,
91 | WM_CHARTOITEM = 0x002F,
92 | WM_SETFONT = 0x0030,
93 | WM_GETFONT = 0x0031,
94 | WM_SETHOTKEY = 0x0032,
95 | WM_GETHOTKEY = 0x0033,
96 | WM_QUERYDRAGICON = 0x0037,
97 | WM_COMPAREITEM = 0x0039,
98 | WM_GETOBJECT = 0x003D,
99 | WM_COMPACTING = 0x0041,
100 | WM_COMMNOTIFY = 0x0044,
101 | WM_WINDOWPOSCHANGING = 0x0046,
102 | WM_WINDOWPOSCHANGED = 0x0047,
103 | WM_POWER = 0x0048,
104 | WM_COPYDATA = 0x004A,
105 | WM_CANCELJOURNAL = 0x004B,
106 | WM_NOTIFY = 0x004E,
107 | WM_INPUTLANGCHANGEREQUEST = 0x0050,
108 | WM_INPUTLANGCHANGE = 0x0051,
109 | WM_TCARD = 0x0052,
110 | WM_HELP = 0x0053,
111 | WM_USERCHANGED = 0x0054,
112 | WM_NOTIFYFORMAT = 0x0055,
113 | WM_CONTEXTMENU = 0x007B,
114 | WM_STYLECHANGING = 0x007C,
115 | WM_STYLECHANGED = 0x007D,
116 | WM_DISPLAYCHANGE = 0x007E,
117 | WM_GETICON = 0x007F,
118 | WM_SETICON = 0x0080,
119 | WM_NCCREATE = 0x0081,
120 | WM_NCDESTROY = 0x0082,
121 | WM_NCCALCSIZE = 0x0083,
122 | WM_NCHITTEST = 0x0084,
123 | WM_NCPAINT = 0x0085,
124 | WM_NCACTIVATE = 0x0086,
125 | WM_GETDLGCODE = 0x0087,
126 | WM_SYNCPAINT = 0x0088,
127 | WM_NCMOUSEMOVE = 0x00A0,
128 | WM_NCLBUTTONDOWN = 0x00A1,
129 | WM_NCLBUTTONUP = 0x00A2,
130 | WM_NCLBUTTONDBLCLK = 0x00A3,
131 | WM_NCRBUTTONDOWN = 0x00A4,
132 | WM_NCRBUTTONUP = 0x00A5,
133 | WM_NCRBUTTONDBLCLK = 0x00A6,
134 | WM_NCMBUTTONDOWN = 0x00A7,
135 | WM_NCMBUTTONUP = 0x00A8,
136 | WM_NCMBUTTONDBLCLK = 0x00A9,
137 | WM_NCXBUTTONDOWN = 0x00AB,
138 | WM_NCXBUTTONUP = 0x00AC,
139 | WM_NCXBUTTONDBLCLK = 0x00AD,
140 | WM_INPUT = 0x00FF,
141 | WM_KEYFIRST = 0x0100,
142 | WM_KEYDOWN = 0x0100,
143 | WM_KEYUP = 0x0101,
144 | WM_CHAR = 0x0102,
145 | WM_DEADCHAR = 0x0103,
146 | WM_SYSKEYDOWN = 0x0104,
147 | WM_SYSKEYUP = 0x0105,
148 | WM_SYSCHAR = 0x0106,
149 | WM_SYSDEADCHAR = 0x0107,
150 | WM_UNICHAR = 0x0109,
151 | WM_KEYLAST = 0x0108,
152 | WM_IME_STARTCOMPOSITION = 0x010D,
153 | WM_IME_ENDCOMPOSITION = 0x010E,
154 | WM_IME_COMPOSITION = 0x010F,
155 | WM_IME_KEYLAST = 0x010F,
156 | WM_INITDIALOG = 0x0110,
157 | WM_COMMAND = 0x0111,
158 | WM_SYSCOMMAND = 0x0112,
159 | WM_TIMER = 0x0113,
160 | WM_HSCROLL = 0x0114,
161 | WM_VSCROLL = 0x0115,
162 | WM_INITMENU = 0x0116,
163 | WM_INITMENUPOPUP = 0x0117,
164 | WM_MENUSELECT = 0x011F,
165 | WM_MENUCHAR = 0x0120,
166 | WM_ENTERIDLE = 0x0121,
167 | WM_MENURBUTTONUP = 0x0122,
168 | WM_MENUDRAG = 0x0123,
169 | WM_MENUGETOBJECT = 0x0124,
170 | WM_UNINITMENUPOPUP = 0x0125,
171 | WM_MENUCOMMAND = 0x0126,
172 | WM_CHANGEUISTATE = 0x0127,
173 | WM_UPDATEUISTATE = 0x0128,
174 | WM_QUERYUISTATE = 0x0129,
175 | WM_CTLCOLOR = 0x0019,
176 | WM_CTLCOLORMSGBOX = 0x0132,
177 | WM_CTLCOLOREDIT = 0x0133,
178 | WM_CTLCOLORLISTBOX = 0x0134,
179 | WM_CTLCOLORBTN = 0x0135,
180 | WM_CTLCOLORDLG = 0x0136,
181 | WM_CTLCOLORSCROLLBAR = 0x0137,
182 | WM_CTLCOLORSTATIC = 0x0138,
183 | WM_MOUSEFIRST = 0x0200,
184 | WM_MOUSEMOVE = 0x0200,
185 | WM_LBUTTONDOWN = 0x0201,
186 | WM_LBUTTONUP = 0x0202,
187 | WM_LBUTTONDBLCLK = 0x0203,
188 | WM_RBUTTONDOWN = 0x0204,
189 | WM_RBUTTONUP = 0x0205,
190 | WM_RBUTTONDBLCLK = 0x0206,
191 | WM_MBUTTONDOWN = 0x0207,
192 | WM_MBUTTONUP = 0x0208,
193 | WM_MBUTTONDBLCLK = 0x0209,
194 | WM_MOUSEWHEEL = 0x020A,
195 | WM_XBUTTONDOWN = 0x020B,
196 | WM_XBUTTONUP = 0x020C,
197 | WM_XBUTTONDBLCLK = 0x020D,
198 | WM_MOUSELAST = 0x020D,
199 | WM_PARENTNOTIFY = 0x0210,
200 | WM_ENTERMENULOOP = 0x0211,
201 | WM_EXITMENULOOP = 0x0212,
202 | WM_NEXTMENU = 0x0213,
203 | WM_SIZING = 0x0214,
204 | WM_CAPTURECHANGED = 0x0215,
205 | WM_MOVING = 0x0216,
206 | WM_POWERBROADCAST = 0x0218,
207 | WM_DEVICECHANGE = 0x0219,
208 | WM_MDICREATE = 0x0220,
209 | WM_MDIDESTROY = 0x0221,
210 | WM_MDIACTIVATE = 0x0222,
211 | WM_MDIRESTORE = 0x0223,
212 | WM_MDINEXT = 0x0224,
213 | WM_MDIMAXIMIZE = 0x0225,
214 | WM_MDITILE = 0x0226,
215 | WM_MDICASCADE = 0x0227,
216 | WM_MDIICONARRANGE = 0x0228,
217 | WM_MDIGETACTIVE = 0x0229,
218 | WM_MDISETMENU = 0x0230,
219 | WM_ENTERSIZEMOVE = 0x0231,
220 | WM_EXITSIZEMOVE = 0x0232,
221 | WM_DROPFILES = 0x0233,
222 | WM_MDIREFRESHMENU = 0x0234,
223 | WM_IME_SETCONTEXT = 0x0281,
224 | WM_IME_NOTIFY = 0x0282,
225 | WM_IME_CONTROL = 0x0283,
226 | WM_IME_COMPOSITIONFULL = 0x0284,
227 | WM_IME_SELECT = 0x0285,
228 | WM_IME_CHAR = 0x0286,
229 | WM_IME_REQUEST = 0x0288,
230 | WM_IME_KEYDOWN = 0x0290,
231 | WM_IME_KEYUP = 0x0291,
232 | WM_MOUSEHOVER = 0x02A1,
233 | WM_MOUSELEAVE = 0x02A3,
234 | WM_NCMOUSELEAVE = 0x02A2,
235 | WM_WTSSESSION_CHANGE = 0x02B1,
236 | WM_TABLET_FIRST = 0x02c0,
237 | WM_TABLET_LAST = 0x02df,
238 | WM_CUT = 0x0300,
239 | WM_COPY = 0x0301,
240 | WM_PASTE = 0x0302,
241 | WM_CLEAR = 0x0303,
242 | WM_UNDO = 0x0304,
243 | WM_RENDERFORMAT = 0x0305,
244 | WM_RENDERALLFORMATS = 0x0306,
245 | WM_DESTROYCLIPBOARD = 0x0307,
246 | WM_DRAWCLIPBOARD = 0x0308,
247 | WM_PAINTCLIPBOARD = 0x0309,
248 | WM_VSCROLLCLIPBOARD = 0x030A,
249 | WM_SIZECLIPBOARD = 0x030B,
250 | WM_ASKCBFORMATNAME = 0x030C,
251 | WM_CHANGECBCHAIN = 0x030D,
252 | WM_HSCROLLCLIPBOARD = 0x030E,
253 | WM_QUERYNEWPALETTE = 0x030F,
254 | WM_PALETTEISCHANGING = 0x0310,
255 | WM_PALETTECHANGED = 0x0311,
256 | WM_HOTKEY = 0x0312,
257 | WM_PRINT = 0x0317,
258 | WM_PRINTCLIENT = 0x0318,
259 | WM_APPCOMMAND = 0x0319,
260 | WM_THEMECHANGED = 0x031A,
261 | WM_HANDHELDFIRST = 0x0358,
262 | WM_HANDHELDLAST = 0x035F,
263 | WM_AFXFIRST = 0x0360,
264 | WM_AFXLAST = 0x037F,
265 | WM_PENWINFIRST = 0x0380,
266 | WM_PENWINLAST = 0x038F,
267 | WM_USER = 0x0400,
268 | WM_REFLECT = 0x2000,
269 | WM_APP = 0x8000
270 | }
271 |
272 | extern(Windows)
273 | {
274 | alias WNDPROC = LRESULT function(HWND, UINT, WPARAM, LPARAM);
275 | }
276 |
277 |
278 | struct MONITORINFO {
279 | DWORD cbSize = this.sizeof;
280 | RECT rcMonitor;
281 | RECT rcWork;
282 | DWORD dwFlags;
283 | }
284 | alias MONITORINFO* LPMONITORINFO;
285 |
286 | struct WNDCLASSEXW {
287 | UINT cbSize = WNDCLASSEXW.sizeof;
288 | UINT style;
289 | WNDPROC lpfnWndProc;
290 | int cbClsExtra;
291 | int cbWndExtra;
292 | HINSTANCE hInstance;
293 | HICON hIcon;
294 | HCURSOR hCursor;
295 | HBRUSH hbrBackground;
296 | LPCWSTR lpszMenuName;
297 | LPCWSTR lpszClassName;
298 | HICON hIconSm;
299 | }
300 |
301 | struct INITCOMMONCONTROLSEX
302 | {
303 | DWORD dwSize = INITCOMMONCONTROLSEX.sizeof;
304 | DWORD dwICC;
305 | }
306 |
307 | struct SIZE
308 | {
309 | int cx;
310 | int cy;
311 | }
312 |
313 | enum
314 | {
315 | ICC_LISTVIEW_CLASSES = 1,
316 | ICC_TREEVIEW_CLASSES = 2,
317 | ICC_BAR_CLASSES = 4,
318 | ICC_TAB_CLASSES = 8,
319 | ICC_UPDOWN_CLASS = 16,
320 | ICC_PROGRESS_CLASS = 32,
321 | ICC_HOTKEY_CLASS = 64,
322 | ICC_ANIMATE_CLASS = 128,
323 | ICC_WIN95_CLASSES = 255,
324 | ICC_DATE_CLASSES = 256,
325 | ICC_USEREX_CLASSES = 512,
326 | ICC_COOL_CLASSES = 1024,
327 | ICC_STANDARD_CLASSES = 0x00004000,
328 | ICC_LINK_CLASS = 0x00008000
329 | }
330 |
331 | extern(Windows)
332 | {
333 | HRESULT OleInitialize(void*);
334 | BOOL InitCommonControlsEx(INITCOMMONCONTROLSEX*);
335 | BOOL GetMessageW(LPMSG, HWND, UINT, UINT);
336 | LONG DispatchMessageW(const(MSG)*);
337 | BOOL TranslateMessage(const(MSG)*);
338 |
339 | LRESULT SendMessageW(HWND, UINT, WPARAM, LPARAM);
340 | BOOL PostMessageW(HWND, UINT, WPARAM, LPARAM);
341 | HWND GetParent(HWND);
342 | BOOL IsWindow(HWND);
343 | BOOL IsWindowEnabled(HWND);
344 | BOOL IsWindowVisible(HWND);
345 | BOOL MoveWindow(HWND, int, int, int, int, BOOL);
346 | HWND CreateWindowExW(DWORD, LPCWSTR, LPCWSTR, DWORD, int, int, int, int, HWND, HMENU, HINSTANCE, LPVOID);
347 | HMODULE GetModuleHandleW(LPCWSTR);
348 | ATOM RegisterClassExW(const(WNDCLASSEXW)*);
349 | HWND GetDesktopWindow();
350 | HWND GetForegroundWindow();
351 |
352 | LONG GetWindowLongW(HWND, int);
353 | LONG SetWindowLongW(HWND, int, LONG);
354 | LRESULT DefWindowProcW(HWND, UINT, WPARAM, LPARAM);
355 | HICON LoadIconW(HINSTANCE, LPCWSTR);
356 |
357 | void DragFinish(HDROP);
358 | UINT DragQueryFileW(HDROP, UINT, LPWSTR, UINT);
359 |
360 | version(Win64)
361 | {
362 | LONG_PTR GetWindowLongPtrW(HWND, int);
363 | LONG_PTR SetWindowLongPtrW(HWND, int, LONG_PTR);
364 | } else {
365 | alias GetWindowLongPtrW = GetWindowLongW;
366 | alias SetWindowLongPtrW = SetWindowLongW;
367 | }
368 | }
369 |
370 | LPWSTR MAKEINTRESOURCEW(/*WORD*/uint i) {
371 | return cast(LPWSTR) i;
372 | }
--------------------------------------------------------------------------------
/source/winkit/Window.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 winkit.Window;
22 |
23 | import winkit.WinAPI;
24 |
25 |
26 | struct Window
27 | {
28 | public:
29 | this(HWND hWnd) { m_hWnd = hWnd; }
30 |
31 | HWND m_hWnd;
32 | alias m_hWnd this;// a.k.a. implicit cast operator to HWND
33 |
34 | public:
35 | LRESULT SendMessage(UINT Msg, WPARAM wParam = 0, LPARAM lParam = 0)
36 | { return .SendMessageW(m_hWnd, Msg, wParam, lParam); }
37 |
38 | LRESULT PostMessage(UINT Msg, WPARAM wParam = 0, LPARAM lParam = 0)
39 | { return .PostMessageW(m_hWnd, Msg, wParam, lParam); }
40 |
41 | BOOL ShowWindow(in int nCmdShow = SW_SHOW)
42 | { return .ShowWindow(m_hWnd, nCmdShow); }
43 |
44 | BOOL UpdateWindow()
45 | { return .UpdateWindow(m_hWnd); }
46 |
47 | BOOL Invalidate()
48 | { return .InvalidateRect(m_hWnd, null, TRUE); }
49 |
50 | LONG_PTR GetWindowLongPtr(in int nIndex)
51 | { return GetWindowLongPtrW(m_hWnd, nIndex); }
52 |
53 | LONG_PTR SetWindowLongPtr(in int nIndex, in int dwNewLong)
54 | { return SetWindowLongPtrW(m_hWnd, nIndex, dwNewLong); }
55 |
56 | size_t GetStyle()
57 | { return GetWindowLongPtrW(m_hWnd, GWL_STYLE); }
58 |
59 | size_t GetStyleEx()
60 | { return GetWindowLongPtrW(m_hWnd, GWL_EXSTYLE); }
61 |
62 | BOOL ModifyStyle(DWORD dwRemove, DWORD dwAdd)
63 | {
64 | DWORD dwStyle = .GetWindowLongPtrW(m_hWnd, GWL_STYLE);
65 | DWORD dwNewStyle = (dwStyle & ~dwRemove) | dwAdd;
66 | if(dwStyle == dwNewStyle)
67 | return FALSE;
68 |
69 | .SetWindowLongPtrW(m_hWnd, GWL_STYLE, dwNewStyle);
70 | return TRUE;
71 | }
72 |
73 | BOOL ModifyStyleEx(DWORD dwRemove, DWORD dwAdd)
74 | {
75 | DWORD dwStyle = .GetWindowLongPtrW(m_hWnd, GWL_EXSTYLE);
76 | DWORD dwNewStyle = (dwStyle & ~dwRemove) | dwAdd;
77 | if(dwStyle == dwNewStyle)
78 | return FALSE;
79 |
80 | .SetWindowLongPtrW(m_hWnd, GWL_EXSTYLE, dwNewStyle);
81 | return TRUE;
82 | }
83 |
84 | HWND GetParent()
85 | { return .GetParent(m_hWnd); }
86 |
87 | BOOL IsEnabled()
88 | { return IsWindowEnabled(m_hWnd); }
89 |
90 | BOOL IsVisible()
91 | { return IsWindowVisible(m_hWnd); }
92 |
93 | void CenterTopLevelWindow(HWND parent = GetDesktopWindow())
94 | {
95 | HWND hwndParent = parent;
96 | RECT rectWindow, rectParent;
97 |
98 | //assert(hwndParent!=NULL);
99 | .GetWindowRect(m_hWnd, &rectWindow);
100 | .GetWindowRect(hwndParent, &rectParent);
101 |
102 | int nWidth = rectWindow.right - rectWindow.left;
103 | int nHeight = rectWindow.bottom - rectWindow.top;
104 |
105 | int nX = ((rectParent.right - rectParent.left) - nWidth) / 2 + rectParent.left;
106 | int nY = ((rectParent.bottom - rectParent.top) - nHeight) / 2 + rectParent.top;
107 |
108 | int nScreenWidth = GetSystemMetrics(SM_CXSCREEN);
109 | int nScreenHeight = GetSystemMetrics(SM_CYSCREEN);
110 |
111 | if (nX < 0) nX = 0;
112 | if (nY < 0) nY = 0;
113 | if (nX + nWidth > nScreenWidth) nX = nScreenWidth - nWidth;
114 | if (nY + nHeight > nScreenHeight) nY = nScreenHeight - nHeight;
115 |
116 | MoveWindow(m_hWnd, nX, nY, nWidth, nHeight, FALSE);
117 | }
118 |
119 | /*void CenterOverWindow(HWND hWndWhere)
120 | {
121 | RECT rectWindow, rectParent;
122 | .GetWindowRect(m_hWnd, &rectWindow);
123 | .GetWindowRect(hwndParent, &rectParent);
124 | }*/
125 |
126 | BOOL SetWindowPos(HWND hWndInsertAfter, int x, int y, int cx, int cy, UINT flags)
127 | { return .SetWindowPos(m_hWnd, hWndInsertAfter, x, y, cx, cy, flags); }
128 | BOOL SetWindowPos(POINT pt)// position
129 | { return .SetWindowPos(m_hWnd, NULL, pt.x, pt.y, 0, 0, SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOSIZE); }
130 | BOOL SetWindowPos(SIZE sz)// size
131 | { return .SetWindowPos(m_hWnd, NULL, 0, 0, sz.cx, sz.cy, SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOMOVE); }
132 | BOOL SetWindowPos(POINT pt, SIZE sz)// position and size
133 | { return .SetWindowPos(m_hWnd, NULL, pt.x, pt.y, sz.cx, sz.cy, SWP_NOZORDER | SWP_NOACTIVATE); }
134 |
135 | RECT GetWindowRect()
136 | {
137 | RECT rc;
138 | .GetWindowRect(m_hWnd, &rc);
139 | return rc;
140 | }
141 | RECT GetClientRect()
142 | {
143 | RECT rc;
144 | .GetClientRect(m_hWnd, &rc);
145 | return rc;
146 | }
147 | }
--------------------------------------------------------------------------------
/source/winkit/WindowImplMixin.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 winkit.WindowImplMixin;
22 |
23 |
24 | mixin template WindowImplMixin(bool isSciter = false)
25 | {
26 | public:
27 | import std.conv;
28 | import std.traits;
29 | import winkit.WinAPI;
30 | import winkit.Window;
31 |
32 | Window wnd;
33 |
34 | void Create(SIZE sz, wstring title, HWND parent = NULL, DWORD dwStyle = WS_OVERLAPPEDWINDOW, DWORD dwExStyle = 0)// frames
35 | {
36 | if(!s_cls)
37 | s_cls = RegisterClass();
38 |
39 | HWND hWnd = CreateWindowExW(
40 | dwExStyle, // extended style
41 | cast(LPCWSTR) s_cls,// class
42 | title.ptr, // window title
43 | dwStyle, // normal style
44 | CW_USEDEFAULT, 0, // position
45 | sz.cx, sz.cy, // size
46 | parent,
47 | null,
48 | .GetModuleHandleW(null),
49 | null
50 | );
51 |
52 | assert(hWnd && wnd==hWnd);// wnd set at StartWndProc
53 | }
54 |
55 | void Create(POINT pt, SIZE sz, HWND parent, DWORD dwStyle = WS_CHILD | WS_VISIBLE, DWORD dwExStyle = 0)// childs
56 | {
57 | if(!s_cls)
58 | s_cls = RegisterClass();
59 |
60 | HWND hWnd = CreateWindowExW(
61 | dwExStyle, // extended style
62 | cast(LPCWSTR) s_cls,// class
63 | null, // window title
64 | dwStyle, // normal style
65 | pt.x, pt.y, // position
66 | sz.cx, sz.cy, // size
67 | parent,
68 | null,
69 | .GetModuleHandleW(null),
70 | null
71 | );
72 |
73 | assert(hWnd && wnd==hWnd);// wnd set at StartWndProc
74 | }
75 |
76 | // Operations
77 | LRESULT DefWindowProc()
78 | {
79 | static if(isSciter)
80 | {
81 | import sciter.api;
82 | return SciterProc(m_CurrentMsg.hwnd, m_CurrentMsg.message, m_CurrentMsg.wParam, m_CurrentMsg.lParam);
83 | } else {
84 | return DefWindowProcW(m_CurrentMsg.hwnd, m_CurrentMsg.message, m_CurrentMsg.wParam, m_CurrentMsg.lParam);
85 | }
86 | }
87 |
88 |
89 | // Internal ------------------------------------------------------------------------------
90 | private:
91 | ATOM s_cls;
92 |
93 | /*static this()
94 | {
95 | s_cls = RegisterClass();
96 | }*/
97 |
98 | ATOM RegisterClass()
99 | {
100 | enum FRAME_WNDCLS = "WinkitWindowClass-" ~ fullyQualifiedName!ProcessWindowMessage;
101 |
102 | auto hInstance = .GetModuleHandleW(null);
103 | WNDCLASSEXW wcex;
104 | wcex.style = CS_HREDRAW | CS_VREDRAW;
105 | wcex.lpfnWndProc = &StartWndProc;
106 | wcex.cbClsExtra = 0;
107 | wcex.cbWndExtra = 0;
108 | wcex.hInstance = hInstance;
109 | wcex.hIcon = LoadIconW(hInstance, MAKEINTRESOURCEW(100));
110 | //wcex.hCursor = .LoadCursor(null, IDC_ARROW);
111 | wcex.hbrBackground = cast(HBRUSH)(COLOR_WINDOW+1);
112 | wcex.lpszMenuName = null;
113 | wcex.lpszClassName = to!wstring(FRAME_WNDCLS).ptr;
114 | wcex.hIconSm = null;
115 | return .RegisterClassExW(&wcex);
116 | }
117 |
118 | // messaging
119 | MSG m_CurrentMsg;
120 |
121 | LRESULT IntanceWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
122 | {
123 | m_CurrentMsg.hwnd = hWnd;
124 | m_CurrentMsg.message = message;
125 | m_CurrentMsg.wParam = wParam;
126 | m_CurrentMsg.lParam = lParam;
127 |
128 | LRESULT lResult;
129 | if( ProcessWindowMessage(message, wParam, lParam, lResult) )
130 | return lResult;
131 | return DefWindowProc();
132 | }
133 |
134 | extern(Windows) static LRESULT StaticWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
135 | {
136 | return IntanceWndProc(hWnd, message, wParam, lParam);
137 | }
138 |
139 | extern(Windows) static LRESULT StartWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
140 | {
141 | wnd = hWnd;
142 | wnd.SetWindowLongPtr(GWLP_WNDPROC, cast(LONG_PTR) &StaticWndProc);
143 | return IntanceWndProc(hWnd, message, wParam, lParam);
144 | }
145 |
146 |
147 | // compile time checking
148 | private:
149 | alias f_pwm = bool function(UINT message, WPARAM wParam, LPARAM lParam, ref LRESULT lResult);
150 | static assert( is(typeof(&ProcessWindowMessage) == f_pwm), "ProcessWindowMessage() function not declared or with wrong types" );
151 | }
--------------------------------------------------------------------------------