/* ----------------------------------------------------------------------------- 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 ----------------------------------------------------------------------------- */ typeof globalInstance = PInstance;; fun deleteOb(inst)= 0;; fun cbGetFocus(inst, from, action, param, rep)= let (V3DgetSessionView c3dXsession) -> viewstr in V3DviewSetFocus viewstr; 0;; fun cbShow(inst, from, action, param, rep)= _SHOWwindow mainWindow.EDW_win WINDOW_UNHIDDEN; 0;; fun cbHide(inst, from, action, param, rep)= _SHOWwindow mainWindow.EDW_win WINDOW_HIDDEN; 0;; fun cbTitle(inst, from, action, param, rep)= if ((param == nil) || ((strlen param) == 0)) then nil else _SETwindowName mainWindow.EDW_win param; 0;; fun cbWinClose(win, inst)= SendPluginEvent inst "Closed" nil nil; 0;; fun cbSetSize(inst, from, action, param, rep)= let hd strextr param -> pl in let [(atoi hd pl) (atoi hd tl pl)] -> [w h] in setEdWindowSize mainWindow w h; 0;; fun newOb(inst)= // test if we are in editor then we stop the play mode if (_test_exist "stopEditorFromPlugin") then ( 0; ) else ( let atoi (getPluginInstanceParam inst "width") -> width in let if width == nil then 800 else width -> width in let atoi (getPluginInstanceParam inst "height") -> height in let if height == nil then 600 else height -> height in let atoi (getPluginInstanceParam inst "desksize") -> desksize in let if desksize == nil then 0 else desksize -> desksize in let atoi (getPluginInstanceParam inst "resize") -> resize in let if resize == nil then 1 else resize -> resize in let atoi (getPluginInstanceParam inst "border") -> border in let if border == nil then 1 else border -> border in let atoi (getPluginInstanceParam inst "caption") -> caption in let if caption == nil then 1 else caption -> caption in let atoi (getPluginInstanceParam inst "catchClose") -> catchClose in let if catchClose == nil then 0 else catchClose -> catchClose in let (getPluginInstanceParam inst "title") -> title in let _GETdesktopSize -> [sw sh] in let WN_MENU|WN_SIZEBOX -> style in ( if (border) then nil else set style = style | WN_NOBORDER; if (caption) then nil else set style = style | WN_NOCAPTION; if (resize) then nil else set style = style & ~(WN_SIZEBOX); if (!catchClose) then nil else _CBwinClose mainWindow.EDW_win @cbWinClose inst; _SETwindowStyle mainWindow.EDW_win style; if ((title == nil) || ((strlen title) == 0)) then nil else _SETwindowName mainWindow.EDW_win title; if (!desksize) then _SIZEwindowEx mainWindow.EDW_win width height ((sw / 2) - (width / 2)) ((sh / 2) - (height / 2)) else ( //big hack to get the correct windows size with no border _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 let _GETscreenSize -> [ssw ssh] in _SIZEwindowEx mainWindow.EDW_win (ssw + nw) (ssh + nh) nx ny; ); PluginRegisterAction inst "Get focus" @cbGetFocus; PluginRegisterAction inst "Show" @cbShow; PluginRegisterAction inst "Hide" @cbHide; PluginRegisterAction inst "Set title" @cbTitle; PluginRegisterAction inst "Set size" @cbSetSize; ); 0; ); set globalInstance = inst; setPluginInstanceCbDel inst @deleteOb; SendPluginEvent inst "Started" nil nil; 0;; fun IniPlug(file)= PlugRegister @newOb nil; setPluginEditor @dynamicedit; 0;;