/***************************************************************************************/ /* */ /* SCS editor Version 2 */ /* File : ModulesManipulation.pkg */ /* Version : 27 juin 2000 */ /* Modules Graph modules user interface handling */ /* */ /***************************************************************************************/ /* ************************************************************** */ /* link creation pending */ /* ************************************************************** */ fun MODULESMOVE_LinksCreationDrawing(cont,param,rect)= let param -> [ModulesViewed posx posy] in let _GETcontainerMap cont -> buffer in LINKS_LinksCreationDrawing buffer ModulesViewed posx posy ;; fun MODULESMOVE_DrawLinkPending( container, ModulesViewed, posx, posy, mask )= _CBcontainerPostRender container @MODULESMOVE_LinksCreationDrawing [ModulesViewed posx posy]; _PAINTcontainer container ;; /* ************************************************************** */ /* workspace scrolling */ /* ************************************************************** */ /* moves an ObjNode node : ObjNode to move horizontal : moving step in pixel (positive or negative) vertical : moving step in pixel (positive or negative) minX : minimum possible value for x position maxX : maximum possible value for x position minY : minimum possible value for y position maxY : maximum possible value for y position */ fun MODULESMOVE_MoveNode( node, horizontal, vertical, minX, maxX, minY, maxY )= let _GETobjNodePositionSizeInContainerRef node -> [x y _ _] in _CHANGEobjNodeCoordinates node [ min maxX max minX x + horizontal min maxX max minY y + vertical ] 0 ;; fun MODULESMOVE_ScrollWorkspace( container, param, posx, posy, mask )= let param -> [ModulesViewed diffx diffy] in let _GETcontainerPositionSize container -> [_ _ Width Height] in let ModulesViewed.MODVIEWlinksLines -> [_ rootNode] in let _GETobjNodePositionSizeInContainerRef rootNode -> [X Y width height] in ( MODULESMOVE_MoveNode ModulesViewed.MODVIEWrootNode (posx-X-diffx) (posy-Y-diffy) (Width-width) 0 (Height-height) 0; _CBcontainerPostRender container @MODULESMOVE_LinksCreationDrawing [ModulesViewed posx posy]; _PAINTcontainer container ) ;; /* ************************************************************** */ /* module selection and move handling */ /* ************************************************************** */ /* handles all links redrawing hoverModule : module under mouse (nil if none) clear : 0 or 1 indicating if buffer should be erased */ /* MAT ICI ne redessiner que les liens necessaires et pas tous systematiquement */ fun MODULESMOVE_DrawLinks( ModulesViewed, hoverModule, clear )= /* let ModulesViewed.MODVIEWlinksCreation -> [nodes _ ] in */ let ModulesViewed.MODVIEWlinksLines -> [alphaBmp _] in let _GETalphaBitmaps alphaBmp -> [buffer _] in ( if (clear || PARAMS_GetI SCSparameters "MODULES_GRAPH_DRAW_MODE")/* && nodes == nil*/ then let _GETalphaBitmapTransparency alphaBmp -> transparency in _FILLbitmap buffer transparency else nil; LINKS_DrawAllLinks buffer ModulesViewed.MODVIEWmodules hoverModule SELECT_GetModule REFLEX_PRIORITY_ONE ) ;; fun MODULESMOVE_DrawLinksModule( ModulesViewed, check, module, hoverModule, selectedModules )= let ModulesViewed.MODVIEWlinksLines -> [alphaBmp _] in let _GETalphaBitmaps alphaBmp -> [buffer _] in ( LINKS_DrawLinks buffer check module MODULESVIEW_GetLinksByModule ModulesViewed module hoverModule selectedModules; LINKS_DrawLinks buffer check module MODULESVIEW_GetReversedLinksByModule ModulesViewed module hoverModule selectedModules ) ;; fun MODULESMOVE_ModuleMove( node, posx, posy )= _CHANGEobjNodeCoordinates node [posx posy] 0 ;; fun MODULESMOVE_LinksMove( links, node1 )= if links == nil then nil else let links -> [[linkCheck check2 _] next] in if linkCheck != nil then let _CONVERTcompCheckToObjNode linkCheck -> node in let _GETobjNodePositionSizeInFatherRef node -> [_ _ w3 h3] in ( MODULESMOVE_LinksMove next node1; _CHANGEobjNodeCoordinates node LINKS_CreateLinkRoundComputePosition node1 _CONVERTcompCheckToObjNode check2 w3/2 h3/2 0 ) else MODULESMOVE_LinksMove next node1 ;; fun MODULESMOVE_CheckWorkspaceScroll( container, ModulesViewed, node )= let _GETobjNodePositionSizeInContainerRef node -> [x y width height] in let _GETcontainerPositionSize container -> [_ _ Width Height] in ( if y + height > Height then MODULESMOVE_MoveNode ModulesViewed.MODVIEWrootNode 0 (Height-y-height) (width-Width) 0 (height-Height) 0 else if y < 0 then MODULESMOVE_MoveNode ModulesViewed.MODVIEWrootNode 0 (-y) (width-Width) 0 (height-Height) 0 else nil; if x + width > Width then MODULESMOVE_MoveNode ModulesViewed.MODVIEWrootNode (Width-x-width) 0 (width-Width) 0 (height-Height) 0 else if x < 0 then MODULESMOVE_MoveNode ModulesViewed.MODVIEWrootNode (-x) 0 (width-Width) 0 (height-Height) 0 else nil ) ;; proto MODULESMOVE_ContainerUnClick = fun [ObjContainer [ModulesView Module I I] I I I I] I;; fun MODULESMOVE_ContainerUnClick( container, param, posx, posy, btn, mask )= let param -> [ModulesViewed module posXmod posYmod] in /* Module drag disabled */ if btn != 2 then ( if module != nil then ( MODULE_SetPosition module [posXmod posYmod]; _CBcontainerUnClick container @MODULESMOVE_ContainerUnClick [ModulesViewed nil nil nil]; ) else nil; _CBcontainerCursorMove container @MODULESMOVE_DrawLinkPending ModulesViewed ) else nil; 0 ;; fun MODULESMOVE_ContainerMove( container, param, posx, posy, mask )= let param -> [ModulesViewed module handledNode diffx diffy] in let ModulesViewed.MODVIEWlinksLines -> [_ rootNode] in let _GETobjNodePositionSizeInContainerRef rootNode -> [X Y width height] in let _GETobjNodePositionSizeInContainerRef handledNode -> [_ _ w h] in ( /* module position */ let max 0 min width-w posx-diffx-X -> posX in let max 0 min height-h posy-diffy-Y -> posY in ( MODULESMOVE_ModuleMove handledNode posX posY; _CBcontainerUnClick container @MODULESMOVE_ContainerUnClick [ModulesViewed module posX posY]; ); /* check if module gets outside of current view */ MODULESMOVE_CheckWorkspaceScroll container ModulesViewed handledNode; /* MAT ICI optimisation possible sur les recherches dans ModulesViewed en les regroupant (MODULESVIEW_GetLinksByButton et MODULESMOVE_DrawLinks) */ /* links bubbles positions */ let MODULESVIEW_GetLinksByButton ModulesViewed handledNode -> links in MODULESMOVE_LinksMove links handledNode; let MODULESVIEW_GetReversedLinksByButton ModulesViewed handledNode -> links in MODULESMOVE_LinksMove links handledNode; /* to redraw links */ MODULESMOVE_DrawLinks ModulesViewed module 1; _CBcontainerPostRender container @MODULESMOVE_LinksCreationDrawing [ModulesViewed posx posy]; _PAINTcontainer container ) ;; fun MODULESMOVE_SelectModule( ModulesViewed, module, clearSelection )= if clearSelection then SELECT_NewModule module::nil REFLEX_PRIORITY_ONE else SELECT_AddModule module::nil REFLEX_PRIORITY_ONE ;; fun MODULESMOVE_UnselectModule( ModulesViewed, module, clearSelection )= if clearSelection then SELECT_ClearModule REFLEX_PRIORITY_ONE else let MODULE_GetFather SELECT_GetSite module -> father in SELECT_RemoveModule module::nil if father != nil then father::nil else module::nil REFLEX_PRIORITY_ONE ;; fun MODULESMOVE_ContainerClick( container, param, posx, posy, btn, mask )= let param -> [cont ModulesViewed module handledNode] in ( _CBcontainerUnClick cont @MODULESMOVE_ContainerUnClick [ModulesViewed nil nil nil]; if btn == 2 then ( /* On right button click create links */ let SELECT_GetModule REFLEX_PRIORITY_ONE -> modules in if ModulesViewed.MODVIEWlinksCreation == nil then if is_in_list modules module then LINKS_StartCreation container ModulesViewed modules posx posy else LINKS_StartCreation container ModulesViewed module::nil posx posy else if is_in_list modules module then LINKS_FinishCreation container ModulesViewed modules posx posy else LINKS_FinishCreation container ModulesViewed module::nil posx posy; _CBcontainerCursorMove container @MODULESMOVE_DrawLinkPending ModulesViewed ) else ( /* MAT ICI CURRENT: pour gerer la deselection d'un module parmi une selection multiple */ if !is_in_list SELECT_GetModule REFLEX_PRIORITY_ONE module then /* Module is added to selection */ MODULESMOVE_SelectModule ModulesViewed module !(mask & MK_CONTROL) else if (sizelist SELECT_GetModule REFLEX_PRIORITY_ONE) > 1 then MODULESMOVE_UnselectModule ModulesViewed module 0 else nil; /* Module drag enabled */ if handledNode != nil then /* module will be moved */ let _GETobjNodePositionSizeInContainerRef handledNode -> [x y _ _] in _CBcontainerCursorMove container @MODULESMOVE_ContainerMove [ModulesViewed module handledNode posx-x posy-y] else /* workspace will be moved */ let ModulesViewed.MODVIEWlinksLines -> [_ rootNode] in let _GETobjNodePositionSizeInContainerRef rootNode -> [x y _ _] in _CBcontainerCursorMove container @MODULESMOVE_ScrollWorkspace [ModulesViewed posx-x posy-y] ) ) ;; /* ************************************************************** */ /* editor launch */ /* ************************************************************** */ /* callback for dblclick on a module: runs the editor */ fun MODULESMOVE_RunEditor( cont, module, posx, posy, btn, mask )= if (btn == 1) && !(mask & MK_CONTROL) then EDITORSMANAGER_RunEditor scsgui.SCSGUIeditorsManager SELECT_GetSite module else nil ;; /* ************************************************************** */ /* mouse entering and leaving a module */ /* ************************************************************** */ /* callback for movein on a module: sets the current hover module */ fun MODULESMOVE_SetModule( button, param, posx, posy, mask )= let param -> [cont ModulesViewed module] in ( /* MAT ICI optimisation possible sur les recherches dans ModulesViewed en les regroupant (LINKS_SetLinksStateByButton et MODULESMOVE_DrawLinks) */ /* set all round links to hover */ let SELECT_GetModule REFLEX_PRIORITY_ONE -> modules in ( let !(is_in_list modules module) && PARAMS_GetI SCSparameters "MODULES_GRAPH_DRAW_MODE" -> drawmode in LINKS_SetLinksStateByButton ModulesViewed _CONVERTcompCheckToObjNode button modules CHK_CHECKED 1 drawmode; /* to redraw links */ MODULESMOVE_DrawLinksModule ModulesViewed button module module modules; _PAINTcontainer cont ); _CBcontainerClick cont @MODULESMOVE_ContainerClick [cont ModulesViewed module _CONVERTcompCheckToObjNode button]; _CBcontainerDblClick cont @MODULESMOVE_RunEditor module; set ModulesViewed.MODVIEWhoverModule = module ) ;; /* callback for moveout on a module: unsets the current hover module */ fun MODULESMOVE_UnsetModule( button, param, posx, posy, mask )= let param -> [cont ModulesViewed module] in ( /* MAT ICI optimisation possible sur les recherches dans ModulesViewed en les regroupant (LINKS_SetLinksStateByButton et MODULESMOVE_DrawLinks) */ /* set all round links to normal */ let SELECT_GetModule REFLEX_PRIORITY_ONE -> modules in ( let !(is_in_list modules module) && PARAMS_GetI SCSparameters "MODULES_GRAPH_DRAW_MODE" -> drawmode in ( LINKS_SetLinksStateByButton ModulesViewed _CONVERTcompCheckToObjNode button modules CHK_UNCHECKED 0 drawmode; /* to redraw links */ if drawmode then MODULESMOVE_DrawLinks ModulesViewed nil 1 else MODULESMOVE_DrawLinksModule ModulesViewed button module nil modules ); _PAINTcontainer cont ); _CBcontainerClick cont @MODULESMOVE_ContainerClick [cont ModulesViewed MODULE_GetFather SELECT_GetSite module nil]; _CBcontainerUnClick cont @MODULESMOVE_ContainerUnClick [ModulesViewed nil nil nil]; _CBcontainerDblClick cont @MODULESVIEW_BgDblClick nil; set ModulesViewed.MODVIEWhoverModule = nil ) ;;