-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreport-view.ss
50 lines (34 loc) · 1.33 KB
/
report-view.ss
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
#lang scheme/base
(require "base.ss")
(require (unlib-in symbol)
"report-column.ss")
; Structure types --------------------------------
; (struct symbol string (listof column))
(define-struct view (id name columns) #:transparent)
; Components -------------------------------------
(define view-combo-box%
(class/cells vanilla-combo-box% ()
; Fields -------------------------------------
; snooze-report%
(init-field report #f #:accessor #:mutator)
; Methods ------------------------------------
; -> (listof view)
(define/override (get-options)
(send report get-views))
; view -> string
(define/override (option->raw view)
(symbol->string (view-id view)))
; (U string #f) -> (U view #f)
(define/override (raw->option raw-string)
(and raw-string
(let ([raw-symbol (string->symbol raw-string)])
(ormap (lambda (view)
(and (eq? raw-symbol (view-id view)) view))
(get-options)))))
; view -> string
(define/override (option->string view)
(format "Show ~a" (view-name view)))))
; Provide statements -----------------------------
(provide view-combo-box%)
(provide/contract
[struct view ([id symbol?] [name string?] [columns (listof (is-a?/c snooze-report-column%))])])