/**************************************************************************************** * BLACK BOX EDITOR for SCS2 * sept. 2000 ****************************************************************************************/ typeof Ed = Editor;; typeof EditCont = ObjContainer;; typeof InList = CompList;; typeof OutList = CompList;; typeof InField = CompText;; typeof OutField = CompText;; typeof RenamedFields = [[S S S] r1];; /* [[in/out oldname newname] r1] */ var RENAME_DEF = "ren";; /* rename definition block name */ fun _RenameField2(rl,oldname,newname)= if rl==nil then nil else let rl -> [first next] in let first -> [io old new] in if !strcmp new oldname then mutate first <- [_ _ newname] else _RenameField2 next oldname newname;; fun _RenameField (list,newname,inout)= let _GETcompListClicked list -> [pos [oldname _]] in ( _SETcompListValue list pos [newname nil]; if ((_RenameField2 RenamedFields oldname newname) == nil) && (oldname!=nil) then set RenamedFields = [inout oldname newname]::RenamedFields else nil ) ;; fun _RenamedFieldsDefinition (list) = if list==nil then nil else let list -> [first next] in let first -> [io old new] in (io::old::new::nil)::(_RenamedFieldsDefinition next) ;; /* return the name or nil if the name is invalid */ fun _ADDtoList (compList, name, i) = if i >= _GETcompListCount compList then _ADDcompList compList i [name nil] else let _GETcompListValue compList i -> [txt _] in let strcmpi txt name -> newpos in if newpos > 0 then _ADDcompList compList i [name nil] else if newpos == 0 then _SETcompListValue compList i [name nil] else _ADDtoList compList name i+1;; fun _rflCLICKbuttons (action, x, y, w, h, cont) = if !strcmp action "ADD_IN" then (_ADDtoList InList _GETcompText InField 0 ; 0) else if !strcmp action "ADD_OUT" then (_ADDtoList OutList _GETcompText OutField 0 ; 0) else if !strcmp action "REN_IN" then (_RenameField InList _GETcompText InField "in" ; 0) else if !strcmp action "REN_OUT" then (_RenameField OutList _GETcompText OutField "out"; 0) else if !strcmp action "DEL_IN" then (_SDELcompList InList _GETcompText InField ; 0) else if !strcmp action "DEL_OUT" then (_SDELcompList OutList _GETcompText OutField ; 0) else nil; _PAINTcontainer cont; 0 ;; fun _rflCLICKlist (compList, param, pos) = let param -> [cont field] in let _GETcompListValue compList pos -> [relayName _] in ( _SETcompText field relayName nil nil CT_NOCHANGE; _PAINTcontainer cont ) ;; fun getList (compList, portName, i) = if i >= _GETcompListCount compList then nil else let _GETcompListValue compList i -> [txt _] in (portName::txt::nil)::(getList compList portName i+1);; fun save (filename, n) = setDef Ed RENAME_DEF _RenamedFieldsDefinition RenamedFields; listcat (getList InList "in" 0) (getList OutList "out" 0);; fun setList (list) = if list == nil then 0 else let list -> [first next] in let first -> [port [name _ ]] in ( if !strcmp port "in" then _ADDtoList InList name 0 else if !strcmp port "out" then _ADDtoList OutList name 0 else nil; setList next );; fun load (l) = set RenamedFields = nil; setList l;; /* main function */ fun IniEditor (s)= let [315 245] -> [w h] in let startEditor _channel nil nil nil w h WN_MENU|WN_MINBOX EDITOR_NORMAL s nil nil nil @load @save nil -> ed in let getEditCont ed -> edcont in let mkfun6 @_rflCLICKbuttons edcont -> reflex in ( set Ed = ed; set EditCont = edcont; GRAPHICDRESSING_CRcompText _channel edcont nil [5 5] OBJ_ENABLE|OBJ_VISIBLE|CT_CENTER|CT_LABEL|CT_WORDWRAP|OBJ_RW_FLEX|OBJ_MW_FLEX OBJ_CONTAINER_UNCLICK|OBJ_CONTAINER_MOVE|OBJ_CONTAINER_KEYUP|OBJ_CONTAINER_KEYDOWN 155 15 _locEditor "LABEL-inputports" nil Font [GD_DEFAULT_TEXT_COLOR nil 0 0] nil; set InList = GRAPHICDRESSING_CRcompList _channel edcont nil [0 25] OBJ_ENABLE|OBJ_VISIBLE|LST_LEFT|LST_HIGHLIGHT_SELECTED|LST_HIGHLIGHT_CLICKED|OBJ_MW_FLEX|OBJ_RW_FLEX|OBJ_MH_FLEX OBJ_CONTAINER_UNCLICK|OBJ_CONTAINER_MOVE|OBJ_CONTAINER_KEYUP|OBJ_CONTAINER_KEYDOWN 155 160 10 LST_VERTICAL Font 0 [GD_COMPLIST_TEXT_COLOR 0 0 0] [GD_COMPLIST_HIGHLIGHT_COLOR GD_COMPLIST_HIGHLIGHT_TRANSPARENCY]; set InField = GRAPHICDRESSING_CRcompText _channel edcont nil [0 190] OBJ_ENABLE|OBJ_VISIBLE|CT_EDITLINE|OBJ_RW_FLEX|OBJ_MW_FLEX|OBJ_LH_FLEX OBJ_CONTAINER_UNCLICK|OBJ_CONTAINER_MOVE|OBJ_CONTAINER_KEYUP|OBJ_CONTAINER_KEYDOWN 155 20 nil Font [GD_DEFAULT_TEXT_COLOR nil 0 0] nil; let [Font 0 "-" "DEL_IN"]::[Font 0 (_locEditor "BUT-renamein" nil) "REN_IN"]::[Font 0 "+" "ADD_IN"]::nil -> txt in let [8 8 3 3] -> edgeWidths in GRAPHICDRESSING_CRbuttonBar _channel edcont nil 155 215 edgeWidths [0 22] reflex txt BUTTONBAR_HORIZONTAL|BUTTONBAR_INVX OBJ_ENABLE|OBJ_VISIBLE|ROL_DISABLE|ROL_MASK|OBJ_LW_FLEX|OBJ_RW_FLEX|OBJ_LH_FLEX OBJ_CONTAINER_UNCLICK|OBJ_CONTAINER_KEYUP|OBJ_CONTAINER_MOVE; GRAPHICDRESSING_CRcompText _channel edcont nil [160 5] OBJ_ENABLE|OBJ_VISIBLE|CT_CENTER|CT_LABEL|CT_WORDWRAP|OBJ_LW_FLEX|OBJ_MW_FLEX OBJ_CONTAINER_UNCLICK|OBJ_CONTAINER_MOVE|OBJ_CONTAINER_KEYUP|OBJ_CONTAINER_KEYDOWN 155 15 _locEditor "LABEL-outputports" nil Font [GD_DEFAULT_TEXT_COLOR 0 0 0] [GD_DEFAULT_TEXT_HIGHLIGHT_COLOR 50]; set OutList = GRAPHICDRESSING_CRcompList _channel edcont nil [160 25] OBJ_ENABLE|OBJ_VISIBLE|LST_LEFT|LST_HIGHLIGHT_SELECTED|LST_HIGHLIGHT_CLICKED|OBJ_MW_FLEX|OBJ_LW_FLEX|OBJ_MH_FLEX OBJ_CONTAINER_UNCLICK|OBJ_CONTAINER_MOVE|OBJ_CONTAINER_KEYUP|OBJ_CONTAINER_KEYDOWN 155 160 10 LST_VERTICAL Font 0 [GD_COMPLIST_TEXT_COLOR 0 0 0] [GD_COMPLIST_HIGHLIGHT_COLOR GD_COMPLIST_HIGHLIGHT_TRANSPARENCY]; set OutField = GRAPHICDRESSING_CRcompText _channel edcont nil [160 190] OBJ_ENABLE|OBJ_VISIBLE|CT_EDITLINE|OBJ_LW_FLEX|OBJ_MW_FLEX|OBJ_LH_FLEX OBJ_CONTAINER_UNCLICK|OBJ_CONTAINER_MOVE|OBJ_CONTAINER_KEYUP|OBJ_CONTAINER_KEYDOWN 155 20 nil Font [GD_DEFAULT_TEXT_COLOR nil 0 0] [GD_DEFAULT_TEXT_HIGHLIGHT_COLOR 50]; let [Font 0 "-" "DEL_OUT"]::[Font 0 (_locEditor "BUT-renameout" nil) "REN_OUT"]::[Font 0 "+" "ADD_OUT"]::nil -> txt in let [8 8 3 3] -> edgeWidths in GRAPHICDRESSING_CRbuttonBar _channel edcont nil w 215 edgeWidths [0 22] reflex txt BUTTONBAR_HORIZONTAL|BUTTONBAR_INVX OBJ_ENABLE|OBJ_VISIBLE|ROL_DISABLE|ROL_MASK|OBJ_LW_FLEX|OBJ_RW_FLEX|OBJ_LH_FLEX OBJ_CONTAINER_UNCLICK|OBJ_CONTAINER_KEYUP|OBJ_CONTAINER_MOVE; _CBcompListClick InList @_rflCLICKlist [edcont InField]; _CBcompListClick OutList @_rflCLICKlist [edcont OutField]; _PAINTcontainer edcont; if s==nil then nil else openDMI ed ); 0;;