/* ----------------------------------------------------------------------------- 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 PlugTaskIcon = [ TICON_instance : PInstance, TICON_bitmap : ObjBitmap, TICON_sTitle : S, TICON_Icon : ObjIcon, TICON_iBalloonTimeout : I, TICON_bMinimize : I, TICON_lMenu : [S r1] ] MkPlugTaskIcon;; fun deleteOb(inst, ticonstr)= if (ticonstr.TICON_Icon == nil) then nil else _DStaskIcon ticonstr.TICON_Icon; if (ticonstr.TICON_bitmap == nil) then nil else _DSbitmap ticonstr.TICON_bitmap; 0;; fun cbDbClick(icon, ticonstr, btn)= if (btn != 0) then nil else ( SendPluginEvent ticonstr.TICON_instance "DoubleClick" nil nil; if !ticonstr.TICON_bMinimize then nil else let _GETwindowPositionSize mainWindow.EDW_win -> [x y w h] in ( if w != 0 then _SHOWwindow mainWindow.EDW_win WINDOW_MINIMIZED else _SHOWwindow mainWindow.EDW_win WINDOW_RESTORED; ); ); 0;; fun cbMenu(item, label, ticonstr)= SendPluginEvent ticonstr.TICON_instance label nil nil; 0;; fun makeMenu(ticonstr)= let _CRpopupMenu _channel -> mnu in ( let sizelist ticonstr.TICON_lMenu -> size in let 0 -> i in while (i < size) do ( let nth_list ticonstr.TICON_lMenu i -> label in let if !strcmpi label "__" then ME_SEPARATOR else ME_ENABLED -> flag in _CBmenu (_APPitem _channel mnu flag label) mkfun3 @cbMenu ticonstr label; set i = i + 1; ); mnu; );; fun cbClick(icon, ticonstr, btn)= if (btn == 1) then ( SendPluginEvent ticonstr.TICON_instance "RightClick" nil nil; _SETfocus nil; let makeMenu ticonstr -> mnu in let _GETscreenPos -> [x y] in _DRAWmenu nil mnu x y PM_SCREEN|PM_RIGHT_ALIGN|PM_BOTTOM_ALIGN; 0; ) else if (btn == 0) then ( SendPluginEvent ticonstr.TICON_instance "LeftClick" nil nil; 0; ) else nil; 0;; fun cbShow(inst, from, action, param, reply, ticonstr)= if (ticonstr.TICON_Icon != nil) then nil else ( set ticonstr.TICON_Icon = _CRtaskIcon2 _channel ticonstr.TICON_bitmap ticonstr.TICON_sTitle; _CBtaskIconDClick ticonstr.TICON_Icon @cbDbClick ticonstr; _CBtaskIconClick ticonstr.TICON_Icon @cbClick ticonstr; ); 0;; fun cbHide(inst, from, action, param, reply, ticonstr)= if (ticonstr.TICON_Icon == nil) then nil else ( _DStaskIcon ticonstr.TICON_Icon; set ticonstr.TICON_Icon = nil; ); 0;; fun cbSetTitle(inst, from, action, param, reply, ticonstr)= set ticonstr.TICON_sTitle = param; if (ticonstr.TICON_Icon == nil) then nil else _SETtaskIconText ticonstr.TICON_Icon ticonstr.TICON_sTitle; 0;; fun cbSetBitmap(inst, from, action, param, reply, ticonstr)= let G2DstrechBitmap _channel (G2DloadBmp _channel param) 16 16 0 -> bmp in if (bmp == nil) then nil else ( _DSbitmap ticonstr.TICON_bitmap; set ticonstr.TICON_bitmap = bmp; if (ticonstr.TICON_Icon == nil) then nil else _SETtaskIconImage2 ticonstr.TICON_Icon ticonstr.TICON_bitmap; ); 0;; fun loadMenu(menu)= let strextr menu -> l in let sizelist l -> size in let nil -> ndata in let 0 -> i in ( while i < size do ( let nth_list l i -> elem in set ndata = lcat ndata (strcatnSep elem " ")::nil; set i = i + 1; ); ndata; );; fun cbShowBalloonTip(inst, from, action, param, reply, ticonstr)= _ShowtaskIconBalloonTip ticonstr.TICON_Icon nil param ticonstr.TICON_iBalloonTimeout * 1000; 0;; fun newOb(inst)= let (getPluginInstanceParam inst "path") -> path in let (getPluginInstanceParam inst "title") -> title in let loadMenu (getPluginInstanceParam inst "menu") -> menu in let atoi (getPluginInstanceParam inst "balloonTimeout") -> balloonTimeout in let atoi (getPluginInstanceParam inst "minimize") -> minimize in let atoi (getPluginInstanceParam inst "init") -> init in let G2DstrechBitmap _channel (G2DloadBmp _channel path) 16 16 0 -> bmp in let MkPlugTaskIcon [inst bmp title nil balloonTimeout minimize menu] -> ticonstr in ( if !init then nil else cbShow inst nil nil nil nil ticonstr; PluginRegisterAction inst "Show" mkfun6 @cbShow ticonstr; PluginRegisterAction inst "Hide" mkfun6 @cbHide ticonstr; PluginRegisterAction inst "Set title" mkfun6 @cbSetTitle ticonstr; PluginRegisterAction inst "Set bitmap" mkfun6 @cbSetBitmap ticonstr; PluginRegisterAction inst "Show Balloon Tip" mkfun6 @cbShowBalloonTip ticonstr; setPluginInstanceCbDel inst mkfun2 @deleteOb ticonstr; ); 0;; fun IniPlug(file)= _refreshExe; PlugRegister @newOb nil; setPluginEditor @dynamicedit; 0;;