/*
-----------------------------------------------------------------------------
This source file is part of OpenSpace3D
For the latest info, see http://www.openspace3d.com
Copyright (c) 2012 I-maginer
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place - Suite 330, Boston, MA 02111-1307, USA, or go to
http://www.gnu.org/copyleft/lesser.txt
-----------------------------------------------------------------------------
*/
/*
Version : 1.0
First version : 23/03/2013
Author : Bourineau Bastien
*/
/*! \brief Callback on plugIT instance editor closed
*
* Prototype: fun [] [[S S] r1]
*
* \return [[S S] r1] : parameters to save in the instance XML data
**/
fun cbCloseEdit(p)=
let p -> [ctrlport ctrlspeed ctrlbytesize ctrlparity ctrlstopbits ctrlendchar ctrldatatype] in
["port" (getSelectedEdCtrlSelect ctrlport)]::
["speed" (getSelectedEdCtrlSelect ctrlspeed)]::
["bytesize" (getSelectedEdCtrlSelect ctrlbytesize)]::
["parity" itoa (getSelectedEdCtrlSelectPos ctrlparity)]::
["stopbits" itoa (getSelectedEdCtrlSelectPos ctrlstopbits)]::
["lastchar" itoa (getSelectedEdCtrlSelectPos ctrlendchar)]::
["datatype" itoa (getSelectedEdCtrlSelectPos ctrldatatype)]::
nil;;
/*! \brief Callback on plugIT instance editor opened
*
* Prototype: fun [EdWindow PInstance V3Dview] I
*
* \param EdWindow : editor window structure
* \param PInstance : plugIT instance
* \param V3Dview : default 3D view structure
*
* \return @fun [] [[S S] r1] : Callback to call on close
**/
fun dynamicedit(ewinstr, inst, viewstr, applybtn)=
let [400 250] -> [iw ih] in
(
setEdWindowSize ewinstr iw ih;
let (getPluginInstanceParam inst "port") -> sport in
let if sport == nil then "1" else sport -> sport in
let (getPluginInstanceParam inst "speed") -> speed in
let if speed == nil then "9600" else speed -> speed in
let (getPluginInstanceParam inst "bytesize") -> bytesize in
let if bytesize == nil then "8" else bytesize -> bytesize in
let atoi (getPluginInstanceParam inst "parity") -> parity in
let if parity == nil then 0 else parity -> parity in
let atoi (getPluginInstanceParam inst "stopbits") -> stopbits in
let if stopbits == nil then 0 else stopbits -> stopbits in // 0 equal to onestopbit
let atoi (getPluginInstanceParam inst "lastchar") -> lastchar in
let if lastchar == nil then 2 else lastchar -> lastchar in
let atoi (getPluginInstanceParam inst "datatype") -> datatype in
let if datatype == nil then 1 else datatype -> datatype in
let 10 -> ypos in
let crEdFrameWindow _channel ewinstr 0 0 iw 180 EDWIN_RESIZE_MW nil (loc "OS3DEDUCATIONALBUREAU_0010") (loc "OS3DEDUCATIONALBUREAU_0006") -> winfrm in
let crEdWindow _channel winfrm 0 18 iw 160 WN_CHILDINSIDE|WN_NOBORDER EDWIN_RESIZE_MW nil nil -> winstr in
let crEdCtrlLabel winstr 10 (set ypos = 10) + 2 160 20 (loc "OS3DEDUCATIONALBUREAU_0002") nil -> labeltitle in
let crEdCtrlSelect winstr 180 ypos 200 120 EDWIN_RESIZE_MW -> ctrlport in
let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 160 20 (loc "OS3DEDUCATIONALBUREAU_0011") nil -> labelspeed in
let crEdCtrlSelect winstr 180 ypos 200 120 EDWIN_RESIZE_MW -> ctrlspeed in
let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 160 20 (loc "OS3DEDUCATIONALBUREAU_0001") nil -> labelbyte in
let crEdCtrlSelect winstr 180 ypos 200 120 EDWIN_RESIZE_MW -> ctrlbytesize in
let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 160 20 (loc "OS3DEDUCATIONALBUREAU_0007") nil -> labelparity in
let crEdCtrlSelect winstr 180 ypos 200 120 EDWIN_RESIZE_MW -> ctrlparity in
let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 160 20 (loc "OS3DEDUCATIONALBUREAU_0012") nil -> labelstopbits in
let crEdCtrlSelect winstr 180 ypos 200 120 EDWIN_RESIZE_MW -> ctrlstopbits in
let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 160 20 (loc "OS3DEDUCATIONALBUREAU_0005") nil -> labelendchar in
let crEdCtrlSelect winstr 180 ypos 200 120 EDWIN_RESIZE_MW -> ctrlendchar in
let crEdFrameWindow _channel ewinstr 0 0 iw 60 EDWIN_RESIZE_MW nil (loc "OS3DEDUCATIONALBUREAU_0003") (loc "OS3DEDUCATIONALBUREAU_0006") -> winfrm in
let crEdWindow _channel winfrm 0 18 iw 40 WN_CHILDINSIDE|WN_NOBORDER EDWIN_RESIZE_MW nil nil -> winstr in
let crEdCtrlLabel winstr 10 ((set ypos = 10) + 2) 160 20 (loc "OS3DEDUCATIONALBUREAU_0004") nil -> labeldata in
let crEdCtrlSelect winstr 180 ypos 200 120 EDWIN_RESIZE_MW -> ctrldatatype in
(
let 1 -> i in
while i < 256 do
(
addEdCtrlSelect ctrlport itoa i;
set i = i + 1;
);
selectEdCtrlSelect ctrlport sport;
fillEdCtrlSelect ctrlspeed "110"::"300"::"600"::"1200"::"2400"::"4800"::"9600"::"14400"::"19200"::"38400"::"56000"::"57600"::"115200"::"128000"::"256000"::nil;
selectEdCtrlSelect ctrlspeed speed;
fillEdCtrlSelect ctrlbytesize "4"::"5"::"6"::"7"::"8"::nil;
selectEdCtrlSelect ctrlbytesize bytesize;
fillEdCtrlSelect ctrlparity "NONE"::"ODD"::"EVEN"::"MARK"::"SPACE"::nil;
selectEdCtrlSelectByPos ctrlparity parity;
fillEdCtrlSelect ctrlstopbits "1"::"1.5"::"2"::nil;
selectEdCtrlSelectByPos ctrlstopbits stopbits;
fillEdCtrlSelect ctrlendchar "NONE"::"CR (/13)"::"CRLF (/13/10)"::nil;
selectEdCtrlSelectByPos ctrlendchar lastchar;
fillEdCtrlSelect ctrldatatype "Number"::"Char"::nil;
selectEdCtrlSelectByPos ctrldatatype datatype;
[mkfun1 @cbCloseEdit [ctrlport ctrlspeed ctrlbytesize ctrlparity ctrlstopbits ctrlendchar ctrldatatype] nil];
);
);;