-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathrapid-gui.rkt
More file actions
53 lines (46 loc) · 1.4 KB
/
rapid-gui.rkt
File metadata and controls
53 lines (46 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#lang racket/base
(require racket/gui/base
racket/class
(for-syntax syntax/parse racket/base))
;;; ********************* ;;;
;;; *** Rapid Gui *** ;;;
;;; ********************* ;;;
(provide rapid-gui)
(define-syntax-rule (rapid-gui obj)
(rapid-gui-parent #f obj))
(define-syntax (rapid-gui-parent stx)
(syntax-case stx () ; todo: use syntax-parser
[(_ parent (cl-name (args ...) child ...))
(with-syntax ([name (gensym (syntax-e #'cl-name))])
#'(rapid-gui-named parent cl-name name (args ...) child ...))
]
[(_ parent (cl-name name (args ...) child ...))
#'(rapid-gui-named parent cl-name name (args ...) child ...)
]))
(define-syntax-rule (rapid-gui-named par cl-name name (args ...) child ...)
(begin
(define name (new cl-name [parent par] args ...))
(rapid-gui-parent name child) ...))
;=============;
;=== Tests ===;
;=============;
(module+ main
(rapid-gui
(frame%
fr1 ([label "a frame"] [min-width 400])
(horizontal-panel%
([min-width 400])
(button% bt1 ([label "Button 1"]))
(button% bt2 ([label "Close"]
[callback (λ(bt ev)(send fr1 show #f))]))
)
(horizontal-panel%
([min-width 400])
(check-box% cb1 ([label "CB 1"]))
(check-box% cb2 ([label "CB 2"]))
)
(message% ([label "Hello!"]))
))
(send fr1 show #t)
(send cb1 get-value)
)