sections/flower-dialog.rkt
#lang racket

(require racket/gui racket/class)
(provide flower-dialog%)


(define flower-dialog%
  {class
   dialog%
   (init garden)
   (define my-garden garden)
   (super-new [label "Flowers"]
              [parent (send my-garden get-table)]
              [stretchable-width #f]
              [stretchable-height #f])
   ;; See the documentation of color-database<%> for color names.
   ;; (But you're only allowed to use colors named after flowers. ;-)
   ;; Oops, Racket's color database seems to have been hacked: a
   ;; little name mix up: Cornflower Blue is Lavender where Lavender
   ;; probably is azzurro (in italian) where the database has a french
   ;; sounding entry named azure. The other CornflowerBlue is alright
   ;; but the way things are you're now allowed to pick any colors not
   ;; only the ones named after flowers.
   (define flowers
     (list
      "Pale Green" ; you might take this for the infamous Mint Green
      "Lavender"
      "FloralWhite"
      "MistyRose"
      "Cornflower Blue"
      "Orchid"
      "Violet Red"
      ))
   (define flower-chooser
    (new radio-box%
         [label #f]
         [parent (new group-box-panel%
                      [parent this]
                      [label "You can pick a flower!"]
                      [stretchable-width #f]
                      [stretchable-height #f])]
         [choices flowers]))
   (define bottom-panel
     (new horizontal-panel%
          [parent this]
          [alignment '(center center)]
          [stretchable-height #f]))
   (new button%
       [parent bottom-panel]
       [label "&Ok"]
       [style '(border)]
       [callback {lambda (b e)
                   (send this show #f)
                   (send my-garden flower-picked
                         (vector-ref (list->vector flowers)
                                     (send flower-chooser get-selection)))
                   } ])

   (define/public (flower-present)
     (send this center)
     (send this show #t))
})