/* ----------------------------------------------------------------------------- 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 ----------------------------------------------------------------------------- */ var sConfigPath = "tmp/config/";; fun getEvents(l)= let sizelist l -> size in let nil -> ndata in let 0 -> i in ( while i < size do ( let nth_list l i -> elem in set ndata = ["EVENT" strcat elem " value"]::ndata; set i = i + 1; ); ndata; );; fun getActions(l)= let sizelist l -> size in let nil -> ndata in let 0 -> i in ( while i < size do ( let nth_list l i -> elem in ( set ndata = ["ACTION" strcat "Set " elem]::ndata; set ndata = ["ACTION" strcat "Get " elem]::ndata; set ndata = ["ACTION" strcat "Increment " elem]::ndata; set ndata = ["ACTION" strcat "Decrement " elem]::ndata; ); set i = i + 1; ); ndata; );; fun cbCloseEdit(p)= let p -> [inst xmldata ctrlevent ctrlload] in ( //remove previous saved config file since the var list can be changed _deletepack _checkpack strcatn sConfigPath::(getPluginInstanceName inst)::".conf"::nil; let getEdCtrlListElems ctrlevent -> levent in let getEdCtrlCheckState ctrlload -> loadonstart in ["xmldata" (strtoweb XMLserialize xmldata)]:: ["loadonstart" (itoa loadonstart)]:: (lcat (getEvents levent) (getActions levent)); );; fun cbValueChanged(ctrlstr, val, varmark)= XMLsetData varmark val; 0;; fun cbAddActEvnt(ctrlstr, value, p)= let p -> [xmldata liststr ctrladdevent ctrlvalue fathermark] in if (value == nil) || (!strcmp "" strtrim value) then nil else let getEdCtrlListElems liststr -> lelem in if (isStringInListi lelem value) then nil else ( setEdCtrlEditTextValue ctrlvalue ""; XMLaddMark xmldata "var" fathermark ["name" (strtrim value)]::nil nil; addEdCtrlList liststr value nil nil; setEdCtrlTextLineValue ctrlstr nil; selectEdCtrlListByPos liststr ((getEdCtrlListNbElems liststr) - 1); let getSelectedEdCtrlList liststr -> [elem _ _] in let XMLgetMarkByValueAndParamValueFromMark fathermark "var" "name" elem -> varmark in ( setEdCtrlEditTextValue ctrlvalue XMLgetData varmark; setEdCtrlEditTextCbChange ctrlvalue mkfun3 @cbValueChanged varmark; ); ); 0;; fun cbAddList(ctrlstr, p)= let p -> [xmldata liststr ctrladdevent ctrlvalue fathermark] in let getEdCtrlTextLineValue ctrladdevent -> value in if (value == nil) || (!strcmp "" strtrim value) then nil else let getEdCtrlListElems liststr -> lelem in if (isStringInListi lelem value) then nil else ( setEdCtrlEditTextValue ctrlvalue ""; XMLaddMark xmldata "var" fathermark ["name" (strtrim value)]::nil nil; addEdCtrlList liststr value nil nil; setEdCtrlTextLineValue ctrladdevent nil; selectEdCtrlListByPos liststr ((getEdCtrlListNbElems liststr) - 1); let getSelectedEdCtrlList liststr -> [elem _ _] in let XMLgetMarkByValueAndParamValueFromMark fathermark "var" "name" elem -> varmark in ( setEdCtrlEditTextValue ctrlvalue XMLgetData varmark; setEdCtrlEditTextCbChange ctrlvalue mkfun3 @cbValueChanged varmark; ); ); 0;; fun cbDelList(ctrlstr, p)= let p -> [xmldata liststr ctrladdevent ctrlvalue fathermark] in let getSelectedEdCtrlList liststr -> [name _ _] in let XMLgetMarkByValueAndParamValueFromMark fathermark "var" "name" name -> varmark in ( setEdCtrlEditTextValue ctrlvalue ""; XMLdelMark xmldata varmark; delEdCtrlList liststr name; selectEdCtrlListByPos liststr ((getEdCtrlListNbElems liststr) - 1); let getSelectedEdCtrlList liststr -> [elem _ _] in let XMLgetMarkByValueAndParamValueFromMark fathermark "var" "name" elem -> varmark in ( setEdCtrlEditTextValue ctrlvalue XMLgetData varmark; setEdCtrlEditTextCbChange ctrlvalue mkfun3 @cbValueChanged varmark; ); ); 0;; fun cbClickevent(ctrlstr, pos, elem, lval, type, p) = let p -> [xmldata liststr ctrladdevent ctrlvalue fathermark] in if elem == nil then ( setEdCtrlEditTextValue ctrlvalue ""; 0; ) else ( if ((elem == nil) || (!strcmp "" (strtrim elem))) then nil else ( let XMLgetMarkByValueAndParamValueFromMark fathermark "var" "name" elem -> varmark in ( setEdCtrlEditTextValue ctrlvalue XMLgetData varmark; setEdCtrlEditTextCbChange ctrlvalue mkfun3 @cbValueChanged varmark; ); ); 0; ); 0;; fun dynamicedit(winstr, inst, viewstr, applybtn)= let [400 150] -> [iw ih] in let 0 -> ypos in ( setEdWindowSize winstr iw ih; let XMLloadString webtostr (getPluginInstanceParam inst "xmldata") -> xmldata in let if xmldata == nil then XMLcreate nil nil else xmldata -> xmldata in let if (XMLgetMarkByValue xmldata "config") == nil then (XMLaddMark xmldata "config" nil nil nil) else (XMLgetMarkByValue xmldata "config") -> configmark in let XMLgetMarksParamByValueFromMarkSons configmark "var" "name" -> levent in let atoi (getPluginInstanceParam inst "loadonstart") -> loadonstart in let if loadonstart == nil then 1 else loadonstart -> loadonstart in let crEdCtrlLabel winstr 10 (set ypos = 10) ((iw / 2) - 20) 20 (loc "OS3DCONFIGFILE_0007") nil -> varlabel in let crEdCtrlLabel winstr (iw / 2) ypos ((iw / 2) - 10) 20 (loc "OS3DCONFIGFILE_0001") nil -> valuelabel in let crEdCtrlList winstr 10 (set ypos = ypos + 25) ((iw / 2) - 20) 60 LB_BORDER|LB_VSCROLL|ET_TABFOCUS EDWIN_RESIZE_MW|EDWIN_RESIZE_MH -> ctrlevent in let crEdCtrlEditText winstr (iw / 2) ypos ((iw / 2) - 10) 60 nil nil EDWIN_RESIZE_MW -> ctrlvalue in let crEdCtrlTextLine winstr 10 (set ypos = ypos + 65) (iw - 70) 20 nil nil EDWIN_RESIZE_MW -> ctrladdevent in let crEdCtrlButton winstr (iw - 55) ypos 20 20 "+" EDWIN_RESIZE_MW -> ctrlbtnadd1 in let crEdCtrlButton winstr (iw - 30) ypos 20 20 "-" EDWIN_RESIZE_MW -> ctrlbtndel1 in let crEdCtrlCheck winstr 10 (set ypos = ypos + 25) 300 20 (loc "OS3DCONFIGFILE_0004") EDWIN_RESIZE_MW -> ctrlload in let [xmldata ctrlevent ctrladdevent ctrlvalue configmark] -> p in ( setEdCtrlButtonCb ctrlbtnadd1 mkfun2 @cbAddList p; setEdCtrlButtonCb ctrlbtndel1 mkfun2 @cbDelList p; setEdCtrlTextLineCbValidate ctrladdevent mkfun3 @cbAddActEvnt p; setEdCtrlCheckState ctrlload loadonstart; fillEdCtrlList ctrlevent levent; let getSelectedEdCtrlList ctrlevent -> [name _ _] in if name == nil then nil else cbClickevent ctrlevent 0 name nil nil p; setEdCtrlListCbClick ctrlevent mkfun6 @cbClickevent p; [mkfun1 @cbCloseEdit [inst xmldata ctrlevent ctrlload] nil]; ); );;