/* ----------------------------------------------------------------------------- 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 getModeFromName(mode)= let _GETscreenSize -> size in let strfind "x" mode 0 -> xpos in let strfind " " mode xpos -> endpos in let if endpos == nil then (strlen mode) else endpos -> endpos in let atoi (substr mode 0 xpos) -> w in let atoi (substr mode xpos+1 (endpos - (xpos+1))) -> h in ( if (mode == nil) || (w == nil) || (h == nil) then size else [w h]; );; fun deleteOb(inst, p)= let p -> [size current windowmode _] in if (windowmode) then ( // test if we are in editor then we stop the play mode if (_test_exist "stopEditorFromPlugin") then ( 0; ) else ( let WN_NORMAL|WN_MENU|WN_SIZEBOX -> style in _SETwindowStyle mainWindow.EDW_win style; let _GETwindowScreenSize mainWindow.EDW_win -> [x y ssw ssh] in _SIZEwindowEx mainWindow.EDW_win 800 600 x + ((ssw / 2) - 400) y + ((ssh / 2) - 400); 0; ); ) else ( let c3dXsession -> sessionstr in V3DsetWindowedMode sessionstr.V3D_sessionView; 0; ); 0;; fun cbEnable(inst, from, action, param, rep, p) = let p -> [size current windowmode state] in if (state) then nil else ( mutate p <- [_ _ _ 1]; if (windowmode) then ( // test if we are in editor then we stop the play mode if (_test_exist "stopEditorFromPlugin") then ( 0; ) else ( let WN_NOBORDER|WN_NOCAPTION -> style in _SETwindowStyle mainWindow.EDW_win style; //big hack to get the correct windows size with no border let _GETwindowScreenSize mainWindow.EDW_win -> [x y ssw ssh] in ( _SIZEwindowEx mainWindow.EDW_win 800 600 0 0; let _GETwindowPositionSize mainWindow.EDW_win -> [nx ny nw nh] in let [(0 - nx) (0 - ny) (800 - nw) (600 - nh)] -> [nx ny nw nh] in _SIZEwindowEx mainWindow.EDW_win (ssw + nw) (ssh + nh) x + nx y + ny; _SETfocus DMSwin; ); 0; ); ) else ( let c3dXsession -> sessionstr in let if current then let _GETwindowScreenSize mainWindow.EDW_win -> [_ _ w h] in [w h] else size -> [sw sh] in V3DsetFullScreenMode sessionstr.V3D_sessionView sw sh; 0; ); ); 0;; fun cbDisable(inst, from, action, param, rep, p) = let p -> [size current windowmode state] in if (!state) then nil else ( mutate p <- [_ _ _ 0]; if (windowmode) then ( // test if we are in editor then we stop the play mode if (_test_exist "stopEditorFromPlugin") then ( 0; ) else ( let WN_NORMAL|WN_MENU|WN_SIZEBOX -> style in _SETwindowStyle mainWindow.EDW_win style; let _GETwindowScreenSize mainWindow.EDW_win -> [x y ssw ssh] in _SIZEwindowEx mainWindow.EDW_win 800 600 x + ((ssw / 2) - 400) y + ((ssh / 2) - 400); _SETfocus DMSwin; 0; ); 0; ) else ( let c3dXsession -> sessionstr in V3DsetWindowedMode sessionstr.V3D_sessionView; 0; ); ); 0;; fun cbSetState(inst, from, action, param, rep, p)= if (param == nil) || (strcmpi param "") == 0 then nil else ( if (atoi param) <= 0 then cbDisable inst from action param rep p else cbEnable inst from action param rep p; ); 0;; fun cbSwitch(inst, from, action, param, rep, p) = let p -> [_ _ _ state] in if state then cbDisable inst from action param rep p else cbEnable inst from action param rep p; 0;; fun cbSetSize(inst, from, action, param, rep, p) = if param == nil then nil else let p -> [_ _ windowmode init] in ( if (windowmode) then nil else let getModeFromName param -> [sw sh] in ( mutate p <- [[sw sh] 0 _ _]; if !init then nil else let c3dXsession -> sessionstr in ( V3DsetWindowedMode sessionstr.V3D_sessionView; V3DsetFullScreenMode sessionstr.V3D_sessionView sw sh; ); ); ); 0;; fun newOb(inst)= let atoi (getPluginInstanceParam inst "windowmode") -> windowmode in let if windowmode == nil then 0 else windowmode -> windowmode in let (getPluginInstanceParam inst "mode") -> mode in let atoi (getPluginInstanceParam inst "current") -> current in let atoi (getPluginInstanceParam inst "init") -> init in let (getModeFromName mode) -> size in let [size current windowmode 0] -> p in ( if !init then nil else ( cbEnable inst nil nil nil nil p; ); PluginRegisterAction inst "Enable" mkfun6 @cbEnable p; PluginRegisterAction inst "Disable" mkfun6 @cbDisable p; PluginRegisterAction inst "Set state" mkfun6 @cbSetState p; PluginRegisterAction inst "Set size" mkfun6 @cbSetSize p; PluginRegisterAction inst "Switch" mkfun6 @cbSwitch p; setPluginInstanceCbDel inst mkfun2 @deleteOb p; ); 0;; fun IniPlug(file)= PlugRegister @newOb nil; setPluginEditor @dynamicedit; 0;;