/***************************************************************************************/ /* */ /* SCS editor Version 2 */ /* File : ZoneEdge.pkg */ /* Version : 08 juillet 2000 */ /* Zone edges functions */ /* */ /***************************************************************************************/ /* fun ZONE_FooEdges (zone) = let zone.ZONEorigEdgePositions -> [x1 x2 y1 y2] in let zone.ZONEorigSize -> [w h] in ( _fooS strcatn "Positions:"::(itoa x1)::" "::(itoa x2)::" "::(itoa y1)::" "::(itoa y2)::nil; _fooS strcatn "Sizes:"::(itoa w)::" "::(itoa h)::nil ) ;; */ fun ZONE_VerifyEdge (edge, size, fatherSize, oldedge, oldsize, oldSecondEdge) = if edge < 0 then set edge = 0 else nil; if (size != oldsize) && (size < ZONE_MIN_SIZE) then set size = ZONE_MIN_SIZE else nil; if (fatherSize == nil) then ( if edge >= MAX_RESOLUTION then set edge = oldedge else nil; if size >= MAX_RESOLUTION then set size = oldsize else nil; [edge oldSecondEdge size] ) else ( if ((edge + size) > fatherSize) then if (oldedge != edge) && (edge != 0) && (oldsize == size) /* only edge change */ then set edge = fatherSize - size else/* size change or fatherSize change */ ( set size = fatherSize - edge; if (size < ZONE_MIN_SIZE) then ( set size = ZONE_MIN_SIZE; set edge = fatherSize - size ) else nil; ) else nil; [edge (fatherSize - edge - size) size] ) ;; proto ZONE_ComputNewChildPositions = fun [Zone Site] I;; fun ZONE_ForceSetEdgeAndSize (site, zone, x1, y1, w, h) = let ZONE_GetFatherSize site zone -> [fatherW fatherH] in let zone.ZONEsize -> [oldW oldH] in let zone.ZONEedgePositions -> [oldX oldX2 oldY oldY2] in let ZONE_VerifyEdge x1 w fatherW oldX oldW oldX2 -> [x1 x2 w] in let ZONE_VerifyEdge y1 h fatherH oldY oldH oldY2 -> [y1 y2 h] in ( set zone.ZONEedgePositions = [x1 x2 y1 y2]; if (oldW == w) && (oldH == h) then nil else ( set zone.ZONEsize = [w h]; apply_on_list ZONE_GetChildren site zone @ZONE_ComputNewChildPositions site ) ) ;; fun ZONE_CalcDim (typ,x1,w,x2,l) = let max 1 (if typ&1 then x1 else 0)+(if typ&2 then w else 0)+(if typ&4 then x2 else 0) ->sum in [if typ&1 then (x1*(l-x1-x2-w+sum))/sum else x1 if typ&2 then (w*(l-x1-x2-w+sum))/sum else w];; fun ZONE_CalcResize (typeResize, x1, x2, y1, y2, w, h, fatherW, fatherH ) = let ZONE_CalcDim typeResize x1 w x2 fatherW ->[xx ww] in let ZONE_CalcDim typeResize>>3 y1 h y2 fatherH ->[yy hh] in [xx yy ww hh];; fun ZONE_ComputNewChildPositions (zone, site) = if ZONE_IsPopup zone nil /* no change */ then 0 else let ZONE_GetFatherSize site zone -> [fatherW fatherH] in let zone.ZONEorigEdgePositions -> [x1 x2 y1 y2] in let zone.ZONEorigSize -> [w h] in let ZONE_CalcResize zone.ZONEpositionFlag x1 x2 y1 y2 w h fatherW fatherH -> [xx yy ww hh] in ( ZONE_ForceSetEdgeAndSize site zone xx yy ww hh; 1 ) ;; fun ZONE_SetEdgeAndSize (site, zone, x, y, w, h) = let zone.ZONEedgePositions -> [oldx _ oldy _] in let zone.ZONEsize -> [oldw oldh] in if (x == oldx) && (y == oldy) && (w == oldw) && (h == oldh) then 0 else ( ZONE_ForceSetEdgeAndSize site zone x y w h; let zone.ZONEedgePositions -> [x1 x2 y1 y2] in set zone.ZONEorigEdgePositions = [x1 x2 y1 y2]; let zone.ZONEsize -> [w h] in set zone.ZONEorigSize = [w h]; 1 ) ;; fun ZONE_SetEdge (site, zone, x1, x2, y1, y2) = let ZONE_GetFatherSize site zone -> [fatherW fatherH] in let if fatherW == nil then [200 200] else [(fatherW - x1 - x2) (fatherH - y1 - y2)] -> [w h] in ZONE_SetEdgeAndSize site zone x1 y1 w h ;; fun ZONE_GetBiggestSpace (spacelist, space, fatherSize) = if spacelist == nil then if space == nil then [0 0 0 0] else space else let hd spacelist -> [x1 x2 y1 y2] in let space -> [xx1 xx2 yy1 yy2] in let fatherSize -> [w h] in let (w - x1 - x2) -> diffx in let (h - y1 - y2) -> diffy in let (w - xx1 - xx2) -> diffxx in let (h - yy1 - yy2) -> diffyy in ZONE_GetBiggestSpace (tl spacelist) (if (diffx + diffy) > (diffxx + diffyy) then (hd spacelist) else space) fatherSize ;; fun ZONE_ComputeNewSpaceList (spacelist, edges, fatherSize) = if spacelist == nil then nil else let spacelist -> [space next] in let space -> [xx1 xx2 yy1 yy2] in let edges -> [x1 x2 y1 y2] in let fatherSize -> [w h] in ( listcat listcat listcat listcat (if x1 > xx1 then if x1 < (w - xx2) then if (x1 - xx1) > ZONE_MIN_SIZE then [xx1 (w-x1) yy1 yy2]::nil else nil else space::nil else nil) (if x2 > xx2 then if (w - x2) > xx1 then if (x2 - xx2) > ZONE_MIN_SIZE then [(w-x2) xx2 yy1 yy2]::nil else nil else space::nil else nil) (if y1 > yy1 then if y1 < (h - yy2) then if (y1 - yy1) > ZONE_MIN_SIZE then [xx1 xx2 yy1 (h-y1)]::nil else nil else space::nil else nil) (if y2 > yy2 then if (h - y2) > yy1 then if (y2 - yy2) > ZONE_MIN_SIZE then [xx1 xx2 (h-y2) yy2]::nil else nil else space::nil else nil) (ZONE_ComputeNewSpaceList next edges fatherSize) ) ;; fun ZONE_GetFreePositions (zonelist, spacelist, fatherSize) = if (sizelist zonelist) > 10 then [0 0 0 0] else if zonelist == nil then ZONE_GetBiggestSpace (tl spacelist) (hd spacelist) fatherSize else let zonelist -> [zone next] in let if ZONE_IsPopup zone nil then spacelist else ZONE_ComputeNewSpaceList spacelist zone.ZONEedgePositions fatherSize -> newspacelist in ZONE_GetFreePositions next newspacelist fatherSize ;;