<?xml version="1.0" encoding="utf-8"?>
<!--$Date: 2013/10/25 08:37:28 $ $Revision: 1.1 $ $Author: pbrezina $ $ExpSubDir$-->
<ROOT>
  <REFERENCES>
    <HOBJ_REF>
      <uid>PICTURES</uid>
      <name>PICTURES</name>
      <objType>SYSTEM</objType>
      <valType>NAN</valType>
    </HOBJ_REF>
    <HOBJ_REF>
      <uid>DBD31119C1FBD348AC2D58CEADF7BC0A</uid>
      <name>SD.FileList</name>
      <objType>STRUCTDEF</objType>
      <valType>NAN</valType>
    </HOBJ_REF>
    <COL_REF>
      <col_idx>1</col_idx>
      <col_name>fileName</col_name>
      <col_valType>Text</col_valType>
    </COL_REF>
  </REFERENCES>
  <CFGRECORDS>
    <TObjItemData>
      <Id>245</Id>
      <Name>S.DnD_example</Name>
      <Descript/>
      <Typ>PICTURE</Typ>
      <ParentId>PICTURES</ParentId>
      <Value_Type>Int</Value_Type>
      <CreateTime>23.10.2013 15:08:00.008</CreateTime>
      <ModifyTime>24.10.2013 09:25:46.691</ModifyTime>
      <Text_Palette/>
      <Read_Only>False</Read_Only>
      <TECH_UNIT/>
      <UseLimits>False</UseLimits>
      <VHL>1.00000000000000E+02</VHL>
      <HL>1.00000000000000E+02</HL>
      <LL>0.00000000000000E+00</LL>
      <VLL>0.00000000000000E+00</VLL>
      <VHL_ID/>
      <HL_ID/>
      <LL_ID/>
      <VLL_ID/>
      <Hysterezia>0.00000000000000E+00</Hysterezia>
      <TransPalIdx>0</TransPalIdx>
      <Hidden>False</Hidden>
      <uuid>3E7C20B74DFA444EA09864A4D7D4AC22</uuid>
      <memberOfModule/>
      <moduleRelation>AM_None</moduleRelation>
    </TObjItemData>
    <TPictureData>
      <DX>500</DX>
      <DY>400</DY>
      <MIN_DX>0</MIN_DX>
      <MIN_DY>0</MIN_DY>
      <BACKCOLOR>4</BACKCOLOR>
      <bOldCoordSyst>False</bOldCoordSyst>
      <bUseGradient>False</bUseGradient>
      <bInvertColors>True</bInvertColors>
      <backColor2>0</backColor2>
      <patternBr>2</patternBr>
      <BITMAPFILE/>
      <bitmapStyle>stretch</bitmapStyle>
      <bmpPattern/>
      <bmpLogo/>
      <posLogo>tPL_right_up</posLogo>
      <userHelp/>
      <posType>0</posType>
      <posAt>0</posAt>
      <skupina>tPaintNormal</skupina>
      <transform>tZoom</transform>
      <windowType>tWT_MDI</windowType>
      <dockPos>tDP_Top</dockPos>
      <modality>False</modality>
      <applModality>False</applModality>
      <unvisible>False</unvisible>
      <log_close>False</log_close>
      <refresh_in_hi>True</refresh_in_hi>
      <rdReOpen>True</rdReOpen>
      <scrollsInZoom>True</scrollsInZoom>
      <min_btn>True</min_btn>
      <max_btn>True</max_btn>
      <close_btn>True</close_btn>
      <javaThreadType>tJT_OWN</javaThreadType>
      <layersNum>1</layersNum>
      <layers_Arr>
        <Layer_0>0.00000000000000E+00</Layer_0>
        <Layer_1>0.00000000000000E+00</Layer_1>
        <Layer_2>0.00000000000000E+00</Layer_2>
        <Layer_3>0.00000000000000E+00</Layer_3>
        <Layer_4>0.00000000000000E+00</Layer_4>
        <Layer_5>0.00000000000000E+00</Layer_5>
        <Layer_6>0.00000000000000E+00</Layer_6>
        <Layer_7>0.00000000000000E+00</Layer_7>
        <Layer_8>0.00000000000000E+00</Layer_8>
      </layers_Arr>
      <goEnter>1</goEnter>
      <goEsc>2</goEsc>
      <odkaz1/>
      <odkaz2/>
      <odkaz3/>
      <homeIsntNr>0</homeIsntNr>
      <prevIsntNr>0</prevIsntNr>
      <nextIsntNr>0</nextIsntNr>
    </TPictureData>
    <tDisplayData>
      <grObjectNr>1</grObjectNr>
      <objectId/>
      <locVarId>0</locVarId>
      <objectNr>1</objectNr>
      <objectFnct>0</objectFnct>
      <objectIndex>0</objectIndex>
      <objectItem>0</objectItem>
      <redrawMode>0</redrawMode>
      <color>0</color>
      <bObjIsLocVar>False</bObjIsLocVar>
      <bObjIdxIsLocVar>False</bObjIdxIsLocVar>
    </tDisplayData>
    <tPictureDataBin>
      <objNr>1</objNr>
      <order>1</order>
      <Data><![CDATA[1.typ='GENIUS'
1.zoomed=TRUE
1.layers[1]=TRUE
1.layers[2]=TRUE
1.layers[3]=TRUE
1.layers[4]=TRUE
1.layers[5]=TRUE
1.layers[6]=TRUE
1.layers[7]=TRUE
1.layers[8]=TRUE
1.layers[9]=TRUE
1.layers[10]=TRUE
1.refvarid= 2
1.x= 10
1.y= 10
1.bkeepright=FALSE
1.bkeepbottom=FALSE
1.bfloatwidth=FALSE
1.bfloatheight=FALSE
1.bscalewidth=FALSE
1.bscaleheight=FALSE
1.bplacewidth=FALSE
1.bplaceheight=FALSE
1.bplacewidth2=FALSE
1.bplaceheight2=FALSE
1.bkeepacpectratio=FALSE
1.colorp_idx= 15
1.colorb_idx= 0
1.patternb= 0
1.tooltip=''
1.linetype=SOLID
1.linewend= 0
1.linejoin= 2
1.linewidth= 1
1.buse=FALSE
1.binvert=FALSE
1.colorb2_idx= 0
1.patternbr= 2
1.alfa= 25700
1.metadata=''
1.objurl=''
1.dx= 480
1.dy= 380
1.round= 0
1.pristroj='CTRL_TREE'
]]></Data>
    </tPictureDataBin>
    <tDispSpecDataBin>
      <objNr>1</objNr>
      <Data><![CDATA[1.pristroj='CTRL_TREE'
1.bgroup=FALSE
1.bscaption=''
1.neflimit= 32
1.nsblow= 1
1.nsbhigh= 99
1.lbtype=TLB_LIST
1.dynsearching=WITHOUTDYNSEARCHING
1.befmulti=FALSE
1.brichedit=FALSE
1.brightaligned=FALSE
1.binitvisible=TRUE
1.binitdisabled=FALSE
1.bwordwrap=TRUE
1.btransparent=FALSE
1.bexpandsttext=FALSE
1.bpushlike=FALSE
1.bpassword=FALSE
]]></Data>
    </tDispSpecDataBin>
    <tScriptLocalVar>
      <Name>_tree</Name>
      <Id>2</Id>
      <forObject>ObjTree</forObject>
      <vTyp>Int</vTyp>
      <typ>RefID</typ>
      <refVal>1</refVal>
      <structId/>
      <desc/>
      <filter>NoFilter</filter>
      <stTextID/>
      <txtPalIdx>0</txtPalIdx>
    </tScriptLocalVar>
    <tScriptDef_Full>
      <script><![CDATA[; This scheme script provides example how to handle drag and drop operation in tree view.
; Scheme contains one tree with multiple nodes that can manipulated by drag and drop.
; Text nodes can be added if user drag some text or files into its tree structure.
; Tree is also source of texts, that can be dragged away into text editor or other applications supporting drag and drop.
; This is just an example script, that do not cover all cases of drag and drop operation.
; For using in production environment you should test it and add some features as:
;   - removing dragged tree node properly in tree_OnDragEnd
;   - ...

; Author: Adam Bella


; -- constants --
INT _BACK_COLOR = %MakeRGB(200, 200, 200) ;this color is set as standard background color of tree
INT _DND_COLOR = %MakeRGB(200, 230, 230)  ;this color is set as backgrounf color of tree if drag and drop operation if procceeding

INT _DND_HANDLE = 0  ; standard handle to drag and drop

; constant determinating type of drag and drop operation
INT _DROP_END_NONE = 0
INT _DROP_END_COPY = 1
INT _DROP_END_MOVE = 2
INT _DROP_END_SHORTCUT = 3

; constant determining where to insert new node
INT _INSERT_AT_END = 0
INT _INSERT_AT_BEGINING = -1

; some three constnats
INT _ROOT_PARENT = 0
INT _ROOT_ITEM = 1
INT _PARENT_POS_INDEX = 1 ; position where custom data are inserted into node

; -- globals --
INT _node_indexer ; hold index value of last added node in tree

PROCEDURE InitTree
  ; make some initialization in tree
  ; add few nodes as an exapmle
  
  INT _parent
  INT _itemID
  
  _node_indexer := 1
  
  %HI_SetBackColor(_tree, _BACK_COLOR)
  _parent := _ROOT_PARENT
  _itemID := _node_indexer
  _node_indexer  := _node_indexer + 1
  %HI_AddTreeItem(_tree, "/", _parent, _itemID, _INSERT_AT_END)
  %HI_SetItemData(_tree, _itemID, _PARENT_POS_INDEX, _parent)
  %HI_ExpandItem(_tree, _parent, @TRUE)
  
  _parent := _ROOT_ITEM
  _itemID := _node_indexer
  _node_indexer  := _node_indexer + 1
  %HI_AddTreeItem(_tree, "C:", _parent, _itemID, _INSERT_AT_END)
  %HI_SetItemData(_tree, _itemID, _PARENT_POS_INDEX, _parent)
  %HI_ExpandItem(_tree, _parent, @TRUE)
  
  _parent := _ROOT_ITEM
  _itemID := _node_indexer
  _node_indexer  := _node_indexer + 1
  %HI_AddTreeItem(_tree, "D:", _parent, _itemID, _INSERT_AT_END)
  %HI_SetItemData(_tree, _itemID, _PARENT_POS_INDEX, _parent)
  %HI_ExpandItem(_tree, _parent, @TRUE)
END InitTree


; -----------------
; -- SOURCE SIDE --
; -----------------

; tree_OnDragStart
ENTRY tree_OnDragStart
  ; tell system if some data can be dragged from this tree by calling HI_DoDragDrop
  
  ; get seelcted node
  INT _selectedNode = %HI_GetSelectedItem(_tree)
  ; get text value from node for drag operation
  TEXT _dragingValue = %HI_GetItemText(_tree, _selectedNode)
  ; set text value into dnd buffer
  %SetDragDataText(_DND_HANDLE, _dragingValue)
  ; notify system that drag operation should begins 
  ;- do not forget call this procedure, otherwise no drag and drop will be performed!
  %HI_DoDragDrop(_tree)
END tree_OnDragStart

; tree_OnDragEnd
ENTRY tree_OnDragEnd (IN INT _operationType)
  ; if type of operation is 'moving' than it is responsibility of this entry to delete source of dragging value
  ; !!! CAUTION - this script do not remove nodes properly in all cases, for example if draging node has some childs, they are removed too
  ; for using in production environment programmer should add some others checks of dragged nodes and remove it from the tree properly!
  
  IF _operationType # _DROP_END_MOVE THEN
    RETURN
  ENDIF
  
  ; get selectet node = dragged node
  INT _draggedNode = %HI_GetSelectedItem(_tree)
  ; detele it from tree
  IF _draggedNode\VLD THEN
    %HI_DeleteItem(_tree, _draggedNode, @TRUE);
  ENDIF
END tree_OnDragEnd

; -----------------
; -- TARGET SIDE --
; -----------------

; tree_OnDragEnter
ENTRY tree_OnDragEnter(BOOL _bAllow)
  ; check what kind of data are dragging into this tree and dtermine if it can be dragged there
  
  ; this tree support:
  ; - text data
  ; - fele list data
  
  ; no IPS data type are supported by this script
  
  IF %IsDragData(_DND_HANDLE, _CF_IPS) THEN
    _bAllow := @FALSE
    RETURN  
  ENDIF
  
  %HI_SetBackColor(_tree, _DND_COLOR)
  _bAllow := @TRUE
END tree_OnDragEnter

; tree_OnDragOver
ENTRY tree_OnDragOver(BOOL _bAllow)
  ; check if dragging data can be over this position
  
  IF %IsDragData(_DND_HANDLE, _CF_IPS) THEN
    _bAllow := @FALSE
    RETURN  
  ENDIF
  
  _bAllow := @TRUE
END tree_OnDragOver

; tree_OnDragLeave
ENTRY tree_OnDragLeave
  ; user cancel dragging operation or move mouse elsewhere
  
  %HI_SetBackColor(_tree, _BACK_COLOR)
END tree_OnDragLeave

; tree_OnDrop
ENTRY tree_OnDrop
  ; user drop data into this tree, so it has to be processed and
  ; state of nodes has to be updated
  
  BOOL _result
  INT _parentNode, _node, _insertAtPosition
  INT _node1, _node2
  ; check position where user drop data
  _result := %HI_TVQueryDnDItem (_tree, _node1, _node2)
  IF _node1\VLD THEN
    IF _node2\VLD THEN
      IF _node1 = _node2 THEN
        ; drop exactly at node - add new node as a child
        _parentNode := _node1
        _insertAtPosition := _INSERT_AT_END
        
      ELSE
        ; drop between node1 and node2 - add above node2 at its level
        _parentNode := %HI_GetItemData(_tree, _node2, _PARENT_POS_INDEX)
        _insertAtPosition := _node1
      ENDIF
    ELSE
      ; drop below node1
      _parentNode := %HI_GetItemData(_tree, _node1, _PARENT_POS_INDEX)
      _insertAtPosition := _INSERT_AT_END
    ENDIF
  ELSE
    IF _node2\VLD THEN
      ; drop above node2
      _parentNode := %HI_GetItemData(_tree, _node2, _PARENT_POS_INDEX)
      _insertAtPosition := _INSERT_AT_BEGINING
    ELSE
      ; drop outside of three items
      ; just return and make no insert operation
      RETURN
    ENDIF
  ENDIF
  
  ;insert data into retrieved position to the tree according to type of data
  IF %IsDragData(_DND_HANDLE, _CF_TEXT) THEN
    ; if dragging text add new text node
    TEXT _droppingText = %GetDragDataText(_DND_HANDLE)
    %HI_AddTreeItem(_tree, _droppingText, _parentNode, _node_indexer, _insertAtPosition)
    %HI_SetItemData(_tree, _node_indexer, _PARENT_POS_INDEX, _parentNode)
    %HI_ExpandItem(_tree, _parentNode, @TRUE)
    _node_indexer := _node_indexer + 1
  ELSIF %IsDragData(_DND_HANDLE, _CF_FILELIST) THEN
    ; if dragging file list, for each file add new node with its name
    RECORD NOALIAS (SD.FileList) _flist
    %GetDragDataFileList(_DND_HANDLE, _flist^fileName)
    
    INT _i
    FOR _i RANGE _flist DO_LOOP
      ; item of file list contain full path to the dragged file
      ; but I will insert to the tree just the filename
      INT _fileDirLevel = %GetStrItemsCount(_flist[_i]^fileName, "\")
      TEXT _lastNode = %GetStrItem(_flist[_i]^fileName, _fileDirLevel, "\")
      
      %HI_AddTreeItem(_tree, _lastNode, _parentNode, _node_indexer, _insertAtPosition)
      %HI_SetItemData(_tree, _node_indexer, _PARENT_POS_INDEX, _parentNode)
      %HI_ExpandItem(_tree, _parentNode, @TRUE)
      _node_indexer := _node_indexer + 1
    END_LOOP
  ENDIF
  
  %HI_SetBackColor(_tree, _BACK_COLOR)
END tree_OnDrop

BEGIN
  CALL InitTree
END]]></script>
      <scriptRemote/>
    </tScriptDef_Full>
  </CFGRECORDS>
  <MEMBEROFRESGROUP>
    <member>Home_admin\B2AA0C07C6CCCB40B1BB0AFE42FF05F9</member>
  </MEMBEROFRESGROUP>
  <CRC>ddcca38607cfe9be9a79b3925e8e3fdb</CRC>
  <OBJLIFELOGS>
    <tObjLifeLogData>
      <name>S.DnD_example</name>
      <state>OLA_CHANGED</state>
      <modify_time>24.10.2013 09:19:04.531</modify_time>
      <user_name>admin</user_name>
      <process_name>WS1ABEL1.GRE</process_name>
      <computer_name>WS1ABEL1</computer_name>
      <log_type>OLT_CONFIG</log_type>
      <comment_text/>
    </tObjLifeLogData>
    <tObjLifeLogData>
      <name>S.DnD_example</name>
      <state>OLA_CHANGED</state>
      <modify_time>24.10.2013 09:19:39.169</modify_time>
      <user_name>admin</user_name>
      <process_name>WS1ABEL1.GRE</process_name>
      <computer_name>WS1ABEL1</computer_name>
      <log_type>OLT_CONFIG</log_type>
      <comment_text/>
    </tObjLifeLogData>
    <tObjLifeLogData>
      <name>S.DnD_example</name>
      <state>OLA_CHANGED</state>
      <modify_time>24.10.2013 09:20:05.397</modify_time>
      <user_name>admin</user_name>
      <process_name>WS1ABEL1.GRE</process_name>
      <computer_name>WS1ABEL1</computer_name>
      <log_type>OLT_CONFIG</log_type>
      <comment_text/>
    </tObjLifeLogData>
    <tObjLifeLogData>
      <name>S.DnD_example</name>
      <state>OLA_CHANGED</state>
      <modify_time>24.10.2013 09:20:40.763</modify_time>
      <user_name>admin</user_name>
      <process_name>WS1ABEL1.GRE</process_name>
      <computer_name>WS1ABEL1</computer_name>
      <log_type>OLT_CONFIG</log_type>
      <comment_text/>
    </tObjLifeLogData>
    <tObjLifeLogData>
      <name>S.DnD_example</name>
      <state>OLA_CHANGED</state>
      <modify_time>24.10.2013 09:24:54.097</modify_time>
      <user_name>admin</user_name>
      <process_name>WS1ABEL1.GRE</process_name>
      <computer_name>WS1ABEL1</computer_name>
      <log_type>OLT_CONFIG</log_type>
      <comment_text/>
    </tObjLifeLogData>
    <tObjLifeLogData>
      <name>S.DnD_example</name>
      <state>OLA_CHANGED</state>
      <modify_time>24.10.2013 09:24:59.069</modify_time>
      <user_name>admin</user_name>
      <process_name>WS1ABEL1.GRE</process_name>
      <computer_name>WS1ABEL1</computer_name>
      <log_type>OLT_CONFIG</log_type>
      <comment_text/>
    </tObjLifeLogData>
    <tObjLifeLogData>
      <name>S.DnD_example</name>
      <state>OLA_CHANGED</state>
      <modify_time>24.10.2013 09:25:46.691</modify_time>
      <user_name>admin</user_name>
      <process_name>WS1ABEL1.GRE</process_name>
      <computer_name>WS1ABEL1</computer_name>
      <log_type>OLT_CONFIG</log_type>
      <comment_text/>
    </tObjLifeLogData>
  </OBJLIFELOGS>
</ROOT>