Files
racket-webview/wv-dialog.rkt
2026-04-09 10:41:58 +02:00

51 lines
1.3 KiB
Racket

#lang racket/base
(require racket/class
"wv-window.rkt"
"private/utils.rkt"
)
(provide wv-dialog%
)
(define (default-w) 400)
(define (default-h) 400)
(define wv-dialog%
(class wv-window%
(inherit-field parent settings wv-context html-path x y width height)
(super-new)
(define/override (init-size)
(dbg-webview "init-size")
(let ((px (get-field x parent))
(py (get-field y parent))
(pw (get-field width parent))
(ph (get-field height parent))
)
(dbg-webview "geom: ~a, ~a; ~a, ~a" px py pw ph)
(let ((dw (send settings get 'width (if (eq? width #f) (default-w) width)))
(dh (send settings get 'height (if (eq? height #f) (default-h) height)))
)
(dbg-webview "size: ~a, ~a" dw dh)
(let ((xx (/ (- pw dw) 2))
(yy (/ (- ph dh) 2)))
(let ((x (inexact->exact (round (exact->inexact (+ px xx)))))
(y (inexact->exact (round (exact->inexact (+ py yy)))))
)
(dbg-webview "move ~a ~a" x y)
(send this move x y)
(dbg-webview "resize ~a ~a" dw dh)
(send this resize dw dh)
)
)
)
)
)
)
)