/************************************************************************************** * * SCS editor Version 2 * File : TitleBar.pkg * Version : 28 juillet 2000 * * * * This package allows to create a title bar in a container * in order to control a window (objwin or container) . * ***************************************************************************************/ var TITLEBAR_OFFSET_BUT = 5;; var TITLEBAR_RESIZE_LEFT = 0b0001;; var TITLEBAR_RESIZE_RIGHT = 0b0010;; var TITLEBAR_RESIZE_TOP = 0b0100;; var TITLEBAR_RESIZE_BOTTOM= 0b1000;; var TITLEBAR_ROLL_OFF = 0b000;; /* la fenêtre ne s'enroule pas */ var TITLEBAR_ROLL_DBLCLICK= 0b001;; /* la fenêtre s'enroule si on double click sur la barre de titre */ var TITLEBAR_ROLL_CURHOVER= 0b010;; /* la fenêtre s'enroule si le curseur quitte le container */ var TITLEBAR_NO_CALLBACKS = 0b100;; /* if no callbacks must be defined */ /**************************************************************************************** * * This function stretch a bitmap according to the xList and yList which are lists * of [I I] where the first I is the coordinate in the motif and the second I * is the corresponding coordinate in the streched bmp. * ****************************************************************************************/ fun _STRETCHalphaBitmap2 (bmp,motif,xList,yList,oxList) = let xList -> [x1 [x2 nextx]] in let yList -> [y1 [y2 nexty]] in if y2 == nil then bmp else let x1 -> [ox1 nx1] in let x2 -> [ox2 nx2] in let y1 -> [oy1 ny1] in let y2 -> [oy2 ny2] in ( _SCPalphaBitmap bmp nx1 ny1 nx2-1 ny2-1 motif ox1 oy1 ox2-1 oy2-1; if (hd nextx)!=nil then _STRETCHalphaBitmap2 bmp motif (tl xList) yList oxList else _STRETCHalphaBitmap2 bmp motif oxList (tl yList) oxList );; /* here is the function to use */ fun _STRETCHalphaBitmap (bmp,motif,xList,yList) = _STRETCHalphaBitmap2 bmp motif xList yList xList ;; fun _rflResizeCompBar ( compBmp, param, w, h, parambmp) = let param -> [channel bar a b trans] in let _GETalphaBitmapSize bar -> [barw h] in let [0 0]::[a a]::[b w-(barw-b)]::[barw w]::nil -> xList in let [0 0]::[h h]::nil -> yList in let _CRbitmap channel w h -> bmp in let _STRETCHalphaBitmap bmp bar xList yList -> _ in let _CRalphaBitmap channel bmp nil trans trans -> abmp in ( _DSbitmap bmp; [abmp [0 0 w h]] ) ;; /*************************************************************************************** ************ CONTROL WINDOW ******** ***************************************************************************************/ /* resize the container when the window is resized */ fun rflSizeWin (win, cont, w, h) = _SIZEcontainer cont 0 0 w h ;; fun _MoveWindow (cont, param, x, y, bt) = let param -> [win initx inity] in let _GETwindowExSizePosition win -> [_ _ tx ty] in let (x - initx) -> difx in let (y - inity) -> dify in _MVwindow win tx + difx ty + dify ;; fun _UnClickContToMoveWin (cont, param, x, y, bt, mask) = _CBcontainerCursorMove cont nil nil ;; fun _ResizeWindow (cont, param, x, y, bt) = if bt&MK_LBUTTON then ( let param -> [win initx inity initw inith minmaxsize flag] in let minmaxsize -> [minw minh maxw maxh] in let _GETwindowSizePosition win -> [tw th tx ty] in let (x - initx) -> difx in let (y - inity) -> dify in let if flag&TITLEBAR_RESIZE_LEFT then tw-difx else if flag&TITLEBAR_RESIZE_RIGHT then initw+difx else tw -> nw in let if nw > maxw then maxw else if nw < minw then minw else nw -> neww in let if flag&TITLEBAR_RESIZE_TOP then th-dify else if flag&TITLEBAR_RESIZE_BOTTOM then inith+dify else th -> nh in let if nh > maxh then maxh else if nh < minh then minh else nh -> newh in let if flag&TITLEBAR_RESIZE_LEFT then tx+(tw-neww) else tx -> newx in let if flag&TITLEBAR_RESIZE_TOP then ty+(th-newh) else ty -> newy in _SIZEwindow win neww newh newx newy; 0 ) else ( _CBcontainerCursorMove cont nil nil; 0 ) ;; fun _ClickContToMoveWin (cont, param, x, y, bt, mask) = let param -> [win minmaxsize borders] in let borders -> [barLeft barRight barTop barBottom] in let _GETwindowExSizePosition win -> [tw th _ _] in let 0 -> flag in ( if x < barLeft then set flag=TITLEBAR_RESIZE_LEFT else if x > (tw-barRight) then set flag=TITLEBAR_RESIZE_RIGHT else nil; if y < barTop then set flag=flag|TITLEBAR_RESIZE_TOP else if y > (th-barBottom) then set flag=flag|TITLEBAR_RESIZE_BOTTOM else nil; if flag==0 then _CBcontainerCursorMove cont @_MoveWindow [win x y] else _CBcontainerCursorMove cont @_ResizeWindow [win x y tw th minmaxsize flag] ) ;; fun _ClickButToResizeWin (compBmp, param, x, y, bt, mask) = let param -> [win cont minmaxsize borders] in let borders -> [barLeft barRight barTop barBottom] in let _GETwindowExSizePosition win -> [tw th _ _] in let TITLEBAR_RESIZE_RIGHT|TITLEBAR_RESIZE_BOTTOM -> flag in _CBcontainerCursorMove cont @_ResizeWindow [win x y tw th minmaxsize flag] ;; fun _MaximizeWindow (compCheck, param, state) = let param -> [win rfl corner] in ( if state&CHK_CHECKED then ( _CHANGEobjNodeFlags corner OBJ_HIDE 0; _SHOWwindow win WINDOW_MAXIMIZED ) else ( _CHANGEobjNodeFlags corner OBJ_ENABLE|OBJ_VISIBLE|OBJ_LW_FLEX|OBJ_LH_FLEX 0; _SHOWwindow win WINDOW_RESTORED ); exec rfl with [] ) ;; fun _MinimizeWindow (compRollOver, param, posx, posy, btn, mask) = let param -> [win rfl] in if btn&LBUTTON then ( exec rfl with []; _SHOWwindow win WINDOW_MINIMIZED ) else nil ;; fun _CloseWindow (compRollOver, param, posx, posy, btn, mask) = let param -> [win rfl] in if btn&LBUTTON then ( exec rfl with []; _DSwindow win ) else nil ;; proto _UnRollWindow=fun[ObjContainer [ObjWin [I I I I] [I I I I] I I I ObjNode] I I I I] I;; fun _RollWindow (cont, param, posx, posy, btn, mask) = let param -> [win minmaxsize borders rollh rollflag corner] in if btn&LBUTTON then let _GETwindowExSizePosition win -> [w h x y] in ( if rollflag&TITLEBAR_ROLL_DBLCLICK then _CBcontainerDblClick cont @_UnRollWindow [win minmaxsize borders rollh h rollflag corner] else if rollflag&TITLEBAR_ROLL_CURHOVER then _CBcontainerCursorHover cont (mkfun3 mkfun4 mkfun5 mkfun6 @_UnRollWindow 0 LBUTTON 0 0) [win minmaxsize borders rollh h rollflag corner] else nil; /*_CBwinSize win nil nil;*/ _CHANGEobjNodeFlags corner OBJ_HIDE 0; _SIZEwindowEx win w rollh x y; /*_CBwinSize win @rflSizeWin cont;*/ _CBcontainerClick cont @_ClickContToMoveWin [win [w rollh w rollh] borders]; _CBcontainerUnClick cont @_UnClickContToMoveWin win; 0 ) else nil ;; fun _UnRollWindow (cont, param, posx, posy, btn, mask) = let param -> [win minmaxsize borders rollh inith rollflag corner] in if btn&LBUTTON then let _GETwindowExSizePosition win -> [w _ x y] in ( if rollflag&TITLEBAR_ROLL_DBLCLICK then _CBcontainerDblClick cont @_RollWindow [win minmaxsize borders rollh rollflag corner] else if rollflag&TITLEBAR_ROLL_CURHOVER then _CBcontainerCursorLeave cont (mkfun3 mkfun4 mkfun5 mkfun6 @_RollWindow 0 LBUTTON 0 0) [win minmaxsize borders rollh rollflag corner] else nil; _CHANGEobjNodeFlags corner OBJ_ENABLE|OBJ_VISIBLE|OBJ_LW_FLEX|OBJ_LH_FLEX 0; _SIZEwindowEx win w inith x y; _CBcontainerClick cont @_ClickContToMoveWin [win minmaxsize borders]; _CBcontainerUnClick cont @_UnClickContToMoveWin win; 0 ) else nil ;; fun _MaxWindow (cont, compCheck, posx, posy, btn, mask) = let _GETcompCheckState compCheck -> state in if state == CHK_UNCHECKED then _SETcompCheckState compCheck CHK_CHECKED else _SETcompCheckState compCheck CHK_UNCHECKED ;; /* création d'une barre d'une barre de titre dans un container pour controler sa fenêtre mère */ fun _CRtitleBar1 (channel, cont, win, minmaxsize, bar, buttons, corner, rollflag, title, posx, font, colors, flag, transparencyColor) = if bar==nil then nil else let bar -> [barbmp barA barB barLeft barRight barTop barBottom] in let buttons -> [minimize rflmin maximize rflmax closewin rflclose] in let _GETcontainerPositionSize cont -> [_ _ wCont hCont] in let wCont-(barLeft+barRight) -> w in let _GETalphaBitmapSize barbmp -> [barw h] in let if minimize!=nil then _GETalphaBitmapSize minimize else [0 0] -> [minw minh] in let if maximize!=nil then _GETalphaBitmapSize maximize else [0 0] -> [maxw maxh] in let if closewin!=nil then _GETalphaBitmapSize closewin else [0 0] -> [clow cloh] in let _CRbitmap channel w h -> bmp in let [0 0]::[barA barA]::[barB w-(barw-barB)]::[barw w]::nil -> xList in let [0 0]::[h h]::nil -> yList in let _STRETCHalphaBitmap bmp barbmp xList yList -> _ in let _GETstringSize font "|M£fF0!" -> [_ th] in let _CRalphaBitmap channel bmp nil transparencyColor transparencyColor -> abmp in let _CRcompBitmap channel cont nil [barLeft barTop] OBJ_ENABLE|OBJ_VISIBLE|OBJ_MW_FLEX|OBJ_RH_FLEX OBJ_CONTAINER_DBLCLICK|OBJ_CONTAINER_CLICK|OBJ_CONTAINER_UNCLICK|OBJ_CONTAINER_MOVE|OBJ_CONTAINER_KEYDOWN|OBJ_CONTAINER_KEYUP abmp 0 0 w h -> compBar in let _CONVERTcompBitmapToObjNode compBar -> bmpFather in let _CRcompText channel cont bmpFather [posx+barA (h-th)/2] OBJ_ENABLE|OBJ_VISIBLE|CT_LABEL|OBJ_MW_FLEX|OBJ_RH_FLEX|flag OBJ_CONTAINER_DBLCLICK|OBJ_CONTAINER_CLICK|OBJ_CONTAINER_MOVE|OBJ_CONTAINER_UNCLICK|OBJ_CONTAINER_KEYDOWN|OBJ_CONTAINER_KEYUP w-posx-(barA+TITLEBAR_OFFSET_BUT)-(minw+maxw+clow) h title font colors [0 0] nil nil -> titleText in let [barLeft barRight barTop barBottom] -> borders in let if closewin==nil then nil else _CRcompRollOver channel cont bmpFather [w-clow-TITLEBAR_OFFSET_BUT (h-cloh/3)/2] OBJ_ENABLE|OBJ_VISIBLE|OBJ_LW_FLEX|OBJ_RH_FLEX 0 closewin -> compClose in let if maximize==nil then nil else _CRcompCheck channel cont bmpFather [w-maxw/2-clow-TITLEBAR_OFFSET_BUT (h-maxh/3)/2] OBJ_ENABLE|OBJ_VISIBLE|OBJ_LW_FLEX|OBJ_RH_FLEX 0 maximize -> compMax in let if minimize==nil then nil else _CRcompRollOver channel cont bmpFather [w-minw-maxw/2-clow-TITLEBAR_OFFSET_BUT (h-minh/3)/2] OBJ_ENABLE|OBJ_VISIBLE|OBJ_LW_FLEX|OBJ_RH_FLEX 0 minimize -> compMin in let h+barTop+barBottom -> rollh in /* resize button (corner) */ let _GETalphaBitmapSize corner -> [corw corh] in let _CRcompBitmap channel cont nil [wCont-corw hCont-corh] OBJ_ENABLE|OBJ_VISIBLE|OBJ_LW_FLEX|OBJ_LH_FLEX OBJ_CONTAINER_DBLCLICK|OBJ_CONTAINER_MOVE|OBJ_CONTAINER_UNCLICK|OBJ_CONTAINER_KEYDOWN|OBJ_CONTAINER_KEYUP corner 0 0 corw-1 corh-1 -> compBmp in let _CONVERTcompBitmapToObjNode compBmp -> oCorner in ( _CBcompBitmapClick compBmp @_ClickButToResizeWin [win cont minmaxsize [barLeft barRight barTop barBottom]]; _CBcompBitmapResizeResource compBar @_rflResizeCompBar [channel barbmp barA barB transparencyColor]; if rollflag&TITLEBAR_ROLL_DBLCLICK then _CBcontainerDblClick cont @_RollWindow [win minmaxsize borders rollh rollflag oCorner] else if rollflag&TITLEBAR_ROLL_CURHOVER then _CBcontainerCursorLeave cont (mkfun3 mkfun4 mkfun5 mkfun6 @_RollWindow 0 LBUTTON 0 0) [win minmaxsize borders rollh rollflag oCorner] else _CBcontainerDblClick cont @_MaxWindow compMax; _CBcompRollOverClick compClose @_CloseWindow [win rflclose]; _CBcompCheckStateChanged compMax @_MaximizeWindow [win rflmax oCorner]; _CBcompRollOverClick compMin @_MinimizeWindow [win rflmin]; _CBcontainerClick cont @_ClickContToMoveWin [win minmaxsize [barLeft barRight barTop barBottom]]; _CBcontainerUnClick cont @_UnClickContToMoveWin win; _CBwinSize win @rflSizeWin cont; [titleText compMin compMax compClose w+barRight+barLeft h+barTop+barBottom] ) ;; /*********************************************************************************************************************** ****** CONTROL CONTAINER ******* ***********************************************************************************************************************/ fun _UnClickContToMoveCont (cont, param, x, y, bt, mask) = _CBcontainerCursorMove cont nil nil ;; fun _MoveContainer (cont, param, x, y, bt) = if bt&MK_LBUTTON then ( let param -> [initx inity] in let _GETcontainerExPositionSize cont -> [tx ty _ _] in let (x - initx) -> difx in let (y - inity) -> dify in _MOVEcontainer cont (tx + difx) (ty + dify); 0 ) else ( _UnClickContToMoveCont cont nil nil nil nil nil; 0 ) ;; fun _ResizeContainer (cont, param, x, y, bt) = if bt&MK_LBUTTON then ( let param -> [initx inity initw inith minmaxsize flag] in let minmaxsize -> [minw minh maxw maxh] in let _GETcontainerPositionSize cont -> [tx ty tw th] in let (x - initx) -> difx in let (y - inity) -> dify in let if flag&TITLEBAR_RESIZE_LEFT then tw-difx else if flag&TITLEBAR_RESIZE_RIGHT then initw+difx else tw -> nw in let if nw > maxw then maxw else if nw < minw then minw else nw -> neww in let if flag&TITLEBAR_RESIZE_TOP then th-dify else if flag&TITLEBAR_RESIZE_BOTTOM then inith+dify else th -> nh in let if nh > maxh then maxh else if nh < minh then minh else nh -> newh in let if flag&TITLEBAR_RESIZE_LEFT then tx+(tw-neww) else tx -> newx in let if flag&TITLEBAR_RESIZE_TOP then ty+(th-newh) else ty -> newy in _SIZEcontainer cont newx newy neww newh; 0 ) else ( _UnClickContToMoveCont cont nil nil nil nil nil; 0 ) ;; fun _ClickContToMoveCont (cont, param, x, y, bt, mask) = let param -> [minmaxsize borders noresize nomove] in let borders -> [barLeft barRight barTop barBottom] in let _GETcontainerExPositionSize cont -> [_ _ tw th] in let 0 -> flag in ( if x < barLeft then set flag=TITLEBAR_RESIZE_LEFT else if x > (tw-barRight) then set flag=TITLEBAR_RESIZE_RIGHT else nil; if y < barTop then set flag=flag|TITLEBAR_RESIZE_TOP else if y > (th-barBottom) then set flag=flag|TITLEBAR_RESIZE_BOTTOM else nil; if (((flag==0) || noresize)&&!nomove) then _CBcontainerCursorMove cont @_MoveContainer [x y] else if noresize==0 then _CBcontainerCursorMove cont @_ResizeContainer [x y tw th minmaxsize flag] else nil; ) ;; fun _ClickButToResizeCont (compBmp, param, x, y, bt, mask) = let param -> [cont param2] in let param2 -> [minmaxsize borders noresize nomove] in let borders -> [barLeft barRight barTop barBottom] in let _GETcontainerExPositionSize cont -> [_ _ tw th] in let TITLEBAR_RESIZE_RIGHT|TITLEBAR_RESIZE_BOTTOM -> flag in ( if (((flag==0) || noresize)&&!nomove) then _CBcontainerCursorMove cont @_MoveContainer [x y] else if noresize==0 then _CBcontainerCursorMove cont @_ResizeContainer [x y tw th minmaxsize flag] else nil; ) ;; fun _MinimizeContainer (compRollOver, param, posx, posy, btn, mask) = let param -> [cont rfl] in if btn&LBUTTON then ( exec rfl with []; _SHOWcontainer cont CONTAINER_MINIMIZED ) else nil ;; fun _CloseContainer (compRollOver, param, posx, posy, btn, mask) = let param -> [cont rfl] in if btn&LBUTTON then ( if rfl==nil then (_METHODcontainerPreDestroy cont;0) else exec rfl with [] ) else nil ;; proto _UnRollContainer=fun[ObjContainer [[I I I I] [I I I I] I I I ObjNode] I I I I] I;; fun _RollContainer (cont, param, posx, posy, btn, mask) = let param -> [minmaxsize borders rollh rollflag corner] in if (btn&LBUTTON) && (posy [x y w h] in ( if rollflag&TITLEBAR_ROLL_DBLCLICK then _CBcontainerDblClick cont @_UnRollContainer [minmaxsize borders rollh h rollflag corner] else if rollflag&TITLEBAR_ROLL_CURHOVER then _CBcontainerCursorHover cont (mkfun3 mkfun4 mkfun5 mkfun6 @_UnRollContainer 0 LBUTTON 0 0) [minmaxsize borders rollh h rollflag corner] else nil; _CHANGEobjNodeFlags corner OBJ_HIDE 0; _SIZEEXcontainer cont x y w rollh; _CBcontainerClick cont @_ClickContToMoveCont [minmaxsize borders 1 0]; 0 ) else nil ;; fun _UnRollContainer (cont, param, posx, posy, btn, mask) = let param -> [minmaxsize borders rollh inith rollflag corner] in if (btn&LBUTTON) && (posy [x y w _] in ( if rollflag&TITLEBAR_ROLL_DBLCLICK then _CBcontainerDblClick cont @_RollContainer [minmaxsize borders rollh rollflag corner] else if rollflag&TITLEBAR_ROLL_CURHOVER then _CBcontainerCursorLeave cont (mkfun3 mkfun4 mkfun5 mkfun6 @_RollContainer 0 LBUTTON 0 0) [minmaxsize borders rollh rollflag corner] else nil; _CHANGEobjNodeFlags corner OBJ_ENABLE|OBJ_VISIBLE|OBJ_LW_FLEX|OBJ_LH_FLEX 0; _SIZEEXcontainer cont x y w inith; _CBcontainerClick cont @_ClickContToMoveCont [minmaxsize borders 0 0]; 0 ) else nil ;; fun _MaximizeContainer (compCheck, param, state) = let param -> [cont rfl minmaxsize borders rollh corner] in ( if state&CHK_CHECKED then ( _CBcontainerClick cont @_ClickContToMoveCont [minmaxsize borders 1 1]; _CHANGEobjNodeFlags corner OBJ_HIDE 0; _SHOWcontainer cont CONTAINER_MAXIMIZED ) else ( _CBcontainerClick cont @_ClickContToMoveCont [minmaxsize borders 0 0]; _CHANGEobjNodeFlags corner OBJ_ENABLE|OBJ_VISIBLE|OBJ_LW_FLEX|OBJ_LH_FLEX 0; _SHOWcontainer cont CONTAINER_RESTORED ); exec rfl with [] ) ;; fun _MaxContainer (cont, compCheck, posx, posy, btn, mask) = let _GETcompCheckState compCheck -> state in if state == CHK_UNCHECKED then _SETcompCheckState compCheck CHK_CHECKED else _SETcompCheckState compCheck CHK_UNCHECKED ;; /* création d'une barre de titre contrôlant le container dans lequel elle est créée */ fun _CRtitleBar2 (channel, cont, minmaxsize, bar, buttons, corner, rollflag, title, posx, font, colors, flag, transparencyColor) = if bar==nil then nil else let bar -> [barbmp barA barB _barLeft _barRight _barTop _barBottom] in let buttons -> [minimize rflmin maximize rflmax closewin rflclose] in let _GETcontainerPositionSize cont -> [_ _ wCont hCont] in let if barbmp==nil then [0 0 0 0] else [_barLeft _barRight _barTop _barBottom] -> [barLeft barRight barTop barBottom] in let wCont-(barLeft+barRight) -> w in let _GETalphaBitmapSize barbmp -> [barw h] in let if minimize!=nil then _GETalphaBitmapSize minimize else [0 0] -> [minw minh] in let if maximize!=nil then _GETalphaBitmapSize maximize else [0 0] -> [maxw maxh] in let if closewin!=nil then _GETalphaBitmapSize closewin else [0 0] -> [clow cloh] in let _CRbitmap channel w h -> bmp in let [0 0]::[barA barA]::[barB w-(barw-barB)]::[barw w]::nil -> xList in let [0 0]::[h h]::nil -> yList in let _STRETCHalphaBitmap bmp barbmp xList yList -> _ in let _GETstringSize font "|M£fF0!" -> [_ th] in let _CRalphaBitmap channel bmp nil transparencyColor transparencyColor -> abmp in let _CRcompBitmap channel cont nil [barLeft barTop] OBJ_ENABLE|OBJ_VISIBLE|OBJ_MW_FLEX|OBJ_RH_FLEX OBJ_CONTAINER_CLICK|OBJ_CONTAINER_UNCLICK|OBJ_CONTAINER_MOVE|OBJ_CONTAINER_KEYDOWN|OBJ_CONTAINER_KEYUP abmp 0 0 w h -> compBar in let _CONVERTcompBitmapToObjNode compBar -> bmpFather in let _CRcompText channel cont bmpFather [posx+barA (h-th)/2] OBJ_ENABLE|OBJ_VISIBLE|CT_LABEL|OBJ_MW_FLEX|OBJ_RH_FLEX|flag OBJ_CONTAINER_DBLCLICK|OBJ_CONTAINER_CLICK|OBJ_CONTAINER_MOVE|OBJ_CONTAINER_UNCLICK|OBJ_CONTAINER_KEYDOWN|OBJ_CONTAINER_KEYUP w-posx-(barA+TITLEBAR_OFFSET_BUT)-(minw+maxw+clow) h title font colors [0 0] nil nil -> titleText in let [barLeft barRight barTop barBottom] -> borders in let h+barTop+barBottom -> rollh in let if closewin==nil then nil else _CRcompRollOver channel cont bmpFather [w-clow-TITLEBAR_OFFSET_BUT (h-cloh/3)/2] OBJ_ENABLE|OBJ_VISIBLE|OBJ_LW_FLEX|OBJ_RH_FLEX 0 closewin -> compClose in let if maximize==nil then nil else _CRcompCheck channel cont bmpFather [w-maxw/2-clow-TITLEBAR_OFFSET_BUT (h-maxh/3)/2] OBJ_ENABLE|OBJ_VISIBLE|OBJ_LW_FLEX|OBJ_RH_FLEX 0 maximize -> compMax in let if minimize==nil then nil else _CRcompRollOver channel cont bmpFather [w-minw-maxw/2-clow-TITLEBAR_OFFSET_BUT (h-minh/3)/2] OBJ_ENABLE|OBJ_VISIBLE|OBJ_LW_FLEX|OBJ_RH_FLEX 0 minimize -> compMin in /* resize button (corner) */ let _GETalphaBitmapSize corner -> [corw corh] in let _CRcompBitmap channel cont nil [wCont-corw hCont-corh] OBJ_ENABLE|OBJ_VISIBLE|OBJ_LW_FLEX|OBJ_LH_FLEX OBJ_CONTAINER_DBLCLICK|OBJ_CONTAINER_MOVE|OBJ_CONTAINER_UNCLICK|OBJ_CONTAINER_KEYDOWN|OBJ_CONTAINER_KEYUP corner 0 0 corw-1 corh-1 -> compBmp in let _CONVERTcompBitmapToObjNode compBmp -> oCorner in ( /* container callbacks definitions */ if rollflag&TITLEBAR_NO_CALLBACKS then nil else ( _CBcompBitmapResizeResource compBar @_rflResizeCompBar [channel barbmp barA barB transparencyColor]; _CBcompRollOverClick compClose @_CloseContainer [cont rflclose]; _CBcompCheckStateChanged compMax @_MaximizeContainer [cont rflmax minmaxsize borders rollh oCorner]; _CBcompRollOverClick compMin @_MinimizeContainer [cont rflmin]; _CBcompBitmapClick compBmp @_ClickButToResizeCont [cont [minmaxsize borders 0 0]]; _CBcontainerClick cont @_ClickContToMoveCont [minmaxsize borders 0 0]; _CBcontainerUnClick cont @_UnClickContToMoveCont nil; /* * when the mouse come on the container, the container is unroll, * it is roll when it leaves */ if rollflag&TITLEBAR_ROLL_DBLCLICK then _CBcontainerDblClick cont @_RollContainer [minmaxsize borders rollh rollflag oCorner] else if rollflag&TITLEBAR_ROLL_CURHOVER then _CBcontainerCursorLeave cont (mkfun3 mkfun4 mkfun5 mkfun6 @_RollContainer 0 LBUTTON 0 0) [minmaxsize borders rollh rollflag oCorner] else _CBcontainerDblClick cont @_MaxContainer compMax ); [titleText compMin compMax compClose w+barRight+barLeft h+barTop+barBottom] ) ;; /**************************************************************************************** * * TitleBar * -------- * * * * Here is the main function * * PARAMETERS: * * channel * * cont : ObjContainer , container (should be in the 0 0 coordinates of the window * * win ; ObjWindow , the window (if nil this is the container which is controled * by the title bar) * * * minmaxsize: [I I I I] , the minimum size of the window * * * bar: [AlphaBitmap I I I I I I] * [barbmp barA barB barLeft barRight barTop barBottom] * barbmp=ressource graphique pour la barre * qui sera découpée en segments [0,barA-1]::[barA,barB-1]::[barB w] * le segment du milieu sera stretché pour correspondre à la largeur de * la fenêtre. * barLeft, barRight, barTop et barBottom déterminent des distances entre la barre * et le bord de la fenêtre. barBottom n'est utilisé que lorque la fenêtre est enroulée. * * * buttons: [AlphaBitmap fun[]u0 AlphaBitmap fun[]u0 AlphaBitmap fun[]u0], * bitmaps for the minimize button, the maximize/restore button, * the close button. Each of them has a reflex (fun[]u0) * dans le cas du close le reflex est appelé en remplacement de la fermeture de fenêtre * ce qui permet de la cacher et de ne pas la détruire par exemple. * * corner: AlphaBitmap , l'image du coin inférieur droit pour redimensionner la fenêtre. * * rollFlag, I , détermine si et de quelle manière la fenêtre s'enroule pour laisser seulement la * barre de titre apparente. (-les trois flags sont définis en tête du fichier-) * * title: S , title * * posx I , position of the comptext which will contain the title * in order to have a good position on the left (not on the border) * * font: ObjFont , font of the title * * colors: [I I I I] , [ textcolor textcoefftransp shadowflag shadowcolor ] * * flag: I , flag for the text position (see CompText) * * transparencyColor : I , TransparencyColor for blitting GUI bitmaps * * RETURN * *[CompText CompRollOver CompCheck CompRollOver w h] * , compText qui contient le titre (pour pouvoir le modifier en dynamique * , bouton de minimisationde la fenêtre * , ------- maximize/restore * , ------- close * pour leur adjoindre des tooltips par exemple * , w h sont les dimensions de la barre (lorsqu'elle est enroulée) * * ATTENTION: certaines fonctionnalités ne sont pas effectives dans le cas où la fenêtre (win) * est définie. ****************************************************************************************/ fun _CRtitleBar (channel, cont, win, minmaxsize, bar, buttons, corner, rollflag, title, posx, font, colors, flag,transparencyColor) = /* if min and max size are equal, the window is not resizable and the corner bitmap is set to nil */ let minmaxsize -> [minw minh maxw maxh] in let if (minw==maxw && minh==maxh) then nil else corner -> _corner in if win == nil then _CRtitleBar2 channel cont minmaxsize bar buttons _corner rollflag title posx font colors flag transparencyColor else _CRtitleBar1 channel cont win minmaxsize bar buttons _corner rollflag title posx font colors flag transparencyColor ;;