-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuilding-blocks-field.rkt
34 lines (27 loc) · 1.1 KB
/
building-blocks-field.rkt
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
#lang racket
(provide building-blocks-field%)
(require "component.rkt")
(require "building-block.rkt")
(define building-blocks-field%
(class component%
(field (building-blocks (list
(new building-block% [name "+"])
(new building-block% [name "-"])
(new building-block% [name "*"])
(new building-block% [name "/"]))))
(define/override (set-size! width height)
(super set-size! width height)
(for-each (lambda (block)
(send block set-width! width)) building-blocks))
(define/override (draw dc)
(super draw dc)
(for-each (lambda (building-block)
(send building-block draw dc)
) building-blocks))
(super-new [color "blue"])
(let ((y (send this get-y)))
(for-each (lambda (block)
(send block set-position! 0 y)
(send block set-height! 30)
(set! y (+ y 30)))
building-blocks))))