/************************************************************************************** * * SCS editor Version 2 * File : CreateWindow.pkg * Version : 25 août 2000 * * * * This package allows to create a container in a window (automaticaly created when nil) * in order to control a window (objwin or container) . * * return a tuple with * [ the container created, * [l r t b] for the 'client zone', * a comptext containing the title ] * ***************************************************************************************/ /* parameters section */ struct WindowTemplate = [ WINDOWbar : [AlphaBitmap I I I I I I], /* for the title bar */ WINDOWrollflag: I, /* flag for roll (see TitleBar) */ WINDOWcorner : AlphaBitmap, /* bitmap for the tile bar when the window is focused */ WINDOWborders : [AlphaBitmap I I I I], /* bitmap for the border */ WINDOWbuttons : [AlphaBitmap fun[]I AlphaBitmap fun[]I AlphaBitmap fun[]I], /* bitmaps and callbacks for buttons */ WINDOWflag : I, /* flag for the title position */ WINDOWfont : ObjFont, /* */ WINDOWtextCol : [I I I I], /* */ WINDOWtrans : I, /* transparency color for bitmaps */ WINDOWbgColor : I /* Background color */ ] mkWindowTemplate;; fun WINDOW_MakeTemplate (bar, corner, borders, buttons, rollflag, flag, font, textcol, trans, bgcolor) = mkWindowTemplate [bar rollflag corner borders buttons flag font textcol trans bgcolor] ;; /* display section */ fun _rflResizeCompBmp ( compBmp, param, w, h, parambmp) = let param -> [channel motif trans] in let _GETalphaBitmapSize motif -> [mw mh] in let _FILLbitmap (_CRbitmap channel w h) trans -> bmp in let _SCPalphaBitmap bmp 0 0 w-1 h-1 motif 0 0 mw-1 mh-1 -> _ in let _CRalphaBitmap channel bmp nil trans trans -> abmp in ( _DSbitmap bmp; [abmp [0 0 w h]] ) ;; fun _AddDressingToContainer(chan, cont, params, trans) = let params -> [alphabmp X1 X2 Y1 Y2] in let _GETalphaBitmapSize alphabmp -> [bw bh] in let _GETcontainerPositionSize cont -> [x y w h] in let OBJ_CONTAINER_CLICK|OBJ_CONTAINER_UNCLICK|OBJ_CONTAINER_DBLCLICK| OBJ_CONTAINER_KEYDOWN|OBJ_CONTAINER_KEYUP|OBJ_CONTAINER_MOUSEWHEEL|OBJ_CONTAINER_MOVE -> eventFlag in ( /* Top Left hand corner */ _CRcompBitmap chan cont nil [0 0] OBJ_ENABLE|OBJ_VISIBLE|OBJ_RW_FLEX|OBJ_RH_FLEX eventFlag alphabmp 0 0 X1 Y1; /* Top Right hand corner */ _CRcompBitmap chan cont nil [w-bw+X2 0] OBJ_ENABLE|OBJ_VISIBLE|OBJ_LW_FLEX|OBJ_RH_FLEX eventFlag alphabmp X2 0 bw-X2 Y1; /* bottom Right hand corner */ _CRcompBitmap chan cont nil [w-bw+X2 h-bh+Y2] OBJ_ENABLE|OBJ_VISIBLE|OBJ_LW_FLEX|OBJ_LH_FLEX eventFlag alphabmp X2 Y2 bw-X2 bh-Y2; /* bottom left hand corner */ _CRcompBitmap chan cont nil [0 h-bh+Y2] OBJ_ENABLE|OBJ_VISIBLE|OBJ_RW_FLEX|OBJ_LH_FLEX eventFlag alphabmp 0 Y2 X1 bh-Y2/*bh-1*/; /* Top middle adjustment bar */ let _FILLbitmap (_CRbitmap chan w-bw+(X2-X1) Y1) trans -> newbmp in let _SCPalphaBitmap newbmp 0 0 w-bw+(X2-X1)-1 Y1-1 alphabmp X1 0 X2-1 Y1-1 -> finalbmp in let _CRalphaBitmap chan finalbmp nil nil trans -> babmp in let _CRcompBitmap chan cont nil [X1 0] OBJ_ENABLE|OBJ_VISIBLE|OBJ_RH_FLEX|OBJ_MW_FLEX eventFlag babmp 0 0 w-bw+(X2-X1) Y1 -> compBmp in ( _CBcompBitmapResizeResource compBmp @_rflResizeCompBmp [chan babmp trans]; _DSbitmap newbmp ); /* bottom middle adjustment bar */ let _FILLbitmap (_CRbitmap chan w-bw+(X2-X1) bh-Y2) trans -> newbmp in let _SCPalphaBitmap newbmp 0 0 w-bw+(X2-X1)-1 bh-Y2-1 alphabmp X1 Y2 X2-1 bh-1 -> finalbmp in let _CRalphaBitmap chan finalbmp nil nil trans -> babmp in let _CRcompBitmap chan cont nil [X1 h-bh+Y2] OBJ_ENABLE|OBJ_VISIBLE|OBJ_LH_FLEX|OBJ_MW_FLEX eventFlag babmp 0 0 w-bw+(X2-X1) bh-Y2 -> compBmp in ( _CBcompBitmapResizeResource compBmp @_rflResizeCompBmp [chan babmp trans]; _DSbitmap newbmp ); /* left middle adjustment bar */ let _FILLbitmap (_CRbitmap chan X1 h-bh+(Y2-Y1)) trans -> newbmp in let _SCPalphaBitmap newbmp 0 0 X1-1 h-bh+(Y2-Y1)-1 alphabmp 0 Y1 X1-1 Y2-1 -> finalbmp in let _CRalphaBitmap chan finalbmp nil nil trans -> babmp in let _CRcompBitmap chan cont nil [0 Y1] OBJ_ENABLE|OBJ_VISIBLE|OBJ_RW_FLEX|OBJ_MH_FLEX eventFlag babmp 0 0 X1 h-bh+(Y2-Y1) -> compBmp in ( _CBcompBitmapResizeResource compBmp @_rflResizeCompBmp [chan babmp trans]; _DSbitmap newbmp ); /* right middle adjustment bar */ let _FILLbitmap (_CRbitmap chan bw-X2 h-bh+(Y2-Y1)) trans -> newbmp in let _SCPalphaBitmap newbmp 0 0 bw-X2-1 h-bh+(Y2-Y1)-1 alphabmp X2 Y1 bw-1 Y2-1 -> finalbmp in let _CRalphaBitmap chan finalbmp nil nil trans -> babmp in let _CRcompBitmap chan cont nil [w-bw+X2 Y1] OBJ_ENABLE|OBJ_VISIBLE|OBJ_LW_FLEX|OBJ_MH_FLEX eventFlag babmp 0 0 bw-X2 h-bh+(Y2-Y1) -> compBmp in ( _CBcompBitmapResizeResource compBmp @_rflResizeCompBmp [chan babmp trans]; _DSbitmap newbmp ); cont ) ;; /* main function */ fun WINDOW_Create (channel, father, template, possize, minmaxsize, title) = let template.WINDOWbar -> [barBmp barA barB barLeft barRight barTop barBottom] in let template.WINDOWborders -> [borBmp X1 X2 Y1 Y2] in let if template.WINDOWrollflag == nil then 0 else template.WINDOWrollflag -> rollflag in let possize -> [x y w h] in let _CRcontainerFromObjCont channel father x y w h CO_NOBORDER|CO_NOCAPTION|CO_HIDE template.WINDOWbgColor nil -> cont in ( _AddDressingToContainer channel cont template.WINDOWborders template.WINDOWtrans; let _CRtitleBar channel cont nil minmaxsize template.WINDOWbar template.WINDOWbuttons template.WINDOWcorner rollflag title 0 template.WINDOWfont template.WINDOWtextCol template.WINDOWflag template.WINDOWtrans -> [compText compMin compMax compClose tw th] in [cont compText compMin compMax compClose] ) ;; /* main function */ fun WINDOW_CreateFromObjWin (channel, father, template, possize, minmaxsize, title) = let template.WINDOWbar -> [barBmp barA barB barLeft barRight barTop barBottom] in let template.WINDOWborders -> [borBmp X1 X2 Y1 Y2] in let if template.WINDOWrollflag == nil then 0 else template.WINDOWrollflag -> rollflag in let possize -> [x y w h] in let _CRcontainerFromObjWin channel father x y w h CO_NOBORDER|CO_NOCAPTION|CO_HIDE template.WINDOWbgColor nil -> cont in ( _AddDressingToContainer channel cont template.WINDOWborders template.WINDOWtrans; let _CRtitleBar channel cont nil minmaxsize template.WINDOWbar template.WINDOWbuttons template.WINDOWcorner rollflag title 0 template.WINDOWfont template.WINDOWtextCol template.WINDOWflag template.WINDOWtrans -> [compText compMin compMax compClose tw th] in [cont compText compMin compMax compClose] ) ;; /* main function */ fun WINDOW_CreateWithObjWin (channel, win, template, possize, minmaxsize, title) = let template.WINDOWbar -> [barBmp barA barB barLeft barRight barTop barBottom] in let template.WINDOWborders -> [borBmp X1 X2 Y1 Y2] in let if template.WINDOWrollflag == nil then 0 else template.WINDOWrollflag -> rollflag in let possize -> [x y w h] in let if win!=nil then (_SIZEwindow win w-1 h-1 x y; [0 0]) else [x y] -> [cx cy] in let _CRcontainerFromObjWin channel win cx cy w h CO_NOBORDER|CO_NOCAPTION|CO_CHILDINSIDE template.WINDOWbgColor nil -> cont in ( _AddDressingToContainer channel cont template.WINDOWborders template.WINDOWtrans; let _CRtitleBar channel cont win minmaxsize template.WINDOWbar template.WINDOWbuttons template.WINDOWcorner rollflag title 0 template.WINDOWfont template.WINDOWtextCol template.WINDOWflag template.WINDOWtrans -> [compText compMin compMax compClose tw th] in [cont compText compMin compMax compClose] ) ;;