quickwin 2.2.0 → 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.
Files changed (111) hide show
  1. package/README.en.md +7 -7
  2. package/README.md +7 -7
  3. package/constants.ts +1063 -0
  4. package/enum_map.d.ts +129 -0
  5. package/examples/PdfCanvas.js +2 -2
  6. package/examples/PdfCanvas.tsx +3 -2
  7. package/examples/{execd.js → execd/main.js} +563 -122
  8. package/examples/execd/tray.js +192 -0
  9. package/examples/{execd_worker.js → execd/worker.js} +7 -7
  10. package/examples/pdf_preview2.js +46 -46
  11. package/examples/pdf_preview2.ts +55 -54
  12. package/examples/pdf_viewer.js +34 -19
  13. package/examples/pdf_viewer.tsx +6 -5
  14. package/examples/test_gallery.js +35 -20
  15. package/examples/test_gallery.tsx +9 -8
  16. package/examples/test_react_lazy.js +34 -19
  17. package/examples/test_react_lazy.tsx +7 -6
  18. package/examples/test_react_listbox.js +34 -19
  19. package/examples/test_react_listbox.tsx +8 -7
  20. package/examples/test_root_window.js +34 -19
  21. package/examples/test_root_window.tsx +5 -5
  22. package/examples/test_tab.js +34 -19
  23. package/examples/test_tab.tsx +7 -6
  24. package/examples/tray_demo.js +8 -8
  25. package/examples/tray_demo.tsx +9 -8
  26. package/lib/dumpRects.js +2 -2
  27. package/lib/dumpRects.ts +3 -2
  28. package/lib/fetch.js +15 -15
  29. package/lib/fetch.ts +16 -15
  30. package/lib/ffi/bind.js +3 -3
  31. package/lib/ffi/bind.ts +3 -3
  32. package/lib/http-server.js +4 -4
  33. package/lib/http-server.ts +5 -4
  34. package/lib/react-qw/components/Button.js +2 -2
  35. package/lib/react-qw/components/CheckBox.js +4 -4
  36. package/lib/react-qw/components/ComboBox.js +10 -10
  37. package/lib/react-qw/components/DateTimePicker.js +12 -12
  38. package/lib/react-qw/components/Input.js +7 -7
  39. package/lib/react-qw/components/Link.js +4 -4
  40. package/lib/react-qw/components/ListBox.js +12 -12
  41. package/lib/react-qw/components/ListView.js +35 -35
  42. package/lib/react-qw/components/PathPicker.js +3 -3
  43. package/lib/react-qw/components/ProgressBar.js +4 -4
  44. package/lib/react-qw/components/RadioButton.js +4 -4
  45. package/lib/react-qw/components/ScrollView.js +28 -28
  46. package/lib/react-qw/components/Slider.js +11 -11
  47. package/lib/react-qw/components/Tab.js +10 -10
  48. package/lib/react-qw/components/Tooltip.js +8 -8
  49. package/lib/react-qw/components/TreeView.js +20 -20
  50. package/lib/react-qw/index.js +5 -5
  51. package/lib/react-qw/index.ts +6 -5
  52. package/lib/react-qw/props.js +4 -4
  53. package/lib/react-qw/props.ts +5 -4
  54. package/lib/react-qw/reconciler.js +10 -10
  55. package/lib/react-qw/reconciler.ts +11 -10
  56. package/lib/text-measure.js +3 -3
  57. package/lib/text-measure.ts +4 -3
  58. package/lib/websocket.js +17 -17
  59. package/lib/websocket.ts +18 -17
  60. package/lib/windows/advapi32.js +7 -7
  61. package/lib/windows/advapi32.ts +7 -7
  62. package/lib/windows/gdi32.js +16 -16
  63. package/lib/windows/gdi32.ts +16 -16
  64. package/lib/windows/kernel32.js +41 -2
  65. package/lib/windows/kernel32.ts +45 -2
  66. package/lib/windows/shell32.js +24 -3
  67. package/lib/windows/shell32.ts +27 -4
  68. package/lib/windows/structs.js +54 -0
  69. package/lib/windows/structs.ts +63 -1
  70. package/lib/windows/user32.js +18 -6
  71. package/lib/windows/user32.ts +18 -6
  72. package/lib/windows/winspool.js +3 -3
  73. package/lib/windows/winspool.ts +3 -3
  74. package/package.json +4 -3
  75. package/quickwin.d.ts +32 -10
  76. package/qwin-nowasm-x86.exe +0 -0
  77. package/qwin-nowasm.exe +0 -0
  78. package/qwin-x86.exe +0 -0
  79. package/qwin.exe +0 -0
  80. package/test/test_ffi_bind.js +7 -7
  81. package/test/test_ffi_bind.ts +8 -8
  82. package/test/test_ffi_struct.js +2 -2
  83. package/test/test_ffi_struct.ts +3 -3
  84. package/test/test_ffi_windows.js +1 -1
  85. package/test/test_ffi_windows.ts +1 -1
  86. package/test/test_files.js +7 -7
  87. package/test/test_files.ts +8 -8
  88. package/test/test_gdi_draw.js +51 -51
  89. package/test/test_gdi_draw.ts +57 -57
  90. package/test/test_http_server.js +3 -3
  91. package/test/test_http_server.ts +4 -3
  92. package/test/test_ipv6.js +3 -3
  93. package/test/test_ipv6.ts +4 -3
  94. package/test/test_net_event.js +3 -3
  95. package/test/test_net_event.ts +4 -3
  96. package/test/test_printer.js +4 -4
  97. package/test/test_printer.ts +5 -5
  98. package/test/test_react_complex.js +36 -21
  99. package/test/test_react_counter.js +34 -19
  100. package/test/test_react_flex.js +36 -21
  101. package/test/test_react_hidden.js +34 -19
  102. package/test/test_react_listview_link.js +35 -20
  103. package/test/test_react_notify.js +52 -37
  104. package/test/test_react_render.js +34 -19
  105. package/test/test_registry.js +6 -6
  106. package/test/test_registry.ts +8 -8
  107. package/test/test_wolfssl_read.js +8 -8
  108. package/test/test_wolfssl_read.ts +9 -8
  109. package/examples/execd.tsx +0 -798
  110. package/examples/execd_worker.ts +0 -127
  111. package/quickwin_const.d.ts +0 -1063
