/*
-----------------------------------------------------------------------------
This source file is part of OpenSpace3D
For the latest info, see http://www.openspace3d.com
Copyright (c) 2016 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 : 05/29/2016
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 -> [ctrlcols ctrlrows ctrlbits ctrlpinrs ctrlpinstrb ctrlpin0 ctrlpin1 ctrlpin2 ctrlpin3 ctrlpin4 ctrlpin5 ctrlpin6 ctrlpin7 ctrlalign ctrltext ctrlscroll ctrlenable] in
let itoa (ftoi (getEdCtrlFloatValue ctrlcols)) -> cols in
let itoa (ftoi (getEdCtrlFloatValue ctrlrows)) -> rows in
let (getSelectedEdCtrlSelect ctrlbits) -> bits in
let (getSelectedEdCtrlSelect ctrlpinrs) -> rs in
let (getSelectedEdCtrlSelect ctrlpinstrb) -> strb in
let (getSelectedEdCtrlSelect ctrlpin0) -> d0 in
let (getSelectedEdCtrlSelect ctrlpin1) -> d1 in
let (getSelectedEdCtrlSelect ctrlpin2) -> d2 in
let (getSelectedEdCtrlSelect ctrlpin3) -> d3 in
let (getSelectedEdCtrlSelect ctrlpin4) -> d4 in
let (getSelectedEdCtrlSelect ctrlpin5) -> d5 in
let (getSelectedEdCtrlSelect ctrlpin6) -> d6 in
let (getSelectedEdCtrlSelect ctrlpin7) -> d7 in
let itoa getSelectedEdCtrlSelectPos ctrlalign -> align in
let getEdCtrlEditTextValue ctrltext -> text in
let itoa (ftoi (getEdCtrlFloatValue ctrlscroll)) -> scroll in
let itoa getEdCtrlCheckState ctrlenable -> init in
["cols" cols]::
["rows" rows]::
["bits" bits]::
["rs" rs]::
["strb" strb]::
["d0" d0]::
["d1" d1]::
["d2" d2]::
["d3" d3]::
["d4" d4]::
["d5" d5]::
["d6" d6]::
["d7" d7]::
["textalign" align]::
["text" text]::
["scroll" scroll]::
["init" init]::
nil;;
fun cbSelectMode(ctrl, pos, elem, p)=
let p -> [ctrlpin4 ctrlpin5 ctrlpin6 ctrlpin7] in
if (pos == 0) then
(
setEdCtrlSelectEnable ctrlpin4 0;
setEdCtrlSelectEnable ctrlpin5 0;
setEdCtrlSelectEnable ctrlpin6 0;
setEdCtrlSelectEnable ctrlpin7 0;
)
else
(
setEdCtrlSelectEnable ctrlpin4 1;
setEdCtrlSelectEnable ctrlpin5 2;
setEdCtrlSelectEnable ctrlpin6 3;
setEdCtrlSelectEnable ctrlpin7 4;
);
0;;
fun fillPinSelector(ctrlpin, select)=
let 2 -> i in
while i < 28 do
(
addEdCtrlSelect ctrlpin itoa i;
set i = i + 1;
);
selectEdCtrlSelect ctrlpin itoa select;
0;;
/*! \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 530] -> [iw ih] in
(
setEdWindowSize ewinstr iw ih;
let atoi (getPluginInstanceParam inst "cols") -> cols in
let if cols == nil then 16 else cols -> cols in
let atoi (getPluginInstanceParam inst "rows") -> rows in
let if rows == nil then 2 else rows -> rows in
let atoi (getPluginInstanceParam inst "bits") -> bits in
let if bits == nil then 4 else bits -> bits in
let atoi (getPluginInstanceParam inst "rs") -> rs in
let if rs == nil then 14 else rs -> rs in
let atoi (getPluginInstanceParam inst "strb") -> strb in
let if strb == nil then 15 else strb -> strb in
let atoi (getPluginInstanceParam inst "d0") -> d0 in
let if d0 == nil then 18 else d0 -> d0 in
let atoi (getPluginInstanceParam inst "d1") -> d1 in
let if d1 == nil then 17 else d1 -> d1 in
let atoi (getPluginInstanceParam inst "d2") -> d2 in
let if d2 == nil then 27 else d2 -> d2 in
let atoi (getPluginInstanceParam inst "d3") -> d3 in
let if d3 == nil then 22 else d3 -> d3 in
let atoi (getPluginInstanceParam inst "d4") -> d4 in
let if d4 == nil then 25 else d4 -> d4 in
let atoi (getPluginInstanceParam inst "d5") -> d5 in
let if d5 == nil then 8 else d5 -> d5 in
let atoi (getPluginInstanceParam inst "d6") -> d6 in
let if d6 == nil then 7 else d6 -> d6 in
let atoi (getPluginInstanceParam inst "d7") -> d7 in
let if d7 == nil then 10 else d7 -> d7 in
let atoi (getPluginInstanceParam inst "scroll") -> scroll in
let if scroll == nil then 0 else scroll -> scroll in
let atoi (getPluginInstanceParam inst "textalign") -> textalign in
let if textalign == nil then 0 else textalign -> textalign in
let (getPluginInstanceParam inst "text") -> text in
let if text == nil then "" else text -> text in
let atoi (getPluginInstanceParam inst "init") -> init in
let if init == nil then 1 else init -> init in
let 10 -> ypos in
let crEdFrameWindow _channel ewinstr 0 0 iw 370 EDWIN_RESIZE_MW nil (loc "OS3DGPIOLCD_0002") (loc "OS3DGPIOLCD_0001") -> winfrm in
let crEdWindow _channel winfrm 0 18 iw 350 WN_CHILDINSIDE|WN_NOBORDER EDWIN_RESIZE_MW nil nil -> winstr in
let crEdCtrlLabel winstr 10 ypos + 2 160 20 (loc "OS3DGPIOLCD_0003") nil -> labelcols in
let crEdCtrlFloat winstr 180 ypos 110 20 itof cols 0.0 1023.0 1.0 0 nil EDWIN_RESIZE_MW -> ctrlcols in
let crEdCtrlLabel winstr 10 (set ypos = ypos + 25) + 2 160 20 (loc "OS3DGPIOLCD_0004") nil -> labelrows in
let crEdCtrlFloat winstr 180 ypos 110 20 itof rows 0.0 1023.0 1.0 0 nil EDWIN_RESIZE_MW -> ctrlrows in
let crEdCtrlLabel winstr 10 (set ypos = ypos + 25) + 2 160 20 (loc "OS3DGPIOLCD_0005") nil -> labelbits in
let crEdCtrlSelect winstr 180 ypos 200 130 EDWIN_RESIZE_MW -> ctrlbits in
let crEdCtrlLabel winstr 10 (set ypos = ypos + 25) + 2 160 20 (loc "OS3DGPIOLCD_0006") nil -> labeltitle in
let crEdCtrlSelect winstr 180 ypos 200 130 EDWIN_RESIZE_MW -> ctrlpinrs in
let crEdCtrlLabel winstr 10 (set ypos = ypos + 25) + 2 160 20 (loc "OS3DGPIOLCD_0007") nil -> labeltitle in
let crEdCtrlSelect winstr 180 ypos 200 130 EDWIN_RESIZE_MW -> ctrlpinstrb in
let crEdCtrlLabel winstr 10 (set ypos = ypos + 25) + 2 160 20 (loc "OS3DGPIOLCD_0008") nil -> labeltitle in
let crEdCtrlSelect winstr 180 ypos 200 130 EDWIN_RESIZE_MW -> ctrlpin0 in
let crEdCtrlLabel winstr 10 (set ypos = ypos + 25) + 2 160 20 (loc "OS3DGPIOLCD_0009") nil -> labeltitle in
let crEdCtrlSelect winstr 180 ypos 200 130 EDWIN_RESIZE_MW -> ctrlpin1 in
let crEdCtrlLabel winstr 10 (set ypos = ypos + 25) + 2 160 20 (loc "OS3DGPIOLCD_0010") nil -> labeltitle in
let crEdCtrlSelect winstr 180 ypos 200 130 EDWIN_RESIZE_MW -> ctrlpin2 in
let crEdCtrlLabel winstr 10 (set ypos = ypos + 25) + 2 160 20 (loc "OS3DGPIOLCD_0011") nil -> labeltitle in
let crEdCtrlSelect winstr 180 ypos 200 130 EDWIN_RESIZE_MW -> ctrlpin3 in
let crEdCtrlLabel winstr 10 (set ypos = ypos + 25) + 2 160 20 (loc "OS3DGPIOLCD_0012") nil -> labeltitle in
let crEdCtrlSelect winstr 180 ypos 200 130 EDWIN_RESIZE_MW -> ctrlpin4 in
let crEdCtrlLabel winstr 10 (set ypos = ypos + 25) + 2 160 20 (loc "OS3DGPIOLCD_0013") nil -> labeltitle in
let crEdCtrlSelect winstr 180 ypos 200 130 EDWIN_RESIZE_MW -> ctrlpin5 in
let crEdCtrlLabel winstr 10 (set ypos = ypos + 25) + 2 160 20 (loc "OS3DGPIOLCD_0014") nil -> labeltitle in
let crEdCtrlSelect winstr 180 ypos 200 130 EDWIN_RESIZE_MW -> ctrlpin6 in
let crEdCtrlLabel winstr 10 (set ypos = ypos + 25) + 2 160 20 (loc "OS3DGPIOLCD_0015") nil -> labeltitle in
let crEdCtrlSelect winstr 180 ypos 200 130 EDWIN_RESIZE_MW -> ctrlpin7 in
let crEdFrameWindow _channel ewinstr 0 0 iw 160 EDWIN_RESIZE_MW nil (loc "OS3DGPIOLCD_0016") (loc "OS3DGPIOLCD_0001") -> winfrm in
let crEdWindow _channel winfrm 0 18 iw 140 WN_CHILDINSIDE|WN_NOBORDER EDWIN_RESIZE_MW nil nil -> winstr in
let crEdCtrlLabel winstr 10 (set ypos = 10) + 2 160 20 (loc "OS3DGPIOLCD_0018") nil -> labeltextalign in
let crEdCtrlSelect winstr 180 ypos 200 130 EDWIN_RESIZE_MW -> ctrlalign in
let crEdCtrlLabel winstr 10 (set ypos = ypos + 25) + 2 160 20 (loc "OS3DGPIOLCD_0017") nil -> labeltext in
let crEdCtrlEditText winstr 180 ypos + 2 (iw - 180) 50 text ET_AVSCROLL|ET_VSCROLL|ET_ALIGN_LEFT|ET_BORDER EDWIN_RESIZE_MW -> ctrltext in
let crEdCtrlLabel winstr 10 (set ypos = ypos + 60) + 2 160 20 (loc "OS3DGPIOLCD_0019") nil -> labelscroll in
let crEdCtrlFloat winstr 180 ypos 110 20 itof scroll 0.0 100.0 1.0 0 nil EDWIN_RESIZE_MW -> ctrlscroll in
let crEdCtrlCheck winstr 10 (set ypos = ypos + 25) 280 20 (loc "OS3DGPIOLCD_0020") EDWIN_RESIZE_MW -> ctrlenable in
(
fillPinSelector ctrlpinrs rs;
fillPinSelector ctrlpinstrb strb;
fillPinSelector ctrlpin0 d0;
fillPinSelector ctrlpin1 d1;
fillPinSelector ctrlpin2 d2;
fillPinSelector ctrlpin3 d3;
fillPinSelector ctrlpin4 d4;
fillPinSelector ctrlpin5 d5;
fillPinSelector ctrlpin6 d6;
fillPinSelector ctrlpin7 d7;
fillEdCtrlSelect ctrlbits "4"::"8"::nil;
selectEdCtrlSelect ctrlbits itoa bits;
setEdCtrlSelectCb ctrlbits mkfun4 @cbSelectMode [ctrlpin4 ctrlpin5 ctrlpin6 ctrlpin7];
if (bits == 4) then
(
setEdCtrlSelectEnable ctrlpin4 0;
setEdCtrlSelectEnable ctrlpin5 0;
setEdCtrlSelectEnable ctrlpin6 0;
setEdCtrlSelectEnable ctrlpin7 0;
)
else
(
setEdCtrlSelectEnable ctrlpin4 1;
setEdCtrlSelectEnable ctrlpin5 2;
setEdCtrlSelectEnable ctrlpin6 3;
setEdCtrlSelectEnable ctrlpin7 4;
);
fillEdCtrlSelect ctrlalign "Left"::"Center"::"Right"::nil;
selectEdCtrlSelectByPos ctrlalign textalign;
setEdCtrlCheckState ctrlenable init;
[mkfun1 @cbCloseEdit [ctrlcols ctrlrows ctrlbits ctrlpinrs ctrlpinstrb ctrlpin0 ctrlpin1 ctrlpin2 ctrlpin3 ctrlpin4 ctrlpin5 ctrlpin6 ctrlpin7 ctrlalign ctrltext ctrlscroll ctrlenable] nil];
);
);;