dbase/ui/demo_ui.prg · 2175 字节 · 下载原文
* demo_ui.prg —— dBase (xBase) 第四层:**最新 UI 接口**(宿主 `ui_*` 图元 + 绘图窗口)
* demo_ui.prg -- dBase (xBase) layer 4: **the newest UI interface** (host ui_* primitives + a drawing window)
*
* 跑法(桌面 vmlcli):
* How to run (desktop vmlcli):
* dotnet scripts/vmlcli/bin/Release/net10.0/vmlcli.dll Examples/dbase/ui/demo_ui.prg \
* --screen 480x640 --frames /tmp/dbase_ui_frames/
*
* ⚠ 要看画面请用 `--frames 目录`:`ui_win_close()` 会把场景置空,`--frame` 事后取不到东西。
* ⚠ Use --frames DIR: ui_win_close() clears the scene, so --frame has nothing to take afterwards.
*
* 本前端的写法要求:
* Coding rules of this frontend:
* ① 库函数直接按名字写(`ui_2d_rect(...)`),前端发 `CALL <原名>` 交给链接器。
* ① write library functions by name (ui_2d_rect(...)); the frontend emits CALL <name> for the linker.
* ② `/` 是**浮点除法** ⇒ 圆心坐标要用 `INT(w / 2)`(整数库函数收浮点会截断/出错)。
* ② `/` is **floating division** => use INT(w / 2) for the circle centre (integer library calls mis-handle floats).
* ③ 颜色是 0xAARRGGBB 作为 32 位有符号整数的十进制值(每行后面标了十六进制)。
* ③ colours are 0xAARRGGBB as signed-32-bit decimals (each line carries its hex value).
k = ui_win_open_ex("dBase UI demo", 0, 0, 0, 0)
w = ui_scr_get_w()
h = ui_scr_get_h()
IF w <= 0
w = 360
ENDIF
IF h <= 0
h = 620
ENDIF
frame = 0
DO WHILE frame < 20
k = ui_2d_clear(-15722464) && 0xFF101820 深底
k = ui_2d_rect(16, 16, w - 32, 96, -11890471, 1, 0, 10) && 0xFF4A90D9 面板
k = ui_2d_circle(INT(w / 2), INT(h / 2), 48, -1618884, 1, 0) && 0xFFE74C3C 红圆
k = ui_2d_line(16, h - 80, w - 16, h - 80, -12961206, 2) && 0xFF3A3A4A 分隔线
k = ui_2d_text(24, 30, "dBase UI demo", -1513232, 18, 0) && 0xFFE8E8F0 标题
k = ui_2d_text(24, 62, "rect / circle / line / text", -6643536, 12, 0) && 0xFF9AA0B0
k = ui_2d_present()
frame = frame + 1
k = ui_msg_fetch_wait(40)
IF ui_win_is_closed() # 0
frame = 20
ENDIF
ENDDO
k = ui_win_close()