@@ -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 /* gui.WindowStyle.VISIBLE */ | 8388608 /* gui.WindowStyle.BORDER */ | 2097152 /* gui.WindowStyle.VSCROLL */ | 1048576 /* gui.WindowStyle.HSCROLL */
32
- | 1 /* gui.ListViewStyle.REPORT */ | 4 /* gui.ListViewStyle.SINGLESEL */;
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 /* gui.WmMsg.GETFONT */, 0, 0);
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 /* gui.FontWeight.BOLD */ } : {}),
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 /* gui.CustomDrawStage.PREPAINT */)
67
- return 32 /* gui.CustomDrawFlag.NOTIFYITEMDRAW */;
68
- if (stage === 65537 /* gui.CustomDrawStage.ITEMPREPAINT */)
69
- return 32 /* gui.CustomDrawFlag.NOTIFYSUBITEMDRAW */;
70
- if (stage === 196609 /* gui.CustomDrawStage.SUBITEMPREPAINT */) {
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 /* gui.CustomDrawFlag.DODEFAULT */;
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 /* gui.CustomDrawFlag.NEWFONT */;
83
+ return 2 /* CustomDrawFlag.NEWFONT */;
84
84
  }
85
85
  }
86
- return 0 /* gui.CustomDrawFlag.DODEFAULT */;
86
+ return 0 /* CustomDrawFlag.DODEFAULT */;
87
87
  }
88
88
  function alignToFmt(align) {
89
89
  if (align === 'center')
90
- return 2 /* gui.LvColumnFormat.CENTER */;
90
+ return 2 /* LvColumnFormat.CENTER */;
91
91
  if (align === 'right')
92
- return 1 /* gui.LvColumnFormat.RIGHT */;
93
- return 0 /* gui.LvColumnFormat.LEFT */;
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 /* gui.LvMsg.SETIMAGELIST */, 1 /* gui.LvImageList.SMALL */, 0);
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 /* gui.ImageListFlag.COLOR32 */, icons.length, 1);
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 /* gui.LvMsg.SETIMAGELIST */, 1 /* gui.LvImageList.SMALL */, img);
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 /* gui.LvMsg.GETHEADER */, 0, 0);
169
+ const hdr = gui.SendMessage(h, 4127 /* LvMsg.GETHEADER */, 0, 0);
170
170
  if (hdr) {
171
- let n = gui.SendMessage(hdr, 4608 /* gui.HdmMsg.GETITEMCOUNT */, 0, 0);
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 /* gui.LvMsg.DELETECOLUMN */, k, 0);
173
+ gui.SendMessage(h, 4124 /* LvMsg.DELETECOLUMN */, k, 0);
174
174
  }
