[racket] Changing the background color of a GUI button.
Look like this will work very nicely indeed ... Thanks.
Am I correct in thinking that 'button-colors' models a 3-element ring
buffer where 'cdr' advances the access window one element?
On Thu, Feb 23, 2012 at 10:59 AM, Matthias Felleisen
<matthias at ccs.neu.edu>wrote:
>
> Would this work for you:
>
> #lang racket/gui
>
> (define (make-colored-bm color:str)
> [define bm (make-object bitmap% 200 200)]
> [define dc (make-object bitmap-dc% bm)]
> (send dc set-brush (make-object brush% color:str 'solid))
> (send dc draw-rectangle 0 0 200 200)
> (send dc set-bitmap #f)
> bm)
>
> (define frame (new frame% [label "test"] [width 200] [height 200]))
>
> (define panel (new panel% [parent frame]))
>
> (define button-colors
> (shared ([c (append (map make-colored-bm '("green" "red" "blue")) c)])
> c))
>
> (define buttn
> (new button%
> [label (car button-colors)]
> [parent panel]
> [callback (lambda (b e)
> (set! button-colors (cdr button-colors))
> (send buttn set-label (car button-colors)))]))
>
> (send frame show #t)
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20120223/535219fc/attachment-0001.html>