[plt-scheme] using macros to create new widgets in MrEd

From: Stephen De Gabrielle (spdegabrielle at gmail.com)
Date: Thu Jul 17 05:22:25 EDT 2008

Thanks Chongkai,

Despite my failing to include half my post, your advice was good; it
works! (attached)

I've also put it on the cookbook
http://schemecookbook.org/preview/Cookbook/GUIWidgetAggregation

I'd appreciate any comments on either implementation and utility
(the value of repeating the same components is dubious)

Cheers,

Stephen


On Wed, Jul 16, 2008 at 4:40 PM, Chongkai Zhu <czhu at cs.utah.edu> wrote:
> Stephen De Gabrielle wrote:
>>
>> Hi, I've been fiddling with composing widgets, and I thought I'd have
>> a try at making a macro to make the code a little easier to read;
>>
>> I've come up with a solution that allows me to specify a container and
>> two child widgets in the form
>> ;; make-widget : classname container-class function function -> class
>>
>> I'd prefer to have something like;
>> ;; define-widget new-widget-classname container-class container-args
>> sub-widget1% args1 subwidget2% args2)
>> eg
>> (define-widget double-button% horizontal-panel% '() button% '([label
>> label1])  button% '([label label1] [stretchable-width #t]))
>>
>> My problem is I can't work out how to use the args1 list.
>> As you can see below I have tried apply as in
>> (apply new sub-widget% (parent this) sub-widget-args)
>> but 'new' isn't a function.
>>
>> Any suggestions?
>>
>> Cheers,
>> Stephen
>> _________________________________________________
>>  For list-related administrative tasks:
>>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>>
>
> (define-syntax define-widget1
>  (syntax-rules ()
>   ((_ new-widget-classname (args ...))
>    (new new-widget-classname args ...))))
>
> (define-syntax define-widget2
>  (syntax-rules ()
>   ((_ new-widget-classname args)
>    (new new-widget-classname . args))))
>
>



-- 
Cheers,

Stephen

--
Stephen De Gabrielle
s.degabrielle at cs.ucl.ac.uk
Telephone +44 (0)20 7679 0693 (x30693)
Mobile 079 851 890 45
Project: Making Sense of Information (MaSI)
Work:http://www.uclic.ucl.ac.uk/annb/MaSI.html
Home:http://www.degabrielle.name/stephen


UCL Interaction Centre
MPEB 8th floor
University College London
Gower Street
London WC1E 6BT
-------------- next part --------------
A non-text attachment was scrubbed...
Name: widget-aggregator.ss
Type: application/octet-stream
Size: 1304 bytes
Desc: not available
URL: <http://lists.racket-lang.org/users/archive/attachments/20080717/c3773378/attachment.obj>

Posted on the users mailing list.