175
- gui.SendMessage(h, 4150 /* gui.LvMsg.SETEXTENDEDLISTVIEWSTYLE */, 0, 32 /* gui.LvExStyle.FULLROWSELECT */ | 1 /* gui.LvExStyle.GRIDLINES */ | 65536 /* gui.LvExStyle.DOUBLEBUFFER */);
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 /* gui.LvMsg.INSERTCOLUMNW */, j, lvc.ptr);
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 /* gui.LvMsg.DELETEALLITEMS */, 0, 0);
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 /* gui.LvMsg.INSERTITEMW */, 0, itemBuf.ptr);
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 /* gui.LvMsg.SETITEMW */, 0, subBuf.ptr);
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 /* gui.LvMsg.SETCOLUMNWIDTH */, j, -2 /* gui.LvColumnWidthCmd.AUTOSIZE_USEHEADER */);
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 /* gui.WindowStyle.VISIBLE */ | 33554432 /* gui.WindowStyle.CLIPCHILDREN */, style: { ...style, flexDirection: 'column', alignItems: 'stretch' }, ref: ref, onEvent: (e) => {
219
- if (e.msg === 78 /* gui.WmMsg.NOTIFY */) {
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 /* gui.LvNotifyCode.CUSTOMDRAW */) {
221
+ if (code === -12 /* LvNotifyCode.CUSTOMDRAW */) {
222
222
  return handleCustomDraw(e.lParam, columns, data, lvRef.current);
223
223
  }
224
- if (code === -100 /* gui.LvNotifyCode.ITEMCHANGING */) {
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 /* gui.LvNotifyCode.CLICK */) {
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 /* gui.WmMsg.SETCURSOR */)
241
+ if (e.msg !== 32 /* WmMsg.SETCURSOR */)
242
242
  return;
243
- if ((e.lParam & 0xFFFF) !== 1 /* gui.HitTest.CLIENT */)
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 /* gui.LvMsg.SUBITEMHITTEST */, 0, hit.ptr);
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 /* gui.WindowStyle.VISIBLE */ | 33554432 /* gui.WindowStyle.CLIPCHILDREN */, style: { ...style, flexDirection: 'row', alignItems: 'stretch' }, ref: (h) => {
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 /* gui.WindowStyle.VISIBLE */ | 8388608 /* gui.WindowStyle.BORDER */ | 2048 /* gui.EditStyle.READONLY */ | 128 /* gui.EditStyle.AUTOHSCROLL */, style: { flexGrow: 1 } }), _jsx("w", { type: "BUTTON", text: "...", ws: 268435456 /* gui.WindowStyle.VISIBLE */, style: { width: 70 }, disabled: disabled, onEvent: (e) => {
89
- if (e.msg === 514 /* gui.WmMsg.LBUTTONUP */)
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 /* gui.WindowStyle.VISIBLE */ | 8388608 /* gui.WindowStyle.BORDER */
7
- | (smooth ? 1 /* gui.ProgressStyle.SMOOTH */ : 0);
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 /* gui.ProgressMsg.SETRANGE32 */, 0, max);
13
- gui.SendMessage(h, 1026 /* gui.ProgressMsg.SETPOS */, Math.min(value, max), 0);
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 /* gui.ButtonMsg.SETCHECK */, displayChecked ? 1 /* gui.ButtonCheckState.CHECKED */ : 0 /* gui.ButtonCheckState.UNCHECKED */, 0);
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 /* gui.WindowStyle.VISIBLE */ | 9 /* gui.ButtonStyle.AUTORADIOBUTTON */, style: style, disabled: disabled, ref: (h) => {
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 /* gui.WmMsg.LBUTTONUP */) {
23
- const newChecked = gui.SendMessage(e.hwnd, 240 /* gui.ButtonMsg.GETCHECK */, 0, 0) !== 0;
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 /* gui.SetWindowPosHwnd.TOP */, -scrollXRef.current, -scrollYRef.current, natW, natH, 4 /* gui.SetWindowPosFlag.SWP_NOZORDER */);
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 /* gui.ScrollBar.HORZ */, { min: 0, max: natW - 1, page: svW, pos: scrollXRef.current }, true);
37
- ShowScrollBar(sv, 0 /* gui.ScrollBar.HORZ */, 1);
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 /* gui.ScrollBar.HORZ */, 0);
41
+ ShowScrollBar(sv, 0 /* ScrollBar.HORZ */, 0);
42
42
  }
43
43
  if (natH > svH) {
44
- gui.SetScrollInfo(sv, 1 /* gui.ScrollBar.VERT */, { min: 0, max: natH - 1, page: svH, pos: scrollYRef.current }, true);
45
- ShowScrollBar(sv, 1 /* gui.ScrollBar.VERT */, 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 /* gui.ScrollBar.VERT */, 0);
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 /* gui.ScrollBar.VERT */) {
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 /* gui.SetWindowPosHwnd.TOP */, -scrollXRef.current, -scrollYRef.current, 0, 0, 1 /* gui.SetWindowPosFlag.SWP_NOSIZE */ | 4 /* gui.SetWindowPosFlag.SWP_NOZORDER */);
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 /* gui.ScrollBar.VERT */ ? scrollYRef : scrollXRef;
77
+ const ref_ = bar === 1 /* ScrollBar.VERT */ ? scrollYRef : scrollXRef;
78
78
  let newPos = ref_.current;
