/* ----------------------------------------------------------------------------- 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 ----------------------------------------------------------------------------- */ 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" elem]::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" elem]::ndata; set i = i + 1; ); ndata; );; fun cbCloseEdit(p)= let p -> [ctrlport ctrlwww ctrlaction ctrlevent] in let ftoi (getEdCtrlFloatValue ctrlport) -> port in let getEdCtrlTextLineValue ctrlwww -> www in let getEdCtrlListElems ctrlaction -> laction in let getEdCtrlListElems ctrlevent -> levent in ["port" itoa port]:: ["www" www]:: (lcat (getEvents levent) (getActions laction));; fun cbAddActEvnt(ctrlstr, value, liststr)= if (value == nil) || (!strcmp "" strtrim value) then nil else let getEdCtrlListElems liststr -> lelem in if (isStringInListi lelem value) then nil else ( addEdCtrlList liststr value nil nil; setEdCtrlTextLineValue ctrlstr nil; ); 0;; fun cbAddList(ctrlstr, p)= let p -> [liststr textstr] in let getEdCtrlTextLineValue textstr -> value in if (value == nil) || (!strcmp "" strtrim value) then nil else let getEdCtrlListElems liststr -> lelem in if (isStringInListi lelem value) then nil else ( addEdCtrlList liststr value nil nil; setEdCtrlTextLineValue textstr nil; ); 0;; fun cbDelList(ctrlstr, p)= let p -> [liststr textstr] in let getSelectedEdCtrlList liststr -> [name _ _] in delEdCtrlList liststr name; 0;; fun cbOpenDirectory(opendir, p, path)= let p -> [inst winstr ctrlwww] in if path == nil then nil else { // Set directory setEdCtrlTextLineValue ctrlwww path; }; 0;; fun cbBtnPickDir(ctrlstr, p)= let p -> [inst winstr ctrlwww] in _DLGrflopenDir _DLGOpenDir _channel winstr.EDW_win nil (loc "OS3DWEBCONTROL_0010") @cbOpenDirectory p; 0;; fun cbRefreshBtn(pickbtn, ctrlwww)= setEdCtrlTextLineValue ctrlwww ""; 0;; fun dynamicedit(ewinstr, inst, viewstr, applybtn)= let [400 230] -> [iw ih] in let 10 -> ypos in ( setEdWindowSize ewinstr iw ih; let getPluginInstanceUserActions inst -> laction in let getPluginInstanceUserEvents inst -> levent in let atof (getPluginInstanceParam inst "port") -> port in let if port == nil then 1205.0 else port -> port in let (getPluginInstanceParam inst "www") -> www in let crEdFrameWindow _channel ewinstr 0 0 iw 75 EDWIN_RESIZE_MW nil (loc "OS3DWEBCONTROL_0012") (loc "OS3DWEBCONTROL_0008") -> winfrm in let crEdWindow _channel winfrm 0 18 iw 55 WN_CHILDINSIDE|WN_NOBORDER EDWIN_RESIZE_MW nil nil -> winstr in let crEdCtrlLabel winstr 10 (ypos + 2) 170 20 (loc "OS3DWEBCONTROL_0011") nil -> labelport in let crEdCtrlFloat winstr 190 ypos 100 20 port 1.0 65535.0 1.0 0 nil EDWIN_RESIZE_MW -> ctrlport in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 170 20 (loc "OS3DWEBCONTROL_0009") nil -> labelwww in let crEdCtrlTextLine winstr 190 ypos (iw - 290) 20 www nil EDWIN_RESIZE_MW -> ctrlwww in let crEdCtrlButton winstr (iw - 95) ypos 55 20 "..." nil -> dirbtn in let crEdCtrlButton winstr (iw - 35) ypos 35 20 "X" nil -> refreshdirname in let crEdFrameWindow _channel ewinstr 0 0 iw 155 EDWIN_RESIZE_MW nil (loc "OS3DWEBCONTROL_0005") (loc "OS3DWEBCONTROL_0008") -> winfrm in let crEdWindow _channel winfrm 0 18 iw 135 WN_CHILDINSIDE|WN_NOBORDER EDWIN_RESIZE_MW nil nil -> winstr in let crEdCtrlLabel winstr 10 ((set ypos = 10) + 2) (iw / 2 - 20) 20 (loc "OS3DWEBCONTROL_0007") nil -> labelc1 in let crEdCtrlLabel winstr (iw / 2) + 10 ypos (iw / 2 - 20) 20 (loc "OS3DWEBCONTROL_0006") nil -> labelc2 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 -> ctrlaction in let crEdCtrlList winstr (iw / 2) + 10 ypos (iw / 2 - 20) 60 LB_BORDER|LB_VSCROLL|ET_TABFOCUS EDWIN_RESIZE_MW|EDWIN_RESIZE_MH -> ctrlevent in let crEdCtrlTextLine winstr 10 (set ypos = ypos + 65) (iw / 2 - 70) 20 nil nil EDWIN_RESIZE_MW -> ctrladdaction in let crEdCtrlTextLine winstr (iw / 2) + 10 ypos (iw / 2 - 70) 20 nil nil EDWIN_RESIZE_MW -> ctrladdevent in let crEdCtrlButton winstr (iw / 2 - 55) ypos 20 20 "+" EDWIN_RESIZE_MW -> ctrlbtnadd1 in let crEdCtrlButton winstr (iw / 2 - 30) ypos 20 20 "-" EDWIN_RESIZE_MW -> ctrlbtndel1 in let crEdCtrlButton winstr (iw / 2) + 10 + (iw / 2 - 65) ypos 20 20 "+" EDWIN_RESIZE_MW -> ctrlbtnadd2 in let crEdCtrlButton winstr (iw / 2) + 10 + (iw / 2 - 40) ypos 20 20 "-" EDWIN_RESIZE_MW -> ctrlbtndel2 in ( fillEdCtrlList ctrlaction laction; fillEdCtrlList ctrlevent levent; setEdCtrlButtonCb dirbtn mkfun2 @cbBtnPickDir [inst winstr ctrlwww]; setEdCtrlTextLineEnable ctrlwww 0; setEdCtrlButtonCb refreshdirname mkfun2 @cbRefreshBtn ctrlwww; setEdCtrlButtonCb ctrlbtnadd1 mkfun2 @cbAddList [ctrlaction ctrladdaction]; setEdCtrlButtonCb ctrlbtnadd2 mkfun2 @cbAddList [ctrlevent ctrladdevent]; setEdCtrlButtonCb ctrlbtndel1 mkfun2 @cbDelList [ctrlaction ctrladdaction]; setEdCtrlButtonCb ctrlbtndel2 mkfun2 @cbDelList [ctrlevent ctrladdevent]; setEdCtrlTextLineCbValidate ctrladdaction mkfun3 @cbAddActEvnt ctrlaction; setEdCtrlTextLineCbValidate ctrladdevent mkfun3 @cbAddActEvnt ctrlevent; [mkfun1 @cbCloseEdit [ctrlport ctrlwww ctrlaction ctrlevent] nil]; ); );;