/* ----------------------------------------------------------------------------- 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 ETableStr = [ ETB_values : [[S r1] r1], ETB_cwidths : [S r1], ETB_data : S ]mkETableStr;; fun cbCloseEdit(p)= let p -> [edstr posstr ctrlnbrow ctrlnbcol ctrlcellxmargin ctrlcellymargin ctrltexthalign ctrltextvalign ctrlusetheme theltselector ctrlccolor ctrlborder ctrlbcolor ctrlfname ctrlfsize ctrlfcolor ctrlshow] in let ftoi getEdCtrlFloatValue ctrlnbrow -> nbrow in let ftoi getEdCtrlFloatValue ctrlnbcol -> nbcol in let ftoi getEdCtrlFloatValue ctrlcellxmargin -> xmargin in let ftoi getEdCtrlFloatValue ctrlcellymargin -> ymargin in let getSelectedEdCtrlSelectPos ctrltexthalign -> texthalign in let getSelectedEdCtrlSelectPos ctrltextvalign -> textvalign in let getEdCtrlCheckState ctrlusetheme -> usetheme in let getEdCtrlColorButtonColor ctrlccolor -> ccolor in let ftoi getEdCtrlFloatValue ctrlborder -> border in let getEdCtrlColorButtonColor ctrlbcolor -> bcolor in let getEdCtrlTextLineValue ctrlfname -> fontname in let ftoi getEdCtrlFloatValue ctrlfsize -> fontsize in let getEdCtrlColorButtonColor ctrlfcolor -> fontcolor in let getThemeEltSelectorSave theltselector -> thdefsave in let getEdCtrlCheckState ctrlshow -> show in let strcatnSep edstr.ETB_cwidths ";" -> colwidths in let getInterfaceSaveData posstr -> possave in ["nbrow" itoa nbrow]:: ["nbcol" itoa nbcol]:: ["xmargin" itoa xmargin]:: ["ymargin" itoa ymargin]:: ["texthalign" itoa texthalign]:: ["textvalign" itoa textvalign]:: ["usetheme" itoa usetheme]:: ["ccolor" itoa ccolor]:: ["border" itoa border]:: ["bcolor" itoa bcolor]:: ["fontname" fontname]:: ["fontsize" itoa fontsize]:: ["fontcolor" itoa fontcolor]:: ["show" itoa show]:: ["value" edstr.ETB_data]:: ["colwidths" colwidths]:: (lcat thdefsave possave);; fun cbCloseArray(winstr, p)= let p -> [lwidths letxt edstr] in ( set edstr.ETB_cwidths = nil; while (lwidths != nil) do ( let itoa (ftoi getEdCtrlFloatValue (hd lwidths)) -> width in set edstr.ETB_cwidths = width::edstr.ETB_cwidths; set lwidths = tl lwidths; ); set edstr.ETB_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 edstr.ETB_values = line::edstr.ETB_values; ); set letxt = tl letxt; ); set edstr.ETB_data = formatCSV nil nil edstr.ETB_values; ); dsEdWindow winstr; 0;; fun drawcells(fatherstr, nbcols, nbrows, edstr)= let 120 -> celw in let 60 -> celh in let 10 -> margin in let nbcols * celw + (nbcols * margin) -> lw in let 85 + nbrows * celh + (nbrows * margin) -> lh in let _GETscreenSize -> [sw sh] in let [(if (lw > (sw - 100)) then sw - 100 else lw + 20) (if ((lh + 28) > (sh - 100)) then sh - 100 else lh + 28 + 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 (loc "OS3DTABLE_0015") -> popstr in let crEdWindowToolBar popstr 0 0 iw 28 5 1 EdDefaultTheme.EDT_iToolBarColor ETB_HORIZONTAL -> tbstr in let crEdScrollWindow _channel popstr 0 28 iw (ih - 28) 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 crEdCtrlLabel winstr 10 12 (lw - 20) 20 (loc "OS3DTABLE_0016") nil -> labelcolwidths in let crEdCtrlLabel winstr 10 72 (lw - 20) 20 (loc "OS3DTABLE_0017") nil -> labelcellvalues in let nil -> lwidths in let nil -> letxt in ( let 0 -> i in let margin + 85 -> ypos in while (i < nbrows) do ( let 0 -> j in let margin -> xpos in let nil -> lrows in let nth_list edstr.ETB_values i -> lineval in ( while (j < nbcols) do ( if (i != 0) then nil else set lwidths = (crEdCtrlFloat winstr (xpos + 20) 35 80 20 (atof (nth_list edstr.ETB_cwidths j)) 1.0 10000.0 1.0 0 nil EDWIN_RESIZE_MW)::lwidths; set lrows = (crEdCtrlEditText winstr xpos ypos celw celh (webtostr (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 [lwidths letxt edstr]; ); 0;; fun cbBtnEditValues(ctrlbtn, p)= let p -> [inst ewinstr ctrlnbrow ctrlnbcol edstr] in let ftoi getEdCtrlFloatValue ctrlnbrow -> nbrows in let ftoi getEdCtrlFloatValue ctrlnbcol -> nbcols in drawcells ewinstr nbcols nbrows edstr; 0;; /*fun cbCheckUseTheme(ctrlstr, state, p)= let p -> [theltselector ctrlccolor ctrlborder ctrlbcolor ctrlfname ctrlfsize ctrlfcolor] in ( setThemeEltSelectorEnable theltselector state; setEdCtrlColorButtonEnable ctrlccolor !state; setEdCtrlFloatEnable ctrlborder !state; setEdCtrlColorButtonEnable ctrlbcolor !state; setEdCtrlTextLineEnable ctrlfname !state; setEdCtrlFloatEnable ctrlfsize !state; setEdCtrlColorButtonEnable ctrlfcolor !state; ); 0;;*/ fun cbCheckUseTheme(ctrlstr, state, p)= let p -> [ewinstr themewinfrm lookswinstr] in ( if state then ( let _GETwindowPositionSize ewinstr.EDW_win -> [_ _ w h] in setEdWindowSize ewinstr w (h - 125); let _GETwindowPositionSize themewinfrm.EDW_win -> [_ _ w h] in setEdWindowSize themewinfrm w (h - 125); ) else ( let _GETwindowPositionSize ewinstr.EDW_win -> [_ _ w h] in setEdWindowSize ewinstr w (h + 125); let _GETwindowPositionSize themewinfrm.EDW_win -> [_ _ w h] in setEdWindowSize themewinfrm w (h + 125); ); setEdWindowVisible lookswinstr !state; ); 0;; fun dynamicedit(ewinstr, inst, viewstr, applybtn)= let [455 300] -> [iw ih] in let 10 -> ypos in ( setEdWindowSize ewinstr iw ih; let atoi (getPluginInstanceParam inst "nbrow") -> nbrow in let if (nbrow == nil) then 3 else nbrow -> nbrow in let atoi (getPluginInstanceParam inst "nbcol") -> nbcol in let if (nbcol == nil) then 4 else nbcol -> nbcol in let atoi (getPluginInstanceParam inst "xmargin") -> xmargin in let if (xmargin == nil) then 5 else xmargin -> xmargin in let atoi (getPluginInstanceParam inst "ymargin") -> ymargin in let if (ymargin == nil) then 5 else ymargin -> ymargin in let atoi (getPluginInstanceParam inst "texthalign") -> texthalign in let if (texthalign == nil) then 1 else texthalign -> texthalign in let atoi (getPluginInstanceParam inst "textvalign") -> textvalign in let if (textvalign == nil) then 1 else textvalign -> textvalign in let atoi (getPluginInstanceParam inst "usetheme") -> usetheme in let if (usetheme == nil) then 0 else usetheme -> usetheme in let atoi (getPluginInstanceParam inst "ccolor") -> ccolor in let if (ccolor == nil) then 0xffffffff else ccolor -> ccolor in let atoi (getPluginInstanceParam inst "border") -> border in let if (border == nil) then 1 else border -> border in let atoi (getPluginInstanceParam inst "bcolor") -> bcolor in let if (bcolor == nil) then 0x000000ff else bcolor -> bcolor in let getPluginInstanceParam inst "fontname" -> fontname in let if (fontname == nil) then "Sans" else fontname -> fontname in let atoi (getPluginInstanceParam inst "fontsize") -> fontsize in let if (fontsize == nil) then 10 else fontsize -> fontsize in let atoi (getPluginInstanceParam inst "fontcolor") -> fontcolor in let if (fontcolor == nil) then 0x000000 else fontcolor -> fontcolor in let atoi (getPluginInstanceParam inst "show") -> show in let if (show == nil) then 1 else show -> show in let (getPluginInstanceParam inst "colwidths") -> colwidths in let if colwidths == nil then nil else colwidths -> colwidths in let (getPluginInstanceParam inst "value") -> value in let if value == nil then nil else value -> value in let crPositionInterface inst viewstr ewinstr nil (iPOS_INTERFACE_2D_NO_BACKGROUND_NO_KEEPRATIO | iPOS_INTERFACE_MAT | iPOS_INTERFACE_3D | iPOS_INTERFACE_VR) iw ih -> posstr in let crEdFrameWindow _channel ewinstr 0 0 iw 190 EDWIN_RESIZE_MW nil (loc "OS3DTABLE_0007") (loc "OS3DTABLE_0005") -> winfrm in let crEdWindow _channel winfrm 0 18 iw 170 WN_CHILDINSIDE|WN_NOBORDER EDWIN_RESIZE_MW nil nil -> winstr in let crEdCtrlLabel winstr 10 ((set ypos = 10) + 2) 160 20 (loc "OS3DTABLE_0002") nil -> labelnbrow in let crEdCtrlFloat winstr 180 ypos 60 20 (itof nbrow) 1.0 20.0 1.0 0 nil EDWIN_RESIZE_MW -> ctrlnbrow in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 160 20 (loc "OS3DTABLE_0003") nil -> labelnbcol in let crEdCtrlFloat winstr 180 ypos 60 20 (itof nbcol) 1.0 20.0 1.0 0 nil EDWIN_RESIZE_MW -> ctrlnbcol in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 160 20 (loc "OS3DTABLE_0014") nil -> labelcellmargins in let crEdCtrlFloat winstr 180 ypos 60 20 (itof xmargin) 0.0 10000.0 1.0 0 nil EDWIN_RESIZE_MW -> ctrlcellxmargin in let crEdCtrlFloat winstr 250 ypos 60 20 (itof ymargin) 0.0 10000.0 1.0 0 nil EDWIN_RESIZE_MW -> ctrlcellymargin in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 160 20 (loc "OS3DTABLE_0023") nil -> labeltexthalign in let crEdCtrlSelect winstr 180 ypos 100 80 EDWIN_RESIZE_MW -> ctrltexthalign in let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 160 20 (loc "OS3DTABLE_0024") nil -> labeltextvalign in let crEdCtrlSelect winstr 180 ypos 100 80 EDWIN_RESIZE_MW -> ctrltextvalign in let crEdCtrlButton winstr ((iw / 2) - 80) (set ypos = ypos + 35) 160 20 (loc "OS3DTABLE_0015") nil -> editbtn in let crEdFrameWindow _channel ewinstr 0 0 iw (55 + (if usetheme then 0 else 125)) EDWIN_RESIZE_MW nil (loc "OS3DTABLE_0008") (loc "OS3DTABLE_0005") -> themewinfrm in let crEdWindow _channel themewinfrm 0 18 iw 35 WN_CHILDINSIDE|WN_NOBORDER EDWIN_RESIZE_MW nil nil -> themewinstr in let crEdCtrlCheck themewinstr 10 (set ypos = 10) 280 20 (loc "OS3DTABLE_0025") EDWIN_RESIZE_MW -> ctrlusetheme in let crIntegratedThemeEltSelector inst themewinstr ewinstr::themewinfrm::themewinstr::nil "common/tableCell"::nil (set ypos = ypos + 25) iw -> [th theltselector] in let crEdWindow _channel themewinfrm 0 53 iw 150 WN_CHILDINSIDE|WN_NOBORDER EDWIN_RESIZE_MW nil nil -> lookswinstr in let crEdCtrlLabel lookswinstr 10 ((set ypos = 0) + 2) 160 20 (loc "OS3DTABLE_0018") nil -> labelccolor in let crEdCtrlColorButton lookswinstr 180 ypos 100 20 ccolor 1 EDWIN_RESIZE_MW nil -> ctrlccolor in let crEdCtrlLabel lookswinstr 10 ((set ypos = ypos + 25) + 2) 160 20 (loc "OS3DTABLE_0004") nil -> labelborder in let crEdCtrlFloat lookswinstr 180 ypos 60 20 (itof border) 0.0 10000.0 1.0 0 nil EDWIN_RESIZE_MW -> ctrlborder in let crEdCtrlLabel lookswinstr 10 ((set ypos = ypos + 25) + 2) 160 20 (loc "OS3DTABLE_0019") nil -> labelbcolor in let crEdCtrlColorButton lookswinstr 180 ypos 100 20 bcolor 1 EDWIN_RESIZE_MW nil -> ctrlbcolor in let crEdCtrlLabel lookswinstr 10 ((set ypos = ypos + 25) + 2) 160 20 (loc "OS3DTABLE_0020") nil -> labelfname in let crEdCtrlTextLine lookswinstr 180 ypos 170 20 fontname nil EDWIN_RESIZE_MW -> ctrlfname in let crEdCtrlLabel lookswinstr 10 ((set ypos = ypos + 25) + 2) 160 20 (loc "OS3DTABLE_0021") nil -> labelfsize in let crEdCtrlFloat lookswinstr 180 ypos 60 20 (itof fontsize) 1.0 1024.0 1.0 0 nil EDWIN_RESIZE_MW -> ctrlfsize in let crEdCtrlLabel lookswinstr 10 ((set ypos = ypos + 25) + 2) 160 20 (loc "OS3DTABLE_0022") nil -> labelfcolor in let crEdCtrlColorButton lookswinstr 180 ypos 100 20 fontcolor 0 EDWIN_RESIZE_MW nil -> ctrlfcolor in //let crThemeEltSelector inst ewinstr nil "table"::nil iw ih -> theltselector in let crEdFrameWindow _channel ewinstr 0 0 iw 55 EDWIN_RESIZE_MW nil (loc "OS3DTABLE_0006") (loc "OS3DTABLE_0005") -> winfrm in let crEdWindow _channel winfrm 0 18 iw 35 WN_CHILDINSIDE|WN_NOBORDER EDWIN_RESIZE_MW nil nil -> winstr in let crEdCtrlCheck winstr 10 (set ypos = 10) 280 20 (loc "OS3DTABLE_0001") EDWIN_RESIZE_MW -> ctrlshow in let mkETableStr [(readCSVdata value nil) (strToListSep colwidths ";") value] -> edstr in ( fillEdCtrlSelect ctrltexthalign (loc "OS3DTABLE_0009")::(loc "OS3DTABLE_0010")::(loc "OS3DTABLE_0011")::nil; fillEdCtrlSelect ctrltextvalign (loc "OS3DTABLE_0012")::(loc "OS3DTABLE_0010")::(loc "OS3DTABLE_0013")::nil; selectEdCtrlSelectByPos ctrltexthalign texthalign; selectEdCtrlSelectByPos ctrltextvalign textvalign; setEdCtrlButtonCb editbtn mkfun2 @cbBtnEditValues [inst ewinstr ctrlnbrow ctrlnbcol edstr]; let _GETwindowPositionSize ewinstr.EDW_win -> [_ _ w h] in setEdWindowSize ewinstr w (h + (if usetheme then 0 else 125)); setEdWindowVisible lookswinstr !usetheme; //setEdCtrlCheckCbState ctrlusetheme mkfun3 @cbCheckUseTheme [theltselector ctrlccolor ctrlborder ctrlbcolor ctrlfname ctrlfsize ctrlfcolor]; //cbCheckUseTheme nil usetheme [theltselector ctrlccolor ctrlborder ctrlbcolor ctrlfname ctrlfsize ctrlfcolor]; setEdCtrlCheckCbState ctrlusetheme mkfun3 @cbCheckUseTheme [ewinstr themewinfrm lookswinstr]; setEdCtrlCheckState ctrlusetheme usetheme; setEdCtrlCheckState ctrlshow show; [mkfun1 @cbCloseEdit [edstr posstr ctrlnbrow ctrlnbcol ctrlcellxmargin ctrlcellymargin ctrltexthalign ctrltextvalign ctrlusetheme theltselector ctrlccolor ctrlborder ctrlbcolor ctrlfname ctrlfsize ctrlfcolor ctrlshow] nil]; ); );;