79
- if (code === 5 /* gui.ScrollCmd.THUMBTRACK */) {
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 /* gui.ScrollCmd.LINEUP */)
82
+ else if (code === 0 /* ScrollCmd.LINEUP */)
83
83
  newPos -= 20;
84
- else if (code === 1 /* gui.ScrollCmd.LINEDOWN */)
84
+ else if (code === 1 /* ScrollCmd.LINEDOWN */)
85
85
  newPos += 20;
86
- else if (code === 2 /* gui.ScrollCmd.PAGEUP */)
86
+ else if (code === 2 /* ScrollCmd.PAGEUP */)
87
87
  newPos -= info.page;
88
- else if (code === 3 /* gui.ScrollCmd.PAGEDOWN */)
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 /* gui.MouseKeyFlag.MK_SHIFT */) !== 0;
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 /* gui.ScrollBar.HORZ */ : 1 /* gui.ScrollBar.VERT */;
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 /* gui.WindowStyle.VISIBLE */ | 33554432 /* gui.WindowStyle.CLIPCHILDREN */ |
118
- (contentWidth !== undefined ? 1048576 /* gui.WindowStyle.HSCROLL */ : 0) |
119
- (contentHeight !== undefined ? 2097152 /* gui.WindowStyle.VSCROLL */ : 0), style: style, ref: (h) => {
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 /* gui.WmMsg.NCHITTEST */ ||
128
- e.msg === 161 /* gui.WmMsg.NCLBUTTONDOWN */) {
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 /* gui.WmMsg.VSCROLL */) {
132
- handleScroll(e, 1 /* gui.ScrollBar.VERT */);
131
+ if (e.msg === 277 /* WmMsg.VSCROLL */) {
132
+ handleScroll(e, 1 /* ScrollBar.VERT */);
133
133
  return 0;
134
134
  }
135
- if (e.msg === 276 /* gui.WmMsg.HSCROLL */) {
136
- handleScroll(e, 0 /* gui.ScrollBar.HORZ */);
135
+ if (e.msg === 276 /* WmMsg.HSCROLL */) {
136
+ handleScroll(e, 0 /* ScrollBar.HORZ */);
137
137
  return 0;
138
138
  }
139
- if (e.msg === 522 /* gui.WmMsg.MOUSEWHEEL */) {
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 /* gui.WindowStyle.VISIBLE */ | 33554432 /* gui.WindowStyle.CLIPCHILDREN */, style: { flexDirection: 'column', alignItems: 'flex-start' }, ref: (h) => { contentRef.current = h; }, children: children }) }));
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
  });
