Hi,<br><br>I'm trying my hand at making a simple widget.<br><br>I've done something wrong and it is twice as high as it should be. <br><br>Please look at my code below and let me know where I have gone wrong.<br><br>
Cheers, <br><br>Stephen<br><br><br>; language 'Pretty Big'<br><br><br>;make new widget<br>(define scatter-chart% (class pane% ()<br> (init-field parent)<br> ; Make the drawing area
<br> (define pane (new pane% (parent parent))) ; this doesn't help<br> (define canvas (new canvas% [parent pane]<br> [min-width 100] [stretchable-width #f]
<br> [min-height 200] [stretchable-height #f]<br> ))<br> ; Get the canvas's drawing context
<br> (define dc (send canvas get-dc))<br> ; Make some pens and brushes<br> (define no-pen (make-object pen% "BLACK" 1 'transparent))<br>
(define blue-brush (make-object brush% "BLUE" 'solid))<br> (define yellow-brush (make-object brush% "YELLOW" 'solid)) <br> (define/public (redraw-chart list-of-integers)
<br> (send dc set-pen no-pen)<br> (send dc set-brush blue-brush)<br> (send dc draw-rectangle 0 0 100 200) ; big blue rectangle<br> (send dc set-brush yellow-brush)
<br> (map<br> (lambda (y) (send dc draw-rectangle 0 y 200 1)) ; draw a line for each integer.<br> list-of-integers ))<br> (super-instantiate () (parent parent)
<br> (min-height 200) [stretchable-height #f]<br> [min-width 100] [stretchable-width #f]<br> )<br> ))<br><br>; Make a frame
<br>(define frame (new frame% [label "scatter-chart% Example"]<br> [width 100]<br> [height 200]))<br><br><br>(define new-my-widget (new scatter-chart% (parent frame) ))
<br>; Show the frame<br>(send frame show #t)<br>; Wait a second to let the window get ready<br>(sleep/yield 1)<br><br>; Draw <br>(send new-my-widget redraw-chart '(10 30 22 77 78 79 33 55 95 99 125 155 157 159 188 187 186 191))
<br><br><br>