Path: news.daimi.aau.dk!not-for-mail From: Manmathan Muthukumarapillai Newsgroups: daimi.dsa,daimi.beta Subject: Re: RadioGroup Date: Tue, 08 Apr 1997 22:26:57 +0200 Organization: DAIMI, Computer Science Dept. at Aarhus University Lines: 265 Message-ID: <334AAA11.4361@daimi.aau.dk> References: <334AA8A0.6B9E@daimi.aau.dk> NNTP-Posting-Host: kip.daimi.aau.dk Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------6150294B529A" X-Mailer: Mozilla 3.0 (X11; I; SunOS 5.4 sun4m) Xref: news.daimi.aau.dk daimi.dsa:10370 daimi.beta:10261 This is a multi-part message in MIME format. --------------6150294B529A Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit En fejl ved sidste sending.. Jeg haaber at I kan laese kildekoden og eksemplet... /mannan --------------6150294B529A Content-Type: text/plain; charset=iso-8859-1; name="radioGroupLib.bet" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline; filename="radioGroupLib.bet" ORIGIN '~beta/guienv/v1.4/guienvall'; INCLUDE '~beta/guienv/v1.4/utils/iconname'; -- canvasLib: Attributes -- RadioGroup: = (# = ifGroupIsOpen: = (# = do (if private.isGroupOpen then INNER ifGroupIsOpen; else 'cannot change state! Group is Not Open'->putline; this(G= uienv).terminate; if); #); onSelectedChanged:< (# current:^radioGroupButton; enter current[] do= INNER;#); selectedButton: = (# sb: ^radioGroupButton; enter ifGroupIsOpen (# enter sb[] do true->sb.state; #) exit ifGroupIsOpen (# = do none->sb[]; Loop: = (for int: private.buttons.range repeat (if private.buttons[int].state then private.buttons[i= nt][]->sb[]; leave loop; if) for); (if sb[]=3Dnone then private.buttons[1][]->sb[]; true->sb.st= ate; if); exit sb[] #) #); selectedNr: = (# butnr: @integer; enter ifGroupIsOpen (# enter butnr do (if (butnr>0) and (private.buttons.range>=3Db= utnr) then true->private.buttons[butnr].state; if); #) exit ifGroupIsOpen (# do Loop: = (for int: private.buttons.range repeat (if private.buttons[int].state then int->butnr; leave= loop; if) for); (if not((butnr<=3Dprivate.buttons.range) and (butnr>0)) then= 1->butnr; true->private.buttons[1].state; if); exit butnr #) #); private: @ (# = buttons: [2]^radioGroupButton; isGroupOpenVal,isGroupActive: @Boolean; isGroupOpen: (# val:@boolean; enter (# enter val do (if not(val) then false->isGroupActive-= >isGroupOpenVal; else true->isGroupOpenVal; if); #) exit isGroupOpenVal #); selectThis: = (# = sb: ^radioGroupButton; enter sb[] do false->isGroupActive; (for int: buttons.range repeat (if (sb[]<>buttons[int][]) then false->buttons[int].state; else true->buttons[int].state; if); for); true->isGroupActive; #); #); radioGroupButton: radioButton (# = eventhandler:: = (# onMouseUp:: = (# = do true->state; false->this(RadioGroup).private.isGroupActive; false->state; true->this(RadioGroup).private.isGroupActive; #); onStateChanged:: = (# (* this button is always selected *) do (if this(RadioGroup).private.isGroupActive then this(radioGroupButton)[]->this(radioGroup).privat= e.selectThis; this(radioGroupButton).onSelect; this(radioGroupButton)[]->this(radioGroup).onSele= ctedChanged; if); #); #); onSelect:< (# do INNER;#); open::< (# do INNER; #); #); addgroup: = (# = rb: ^radioGroupButton; index: @integer; enter (index,rb[]) do (if ((index>=3D1) and (index<=3Dprivate.buttons.range) and (rb[= ]<>NONE)) then rb[]->private.buttons[index][]; else 'AddGroup failed'->putline; this(Guienv).terminate; if); #); groupsize: = (# size: @integer; enter (# enter size do size->private.buttons.new; #) exit (# do private.buttons.range->size; exit size #) #); init:< = (* Must run First. * How many radiobuttons should there be? size->groupsize; * (1,radio1[])->addgroup; (2,radio2[])->addgroup; and so on.. *) (# do false->private.isGroupOpen; INNER; #); open:< = (* den f=F8rste der blev tilf=F8jet er pr. default den aktive unle= ss you say * radioN[]->selectedButton[]; OR nr->selectedNr; *) (# = do init; (for int: private.buttons.range repeat (if private.buttons[int][]<>none then private.buttons[int].open; else 'Opening Failed: pointer NONE'->putline; this(Guienv).= terminate; if); for); true->private.isGroupOpen->private.isGroupActive; INNER; (# tmp:@integer; do selectedNr->tmp; #); #); close:< = (* Bruges til at lukke radioGroup *) (# = do INNER; (for int: private.buttons.range repeat private.buttons[int].close; for) #); state: = (* Bruges af software til =E6ndring/afl=E6sning af status *) (# = butnr: @integer; enter (# enter butnr do butnr->selectedNr; #) exit (# do selectedNr->butnr; exit butnr #) #); #) = --------------6150294B529A Content-Type: text/plain; charset=us-ascii; name="radioGroupEksempel.bet" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="radioGroupEksempel.bet" Koen: @ canvas (# stateMand: (# enter theRadioGroup.Mand.state exit theRadioGroup.Mand.state #); stateBegge: (# enter theRadioGroup.begge.state exit theRadioGroup.begge.state #); open:: (# do (184,36)->size; false->border.visible; 3->border.style; theRadioGroup.open; INNER; #); theRadioGroup: @RadioGroup (# onSelectedChanged:: (# do selectedNr-1->akc.koen; #); mand: @radioGroupButton (# open:: (# do (60,30)->size; 'Mand'->label; (2,2)->position; #); #); kvinde: @radioGroupButton (# open:: (# do (60,30)->size; 'Kvinde'->label; (62,2)->position; #); #); begge: @radioGroupButton (# open:: (# do (60,30)->size; 'Begge'->label; (122,2)->position; #); #); init:: (# do 3->groupsize; (1,begge[])->addgroup; (2,mand[])->addgroup; (3,kvinde[])->addgroup; #); edNr; #); #); #); --------------6150294B529A--