@@ -10,34 +10,34 @@ export const Slider = forwardRef(({ value, onChange, min = 0, max = 100, vertica
10
10
  if (!h)
11
11
  return;
12
12
  const lParam = (min & 0xFFFF) | ((max & 0xFFFF) << 16);
13
- gui.SendMessage(h, 1030 /* gui.TbMsg.SETRANGE */, 0, lParam);
14
- gui.SendMessage(h, 1029 /* gui.TbMsg.SETPOS */, 1, value);
13
+ gui.SendMessage(h, 1030 /* TbMsg.SETRANGE */, 0, lParam);
14
+ gui.SendMessage(h, 1029 /* TbMsg.SETPOS */, 1, value);
15
15
  }, [min, max]);
16
16
  useEffect(() => {
17
17
  const h = sliderRef.current;
18
18
  if (!h)
19
19
  return;
20
- gui.SendMessage(h, 1029 /* gui.TbMsg.SETPOS */, 1, value);
20
+ gui.SendMessage(h, 1029 /* TbMsg.SETPOS */, 1, value);
21
21
  }, [value]);
22
- const tbStyle = 268435456 /* gui.WindowStyle.VISIBLE */ | 65536 /* gui.WindowStyle.TABSTOP */
23
- | 1 /* gui.TrackBarStyle.AUTOTICKS */
24
- | (vertical ? 2 /* gui.TrackBarStyle.VERT */ : 0);
25
- return (_jsx("w", { type: "STATIC", ws: 268435456 /* gui.WindowStyle.VISIBLE */ | 33554432 /* gui.WindowStyle.CLIPCHILDREN */, style: style, ref: (h) => {
22
+ const tbStyle = 268435456 /* WindowStyle.VISIBLE */ | 65536 /* WindowStyle.TABSTOP */
23
+ | 1 /* TrackBarStyle.AUTOTICKS */
24
+ | (vertical ? 2 /* TrackBarStyle.VERT */ : 0);
25
+ return (_jsx("w", { type: "STATIC", ws: 268435456 /* WindowStyle.VISIBLE */ | 33554432 /* WindowStyle.CLIPCHILDREN */, style: style, ref: (h) => {
26
26
  wrapperRef.current = h;
27
27
  if (typeof ref === 'function')
28
28
  ref(h);
29
29
  else if (ref)
30
30
  ref.current = h;
31
31
  }, onEvent: (e) => {
32
- if (e.msg === 132 /* gui.WmMsg.NCHITTEST */ ||
33
- e.msg === 161 /* gui.WmMsg.NCLBUTTONDOWN */) {
32
+ if (e.msg === 132 /* WmMsg.NCHITTEST */ ||
33
+ e.msg === 161 /* WmMsg.NCLBUTTONDOWN */) {
34
34
  return DefWindowProc(e.hwnd, e.msg, e.wParam, e.lParam);
35
35
  }
36
- if (e.msg === 276 /* gui.WmMsg.HSCROLL */ || e.msg === 277 /* gui.WmMsg.VSCROLL */) {
36
+ if (e.msg === 276 /* WmMsg.HSCROLL */ || e.msg === 277 /* WmMsg.VSCROLL */) {
37
37
  const h = sliderRef.current;
38
38
  if (!h)
39
39
  return 0;
40
- const pos = gui.SendMessage(h, 1024 /* gui.TbMsg.GETPOS */, 0, 0);
40
+ const pos = gui.SendMessage(h, 1024 /* TbMsg.GETPOS */, 0, 0);
41
41
  onChange?.(pos);
42
42
  return 0;
43
43
  }
@@ -13,11 +13,11 @@ export const Tab = forwardRef(({ tabs, selectedIndex: controlledIndex, defaultSe
13
13
  const h = tabHwnd.current;
14
14
  if (!h)
15
15
  return;
16
- gui.SendMessage(h, 4873 /* gui.TcMsg.DELETEALLITEMS */, 0, 0);
16
+ gui.SendMessage(h, 4873 /* TcMsg.DELETEALLITEMS */, 0, 0);
17
17
  for (let i = 0; i < tabs.length; i++) {
18
18
  const titleBuf = WCHAR.encode(tabs[i].title);
19
19
  const tci = TCITEMW.encode({
20
- mask: 1 /* gui.TcItemFlag.TEXT */,
20
+ mask: 1 /* TcItemFlag.TEXT */,
21
21
  dwState: 0,
22
22
  dwStateMask: 0,
23
23
  pszText: titleBuf.ptr,
@@ -26,25 +26,25 @@ export const Tab = forwardRef(({ tabs, selectedIndex: controlledIndex, defaultSe
26
26
  lParam: 0,
27
27
  });
28
28
  const tciPtr = tci.ptr;
29
- gui.SendMessage(h, 4926 /* gui.TcMsg.INSERTITEMW */, i, tciPtr);
29
+ gui.SendMessage(h, 4926 /* TcMsg.INSERTITEMW */, i, tciPtr);
30
30
  }
31
- gui.SendMessage(h, 4876 /* gui.TcMsg.SETCURSEL */, sel, 0);
31
+ gui.SendMessage(h, 4876 /* TcMsg.SETCURSEL */, sel, 0);
32
32
  }, [tabs]);
33
33
  useEffect(() => {
34
34
  const h = tabHwnd.current;
35
35
  if (h)
36
- gui.SendMessage(h, 4876 /* gui.TcMsg.SETCURSEL */, sel, 0);
36
+ gui.SendMessage(h, 4876 /* TcMsg.SETCURSEL */, sel, 0);
37
37
  }, [sel]);
38
- return (_jsxs("w", { type: "STATIC", ws: 268435456 /* gui.WindowStyle.VISIBLE */ | 33554432 /* gui.WindowStyle.CLIPCHILDREN */, style: { ...style, flexDirection: 'column', alignItems: 'stretch' }, ref: ref, onEvent: (e) => {
39
- if (e.msg === 78 /* gui.WmMsg.NOTIFY */) {
38
+ return (_jsxs("w", { type: "STATIC", ws: 268435456 /* WindowStyle.VISIBLE */ | 33554432 /* WindowStyle.CLIPCHILDREN */, style: { ...style, flexDirection: 'column', alignItems: 'stretch' }, ref: ref, onEvent: (e) => {
39
+ if (e.msg === 78 /* WmMsg.NOTIFY */) {
40
40
  const h = tabHwnd.current;
41
41
  if (!h)
42
42
  return;
43
43
  const code = nmCode(e.lParam);
44
44
  // SysTabControl32 在 comctl32 v6 下不发标准的 TCN_SELCHANGE (-550),
45
45
  // 收到 NM_CLICK (-2) 或 TCN_SELCHANGING (-551) 时读实际选中项
46
- if (code === -552 /* gui.TcNotifyCode.SELCHANGING */ || code === -2 /* gui.SysLinkNotifyCode.CLICK */) {
47
- const newSel = gui.SendMessage(h, 4875 /* gui.TcMsg.GETCURSEL */, 0, 0);
46
+ if (code === -552 /* TcNotifyCode.SELCHANGING */ || code === -2 /* SysLinkNotifyCode.CLICK */) {
47
+ const newSel = gui.SendMessage(h, 4875 /* TcMsg.GETCURSEL */, 0, 0);
48
48
  if (newSel !== sel) {
49
49
  if (!isControlled)
50
50
  setInternalIndex(newSel);
@@ -52,5 +52,5 @@ export const Tab = forwardRef(({ tabs, selectedIndex: controlledIndex, defaultSe
52
52
  }
53
53
  }
54
54
  }
55
- }, children: [_jsx("w", { type: "SysTabControl32", ws: 268435456 /* gui.WindowStyle.VISIBLE */ | 32768 /* gui.TabStyle.FOCUSNEVER */, style: { height: 20 }, ref: tabHwnd }), _jsx("w", { type: "STATIC", ws: 268435456 /* gui.WindowStyle.VISIBLE */ | 33554432 /* gui.WindowStyle.CLIPCHILDREN */, style: { flexGrow: 1, flexDirection: 'column', alignItems: 'stretch' }, children: tabs[sel]?.content })] }));
55
+ }, children: [_jsx("w", { type: "SysTabControl32", ws: 268435456 /* WindowStyle.VISIBLE */ | 32768 /* TabStyle.FOCUSNEVER */, style: { height: 20 }, ref: tabHwnd }), _jsx("w", { type: "STATIC", ws: 268435456 /* WindowStyle.VISIBLE */ | 33554432 /* WindowStyle.CLIPCHILDREN */, style: { flexGrow: 1, flexDirection: 'column', alignItems: 'stretch' }, children: tabs[sel]?.content })] }));
56
56
  });
@@ -9,7 +9,7 @@ function buildToolInfo(hTarget, text) {
9
9
  const buf = new PtrArrayBuffer(size + textLen);
10
10
  TTTOOLINFOW.encode({
11
11
  cbSize: size,
12
- uFlags: 16 /* gui.TtToolFlag.SUBCLASS */ | 1 /* gui.TtToolFlag.IDISHWND */,
12
+ uFlags: 16 /* TtToolFlag.SUBCLASS */ | 1 /* TtToolFlag.IDISHWND */,
13
13
  hwnd: hTarget,
14
14
  uId: hTarget,
15
15
  rect: [0, 0, 0, 0],
@@ -31,20 +31,20 @@ function Tooltip({ text, children, balloon }) {
31
31
  const hTarget = childRef.current;
32
32
  if (!hTarget)
33
33
  return;
34
- const hTT = gui.CreateWindow('tooltips_class32', '', -2147483648 /* gui.WindowStyle.POPUP */ | 1 /* gui.TooltipStyle.ALWAYSTIP */ | 2 /* gui.TooltipStyle.NOPREFIX */
35
- | (balloon ? 64 /* gui.TooltipStyle.BALLOON */ : 0), 0, 0, 0, 0, hTarget, null);
34
+ const hTT = gui.CreateWindow('tooltips_class32', '', -2147483648 /* WindowStyle.POPUP */ | 1 /* TooltipStyle.ALWAYSTIP */ | 2 /* TooltipStyle.NOPREFIX */
35
+ | (balloon ? 64 /* TooltipStyle.BALLOON */ : 0), 0, 0, 0, 0, hTarget, null);
36
36
  if (!hTT)
37
37
  return;
38
38
  hTTRef.current = hTT;
39
- SetWindowPos(hTT, -1 /* gui.SetWindowPosHwnd.TOPMOST */, 0, 0, 0, 0, 2 /* gui.SetWindowPosFlag.SWP_NOMOVE */ | 1 /* gui.SetWindowPosFlag.SWP_NOSIZE */ | 16 /* gui.SetWindowPosFlag.SWP_NOACTIVATE */);
39
+ SetWindowPos(hTT, -1 /* SetWindowPosHwnd.TOPMOST */, 0, 0, 0, 0, 2 /* SetWindowPosFlag.SWP_NOMOVE */ | 1 /* SetWindowPosFlag.SWP_NOSIZE */ | 16 /* SetWindowPosFlag.SWP_NOACTIVATE */);
40
40
  const ti = buildToolInfo(hTarget, text);
41
- gui.SendMessage(hTT, 1074 /* gui.TtMsg.ADDTOOLW */, 0, ti.ptr);
42
- gui.SendMessage(hTT, 1048 /* gui.TtMsg.SETMAXTIPWIDTH */, 0, 400);
43
- gui.SendMessage(hTT, 1025 /* gui.TtMsg.ACTIVATE */, 1, 0);
41
+ gui.SendMessage(hTT, 1074 /* TtMsg.ADDTOOLW */, 0, ti.ptr);
42
+ gui.SendMessage(hTT, 1048 /* TtMsg.SETMAXTIPWIDTH */, 0, 400);
43
+ gui.SendMessage(hTT, 1025 /* TtMsg.ACTIVATE */, 1, 0);
44
44
  return () => {
45
45
  if (hTT) {
46
46
  const ti2 = buildToolInfo(hTarget, text);
47
- gui.SendMessage(hTT, 1075 /* gui.TtMsg.DELTOOLW */, 0, ti2.ptr);
47
+ gui.SendMessage(hTT, 1075 /* TtMsg.DELTOOLW */, 0, ti2.ptr);
48
48
  gui.DestroyWindow(hTT);
49
49
  }
50
50
  hTTRef.current = null;
@@ -5,9 +5,9 @@ import { WCHAR } from '../../ffi/bind.js';
5
5
  import { TVITEM, TVINSERTSTRUCT } from '../../windows/structs.js';
6
6
  import { nmCode } from '../nmhdr.js';
7
7
  function buildTvItem(textPtr, cChildren) {
8
- let mask = 1 /* gui.TvIfFlag.TEXT */;
8
+ let mask = 1 /* TvIfFlag.TEXT */;
9
9
  if (cChildren > 0)
10
- mask |= 64 /* gui.TvIfFlag.CHILDREN */;
10
+ mask |= 64 /* TvIfFlag.CHILDREN */;
11
11
  return TVITEM.encode({
12
12
  mask, hItem: 0, state: 0, stateMask: 0,
13
13
  pszText: textPtr, cchTextMax: 260,
@@ -20,21 +20,21 @@ function insertItems(hTree, nodes, parentHandle, hItemMap, keyMap) {
20
20
  const textBuf = WCHAR.encode(node.label);
21
21
  const itemBuf = buildTvItem(textBuf.ptr, cChildren);
22
22
  const item = TVITEM.decode(itemBuf);
23
- const tvins = TVINSERTSTRUCT.encode({ hParent: parentHandle, hInsertAfter: -65536 /* gui.TvInsertAfter.ROOT */, item });
24
- const hItem = gui.SendMessage(hTree, 4402 /* gui.TvMsg.INSERTITEMW */, 0, tvins.ptr);
23
+ const tvins = TVINSERTSTRUCT.encode({ hParent: parentHandle, hInsertAfter: -65536 /* TvInsertAfter.ROOT */, item });
24
+ const hItem = gui.SendMessage(hTree, 4402 /* TvMsg.INSERTITEMW */, 0, tvins.ptr);
25
25
  hItemMap.set(hItem, node);
26
26
  if (node.key)
27
27
  keyMap.set(node.key, hItem);
28
28
  if (node.children && node.children.length > 0) {
29
29
  insertItems(hTree, node.children, hItem, hItemMap, keyMap);
30
- gui.SendMessage(hTree, 4354 /* gui.TvMsg.EXPAND */, 2 /* gui.TvExpandCmd.EXPAND */, hItem);
30
+ gui.SendMessage(hTree, 4354 /* TvMsg.EXPAND */, 2 /* TvExpandCmd.EXPAND */, hItem);
31
31
  }
32
32
  }
33
33
  }
34
34
  function deleteAllItems(hTree) {
35
- const n = gui.SendMessage(hTree, 4357 /* gui.TvMsg.GETCOUNT */, 0, 0);
35
+ const n = gui.SendMessage(hTree, 4357 /* TvMsg.GETCOUNT */, 0, 0);
36
36
  if (n > 0)
37
- gui.SendMessage(hTree, 4353 /* gui.TvMsg.DELETEITEM */, 1, -65536 /* gui.TvInsertAfter.ROOT */);
37
+ gui.SendMessage(hTree, 4353 /* TvMsg.DELETEITEM */, 1, -65536 /* TvInsertAfter.ROOT */);
38
38
  }
39
39
  const TreeView = forwardRef(function TreeViewInner({ data, onSelect, defaultSelectedKey, selectedKey: controlledKey, style }, ref) {
40
40
  const [internalKey, setInternalKey] = useState(defaultSelectedKey ?? null);
@@ -45,12 +45,12 @@ const TreeView = forwardRef(function TreeViewInner({ data, onSelect, defaultSele
45
45
  const keyMapRef = useRef(new Map());
46
46
  const onChangeRef = useRef(onSelect);
47
47
  onChangeRef.current = onSelect;
48
- const tvWs = 268435456 /* gui.WindowStyle.VISIBLE */ | 8388608 /* gui.WindowStyle.BORDER */ | 2097152 /* gui.WindowStyle.VSCROLL */
49
- | 65536 /* gui.WindowStyle.TABSTOP */
50
- | 2 /* gui.TreeViewStyle.HASLINES */
51
- | 1 /* gui.TreeViewStyle.HASBUTTONS */
52
- | 4 /* gui.TreeViewStyle.LINESATROOT */
53
- | 32 /* gui.TreeViewStyle.SHOWSELALWAYS */;
48
+ const tvWs = 268435456 /* WindowStyle.VISIBLE */ | 8388608 /* WindowStyle.BORDER */ | 2097152 /* WindowStyle.VSCROLL */
49
+ | 65536 /* WindowStyle.TABSTOP */
50
+ | 2 /* TreeViewStyle.HASLINES */
51
+ | 1 /* TreeViewStyle.HASBUTTONS */
52
+ | 4 /* TreeViewStyle.LINESATROOT */
53
+ | 32 /* TreeViewStyle.SHOWSELALWAYS */;
54
54
  useEffect(() => {
55
55
  const h = tvRef.current;
56
56
  if (!h)
@@ -59,13 +59,13 @@ const TreeView = forwardRef(function TreeViewInner({ data, onSelect, defaultSele
59
59
  hItemMapRef.current.clear();
60
60
  keyMapRef.current.clear();
61
61
  if (data && data.length > 0)
62
- insertItems(h, data, -65536 /* gui.TvInsertAfter.ROOT */, hItemMapRef.current, keyMapRef.current);
62
+ insertItems(h, data, -65536 /* TvInsertAfter.ROOT */, hItemMapRef.current, keyMapRef.current);
63
63
  }, [data]);
64
64
  useEffect(() => {
65
65
  const h = tvRef.current;
66
66
  if (!h)
67
67
  return;
68
- gui.SendMessage(h, 4396 /* gui.TvMsg.SETEXTENDEDSTYLE */, 0, 4 /* gui.TvExStyle.DOUBLEBUFFER */);
68
+ gui.SendMessage(h, 4396 /* TvMsg.SETEXTENDEDSTYLE */, 0, 4 /* TvExStyle.DOUBLEBUFFER */);
69
69
  }, []);
70
70
  useEffect(() => {
71
71
  if (selKey == null)
@@ -75,16 +75,16 @@ const TreeView = forwardRef(function TreeViewInner({ data, onSelect, defaultSele
75
75
  return;
76
76
  const hItem = keyMapRef.current.get(selKey);
77
77
  if (hItem !== undefined)
78
- gui.SendMessage(h, 4363 /* gui.TvMsg.SELECTITEM */, 9 /* gui.TvGnRelative.CARET */, hItem);
78
+ gui.SendMessage(h, 4363 /* TvMsg.SELECTITEM */, 9 /* TvGnRelative.CARET */, hItem);
79
79
  }, [selKey]);
80
- return (_jsx("w", { type: "STATIC", ws: 268435456 /* gui.WindowStyle.VISIBLE */ | 33554432 /* gui.WindowStyle.CLIPCHILDREN */, style: { ...style, flexDirection: 'column', alignItems: 'stretch' }, ref: ref, onEvent: (e) => {
81
- if (e.msg === 78 /* gui.WmMsg.NOTIFY */) {
80
+ return (_jsx("w", { type: "STATIC", ws: 268435456 /* WindowStyle.VISIBLE */ | 33554432 /* WindowStyle.CLIPCHILDREN */, style: { ...style, flexDirection: 'column', alignItems: 'stretch' }, ref: ref, onEvent: (e) => {
81
+ if (e.msg === 78 /* WmMsg.NOTIFY */) {
82
82
  const code = nmCode(e.lParam);
83
- if (code === -451 /* gui.TvNotifyCode.SELCHANGEDW */) {
83
+ if (code === -451 /* TvNotifyCode.SELCHANGEDW */) {
84
84
  const h = tvRef.current;
85
85
  if (!h)
86
86
  return;
87
- const hCaret = gui.SendMessage(h, 4362 /* gui.TvMsg.GETNEXTITEM */, 9 /* gui.TvGnRelative.CARET */, 0);
87
+ const hCaret = gui.SendMessage(h, 4362 /* TvMsg.GETNEXTITEM */, 9 /* TvGnRelative.CARET */, 0);
88
88
  const node = hItemMapRef.current.get(hCaret) ?? null;
89
89
  const key = node?.key ?? null;
90
90
  if (!isControlled)