#lang scheme/base

(require scheme/gui/base)
(require scheme/class)

(define (scrolled-text-box text-class insert input)
  (define frame (new frame% (label "something") (width 100) (height 100)))
  (define text (new text-class))
  (define canvas (new editor-canvas% 
                      (style '(auto-hscroll auto-vscroll))
                      (parent frame) (editor text)))
  
  (define hbox (new horizontal-pane% (stretchable-height #f) (alignment '(center top)) (parent frame)))
  (define close (new button% (parent hbox) (label "Close")
                     (callback (λ (btn event)
                                 (send frame show #f)))))
  (send-generic text insert input 0)
  (send frame show #t))

(scrolled-text-box 
 text% 
 (generic text% insert)
 "1 This is a test.
2 This is a test.
3 This is a test.
4 This is a test.
5 This is a test.
6 This is a test.
7 This is a test.
8 This is a test.
9 This is a test.")

(require (prefix-in widget: (planet dherman/widgets:2/widgets)))

(scrolled-text-box
 widget:read-only-text% 
 (generic widget:read-only-text% insert/programmatic)
 "This is a test. This is a test. This is a test. This is a test. This is a test. 
That is a test. This is a test. This is a test. This is a test. This is a test. 
This is a test. This is a test. This is a test. This is a test. This is a test. 
That is a test. This is a test. This is a test. This is a test. This is a test.")