!if $wims_read_parm!=slib_header
 !goto proc
!endif
slib_title=to display a Geogebra Applet
slib_parms=2\
,appletcommand : commands for constructions in the applet, one by line and "\" character in the end of the lines.The syntaxe is the same that in GeoGebra (see here for details : http://www.geogebra.org/help/docufr/ ).\
,options (for example : <tt>width=300 height=300</tt>)
slib_author=Paul BYACHE et Bernadette PERRIN-RIOU
slib_out=

slib_comment=The first parameter is the appletcommand&#46; Be careful &#58; at least a comma " &#44;" for not to have a confusion between appletcommand and appletoptions\
Allowed options are the followings:\
<br><tt>height</tt> default 300\
<br><tt>width</tt> default 300\
<br><tt>file</tt> default none&#46; Be careful &#58; the &#46;ggb file must be in the "image" directory in you use the slib in a module OEF, in the "files" directory if you use the slib in a document, or else you have to use relative adress from $moduledir.\
<br><tt>showToolBar</tt> default false\
<br><tt>customToolBar</tt> default none. See here for details : http://www.geogebra.org/en/wiki/index.php/Barre . Be careful : no comma is allowed and if you want to separate two integers by a space-character, type a "@" instead of this space-character !\
<br><tt>showMenuBar</tt> default false\
<br><tt>showAlgebraInput</tt> default false\
<br><tt>language</tt> default fr\
<br><tt>debug</tt> default false\
<br>\
<br><tt>EXAMPLE\
<br><tt>&#92;integer{x=random(3)}\
<br><tt>&#92;text{appletcommand= Z=(&#92;x,3.78)&#92;\
<br><tt>W=(6.2,2.8)&#92;\
<br><tt>Ellipse[Z,W,5]&#92;\
<br><tt>u=Line[W,Z]}\
<br><tt>#the language can be setted in the options\
<br><tt>&#92;text{option= showToolBar=true\
<br><tt>language=en\
<br><tt>customToolBar="0|5@40@10||1|2"\
<br><tt>width=600\
<br><tt>height=500}\
<br><tt>#to hide the axes or the algebra window (on the left), use a ".ggb" file in the options\
<br><tt>&#92;text{applet=slib(geo2D/geogebra  &#92;appletcommand , &#92;option)}\
<br><tt>&#92;statement{&#92;applet}
 
!exit

:proc


!!!!!pour ne pas afficher l'applet lors de l'analyse de la rponse
!!  enlever car cela empche l'applet de s'afficher dans un document
!!!if $cmd=reply
!!!exit
!!!endif

!!!!!il y a un autre problme : quand une rponse de type texte est mal saisie et qu'on est invit  la redonner, la construction dans l'applet est perdue...
!!!!!pour l'instant, la syntaxe pour slib_data est la syntaxe "GeoGebra". Par la suite, il faudra que la syntaxe "wims" (celle du anstype) soit aussi reconnue.

!default slib_cnt=0
slib_cnt= $[$slib_cnt +1]
slib_data= !item 1 of $wims_read_parm
slib_z2= $slib_data
slib_option= !listcomplement  $slib_data in $wims_read_parm
slib_option= !replace internal , by @ in $slib_option

!for slib_a in file,width,height,showToolBar,showMenuBar,showAlgebraInput,customToolBar,language,debug
  slib_$slib_a=!getopt $slib_a in $slib_option
!next slib_a
slib_customToolBar= !nospace $slib_customToolBar
slib_customToolBar= !replace internal @ by , in $slib_customToolBar
slib_customToolBar= !replace internal || by % in $slib_customToolBar
slib_customToolBar= !replace internal | by ,|, in $slib_customToolBar
slib_customToolBar= !replace internal % by ,||, in $slib_customToolBar
slib_customToolBar= !items2words  $slib_customToolBar

!default slib_width=300
!default slib_height=300
!default slib_showToolBar=false
!default slib_showMenuBar=false
!default slib_showAlgebraInput=false
!default slib_language=fr
!default slib_debug=false


slib_data=!replace internal $\$ by $\
$ in $slib_data
slib_cnt=!linecnt $slib_data
slib_appletcommand=
!for slib_u=1 to $slib_cnt
  slib_line=!line $slib_u of $slib_data
  slib_appletcommand=!append line document.applets[0].evalCommand("$slib_line") to $slib_appletcommand
!next

slib_out=<applet codebase=java/geogebra code=geogebra.GeoGebraApplet \
archive=geogebra.jar width=$slib_width height=$slib_height>\
<param name=language value=$slib_language>\
<param name="showToolBar" value="$slib_showToolBar">\
<param name="framePossible" value="false">\
<param name="showMenuBar"  value="$slib_showMenuBar">\
<param name="showAlgebraInput"  value="$slib_showAlgebraInput">

!if $slib_file!=$empty
  slib_mod = $module_category
  !if document iswordof $slib_mod
    slib_image_dir=$Docdir/$doc/files
  !endif
  !if oef iswordof $slib_mod
    slib_image_dir=$imagedir
  !endif
  !default slib_image_dir=$module_dir
  
 slib_out=$slib_out \
 <param name="filename" value="../../$slib_image_dir/$slib_file">
!endif
!if $slib_customToolBar!=$empty
  slib_out=$slib_out \
  <param name="customToolBar" value="$slib_customToolBar">
!endif

slib_out=$slib_out \
</applet>\
<script language="JavaScript">\
   $slib_appletcommand\
</script>

slib_z1=$wims_read_parm

!if $slib_debug=true
  slib_out=$slib_out \
<br><br>Parameters read by the applet : $slib_z1<br><br>The slib_data : $slib_z2 --> $slib_data
!endif
