/* ----------------------------------------------------------------------------- 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 ----------------------------------------------------------------------------- */ struct EArrayStr = [ EARR_values : [[S r1] r1], EARR_data : S ] MkEArrayStr;; fun cbDestroyEdit()= 0;; fun cbCloseEdit(p)= let p -> [ctrltype ctrlrows ctrlcols earrstr] in let ftoi getEdCtrlFloatValue ctrlrows -> nbrows in let ftoi getEdCtrlFloatValue ctrlcols -> nbcols in let getSelectedEdCtrlSelect ctrltype -> type in ["value" earrstr.EARR_data]:: ["nbrows" itoa nbrows]:: ["nbcols" itoa nbcols]:: ["type" type]:: nil;; fun cbCloseArray(winstr, p)= let p -> [letxt earrstr] in ( set earrstr.EARR_values = nil; while (letxt != nil) do ( let nil -> line in ( let hd letxt -> lvalues in while (lvalues != nil) do ( let getEdCtrlEditTextValue (hd lvalues) -> value in set line = value::line; set lvalues = tl lvalues; ); set earrstr.EARR_values = line::earrstr.EARR_values; ); set letxt = tl letxt; ); set earrstr.EARR_data = formatCSV nil nil earrstr.EARR_values; ); dsEdWindow winstr; 0;; fun drawcells(fatherstr, nbcols, nbrows, earrstr)= let 120 -> celw in let 60 -> celh in let 10 -> margin in let nbcols * celw + (nbcols * margin) -> lw in let nbrows * celh + (nbrows * margin) -> lh in let _GETscreenSize -> [sw sh] in let [(if (lw > sw) then sw - 100 else lw + 20) (if (lh > sh) then sh - 100 else lh + 20)] -> [iw ih] in let [((sw / 2) - (iw / 2)) ((sh / 2) - (ih / 2)) - 40] -> [x y] in let crEdModalDialogWindow _channel fatherstr x y iw ih WN_NOSCOL|WN_MENU|WN_SIZEBOX nil "Values" -> popstr in let crEdScrollWindow _channel popstr 0 0 iw ih WN_CHILDINSIDE|WN_VSCROLL|WN_HSCROLL EDWIN_RESIZE_MW|EDWIN_RESIZE_MH nil nil -> winscrl in let crEdWindow _channel winscrl 0 0 lw lh WN_CHILDINSIDE|WN_NOBORDER nil nil nil -> winstr in let nil -> letxt in ( let 0 -> i in let margin -> ypos in while (i < nbrows) do ( let 0 -> j in let margin -> xpos in let nil -> lrows in let nth_list earrstr.EARR_values i -> lineval in ( while (j < nbcols) do ( set lrows = (crEdCtrlEditText winstr xpos ypos celw celh (nth_list lineval j) nil nil)::lrows; set xpos = xpos + celw + margin; set j = j + 1; ); set letxt = lrows::letxt; ); set ypos = ypos + celh + margin; set i = i + 1; ); setEdwindowCbClose popstr mkfun2 @cbCloseArray [letxt earrstr]; ); 0;; fun cbBtnEditValues(ctrlbtn, p)= let p -> [inst ewinstr ctrlrows ctrlcols earrstr] in let ftoi getEdCtrlFloatValue ctrlrows -> nbrows in let ftoi getEdCtrlFloatValue ctrlcols -> nbcols in drawcells ewinstr nbcols nbrows earrstr; 0;; fun dynamicedit(ewinstr, inst, viewstr, applybtn)= let [420 180] -> [iw ih] in let 10 -> ypos in ( setEdWindowSize ewinstr iw ih; let (getPluginInstanceParam inst "type") -> type in let if type == nil then "String" else type -> type in let atoi (getPluginInstanceParam inst "nbrows") -> nbrows in let if (nbrows == nil) then 5 else nbrows -> nbrows in let atoi (getPluginInstanceParam inst "nbcols") -> nbcols in let if (nbcols == nil) then 5 else nbcols -> nbcols in let (getPluginInstanceParam inst "value") -> value in let if value == nil then nil else value -> value in let crEdFrameWindow _channel ewinstr 0 0 iw 105 EDWIN_RESIZE_MW nil (loc "OS3DARRAY_0002") (loc "OS3DARRAY_0001") -> winfrm in let crEdWindow _channel winfrm 0 18 iw 85 WN_CHILDINSIDE|WN_NOBORDER EDWIN_RESIZE_MW nil nil -> winstr in let crEdCtrlLabel winstr 10 ((set ypos = 10) + 2) 160 20 (loc "OS3DARRAY_0003") nil -> labeltype in let crEdCtrlSelect winstr 180 ypos 200 120 EDWIN_RESIZE_MW -> ctrltype in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 170 20 (loc "OS3DARRAY_0004") nil -> labelrows in let crEdCtrlFloat winstr 180 ypos 100 20 (itof nbrows) 1.0 20.0 1.0 0 nil EDWIN_RESIZE_MW -> ctrlrows in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 170 20 (loc "OS3DARRAY_0005") nil -> labelcols in let crEdCtrlFloat winstr 180 ypos 100 20 (itof nbcols) 1.0 20.0 1.0 0 nil EDWIN_RESIZE_MW -> ctrlcols in let crEdFrameWindow _channel ewinstr 0 0 iw 70 EDWIN_RESIZE_MW nil (loc "OS3DARRAY_0006") (loc "OS3DARRAY_0001") -> winfrm in let crEdWindow _channel winfrm 0 18 iw 50 WN_CHILDINSIDE|WN_NOBORDER EDWIN_RESIZE_MW nil nil -> winstr in let crEdCtrlButton winstr ((iw / 2) - 80) (set ypos = 10) 160 20 (loc "OS3DARRAY_0007") nil -> editbtn in let MkEArrayStr [(readCSVdata value nil) value] -> earrstr in ( fillEdCtrlSelect ctrltype "String"::"Hexa"::"Int"::"Float"::nil; selectEdCtrlSelect ctrltype type; setEdCtrlButtonCb editbtn mkfun2 @cbBtnEditValues [inst ewinstr ctrlrows ctrlcols earrstr]; [(mkfun1 @cbCloseEdit [ctrltype ctrlrows ctrlcols earrstr]) @cbDestroyEdit]; ); );;