/*
-----------------------------------------------------------------------------
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 -> [ctrlpindata ctrlpinclock ctrlpinlatch ctrlpath] in
let getSelectedEdCtrlSelect ctrlpindata -> pindata in
let getSelectedEdCtrlSelect ctrlpinclock -> pinclock in
let getSelectedEdCtrlSelect ctrlpinlatch -> pinlatch in
let getEdCtrlTextLineValue ctrlpath -> path in
["pinData" pindata]::
["pinClock" pinclock]::
["pinLatch" pinlatch]::
["path" path]::
nil;;
fun cbDlgGetPath(pfile, p)=
let p -> [inst ctrlbtn winstr ctrlpath] in
(
if pfile == nil then nil else
let _PtoScol pfile -> file in
if file == nil then
(
_DLGMessageBox _channel winstr.EDW_win (loc "OS3DGPIOLMATRIX_0003") (loc "OS3DGPIOLMATRIX_0014") 0;
0;
)
else
(
setEdCtrlTextLineValue ctrlpath file;
0;
);
setEdCtrlButtonEnable ctrlbtn 1;
);
0;;
fun cbBtnPickFile(ctrlbtn, p)=
let p -> [inst winstr ctrlpath] in
let getEdCtrlTextLineValue ctrlpath -> path in
let getPathFile path "" -> [fpath fname] in
(
setEdCtrlButtonEnable ctrlbtn 1;
let _GETdesktopSize -> [sw sh] in
let getEdWindowPos mainInterf.MINT_winMain -> [nx ny] in
let getEdWindowSize mainInterf.MINT_winMain -> [nmw nmh] in
let [750 450] -> [iw ih] in
let crEdOpenFileBitmapDialog _channel winstr nx + ((nmw / 2) - (iw / 2)) ny + ((nmh / 2) - (ih / 2)) iw ih ""
["Bitmaps" "bmp"::"jpg"::"png"::"tga"::nil]::["Bitmap" "bmp"::nil]::["Jpeg" "jpg"::nil]::["PNG" "png"::nil]::["Targa" "tga"::nil]::nil
EDFILE_DIALOG_LIST_FOLDERS|EDFILE_DIALOG_SHOW_TOOLBAR nil path
-> dlgfstr in
(
setEdWindowIcon dlgfstr.EDFD_dialog sWinDlgIcon;
setEdOpenFileDialogCb dlgfstr mkfun2 @cbDlgGetPath [inst ctrlbtn winstr ctrlpath];
);
);
0;;
fun cbRefreshBtn(pickbtn, p)=
let p -> [ctrlobjname] in
setEdCtrlTextLineValue ctrlobjname "";
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(winstr, inst, viewstr, applybtn)=
let [455 110] -> [iw ih] in
(
setEdWindowSize winstr iw ih;
let atoi (getPluginInstanceParam inst "pinData") -> pindata in
let if pindata == nil then 2 else pindata -> pindata in
let atoi (getPluginInstanceParam inst "pinClock") -> pinclock in
let if pinclock == nil then 3 else pinclock -> pinclock in
let atoi (getPluginInstanceParam inst "pinLatch") -> pinlatch in
let if pinlatch == nil then 4 else pinlatch -> pinlatch in
let (getPluginInstanceParam inst "path") -> path in
let 10 -> ypos in
let crEdCtrlLabel winstr 10 ypos + 2 160 20 (loc "OS3DGPIOLMATRIX_0001") nil -> labeldata in
let crEdCtrlSelect winstr 180 ypos 200 130 EDWIN_RESIZE_MW -> ctrlpindata in
let crEdCtrlLabel winstr 10 (set ypos = ypos + 25) + 2 160 20 (loc "OS3DGPIOLMATRIX_0003") nil -> labellatch in
let crEdCtrlSelect winstr 180 ypos 200 130 EDWIN_RESIZE_MW -> ctrlpinlatch in
let crEdCtrlLabel winstr 10 (set ypos = ypos + 25) + 2 160 20 (loc "OS3DGPIOLMATRIX_0002") nil -> labelclock in
let crEdCtrlSelect winstr 180 ypos 200 130 EDWIN_RESIZE_MW -> ctrlpinclock in
let crEdCtrlLabel winstr 10 ((set ypos = ypos + 25) + 2) 160 20 (loc "OS3DGPIOLMATRIX_0004") nil -> labelbmp in
let crEdCtrlTextLine winstr 180 ypos 170 20 path nil EDWIN_RESIZE_MW -> ctrlpath in
let crEdCtrlButton winstr 360 ypos 55 20 "..." nil -> pickfilebtn in
let crEdCtrlButton winstr 420 ypos 35 20 "X" nil -> refreshpath in
(
fillPinSelector ctrlpindata pindata;
fillPinSelector ctrlpinclock pinclock;
fillPinSelector ctrlpinlatch pinlatch;
setEdCtrlButtonCb pickfilebtn mkfun2 @cbBtnPickFile [inst winstr ctrlpath];
setEdCtrlTextLineEnable ctrlpath 0;
setEdCtrlButtonCb refreshpath mkfun2 @cbRefreshBtn [ctrlpath];
[mkfun1 @cbCloseEdit [ctrlpindata ctrlpinclock ctrlpinlatch ctrlpath] nil];
);
);;