quickwin 2.1.1 → 2.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 +9 -9
- package/README.md +9 -9
- package/constants.ts +1063 -0
- package/enum_map.d.ts +129 -0
- package/examples/PdfCanvas.js +2 -2
- package/examples/PdfCanvas.tsx +3 -2
- package/examples/{exec_server.js → execd/main.js} +1114 -287
- package/examples/execd/tray.js +192 -0
- package/examples/execd/worker.js +122 -0
- package/examples/pdf_preview2.js +46 -46
- package/examples/pdf_preview2.ts +55 -54
- package/examples/pdf_viewer.js +134 -130
- package/examples/pdf_viewer.tsx +6 -5
- package/examples/test_gallery.js +135 -131
- package/examples/test_gallery.tsx +9 -8
- package/examples/test_react_lazy.js +130 -128
- package/examples/test_react_lazy.tsx +7 -6
- package/examples/test_react_listbox.js +130 -128
- package/examples/test_react_listbox.tsx +8 -7
- package/examples/test_root_window.js +130 -128
- package/examples/test_root_window.tsx +5 -5
- package/examples/test_tab.js +130 -128
- package/examples/test_tab.tsx +7 -6
- package/examples/tray_demo.js +8 -8
- package/examples/tray_demo.tsx +9 -8
- package/lib/dumpRects.js +2 -2
- package/lib/dumpRects.ts +3 -2
- package/lib/fetch.js +15 -15
- package/lib/fetch.ts +16 -15
- package/lib/ffi/bind.js +3 -3
- package/lib/ffi/bind.ts +3 -3
- package/lib/ffi/ctype.ts +3 -1
- package/lib/ffi/struct.js +23 -7
- package/lib/ffi/struct.ts +50 -23
- package/lib/http-server.js +5 -5
- package/lib/http-server.ts +6 -5
- package/lib/react-qw/components/Button.js +2 -2
- package/lib/react-qw/components/CheckBox.js +4 -4
- package/lib/react-qw/components/ComboBox.js +10 -10
- package/lib/react-qw/components/DateTimePicker.js +12 -12
- package/lib/react-qw/components/Input.js +7 -7
- package/lib/react-qw/components/Link.js +4 -4
- package/lib/react-qw/components/ListBox.js +12 -12
- package/lib/react-qw/components/ListView.js +35 -35
- package/lib/react-qw/components/PathPicker.js +3 -3
- package/lib/react-qw/components/ProgressBar.js +4 -4
- package/lib/react-qw/components/RadioButton.js +4 -4
- package/lib/react-qw/components/ScrollView.js +28 -28
- package/lib/react-qw/components/Slider.js +11 -11
- package/lib/react-qw/components/Tab.js +10 -10
- package/lib/react-qw/components/Tooltip.js +8 -8
- package/lib/react-qw/components/TreeView.js +20 -20
- package/lib/react-qw/index.js +5 -5
- package/lib/react-qw/index.ts +6 -5
- package/lib/react-qw/props.js +4 -4
- package/lib/react-qw/props.ts +5 -4
- package/lib/react-qw/reconciler.js +10 -10
- package/lib/react-qw/reconciler.ts +11 -10
- package/lib/text-measure.js +3 -3
- package/lib/text-measure.ts +4 -3
- package/lib/websocket.js +17 -17
- package/lib/websocket.ts +18 -17
- package/lib/windows/advapi32.js +7 -7
- package/lib/windows/advapi32.ts +7 -7
- package/lib/windows/gdi32.js +17 -17
- package/lib/windows/gdi32.ts +17 -17
- package/lib/windows/kernel32.js +41 -2
- package/lib/windows/kernel32.ts +45 -2
- package/lib/windows/shell32.js +24 -3
- package/lib/windows/shell32.ts +27 -4
- package/lib/windows/structs.js +230 -92
- package/lib/windows/structs.ts +278 -92
- package/lib/windows/user32.js +18 -6
- package/lib/windows/user32.ts +18 -6
- package/lib/windows/winspool.js +3 -3
- package/lib/windows/winspool.ts +3 -3
- package/package.json +4 -3
- package/quickwin.d.ts +32 -10
- 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/test_ffi_bind.js +12 -10
- package/test/test_ffi_bind.ts +14 -12
- package/test/test_ffi_struct.js +60 -26
- package/test/test_ffi_struct.ts +58 -28
- package/test/test_ffi_windows.js +1 -1
- package/test/test_ffi_windows.ts +1 -1
- package/test/test_files.js +7 -7
- package/test/test_files.ts +8 -8
- package/test/test_gdi_draw.js +51 -51
- package/test/test_gdi_draw.ts +57 -57
- package/test/test_http_server.js +3 -3
- package/test/test_http_server.ts +4 -3
- package/test/test_ipv6.js +3 -3
- package/test/test_ipv6.ts +4 -3
- package/test/test_net_event.js +3 -3
- package/test/test_net_event.ts +4 -3
- package/test/test_printer.js +4 -4
- package/test/test_printer.ts +5 -5
- package/test/test_react_complex.js +132 -130
- package/test/test_react_counter.js +130 -128
- package/test/test_react_flex.js +132 -130
- package/test/test_react_hidden.js +130 -128
- package/test/test_react_listview_link.js +131 -129
- package/test/test_react_notify.js +148 -146
- package/test/test_react_render.js +130 -128
- package/test/test_registry.js +6 -6
- package/test/test_registry.ts +8 -8
- package/test/test_wolfssl_read.js +8 -8
- package/test/test_wolfssl_read.ts +9 -8
- package/examples/exec_server.tsx +0 -488
- package/examples/exec_server_worker.js +0 -395
- package/examples/exec_server_worker.ts +0 -417
- package/examples/setres.js +0 -79
- package/examples/setres.ts +0 -86
- package/quickwin_const.d.ts +0 -1037
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef } from 'react';
|
|
3
3
|
export const Button = forwardRef(({ children, onClick, style, disabled }, ref) => {
|
|
4
|
-
return (_jsx("w", { type: "BUTTON", text: children != null ? (Array.isArray(children) ? children.join('') : String(children)) : '', ws: 268435456 /*
|
|
5
|
-
if (e.msg === 514 /*
|
|
4
|
+
return (_jsx("w", { type: "BUTTON", text: children != null ? (Array.isArray(children) ? children.join('') : String(children)) : '', ws: 268435456 /* WindowStyle.VISIBLE */, style: style, disabled: disabled, ref: ref, onEvent: (e) => {
|
|
5
|
+
if (e.msg === 514 /* WmMsg.LBUTTONUP */)
|
|
6
6
|
onClick?.();
|
|
7
7
|
} }));
|
|
8
8
|
});
|
|
@@ -10,17 +10,17 @@ export const CheckBox = forwardRef(({ checked: controlledChecked, defaultChecked
|
|
|
10
10
|
const h = cbRef.current;
|
|
11
11
|
if (!h)
|
|
12
12
|
return;
|
|
13
|
-
gui.SendMessage(h, 241 /*
|
|
13
|
+
gui.SendMessage(h, 241 /* ButtonMsg.SETCHECK */, displayChecked ? 1 /* ButtonCheckState.CHECKED */ : 0 /* ButtonCheckState.UNCHECKED */, 0);
|
|
14
14
|
}, [displayChecked]);
|
|
15
|
-
return (_jsx("w", { type: "BUTTON", text: label ?? '', ws: 268435456 /*
|
|
15
|
+
return (_jsx("w", { type: "BUTTON", text: label ?? '', ws: 268435456 /* WindowStyle.VISIBLE */ | 3 /* ButtonStyle.AUTOCHECKBOX */, style: style, disabled: disabled, ref: (h) => {
|
|
16
16
|
cbRef.current = h;
|
|
17
17
|
if (typeof ref === 'function')
|
|
18
18
|
ref(h);
|
|
19
19
|
else if (ref)
|
|
20
20
|
ref.current = h;
|
|
21
21
|
}, onEvent: (e) => {
|
|
22
|
-
if (e.msg === 514 /*
|
|
23
|
-
const newChecked = gui.SendMessage(e.hwnd, 240 /*
|
|
22
|
+
if (e.msg === 514 /* WmMsg.LBUTTONUP */) {
|
|
23
|
+
const newChecked = gui.SendMessage(e.hwnd, 240 /* ButtonMsg.GETCHECK */, 0, 0) !== 0;
|
|
24
24
|
if (newChecked !== displayChecked) {
|
|
25
25
|
if (!isControlled)
|
|
26
26
|
setInternalChecked(newChecked);
|
|
@@ -6,32 +6,32 @@ export const ComboBox = forwardRef(({ items, selectedIndex: controlledIndex, def
|
|
|
6
6
|
const isControlled = controlledIndex !== undefined;
|
|
7
7
|
const sel = isControlled ? controlledIndex : internalIndex;
|
|
8
8
|
const cbRef = useRef(null);
|
|
9
|
-
const cbWs = 268435456 /*
|
|
10
|
-
| 3 /*
|
|
9
|
+
const cbWs = 268435456 /* WindowStyle.VISIBLE */ | 8388608 /* WindowStyle.BORDER */
|
|
10
|
+
| 3 /* ComboBoxStyle.DROPDOWNLIST */ | 512 /* ComboBoxStyle.HASSTRINGS */;
|
|
11
11
|
useEffect(() => {
|
|
12
12
|
const h = cbRef.current;
|
|
13
13
|
if (!h)
|
|
14
14
|
return;
|
|
15
|
-
gui.SendMessage(h, 331 /*
|
|
15
|
+
gui.SendMessage(h, 331 /* ComboBoxMsg.RESETCONTENT */, 0, 0);
|
|
16
16
|
for (const item of items)
|
|
17
|
-
gui.SendMessage(h, 323 /*
|
|
17
|
+
gui.SendMessage(h, 323 /* ComboBoxMsg.ADDSTRING */, 0, item);
|
|
18
18
|
if (sel >= 0 && sel < items.length)
|
|
19
|
-
gui.SendMessage(h, 334 /*
|
|
19
|
+
gui.SendMessage(h, 334 /* ComboBoxMsg.SETCURSEL */, sel, 0);
|
|
20
20
|
}, [items]);
|
|
21
21
|
useEffect(() => {
|
|
22
22
|
const h = cbRef.current;
|
|
23
23
|
if (h)
|
|
24
|
-
gui.SendMessage(h, 334 /*
|
|
24
|
+
gui.SendMessage(h, 334 /* ComboBoxMsg.SETCURSEL */, sel, 0);
|
|
25
25
|
}, [sel]);
|
|
26
|
-
return (_jsx("w", { type: "STATIC", ws: 268435456 /*
|
|
27
|
-
if (e.msg !== 273 /*
|
|
26
|
+
return (_jsx("w", { type: "STATIC", ws: 268435456 /* WindowStyle.VISIBLE */ | 33554432 /* WindowStyle.CLIPCHILDREN */, style: { ...style, flexDirection: 'column', alignItems: 'stretch' }, ref: ref, onEvent: (e) => {
|
|
27
|
+
if (e.msg !== 273 /* WmMsg.COMMAND */)
|
|
28
28
|
return;
|
|
29
29
|
const code = (e.wParam >> 16) & 0xFFFF;
|
|
30
|
-
if (code === 1 /*
|
|
30
|
+
if (code === 1 /* CbnCode.SELCHANGE */) {
|
|
31
31
|
const h = cbRef.current;
|
|
32
32
|
if (!h)
|
|
33
33
|
return;
|
|
34
|
-
const newSel = gui.SendMessage(h, 327 /*
|
|
34
|
+
const newSel = gui.SendMessage(h, 327 /* ComboBoxMsg.GETCURSEL */, 0, 0);
|
|
35
35
|
if (newSel !== sel && newSel >= 0) {
|
|
36
36
|
if (!isControlled)
|
|
37
37
|
setInternalIndex(newSel);
|
|
@@ -24,15 +24,15 @@ const DateTimePicker = forwardRef(function DateTimePicker({ value, onChange, def
|
|
|
24
24
|
const dpRef = useRef(null);
|
|
25
25
|
const onChangeRef = useRef(onChange);
|
|
26
26
|
onChangeRef.current = onChange;
|
|
27
|
-
let dpStyle = 268435456 /*
|
|
27
|
+
let dpStyle = 268435456 /* WindowStyle.VISIBLE */ | 8388608 /* WindowStyle.BORDER */;
|
|
28
28
|
if (format === 'long')
|
|
29
|
-
dpStyle |= 4 /*
|
|
29
|
+
dpStyle |= 4 /* DtStyle.LONGDATEFORMAT */;
|
|
30
30
|
else if (format === 'time')
|
|
31
|
-
dpStyle |= 9 /*
|
|
31
|
+
dpStyle |= 9 /* DtStyle.TIMEFORMAT */;
|
|
32
32
|
if (updown)
|
|
33
|
-
dpStyle |= 1 /*
|
|
33
|
+
dpStyle |= 1 /* DtStyle.UPDOWN */;
|
|
34
34
|
if (allowNone)
|
|
35
|
-
dpStyle |= 2 /*
|
|
35
|
+
dpStyle |= 2 /* DtStyle.SHOWNONE */;
|
|
36
36
|
useEffect(() => {
|
|
37
37
|
const h = dpRef.current;
|
|
38
38
|
if (!h)
|
|
@@ -40,10 +40,10 @@ const DateTimePicker = forwardRef(function DateTimePicker({ value, onChange, def
|
|
|
40
40
|
const d = effectiveDate;
|
|
41
41
|
if (d) {
|
|
42
42
|
const buf = dateToSysTimeBuf(d);
|
|
43
|
-
gui.SendMessage(h, 4098 /*
|
|
43
|
+
gui.SendMessage(h, 4098 /* DtMsg.SETSYSTEMTIME */, 0 /* DtFlag.GDT_VALID */, buf.ptr);
|
|
44
44
|
}
|
|
45
45
|
else {
|
|
46
|
-
gui.SendMessage(h, 4098 /*
|
|
46
|
+
gui.SendMessage(h, 4098 /* DtMsg.SETSYSTEMTIME */, 1 /* DtFlag.GDT_NONE */, 0);
|
|
47
47
|
}
|
|
48
48
|
}, [effectiveDate]);
|
|
49
49
|
useEffect(() => {
|
|
@@ -56,16 +56,16 @@ const DateTimePicker = forwardRef(function DateTimePicker({ value, onChange, def
|
|
|
56
56
|
if (cr) {
|
|
57
57
|
const w = cr.right - cr.left;
|
|
58
58
|
const hh = cr.bottom - cr.top;
|
|
59
|
-
gui.SendMessage(h, 5 /*
|
|
59
|
+
gui.SendMessage(h, 5 /* WmMsg.SIZE */, 0, (hh << 16) | w);
|
|
60
60
|
}
|
|
61
61
|
}, []);
|
|
62
|
-
return (_jsx("w", { type: "STATIC", ws: 268435456 /*
|
|
63
|
-
if (e.msg === 78 /*
|
|
62
|
+
return (_jsx("w", { type: "STATIC", ws: 268435456 /* WindowStyle.VISIBLE */ | 33554432 /* WindowStyle.CLIPCHILDREN */, style: { ...style, flexDirection: 'column', alignItems: 'stretch' }, ref: ref, onEvent: (e) => {
|
|
63
|
+
if (e.msg === 78 /* WmMsg.NOTIFY */) {
|
|
64
64
|
const code = nmCode(e.lParam);
|
|
65
|
-
if (code === -759 /*
|
|
65
|
+
if (code === -759 /* DtNotifyCode.DATETIMECHANGE */) {
|
|
66
66
|
// NMDATETIMECHANGE: NMHDR + DWORD dwFlags + SYSTEMTIME st
|
|
67
67
|
const { dwFlags, st } = NMDATETIMECHANGE.decode(e.lParam);
|
|
68
|
-
if (dwFlags === 1 /*
|
|
68
|
+
if (dwFlags === 1 /* DtFlag.GDT_NONE */) {
|
|
69
69
|
if (!isControlled)
|
|
70
70
|
setInternalDate(null);
|
|
71
71
|
onChangeRef.current?.(null);
|
|
@@ -7,21 +7,21 @@ export const Input = forwardRef(({ value: controlledValue, defaultValue = '', on
|
|
|
7
7
|
const isControlled = controlledValue !== undefined;
|
|
8
8
|
const displayValue = isControlled ? controlledValue : internalValue;
|
|
9
9
|
const inputRef = useRef(null);
|
|
10
|
-
let ws = 268435456 /*
|
|
10
|
+
let ws = 268435456 /* WindowStyle.VISIBLE */ | 8388608 /* WindowStyle.BORDER */;
|
|
11
11
|
if (multiline)
|
|
12
|
-
ws |= 4 /*
|
|
12
|
+
ws |= 4 /* EditStyle.MULTILINE */ | 64 /* EditStyle.AUTOVSCROLL */ | 2097152 /* WindowStyle.VSCROLL */;
|
|
13
13
|
if (readonly)
|
|
14
|
-
ws |= 2048 /*
|
|
14
|
+
ws |= 2048 /* EditStyle.READONLY */;
|
|
15
15
|
if (number)
|
|
16
|
-
ws |= 8192 /*
|
|
16
|
+
ws |= 8192 /* EditStyle.NUMBER */;
|
|
17
17
|
if (password)
|
|
18
|
-
ws |= 32 /*
|
|
18
|
+
ws |= 32 /* EditStyle.PASSWORD */ | 128 /* EditStyle.AUTOHSCROLL */;
|
|
19
19
|
useEffect(() => {
|
|
20
20
|
const h = inputRef.current;
|
|
21
21
|
if (!h || !placeholder)
|
|
22
22
|
return;
|
|
23
23
|
const buf = WCHAR.encode(placeholder);
|
|
24
|
-
gui.SendMessage(h, 5377 /*
|
|
24
|
+
gui.SendMessage(h, 5377 /* EditMsg.SETCUEBANNER */, 1, buf.ptr);
|
|
25
25
|
}, [placeholder]);
|
|
26
26
|
return (_jsx("w", { type: "EDIT", text: displayValue, ws: ws, style: style, disabled: disabled, ref: (h) => {
|
|
27
27
|
inputRef.current = h;
|
|
@@ -30,7 +30,7 @@ export const Input = forwardRef(({ value: controlledValue, defaultValue = '', on
|
|
|
30
30
|
else if (ref)
|
|
31
31
|
ref.current = h;
|
|
32
32
|
}, onEvent: (e) => {
|
|
33
|
-
if (e.msg === 258 /*
|
|
33
|
+
if (e.msg === 258 /* WmMsg.CHAR */) {
|
|
34
34
|
const h = inputRef.current;
|
|
35
35
|
if (!h)
|
|
36
36
|
return;
|
|
@@ -16,13 +16,13 @@ const Link = forwardRef(function Link({ href, children, onClick, style }, ref) {
|
|
|
16
16
|
return;
|
|
17
17
|
InvalidateRect(h, NULL, 1);
|
|
18
18
|
}, [linkText]);
|
|
19
|
-
return (_jsx("w", { type: "STATIC", ws: 268435456 /*
|
|
20
|
-
if (e.msg === 78 /*
|
|
19
|
+
return (_jsx("w", { type: "STATIC", ws: 268435456 /* WindowStyle.VISIBLE */ | 33554432 /* WindowStyle.CLIPCHILDREN */, style: { ...style, flexDirection: 'column', alignItems: 'stretch' }, ref: ref, onEvent: (e) => {
|
|
20
|
+
if (e.msg === 78 /* WmMsg.NOTIFY */) {
|
|
21
21
|
const code = nmCode(e.lParam);
|
|
22
|
-
if (code === -2 /*
|
|
22
|
+
if (code === -2 /* SysLinkNotifyCode.CLICK */ || code === -4 /* SysLinkNotifyCode.RETURN */) {
|
|
23
23
|
onClickRef.current?.(NMLINK.decode(e.lParam).item.szUrl);
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
-
}, children: _jsx("w", { type: "SysLink", ws: 268435456 /*
|
|
26
|
+
}, children: _jsx("w", { type: "SysLink", ws: 268435456 /* WindowStyle.VISIBLE */ | 65536 /* WindowStyle.TABSTOP */, text: linkText, style: { flexGrow: 1 }, ref: (h) => { linkRef.current = h; } }) }));
|
|
27
27
|
});
|
|
28
28
|
export { Link };
|
|
@@ -7,35 +7,35 @@ export const ListBox = forwardRef(({ items, selectedIndex: controlledIndex, defa
|
|
|
7
7
|
const sel = isControlled ? controlledIndex : internalIndex;
|
|
8
8
|
const lbRef = useRef(null);
|
|
9
9
|
useImperativeHandle(ref, () => lbRef.current);
|
|
10
|
-
const lbWs = 268435456 /*
|
|
11
|
-
| 64 /*
|
|
12
|
-
| (sort ? 2 /*
|
|
10
|
+
const lbWs = 268435456 /* WindowStyle.VISIBLE */ | 8388608 /* WindowStyle.BORDER */ | 2097152 /* WindowStyle.VSCROLL */
|
|
11
|
+
| 64 /* ListBoxStyle.HASSTRINGS */ | 1 /* ListBoxStyle.NOTIFY */ | 256 /* ListBoxStyle.NOINTEGRALHEIGHT */
|
|
12
|
+
| (sort ? 2 /* ListBoxStyle.SORT */ : 0);
|
|
13
13
|
useEffect(() => {
|
|
14
14
|
const h = lbRef.current;
|
|
15
15
|
if (!h)
|
|
16
16
|
return;
|
|
17
|
-
gui.SendMessage(h, 388 /*
|
|
17
|
+
gui.SendMessage(h, 388 /* LbMsg.RESETCONTENT */, 0, 0);
|
|
18
18
|
for (const item of items)
|
|
19
|
-
gui.SendMessage(h, 384 /*
|
|
19
|
+
gui.SendMessage(h, 384 /* LbMsg.ADDSTRING */, 0, item);
|
|
20
20
|
if (sel >= 0 && sel < items.length)
|
|
21
|
-
gui.SendMessage(h, 390 /*
|
|
21
|
+
gui.SendMessage(h, 390 /* LbMsg.SETCURSEL */, sel, 0);
|
|
22
22
|
if (scrollToBottom && items.length > 0)
|
|
23
|
-
gui.SendMessage(h, 407 /*
|
|
23
|
+
gui.SendMessage(h, 407 /* LbMsg.SETTOPINDEX */, items.length - 1, 0);
|
|
24
24
|
}, [items]);
|
|
25
25
|
useEffect(() => {
|
|
26
26
|
const h = lbRef.current;
|
|
27
27
|
if (h)
|
|
28
|
-
gui.SendMessage(h, 390 /*
|
|
28
|
+
gui.SendMessage(h, 390 /* LbMsg.SETCURSEL */, sel, 0);
|
|
29
29
|
}, [sel]);
|
|
30
|
-
return (_jsx("w", { type: "STATIC", ws: 268435456 /*
|
|
31
|
-
if (e.msg !== 273 /*
|
|
30
|
+
return (_jsx("w", { type: "STATIC", ws: 268435456 /* WindowStyle.VISIBLE */ | 33554432 /* WindowStyle.CLIPCHILDREN */, style: { ...style, flexDirection: 'column', alignItems: 'stretch' }, onEvent: (e) => {
|
|
31
|
+
if (e.msg !== 273 /* WmMsg.COMMAND */)
|
|
32
32
|
return;
|
|
33
33
|
const code = (e.wParam >> 16) & 0xFFFF;
|
|
34
|
-
if (code === 1 /*
|
|
34
|
+
if (code === 1 /* LbnCode.SELCHANGE */) {
|
|
35
35
|
const h = lbRef.current;
|
|
36
36
|
if (!h)
|
|
37
37
|
return;
|
|
38
|
-
const newSel = gui.SendMessage(h, 392 /*
|
|
38
|
+
const newSel = gui.SendMessage(h, 392 /* LbMsg.GETCURSEL */, 0, 0);
|
|
39
39
|
if (newSel !== sel && newSel >= 0) {
|
|
40
40
|
if (!isControlled)
|
|
41
41
|
setInternalIndex(newSel);
|
|
@@ -28,8 +28,8 @@ function writeU32(ptr, offset, v) {
|
|
|
28
28
|
ffi.writeByte(ptr + offset + 2, (v >> 16) & 0xFF);
|
|
29
29
|
ffi.writeByte(ptr + offset + 3, (v >> 24) & 0xFF);
|
|
30
30
|
}
|
|
31
|
-
const LV_WS = 268435456 /*
|
|
32
|
-
| 1 /*
|
|
31
|
+
const LV_WS = 268435456 /* WindowStyle.VISIBLE */ | 8388608 /* WindowStyle.BORDER */ | 2097152 /* WindowStyle.VSCROLL */ | 1048576 /* WindowStyle.HSCROLL */
|
|
32
|
+
| 1 /* ListViewStyle.REPORT */ | 4 /* ListViewStyle.SINGLESEL */;
|
|
33
33
|
const CD_CLRTEXT = NMLVCUSTOMDRAW.offsetOf('clrText');
|
|
34
34
|
const CD_CLRTEXTBK = NMLVCUSTOMDRAW.offsetOf('clrTextBk');
|
|
35
35
|
const fontCache = new Map();
|
|
@@ -44,7 +44,7 @@ function getCellFont(hwnd, style) {
|
|
|
44
44
|
return null;
|
|
45
45
|
// 以控件当前字体为底(取不到则用 -13 高度的默认字体),再叠加粗 / 斜 / 下划线
|
|
46
46
|
let base = { lfHeight: -13 };
|
|
47
|
-
const cur = gui.SendMessage(hwnd, 49 /*
|
|
47
|
+
const cur = gui.SendMessage(hwnd, 49 /* WmMsg.GETFONT */, 0, 0);
|
|
48
48
|
if (cur) {
|
|
49
49
|
const lf = LOGFONTW.alloc();
|
|
50
50
|
// GETFONT 的 LRESULT 断言为 HFONT(gdi32 <HGDIOBJ>ptr 位)
|
|
@@ -54,7 +54,7 @@ function getCellFont(hwnd, style) {
|
|
|
54
54
|
}
|
|
55
55
|
const h = CreateFontIndirect({
|
|
56
56
|
...base,
|
|
57
|
-
...(style.bold ? { lfWeight: 700 /*
|
|
57
|
+
...(style.bold ? { lfWeight: 700 /* FontWeight.BOLD */ } : {}),
|
|
58
58
|
...(style.italic ? { lfItalic: 1 } : {}),
|
|
59
59
|
...(style.underline ? { lfUnderline: 1 } : {}),
|
|
60
60
|
});
|
|
@@ -63,16 +63,16 @@ function getCellFont(hwnd, style) {
|
|
|
63
63
|
}
|
|
64
64
|
function handleCustomDraw(lParam, columns, data, hwnd) {
|
|
65
65
|
const { dwDrawStage: stage } = NMCUSTOMDRAW.decode(lParam);
|
|
66
|
-
if (stage === 1 /*
|
|
67
|
-
return 32 /*
|
|
68
|
-
if (stage === 65537 /*
|
|
69
|
-
return 32 /*
|
|
70
|
-
if (stage === 196609 /*
|
|
66
|
+
if (stage === 1 /* CustomDrawStage.PREPAINT */)
|
|
67
|
+
return 32 /* CustomDrawFlag.NOTIFYITEMDRAW */;
|
|
68
|
+
if (stage === 65537 /* CustomDrawStage.ITEMPREPAINT */)
|
|
69
|
+
return 32 /* CustomDrawFlag.NOTIFYSUBITEMDRAW */;
|
|
70
|
+
if (stage === 196609 /* CustomDrawStage.SUBITEMPREPAINT */) {
|
|
71
71
|
// 只有子项阶段才按 NMLVCUSTOMDRAW(更大的结构)读,前面的阶段只读了 NMCUSTOMDRAW 的前缀
|
|
72
72
|
const cd = NMLVCUSTOMDRAW.decode(lParam);
|
|
73
73
|
const style = resolveCellStyle(columns, data, cd.dwItemSpec, cd.iSubItem);
|
|
74
74
|
if (!style)
|
|
75
|
-
return 0 /*
|
|
75
|
+
return 0 /* CustomDrawFlag.DODEFAULT */;
|
|
76
76
|
if (style.color !== undefined)
|
|
77
77
|
writeU32(lParam, CD_CLRTEXT, style.color);
|
|
78
78
|
if (style.background !== undefined)
|
|
@@ -80,17 +80,17 @@ function handleCustomDraw(lParam, columns, data, hwnd) {
|
|
|
80
80
|
const hfont = getCellFont(hwnd, style);
|
|
81
81
|
if (hfont && cd.hdc) {
|
|
82
82
|
SelectObject(cd.hdc, hfont);
|
|
83
|
-
return 2 /*
|
|
83
|
+
return 2 /* CustomDrawFlag.NEWFONT */;
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
|
-
return 0 /*
|
|
86
|
+
return 0 /* CustomDrawFlag.DODEFAULT */;
|
|
87
87
|
}
|
|
88
88
|
function alignToFmt(align) {
|
|
89
89
|
if (align === 'center')
|
|
90
|
-
return 2 /*
|
|
90
|
+
return 2 /* LvColumnFormat.CENTER */;
|
|
91
91
|
if (align === 'right')
|
|
92
|
-
return 1 /*
|
|
93
|
-
return 0 /*
|
|
92
|
+
return 1 /* LvColumnFormat.RIGHT */;
|
|
93
|
+
return 0 /* LvColumnFormat.LEFT */;
|
|
94
94
|
}
|
|
95
95
|
function cellText(record, col, index) {
|
|
96
96
|
if (col.render)
|
|
@@ -142,13 +142,13 @@ const ListView = forwardRef(function ListViewInner({ columns, data, style, icons
|
|
|
142
142
|
const il = iconListRef.current;
|
|
143
143
|
iconListRef.current = 0;
|
|
144
144
|
if (il) {
|
|
145
|
-
gui.SendMessage(h, 4099 /*
|
|
145
|
+
gui.SendMessage(h, 4099 /* LvMsg.SETIMAGELIST */, 1 /* LvImageList.SMALL */, 0);
|
|
146
146
|
gui.ImageListDestroy(il);
|
|
147
147
|
}
|
|
148
148
|
if (!icons || icons.length === 0)
|
|
149
149
|
return;
|
|
150
150
|
const size = iconSize ?? 32;
|
|
151
|
-
const img = gui.ImageListCreate(size, size, 32 /*
|
|
151
|
+
const img = gui.ImageListCreate(size, size, 32 /* ImageListFlag.COLOR32 */, icons.length, 1);
|
|
152
152
|
if (!img)
|
|
153
153
|
return;
|
|
154
154
|
for (const p of icons) {
|
|
@@ -158,7 +158,7 @@ const ListView = forwardRef(function ListViewInner({ columns, data, style, icons
|
|
|
158
158
|
DeleteObject(hbm);
|
|
159
159
|
}
|
|
160
160
|
}
|
|
161
|
-
gui.SendMessage(h, 4099 /*
|
|
161
|
+
gui.SendMessage(h, 4099 /* LvMsg.SETIMAGELIST */, 1 /* LvImageList.SMALL */, img);
|
|
162
162
|
iconListRef.current = img;
|
|
163
163
|
}, [icons, iconSize]);
|
|
164
164
|
useEffect(() => {
|
|
@@ -166,13 +166,13 @@ const ListView = forwardRef(function ListViewInner({ columns, data, style, icons
|
|
|
166
166
|
if (!h)
|
|
167
167
|
return;
|
|
168
168
|
// 从后往前删旧列
|
|
169
|
-
const hdr = gui.SendMessage(h, 4127 /*
|
|
169
|
+
const hdr = gui.SendMessage(h, 4127 /* LvMsg.GETHEADER */, 0, 0);
|
|
170
170
|
if (hdr) {
|
|
171
|
-
let n = gui.SendMessage(hdr, 4608 /*
|
|
171
|
+
let n = gui.SendMessage(hdr, 4608 /* HdmMsg.GETITEMCOUNT */, 0, 0);
|
|
172
172
|
for (let k = n - 1; k >= 0; k--)
|
|
173
|
-
gui.SendMessage(h, 4124 /*
|
|
173
|
+
gui.SendMessage(h, 4124 /* LvMsg.DELETECOLUMN */, k, 0);
|
|
174
174
|
}
|
|
175
|
-
gui.SendMessage(h, 4150 /*
|
|
175
|
+
gui.SendMessage(h, 4150 /* LvMsg.SETEXTENDEDLISTVIEWSTYLE */, 0, 32 /* LvExStyle.FULLROWSELECT */ | 1 /* LvExStyle.GRIDLINES */ | 65536 /* LvExStyle.DOUBLEBUFFER */);
|
|
176
176
|
const n = columns.length;
|
|
177
177
|
for (let j = 0; j < n; j++) {
|
|
178
178
|
const titleBuf = WCHAR.encode(columns[j].name);
|
|
@@ -190,43 +190,43 @@ const ListView = forwardRef(function ListViewInner({ columns, data, style, icons
|
|
|
190
190
|
cxIdeal: 0,
|
|
191
191
|
});
|
|
192
192
|
lvc.__titleBuf = titleBuf;
|
|
193
|
-
gui.SendMessage(h, 4193 /*
|
|
193
|
+
gui.SendMessage(h, 4193 /* LvMsg.INSERTCOLUMNW */, j, lvc.ptr);
|
|
194
194
|
}
|
|
195
195
|
}, [columns]);
|
|
196
196
|
useEffect(() => {
|
|
197
197
|
const h = lvRef.current;
|
|
198
198
|
if (!h)
|
|
199
199
|
return;
|
|
200
|
-
gui.SendMessage(h, 4105 /*
|
|
200
|
+
gui.SendMessage(h, 4105 /* LvMsg.DELETEALLITEMS */, 0, 0);
|
|
201
201
|
const nCols = columns.length;
|
|
202
202
|
for (let i = 0; i < data.length; i++) {
|
|
203
203
|
const record = data[i];
|
|
204
204
|
const img = getIcon ? getIcon(record, i) : undefined;
|
|
205
205
|
const itemBuf = makeLVItem(i, 0, cellText(record, columns[0], i), img);
|
|
206
|
-
gui.SendMessage(h, 4173 /*
|
|
206
|
+
gui.SendMessage(h, 4173 /* LvMsg.INSERTITEMW */, 0, itemBuf.ptr);
|
|
207
207
|
for (let j = 1; j < nCols; j++) {
|
|
208
208
|
const subBuf = makeLVItem(i, j, cellText(record, columns[j], i));
|
|
209
|
-
gui.SendMessage(h, 4172 /*
|
|
209
|
+
gui.SendMessage(h, 4172 /* LvMsg.SETITEMW */, 0, subBuf.ptr);
|
|
210
210
|
}
|
|
211
211
|
}
|
|
212
212
|
for (let j = 0; j < columns.length; j++) {
|
|
213
213
|
if (columns[j].width == null) {
|
|
214
|
-
gui.SendMessage(h, 4126 /*
|
|
214
|
+
gui.SendMessage(h, 4126 /* LvMsg.SETCOLUMNWIDTH */, j, -2 /* LvColumnWidthCmd.AUTOSIZE_USEHEADER */);
|
|
215
215
|
}
|
|
216
216
|
}
|
|
217
217
|
}, [data, columns, getIcon]);
|
|
218
|
-
return (_jsx("w", { type: "STATIC", ws: 268435456 /*
|
|
219
|
-
if (e.msg === 78 /*
|
|
218
|
+
return (_jsx("w", { type: "STATIC", ws: 268435456 /* WindowStyle.VISIBLE */ | 33554432 /* WindowStyle.CLIPCHILDREN */, style: { ...style, flexDirection: 'column', alignItems: 'stretch' }, ref: ref, onEvent: (e) => {
|
|
219
|
+
if (e.msg === 78 /* WmMsg.NOTIFY */) {
|
|
220
220
|
const code = nmCode(e.lParam);
|
|
221
|
-
if (code === -12 /*
|
|
221
|
+
if (code === -12 /* LvNotifyCode.CUSTOMDRAW */) {
|
|
222
222
|
return handleCustomDraw(e.lParam, columns, data, lvRef.current);
|
|
223
223
|
}
|
|
224
|
-
if (code === -100 /*
|
|
224
|
+
if (code === -100 /* LvNotifyCode.ITEMCHANGING */) {
|
|
225
225
|
const { uNewState, uOldState } = NMLISTVIEW.decode(e.lParam);
|
|
226
226
|
if ((uNewState & 2 /* LvItemState.SELECTED */) !== (uOldState & 2 /* LvItemState.SELECTED */))
|
|
227
227
|
return 1;
|
|
228
228
|
}
|
|
229
|
-
if (code === -2 /*
|
|
229
|
+
if (code === -2 /* LvNotifyCode.CLICK */) {
|
|
230
230
|
const { iItem, iSubItem } = NMLISTVIEW.decode(e.lParam);
|
|
231
231
|
const col = columns[iSubItem];
|
|
232
232
|
const record = data[iItem];
|
|
@@ -238,9 +238,9 @@ const ListView = forwardRef(function ListViewInner({ columns, data, style, icons
|
|
|
238
238
|
}, children: _jsx("w", { type: "SysListView32", ws: LV_WS, style: { flexGrow: 1 }, ref: (h) => {
|
|
239
239
|
lvRef.current = h;
|
|
240
240
|
}, onEvent: (e) => {
|
|
241
|
-
if (e.msg !== 32 /*
|
|
241
|
+
if (e.msg !== 32 /* WmMsg.SETCURSOR */)
|
|
242
242
|
return;
|
|
243
|
-
if ((e.lParam & 0xFFFF) !== 1 /*
|
|
243
|
+
if ((e.lParam & 0xFFFF) !== 1 /* HitTest.CLIENT */)
|
|
244
244
|
return;
|
|
245
245
|
const h = lvRef.current;
|
|
246
246
|
if (!h)
|
|
@@ -252,7 +252,7 @@ const ListView = forwardRef(function ListViewInner({ columns, data, style, icons
|
|
|
252
252
|
ScreenToClient(h, pt.ptr);
|
|
253
253
|
const { x: sx, y: sy } = POINT.decode(pt);
|
|
254
254
|
const hit = LVHITTESTINFO.encode({ pt: [sx, sy], iItem: -1, iSubItem: -1 });
|
|
255
|
-
gui.SendMessage(h, 4153 /*
|
|
255
|
+
gui.SendMessage(h, 4153 /* LvMsg.SUBITEMHITTEST */, 0, hit.ptr);
|
|
256
256
|
const { iItem, iSubItem } = LVHITTESTINFO.decode(hit);
|
|
257
257
|
const style = resolveCellStyle(columns, data, iItem, iSubItem);
|
|
258
258
|
if (!style || style.cursor === undefined)
|
|
@@ -79,14 +79,14 @@ export const PathPicker = forwardRef((props, ref) => {
|
|
|
79
79
|
setInternalValue(result);
|
|
80
80
|
onChange?.(result);
|
|
81
81
|
};
|
|
82
|
-
return (_jsxs("w", { type: "STATIC", ws: 268435456 /*
|
|
82
|
+
return (_jsxs("w", { type: "STATIC", ws: 268435456 /* WindowStyle.VISIBLE */ | 33554432 /* WindowStyle.CLIPCHILDREN */, style: { ...style, flexDirection: 'row', alignItems: 'stretch' }, ref: (h) => {
|
|
83
83
|
containerRef.current = h;
|
|
84
84
|
if (typeof ref === 'function')
|
|
85
85
|
ref(h);
|
|
86
86
|
else if (ref)
|
|
87
87
|
ref.current = h;
|
|
88
|
-
}, children: [_jsx("w", { type: "EDIT", text: displayText, ws: 268435456 /*
|
|
89
|
-
if (e.msg === 514 /*
|
|
88
|
+
}, children: [_jsx("w", { type: "EDIT", text: displayText, ws: 268435456 /* WindowStyle.VISIBLE */ | 8388608 /* WindowStyle.BORDER */ | 2048 /* EditStyle.READONLY */ | 128 /* EditStyle.AUTOHSCROLL */, style: { flexGrow: 1 } }), _jsx("w", { type: "BUTTON", text: "...", ws: 268435456 /* WindowStyle.VISIBLE */, style: { width: 70 }, disabled: disabled, onEvent: (e) => {
|
|
89
|
+
if (e.msg === 514 /* WmMsg.LBUTTONUP */)
|
|
90
90
|
handleBrowse();
|
|
91
91
|
} })] }));
|
|
92
92
|
});
|
|
@@ -3,14 +3,14 @@ import { forwardRef, useEffect, useRef } from 'react';
|
|
|
3
3
|
import * as gui from 'gui';
|
|
4
4
|
export const ProgressBar = forwardRef(({ value = 0, max = 100, style, smooth }, ref) => {
|
|
5
5
|
const pbRef = useRef(null);
|
|
6
|
-
const ws = 268435456 /*
|
|
7
|
-
| (smooth ? 1 /*
|
|
6
|
+
const ws = 268435456 /* WindowStyle.VISIBLE */ | 8388608 /* WindowStyle.BORDER */
|
|
7
|
+
| (smooth ? 1 /* ProgressStyle.SMOOTH */ : 0);
|
|
8
8
|
useEffect(() => {
|
|
9
9
|
const h = pbRef.current;
|
|
10
10
|
if (!h)
|
|
11
11
|
return;
|
|
12
|
-
gui.SendMessage(h, 1030 /*
|
|
13
|
-
gui.SendMessage(h, 1026 /*
|
|
12
|
+
gui.SendMessage(h, 1030 /* ProgressMsg.SETRANGE32 */, 0, max);
|
|
13
|
+
gui.SendMessage(h, 1026 /* ProgressMsg.SETPOS */, Math.min(value, max), 0);
|
|
14
14
|
}, [value, max]);
|
|
15
15
|
return (_jsx("w", { type: "msctls_progress32", ws: ws, style: style, ref: (h) => {
|
|
16
16
|
pbRef.current = h;
|
|
@@ -10,17 +10,17 @@ export const RadioButton = forwardRef(({ checked: controlledChecked, defaultChec
|
|
|
10
10
|
const h = rbRef.current;
|
|
11
11
|
if (!h)
|
|
12
12
|
return;
|
|
13
|
-
gui.SendMessage(h, 241 /*
|
|
13
|
+
gui.SendMessage(h, 241 /* ButtonMsg.SETCHECK */, displayChecked ? 1 /* ButtonCheckState.CHECKED */ : 0 /* ButtonCheckState.UNCHECKED */, 0);
|
|
14
14
|
}, [displayChecked]);
|
|
15
|
-
return (_jsx("w", { type: "BUTTON", text: label ?? '', ws: 268435456 /*
|
|
15
|
+
return (_jsx("w", { type: "BUTTON", text: label ?? '', ws: 268435456 /* WindowStyle.VISIBLE */ | 9 /* ButtonStyle.AUTORADIOBUTTON */, style: style, disabled: disabled, ref: (h) => {
|
|
16
16
|
rbRef.current = h;
|
|
17
17
|
if (typeof ref === 'function')
|
|
18
18
|
ref(h);
|
|
19
19
|
else if (ref)
|
|
20
20
|
ref.current = h;
|
|
21
21
|
}, onEvent: (e) => {
|
|
22
|
-
if (e.msg === 514 /*
|
|
23
|
-
const newChecked = gui.SendMessage(e.hwnd, 240 /*
|
|
22
|
+
if (e.msg === 514 /* WmMsg.LBUTTONUP */) {
|
|
23
|
+
const newChecked = gui.SendMessage(e.hwnd, 240 /* ButtonMsg.GETCHECK */, 0, 0) !== 0;
|
|
24
24
|
if (newChecked !== displayChecked) {
|
|
25
25
|
if (!isControlled)
|
|
26
26
|
setInternalChecked(newChecked);
|
|
@@ -30,23 +30,23 @@ export const ScrollView = forwardRef(({ children, style, contentWidth, contentHe
|
|
|
30
30
|
const natH = Math.round((contentHeight ?? (svH / scale)) * scale);
|
|
31
31
|
scrollXRef.current = Math.max(0, Math.min(scrollXRef.current, natW - svW));
|
|
32
32
|
scrollYRef.current = Math.max(0, Math.min(scrollYRef.current, natH - svH));
|
|
33
|
-
SetWindowPos(content, 0 /*
|
|
33
|
+
SetWindowPos(content, 0 /* SetWindowPosHwnd.TOP */, -scrollXRef.current, -scrollYRef.current, natW, natH, 4 /* SetWindowPosFlag.SWP_NOZORDER */);
|
|
34
34
|
forceFlexLayout(content);
|
|
35
35
|
if (natW > svW) {
|
|
36
|
-
gui.SetScrollInfo(sv, 0 /*
|
|
37
|
-
ShowScrollBar(sv, 0 /*
|
|
36
|
+
gui.SetScrollInfo(sv, 0 /* ScrollBar.HORZ */, { min: 0, max: natW - 1, page: svW, pos: scrollXRef.current }, true);
|
|
37
|
+
ShowScrollBar(sv, 0 /* ScrollBar.HORZ */, 1);
|
|
38
38
|
}
|
|
39
39
|
else {
|
|
40
40
|
scrollXRef.current = 0;
|
|
41
|
-
ShowScrollBar(sv, 0 /*
|
|
41
|
+
ShowScrollBar(sv, 0 /* ScrollBar.HORZ */, 0);
|
|
42
42
|
}
|
|
43
43
|
if (natH > svH) {
|
|
44
|
-
gui.SetScrollInfo(sv, 1 /*
|
|
45
|
-
ShowScrollBar(sv, 1 /*
|
|
44
|
+
gui.SetScrollInfo(sv, 1 /* ScrollBar.VERT */, { min: 0, max: natH - 1, page: svH, pos: scrollYRef.current }, true);
|
|
45
|
+
ShowScrollBar(sv, 1 /* ScrollBar.VERT */, 1);
|
|
46
46
|
}
|
|
47
47
|
else {
|
|
48
48
|
scrollYRef.current = 0;
|
|
49
|
-
ShowScrollBar(sv, 1 /*
|
|
49
|
+
ShowScrollBar(sv, 1 /* ScrollBar.VERT */, 0);
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
useLayoutEffect(() => {
|
|
@@ -57,13 +57,13 @@ export const ScrollView = forwardRef(({ children, style, contentWidth, contentHe
|
|
|
57
57
|
updateScroll(sv, content);
|
|
58
58
|
}, [contentWidth, contentHeight]);
|
|
59
59
|
function setScrollPos(sv, content, bar, newPos) {
|
|
60
|
-
if (bar === 1 /*
|
|
60
|
+
if (bar === 1 /* ScrollBar.VERT */) {
|
|
61
61
|
scrollYRef.current = newPos;
|
|
62
62
|
}
|
|
63
63
|
else {
|
|
64
64
|
scrollXRef.current = newPos;
|
|
65
65
|
}
|
|
66
|
-
SetWindowPos(content, 0 /*
|
|
66
|
+
SetWindowPos(content, 0 /* SetWindowPosHwnd.TOP */, -scrollXRef.current, -scrollYRef.current, 0, 0, 1 /* SetWindowPosFlag.SWP_NOSIZE */ | 4 /* SetWindowPosFlag.SWP_NOZORDER */);
|
|
67
67
|
gui.SetScrollInfo(sv, bar, { pos: newPos }, true);
|
|
68
68
|
}
|
|
69
69
|
function handleScroll(e, bar) {
|
|
@@ -74,18 +74,18 @@ export const ScrollView = forwardRef(({ children, style, contentWidth, contentHe
|
|
|
74
74
|
const info = gui.GetScrollInfo(sv, bar);
|
|
75
75
|
const maxPos = info.max - info.page + 1;
|
|
76
76
|
const code = e.wParam & 0xFFFF;
|
|
77
|
-
const ref_ = bar === 1 /*
|
|
77
|
+
const ref_ = bar === 1 /* ScrollBar.VERT */ ? scrollYRef : scrollXRef;
|
|
78
78
|
let newPos = ref_.current;
|
|
79
|
-
if (code === 5 /*
|
|
79
|
+
if (code === 5 /* ScrollCmd.THUMBTRACK */) {
|
|
80
80
|
newPos = Math.max(0, Math.min(maxPos, (e.wParam >> 16) & 0xFFFF));
|
|
81
81
|
}
|
|
82
|
-
else if (code === 0 /*
|
|
82
|
+
else if (code === 0 /* ScrollCmd.LINEUP */)
|
|
83
83
|
newPos -= 20;
|
|
84
|
-
else if (code === 1 /*
|
|
84
|
+
else if (code === 1 /* ScrollCmd.LINEDOWN */)
|
|
85
85
|
newPos += 20;
|
|
86
|
-
else if (code === 2 /*
|
|
86
|
+
else if (code === 2 /* ScrollCmd.PAGEUP */)
|
|
87
87
|
newPos -= info.page;
|
|
88
|
-
else if (code === 3 /*
|
|
88
|
+
else if (code === 3 /* ScrollCmd.PAGEDOWN */)
|
|
89
89
|
newPos += info.page;
|
|
90
90
|
else
|
|
91
91
|
return;
|
|
@@ -100,12 +100,12 @@ export const ScrollView = forwardRef(({ children, style, contentWidth, contentHe
|
|
|
100
100
|
return;
|
|
101
101
|
const wheel = e.wParam >> 16;
|
|
102
102
|
const dy = -Math.round(wheel * 40 / 120);
|
|
103
|
-
const isHorz = (e.wParam & 4 /*
|
|
103
|
+
const isHorz = (e.wParam & 4 /* MouseKeyFlag.MK_SHIFT */) !== 0;
|
|
104
104
|
if (isHorz && contentWidth === undefined)
|
|
105
105
|
return;
|
|
106
106
|
if (!isHorz && contentHeight === undefined)
|
|
107
107
|
return;
|
|
108
|
-
const bar = isHorz ? 0 /*
|
|
108
|
+
const bar = isHorz ? 0 /* ScrollBar.HORZ */ : 1 /* ScrollBar.VERT */;
|
|
109
109
|
const info = gui.GetScrollInfo(sv, bar);
|
|
110
110
|
const maxPos = info.max - info.page + 1;
|
|
111
111
|
const ref_ = isHorz ? scrollXRef : scrollYRef;
|
|
@@ -114,9 +114,9 @@ export const ScrollView = forwardRef(({ children, style, contentWidth, contentHe
|
|
|
114
114
|
if (newPos !== ref_.current)
|
|
115
115
|
setScrollPos(sv, content, bar, newPos);
|
|
116
116
|
}
|
|
117
|
-
return (_jsx("w", { type: "STATIC", ws: 268435456 /*
|
|
118
|
-
(contentWidth !== undefined ? 1048576 /*
|
|
119
|
-
(contentHeight !== undefined ? 2097152 /*
|
|
117
|
+
return (_jsx("w", { type: "STATIC", ws: 268435456 /* WindowStyle.VISIBLE */ | 33554432 /* WindowStyle.CLIPCHILDREN */ |
|
|
118
|
+
(contentWidth !== undefined ? 1048576 /* WindowStyle.HSCROLL */ : 0) |
|
|
119
|
+
(contentHeight !== undefined ? 2097152 /* WindowStyle.VSCROLL */ : 0), style: style, ref: (h) => {
|
|
120
120
|
svRef.current = h;
|
|
121
121
|
if (typeof ref === 'function')
|
|
122
122
|
ref(h);
|
|
@@ -124,23 +124,23 @@ export const ScrollView = forwardRef(({ children, style, contentWidth, contentHe
|
|
|
124
124
|
ref.current = h;
|
|
125
125
|
}, onEvent: {
|
|
126
126
|
fn: (e) => {
|
|
127
|
-
if (e.msg === 132 /*
|
|
128
|
-
e.msg === 161 /*
|
|
127
|
+
if (e.msg === 132 /* WmMsg.NCHITTEST */ ||
|
|
128
|
+
e.msg === 161 /* WmMsg.NCLBUTTONDOWN */) {
|
|
129
129
|
return DefWindowProc(e.hwnd, e.msg, e.wParam, e.lParam);
|
|
130
130
|
}
|
|
131
|
-
if (e.msg === 277 /*
|
|
132
|
-
handleScroll(e, 1 /*
|
|
131
|
+
if (e.msg === 277 /* WmMsg.VSCROLL */) {
|
|
132
|
+
handleScroll(e, 1 /* ScrollBar.VERT */);
|
|
133
133
|
return 0;
|
|
134
134
|
}
|
|
135
|
-
if (e.msg === 276 /*
|
|
136
|
-
handleScroll(e, 0 /*
|
|
135
|
+
if (e.msg === 276 /* WmMsg.HSCROLL */) {
|
|
136
|
+
handleScroll(e, 0 /* ScrollBar.HORZ */);
|
|
137
137
|
return 0;
|
|
138
138
|
}
|
|
139
|
-
if (e.msg === 522 /*
|
|
139
|
+
if (e.msg === 522 /* WmMsg.MOUSEWHEEL */) {
|
|
140
140
|
handleMouseWheel(e);
|
|
141
141
|
return 0;
|
|
142
142
|
}
|
|
143
143
|
return e.callOldWndProc();
|
|
144
144
|
}
|
|
145
|
-
}, children: _jsx("w", { type: "STATIC", ws: 268435456 /*
|
|
145
|
+
}, children: _jsx("w", { type: "STATIC", ws: 268435456 /* WindowStyle.VISIBLE */ | 33554432 /* WindowStyle.CLIPCHILDREN */, style: { flexDirection: 'column', alignItems: 'flex-start' }, ref: (h) => { contentRef.current = h; }, children: children }) }));
|
|
146
146
|
});
|