quickwin 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +2 -1
- package/README.md +2 -1
- package/examples/PdfCanvas.js +3 -3
- package/examples/PdfCanvas.tsx +3 -3
- package/examples/pdf_preview2.js +34 -19
- package/examples/pdf_preview2.ts +34 -20
- package/examples/pdf_viewer.js +956 -215
- package/examples/pdf_viewer.tsx +29 -19
- package/examples/test_gallery.js +922 -194
- package/examples/test_react_lazy.js +905 -177
- package/examples/test_react_listbox.js +905 -177
- package/examples/test_root_window.js +905 -177
- package/examples/test_tab.js +905 -177
- package/lib/fetch.js +35 -7
- package/lib/fetch.ts +24 -4
- package/lib/ffi-bind.js +85 -0
- package/lib/ffi-bind.ts +170 -0
- package/lib/ffi-struct.js +224 -0
- package/lib/ffi-struct.ts +239 -0
- package/lib/react-qw/components/DateTimePicker.js +21 -15
- package/lib/react-qw/components/Link.js +4 -6
- package/lib/react-qw/components/ListView.js +84 -40
- package/lib/react-qw/components/PathPicker.js +40 -24
- package/lib/react-qw/components/Tab.js +21 -10
- package/lib/react-qw/components/Tooltip.js +27 -15
- package/lib/react-qw/components/TreeView.js +23 -33
- package/lib/react-qw/nmhdr.js +26 -0
- package/lib/react-qw/nmhdr.ts +32 -0
- package/lib/text-measure.js +14 -24
- package/lib/text-measure.ts +14 -24
- package/lib/win-common-structs.js +39 -0
- package/lib/win-common-structs.ts +41 -0
- package/main.js +46 -0
- package/package.json +2 -1
- package/quickwin.d.ts +7 -2
- package/qwin-nowasm-x86.exe +0 -0
- package/qwin-nowasm.exe +0 -0
- package/qwin-x86.exe +0 -0
- package/qwin.exe +0 -0
- package/test/run.js +3 -0
- package/test/run.ts +3 -0
- package/test/test_ffi.js +12 -8
- package/test/test_ffi.ts +12 -12
- package/test/test_ffi_bind.js +42 -0
- package/test/test_ffi_bind.ts +46 -0
- package/test/test_ffi_struct.js +201 -0
- package/test/test_ffi_struct.ts +223 -0
- package/test/test_net_fetch.js +62 -0
- package/test/test_net_fetch.ts +72 -0
- package/test/test_react_complex.js +908 -180
- package/test/test_react_counter.js +905 -177
- package/test/test_react_flex.js +905 -177
- package/test/test_react_hidden.js +907 -179
- package/test/test_react_listview_link.js +905 -177
- package/test/test_react_render.js +905 -177
- package/test/test_wolfssl_read.js +201 -0
- package/test/test_wolfssl_read.ts +181 -0
package/examples/pdf_viewer.js
CHANGED
|
@@ -15360,7 +15360,7 @@ import "../lib/polyfill.js";
|
|
|
15360
15360
|
import * as std from "std";
|
|
15361
15361
|
import * as gui19 from "gui";
|
|
15362
15362
|
import * as win5 from "win";
|
|
15363
|
-
import * as
|
|
15363
|
+
import * as ffi13 from "ffi";
|
|
15364
15364
|
|
|
15365
15365
|
// _build/lib/react-qw/index.js
|
|
15366
15366
|
import * as gui18 from "gui";
|
|
@@ -15490,57 +15490,370 @@ function calculateFlexLayout(flex, parentW, parentH, children) {
|
|
|
15490
15490
|
}
|
|
15491
15491
|
|
|
15492
15492
|
// _build/lib/text-measure.js
|
|
15493
|
+
import * as ffi2 from "ffi";
|
|
15494
|
+
import * as gui2 from "gui";
|
|
15495
|
+
|
|
15496
|
+
// _build/lib/ffi-bind.js
|
|
15493
15497
|
import * as ffi from "ffi";
|
|
15494
15498
|
import * as win from "win";
|
|
15495
|
-
|
|
15496
|
-
|
|
15497
|
-
|
|
15498
|
-
|
|
15499
|
-
|
|
15500
|
-
|
|
15499
|
+
|
|
15500
|
+
// _build/lib/text-codec.js
|
|
15501
|
+
var _labelMap = {
|
|
15502
|
+
"utf-8": "utf-8",
|
|
15503
|
+
"utf8": "utf-8",
|
|
15504
|
+
"unicode-1-1-utf-8": "utf-8",
|
|
15505
|
+
"utf-16": "utf-16le",
|
|
15506
|
+
"utf-16le": "utf-16le",
|
|
15507
|
+
"utf-16be": "utf-16be"
|
|
15508
|
+
};
|
|
15509
|
+
function _normalizeLabel(label) {
|
|
15510
|
+
if (!label)
|
|
15511
|
+
return "utf-8";
|
|
15512
|
+
const result = _labelMap[label.trim().toLowerCase()];
|
|
15513
|
+
if (result)
|
|
15514
|
+
return result;
|
|
15515
|
+
throw new RangeError(`The encoding label "${label}" is not supported`);
|
|
15516
|
+
}
|
|
15517
|
+
function _decodeUTF8(buf, fatal) {
|
|
15518
|
+
let out = "";
|
|
15519
|
+
for (let i = 0; i < buf.length; ) {
|
|
15520
|
+
const b = buf[i++];
|
|
15521
|
+
if (b < 128) {
|
|
15522
|
+
out += String.fromCharCode(b);
|
|
15523
|
+
continue;
|
|
15524
|
+
}
|
|
15525
|
+
if (b < 192) {
|
|
15526
|
+
out += fatal ? (() => {
|
|
15527
|
+
throw new TypeError("unexpected continuation byte");
|
|
15528
|
+
})() : "\uFFFD";
|
|
15529
|
+
continue;
|
|
15530
|
+
}
|
|
15531
|
+
let c, min;
|
|
15532
|
+
if (b < 224) {
|
|
15533
|
+
if (i >= buf.length) {
|
|
15534
|
+
out += fatal ? (() => {
|
|
15535
|
+
throw new TypeError("incomplete utf-8");
|
|
15536
|
+
})() : "\uFFFD";
|
|
15537
|
+
break;
|
|
15538
|
+
}
|
|
15539
|
+
const b2 = buf[i++];
|
|
15540
|
+
if ((b2 & 192) !== 128) {
|
|
15541
|
+
out += "\uFFFD";
|
|
15542
|
+
continue;
|
|
15543
|
+
}
|
|
15544
|
+
c = (b & 31) << 6 | b2 & 63;
|
|
15545
|
+
min = 128;
|
|
15546
|
+
} else if (b < 240) {
|
|
15547
|
+
if (i + 1 >= buf.length) {
|
|
15548
|
+
out += fatal ? (() => {
|
|
15549
|
+
throw new TypeError("incomplete utf-8");
|
|
15550
|
+
})() : "\uFFFD";
|
|
15551
|
+
break;
|
|
15552
|
+
}
|
|
15553
|
+
const b2 = buf[i++];
|
|
15554
|
+
const b3 = buf[i++];
|
|
15555
|
+
if ((b2 & 192) !== 128 || (b3 & 192) !== 128) {
|
|
15556
|
+
out += "\uFFFD";
|
|
15557
|
+
continue;
|
|
15558
|
+
}
|
|
15559
|
+
c = (b & 15) << 12 | (b2 & 63) << 6 | b3 & 63;
|
|
15560
|
+
min = 2048;
|
|
15561
|
+
} else if (b < 248) {
|
|
15562
|
+
if (i + 2 >= buf.length) {
|
|
15563
|
+
out += fatal ? (() => {
|
|
15564
|
+
throw new TypeError("incomplete utf-8");
|
|
15565
|
+
})() : "\uFFFD";
|
|
15566
|
+
break;
|
|
15567
|
+
}
|
|
15568
|
+
const b2 = buf[i++];
|
|
15569
|
+
const b3 = buf[i++];
|
|
15570
|
+
const b4 = buf[i++];
|
|
15571
|
+
if ((b2 & 192) !== 128 || (b3 & 192) !== 128 || (b4 & 192) !== 128) {
|
|
15572
|
+
out += "\uFFFD";
|
|
15573
|
+
continue;
|
|
15574
|
+
}
|
|
15575
|
+
c = (b & 7) << 18 | (b2 & 63) << 12 | (b3 & 63) << 6 | b4 & 63;
|
|
15576
|
+
min = 65536;
|
|
15577
|
+
} else {
|
|
15578
|
+
out += fatal ? (() => {
|
|
15579
|
+
throw new TypeError("invalid utf-8 start");
|
|
15580
|
+
})() : "\uFFFD";
|
|
15581
|
+
continue;
|
|
15582
|
+
}
|
|
15583
|
+
if (c < min || c >= 55296 && c <= 57343 || c > 1114111) {
|
|
15584
|
+
out += fatal ? (() => {
|
|
15585
|
+
throw new TypeError("invalid utf-8 codepoint");
|
|
15586
|
+
})() : "\uFFFD";
|
|
15587
|
+
continue;
|
|
15588
|
+
}
|
|
15589
|
+
if (c <= 65535)
|
|
15590
|
+
out += String.fromCharCode(c);
|
|
15591
|
+
else {
|
|
15592
|
+
c -= 65536;
|
|
15593
|
+
out += String.fromCharCode(55296 | c >> 10, 56320 | c & 1023);
|
|
15594
|
+
}
|
|
15595
|
+
}
|
|
15596
|
+
return out;
|
|
15597
|
+
}
|
|
15598
|
+
function _decodeUTF16(buf, le, fatal) {
|
|
15599
|
+
const dv = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
15600
|
+
let out = "";
|
|
15601
|
+
for (let i = 0; i + 1 < buf.length; i += 2) {
|
|
15602
|
+
let c = dv.getUint16(i, le);
|
|
15603
|
+
if (c >= 55296 && c <= 56319) {
|
|
15604
|
+
i += 2;
|
|
15605
|
+
if (i + 1 >= buf.length) {
|
|
15606
|
+
out += fatal ? (() => {
|
|
15607
|
+
throw new TypeError("truncated surrogate pair");
|
|
15608
|
+
})() : "\uFFFD";
|
|
15609
|
+
break;
|
|
15610
|
+
}
|
|
15611
|
+
const c2 = dv.getUint16(i, le);
|
|
15612
|
+
if (c2 >= 56320 && c2 <= 57343) {
|
|
15613
|
+
out += String.fromCharCode(c, c2);
|
|
15614
|
+
} else {
|
|
15615
|
+
out += fatal ? (() => {
|
|
15616
|
+
throw new TypeError("invalid surrogate pair");
|
|
15617
|
+
})() : "\uFFFD";
|
|
15618
|
+
i -= 2;
|
|
15619
|
+
}
|
|
15620
|
+
} else if (c >= 56320 && c <= 57343) {
|
|
15621
|
+
out += fatal ? (() => {
|
|
15622
|
+
throw new TypeError("unexpected trailing surrogate");
|
|
15623
|
+
})() : "\uFFFD";
|
|
15624
|
+
} else {
|
|
15625
|
+
out += String.fromCharCode(c);
|
|
15626
|
+
}
|
|
15627
|
+
}
|
|
15628
|
+
return out;
|
|
15629
|
+
}
|
|
15630
|
+
var TextDecoderImpl = class {
|
|
15631
|
+
_encoding;
|
|
15632
|
+
_fatal;
|
|
15633
|
+
_ignoreBOM;
|
|
15634
|
+
constructor(label, options) {
|
|
15635
|
+
this._encoding = _normalizeLabel(label);
|
|
15636
|
+
this._fatal = options?.fatal ?? false;
|
|
15637
|
+
this._ignoreBOM = options?.ignoreBOM ?? false;
|
|
15638
|
+
}
|
|
15639
|
+
get encoding() {
|
|
15640
|
+
return this._encoding;
|
|
15641
|
+
}
|
|
15642
|
+
get fatal() {
|
|
15643
|
+
return this._fatal;
|
|
15644
|
+
}
|
|
15645
|
+
get ignoreBOM() {
|
|
15646
|
+
return this._ignoreBOM;
|
|
15647
|
+
}
|
|
15648
|
+
decode(buffer) {
|
|
15649
|
+
if (!buffer)
|
|
15650
|
+
return "";
|
|
15651
|
+
const arr = buffer instanceof Uint8Array ? buffer : buffer instanceof ArrayBuffer ? new Uint8Array(buffer) : new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
15652
|
+
if (this._encoding === "utf-8") {
|
|
15653
|
+
return _decodeUTF8(arr, this._fatal);
|
|
15654
|
+
}
|
|
15655
|
+
const le = this._encoding === "utf-16le";
|
|
15656
|
+
let offset = 0;
|
|
15657
|
+
if (arr.length >= 2 && !this._ignoreBOM) {
|
|
15658
|
+
const bomLo = le ? arr[0] : arr[1];
|
|
15659
|
+
const bomHi = le ? arr[1] : arr[0];
|
|
15660
|
+
const bom = bomHi << 8 | bomLo;
|
|
15661
|
+
if (bom === 65279 || bom === 65534) {
|
|
15662
|
+
offset = 2;
|
|
15663
|
+
}
|
|
15664
|
+
}
|
|
15665
|
+
return _decodeUTF16(arr.slice(offset), le, this._fatal);
|
|
15666
|
+
}
|
|
15667
|
+
};
|
|
15668
|
+
var TextEncoderImpl = class {
|
|
15669
|
+
_encoding;
|
|
15670
|
+
constructor(label) {
|
|
15671
|
+
this._encoding = _normalizeLabel(label);
|
|
15672
|
+
}
|
|
15673
|
+
get encoding() {
|
|
15674
|
+
return this._encoding;
|
|
15675
|
+
}
|
|
15676
|
+
encode(input) {
|
|
15677
|
+
if (!input)
|
|
15678
|
+
return new Uint8Array(0);
|
|
15679
|
+
if (this._encoding === "utf-8") {
|
|
15680
|
+
const bytes = [];
|
|
15681
|
+
for (let i = 0; i < input.length; i++) {
|
|
15682
|
+
let c = input.charCodeAt(i);
|
|
15683
|
+
if (c < 128) {
|
|
15684
|
+
bytes.push(c);
|
|
15685
|
+
} else if (c < 2048) {
|
|
15686
|
+
bytes.push(192 | c >> 6, 128 | c & 63);
|
|
15687
|
+
} else if (c < 55296 || c >= 57344) {
|
|
15688
|
+
bytes.push(224 | c >> 12, 128 | c >> 6 & 63, 128 | c & 63);
|
|
15689
|
+
} else {
|
|
15690
|
+
i++;
|
|
15691
|
+
const c2 = input.charCodeAt(i);
|
|
15692
|
+
c = 65536 + ((c & 1023) << 10) | c2 & 1023;
|
|
15693
|
+
bytes.push(240 | c >> 18, 128 | c >> 12 & 63, 128 | c >> 6 & 63, 128 | c & 63);
|
|
15694
|
+
}
|
|
15695
|
+
}
|
|
15696
|
+
return new Uint8Array(bytes);
|
|
15697
|
+
}
|
|
15698
|
+
const le = this._encoding === "utf-16le";
|
|
15699
|
+
const buf = new ArrayBuffer(input.length * 2);
|
|
15700
|
+
const dv = new DataView(buf);
|
|
15701
|
+
for (let i = 0; i < input.length; i++)
|
|
15702
|
+
dv.setUint16(i * 2, input.charCodeAt(i), le);
|
|
15703
|
+
return new Uint8Array(buf);
|
|
15704
|
+
}
|
|
15705
|
+
};
|
|
15706
|
+
if (typeof globalThis.TextDecoder === "undefined") {
|
|
15707
|
+
globalThis.TextDecoder = TextDecoderImpl;
|
|
15708
|
+
}
|
|
15709
|
+
if (typeof globalThis.TextEncoder === "undefined") {
|
|
15710
|
+
globalThis.TextEncoder = TextEncoderImpl;
|
|
15711
|
+
}
|
|
15712
|
+
|
|
15713
|
+
// _build/lib/ffi-bind.js
|
|
15714
|
+
var KIND_TO_FFI = {
|
|
15715
|
+
void: ffi.FFI_TYPE_VOID,
|
|
15716
|
+
u8: ffi.FFI_TYPE_UINT8,
|
|
15717
|
+
i8: ffi.FFI_TYPE_SINT8,
|
|
15718
|
+
u16: ffi.FFI_TYPE_UINT16,
|
|
15719
|
+
i16: ffi.FFI_TYPE_SINT16,
|
|
15720
|
+
u32: ffi.FFI_TYPE_UINT32,
|
|
15721
|
+
i32: ffi.FFI_TYPE_SINT32,
|
|
15722
|
+
u64: ffi.FFI_TYPE_UINT64,
|
|
15723
|
+
i64: ffi.FFI_TYPE_SINT64,
|
|
15724
|
+
f32: ffi.FFI_TYPE_FLOAT,
|
|
15725
|
+
f64: ffi.FFI_TYPE_DOUBLE,
|
|
15726
|
+
ptr: ffi.FFI_TYPE_POINTER,
|
|
15727
|
+
wstr: ffi.FFI_TYPE_POINTER
|
|
15728
|
+
};
|
|
15729
|
+
var C_ALIAS = {
|
|
15730
|
+
int: "i32",
|
|
15731
|
+
long: "i32",
|
|
15732
|
+
short: "i16",
|
|
15733
|
+
char: "i8",
|
|
15734
|
+
float: "f32",
|
|
15735
|
+
double: "f64",
|
|
15736
|
+
DWORD: "u32",
|
|
15737
|
+
UINT: "u32",
|
|
15738
|
+
ULONG: "u32",
|
|
15739
|
+
LONG: "i32",
|
|
15740
|
+
BOOL: "i32",
|
|
15741
|
+
HRESULT: "i32",
|
|
15742
|
+
SHORT: "i16",
|
|
15743
|
+
USHORT: "u16",
|
|
15744
|
+
BYTE: "u8",
|
|
15745
|
+
LONG_PTR: "ptr",
|
|
15746
|
+
ULONG_PTR: "ptr",
|
|
15747
|
+
INT_PTR: "ptr",
|
|
15748
|
+
UINT_PTR: "ptr",
|
|
15749
|
+
DWORD_PTR: "ptr",
|
|
15750
|
+
SIZE_T: "ptr",
|
|
15751
|
+
WPARAM: "ptr",
|
|
15752
|
+
LPARAM: "ptr",
|
|
15753
|
+
HANDLE: "ptr",
|
|
15754
|
+
HWND: "ptr",
|
|
15755
|
+
HDC: "ptr",
|
|
15756
|
+
HMODULE: "ptr",
|
|
15757
|
+
HFONT: "ptr",
|
|
15758
|
+
HBRUSH: "ptr",
|
|
15759
|
+
HICON: "ptr",
|
|
15760
|
+
HBITMAP: "ptr",
|
|
15761
|
+
LPVOID: "ptr",
|
|
15762
|
+
LPCVOID: "ptr",
|
|
15763
|
+
LPCWSTR: "ptr",
|
|
15764
|
+
PCWSTR: "ptr",
|
|
15765
|
+
LPWSTR: "ptr"
|
|
15766
|
+
};
|
|
15767
|
+
function normKind(t) {
|
|
15768
|
+
const k = C_ALIAS[t] ?? t;
|
|
15769
|
+
if (!(k in KIND_TO_FFI))
|
|
15770
|
+
throw new Error(`ffi-bind: invalid kind "${t}"`);
|
|
15771
|
+
return k;
|
|
15772
|
+
}
|
|
15773
|
+
var _dllCache = /* @__PURE__ */ new Map();
|
|
15774
|
+
function loadDll(dll) {
|
|
15775
|
+
const cached = _dllCache.get(dll);
|
|
15776
|
+
if (cached !== void 0)
|
|
15777
|
+
return cached;
|
|
15778
|
+
const loaded = win.LoadLibrary(dll);
|
|
15779
|
+
if (!loaded)
|
|
15780
|
+
throw new Error(`ffi-bind: LoadLibrary("${dll}") failed`);
|
|
15781
|
+
_dllCache.set(dll, loaded);
|
|
15782
|
+
return loaded;
|
|
15783
|
+
}
|
|
15784
|
+
function parseSig(sig) {
|
|
15785
|
+
const parts = sig.split(" -> ");
|
|
15786
|
+
const ret = parts[1];
|
|
15787
|
+
if (ret === void 0 || parts.length > 2) {
|
|
15788
|
+
throw new Error(`ffi-bind: invalid signature "${sig}" (expected "arg1 arg2 -> ret")`);
|
|
15789
|
+
}
|
|
15790
|
+
const retK = normKind(ret);
|
|
15791
|
+
if (retK === "wstr")
|
|
15792
|
+
throw new Error('ffi-bind: "wstr" cannot be a return type');
|
|
15793
|
+
const tokens = (parts[0] ?? "") === "" ? [] : parts[0].split(" ");
|
|
15794
|
+
const args = tokens.map((t) => normKind(t));
|
|
15795
|
+
return { args, ret: retK };
|
|
15796
|
+
}
|
|
15797
|
+
function makeFn(proc, sig) {
|
|
15798
|
+
const { args, ret } = parseSig(sig);
|
|
15799
|
+
const argTypes = args.map((k) => KIND_TO_FFI[k]);
|
|
15800
|
+
const retType = KIND_TO_FFI[ret];
|
|
15801
|
+
return (...a) => {
|
|
15802
|
+
const vals = args.map((k, i) => k === "wstr" ? new TextEncoder("utf-16le").encode(String(a[i]) + "\0").buffer : a[i]);
|
|
15803
|
+
return ffi.ffiCall(proc, argTypes, vals, retType);
|
|
15804
|
+
};
|
|
15805
|
+
}
|
|
15806
|
+
function bindLib(dll, map) {
|
|
15807
|
+
const out = {};
|
|
15808
|
+
const h = loadDll(dll);
|
|
15809
|
+
for (const [name, sig] of Object.entries(map)) {
|
|
15810
|
+
const proc = win.GetProcAddress(h, name);
|
|
15811
|
+
if (!proc)
|
|
15812
|
+
throw new Error(`ffi-bind: proc "${name}" not found in ${dll}`);
|
|
15813
|
+
out[name] = makeFn(proc, sig);
|
|
15814
|
+
}
|
|
15815
|
+
return out;
|
|
15501
15816
|
}
|
|
15502
|
-
|
|
15503
|
-
|
|
15504
|
-
|
|
15505
|
-
|
|
15506
|
-
|
|
15507
|
-
|
|
15508
|
-
|
|
15509
|
-
var
|
|
15510
|
-
|
|
15511
|
-
|
|
15512
|
-
var FFI_PTR = ffi.FFI_TYPE_POINTER;
|
|
15817
|
+
|
|
15818
|
+
// _build/lib/text-measure.js
|
|
15819
|
+
var user32 = bindLib("user32.dll", {
|
|
15820
|
+
DrawTextW: "ptr wstr i32 ptr i32 -> i32",
|
|
15821
|
+
GetDC: "ptr -> ptr",
|
|
15822
|
+
ReleaseDC: "ptr ptr -> i32"
|
|
15823
|
+
});
|
|
15824
|
+
var gdi32 = bindLib("gdi32.dll", {
|
|
15825
|
+
SelectObject: "ptr ptr -> ptr"
|
|
15826
|
+
});
|
|
15513
15827
|
function measureText(hdc, text, maxWidth) {
|
|
15514
|
-
const textBuf = new TextEncoder("utf-16le").encode(text + "\0").buffer;
|
|
15515
15828
|
const rect = new ArrayBuffer(16);
|
|
15516
15829
|
const dv = new DataView(rect);
|
|
15517
15830
|
dv.setInt32(8, maxWidth, true);
|
|
15518
|
-
|
|
15831
|
+
user32.DrawTextW(
|
|
15519
15832
|
hdc,
|
|
15520
|
-
|
|
15833
|
+
text,
|
|
15521
15834
|
-1,
|
|
15522
15835
|
rect,
|
|
15523
15836
|
1024
|
|
15524
15837
|
/* gui.DrawTextFlag.CALCRECT */
|
|
15525
|
-
|
|
15838
|
+
);
|
|
15526
15839
|
return { width: dv.getInt32(8, true), height: dv.getInt32(12, true) };
|
|
15527
15840
|
}
|
|
15528
15841
|
function getButtonIdealSize(hwnd) {
|
|
15529
15842
|
const size = new ArrayBuffer(8);
|
|
15530
|
-
gui2.SendMessage(hwnd, 5633, 0,
|
|
15843
|
+
gui2.SendMessage(hwnd, 5633, 0, ffi2.bufferPtr(size));
|
|
15531
15844
|
const dv = new DataView(size);
|
|
15532
15845
|
return { width: dv.getInt32(0, true), height: dv.getInt32(4, true) };
|
|
15533
15846
|
}
|
|
15534
15847
|
function measureTextForHwnd(hwnd, text) {
|
|
15535
|
-
const hdc =
|
|
15848
|
+
const hdc = user32.GetDC(hwnd);
|
|
15536
15849
|
if (!hdc)
|
|
15537
15850
|
return { width: 0, height: 0 };
|
|
15538
15851
|
const hFont = gui2.SendMessage(hwnd, 49, 0, 0);
|
|
15539
|
-
const oldFont = hFont ?
|
|
15852
|
+
const oldFont = hFont ? gdi32.SelectObject(hdc, hFont) : 0;
|
|
15540
15853
|
const result = measureText(hdc, text, 0);
|
|
15541
15854
|
if (hFont)
|
|
15542
|
-
|
|
15543
|
-
|
|
15855
|
+
gdi32.SelectObject(hdc, oldFont);
|
|
15856
|
+
user32.ReleaseDC(hwnd, hdc);
|
|
15544
15857
|
const wr = gui2.GetWindowRect(hwnd);
|
|
15545
15858
|
const cr = gui2.GetClientRect(hwnd);
|
|
15546
15859
|
if (wr && cr) {
|
|
@@ -16023,15 +16336,285 @@ var ComboBox = (0, import_react4.forwardRef)(({ items, selectedIndex: controlled
|
|
|
16023
16336
|
var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1);
|
|
16024
16337
|
var import_react5 = __toESM(require_react(), 1);
|
|
16025
16338
|
import * as gui6 from "gui";
|
|
16026
|
-
import * as
|
|
16027
|
-
|
|
16028
|
-
|
|
16339
|
+
import * as ffi4 from "ffi";
|
|
16340
|
+
|
|
16341
|
+
// _build/lib/ffi-struct.js
|
|
16342
|
+
import * as os2 from "os";
|
|
16343
|
+
var PTR = os2.arch === "x64" ? 8 : 4;
|
|
16344
|
+
var AS = {
|
|
16345
|
+
u8: [1, 1],
|
|
16346
|
+
i8: [1, 1],
|
|
16347
|
+
u16: [2, 2],
|
|
16348
|
+
i16: [2, 2],
|
|
16349
|
+
u32: [4, 4],
|
|
16350
|
+
i32: [4, 4],
|
|
16351
|
+
u64: [8, 8],
|
|
16352
|
+
i64: [8, 8],
|
|
16353
|
+
f32: [4, 4],
|
|
16354
|
+
f64: [8, 8],
|
|
16355
|
+
ptr: [PTR, PTR],
|
|
16356
|
+
wstr: [2, 2]
|
|
16357
|
+
// 仅定长数组元素用(wchar)
|
|
16358
|
+
};
|
|
16359
|
+
function alignUp(v, a) {
|
|
16360
|
+
return v + a - 1 & ~(a - 1);
|
|
16029
16361
|
}
|
|
16030
|
-
function
|
|
16031
|
-
|
|
16362
|
+
function parseField(f) {
|
|
16363
|
+
const arr = /^(.+)\[(\d+)\]$/.exec(f);
|
|
16364
|
+
if (arr) {
|
|
16365
|
+
const b2 = normKind(arr[1]);
|
|
16366
|
+
if (b2 === "void")
|
|
16367
|
+
throw new Error(`ffi-struct: "void" cannot be an array base`);
|
|
16368
|
+
return { base: b2, count: Number(arr[2]) };
|
|
16369
|
+
}
|
|
16370
|
+
const b = normKind(f);
|
|
16371
|
+
if (b === "void" || b === "wstr")
|
|
16372
|
+
throw new Error(`ffi-struct: invalid scalar field type "${f}"`);
|
|
16373
|
+
return { base: b, count: 1 };
|
|
16374
|
+
}
|
|
16375
|
+
function layout(def) {
|
|
16376
|
+
const fields = [];
|
|
16377
|
+
let cursor = 0;
|
|
16378
|
+
let maxAlign = 1;
|
|
16379
|
+
for (const key of Object.keys(def)) {
|
|
16380
|
+
const v = def[key];
|
|
16381
|
+
let a;
|
|
16382
|
+
let w;
|
|
16383
|
+
if (typeof v === "string") {
|
|
16384
|
+
const { base, count } = parseField(v);
|
|
16385
|
+
const [align, elem] = AS[base];
|
|
16386
|
+
a = align;
|
|
16387
|
+
w = count >= 1 ? elem * count : elem;
|
|
16388
|
+
fields.push({ name: key, base, count, offset: 0 });
|
|
16389
|
+
} else {
|
|
16390
|
+
const child = v;
|
|
16391
|
+
a = child.structAlign;
|
|
16392
|
+
w = child.size;
|
|
16393
|
+
fields.push({ name: key, base: "u8", count: 0, offset: 0, child });
|
|
16394
|
+
}
|
|
16395
|
+
const off = alignUp(cursor, a);
|
|
16396
|
+
const f = fields[fields.length - 1];
|
|
16397
|
+
f.offset = off;
|
|
16398
|
+
cursor = off + w;
|
|
16399
|
+
if (a > maxAlign)
|
|
16400
|
+
maxAlign = a;
|
|
16401
|
+
}
|
|
16402
|
+
return { fields, size: alignUp(cursor, maxAlign), structAlign: maxAlign };
|
|
16403
|
+
}
|
|
16404
|
+
var _layoutCache = /* @__PURE__ */ new WeakMap();
|
|
16405
|
+
function buildLayout(def) {
|
|
16406
|
+
let hit = _layoutCache.get(def);
|
|
16407
|
+
if (hit)
|
|
16408
|
+
return hit;
|
|
16409
|
+
hit = layout(def);
|
|
16410
|
+
_layoutCache.set(def, hit);
|
|
16411
|
+
return hit;
|
|
16412
|
+
}
|
|
16413
|
+
function readScalar(dv, off, k) {
|
|
16414
|
+
switch (k) {
|
|
16415
|
+
case "u8":
|
|
16416
|
+
return dv.getUint8(off);
|
|
16417
|
+
case "i8":
|
|
16418
|
+
return dv.getInt8(off);
|
|
16419
|
+
case "u16":
|
|
16420
|
+
return dv.getUint16(off, true);
|
|
16421
|
+
case "i16":
|
|
16422
|
+
return dv.getInt16(off, true);
|
|
16423
|
+
case "u32":
|
|
16424
|
+
return dv.getUint32(off, true);
|
|
16425
|
+
case "i32":
|
|
16426
|
+
return dv.getInt32(off, true);
|
|
16427
|
+
case "u64":
|
|
16428
|
+
return Number(dv.getBigUint64(off, true));
|
|
16429
|
+
case "i64":
|
|
16430
|
+
return Number(dv.getBigInt64(off, true));
|
|
16431
|
+
case "f32":
|
|
16432
|
+
return dv.getFloat32(off, true);
|
|
16433
|
+
case "f64":
|
|
16434
|
+
return dv.getFloat64(off, true);
|
|
16435
|
+
case "ptr":
|
|
16436
|
+
return readPtr(dv, off);
|
|
16437
|
+
case "wstr":
|
|
16438
|
+
return dv.getUint16(off, true);
|
|
16439
|
+
}
|
|
16440
|
+
}
|
|
16441
|
+
function readPtr(dv, off) {
|
|
16442
|
+
if (PTR === 8)
|
|
16443
|
+
return Number(dv.getBigUint64(off, true));
|
|
16444
|
+
return dv.getUint32(off, true);
|
|
16032
16445
|
}
|
|
16446
|
+
function writeScalar(dv, off, k, val) {
|
|
16447
|
+
switch (k) {
|
|
16448
|
+
case "u8":
|
|
16449
|
+
dv.setUint8(off, val);
|
|
16450
|
+
break;
|
|
16451
|
+
case "i8":
|
|
16452
|
+
dv.setInt8(off, val);
|
|
16453
|
+
break;
|
|
16454
|
+
case "u16":
|
|
16455
|
+
dv.setUint16(off, val, true);
|
|
16456
|
+
break;
|
|
16457
|
+
case "i16":
|
|
16458
|
+
dv.setInt16(off, val, true);
|
|
16459
|
+
break;
|
|
16460
|
+
case "u32":
|
|
16461
|
+
dv.setUint32(off, val >>> 0, true);
|
|
16462
|
+
break;
|
|
16463
|
+
case "i32":
|
|
16464
|
+
dv.setInt32(off, val | 0, true);
|
|
16465
|
+
break;
|
|
16466
|
+
case "u64":
|
|
16467
|
+
dv.setBigUint64(off, BigInt(Math.trunc(val)), true);
|
|
16468
|
+
break;
|
|
16469
|
+
case "i64":
|
|
16470
|
+
dv.setBigInt64(off, BigInt(Math.trunc(val)), true);
|
|
16471
|
+
break;
|
|
16472
|
+
case "f32":
|
|
16473
|
+
dv.setFloat32(off, val, true);
|
|
16474
|
+
break;
|
|
16475
|
+
case "f64":
|
|
16476
|
+
dv.setFloat64(off, val, true);
|
|
16477
|
+
break;
|
|
16478
|
+
case "ptr":
|
|
16479
|
+
writePtr(dv, off, val);
|
|
16480
|
+
break;
|
|
16481
|
+
case "wstr":
|
|
16482
|
+
dv.setUint16(off, val, true);
|
|
16483
|
+
break;
|
|
16484
|
+
}
|
|
16485
|
+
}
|
|
16486
|
+
function writePtr(dv, off, val) {
|
|
16487
|
+
if (PTR === 8)
|
|
16488
|
+
dv.setBigUint64(off, BigInt(Math.trunc(val)), true);
|
|
16489
|
+
else
|
|
16490
|
+
dv.setUint32(off, val >>> 0, true);
|
|
16491
|
+
}
|
|
16492
|
+
function readField(dv, base, f) {
|
|
16493
|
+
const off = base + f.offset;
|
|
16494
|
+
if (f.child)
|
|
16495
|
+
return readInto(f.child, dv.buffer, off);
|
|
16496
|
+
if (f.count > 1) {
|
|
16497
|
+
if (f.base === "wstr") {
|
|
16498
|
+
const arr = new Uint16Array(dv.buffer, dv.byteOffset + off, f.count);
|
|
16499
|
+
let end = 0;
|
|
16500
|
+
while (end < arr.length && arr[end] !== 0)
|
|
16501
|
+
end++;
|
|
16502
|
+
let s = "";
|
|
16503
|
+
for (let i = 0; i < end; i++)
|
|
16504
|
+
s += String.fromCharCode(arr[i]);
|
|
16505
|
+
return s;
|
|
16506
|
+
}
|
|
16507
|
+
const out = [];
|
|
16508
|
+
const step = AS[f.base][1];
|
|
16509
|
+
for (let i = 0; i < f.count; i++)
|
|
16510
|
+
out.push(readScalar(dv, off + i * step, f.base));
|
|
16511
|
+
return out;
|
|
16512
|
+
}
|
|
16513
|
+
return readScalar(dv, off, f.base);
|
|
16514
|
+
}
|
|
16515
|
+
function writeField(dv, base, f, v) {
|
|
16516
|
+
const off = base + f.offset;
|
|
16517
|
+
if (f.child) {
|
|
16518
|
+
writeInto(f.child, v, dv.buffer, off);
|
|
16519
|
+
return;
|
|
16520
|
+
}
|
|
16521
|
+
if (f.count > 1) {
|
|
16522
|
+
if (f.base === "wstr") {
|
|
16523
|
+
const s = String(v ?? "");
|
|
16524
|
+
const arr = new Uint16Array(dv.buffer, dv.byteOffset + off, f.count);
|
|
16525
|
+
for (let i = 0; i < arr.length; i++)
|
|
16526
|
+
arr[i] = 0;
|
|
16527
|
+
const n = Math.min(s.length, f.count - 1);
|
|
16528
|
+
for (let i = 0; i < n; i++)
|
|
16529
|
+
arr[i] = s.charCodeAt(i);
|
|
16530
|
+
return;
|
|
16531
|
+
}
|
|
16532
|
+
const step = AS[f.base][1];
|
|
16533
|
+
const list = v ?? [];
|
|
16534
|
+
for (let i = 0; i < f.count; i++)
|
|
16535
|
+
writeScalar(dv, off + i * step, f.base, list[i] ?? 0);
|
|
16536
|
+
return;
|
|
16537
|
+
}
|
|
16538
|
+
writeScalar(dv, off, f.base, Number(v));
|
|
16539
|
+
}
|
|
16540
|
+
function doSize(def) {
|
|
16541
|
+
return buildLayout(def).size;
|
|
16542
|
+
}
|
|
16543
|
+
function readInto(child, buf, offset) {
|
|
16544
|
+
const r = child;
|
|
16545
|
+
return r.read(buf, offset);
|
|
16546
|
+
}
|
|
16547
|
+
function doRead(_def, fields, buf, offset) {
|
|
16548
|
+
const out = {};
|
|
16549
|
+
const dv = new DataView(buf);
|
|
16550
|
+
for (const f of fields)
|
|
16551
|
+
out[f.name] = readField(dv, offset, f);
|
|
16552
|
+
return out;
|
|
16553
|
+
}
|
|
16554
|
+
function doWrite(def, fields, v, buf, offset = 0) {
|
|
16555
|
+
buf = buf ?? new ArrayBuffer(doSize(def));
|
|
16556
|
+
const dv = new DataView(buf);
|
|
16557
|
+
for (const f of fields)
|
|
16558
|
+
writeField(dv, offset, f, v[f.name]);
|
|
16559
|
+
return buf;
|
|
16560
|
+
}
|
|
16561
|
+
function writeInto(child, v, buf, offset) {
|
|
16562
|
+
const w = child;
|
|
16563
|
+
w.write(v, buf, offset);
|
|
16564
|
+
}
|
|
16565
|
+
function struct(def) {
|
|
16566
|
+
const { fields, size, structAlign } = buildLayout(def);
|
|
16567
|
+
return {
|
|
16568
|
+
__fields: def,
|
|
16569
|
+
size,
|
|
16570
|
+
structAlign,
|
|
16571
|
+
read: (buf, offset = 0) => doRead(def, fields, buf, offset),
|
|
16572
|
+
write: (v, buf, offset = 0) => doWrite(def, fields, v, buf, offset),
|
|
16573
|
+
offsetOf: (name) => {
|
|
16574
|
+
for (const f of fields)
|
|
16575
|
+
if (f.name === name)
|
|
16576
|
+
return f.offset;
|
|
16577
|
+
throw new Error(`ffi-struct: no field "${String(name)}"`);
|
|
16578
|
+
}
|
|
16579
|
+
};
|
|
16580
|
+
}
|
|
16581
|
+
|
|
16582
|
+
// _build/lib/react-qw/nmhdr.js
|
|
16583
|
+
import * as os3 from "os";
|
|
16584
|
+
import * as ffi3 from "ffi";
|
|
16585
|
+
var IS64 = os3.arch === "x64";
|
|
16586
|
+
var PTR_SIZE = IS64 ? 8 : 4;
|
|
16587
|
+
var NMHDR = struct({ hwndFrom: "ptr", idFrom: "ptr", code: "i32" });
|
|
16588
|
+
var NMHDR_SIZE = NMHDR.size;
|
|
16589
|
+
var NMHDR_CODE = NMHDR.offsetOf("code");
|
|
16590
|
+
function readI32At(ptr, offset) {
|
|
16591
|
+
return ffi3.readByte(ptr + offset) | ffi3.readByte(ptr + offset + 1) << 8 | ffi3.readByte(ptr + offset + 2) << 16 | ffi3.readByte(ptr + offset + 3) << 24;
|
|
16592
|
+
}
|
|
16593
|
+
function readU16At(ptr, offset) {
|
|
16594
|
+
return ffi3.readByte(ptr + offset) | ffi3.readByte(ptr + offset + 1) << 8;
|
|
16595
|
+
}
|
|
16596
|
+
function nmCode(lParam) {
|
|
16597
|
+
return readI32At(lParam, NMHDR_CODE);
|
|
16598
|
+
}
|
|
16599
|
+
|
|
16600
|
+
// _build/lib/react-qw/components/DateTimePicker.js
|
|
16601
|
+
var SYSTEMTIME = struct({
|
|
16602
|
+
wYear: "u16",
|
|
16603
|
+
wMonth: "u16",
|
|
16604
|
+
wDayOfWeek: "u16",
|
|
16605
|
+
wDay: "u16",
|
|
16606
|
+
wHour: "u16",
|
|
16607
|
+
wMinute: "u16",
|
|
16608
|
+
wSecond: "u16",
|
|
16609
|
+
wMilliseconds: "u16"
|
|
16610
|
+
});
|
|
16611
|
+
var NMDATETIMECHANGE = struct({
|
|
16612
|
+
hdr: NMHDR,
|
|
16613
|
+
dwFlags: "u32",
|
|
16614
|
+
st: SYSTEMTIME
|
|
16615
|
+
});
|
|
16033
16616
|
function bufPtr(buf) {
|
|
16034
|
-
return
|
|
16617
|
+
return ffi4.bufferPtr(buf);
|
|
16035
16618
|
}
|
|
16036
16619
|
function dateToSysTimeBuf(d) {
|
|
16037
16620
|
const buf = new ArrayBuffer(16);
|
|
@@ -16088,20 +16671,21 @@ var DateTimePicker = (0, import_react5.forwardRef)(function DateTimePicker2({ va
|
|
|
16088
16671
|
}, []);
|
|
16089
16672
|
return (0, import_jsx_runtime4.jsx)("w", { type: "STATIC", ws: 268435456 | 33554432, style: { ...style, flexDirection: "column", alignItems: "stretch" }, ref, onEvent: (e) => {
|
|
16090
16673
|
if (e.msg === 78) {
|
|
16091
|
-
const code =
|
|
16674
|
+
const code = nmCode(e.lParam);
|
|
16092
16675
|
if (code === -759) {
|
|
16093
|
-
const
|
|
16676
|
+
const st = NMDATETIMECHANGE.offsetOf("st");
|
|
16677
|
+
const dwFlags = readI32At(e.lParam, NMDATETIMECHANGE.offsetOf("dwFlags"));
|
|
16094
16678
|
if (dwFlags === 1) {
|
|
16095
16679
|
if (!isControlled)
|
|
16096
16680
|
setInternalDate(null);
|
|
16097
16681
|
onChangeRef.current?.(null);
|
|
16098
16682
|
} else {
|
|
16099
|
-
const year =
|
|
16100
|
-
const month =
|
|
16101
|
-
const day =
|
|
16102
|
-
const hour =
|
|
16103
|
-
const min =
|
|
16104
|
-
const sec =
|
|
16683
|
+
const year = readU16At(e.lParam, st + 0);
|
|
16684
|
+
const month = readU16At(e.lParam, st + 2);
|
|
16685
|
+
const day = readU16At(e.lParam, st + 6);
|
|
16686
|
+
const hour = readU16At(e.lParam, st + 8);
|
|
16687
|
+
const min = readU16At(e.lParam, st + 10);
|
|
16688
|
+
const sec = readU16At(e.lParam, st + 12);
|
|
16105
16689
|
const d = new Date(year, month - 1, day, hour, min, sec);
|
|
16106
16690
|
if (!isControlled)
|
|
16107
16691
|
setInternalDate(d);
|
|
@@ -16118,7 +16702,7 @@ var DateTimePicker = (0, import_react5.forwardRef)(function DateTimePicker2({ va
|
|
|
16118
16702
|
var import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1);
|
|
16119
16703
|
var import_react6 = __toESM(require_react(), 1);
|
|
16120
16704
|
import * as gui7 from "gui";
|
|
16121
|
-
import * as
|
|
16705
|
+
import * as ffi5 from "ffi";
|
|
16122
16706
|
function textToUtf16(s) {
|
|
16123
16707
|
const buf = new ArrayBuffer((s.length + 1) * 2);
|
|
16124
16708
|
const dv = new DataView(buf);
|
|
@@ -16145,7 +16729,7 @@ var Input = (0, import_react6.forwardRef)(({ value: controlledValue, defaultValu
|
|
|
16145
16729
|
if (!h || !placeholder)
|
|
16146
16730
|
return;
|
|
16147
16731
|
const buf = textToUtf16(placeholder);
|
|
16148
|
-
gui7.SendMessage(h, 5377, 1,
|
|
16732
|
+
gui7.SendMessage(h, 5377, 1, ffi5.bufferPtr(buf));
|
|
16149
16733
|
}, [placeholder]);
|
|
16150
16734
|
return (0, import_jsx_runtime5.jsx)("w", { type: "EDIT", text: displayValue, ws, style, disabled, ref: (h) => {
|
|
16151
16735
|
inputRef.current = h;
|
|
@@ -16170,15 +16754,12 @@ var Input = (0, import_react6.forwardRef)(({ value: controlledValue, defaultValu
|
|
|
16170
16754
|
var import_jsx_runtime6 = __toESM(require_jsx_runtime(), 1);
|
|
16171
16755
|
var import_react7 = __toESM(require_react(), 1);
|
|
16172
16756
|
import * as gui8 from "gui";
|
|
16173
|
-
import * as
|
|
16174
|
-
function readI322(ptr, offset) {
|
|
16175
|
-
return ffi4.readByte(ptr + offset) | ffi4.readByte(ptr + offset + 1) << 8 | ffi4.readByte(ptr + offset + 2) << 16 | ffi4.readByte(ptr + offset + 3) << 24;
|
|
16176
|
-
}
|
|
16757
|
+
import * as ffi6 from "ffi";
|
|
16177
16758
|
function readUtf16(ptr, offset, maxWords) {
|
|
16178
16759
|
const chars = [];
|
|
16179
16760
|
for (let i = 0; i < maxWords; i++) {
|
|
16180
|
-
const lo =
|
|
16181
|
-
const hi =
|
|
16761
|
+
const lo = ffi6.readByte(ptr + offset + i * 2);
|
|
16762
|
+
const hi = ffi6.readByte(ptr + offset + i * 2 + 1);
|
|
16182
16763
|
const code = hi << 8 | lo;
|
|
16183
16764
|
if (code === 0)
|
|
16184
16765
|
break;
|
|
@@ -16200,9 +16781,9 @@ var Link = (0, import_react7.forwardRef)(function Link2({ href, children, onClic
|
|
|
16200
16781
|
}, [linkText]);
|
|
16201
16782
|
return (0, import_jsx_runtime6.jsx)("w", { type: "STATIC", ws: 268435456 | 33554432, style: { ...style, flexDirection: "column", alignItems: "stretch" }, ref, onEvent: (e) => {
|
|
16202
16783
|
if (e.msg === 78) {
|
|
16203
|
-
const code =
|
|
16784
|
+
const code = nmCode(e.lParam);
|
|
16204
16785
|
if (code === -2 || code === -4) {
|
|
16205
|
-
const url = readUtf16(e.lParam,
|
|
16786
|
+
const url = readUtf16(e.lParam, NMHDR_SIZE + 112, 2048);
|
|
16206
16787
|
onClickRef.current?.(url);
|
|
16207
16788
|
}
|
|
16208
16789
|
}
|
|
@@ -16263,7 +16844,7 @@ var ListBox = (0, import_react8.forwardRef)(({ items, selectedIndex: controlledI
|
|
|
16263
16844
|
var import_jsx_runtime8 = __toESM(require_jsx_runtime(), 1);
|
|
16264
16845
|
var import_react9 = __toESM(require_react(), 1);
|
|
16265
16846
|
import * as gui10 from "gui";
|
|
16266
|
-
import * as
|
|
16847
|
+
import * as ffi7 from "ffi";
|
|
16267
16848
|
import * as win2 from "win";
|
|
16268
16849
|
function textToUtf162(s) {
|
|
16269
16850
|
const buf = new ArrayBuffer((s.length + 1) * 2);
|
|
@@ -16272,11 +16853,11 @@ function textToUtf162(s) {
|
|
|
16272
16853
|
dv.setUint16(i * 2, s.charCodeAt(i), true);
|
|
16273
16854
|
return buf;
|
|
16274
16855
|
}
|
|
16275
|
-
function
|
|
16276
|
-
return
|
|
16856
|
+
function readI32(ptr, offset) {
|
|
16857
|
+
return ffi7.readByte(ptr + offset) | ffi7.readByte(ptr + offset + 1) << 8 | ffi7.readByte(ptr + offset + 2) << 16 | ffi7.readByte(ptr + offset + 3) << 24;
|
|
16277
16858
|
}
|
|
16278
16859
|
function readU32(ptr, offset) {
|
|
16279
|
-
return
|
|
16860
|
+
return ffi7.readByte(ptr + offset) | ffi7.readByte(ptr + offset + 1) << 8 | ffi7.readByte(ptr + offset + 2) << 16 | ffi7.readByte(ptr + offset + 3) << 24 >>> 0;
|
|
16280
16861
|
}
|
|
16281
16862
|
function readU64(ptr, offset) {
|
|
16282
16863
|
const lo = readU32(ptr, offset);
|
|
@@ -16284,24 +16865,87 @@ function readU64(ptr, offset) {
|
|
|
16284
16865
|
return lo + hi * 4294967296;
|
|
16285
16866
|
}
|
|
16286
16867
|
function writeU32(ptr, offset, v) {
|
|
16287
|
-
|
|
16288
|
-
|
|
16289
|
-
|
|
16290
|
-
|
|
16868
|
+
ffi7.writeByte(ptr + offset, v & 255);
|
|
16869
|
+
ffi7.writeByte(ptr + offset + 1, v >> 8 & 255);
|
|
16870
|
+
ffi7.writeByte(ptr + offset + 2, v >> 16 & 255);
|
|
16871
|
+
ffi7.writeByte(ptr + offset + 3, v >> 24 & 255);
|
|
16291
16872
|
}
|
|
16292
16873
|
function bufPtr2(buf) {
|
|
16293
|
-
return
|
|
16874
|
+
return ffi7.bufferPtr(buf);
|
|
16294
16875
|
}
|
|
16295
16876
|
var LV_WS = 268435456 | 8388608 | 2097152 | 1048576 | 1 | 4;
|
|
16296
|
-
var
|
|
16297
|
-
|
|
16298
|
-
|
|
16299
|
-
|
|
16300
|
-
|
|
16301
|
-
|
|
16302
|
-
|
|
16303
|
-
|
|
16304
|
-
|
|
16877
|
+
var NMCUSTOMDRAW = struct({
|
|
16878
|
+
hdr: NMHDR,
|
|
16879
|
+
dwDrawStage: "u32",
|
|
16880
|
+
hdc: "ptr",
|
|
16881
|
+
rc: "i32[4]",
|
|
16882
|
+
dwItemSpec: "ptr",
|
|
16883
|
+
uItemState: "u32",
|
|
16884
|
+
lItemlParam: "ptr"
|
|
16885
|
+
});
|
|
16886
|
+
var NMLVCUSTOMDRAW = struct({
|
|
16887
|
+
hdr: NMHDR,
|
|
16888
|
+
dwDrawStage: "u32",
|
|
16889
|
+
hdc: "ptr",
|
|
16890
|
+
rc: "i32[4]",
|
|
16891
|
+
dwItemSpec: "ptr",
|
|
16892
|
+
uItemState: "u32",
|
|
16893
|
+
lItemlParam: "ptr",
|
|
16894
|
+
clrText: "u32",
|
|
16895
|
+
clrTextBk: "u32",
|
|
16896
|
+
iSubItem: "i32",
|
|
16897
|
+
dwItemType: "u32"
|
|
16898
|
+
});
|
|
16899
|
+
var NMLISTVIEW = struct({
|
|
16900
|
+
hdr: NMHDR,
|
|
16901
|
+
iItem: "i32",
|
|
16902
|
+
iSubItem: "i32",
|
|
16903
|
+
uNewState: "u32",
|
|
16904
|
+
uOldState: "u32",
|
|
16905
|
+
uChanged: "u32",
|
|
16906
|
+
ptAction: "i32[2]",
|
|
16907
|
+
lParam: "ptr"
|
|
16908
|
+
});
|
|
16909
|
+
var CD_STAGE = NMCUSTOMDRAW.offsetOf("dwDrawStage");
|
|
16910
|
+
var CD_HDC = NMCUSTOMDRAW.offsetOf("hdc");
|
|
16911
|
+
var CD_ITEM = NMCUSTOMDRAW.offsetOf("dwItemSpec");
|
|
16912
|
+
var CD_CLRTEXT = NMLVCUSTOMDRAW.offsetOf("clrText");
|
|
16913
|
+
var CD_CLRTEXTBK = NMLVCUSTOMDRAW.offsetOf("clrTextBk");
|
|
16914
|
+
var CD_SUBITEM = NMLVCUSTOMDRAW.offsetOf("iSubItem");
|
|
16915
|
+
var NMIA_ITEM = NMLISTVIEW.offsetOf("iItem");
|
|
16916
|
+
var NMIA_SUBITEM = NMLISTVIEW.offsetOf("iSubItem");
|
|
16917
|
+
var NMLV_UNEW = NMLISTVIEW.offsetOf("uNewState");
|
|
16918
|
+
var NMLV_UOLD = NMLISTVIEW.offsetOf("uOldState");
|
|
16919
|
+
var LVITEMW = struct({
|
|
16920
|
+
mask: "u32",
|
|
16921
|
+
iItem: "i32",
|
|
16922
|
+
iSubItem: "i32",
|
|
16923
|
+
state: "u32",
|
|
16924
|
+
stateMask: "u32",
|
|
16925
|
+
pszText: "ptr",
|
|
16926
|
+
cchTextMax: "i32",
|
|
16927
|
+
iImage: "i32",
|
|
16928
|
+
lParam: "ptr",
|
|
16929
|
+
iIndent: "i32",
|
|
16930
|
+
iGroupId: "i32",
|
|
16931
|
+
cColumns: "u32",
|
|
16932
|
+
puColumns: "ptr",
|
|
16933
|
+
piColFmt: "ptr",
|
|
16934
|
+
iGroup: "i32"
|
|
16935
|
+
});
|
|
16936
|
+
var LVCOLUMNW = struct({
|
|
16937
|
+
mask: "u32",
|
|
16938
|
+
fmt: "i32",
|
|
16939
|
+
cx: "i32",
|
|
16940
|
+
pszText: "ptr",
|
|
16941
|
+
cchTextMax: "i32",
|
|
16942
|
+
iSubItem: "i32",
|
|
16943
|
+
iImage: "i32",
|
|
16944
|
+
iOrder: "i32",
|
|
16945
|
+
cxMin: "i32",
|
|
16946
|
+
cxDefault: "i32",
|
|
16947
|
+
cxIdeal: "i32"
|
|
16948
|
+
});
|
|
16305
16949
|
var fontCache = /* @__PURE__ */ new Map();
|
|
16306
16950
|
var gdi322 = null;
|
|
16307
16951
|
var createFontIndirectW = null;
|
|
@@ -16345,7 +16989,7 @@ function getCellFont(hwnd, style) {
|
|
|
16345
16989
|
const dv = new DataView(lf);
|
|
16346
16990
|
const cur = gui10.SendMessage(hwnd, 49, 0, 0);
|
|
16347
16991
|
if (cur) {
|
|
16348
|
-
const got =
|
|
16992
|
+
const got = ffi7.ffiCall(getObjectW, [ffi7.FFI_TYPE_POINTER, ffi7.FFI_TYPE_SINT32, ffi7.FFI_TYPE_POINTER], [cur, 92, lf], ffi7.FFI_TYPE_SINT32);
|
|
16349
16993
|
if (!got)
|
|
16350
16994
|
return null;
|
|
16351
16995
|
} else {
|
|
@@ -16357,9 +17001,9 @@ function getCellFont(hwnd, style) {
|
|
|
16357
17001
|
dv.setUint8(20, 1);
|
|
16358
17002
|
if (style.underline)
|
|
16359
17003
|
dv.setUint8(21, 1);
|
|
16360
|
-
const h =
|
|
16361
|
-
fontCache.set(key, h
|
|
16362
|
-
return h
|
|
17004
|
+
const h = ffi7.ffiCall(createFontIndirectW, [ffi7.FFI_TYPE_POINTER], [lf], ffi7.FFI_TYPE_POINTER);
|
|
17005
|
+
fontCache.set(key, h ? h : 0);
|
|
17006
|
+
return h ? h : null;
|
|
16363
17007
|
}
|
|
16364
17008
|
function handleCustomDraw(lParam, columns, data, hwnd) {
|
|
16365
17009
|
const stage = readU32(lParam, CD_STAGE);
|
|
@@ -16368,8 +17012,8 @@ function handleCustomDraw(lParam, columns, data, hwnd) {
|
|
|
16368
17012
|
if (stage === 65537)
|
|
16369
17013
|
return 32;
|
|
16370
17014
|
if (stage === 196609) {
|
|
16371
|
-
const colIndex =
|
|
16372
|
-
const row =
|
|
17015
|
+
const colIndex = readI32(lParam, CD_SUBITEM);
|
|
17016
|
+
const row = readI32(lParam, CD_ITEM);
|
|
16373
17017
|
const style = resolveCellStyle(columns, data, row, colIndex);
|
|
16374
17018
|
if (!style)
|
|
16375
17019
|
return 0;
|
|
@@ -16379,9 +17023,9 @@ function handleCustomDraw(lParam, columns, data, hwnd) {
|
|
|
16379
17023
|
writeU32(lParam, CD_CLRTEXTBK, style.background);
|
|
16380
17024
|
const hfont = getCellFont(hwnd, style);
|
|
16381
17025
|
if (hfont && selectObjectFn) {
|
|
16382
|
-
const hdc = readU64(lParam, CD_HDC);
|
|
17026
|
+
const hdc = PTR_SIZE === 8 ? readU64(lParam, CD_HDC) : readU32(lParam, CD_HDC);
|
|
16383
17027
|
if (hdc) {
|
|
16384
|
-
|
|
17028
|
+
ffi7.ffiCall(selectObjectFn, [ffi7.FFI_TYPE_POINTER, ffi7.FFI_TYPE_POINTER], [hdc, hfont], ffi7.FFI_TYPE_POINTER);
|
|
16385
17029
|
return 2;
|
|
16386
17030
|
}
|
|
16387
17031
|
}
|
|
@@ -16414,18 +17058,24 @@ function resolveCellStyle(columns, data, row, colIndex) {
|
|
|
16414
17058
|
return style || void 0;
|
|
16415
17059
|
}
|
|
16416
17060
|
function makeLVItem(i, sub, text, image) {
|
|
16417
|
-
const b = new ArrayBuffer(84);
|
|
16418
|
-
const dv = new DataView(b);
|
|
16419
|
-
dv.setInt32(4, i, true);
|
|
16420
|
-
dv.setInt32(8, sub, true);
|
|
16421
|
-
let mask = 1;
|
|
16422
|
-
if (image !== void 0) {
|
|
16423
|
-
mask |= 2;
|
|
16424
|
-
dv.setInt32(36, image, true);
|
|
16425
|
-
}
|
|
16426
|
-
dv.setUint32(0, mask, true);
|
|
16427
17061
|
const textBuf = textToUtf162(text);
|
|
16428
|
-
|
|
17062
|
+
const b = LVITEMW.write({
|
|
17063
|
+
mask: 1 | (image !== void 0 ? 2 : 0),
|
|
17064
|
+
iItem: i,
|
|
17065
|
+
iSubItem: sub,
|
|
17066
|
+
state: 0,
|
|
17067
|
+
stateMask: 0,
|
|
17068
|
+
pszText: bufPtr2(textBuf),
|
|
17069
|
+
cchTextMax: 0,
|
|
17070
|
+
iImage: image ?? 0,
|
|
17071
|
+
lParam: 0,
|
|
17072
|
+
iIndent: 0,
|
|
17073
|
+
iGroupId: 0,
|
|
17074
|
+
cColumns: 0,
|
|
17075
|
+
puColumns: 0,
|
|
17076
|
+
piColFmt: 0,
|
|
17077
|
+
iGroup: 0
|
|
17078
|
+
});
|
|
16429
17079
|
b.__textBuf = textBuf;
|
|
16430
17080
|
return b;
|
|
16431
17081
|
}
|
|
@@ -16478,13 +17128,19 @@ var ListView = (0, import_react9.forwardRef)(function ListViewInner({ columns, d
|
|
|
16478
17128
|
const n = columns.length;
|
|
16479
17129
|
for (let j = 0; j < n; j++) {
|
|
16480
17130
|
const titleBuf = textToUtf162(columns[j].name);
|
|
16481
|
-
const lvc =
|
|
16482
|
-
|
|
16483
|
-
|
|
16484
|
-
|
|
16485
|
-
|
|
16486
|
-
|
|
16487
|
-
|
|
17131
|
+
const lvc = LVCOLUMNW.write({
|
|
17132
|
+
mask: 4 | 2 | 1,
|
|
17133
|
+
fmt: alignToFmt(columns[j].align),
|
|
17134
|
+
cx: columns[j].width ?? 100,
|
|
17135
|
+
pszText: bufPtr2(titleBuf),
|
|
17136
|
+
cchTextMax: 0,
|
|
17137
|
+
iSubItem: j,
|
|
17138
|
+
iImage: 0,
|
|
17139
|
+
iOrder: 0,
|
|
17140
|
+
cxMin: 0,
|
|
17141
|
+
cxDefault: 0,
|
|
17142
|
+
cxIdeal: 0
|
|
17143
|
+
});
|
|
16488
17144
|
lvc.__titleBuf = titleBuf;
|
|
16489
17145
|
gui10.SendMessage(h, 4193, j, bufPtr2(lvc));
|
|
16490
17146
|
}
|
|
@@ -16519,19 +17175,19 @@ var ListView = (0, import_react9.forwardRef)(function ListViewInner({ columns, d
|
|
|
16519
17175
|
}, [data, columns, getIcon]);
|
|
16520
17176
|
return (0, import_jsx_runtime8.jsx)("w", { type: "STATIC", ws: 268435456 | 33554432, style: { ...style, flexDirection: "column", alignItems: "stretch" }, ref, onEvent: (e) => {
|
|
16521
17177
|
if (e.msg === 78) {
|
|
16522
|
-
const code =
|
|
17178
|
+
const code = nmCode(e.lParam);
|
|
16523
17179
|
if (code === -12) {
|
|
16524
17180
|
return handleCustomDraw(e.lParam, columns, data, lvRef.current);
|
|
16525
17181
|
}
|
|
16526
17182
|
if (code === -100) {
|
|
16527
|
-
const uNewState = readU32(e.lParam,
|
|
16528
|
-
const uOldState = readU32(e.lParam,
|
|
17183
|
+
const uNewState = readU32(e.lParam, NMLV_UNEW);
|
|
17184
|
+
const uOldState = readU32(e.lParam, NMLV_UOLD);
|
|
16529
17185
|
if ((uNewState & 2) !== (uOldState & 2))
|
|
16530
17186
|
return 1;
|
|
16531
17187
|
}
|
|
16532
17188
|
if (code === -2) {
|
|
16533
|
-
const iItem =
|
|
16534
|
-
const iSubItem =
|
|
17189
|
+
const iItem = readI32(e.lParam, NMIA_ITEM);
|
|
17190
|
+
const iSubItem = readI32(e.lParam, NMIA_SUBITEM);
|
|
16535
17191
|
const col = columns[iSubItem];
|
|
16536
17192
|
const record = data[iItem];
|
|
16537
17193
|
if (col?.onCellClick && record !== void 0)
|
|
@@ -16559,7 +17215,7 @@ var ListView = (0, import_react9.forwardRef)(function ListViewInner({ columns, d
|
|
|
16559
17215
|
const sdv = new DataView(sbuf);
|
|
16560
17216
|
sdv.setInt32(0, sp[0], true);
|
|
16561
17217
|
sdv.setInt32(4, sp[1], true);
|
|
16562
|
-
|
|
17218
|
+
ffi7.ffiCall(screenToClient, [ffi7.FFI_TYPE_POINTER, ffi7.FFI_TYPE_POINTER], [h, sbuf], ffi7.FFI_TYPE_SINT32);
|
|
16563
17219
|
const lvhi = new ArrayBuffer(24);
|
|
16564
17220
|
const lvd = new DataView(lvhi);
|
|
16565
17221
|
lvd.setInt32(0, sdv.getInt32(0, true), true);
|
|
@@ -16568,14 +17224,14 @@ var ListView = (0, import_react9.forwardRef)(function ListViewInner({ columns, d
|
|
|
16568
17224
|
lvd.setInt32(16, -1, true);
|
|
16569
17225
|
const lvhiPtr = bufPtr2(lvhi);
|
|
16570
17226
|
gui10.SendMessage(h, 4153, 0, lvhiPtr);
|
|
16571
|
-
const iItem =
|
|
16572
|
-
const iSubItem =
|
|
17227
|
+
const iItem = readI32(lvhiPtr, 12);
|
|
17228
|
+
const iSubItem = readI32(lvhiPtr, 16);
|
|
16573
17229
|
const style2 = resolveCellStyle(columns, data, iItem, iSubItem);
|
|
16574
17230
|
if (!style2 || style2.cursor === void 0)
|
|
16575
17231
|
return;
|
|
16576
|
-
const hc =
|
|
17232
|
+
const hc = ffi7.ffiCall(loadCursorW, [ffi7.FFI_TYPE_POINTER, ffi7.FFI_TYPE_POINTER], [0, style2.cursor], ffi7.FFI_TYPE_POINTER);
|
|
16577
17233
|
if (hc) {
|
|
16578
|
-
|
|
17234
|
+
ffi7.ffiCall(setCursorFn, [ffi7.FFI_TYPE_POINTER], [hc], ffi7.FFI_TYPE_POINTER);
|
|
16579
17235
|
return 1;
|
|
16580
17236
|
}
|
|
16581
17237
|
return;
|
|
@@ -16844,7 +17500,16 @@ var Slider = (0, import_react13.forwardRef)(({ value, onChange, min = 0, max = 1
|
|
|
16844
17500
|
var import_jsx_runtime13 = __toESM(require_jsx_runtime(), 1);
|
|
16845
17501
|
var import_react14 = __toESM(require_react(), 1);
|
|
16846
17502
|
import * as gui15 from "gui";
|
|
16847
|
-
import * as
|
|
17503
|
+
import * as ffi8 from "ffi";
|
|
17504
|
+
var TCITEMW = struct({
|
|
17505
|
+
mask: "u32",
|
|
17506
|
+
dwState: "u32",
|
|
17507
|
+
dwStateMask: "u32",
|
|
17508
|
+
pszText: "ptr",
|
|
17509
|
+
cchTextMax: "i32",
|
|
17510
|
+
iImage: "i32",
|
|
17511
|
+
lParam: "ptr"
|
|
17512
|
+
});
|
|
16848
17513
|
function textToUtf163(s) {
|
|
16849
17514
|
const buf = new ArrayBuffer((s.length + 1) * 2);
|
|
16850
17515
|
const dv = new DataView(buf);
|
|
@@ -16852,9 +17517,6 @@ function textToUtf163(s) {
|
|
|
16852
17517
|
dv.setUint16(i * 2, s.charCodeAt(i), true);
|
|
16853
17518
|
return buf;
|
|
16854
17519
|
}
|
|
16855
|
-
function readI324(ptr, offset) {
|
|
16856
|
-
return ffi6.readByte(ptr + offset) | ffi6.readByte(ptr + offset + 1) << 8 | ffi6.readByte(ptr + offset + 2) << 16 | ffi6.readByte(ptr + offset + 3) << 24;
|
|
16857
|
-
}
|
|
16858
17520
|
var Tab = (0, import_react14.forwardRef)(({ tabs, selectedIndex: controlledIndex, defaultSelectedIndex = 0, onChange, style }, ref) => {
|
|
16859
17521
|
const [internalIndex, setInternalIndex] = (0, import_react14.useState)(defaultSelectedIndex);
|
|
16860
17522
|
const isControlled = controlledIndex !== void 0;
|
|
@@ -16867,12 +17529,16 @@ var Tab = (0, import_react14.forwardRef)(({ tabs, selectedIndex: controlledIndex
|
|
|
16867
17529
|
gui15.SendMessage(h, 4873, 0, 0);
|
|
16868
17530
|
for (let i = 0; i < tabs.length; i++) {
|
|
16869
17531
|
const titleBuf = textToUtf163(tabs[i].title);
|
|
16870
|
-
const tci =
|
|
16871
|
-
|
|
16872
|
-
|
|
16873
|
-
|
|
16874
|
-
|
|
16875
|
-
|
|
17532
|
+
const tci = TCITEMW.write({
|
|
17533
|
+
mask: 1,
|
|
17534
|
+
dwState: 0,
|
|
17535
|
+
dwStateMask: 0,
|
|
17536
|
+
pszText: ffi8.bufferPtr(titleBuf),
|
|
17537
|
+
cchTextMax: tabs[i].title.length + 1,
|
|
17538
|
+
iImage: 0,
|
|
17539
|
+
lParam: 0
|
|
17540
|
+
});
|
|
17541
|
+
const tciPtr = ffi8.bufferPtr(tci);
|
|
16876
17542
|
gui15.SendMessage(h, 4926, i, tciPtr);
|
|
16877
17543
|
}
|
|
16878
17544
|
gui15.SendMessage(h, 4876, sel, 0);
|
|
@@ -16887,7 +17553,7 @@ var Tab = (0, import_react14.forwardRef)(({ tabs, selectedIndex: controlledIndex
|
|
|
16887
17553
|
const h = tabHwnd.current;
|
|
16888
17554
|
if (!h)
|
|
16889
17555
|
return;
|
|
16890
|
-
const code =
|
|
17556
|
+
const code = nmCode(e.lParam);
|
|
16891
17557
|
if (code === -552 || code === -2) {
|
|
16892
17558
|
const newSel = gui15.SendMessage(h, 4875, 0, 0);
|
|
16893
17559
|
if (newSel !== sel) {
|
|
@@ -16903,13 +17569,38 @@ var Tab = (0, import_react14.forwardRef)(({ tabs, selectedIndex: controlledIndex
|
|
|
16903
17569
|
// _build/lib/react-qw/components/Tooltip.js
|
|
16904
17570
|
var import_react15 = __toESM(require_react(), 1);
|
|
16905
17571
|
import * as gui16 from "gui";
|
|
16906
|
-
import * as
|
|
17572
|
+
import * as ffi9 from "ffi";
|
|
17573
|
+
var TTTOOLINFOW = struct({
|
|
17574
|
+
cbSize: "u32",
|
|
17575
|
+
uFlags: "u32",
|
|
17576
|
+
hwnd: "ptr",
|
|
17577
|
+
uId: "ptr",
|
|
17578
|
+
rect: "i32[4]",
|
|
17579
|
+
hinst: "ptr",
|
|
17580
|
+
lpszText: "ptr",
|
|
17581
|
+
lParam: "ptr",
|
|
17582
|
+
lpReserved: "ptr"
|
|
17583
|
+
// WinXP+ 追加字段(系统 sizeof 含之)
|
|
17584
|
+
});
|
|
16907
17585
|
|
|
16908
17586
|
// _build/lib/react-qw/components/TreeView.js
|
|
16909
17587
|
var import_jsx_runtime14 = __toESM(require_jsx_runtime(), 1);
|
|
16910
17588
|
var import_react16 = __toESM(require_react(), 1);
|
|
16911
17589
|
import * as gui17 from "gui";
|
|
16912
|
-
import * as
|
|
17590
|
+
import * as ffi10 from "ffi";
|
|
17591
|
+
var TVITEM = struct({
|
|
17592
|
+
mask: "u32",
|
|
17593
|
+
hItem: "ptr",
|
|
17594
|
+
state: "u32",
|
|
17595
|
+
stateMask: "u32",
|
|
17596
|
+
pszText: "ptr",
|
|
17597
|
+
cchTextMax: "i32",
|
|
17598
|
+
iImage: "i32",
|
|
17599
|
+
iSelectedImage: "i32",
|
|
17600
|
+
cChildren: "i32",
|
|
17601
|
+
lParam: "ptr"
|
|
17602
|
+
});
|
|
17603
|
+
var TVINSERTSTRUCT = struct({ hParent: "ptr", hInsertAfter: "ptr", item: TVITEM });
|
|
16913
17604
|
function textToUtf164(s) {
|
|
16914
17605
|
const buf = new ArrayBuffer((s.length + 1) * 2);
|
|
16915
17606
|
const dv = new DataView(buf);
|
|
@@ -16917,50 +17608,33 @@ function textToUtf164(s) {
|
|
|
16917
17608
|
dv.setUint16(i * 2, s.charCodeAt(i), true);
|
|
16918
17609
|
return buf;
|
|
16919
17610
|
}
|
|
16920
|
-
function readI325(ptr, offset) {
|
|
16921
|
-
return ffi8.readByte(ptr + offset) | ffi8.readByte(ptr + offset + 1) << 8 | ffi8.readByte(ptr + offset + 2) << 16 | ffi8.readByte(ptr + offset + 3) << 24;
|
|
16922
|
-
}
|
|
16923
17611
|
function bufPtr3(buf) {
|
|
16924
|
-
return
|
|
16925
|
-
}
|
|
16926
|
-
function setPtr(dv, offset, ptr) {
|
|
16927
|
-
dv.setUint32(offset, ptr & 4294967295, true);
|
|
16928
|
-
dv.setUint32(offset + 4, Math.floor(ptr / 4294967296), true);
|
|
17612
|
+
return ffi10.bufferPtr(buf);
|
|
16929
17613
|
}
|
|
16930
17614
|
function buildTvItem(textPtr, cChildren) {
|
|
16931
17615
|
let mask = 1;
|
|
16932
17616
|
if (cChildren > 0)
|
|
16933
17617
|
mask |= 64;
|
|
16934
|
-
|
|
16935
|
-
|
|
16936
|
-
|
|
16937
|
-
|
|
16938
|
-
|
|
16939
|
-
|
|
16940
|
-
|
|
16941
|
-
|
|
16942
|
-
|
|
16943
|
-
|
|
16944
|
-
|
|
16945
|
-
|
|
16946
|
-
return buf;
|
|
16947
|
-
}
|
|
16948
|
-
function buildTvInsertStruct(hParent, hInsertAfter, itemBuf) {
|
|
16949
|
-
const buf = new ArrayBuffer(72);
|
|
16950
|
-
const dv = new DataView(buf);
|
|
16951
|
-
setPtr(dv, 0, hParent);
|
|
16952
|
-
setPtr(dv, 8, hInsertAfter);
|
|
16953
|
-
const src = new DataView(itemBuf);
|
|
16954
|
-
for (let i = 0; i < 56; i += 4)
|
|
16955
|
-
dv.setUint32(16 + i, src.getUint32(i, true), true);
|
|
16956
|
-
return buf;
|
|
17618
|
+
return TVITEM.write({
|
|
17619
|
+
mask,
|
|
17620
|
+
hItem: 0,
|
|
17621
|
+
state: 0,
|
|
17622
|
+
stateMask: 0,
|
|
17623
|
+
pszText: textPtr,
|
|
17624
|
+
cchTextMax: 260,
|
|
17625
|
+
iImage: 0,
|
|
17626
|
+
iSelectedImage: 0,
|
|
17627
|
+
cChildren,
|
|
17628
|
+
lParam: 0
|
|
17629
|
+
});
|
|
16957
17630
|
}
|
|
16958
17631
|
function insertItems(hTree, nodes, parentHandle, hItemMap, keyMap) {
|
|
16959
17632
|
for (const node of nodes) {
|
|
16960
17633
|
const cChildren = node.children && node.children.length > 0 ? 1 : 0;
|
|
16961
17634
|
const textBuf = textToUtf164(node.label);
|
|
16962
17635
|
const itemBuf = buildTvItem(bufPtr3(textBuf), cChildren);
|
|
16963
|
-
const
|
|
17636
|
+
const item = TVITEM.read(itemBuf);
|
|
17637
|
+
const tvins = TVINSERTSTRUCT.write({ hParent: parentHandle, hInsertAfter: -65536, item });
|
|
16964
17638
|
const hItem = gui17.SendMessage(hTree, 4402, 0, bufPtr3(tvins));
|
|
16965
17639
|
hItemMap.set(hItem, node);
|
|
16966
17640
|
if (node.key)
|
|
@@ -17026,7 +17700,7 @@ var TreeView = (0, import_react16.forwardRef)(function TreeViewInner({ data, onS
|
|
|
17026
17700
|
}, [selKey]);
|
|
17027
17701
|
return (0, import_jsx_runtime14.jsx)("w", { type: "STATIC", ws: 268435456 | 33554432, style: { ...style, flexDirection: "column", alignItems: "stretch" }, ref, onEvent: (e) => {
|
|
17028
17702
|
if (e.msg === 78) {
|
|
17029
|
-
const code =
|
|
17703
|
+
const code = nmCode(e.lParam);
|
|
17030
17704
|
if (code === -451) {
|
|
17031
17705
|
const h = tvRef.current;
|
|
17032
17706
|
if (!h)
|
|
@@ -17047,10 +17721,49 @@ var TreeView = (0, import_react16.forwardRef)(function TreeViewInner({ data, onS
|
|
|
17047
17721
|
// _build/lib/react-qw/components/PathPicker.js
|
|
17048
17722
|
var import_jsx_runtime15 = __toESM(require_jsx_runtime(), 1);
|
|
17049
17723
|
var import_react17 = __toESM(require_react(), 1);
|
|
17050
|
-
import * as
|
|
17724
|
+
import * as ffi11 from "ffi";
|
|
17051
17725
|
import * as win3 from "win";
|
|
17052
|
-
|
|
17053
|
-
|
|
17726
|
+
|
|
17727
|
+
// _build/lib/win-common-structs.js
|
|
17728
|
+
var OPENFILENAMEW = struct({
|
|
17729
|
+
lStructSize: "u32",
|
|
17730
|
+
hwndOwner: "ptr",
|
|
17731
|
+
hInstance: "ptr",
|
|
17732
|
+
lpstrFilter: "ptr",
|
|
17733
|
+
lpstrCustomFilter: "ptr",
|
|
17734
|
+
nMaxCustFilter: "u32",
|
|
17735
|
+
nFilterIndex: "u32",
|
|
17736
|
+
lpstrFile: "ptr",
|
|
17737
|
+
nMaxFile: "u32",
|
|
17738
|
+
lpstrFileTitle: "ptr",
|
|
17739
|
+
nMaxFileTitle: "u32",
|
|
17740
|
+
lpstrInitialDir: "ptr",
|
|
17741
|
+
lpstrTitle: "ptr",
|
|
17742
|
+
Flags: "u32",
|
|
17743
|
+
nFileOffset: "u16",
|
|
17744
|
+
nFileExtension: "u16",
|
|
17745
|
+
lpstrDefExt: "ptr",
|
|
17746
|
+
lCustData: "ptr",
|
|
17747
|
+
lpfnHook: "ptr",
|
|
17748
|
+
lpTemplateName: "ptr",
|
|
17749
|
+
pvReserved: "ptr",
|
|
17750
|
+
dwReserved: "u32",
|
|
17751
|
+
FlagsEx: "u32"
|
|
17752
|
+
});
|
|
17753
|
+
var BROWSEINFOW = struct({
|
|
17754
|
+
hwndOwner: "ptr",
|
|
17755
|
+
pidlRoot: "ptr",
|
|
17756
|
+
pszDisplayName: "ptr",
|
|
17757
|
+
lpszTitle: "ptr",
|
|
17758
|
+
ulFlags: "u32",
|
|
17759
|
+
lpfn: "ptr",
|
|
17760
|
+
lParam: "ptr",
|
|
17761
|
+
iImage: "i32"
|
|
17762
|
+
});
|
|
17763
|
+
|
|
17764
|
+
// _build/lib/react-qw/components/PathPicker.js
|
|
17765
|
+
var FFI_PTR = ffi11.FFI_TYPE_POINTER;
|
|
17766
|
+
var FFI_U32 = ffi11.FFI_TYPE_UINT32;
|
|
17054
17767
|
var _GetOpenFileNameW = 0;
|
|
17055
17768
|
var _SHBrowseForFolderW = 0;
|
|
17056
17769
|
var _SHGetPathFromIDListW = 0;
|
|
@@ -17079,31 +17792,42 @@ function wideToStr(buf, offset = 0) {
|
|
|
17079
17792
|
const nullIdx = str.indexOf("\0");
|
|
17080
17793
|
return nullIdx >= 0 ? str.substring(0, nullIdx) : str;
|
|
17081
17794
|
}
|
|
17082
|
-
function setPtr2(dv, off, ptr) {
|
|
17083
|
-
dv.setUint32(off, ptr & 4294967295, true);
|
|
17084
|
-
dv.setUint32(off + 4, Math.floor(ptr / 4294967296), true);
|
|
17085
|
-
}
|
|
17086
17795
|
function openFileDialog(owner, filter, title, multiple) {
|
|
17087
17796
|
if (!ensureDlls())
|
|
17088
17797
|
return null;
|
|
17089
|
-
const structBuf = new ArrayBuffer(152);
|
|
17090
|
-
const sv = new DataView(structBuf);
|
|
17091
17798
|
const fileBuf = new ArrayBuffer(260 * 2);
|
|
17092
17799
|
const filterWide = strToWide(filter);
|
|
17093
17800
|
const titleWide = title ? strToWide(title) : null;
|
|
17094
|
-
sv.setUint32(0, 152, true);
|
|
17095
|
-
setPtr2(sv, 8, owner);
|
|
17096
|
-
setPtr2(sv, 24, ffi9.bufferPtr(filterWide));
|
|
17097
|
-
setPtr2(sv, 48, ffi9.bufferPtr(fileBuf));
|
|
17098
|
-
sv.setUint32(56, 260, true);
|
|
17099
17801
|
let flags = 4096 | 2048 | 8;
|
|
17100
17802
|
if (multiple)
|
|
17101
17803
|
flags |= 512;
|
|
17102
17804
|
flags |= 524288;
|
|
17103
|
-
|
|
17104
|
-
|
|
17105
|
-
|
|
17106
|
-
|
|
17805
|
+
const ofn = OPENFILENAMEW.write({
|
|
17806
|
+
lStructSize: OPENFILENAMEW.size,
|
|
17807
|
+
hwndOwner: owner,
|
|
17808
|
+
hInstance: 0,
|
|
17809
|
+
lpstrFilter: ffi11.bufferPtr(filterWide),
|
|
17810
|
+
lpstrCustomFilter: 0,
|
|
17811
|
+
nMaxCustFilter: 0,
|
|
17812
|
+
nFilterIndex: 0,
|
|
17813
|
+
lpstrFile: ffi11.bufferPtr(fileBuf),
|
|
17814
|
+
nMaxFile: 260,
|
|
17815
|
+
lpstrFileTitle: 0,
|
|
17816
|
+
nMaxFileTitle: 0,
|
|
17817
|
+
lpstrInitialDir: 0,
|
|
17818
|
+
lpstrTitle: titleWide ? ffi11.bufferPtr(titleWide) : 0,
|
|
17819
|
+
Flags: flags,
|
|
17820
|
+
nFileOffset: 0,
|
|
17821
|
+
nFileExtension: 0,
|
|
17822
|
+
lpstrDefExt: 0,
|
|
17823
|
+
lCustData: 0,
|
|
17824
|
+
lpfnHook: 0,
|
|
17825
|
+
lpTemplateName: 0,
|
|
17826
|
+
pvReserved: 0,
|
|
17827
|
+
dwReserved: 0,
|
|
17828
|
+
FlagsEx: 0
|
|
17829
|
+
});
|
|
17830
|
+
const ret = ffi11.ffiCall(_GetOpenFileNameW, [FFI_PTR], [ofn], FFI_U32);
|
|
17107
17831
|
if (!ret)
|
|
17108
17832
|
return null;
|
|
17109
17833
|
if (!multiple) {
|
|
@@ -17126,19 +17850,23 @@ function openFileDialog(owner, filter, title, multiple) {
|
|
|
17126
17850
|
function openFolderDialog(owner, title) {
|
|
17127
17851
|
if (!ensureDlls())
|
|
17128
17852
|
return null;
|
|
17129
|
-
const structBuf = new ArrayBuffer(64);
|
|
17130
|
-
const sv = new DataView(structBuf);
|
|
17131
17853
|
const titleWide = title ? strToWide(title) : null;
|
|
17132
|
-
|
|
17133
|
-
|
|
17134
|
-
|
|
17135
|
-
|
|
17136
|
-
|
|
17854
|
+
const bi = BROWSEINFOW.write({
|
|
17855
|
+
hwndOwner: owner,
|
|
17856
|
+
pidlRoot: 0,
|
|
17857
|
+
pszDisplayName: 0,
|
|
17858
|
+
lpszTitle: titleWide ? ffi11.bufferPtr(titleWide) : 0,
|
|
17859
|
+
ulFlags: 65,
|
|
17860
|
+
lpfn: 0,
|
|
17861
|
+
lParam: 0,
|
|
17862
|
+
iImage: 0
|
|
17863
|
+
});
|
|
17864
|
+
const pidl = ffi11.ffiCall(_SHBrowseForFolderW, [FFI_PTR], [bi], FFI_PTR);
|
|
17137
17865
|
if (!pidl)
|
|
17138
17866
|
return null;
|
|
17139
17867
|
const pathBuf = new ArrayBuffer(260 * 2);
|
|
17140
|
-
const ok =
|
|
17141
|
-
|
|
17868
|
+
const ok = ffi11.ffiCall(_SHGetPathFromIDListW, [ffi11.FFI_TYPE_POINTER, FFI_PTR], [pidl, pathBuf], FFI_U32);
|
|
17869
|
+
ffi11.ffiCall(_CoTaskMemFree, [ffi11.FFI_TYPE_POINTER], [pidl], ffi11.FFI_TYPE_VOID);
|
|
17142
17870
|
return ok ? wideToStr(pathBuf) : null;
|
|
17143
17871
|
}
|
|
17144
17872
|
var PathPicker = (0, import_react17.forwardRef)((props, ref) => {
|
|
@@ -17255,23 +17983,23 @@ function render(element, containerOrConfig, _callback) {
|
|
|
17255
17983
|
var import_jsx_runtime16 = __toESM(require_jsx_runtime(), 1);
|
|
17256
17984
|
var import_react18 = __toESM(require_react(), 1);
|
|
17257
17985
|
import * as win4 from "win";
|
|
17258
|
-
import * as
|
|
17986
|
+
import * as ffi12 from "ffi";
|
|
17259
17987
|
var _user32 = win4.LoadLibrary("user32.dll");
|
|
17260
17988
|
var _gdi32 = win4.LoadLibrary("gdi32.dll");
|
|
17261
17989
|
if (!_user32 || !_gdi32)
|
|
17262
17990
|
throw new Error("Failed to load user32/gdi32");
|
|
17263
|
-
function
|
|
17991
|
+
function loadProc(lib, name) {
|
|
17264
17992
|
const ptr = win4.GetProcAddress(lib, name);
|
|
17265
17993
|
if (!ptr)
|
|
17266
17994
|
throw new Error("Failed to load " + name);
|
|
17267
17995
|
return ptr;
|
|
17268
17996
|
}
|
|
17269
|
-
var GetDC_ =
|
|
17270
|
-
var ReleaseDC_ =
|
|
17271
|
-
var SetDIBitsToDevice_ =
|
|
17272
|
-
var
|
|
17273
|
-
var FFI_U322 =
|
|
17274
|
-
var
|
|
17997
|
+
var GetDC_ = loadProc(_user32, "GetDC");
|
|
17998
|
+
var ReleaseDC_ = loadProc(_user32, "ReleaseDC");
|
|
17999
|
+
var SetDIBitsToDevice_ = loadProc(_gdi32, "SetDIBitsToDevice");
|
|
18000
|
+
var FFI_PTR2 = ffi12.FFI_TYPE_POINTER;
|
|
18001
|
+
var FFI_U322 = ffi12.FFI_TYPE_UINT32;
|
|
18002
|
+
var FFI_S32 = ffi12.FFI_TYPE_SINT32;
|
|
17275
18003
|
function makeBitmapInfo(w, h) {
|
|
17276
18004
|
const bmi = new ArrayBuffer(40);
|
|
17277
18005
|
const bv = new DataView(bmi);
|
|
@@ -17300,21 +18028,21 @@ var PdfCanvas = (0, import_react18.forwardRef)(({ pixmap, style }, ref) => {
|
|
|
17300
18028
|
const pm = pixmapRef.current;
|
|
17301
18029
|
if (!pm)
|
|
17302
18030
|
return 0;
|
|
17303
|
-
const hdc =
|
|
18031
|
+
const hdc = ffi12.ffiCall(GetDC_, [ffi12.FFI_TYPE_POINTER], [hwnd], ffi12.FFI_TYPE_POINTER);
|
|
17304
18032
|
if (hdc) {
|
|
17305
18033
|
const bmi = makeBitmapInfo(pm.w, pm.h);
|
|
17306
|
-
|
|
17307
|
-
|
|
17308
|
-
|
|
17309
|
-
|
|
18034
|
+
ffi12.ffiCall(SetDIBitsToDevice_, [
|
|
18035
|
+
ffi12.FFI_TYPE_POINTER,
|
|
18036
|
+
FFI_S32,
|
|
18037
|
+
FFI_S32,
|
|
17310
18038
|
FFI_U322,
|
|
17311
18039
|
FFI_U322,
|
|
17312
|
-
|
|
17313
|
-
|
|
18040
|
+
FFI_S32,
|
|
18041
|
+
FFI_S32,
|
|
17314
18042
|
FFI_U322,
|
|
17315
18043
|
FFI_U322,
|
|
17316
|
-
|
|
17317
|
-
|
|
18044
|
+
FFI_PTR2,
|
|
18045
|
+
FFI_PTR2,
|
|
17318
18046
|
FFI_U322
|
|
17319
18047
|
], [
|
|
17320
18048
|
hdc,
|
|
@@ -17329,8 +18057,8 @@ var PdfCanvas = (0, import_react18.forwardRef)(({ pixmap, style }, ref) => {
|
|
|
17329
18057
|
pm.data,
|
|
17330
18058
|
bmi,
|
|
17331
18059
|
0
|
|
17332
|
-
],
|
|
17333
|
-
|
|
18060
|
+
], FFI_S32);
|
|
18061
|
+
ffi12.ffiCall(ReleaseDC_, [ffi12.FFI_TYPE_POINTER, ffi12.FFI_TYPE_POINTER], [hwnd, hdc], FFI_S32);
|
|
17334
18062
|
}
|
|
17335
18063
|
return 0;
|
|
17336
18064
|
}
|
|
@@ -17346,15 +18074,15 @@ if (!_user322 || !_gdi322 || !_comdlg32) {
|
|
|
17346
18074
|
gui19.MessageBox("Failed to load system libraries");
|
|
17347
18075
|
std.exit(0);
|
|
17348
18076
|
}
|
|
17349
|
-
function
|
|
18077
|
+
function loadProc2(lib, name) {
|
|
17350
18078
|
const ptr = win5.GetProcAddress(lib, name);
|
|
17351
18079
|
if (!ptr)
|
|
17352
18080
|
throw new Error("Failed to load " + name);
|
|
17353
18081
|
return ptr;
|
|
17354
18082
|
}
|
|
17355
|
-
var GetOpenFileNameW_ =
|
|
17356
|
-
var
|
|
17357
|
-
var FFI_U323 =
|
|
18083
|
+
var GetOpenFileNameW_ = loadProc2(_comdlg32, "GetOpenFileNameW");
|
|
18084
|
+
var FFI_PTR3 = ffi13.FFI_TYPE_POINTER;
|
|
18085
|
+
var FFI_U323 = ffi13.FFI_TYPE_UINT32;
|
|
17358
18086
|
function strToWide2(str) {
|
|
17359
18087
|
const buf = new ArrayBuffer((str.length + 1) * 2);
|
|
17360
18088
|
const dv = new DataView(buf);
|
|
@@ -17373,23 +18101,36 @@ function wideToStr2(buf) {
|
|
|
17373
18101
|
}
|
|
17374
18102
|
return String.fromCharCode(...chars);
|
|
17375
18103
|
}
|
|
17376
|
-
function setPtr3(dv, off, ptr) {
|
|
17377
|
-
dv.setUint32(off, ptr & 4294967295, true);
|
|
17378
|
-
dv.setUint32(off + 4, Math.floor(ptr / 4294967296), true);
|
|
17379
|
-
}
|
|
17380
18104
|
function openPdfFileDialog(owner) {
|
|
17381
|
-
const structBuf = new ArrayBuffer(152);
|
|
17382
|
-
const sv = new DataView(structBuf);
|
|
17383
18105
|
const fileBuf = new ArrayBuffer(260 * 2);
|
|
17384
18106
|
const filterWide = strToWide2("PDF Files\0*.pdf\0All Files\0*.*\0\0");
|
|
17385
|
-
|
|
17386
|
-
|
|
17387
|
-
|
|
17388
|
-
|
|
17389
|
-
|
|
17390
|
-
|
|
17391
|
-
|
|
17392
|
-
|
|
18107
|
+
const ofn = OPENFILENAMEW.write({
|
|
18108
|
+
lStructSize: OPENFILENAMEW.size,
|
|
18109
|
+
hwndOwner: owner,
|
|
18110
|
+
hInstance: 0,
|
|
18111
|
+
lpstrFilter: ffi13.bufferPtr(filterWide),
|
|
18112
|
+
lpstrCustomFilter: 0,
|
|
18113
|
+
nMaxCustFilter: 0,
|
|
18114
|
+
nFilterIndex: 0,
|
|
18115
|
+
lpstrFile: ffi13.bufferPtr(fileBuf),
|
|
18116
|
+
nMaxFile: 260,
|
|
18117
|
+
lpstrFileTitle: 0,
|
|
18118
|
+
nMaxFileTitle: 0,
|
|
18119
|
+
lpstrInitialDir: 0,
|
|
18120
|
+
lpstrTitle: 0,
|
|
18121
|
+
Flags: 4096 | 2048 | 4,
|
|
18122
|
+
nFileOffset: 0,
|
|
18123
|
+
nFileExtension: 0,
|
|
18124
|
+
lpstrDefExt: 0,
|
|
18125
|
+
lCustData: 0,
|
|
18126
|
+
lpfnHook: 0,
|
|
18127
|
+
lpTemplateName: 0,
|
|
18128
|
+
pvReserved: 0,
|
|
18129
|
+
dwReserved: 0,
|
|
18130
|
+
FlagsEx: 0
|
|
18131
|
+
});
|
|
18132
|
+
ofn.__keep = [fileBuf, filterWide];
|
|
18133
|
+
const ret = ffi13.ffiCall(GetOpenFileNameW_, [FFI_PTR3], [ofn], FFI_U323);
|
|
17393
18134
|
if (!ret)
|
|
17394
18135
|
return null;
|
|
17395
18136
|
const path = wideToStr2(fileBuf);
|