#61505 - 2001-12-19 05:29 PM
KIX-TOOL: KixForms ActiveX Control for GUI Development
|
Shawn
Administrator
   
Registered: 1999-08-13
Posts: 8611
|
Theres been a lot of work going on over the past year and a bit in terms of GUI plugins for KiXtart. The intent is to provide a VB like interface for the kixtart scripting langauge. One that is tailored specifically for kixtart - in that kixtart does not have native support for ActiveX Control Events (like vbs and js have) ... so with that in mind, we had to devise a way for kixtart to respond gracefully to GUI events and at the same time - not soak-up 100% CPU utilization in the process.But first, a digression, the history of the plugins goes a bit like this: 1. kixwin32.dll - a very crude event polling snapin (by yours truly) 2. kixbgi32.dll - a much better, event polling snapin whose interface is based on the Borland Graphics Standard (BGI). This plugin made it all the way to build 18 before development work stopped. cj and Jochen helped the development of BGI immensely and wrote some VERY awesome scripts in the process. 3. kixforms.dll - a gui snapin with a vb like interface. The intent there was to conform (as much as possible) to VB style programming of visual controls ... this eases the learning curve in that if one has VB programming experience, kixforms would be a snap(in) ... 4. kixwinvb.dll - this is Alex`s implementation of kixwin32 but evolved more along the lines of visual basic. Actually, Alex and I started developing these snapins about the same time. But here`s the real deal. I orginally developed an event strategy whereby one would assign a code string to an object event property and then perform an event loop and use kixtart`s wonderful execute() function, like this:
$button.onclick = "button_click()" ; assign event to event property while $form.visible $=execute($form.getevent()) ; execute event properties as they happen loop
function button_click ; here`s an event ?"hi there" endfunction
then about the time kixforms build 3 rolled around. i decided to switch the event strategy and use a polling techique instead, like this:
while $form.getevent if $button.onclick() ?"hi there" endif loop
I personally feel that the polling technique has merit and is much more in-tune with the way KiXtart functions. And that is the way I left things in Build 4. Right now, kixforms is at Build 6 and about 80% percent done (from a functionality stand-point). So like Alex, I`d like to make KIXFORMS.DLL BUILD 4 available for the boards evaluation. Plus, they`re real fun to play with !!!
You can get KIXFORMS from here: KixForms to install kixforms, just unpack the zip into a directory and run the command: regsvr32 kixforms.dll then just run the sample scripts. KIXFORMS is written entirely in Visual C++ so there are no dependencies what-so-ever. But more importantly, it is still under development and is missing certain key controls. So have a look and try it out, and if any problems feel free to post. Anyways, I hoping that by making kixforms available now, and by showing some more sample scripts (abeit kixforms script) this will only help Alex`s efforts to get folks using these snapins. But the big thing that i would like to get the boards thoughts on is which event strategy is easiest, most intuitive, best for long-term, etc ... Looking forward to feedback -Shawn
|
|
Top
|
|
|
|
#61506 - 2001-12-19 05:36 PM
Re: KIX-TOOL: KixForms ActiveX Control for GUI Development
|
Shawn
Administrator
   
Registered: 1999-08-13
Posts: 8611
|
Here's a script I'm very proud of. It was written for and dedicated to - cj's, Jochen's and my children. It the old standard, you may remember: LiteBrite by Milton Bradley ...
; BRITE.KIX ; ; KIXTART 4.01 ; KIXFORMS BUILD 4 ; ;==================================== ; ; This script is dedicated to: ; ; Jessica and Christopher (Tassie) ; Sonja, Jan and Lara (Polster) ; Frances (Matheson) ; ;==================================== ; break on
$CELLWIDTH = 12 $CELLHEIGHT = 12 $CIRCLERADIUS = 5 $MAXCOL = 50 $MAXROW = 28 $XOFFSET = 20 $YOFFSET = 20 $MAXX = $MAXCOL * $CELLWIDTH + $XOFFSET $MAXY = $MAXROW * $CELLHEIGHT + $YOFFSET $CRLF = CHR(13)+CHR(10)
$drawing = 0
;====== ; FORM ;======
$form = createobject("kixtart.form") $form.caption = "Lite Brite - KiXtart" $form.width = 725 $form.height = 405 $form.top = ($form.screenheight - $form.height ) / 2 $form.left = ($form.screenwidth - $form.width ) / 2 $form.borderstyle=1 $form.forecolor = $form.rgb(100,100,100) $form.backcolor = 0 $form.fontsize = 9 $form.fontname = "courier new" $form.backstyle = 1 ;========== ; CONTROLS ;==========
$clear = $form.commandbutton(635,20,70,25,"Clear")
$save = $form.commandbutton(635,50,70,25,"Save")
$load = $form.commandbutton(635,80,70,25,"Load")
;====== ; GRID ;======
dim $row[$MAXROW-1] global $grid[$MAXCOL-1] for $i = 0 to ubound($grid) $grid[$i] = $row for $j = 0 to ubound($grid[$i]) $grid[$i][$j] = 0 ; black next next
$form.forecolor = &646464 $form.fillstyle = 1 for $y = $YOFFSET to $MAXY step $CELLHEIGHT $form.line($XOFFSET,$y,$MAXX+1,$y) next for $x = $XOFFSET to $MAXX step $CELLWIDTH $form.line($x,$YOFFSET,$x,$MAXY+1) next
;========= ; PALETTE ;=========
global $palette[15] $palette[0] = 0 $palette[1] = 8388608 $palette[2] = 32768 $palette[3] = 8421376 $palette[4] = 128 $palette[5] = 8388736 $palette[6] = 32896 $palette[7] = 12632256 $palette[8] = 8421504 $palette[9] = 16711680 $palette[10] = 65280 $palette[11] = 16776960 $palette[12] = 255 $palette[13] = 16711935 $palette[14] = 65535 $palette[15] = 16777215
$color=0 $form.fillstyle = 1 $form.forecolor = &FFFFFF for $x = 0 to 15 $form.fillcolor = $palette[$x] $form.rectangle(635,118+($x*15),70,15) next
$color = $form.rgb(255,0,0)
;==== ; START ;====
load_click("brite.spl")
$form.show
while $form.getevent
select
case $clear.click
clear_click()
case $load.click
load_click("brite.spl")
case $save.click
save_click("brite.spl")
case $form.mousedown
mouse_down($form.mousebutton,$form.mousex,$form.mousey)
case $form.mouseup
mouse_up($form.mousebutton,$form.mousex,$form.mousey)
case $form.mousemove
mouse_move($form.mousebutton,$form.mousex,$form.mousey)
case 1 endselect loop exit 1 function mouse_down($button,$x,$y) $drawing = 1 addcell($x,$y,$color) endfunction
function mouse_move($button,$x,$y) $form.forecolor = &FFFF00 $form.moveto(20,360) $form.print(" ") $c = $form.pixel($x,$y) $form.print("x:$x y:$y c:$c") if $drawing addcell($x,$y,$color) endif endfunction
function mouse_up($button,$x,$y) $drawing = 0 endfunction
function addcell($x,$y,$c)
dim $col,$row
if ( $x > 637 and $x < 704 and $y > 46 and $y < 357 ) $color = $form.pixel($x,$y) return endif
if $drawing if ( $x > $XOFFSET and $x < $MAXX and $y > $YOFFSET and $y < $MAXY ) $row = ($y - $YOFFSET) / $CELLHEIGHT $col = ($x - $XOFFSET) / $CELLWIDTH drawcell($row,$col,$c) $grid[$col][$row] = $c endif endif
endfunction function drawcell($row,$col,$c) $form.forecolor = $c $form.fillstyle = 1 ; solid $form.fillcolor = $c $cx = $col*$CELLWIDTH+$XOFFSET+$CELLWIDTH/2 $cy = $row*$CELLHEIGHT+$YOFFSET+$CELLHEIGHT/2 $form.circle($cx,$cy,$CIRCLERADIUS) if $c $form.forecolor = &FFFFFF $form.fillcolor = &FFFFFF $form.circle($cx,$cy-1,2) endif endfunction
function clear_click() $form.forecolor = 0 ;$form.backcolor $form.fillcolor = 0 ;$form.backcolor $form.fillstyle = 1 ; solid for $col = 0 to ubound($grid) for $row = 0 to ubound($grid[$col]) if $grid[$col][$row] ; not black $form.circle( $col*$CELLWIDTH+$XOFFSET+$CELLWIDTH/2, $row*$CELLHEIGHT+$YOFFSET+$CELLHEIGHT/2, $CIRCLERADIUS) $grid[$col][$row] = 0 endif next next endfunction
function save_click($filename) dim $row,$col,$c del "@curdir\$filename" if open(1,"@curdir\$filename",5) = 0 for $col = 0 to ubound($grid) for $row = 0 to ubound($grid[$col]) if $grid[$col][$row] ; not black $c = $grid[$col][$row] $=writeline(1,"$col,$row,$c"+$crlf) endif next next $=close(1) endif endfunction
function load_click($filename) clear_click() if open(1,"@curdir\$filename") = 0 $drawing=1 $line = readline(1) while $line and not @error if $line $data = split($line,",") $col = val($data[0]) $row = val($data[1]) $c = val($data[2]) drawcell($row,$col,$c) $grid[$col][$row] = $c endif $line = readline(1) loop $=close(1) $drawing=0 endif endfunction
-Shawn [ 19 December 2001: Message edited by: Shawn ]
|
|
Top
|
|
|
|
#61507 - 2001-12-19 05:53 PM
Re: KIX-TOOL: KixForms ActiveX Control for GUI Development
|
Jochen
KiX Supporter
   
Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
|
Shawn,first feedback from me if nobody minds, so you decided to make build 4 available ... Good call ! You know very well my feelings on the design question on kixforms ... For all others interested : I prefer the strategy used in build 2 : assign event to event property (function,line of code) !!! J. (btw. the script I'm very proud of still stucks in Kixbgi shoes ) [ 19 December 2001: Message edited by: jpols ]
_________________________
|
|
Top
|
|
|
|
#61510 - 2001-12-19 06:42 PM
Re: KIX-TOOL: KixForms ActiveX Control for GUI Development
|
Alex.H
Seasoned Scripter
Registered: 2001-04-10
Posts: 406
Loc: France
|
Shawn, The BRITE.KIX is really impressive (other too, also) When i was thinking about adding custom shape support, you were doing a nice job with it
_________________________
? getobject(Kixtart.org.Signature)
|
|
Top
|
|
|
|
#61512 - 2001-12-19 07:07 PM
Re: KIX-TOOL: KixForms ActiveX Control for GUI Development
|
Alex.H
Seasoned Scripter
Registered: 2001-04-10
Posts: 406
Loc: France
|
That's the splash which slap me. Yes i've try ADSI.kix. Nice, but it don't like [Computer] => change=>cancel (just nagging, it's really cool)For the differential target, it could be an idea, as adding more and more stuff get a really big snappin (mine is already 100k, and i have something to try to reduce this). This really help us to prevent a little war  Ah, i've found what i was looking for :  [ 19 December 2001: Message edited by: Alex.H ]
_________________________
? getobject(Kixtart.org.Signature)
|
|
Top
|
|
|
|
#61517 - 2001-12-22 01:00 PM
Re: KIX-TOOL: KixForms ActiveX Control for GUI Development
|
cj
MM club member
   
Registered: 2000-04-06
Posts: 1102
Loc: Brisbane, Australia
|
Note sure what you can do with it!!? I am not sure what I can't do with it!  Here is the IFS fractal script: It supports the "usual 5" IFS fractals: the ubiquitous fern, Sierpinskys triangle and a variation on that, one called the Dragon that I found in a book and one called the Maple leaf that I found in the same book, but looks nothing like a maple leaf. [technical fractal talk] The fern is not perfect as the script gives each transformation the same priority. When I get access to my original notes (at home somewhere) I will look up the transformaion prioritys and put them in the $AT[0] array. This is the "settings" for eact affine transform. [/technical fractal talk]  here is the script: if you have any problems I can email it to you.
code:
break on? "KiXForms IFS Fractal Generator" ? "Version 1.1 by cj" ? ; the fern dim $fern[4] $fern[0]=200,300,1,1,10000 $fern[1]=85,4,0,-4,85,40 $fern[2]=20,-26,0,23,22,40 $fern[3]=-15,28,0,26,24,11 $fern[4]=0,0,0,0,16,0
; Sierpinsky's triangle dim $sierp[3] $sierp[0]=300,300,1,1,20000 $sierp[1]=50,0,0,0,50,0 $sierp[2]=50,0,301,0,50,0 $sierp[3]=50,0,0,0,50,301 ; A slightly modified Sierpinsky triangle dim $sierp2[4] $sierp2[0]=400,400,1,1,10000 $sierp2[1]=50,0,0,0,50,0 $sierp2[2]=50,0,300,0,50,0 $sierp2[3]=50,0,150,0,50,300 $sierp2[4]=25,0,225,0,25,150 ; the dragon dim $dragon[2] $dragon[0]=200,300,1,1,10000 $dragon[1]=45,-50,0,40,55,0 $dragon[2]=45,-50,400,40,55,0 ; a maple leaf - this one doesn't look right... dim $maple[4] $maple[0]=250,200,1,-1,10000 $maple[1]=49,1,25,0,62,-2 $maple[2]=27,52,0,-40,36,56 $maple[3]=18,-73,88,50,26,8 $maple[4]=4,-1,52,50,0,32 ; create KiXForm $form = createobject("kixtart.form") $form.caption = "IFS Fractal test" $form.visible=1 $Form.BackColor = 0 ; black background $form.forecolor = $Form.RGB(0, 200, 0) ; a beautiful green $cmdFern = $Form.CommandButton(560,55,65,25,"Fern") $cmdSierp = $Form.CommandButton(560,80,65,25,"Sierpinsky") $cmdSierp2 = $Form.CommandButton(560,105,65,25,"Sierpinsky2") $cmdDragon = $Form.CommandButton(560,130,65,25,"Dragon") $cmdMaple = $Form.CommandButton(560,155,65,25,"Maple") $cmdExit = $Form.CommandButton(560,205,65,25,"Exit") :again while not $form.getevent() loop ; scan for click ; process click if $cmdFern.click() DrawIFS($fern) endif if $cmdSierp.click() DrawIFS($sierp) endif if $cmdSierp2.click() DrawIFS($sierp2) endif if $cmdDragon.click() DrawIFS($dragon) endif if $cmdMaple.click() DrawIFS($maple) endif if not $cmdExit.click() goto again endif quit quit function DrawIFS($AT)
$Form.BackColor = 0 ; clear the screen again $i=0 ; get image offset $xoff=$at[0][0] $yoff=$at[0][1] ; get image rotation $xflip=$at[0][2] $yflip=$at[0][3] do $t=rnd(ubound($at)-1)+1
$x=(($x*$at[$t][0])/100)+(($y*$at[$t][1])/100)+$at[$t][2] $y=(($x*$at[$t][3])/100)+(($y*$at[$t][4])/100)+$at[$t][5] ; $form.circle(300-$x, 300-$y, 1) ; draw dot $form.circle(-$xflip*$x+$xoff, -$yflip*$y+$yoff, 1) ; draw dot $i=$i+1 until $i=$at[0][4] ; while $Form.getevent() and not $cmdExit.click() loop endfunction
cj
|
|
Top
|
|
|
|
#61519 - 2001-12-22 07:03 PM
Re: KIX-TOOL: KixForms ActiveX Control for GUI Development
|
Shawn
Administrator
   
Registered: 1999-08-13
Posts: 8611
|
Ceej:I made two very minor changes to your sript. I used case statements in the main loop only because in this particular case, all your buttons are mutually exclusive (or at least, that the easiest way to design this) and then I modifed the while loop in the fern function like this:
dountil $i=$at[0][4] or ($form.peekevent() and $cmdexit.click())
peekevent is the asynchronous version of getevent. getevent waits for user input and returns false only when the window closes, thats why you can use it in a loop like this:
while $form.getevent() if $button.click ?"hi there" endif loop
peekevent returns true only if there's an event waiting in the event queue else it returns false right away. so the structure of an asynchronous event loop is different, like this:
while $form.visible if $form.peekevent if $button.click $form.visible=0 ; stop the loop endif else ; there no event waiting so carry on processing forever ... endif loop
anyways, heres your script back at you. thanks for converting that:
break on ? "KiXForms IFS Fractal Generator" ? "Version 1.1 by cj" ?
; the fern dim $fern[4] $fern[0]=200,300,1,1,10000 $fern[1]=85,4,0,-4,85,40 $fern[2]=20,-26,0,23,22,40 $fern[3]=-15,28,0,26,24,11 $fern[4]=0,0,0,0,16,0 ; Sierpinsky's triangle dim $sierp[3] $sierp[0]=300,300,1,1,20000 $sierp[1]=50,0,0,0,50,0 $sierp[2]=50,0,301,0,50,0 $sierp[3]=50,0,0,0,50,301 ; A slightly modified Sierpinsky triangle dim $sierp2[4] $sierp2[0]=400,400,1,1,10000 $sierp2[1]=50,0,0,0,50,0 $sierp2[2]=50,0,300,0,50,0 $sierp2[3]=50,0,150,0,50,300 $sierp2[4]=25,0,225,0,25,150 ; the dragon dim $dragon[2] $dragon[0]=200,300,1,1,10000 $dragon[1]=45,-50,0,40,55,0 $dragon[2]=45,-50,400,40,55,0 ; a maple leaf - this one doesn't look right... dim $maple[4] $maple[0]=250,200,1,-1,10000 $maple[1]=49,1,25,0,62,-2 $maple[2]=27,52,0,-40,36,56 $maple[3]=18,-73,88,50,26,8 $maple[4]=4,-1,52,50,0,32
; create KiXForm $form = createobject("kixtart.form") $form.caption = "IFS Fractal test" $form.visible=1 $Form.BackColor = 0 ; black background $form.forecolor = $Form.RGB(0, 200, 0) ; a beautiful green
$cmdFern = $Form.CommandButton(560,55,65,25,"Fern") $cmdSierp = $Form.CommandButton(560,80,65,25,"Sierpinsky") $cmdSierp2 = $Form.CommandButton(560,105,65,25,"Sierpinsky2") $cmdDragon = $Form.CommandButton(560,130,65,25,"Dragon") $cmdMaple = $Form.CommandButton(560,155,65,25,"Maple") $cmdExit = $Form.CommandButton(560,205,65,25,"Exit")
while $form.getevent
select case $cmdFern.click() DrawIFS($fern) case $cmdSierp.click() DrawIFS($sierp) case $cmdSierp2.click() DrawIFS($sierp2) case $cmdDragon.click() DrawIFS($dragon) case $cmdMaple.click() DrawIFS($maple) case $cmdExit.click() quit() endselect
loop
function DrawIFS($AT) $Form.BackColor = 0 ; clear the screen again $i=0 ; get image offset $xoff=$at[0][0] $yoff=$at[0][1] ; get image rotation $xflip=$at[0][2] $yflip=$at[0][3]
do $t=rnd(ubound($at)-1)+1 $x=(($x*$at[$t][0])/100)+(($y*$at[$t][1])/100)+$at[$t][2] $y=(($x*$at[$t][3])/100)+(($y*$at[$t][4])/100)+$at[$t][5] ; $form.circle(300-$x, 300-$y, 1) ; draw dot $form.circle(-$xflip*$x+$xoff, -$yflip*$y+$yoff, 1) ; draw dot $i=$i+1 until $i=$at[0][4] or ($form.peekevent() and $cmdexit.click()) endfunction
|
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
1 registered
(Allen)
and 1198 anonymous users online.
|
|
|