/***************************************************************************************/ /* */ /* SCS editor Version 2 */ /* File : LinksCreation.pkg */ /* Version : 27 juin 2000 */ /* Modules Graph links creations */ /* */ /***************************************************************************************/ /* ************************************************************** */ /* garbage collector on link rounds */ /* ************************************************************** */ typeof GCresources = [[I AlphaBitmap] r1];; typeof GCresourcesClicked = [[I AlphaBitmap] r1];; fun LINKS_GC_GetResource( resources, size )= if resources == nil then nil else let resources -> [[tested_size alphaBmp] next] in if tested_size == size then alphaBmp else LINKS_GC_GetResource next size ;; /* ************************************************************** */ /* internal creation utilities functions */ /* ************************************************************** */ fun LINKS_CreateLinkRoundResourceDrawCircle( bitmap, x, y, size, color, fill )= _DRAWcircle bitmap x y size DRAW_SOLID 1 /* MAT ICI en parametre */ color DRAW_SOLID if fill then color else GD_DEFAULT_BACKGROUNDCOLOR ;; /* multiplication is 1 for 1st raw of CompCheck and 3th for second raw.... */ fun LINKS_DrawLinkRoundResource( bitmap, size, multiplication, color )= LINKS_CreateLinkRoundResourceDrawCircle bitmap multiplication*size size size color 0; LINKS_CreateLinkRoundResourceDrawCircle bitmap multiplication*size 3*size size color 1; LINKS_CreateLinkRoundResourceDrawCircle bitmap multiplication*size 5*size size color 1; LINKS_CreateLinkRoundResourceDrawCircle bitmap multiplication*size 7*size size 0xFFFFFF 1 ;; fun LINKS_CreateLinkRoundResourceDrawText( bitmap, x, y, text, font, color )= _DRAWtext bitmap font x y TD_CENTER color text ;; fun LINKS_DrawLinkRoundSize( bitmap, size, multiplication, text, font, color )= LINKS_CreateLinkRoundResourceDrawText bitmap multiplication*size size/2+1 text font color; LINKS_CreateLinkRoundResourceDrawText bitmap multiplication*size 3*size-size/2 text font color; LINKS_CreateLinkRoundResourceDrawText bitmap multiplication*size 5*size-size/2 text font color ;; /* fun DEBUG_WriteBmp( bitmap )= let _FILEbitmap bitmap -> str in _storepack str "mat_test.bmp" ;; */ fun LINKS_CreateLinkRoundResource( Channel, transparencyColor, size, RoundSize, mode )= let _FILLbitmap _CRbitmap Channel RoundSize*2 RoundSize*4 transparencyColor -> bitmap in ( if mode == LINK_HOVER then ( let THEME_getInfos GD_THEME "MODULES_GRAPH_LINKS_COLOR" -> [c1 [c2 [c3 _]]] in let make_rgb atoi c1 atoi c2 atoi c3 -> GraphLinkcolor in let THEME_getInfos GD_THEME "MODULES_GRAPH_LINKS_HOVER_COLOR" -> [c4 [c5 [c6 _]]] in let make_rgb atoi c4 atoi c5 atoi c6 -> GraphLinkHovercolor in let THEME_getInfos GD_THEME "MODULES_GRAPH_LINKS_TEXT_COLOR" -> [c7 [c8 [c9 _]]] in let make_rgb atoi c7 atoi c8 atoi c9 -> GraphLinkTextcolor in let THEME_getInfos GD_THEME "MODULES_GRAPH_LINKS_TEXT_HOVER_COLOR" -> [c10 [c11 [c12 _]]] in let make_rgb atoi c10 atoi c11 atoi c12 -> GraphLinkTextHovercolor in ( LINKS_DrawLinkRoundResource bitmap RoundSize / 2 1 GraphLinkcolor; LINKS_DrawLinkRoundResource bitmap RoundSize / 2 3 GraphLinkHovercolor; LINKS_DrawLinkRoundSize bitmap RoundSize / 2 1 itoa size scsgui.SCSGUIsmallFont GraphLinkTextcolor; LINKS_DrawLinkRoundSize bitmap RoundSize / 2 3 itoa size scsgui.SCSGUIsmallFont GraphLinkTextHovercolor; ); ) else ( let THEME_getInfos GD_THEME "MODULES_GRAPH_LINKS_SELECTED_COLOR" -> [c1 [c2 [c3 _]]] in let make_rgb atoi c1 atoi c2 atoi c3 -> GraphLinkSelectcolor in let THEME_getInfos GD_THEME "MODULES_GRAPH_LINKS_HOVER_SELECTED_COLOR" -> [c4 [c5 [c6 _]]] in let make_rgb atoi c4 atoi c5 atoi c6 -> GraphLinkHoverSelectcolor in let THEME_getInfos GD_THEME "MODULES_GRAPH_LINKS_TEXT_SELECTED_COLOR" -> [c7 [c8 [c9 _]]] in let make_rgb atoi c7 atoi c8 atoi c9 -> GraphLinkTextSelectcolor in let THEME_getInfos GD_THEME "MODULES_GRAPH_LINKS_TEXT_HOVER_SELECTED_COLOR" -> [c10 [c11 [c12 _]]] in let make_rgb atoi c10 atoi c11 atoi c12 -> GraphLinkTextHoverSelectcolor in ( LINKS_DrawLinkRoundResource bitmap RoundSize / 2 1 GraphLinkSelectcolor; LINKS_DrawLinkRoundResource bitmap RoundSize / 2 3 GraphLinkHoverSelectcolor; LINKS_DrawLinkRoundSize bitmap RoundSize / 2 1 itoa size scsgui.SCSGUIsmallFont GraphLinkTextSelectcolor; LINKS_DrawLinkRoundSize bitmap RoundSize / 2 3 itoa size scsgui.SCSGUIsmallFont GraphLinkTextHoverSelectcolor; ); ); /* DEBUG_WriteBmp bitmap;*/ _CRalphaBitmap Channel bitmap nil /* no alpha channel */ nil transparencyColor ) ;; /* type is 0: normal links, 1: clicked links */ /* MAT ICI gestion du GC sur les ressources un peu crade */ fun LINKS_GetLinkRoundResource( Channel, type, transparencyColor, size, RoundSize, mode )= let LINKS_GC_GetResource if type then GCresourcesClicked else GCresources size -> round in if round != nil then round else let LINKS_CreateLinkRoundResource Channel transparencyColor size RoundSize mode -> round in ( if type then set GCresourcesClicked = [size round]::GCresourcesClicked else set GCresources = [size round]::GCresources; round ) ;; fun LINKS_CreateLinkRoundComputePosition( node1, node2, half_width, half_height )= if node1 == node2 then let _GETobjNodePositionSizeInFatherRef node1 -> [x1 y1 w1 h1] in [x1-2*half_width/3 y1-2*half_height/3] else if node2 == nil then let _GETobjNodePositionSizeInFatherRef node1 -> [x1 y1 w1 h1] in if x1 < y1 then [x1/2-half_width y1+h1/2-half_height] else [x1+w1/2-half_width y1/2-half_height] else if node1 == nil then let _GETobjNodePositionSizeInFatherRef node2 -> [x2 y2 w2 h2] in if x2 < y2 then [x2/2-half_width y2+h2/2-half_height] else [x2+w2/2-half_width y2/2-half_height] else let _GETobjNodePositionSizeInFatherRef node1 -> [x1 y1 w1 h1] in let _GETobjNodePositionSizeInFatherRef node2 -> [x2 y2 w2 h2] in [(x1+x2)/2+(w1+w2)/4-half_width (y1+y2)/2+(h1+h2)/4-half_height] ;; fun LINKS_ChangeTooltip(mode, links)= lineBuildSeparator (LINK_PrintList links @LINK_Print) "\n" ;; fun LINKS_CreateLinkRound( Channel, cont, ModulesViewed, parent, check1, check2, links, mode )= let THEME_getInfos GD_THEME "MODULES_GRAPH_LINKS_ROUND_SIZE" -> [p1 _] in let atoi p1 -> GraphRoundSize in let sizelist links -> linksNumber in if linksNumber <= 0 then nil else let LINKS_GetLinkRoundResource Channel (mode == LINK_SELECT)/* MAT ICI TMP */0xF0F0F0 linksNumber GraphRoundSize mode -> alphaBmp in /* MAT ICI a mettre en parametres */ let _GETalphaBitmapSize alphaBmp -> [w3 h3] in let _CRcompCheck Channel cont parent LINKS_CreateLinkRoundComputePosition _CONVERTcompCheckToObjNode check1 _CONVERTcompCheckToObjNode check2 w3/4 h3/8 if (PARAMS_GetI SCSparameters "MODULES_GRAPH_DRAW_MODE") && (mode != LINK_SELECT) then OBJ_ENABLE|OBJ_HIDE|ROL_MASK else OBJ_ENABLE|OBJ_VISIBLE|ROL_MASK OBJ_CONTAINER_MOVE|OBJ_CONTAINER_UNCLICK|OBJ_KEYBOARD alphaBmp -> check in ( _CBcompCheckUnClick check @LINKS_SelectLinks [links ModulesViewed]; TOOLTIP_DynamicLink cont _CONVERTcompCheckToObjNode check scsgui.SCSGUIdynamicToolTip mkfun1 mkfun2 @LINKS_ChangeTooltip links mode; /* ajout de l'info-bulles */ check ) ;; fun LINKS_CreateLink( Channel, cont, ModulesViewed, parent, check1, module1, check2, module2, mode )= let MODULE_GetLinksByModule module1 module2 -> links in if links != nil then let LINKS_CreateLinkRound Channel cont ModulesViewed parent check1 check2 links mode -> linkCheck in [ linkCheck check2 module2 ] else nil ;; fun LINKS_MutateExistingLinkRound( module, links, newLinkCheck )= if links == nil then nil else let links -> [link next] in let link -> [linkCheck _ module2] in if module == module2 then mutate link <- [newLinkCheck _ _] else LINKS_MutateExistingLinkRound module next newLinkCheck ;; fun LINKS_MutateLinkRound2( Channel, cont, ModulesViewed, check1, module1, modules, links, mode, reversed, linkDestroyed )= if links == nil then linkDestroyed else let links -> [link next] in let link -> [linkCheck check2 module2] in if ((!is_in_list modules module2) && (!is_in_list modules module1)) then ( /* creation du nouveau check pour un groupe de liens */ let LINKS_CreateLinkRound Channel cont ModulesViewed ModulesViewed.MODVIEWrootNode check1 check2 MODULE_GetLinksByModule module1 module2 mode -> newLinkCheck in ( _DScompCheck linkCheck; /* mutation apres destruction de l'ancien check pour un groupe de liens */ let if reversed then MODULESVIEW_GetLinksByModule ModulesViewed module2 else MODULESVIEW_GetReversedLinksByModule ModulesViewed module2 -> reversedLinks in LINKS_MutateExistingLinkRound module1 reversedLinks newLinkCheck; mutate link <- [newLinkCheck _ _]; if (ModulesViewed.MODVIEWselectedLink != nil) && (linkCheck == ModulesViewed.MODVIEWselectedLink) then ( set ModulesViewed.MODVIEWselectedLink = newLinkCheck; _SETcompCheckState newLinkCheck CHK_CHECKED ) else nil; LINKS_MutateLinkRound2 Channel cont ModulesViewed check1 module1 modules next mode reversed linkDestroyed || (newLinkCheck == nil) ) ) else LINKS_MutateLinkRound2 Channel cont ModulesViewed check1 module1 modules next mode reversed linkDestroyed ;; fun LINKS_MutateLinkRound( Channel, cont, ModulesViewed, check1, module1, modules, links, mode, reversed )= LINKS_MutateLinkRound2 Channel cont ModulesViewed check1 module1 modules links mode reversed 0;; fun LINKS_SetRoundLinksState( ModulesViewed, links, modules, state, appear, drawmode )= if links == nil then nil else let links -> [[linkCheck _ module] next] in ( /* make CompCheck appear or disappear if drawing mode requires */ if drawmode && !(is_in_list modules module) then if appear then _CHANGEobjNodeFlags _CONVERTcompCheckToObjNode linkCheck OBJ_ENABLE|OBJ_VISIBLE 0 else _CHANGEobjNodeFlags _CONVERTcompCheckToObjNode linkCheck OBJ_ENABLE|OBJ_HIDE 0 else nil; LINKS_SetRoundLinksState ModulesViewed next modules state appear drawmode; /* set CompCheck to new state */ if linkCheck != ModulesViewed.MODVIEWselectedLink then _SETcompCheckState linkCheck state else nil ) ;; /* ************************************************************** */ /* external usable functions */ /* ************************************************************** */ /* creates all links rounds (CompCheck) and updates existing links; returns updated links note: buttons are created with a 'nil' parent Channel : Chn container : ObjContainer parent : ObjNode check1 : CompCheck module1 : Module modules : [[CompCheck Module [[CompCheck CompCheck Module] r1] r1] previously links to update */ fun LINKS_CreateLinks( Channel, cont, ModulesViewed, parent, check1, module1, modules )= if modules == nil then /* create link from a module to itself */ let LINKS_CreateLink Channel cont ModulesViewed parent check1 module1 check1 module1 LINK_HOVER -> link in if link == nil then nil else link::nil else let modules -> [[check2 module2 _] next] in let LINKS_CreateLink Channel cont ModulesViewed parent check1 module1 check2 module2 LINK_HOVER -> links in if links != nil then links::LINKS_CreateLinks Channel cont ModulesViewed parent check1 module1 next else LINKS_CreateLinks Channel cont ModulesViewed parent check1 module1 next ;; /* changed state of links rounds for a module referenced by its associated button (CompCheck) */ fun LINKS_SetLinksStateByButton( ModulesViewed, btn, modules, state, appear, drawmode )= let MODULESVIEW_GetLinksByButton ModulesViewed btn -> links in LINKS_SetRoundLinksState ModulesViewed links modules state appear drawmode; let MODULESVIEW_GetReversedLinksByButton ModulesViewed btn -> links in LINKS_SetRoundLinksState ModulesViewed links modules state appear drawmode ;; /* changed state of links rounds for a module AND mutates round links type ('mode' parameter) */ /* mode is one of LINK_HOVER or LINK_SELECT */ /* type is one of REFLEX_UNSELECTION or REFLEX_SELECTION */ fun LINKS_SetLinksStateByModule( ModulesViewed, Channel, cont, module, modules, state, appear, drawmode, mode, top, type )= let MODULESVIEW_GetButton ModulesViewed module -> check in ( let search_in_list ModulesViewed.MODVIEWmodules @MODULESVIEW_SearchByModule module -> moduleLinks in let moduleLinks -> [_ _ links] in ( LINKS_MutateLinkRound Channel cont ModulesViewed check module if type == REFLEX_UNSELECTION then modules else nil links mode 0; LINKS_SetRoundLinksState ModulesViewed links modules state appear drawmode ); let search_in_list ModulesViewed.MODVIEWreversedModules @MODULESVIEW_SearchByModule module -> moduleLinks in let moduleLinks -> [_ _ links] in ( LINKS_MutateLinkRound Channel cont ModulesViewed check module if type == REFLEX_UNSELECTION then modules else nil links mode 1; LINKS_SetRoundLinksState ModulesViewed links modules state appear drawmode ); if top then _TOPobjNode _CONVERTcompCheckToObjNode check else nil ) ;; fun LINKS_SearchModuleByLinks( link, module1 )= let link -> [_ _ module2] in module1 == module2 ;; fun LINKS_FlushLinksByModulesGetMode( module1, module2, modules )= if (is_in_list modules module1) || (is_in_list modules module2) then LINK_SELECT else LINK_HOVER ;; /* rebuilds links rounds for a module */ /* returns 1 if link round has been created, 0 otherwise */ fun LINKS_FlushLinksByModules( ModulesViewed, Channel, cont, module1, module2, modules, appear, drawmode )= let LINKS_FlushLinksByModulesGetMode module1 module2 modules -> mode in let search_in_list ModulesViewed.MODVIEWmodules @MODULESVIEW_SearchByModule module1 -> infos1 in let infos1 -> [check1 _ links1] in let search_in_list links1 @LINKS_SearchModuleByLinks module2 -> link in if link != nil then ( LINKS_MutateLinkRound Channel cont ModulesViewed check1 module1 nil link::nil mode 0; if module1 == module2 then nil else let search_in_list ModulesViewed.MODVIEWreversedModules @MODULESVIEW_SearchByModule module2 -> [check2 _ links2] in let search_in_list links2 @LINKS_SearchModuleByLinks module1 -> link in LINKS_MutateLinkRound Channel cont ModulesViewed check2 module2 nil link::nil mode 1 ) else let search_in_list ModulesViewed.MODVIEWmodules @MODULESVIEW_SearchByModule module2 -> [check2 _ links2] in let search_in_list links2 @LINKS_SearchModuleByLinks module1 -> link in if link != nil then ( LINKS_MutateLinkRound Channel cont ModulesViewed check2 module2 nil link::nil mode 0; if module1 == module2 then nil else let search_in_list ModulesViewed.MODVIEWreversedModules @MODULESVIEW_SearchByModule module1 -> [check1 _ links1] in let search_in_list links1 @LINKS_SearchModuleByLinks module2 -> link in LINKS_MutateLinkRound Channel cont ModulesViewed check1 module1 nil link::nil mode 1 ) else /* first link between modules, we have to create its graphical components ! */ let LINKS_CreateLink Channel cont ModulesViewed ModulesViewed.MODVIEWrootNode check1 module1 check2 module2 mode -> link in let link -> [linkCheck _ _] in ( mutate infos1 <- [_ _ link::links1]; if module1 == module2 then nil else let search_in_list ModulesViewed.MODVIEWreversedModules @MODULESVIEW_SearchByModule module2 -> infos2 in let infos2 -> [_ _ links2] in if infos2 != nil then ( mutate infos2 <- [_ _ [linkCheck check1 module1]::links2]; nil ) else set ModulesViewed.MODVIEWreversedModules = [check2 module2 [linkCheck check1 module1]::nil]::ModulesViewed.MODVIEWreversedModules; 1 ) ;; /* creates a CompBitmap for 2 purposes : . to contain graph lines drawings . to avoid having round links going under modules (round links CompCheck created as brothers of this CompBitmap and modules CompCheck as sons) */ fun LINKS_CreateLinesBitmap( Channel, cont, parent, width, height )= let _CRalphaBitmap Channel _CRbitmap Channel width height nil 0x000000 /* MAT ICI mettre en parametres: couleur de transparence */ 0x000000 /* MAT ICI mettre en parametres: couleur de transparence */ -> alphaBmp in [ alphaBmp _CONVERTcompBitmapToObjNode _CRcompBitmap Channel cont parent [0 0] OBJ_VISIBLE|OBJ_ENABLE OBJ_CONTAINER_CLICK|OBJ_CONTAINER_UNCLICK|OBJ_CONTAINER_MOVE|OBJ_CONTAINER_KEYDOWN|OBJ_CONTAINER_DBLCLICK alphaBmp 0 0 width height ] ;;