/***************************************************************************************/ /* */ /* SCS editor Version 2 */ /* File : Zone.pkg */ /* Version : 23 Mai 2000 */ /* Zone struct and basic functions */ /* */ /***************************************************************************************/ struct Zone = [ ZONEname : S , /* name */ ZONEorigEdgePositions : [I I I I] , /* original offset in pixels from left, right, top and bottom borders respectively */ ZONEorigSize : [I I] , /* original zone's width and height respectively */ ZONEedgePositions : [I I I I] , /* offset in pixels from left, right, top and bottom borders respectively */ ZONEsize : [I I] , /* zone's width and height respectively */ ZONEcolor : I , /* background color */ ZONEbitmapFile : S , /* background bitmap */ ZONEpositionFlag : I , /* resize behavior flag */ ZONEbitmapFlag : I , /* background bitmap display flag */ ZONEtypeFlag : I , /* zone type flag (zone, inner-document or pop-up document) */ ZONEsideFlag : I /* zone side flag (client or server) */ ] mkZone ;; /* Zone type flags */ var ZONE_ZONE = 1 ;; /* zone is a zone */ var ZONE_INNER = 2 ;; /* zone is an inner-document */ var ZONE_POPUP = 4 ;; /* zone is a pop-up document */ /* Zone side flags */ var SCS_CLIENT = 1 ;; /* zone is on client side */ var SCS_SERVER = 2 ;; /* zone is on server side */ var ZONE_MIN_SIZE = 5;; /* zone is minimal width and height size */ var ZONE_TREE_SIZE = 25;; var MAX_RESOLUTION = 4096;; /* maximum autorized resolution for zone popup position */ /*************************************************************************************** External function prototypes ***************************************************************************************/ proto ASSO_RemoveAssociatedZone = fun [Site Zone] I;; proto ASSO_SearchZoneAssociation = fun [Site Zone] [Association r1];; /*************************************************************************************** Interface function prototypes ***************************************************************************************/ proto ZONE_SetTreeBitmapFile = fun [Zone S] I;; proto ZONE_GetStyle = fun [Zone] [I I I];; proto ZONE_GetFather = fun [Site Zone] Zone;; proto ZONE_GetChildren = fun [Site Zone] [Zone r1];; /*************************************************************************************** Internal functions ***************************************************************************************/ fun ZONE_CompareName (zone, name) = !strcmp zone.ZONEname name ;; fun ZONE_IsPopup (zone, param) = (zone.ZONEtypeFlag) & ZONE_POPUP ;; fun ZONE_IsDoc (zone) = ((zone.ZONEtypeFlag) & ZONE_POPUP) || ((zone.ZONEtypeFlag) & ZONE_INNER) ;; /*************************************************************************************** Check for a name's unicity in a zone list Return value: 1 (success) or 0 (failure) ***************************************************************************************/ fun ZONE_CheckNameUnicity(zoneList,zoneName, otherZone)= if zoneList == nil then 1 else let zoneList -> [zone next] in if !(strcmp zone.ZONEname zoneName) then (zone == otherZone) else ZONE_CheckNameUnicity next zoneName otherZone ;; /*************************************************************************************** Check the zone's position flag verify that there is at least on flag activated by axis Return value: 1 (success) or 0 (failure) ***************************************************************************************/ fun ZONE_CheckPositionFlag (position) = ((position & ZONE_LW_FLEX) || (position & ZONE_RW_FLEX) || (position & ZONE_MW_FLEX)) && ((position & ZONE_LH_FLEX) || (position & ZONE_RH_FLEX) || (position & ZONE_MH_FLEX)) ;; /*************************************************************************************** Check the zone's bitmap flag Return value: 1 (success) or 0 (failure) ***************************************************************************************/ fun ZONE_CheckBitmapFlag (bitmap) = (bitmap == DOCtiled) || (bitmap == DOCstretched) || (bitmap == 0) ;; /*************************************************************************************** Check the zone's type flag Return value: 1 (success) or 0 (failure) ***************************************************************************************/ fun ZONE_CheckTypeFlag (type) = (type == ZONE_ZONE) || (type == ZONE_INNER) || (type == ZONE_POPUP) ;; /*************************************************************************************** Check the zone's side flag Return value: 1 (success) or 0 (failure) ***************************************************************************************/ fun ZONE_CheckSideFlag (side) = (side == SCS_CLIENT) || (side == SCS_SERVER) ;; /*************************************************************************************** Free the zone's bitmap Return value: 1 (success) or 0 (failure) ***************************************************************************************/ fun ZONE_FreeBitmap (zone) = if (zone == nil) || (zone.ZONEbitmapFile == nil) then { ERRORS_AddError 1 16 (_locSCS "errorlabel-5" nil) ; logScsError "ZONE_FreeBitmap" nil "zone bitmap file is nil" 0 } else /* free the bitmap in the bitmap manager */ if !BITMAP_Free zone.ZONEbitmapFile then { ERRORS_AddError 1 16 (_locSCS "errorlabel-5" nil) ; logScsError "ZONE_FreeBitmap" "bitmap file="::zone.ZONEbitmapFile::nil "can't free bitmap" 0 } else ( set zone.ZONEbitmapFile = nil; 1 ) ;; fun ZONE_GetFatherSize (site, zone) = if zone.ZONEtypeFlag == ZONE_POPUP then nil else let ZONE_GetFather site zone -> father in father.ZONEsize ;; fun ZONE_GetRandomColor () = make_rgb (rand&127)+128 (rand&127)+128 (rand&127)+128 ;; /*************************************************************************************** External functions ***************************************************************************************/ /*************************************************************************************** Return the client or server root zone Return value: Zone (success) or nil (failure) ***************************************************************************************/ fun ZONE_CreateRoot (sideFlag) = let if SCS_CLIENT == sideFlag then MOD_DEF_CLIENT else MOD_DEF_SERVER -> name in mkZone [ name [50 nil 50 nil] [400 400] [50 nil 50 nil] [400 400] ZONE_GetRandomColor nil ZONE_RW_FLEX|ZONE_RH_FLEX 0 ZONE_POPUP sideFlag ] ;; /*************************************************************************************** Duplicate a zone Return value: Zone (success) or nil (failure) ***************************************************************************************/ fun ZONE_Duplicate (zone) = mkZone [ zone.ZONEname zone.ZONEorigEdgePositions zone.ZONEorigSize zone.ZONEedgePositions zone.ZONEsize zone.ZONEcolor zone.ZONEbitmapFile zone.ZONEpositionFlag zone.ZONEbitmapFlag zone.ZONEtypeFlag zone.ZONEsideFlag ] ;; fun ZONE_VerifyRootData (line, side) = let line -> [type [name _]] in if !strcmpi type MOD_DEF_DOC then if side == SCS_CLIENT then !strcmpi name MOD_DEF_CLIENT else !strcmpi name MOD_DEF_SERVER else 0 ;; fun ZONE_SetRealBitmapFile (zone, bitmapFile) = set zone.ZONEbitmapFile = bitmapFile; 1 ;; /*************************************************************************************** Internal function change zone type from ZONE to INNER or inversely if needed ***************************************************************************************/ fun ZONE_ChangeType (site, zone) = if zone.ZONEtypeFlag == ZONE_POPUP then nil else if ((ZONE_GetChildren site zone) == nil) && (zone.ZONEbitmapFile == nil) then set zone.ZONEtypeFlag = ZONE_ZONE else ( if (ASSO_SearchZoneAssociation site zone) != nil then ( ERRORS_AddError 1 36 (_locSCS "errorlabel-18" nil); ASSO_RemoveAssociatedZone site zone ) else nil; set zone.ZONEtypeFlag = ZONE_INNER ) ;; /*************************************************************************************** Set zone new color Return value: 1 (success) or 0 (failure) ***************************************************************************************/ fun ZONE_NewSetColor (zone, color) = set zone.ZONEcolor = if color == nil then ZONE_GetRandomColor else color ;; fun ZONE_ParseDOC (zone, line) = let line -> [flag [typeResize [xa1 [ya1 [xa2 [ya2 [wa [ha [bitmap [bitmapFlaga [color _]]]]]]]]]]] in ( set zone.ZONEtypeFlag = (if (atoi flag) & DOCpopup then ZONE_POPUP else ZONE_INNER); set zone.ZONEpositionFlag = atoi typeResize; if !strcmp bitmap "_" then nil else ZONE_SetRealBitmapFile zone bitmap; set zone.ZONEbitmapFlag = atoi bitmapFlaga; set zone.ZONEorigSize = [(atoi wa) (atoi ha)]; set zone.ZONEsize = [(atoi wa) (atoi ha)]; let if !strcmp xa2 "_" then nil else (atoi xa2) -> x2 in let if !strcmp ya2 "_" then nil else (atoi ya2) -> y2 in ( set zone.ZONEorigEdgePositions = [(atoi xa1) x2 (atoi ya1) y2]; set zone.ZONEedgePositions = [(atoi xa1) x2 (atoi ya1) y2] ); ZONE_NewSetColor zone if !strcmp color "_" then nil else (atoi color) ) ;; fun ZONE_ParseZONE (zone, line) = let line -> [typeResize [xa1 [ya1 [xa2 [ya2 [wa [ha [color _]]]]]]]] in ( set zone.ZONEtypeFlag = ZONE_ZONE; set zone.ZONEpositionFlag = atoi typeResize; set zone.ZONEorigSize = [(atoi wa) (atoi ha)]; set zone.ZONEsize = [(atoi wa) (atoi ha)]; set zone.ZONEorigEdgePositions = [(atoi xa1) (atoi xa2) (atoi ya1) (atoi ya2)]; set zone.ZONEedgePositions = [(atoi xa1) (atoi xa2) (atoi ya1) (atoi ya2)]; ZONE_NewSetColor zone if !strcmp color "_" then nil else (atoi color) ) ;; fun ZONE_SaveNilInt (data) = if data == nil then "_" else (itoa data) ;; fun ZONE_GetDataDef (zone) = let zone.ZONEedgePositions -> [x1 x2 y1 y2] in let zone.ZONEsize -> [w h] in if zone.ZONEtypeFlag == ZONE_ZONE then (zone.ZONEname):: (itoa zone.ZONEpositionFlag):: (ZONE_SaveNilInt x1):: (ZONE_SaveNilInt y1):: (ZONE_SaveNilInt x2):: (ZONE_SaveNilInt y2):: (ZONE_SaveNilInt w):: (ZONE_SaveNilInt h):: (itoa zone.ZONEcolor):: nil else (zone.ZONEname):: (if zone.ZONEtypeFlag == ZONE_POPUP then itoa DOCpopup else "0"):: (itoa zone.ZONEpositionFlag):: (ZONE_SaveNilInt x1):: (ZONE_SaveNilInt y1):: (ZONE_SaveNilInt x2):: (ZONE_SaveNilInt y2):: (ZONE_SaveNilInt w):: (ZONE_SaveNilInt h):: (if zone.ZONEbitmapFile == nil then "_" else zone.ZONEbitmapFile):: (itoa zone.ZONEbitmapFlag):: (itoa zone.ZONEcolor):: nil ;;