import '../lib/polyfill.js' import * as gui from 'gui' import { useState } from 'react' import { render, Button, Input, CheckBox, ProgressBar, ComboBox, Tab, ListView, type Column, ListBox, ScrollView, RadioButton, Slider, TreeView, type TreeNode, DateTimePicker, Link, Tooltip, PathPicker, } from '../lib/react-qw/index.js' gui.RegisterClass('Gallery', (hwnd, msg, wParam, lParam) => { if (!hwnd) return gui.DefWindowProc(hwnd, msg, wParam, lParam) if (msg === gui.WmMsg.DESTROY) { gui.PostQuitMessage(0) return 0 } return gui.DefWindowProc(hwnd, msg, wParam, lParam) }) const VISIBLE = gui.WindowStyle.VISIBLE const CLIPCHILDREN = gui.WindowStyle.CLIPCHILDREN interface Fruit { name: string color: string origin: string } const treeData: TreeNode[] = [ { key: 'fruits', label: 'Fruits', children: [ { key: 'apple', label: 'Apple' }, { key: 'banana', label: 'Banana' }, { key: 'cherry', label: 'Cherry' }, ], }, { key: 'veggies', label: 'Vegetables', children: [ { key: 'carrot', label: 'Carrot' }, { key: 'broccoli', label: 'Broccoli' }, ], }, { key: 'meats', label: 'Meats', children: [ { key: 'chicken', label: 'Chicken' }, { key: 'beef', label: 'Beef' }, { key: 'pork', label: 'Pork' }, ], }, ] function App({ svW, svH }: { svW: number; svH: number }) { const [count, setCount] = useState(0) const [disabled, setDisabled] = useState(true) const [inputText, setInputText] = useState('') const [checkA, setCheckA] = useState(true) const [checkB, setCheckB] = useState(false) const [progress, setProgress] = useState(30) const [lbSel, setLbSel] = useState(0) const [cbSel, setCbSel] = useState(-1) const [radio, setRadio] = useState('a') const [sliderVal, setSliderVal] = useState(50) const [treeSel, setTreeSel] = useState(null) const [dtDate, setDtDate] = useState(new Date()) const [pickerPath, setPickerPath] = useState('') const [listData, setListData] = useState([ { name: 'Apple', color: 'Red', origin: 'China' }, { name: 'Banana', color: 'Yellow', origin: 'Philippines' }, { name: 'Cherry', color: 'Dark Red', origin: 'USA' }, { name: 'Date', color: 'Brown', origin: 'Middle East' }, { name: 'Elderberry', color: 'Purple', origin: 'Europe' }, { name: 'Fig', color: 'Purple', origin: 'Turkey' }, { name: 'Grape', color: 'Green', origin: 'Italy' }, ]) const [listCols, setListCols] = useState[]>([ { name: 'Name', dataIndex: 'name' }, { name: 'Color', dataIndex: 'color' }, { name: 'Origin', dataIndex: 'origin' }, ]) const lbItems = listData.map(f => f.name) const cbItems = ['Red', 'Green', 'Blue', 'Yellow', 'Purple', 'Orange'] return ( {/* ===== 三列上半区 ===== */} {/* --- 左列: Buttons + CheckBoxes --- */} setRadio('a')} label="Option A" style={{height:24}} /> setRadio('b')} label="Option B" style={{height:24}} /> setRadio('c')} label="Option C" style={{height:24}} /> {/* --- 中列: Input + ProgressBar --- */} {/* --- 右列: ListBox + ComboBox --- */} = 0 ? lbItems[lbSel] : 'none'})`} style={{height:24}} /> setLbSel(i)} style={{flexGrow:1}} /> setCbSel(i)} style={{height:26}} /> = 0 ? `Selected: ${cbItems[cbSel]}` : '(none selected)'} style={{height:24}} /> {/* ===== Auto-Size ===== */} {/* ===== Tab Demo ===== */} )}, { title: 'Typing', content: ( )}, ]} style={{height:120}} /> {/* ===== DateTimePicker ===== */} {/* ===== SysLink ===== */} console.log('Link clicked:', url)} style={{flexGrow:1}}> Example Link console.log('Link clicked:', url)} style={{flexGrow:1}} /> {/* ===== PathPicker ===== */} {/* ===== 下半区: ListView + ScrollView + TreeView ===== */} columns={listCols} data={listData} style={{flexGrow:1}} /> {Array.from({ length: 20 }, (_, i) => ( ))} ) } const hwnd = gui.CreateWindow( 'Gallery', 'Component Gallery', gui.WindowStyle.OVERLAPPEDWINDOW, 100, 100, 1400, 1200, null, null ) if (hwnd) { const cr = gui.GetClientRect(hwnd)! const scale = gui.GetScaleFactor() const svW = Math.round((cr.right - cr.left) / scale) const svH = Math.round((cr.bottom - cr.top) / scale) render(, hwnd) setTimeout(() => { gui.ShowWindow(hwnd) }, 0) }