Subversion Repositories Kolibri OS

Rev

Rev 1277 | Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. ; ìàêðîñ äëÿ ñèñòåìíîé áèáëèîòåêè box_lib.obj
  2. ; ýëåìåíò TreeList äëÿ Kolibri OS
  3. ; ôàéë ïîñëåäíèé ðàç èçìåíÿëñÿ 23.11.2009 IgorA
  4. ; íà êîä ïðèìåíåíà GPL2 ëèöåíçèÿ
  5.  
  6.  
  7. sizeof.TreeList equ 20
  8. ;struct TreeList
  9. ;  type dw ? ;+ 0 òèï ýëåìåíòà, èëè èíäåêñ èêîíêè äëÿ óçëà
  10. ;  lev db ?  ;+ 2 óðîâåíü ýëåìåíòà
  11. ;  clo db ?  ;+ 3 ôëàã çàêðûòèÿ, èëè îòêðûòèÿ (èìååò ñìûñë äëÿ ðîäèòåëüñêîãî óçëà)
  12. ;  perv dd ? ;+ 4 èíäåêñ ïðåäûäóùåãî ýëåìåíòà
  13. ;  next dd ? ;+ 8 èíäåêñ ïîñëåäóþùåãî ýëåìåíòà
  14. ;  tc dd ?   ;+12 âðåì. ñîçäàíèÿ
  15. ;  td dd ?   ;+16 âðåì. óäàëåíèÿ
  16. ;ends
  17.  
  18. tl_info_size  equ  word[edi +4] ;ðàçìåð äàííûõ âûäåëÿåìûõ äëÿ êàæäîãî óçëà (ïîëüçîâàòåëüñüêèå äàííûå + òåêñò äëÿ ïîäïèñè)
  19. tl_style      equ dword[edi+10] ;ñòèëè ýëåìåíòà
  20. tl_data_nodes equ dword[edi+14] ;óêàçàòåëü íà ñòðóêòóðû óçëîâ
  21. tl_img_cx     equ  word[edi+22] ;øèðèíà èêîíîê
  22. tl_img_cy     equ  word[edi+24] ;âûñîòà èêîíîê
  23. tl_data_img_sys equ dword[edi+26] ;óêàçàòåëü íà ñèñòåìíûå èçîáðàæåíèÿ (ñòðåëêè, ïëþñèêè)
  24. tl_ch_tim     equ dword[edi+30] ;êîëè÷åñòâî èçìåíåíèé â ôàéëå
  25. tl_tim_undo   equ dword[edi+38] ;êîëè÷åñòâî îòìåíåííûõ äåéñòâèé
  26. tl_cur_pos    equ dword[edi+42] ;ïîçèöèÿ êóðñîðà
  27. tl_col_bkg    equ dword[edi+46] ;öâåò ôîíà
  28. tl_col_zag    equ dword[edi+50] ;öâåò çàãîëîâêà
  29. tl_col_txt    equ dword[edi+54] ;öâåò òåêñòà
  30. tl_box_left   equ dword[edi+58]
  31. tl_box_top    equ dword[edi+62]
  32. tl_box_width  equ dword[edi+66]
  33. tl_box_height equ dword[edi+70]
  34. tl_capt_cy    equ  word[edi+74] ;âûñîòà ïîäïèñè
  35. tl_info_capt_offs equ dword[edi+76] ;ñäâèã äëÿ íà÷àëà òåêñòà (ïîäïèñè óçëà)
  36. tl_el_focus   equ dword[edi+80] ;óêàçàòåëü íà ñòðóêòóðó ýëåìåíòà â ôîêóñå
  37. tl_p_scrol    equ dword[edi+84] ;óêàçàòåëü íà ñòðóêòóðó ñêðîëëèíãà
  38. tl_sb_draw    equ dword[edi+88] ;óêàçàòåëü íà ôóíêöèþ ïåðåðèñîâûâàþùóþ ñêðîëëèíã
  39. tl_on_press   equ dword[edi+96] ;óêàçàòåëü íà ôóíêöèþ, êîòîðàÿ âûçûâàåòñÿ ïðè íàæàòèè Enter
  40.  
  41. ;êîíñòàíòû ñòèëÿ
  42. tl_key_no_edit   equ   1b ;ýëåìåíò íåëüçÿ ðåäàêòèðîâàòü íà êëàâèàòóðå (èçìåíÿòü óðîâíè, óäàëÿòü)
  43. tl_draw_par_line equ  10b ;ðèñîâàòü ëèíèè ê ðîäèòåëüñêîìó óçëó
  44. tl_list_box_mode equ 100b ;ñòèëü íå îòîáðàæàåò óðîâíè (êàê â ListBox âñå îäíîãî óðîâíÿ)
  45.  
  46. ;data_info       dd ? ;+ 0 óêàçàòåëü íà îñíîâíûå äàíûå
  47. ;info_max_count dd ? ;+ 6 ìàêñèìàëüíîå êîëëè÷åñòâî ñòðóêòóð
  48. ;data_img        dd ? ;+18 óêàçàòåëü íà èçîáðàæåíèÿ
  49. ;ls_tim         dd ? ;+34 âðåìÿ ïîñëåäíåãî ñîõðàíåíèÿ
  50. ;on_activate dd ? ;+92 óêàçàòåëü íà ôóíêöèþ ïðè àêòèâèðîâàíèè óçëà
  51.  
  52. struc tree_list info_size,info_max_count,style, img_cx,img_cy,\
  53.     col_bkg,col_zag,col_txt, box_l,box_t,box_w,box_h, capt_cy,info_capt_offs,\
  54.     el_focus, p_scrol,p_sb_draw,on_press {
  55.   .data_info    dd 0
  56.   .info_size    dw info_size
  57.   .info_max_count dd info_max_count
  58.   .style            dd style
  59.   .data_nodes   dd 0
  60.   .data_img      dd 0
  61.   .img_cx          dw img_cx
  62.   .img_cy          dw img_cy
  63.   .data_img_sys  dd 0
  64.   .ch_tim                 dd 0
  65.   .ls_tim                 dd 0
  66.   .tim_undo      dd 0
  67.   .cur_pos        dd 0
  68.   .col_bkg        dd col_bkg
  69.   .col_zag        dd col_zag
  70.   .col_txt        dd col_txt
  71.   .box_lert   dd box_l
  72.   .box_top    dd box_t
  73.   .box_width  dd box_w
  74.   .box_height dd box_h
  75.   .capt_cy         dw capt_cy
  76.   .info_capt_offs dd info_capt_offs
  77.   .el_focus dd el_focus
  78.   .p_scrol  dd p_scrol
  79.   .p_sb_draw dd p_sb_draw
  80.   .on_activate dd 0
  81.   .on_press dd on_press
  82. }
  83.  
  84. ;-----------------------------------------------------------------------------
  85. ;ôóíêöèÿ äëÿ âûäåëåíèÿ ïàìÿòè
  86. ;input:
  87. ; ecx = size data
  88. ;otput:
  89. ; eax = pointer to memory
  90. align 4
  91. mem_Alloc:
  92.   push ebx
  93.   mov eax,68
  94.   mov ebx,12
  95.   int 0x40
  96.   pop ebx
  97.   ret
  98. ;-----------------------------------------------------------------------------
  99. ;ôóíêöèÿ äëÿ îñâîáîæäåíèÿ ïàìÿòè
  100. ;input:
  101. ; ecx = pointer to memory
  102. align 4
  103. mem_Free:
  104.   push eax ebx
  105.   cmp ecx,0
  106.   jz @f
  107.     mov eax,68
  108.     mov ebx,13
  109.     int 0x40
  110.   @@:
  111.   pop ebx eax
  112.   ret
  113.  
  114. macro use_tree_list
  115. {
  116. align 4
  117. tl_data_init: ;âûäåëíèå ïàìÿòè äëÿ ñòðóêòóð ñïèñêà è îñíîâíîé èíôîðìàöèè (êîíñòðóêòîð)
  118.   push ebp
  119.   mov ebp,esp
  120.   push eax ecx edi
  121.     mov edi,dword[ebp+8]
  122.  
  123.     xor ecx,ecx
  124.     mov cx,tl_info_size
  125.     imul ecx,dword[edi+6]
  126.     call mem_Alloc
  127.     mov dword[edi],eax ;êîïèðóåì óêàçàòåëü íà ïîëó÷åíóþ ïàìÿòü â ñòðóêòóðó
  128.     mov dword[edi+18],0 ;îáíóëÿåì óêàçàòåëü 'data_img'
  129.     mov tl_data_img_sys,0 ;îáíóëÿåì óêàçàòåëü 'data_img_sys'
  130.  
  131.     mov ecx,sizeof.TreeList
  132.     imul ecx,dword[edi+6]
  133.     call mem_Alloc
  134.     mov tl_data_nodes,eax ;êîïèðóåì óêàçàòåëü íà ïîëó÷åíóþ ïàìÿòü â ñòðóêòóðó
  135.  
  136.     push dword edi
  137.     call tl_info_clear
  138.  
  139.     ;íàñòðîéêè äî÷åðíåãî ñêðîëëèíãà
  140.     cmp tl_p_scrol,0
  141.     je @f
  142.       mov eax,tl_p_scrol
  143.       ;*** öâåòîâûå íàñòðîéêè ***
  144.       mov ecx,tl_col_bkg
  145.       mov dword[eax+28],ecx ;+28 .bckg_col
  146.       mov ecx,tl_col_zag
  147.       mov dword[eax+32],ecx ;+32 .frnt_col
  148.       mov ecx,tl_col_txt
  149.       mov dword[eax+36],ecx ;+32 .line_col
  150.       ;*** íàñòðîéêè ðàçìåðîâ ***
  151.       mov ecx,tl_box_left
  152.       add ecx,tl_box_width
  153.       mov word[eax+2],cx
  154.       mov ecx,tl_box_height
  155.       mov word[eax+4],cx
  156.       mov ecx,tl_box_top
  157.       mov word[eax+6],cx
  158.     @@:
  159.   pop edi ecx eax
  160.   pop ebp
  161.   ret 4
  162.  
  163. align 4
  164. tl_data_clear: ;î÷èñòêà ïàìÿòè ýëåìåíòà (äåñòðóêòîð)
  165.   push ebp
  166.   mov ebp,esp
  167.     push ecx edi
  168.     mov edi,dword[ebp+8]
  169.     cmp dword[edi+18],0 ;data_img
  170.     je @f
  171.       mov ecx,dword[edi+18]
  172.       call mem_Free ;÷èñòêà ñèñòåìíûõ èêîíîê
  173.     @@:
  174.     cmp tl_data_img_sys,0
  175.     je @f
  176.       mov ecx,tl_data_img_sys
  177.       call mem_Free ;÷èñòêà ñèñòåìíûõ èêîíîê
  178.     @@:
  179.     mov ecx,dword[edi]
  180.     call mem_Free
  181.  
  182.     mov ecx,tl_data_nodes
  183.     call mem_Free
  184.     pop edi ecx
  185.   pop ebp
  186.   ret 4
  187.  
  188. align 4
  189. tl_info_clear: ;î÷èñòêà ñïèñêà (èíôîðìàöèè)
  190.   push ebp
  191.   mov ebp,esp
  192.     push eax ecx edi
  193.     mov edi,dword[ebp+8]
  194.     mov tl_ch_tim,0
  195.     mov dword[edi+34],0 ;ls_tim
  196.     mov tl_tim_undo,0
  197.     mov tl_cur_pos,0
  198.     ;xor ecx,ecx
  199.     mov ecx,sizeof.TreeList
  200.     imul ecx,dword[edi+6]
  201.     mov eax,tl_data_nodes
  202.     @@:
  203.       mov byte[eax],0 ;÷èñòèì óçëû 0-ìè
  204.       inc eax
  205.       loop @b
  206.     mov eax,tl_data_nodes ;óêàçàòåëü íà 0-é óçåë
  207.     mov dword[eax+8],1 ;óêàçàòåëü next â 0-ì óçëå ïðèðàâíèâàåì ê 1
  208.     call tb_scrol_resize ;îáðàáîòêà ñêðîëëèíãà
  209.     pop edi ecx eax
  210.   pop ebp
  211.   ret 4
  212.  
  213.  
  214. align 4
  215. tl_key: ;ðåàêöèÿ íà êëàâèàòóðó
  216.   push ebp
  217.   mov ebp,esp
  218.     push ebx edi
  219.     mov edi,dword[ebp+8]
  220.  
  221.     mov ebx,tl_el_focus
  222.     cmp dword[ebx],edi
  223.     jne .no_focus ;ýëåìåíò íå â ôîêóñå
  224.  
  225.     xor bx,bx
  226.     cmp ah,13 ;Enter
  227.     jne @f
  228.       cmp tl_on_press,0
  229.       je @f
  230.         call tl_on_press
  231.     @@:
  232.     cmp ah,32 ;Space
  233.     jne @f
  234.       push dword edi
  235.       call tl_node_close_open
  236.     @@:
  237.     cmp ah,178 ;Up
  238.     jne @f
  239.       push dword edi
  240.       call tl_cur_perv
  241.     @@:
  242.     cmp ah,177 ;Down
  243.     jne @f
  244.       push dword edi
  245.       call tl_cur_next
  246.     @@:
  247.  
  248.     bt tl_style,0 ;tl_key_no_edit
  249.     jc .no_edit
  250.       cmp ah,176 ;Left
  251.       jne @f
  252.         push dword edi
  253.         call tl_node_lev_dec
  254.         mov bx,1
  255.       @@:
  256.       cmp ah,179 ;Right
  257.       jne @f
  258.         push dword edi
  259.         call tl_node_lev_inc
  260.         mov bx,1
  261.       @@:
  262.       cmp ah,182 ;Delete
  263.       jne @f
  264.         push dword edi
  265.         call tl_node_delete
  266.         mov bx,1
  267.       @@:
  268.     .no_edit:
  269.  
  270.     cmp bx,1
  271.     jne .no_focus
  272.       push dword edi
  273.       call tl_draw
  274.     .no_focus:
  275.  
  276.     pop edi ebx
  277.   pop ebp
  278.   ret 4
  279.  
  280. align 4
  281. tl_mouse: ;ðåàêöèÿ íà ìûøü
  282.   push ebp
  283.   mov ebp,esp
  284.     push eax ebx ecx edx edi esi
  285.     mov edi,dword[ebp+8]
  286.  
  287.     mov eax,37
  288.     mov ebx,2
  289.     int 0x40
  290.  
  291.     bt eax,0 ;left mouse button press
  292.     jae .no_draw
  293.  
  294.     mov eax,37
  295.     mov ebx,1
  296.     int 0x40
  297.  
  298.     mov ebx,tl_box_left
  299.     shl ebx,16
  300.     cmp eax,ebx ;ëåâàÿ ãðàíèöà îêíà
  301.     jl .no_in_wnd
  302.  
  303.     mov ebx,tl_box_left
  304.     add ebx,tl_box_width
  305.     shl ebx,16
  306.     cmp eax,ebx ;ïðàâàÿ ãðàíèöà îêíà
  307.     jg .no_in_wnd
  308.  
  309.     mov ebx,tl_box_top
  310.     add ebx,tl_box_height
  311.     cmp ax,bx ;íèæíÿÿ ãðàíèöà îêíà
  312.     jg .no_in_wnd
  313.  
  314.     sub ebx,tl_box_height
  315.     add bx,tl_capt_cy
  316.     cmp ax,bx ;âåðõíÿÿ ãðàíèöà îêíà + âûñîòà ïîäïèñè
  317.     jl .no_in_wnd
  318.  
  319.     mov esi,tl_el_focus
  320.     mov dword[esi],edi ;set focus
  321.  
  322.     ; if '+' or '-' press
  323.     mov esi,eax
  324.     shr esi,16
  325.     sub esi,tl_box_left ;esi = mouse x coord in element window
  326.  
  327.     and eax,0xffff
  328.     sub ax,bx
  329.     xor edx,edx
  330.     xor ecx,ecx
  331.     mov cx,tl_img_cy
  332.     div ecx
  333.     cmp tl_p_scrol,0 ;ó÷èòûâàåì ñêðîëëèíã
  334.     je @f
  335.       mov edx,tl_p_scrol
  336.       add eax,dword[edx+24] ;äîáàâëÿåì ñêðîëëèíã íà âåðõó
  337.     @@:
  338.  
  339.     mov ecx,eax
  340.     call tl_get_node_count ;eax = node count
  341.     cmp eax,ecx
  342.     jl @f
  343.       mov eax,ecx ;åñëè êóðñîð íå âûøåë çà ïðåäåëû óçëîâ, âîññòàíàâëèâàåì ñòàðîå çíà÷åíèå eax
  344.     @@:
  345.  
  346.     cmp eax,tl_cur_pos ;åñëè íîâîå çíà÷åíèå êóðñîðà ñîâïàëî ñ ïðåäûäóùèì
  347.     je @f ;òî íå ñòèðàåì êóðñîð
  348.     push esi
  349.       mov esi,tl_box_top
  350.       add esi,tl_box_height ;esi = coord bottom border
  351.       call tl_draw_null_cursor ;ñòèðàåì êóðñîð
  352.     pop esi
  353.     @@:
  354.  
  355.     mov tl_cur_pos,eax
  356.  
  357.     ; if '+' or '-' press
  358.     call tl_get_cur_node_index ;eax = node index
  359.     cmp eax,2
  360.     jl .no_open_close ;êóðñîð ñòîèò íà ïóñòîì ìåñòå, áåç óçëîâ
  361.     imul eax,sizeof.TreeList
  362.     add eax,tl_data_nodes
  363.     xor bx,bx
  364.     mov bl,byte[eax+2] ;+2 lev ñîõðàíÿåì óðîâåíü òåêóùåãî óçëà
  365.     inc bx ;+ ïîëå äëÿ êóðñîðà
  366.  
  367.     cmp si,tl_img_cx
  368.     jl .no_open_close ;ìûøåé ïîïàëè íà ëåâîå ïîëå äëÿ êóðñîðà, ãäå òî÷íî íåò '+' è '-'
  369.       mov eax,esi
  370.       xor edx,edx
  371.       xor ecx,ecx
  372.       mov cx,tl_img_cx
  373.       div ecx
  374.  
  375.       cmp ax,bx
  376.       jne .no_open_close
  377.  
  378.       push dword edi
  379.       call tl_node_close_open
  380.     .no_open_close:
  381.  
  382.       mov esi,tl_box_top
  383.       add esi,tl_box_height ;esi = coord bottom border
  384.       call tl_draw_cursor ;ïåðåðèñîâêà êóðñîðà
  385.       jmp .no_draw
  386.     .no_in_wnd: ;íå ïîïàëè â îêíî - ïîòåðÿ ôîêóñà (ïðè óñëîâèè ÷òî ôîêóñ áûë íà äàííîì ýåëåìåíòå)
  387.       mov ebx,tl_el_focus
  388.       cmp dword[ebx],edi
  389.       jne .no_draw ;ýëåìåíò íå â ôîêóñå
  390.         mov dword[ebx],0 ;reset focus
  391.     .no_draw:
  392.  
  393.     pop esi edi edx ecx ebx eax
  394.   pop ebp
  395.   ret 4
  396.  
  397. align 4
  398. tl_info_undo: ;îòìåíà äåéñòâèÿ
  399.   push ebp
  400.   mov ebp,esp
  401.   push eax edi
  402.     mov edi,dword[ebp+8]
  403.     mov eax,tl_tim_undo
  404.     cmp tl_ch_tim,eax
  405.     jbe @f
  406.       inc tl_tim_undo
  407.       call tb_scrol_resize ;îáðàáîòêà ñêðîëëèíãà
  408.     @@:
  409.   pop edi eax
  410.   pop ebp
  411.   ret 4
  412.  
  413. align 4
  414. tl_info_redo: ;ïîâòîð äåéñòâèÿ
  415.   push ebp
  416.   mov ebp,esp
  417.   push edi
  418.     mov edi,dword[ebp+8]
  419.     cmp tl_tim_undo,1
  420.     jl @f
  421.       dec tl_tim_undo
  422.       call tb_scrol_resize ;îáðàáîòêà ñêðîëëèíãà
  423.     @@:
  424.   pop edi
  425.   pop ebp
  426.   ret 4
  427.  
  428. align 4
  429. tl_info_set_undo: ;óäàëåíèå îòìåíåííûõ äåéñòâèé
  430. ;  push ebp
  431. ;  mov ebp,esp
  432. ;  push edi
  433. ;    mov edi,dword[ebp+8]
  434.  
  435. ;  mov [dragk],0 ;çàêàí÷èâàåì âûäåëåíèå îò êëàâèàòóðû
  436.   cmp tl_tim_undo,1
  437.   jl .no_work
  438.  
  439.   push eax ebx ecx edx
  440.   mov edx,tl_data_nodes
  441.   mov ecx,edx
  442.   add ecx,sizeof.TreeList
  443.   call tl_move_next ;long i=node[0].next;
  444.   mov eax,tl_tim_undo
  445.   sub tl_ch_tim,eax ;ch_tim-=tim_undo;
  446.   mov eax,tl_ch_tim
  447.   cmp [edi+34],eax ;if(ls_tim>ch_tim)
  448.   jle @f
  449.     mov dword[edi+34],0 ;ls_tim=0
  450.   @@:
  451.     cmp edx,ecx
  452.     jle @f
  453.  
  454.     ;if(node[i].tc>ch_tim){ // åñëè ñîçäàíèå ñèìâîëà áûëî îòìåíåíî
  455.     cmp dword[edx+12],eax
  456.     jle .no_u1
  457.       mov dword[edx+12],0
  458.       mov dword[edx+16],0
  459.  
  460.       mov ebx, dword[edx+4]
  461.       imul ebx,sizeof.TreeList
  462.       add ebx, tl_data_nodes ;.next
  463.       push dword[edx+8] ;node[node[i].perv].next=node[i].next;
  464.       pop dword[ebx+8]
  465.  
  466.       mov ebx, dword[edx+8]
  467.       imul ebx,sizeof.TreeList
  468.       add ebx, tl_data_nodes ;.perv
  469.       push dword[edx+4] ;node[node[i].next].perv=node[i].perv;
  470.       pop dword[ebx+4]
  471.  
  472.     .no_u1:
  473.  
  474.     ;else if(node[i].td>ch_tim) node[i].td=0; // åñëè óäàëåíèå ñèìâîëà áûëî îòìåíåíî
  475.     cmp dword[edx+16],eax
  476.     jle .no_u2
  477.       mov dword[edx+16],0
  478.     .no_u2:
  479.  
  480.     call tl_move_next
  481.     jmp @b
  482.   @@:
  483.   mov tl_tim_undo,0
  484. ;  mov eax,[edi+?] ;co_tim
  485. ;  cmp tl_ch_tim,eax ;ch_tim
  486. ;  jge @f
  487. ;    mov [edi+?],0 ;co_tim
  488. ;  @@:
  489.   pop edx ecx ebx eax
  490.   .no_work:
  491.  
  492. ;  pop edi
  493. ;  pop ebp
  494. ;  ret 4
  495.   ret
  496.  
  497. align 4
  498. tl_draw: ;âûâîä ñïèñêà íà ýêðàí
  499.   push ebp
  500.   mov ebp,esp
  501.     push eax ebx ecx edx edi esi
  502.     ;draw dir_list main rect
  503.     mov edi,dword[ebp+8]
  504.     mov ebx,tl_box_left
  505.     shl ebx,16
  506.     add ebx,tl_box_width
  507.     mov ecx,tl_box_top
  508.     shl ecx,16
  509.     mov cx,tl_capt_cy
  510.     mov edx,tl_col_zag
  511.     mov eax,13
  512.     int 0x40 ;draw window caption
  513.  
  514.     add ecx,tl_box_top
  515.     shl ecx,16
  516.     add ecx,tl_box_height
  517.     sub cx,tl_capt_cy
  518.     mov edx,tl_col_bkg
  519.     int 0x40 ;draw window client rect
  520.  
  521.     cmp tl_capt_cy,9 ;9 - minimum caption height
  522.     jl @f
  523.     mov eax,4 ;draw text captions
  524.     mov ebx,tl_box_left
  525.     shl ebx,16
  526.     add ebx,5*65536+3
  527.     add ebx,tl_box_top
  528.     mov ecx,tl_col_txt
  529.     or  ecx,0x80000000
  530.     lea edx,[txt_capt_cur]
  531.     int 0x40
  532.  
  533.     mov ebx,tl_box_left
  534.     shl ebx,16
  535.     add ebx,100*65536+3
  536.     add ebx,tl_box_top
  537.     lea edx,[txt_capt_otm]
  538.     int 0x40
  539.  
  540.     mov eax,47 ;draw
  541.     mov ebx,0x40000
  542.     mov ecx,tl_cur_pos
  543.   inc ecx
  544.     mov edx,tl_box_left
  545.     shl edx,16
  546.     add edx,50*65536+3
  547.     add edx,tl_box_top
  548.     mov esi,tl_col_txt
  549.     int 0x40
  550.     mov ecx,tl_tim_undo
  551.     mov edx,tl_box_left
  552.     shl edx,16
  553.     add edx,140*65536+3
  554.     add edx,tl_box_top
  555.     mov esi,tl_col_txt
  556.     int 0x40
  557.     @@:
  558.  
  559. ;---debug---
  560. ;mov ecx,0
  561. ;@@:
  562. ;call DebugSymb
  563. ;inc ecx
  564. ;cmp ecx,10
  565. ;jge @f
  566. ;jmp @b
  567. ;@@:
  568. ;---debug---
  569.  
  570.     ;cycle to nodes
  571.     xor eax,eax
  572.     mov edx,tl_data_nodes
  573.     mov ecx,edx
  574.     add ecx,sizeof.TreeList
  575.  
  576.     ;*** ïðîïóñê óçëîâ, êîòîðûå ïðîìîòàíû ñêðîëëèíãîì ***
  577.     cmp tl_p_scrol,0 ;åñëè åñòü óêàçàòåëü íà ñêðîëëèíã
  578.     je .end_c1
  579.     mov esi,tl_p_scrol
  580.     cmp dword[esi+24],0 ;åñëè ñêðîëëèíã íà âåðõó, âûõîäèì
  581.     je .end_c1
  582.       @@:
  583.         call tl_iterat_next
  584.         cmp edx,ecx
  585.         jle .end_draw
  586.         inc eax
  587.         cmp eax,dword[esi+24]
  588.         jge .end_c1
  589.         jmp @b
  590.     .end_c1:
  591.  
  592.     xor eax,eax
  593.     mov esi,tl_box_top
  594.     add esi,tl_box_height ;esi = coord bottom border
  595.     @@:
  596.       call tl_iterat_next
  597.       cmp edx,ecx
  598.       jle @f
  599.       call tl_draw_node
  600.       inc eax
  601.       jmp @b
  602.     @@:
  603.  
  604.     call tl_draw_cursor
  605.     .end_draw:
  606.     pop esi edi edx ecx ebx eax
  607.   pop ebp
  608.   ret 4
  609.  
  610. ;input:
  611. ; ecx = pointer to 1 node struct
  612. ; edx = pointer to some node struct
  613. ; edi = pointer to 'TreeList' struct
  614. align 4
  615. tl_iterat_next:
  616.   push bx
  617.   mov bl,0x7f
  618.   cmp byte[edx+3],1
  619.   jne @f
  620.     mov bl,byte[edx+2]
  621.   @@:
  622.  
  623.   cmp tl_tim_undo,0
  624.   je .else
  625.  
  626.   push eax
  627.   .beg0:
  628.     call tl_move_next
  629.     cmp edx,ecx
  630.     jle @f
  631.     call tl_node_not_vis ;ïðîïóñê óäàëåííûõ è îòìåíåííûõ
  632.     cmp al,1
  633.     je .beg0
  634.     cmp bl,byte[edx+2] ;ïðîïóñê çàêðûòûõ
  635.     jl .beg0
  636.   @@:
  637.   pop eax
  638.   pop bx
  639.   ret
  640.  
  641.   .else:
  642.     call tl_move_next
  643.     cmp edx,ecx
  644.     jle .endif
  645.     cmp dword[edx+16],0 ;td = 'time delete' -> ïðîïóñê óäàëåííûõ
  646.     jne .else
  647.     cmp bl,byte[edx+2] ;ïðîïóñê çàêðûòûõ
  648.     jl .else
  649.   .endif:
  650.   pop bx
  651.   ret
  652.  
  653. ;input:
  654. ; ecx = pointer to 1 node struct
  655. ; edx = pointer to some node struct
  656. ; edi = pointer to 'TreeList' struct
  657. align 4
  658. tl_iterat_next_all:
  659.   cmp tl_tim_undo,0
  660.   je .else
  661.  
  662.   push eax
  663.   @@:
  664.     call tl_move_next
  665.     cmp edx,ecx
  666.     jle @f
  667.     call tl_node_not_vis
  668.     cmp al,1
  669.     je @b
  670.   @@:
  671.   pop eax
  672.   ret
  673.   .else:
  674.     call tl_move_next
  675.     cmp edx,ecx
  676.     jle .endif
  677.     cmp dword[edx+16],0 ;td -> time delete
  678.     jne .else
  679.   .endif:
  680.   ret
  681.  
  682. ;input:
  683. ; ecx = pointer to 1 node struct
  684. ; edx = pointer to some node struct
  685. ; edi = pointer to 'TreeList' struct
  686. align 4
  687. tl_iterat_perv:
  688.   push bx
  689.   mov bl,0x7f
  690.   cmp byte[edx+3],1
  691.   jne @f
  692.     mov bl,byte[edx+2]
  693.   @@:
  694.  
  695.   cmp tl_tim_undo,0
  696.   je .else
  697.  
  698.   push eax
  699.   .beg0:
  700.     call tl_move_perv
  701.     cmp edx,ecx
  702.     jle @f
  703.     call tl_node_not_vis ;ïðîïóñê óäàëåííûõ è îòìåíåííûõ
  704.     cmp al,1
  705.     je .beg0
  706.     cmp bl,byte[edx+2] ;ïðîïóñê çàêðûòûõ
  707.     jl .beg0
  708.   @@:
  709.   pop eax
  710.   pop bx
  711.   ret
  712.  
  713.   .else:
  714.     call tl_move_perv
  715.     cmp edx,ecx
  716.     jle .endif
  717.     cmp dword[edx+16],0 ;td = 'time delete' -> ïðîïóñê óäàëåííûõ
  718.     jne .else
  719.     cmp bl,byte[edx+2] ;ïðîïóñê çàêðûòûõ
  720.     jl .else
  721.   .endif:
  722.   pop bx
  723.   ret
  724.  
  725. ;input:
  726. ; edx = pointer to some node struct
  727. ; edi = pointer to 'TreeList' struct
  728. ;output:
  729. ; edx = pointer to next node struct
  730. align 4
  731. tl_move_next:
  732.   mov edx,dword[edx+8]
  733.   imul edx,sizeof.TreeList
  734.   add edx,tl_data_nodes
  735.   ret
  736.  
  737. ;input:
  738. ; edx = pointer to some node struct
  739. ; edi = pointer to 'TreeList' struct
  740. ;output:
  741. ; edx = pointer to perv node struct
  742. align 4
  743. tl_move_perv:
  744.   mov edx,dword[edx+4]
  745.   imul edx,sizeof.TreeList
  746.   add edx,tl_data_nodes
  747.   ret
  748.  
  749. ;input:
  750. ; edx = pointer to symbol struct
  751. ; edi = pointer to 'TreeList' struct
  752. ;output:
  753. ; al = 1 if sumbol not visible
  754. ; (node[i].td+tim_Undo<=ch_tim && node[i].td) || (node[i].tc>ch_tim-tim_Undo)
  755. align 4
  756. tl_node_not_vis:
  757.   cmp dword[edx+16],0
  758.   je @f
  759.   mov eax,dword[edx+16] ;eax=node[i].td
  760.   add eax,tl_tim_undo
  761.   cmp eax,tl_ch_tim
  762.   jg @f
  763.     mov al,1
  764.     ret
  765.   @@:
  766.  
  767.   mov eax,tl_ch_tim
  768.   sub eax,tl_tim_undo
  769.   cmp dword[edx+12],eax ;tc -> time create
  770.   jle @f
  771.     mov al,1
  772.     ret
  773.   @@:
  774.   xor al,al
  775.   ret
  776.  
  777.  
  778. ;input:
  779. ; edi = pointer to TreeInfo struct
  780. ; esi = coord bottom border
  781. align 4
  782. tl_draw_cursor: ;ðèñóåì êóðñîð íà ýêðàíå
  783.   push eax ebx ecx edx esi
  784.     call tl_get_display_cur_pos ;eax = cursor pos in screen
  785.     cmp eax,0
  786.     jl .end_f ;êóðñîð íàõîäèòñÿ âûøå îêíà, â îáëàñòè ïðîêðó÷åííîé ñêðîëëèíãîì
  787.  
  788.     cmp tl_data_img_sys,0 ;ñìîòðèì åñòü ëè óêàçàòåëü íà êàðòèíêó ñèñòåìíûõ èêîíîê
  789.     jne @f
  790.       mov ebx,tl_box_left
  791.       shl ebx,16
  792.       mov bx,tl_img_cx
  793.       xor ecx,ecx
  794.       mov cx,tl_img_cy
  795.       imul ecx,eax
  796.       add ecx,tl_box_top
  797.       add cx,tl_capt_cy
  798.  
  799.       ;crop image if on the border
  800.       cmp esi,ecx ;åñëè êóðñîð âíèçó è åãî âîîáùå íå âèäíî
  801.       jl .end_f
  802.  
  803.       sub esi,ecx
  804.       shl ecx,16
  805.       mov cx,tl_img_cy
  806.       cmp si,tl_img_cy
  807.       jge .crop0
  808.         mov cx,si ;åñëè êóðñîð âèäåí ÷àñòè÷íî (ïîïàë íà íèæíþþ ãðàíèöó)
  809.       .crop0:
  810.  
  811.       mov edx,tl_col_txt
  812.       mov eax,13
  813.       int 0x40 ;ðèñóåì ïðîñòîé ïðÿìîóãîëüíèê, ò.ê. íåò ñèñòåìíûõ èêîíîê
  814.       jmp .end_f
  815.     @@:
  816.       mov ebx,tl_data_img_sys
  817.       imul ax,tl_img_cy
  818.       mov cx,tl_img_cx
  819.       shl ecx,16
  820.       mov cx,tl_img_cy
  821.       mov edx,tl_box_left
  822.       shl edx,16
  823.       mov dx,ax
  824.       add edx,tl_box_top
  825.       add dx,tl_capt_cy
  826.  
  827.       ;crop image if on the border
  828.       cmp si,dx ;åñëè êóðñîð âíèçó è åãî âîîáùå íå âèäíî
  829.       jl .end_f
  830.  
  831.       sub si,dx
  832.       cmp si,tl_img_cy
  833.       jge .crop1
  834.         mov cx,si ;åñëè êóðñîð âèäåí ÷àñòè÷íî (ïîïàë íà íèæíþþ ãðàíèöó)
  835.       .crop1:
  836.  
  837.       mov eax,7
  838.       int 0x40 ;ðèñóåì èêîíêó êóðñîðà
  839.     .end_f:
  840.   pop esi edx ecx ebx eax
  841.   ret
  842.  
  843. ;input:
  844. ; edi = pointer to TreeInfo struct
  845. ; esi = coord bottom border
  846. align 4
  847. tl_draw_null_cursor: ;ñòèðàåì êóðñîð íà ýêðàíå
  848.   push eax ebx ecx edx esi
  849.     call tl_get_display_cur_pos ;eax = cursor pos in screen
  850.     cmp eax,0
  851.     jl .end_f ;êóðñîð íàõîäèòñÿ âûøå îêíà, â îáëàñòè ïðîêðó÷åííîé ñêðîëëèíãîì
  852.  
  853.     mov ebx,tl_box_left
  854.     shl ebx,16
  855.     mov bx,tl_img_cx
  856.     xor ecx,ecx
  857.     mov cx,tl_img_cy
  858.     imul ecx,eax
  859.     add ecx,tl_box_top
  860.     add cx,tl_capt_cy
  861.  
  862.     ;crop image if on the border
  863.     cmp esi,ecx ;åñëè êóðñîð âíèçó è åãî âîîáùå íå âèäíî
  864.     jl .end_f
  865.  
  866.     sub esi,ecx
  867.     shl ecx,16
  868.     mov cx,tl_img_cy
  869.     cmp si,tl_img_cy
  870.     jge @f
  871.       mov cx,si ;åñëè êóðñîð âèäåí ÷àñòè÷íî (ïîïàë íà íèæíþþ ãðàíèöó)
  872.     @@:
  873.  
  874.     mov edx,tl_col_bkg
  875.     mov eax,13
  876.     int 0x40 ;ðèñóåì ïðîñòîé ïðÿìîóãîëüíèê ñ ôîíîâûì öâåòîì
  877.  
  878.     .end_f:
  879.   pop esi edx ecx ebx eax
  880.   ret
  881.  
  882. ;input:
  883. ; edi = pointer to TreeInfo struct
  884. ;output:
  885. ; eax = index
  886. align 4
  887. tl_get_display_cur_pos: ;áåðåò ïîçèöèþ êóðñîðà, îòíîñèòåëüíî ýêðàíà
  888.    mov eax,tl_cur_pos
  889.    cmp tl_p_scrol,0
  890.    je @f
  891.      push ebx
  892.        mov ebx,tl_p_scrol
  893.        mov ebx,dword[ebx+24]
  894.        sub eax,ebx ;îòíèìàåì ïîçèöèþ ñêðîëëèíãà
  895.      pop ebx
  896.   @@:
  897.   ret
  898.  
  899. ;input:
  900. ; eax = node position
  901. ; edx = pointer to some node struct
  902. ; edi = pointer to TreeInfo struct
  903. ; esi = coord of bottom border
  904. align 4
  905. tl_draw_node:
  906.   push eax ebx ecx edx esi
  907.  
  908.     mov ebx,1 ;1 - ìåñòî ïîä êóðñîð è ïîä çíàê +,-
  909.     bt tl_style,2 ;tl_list_box_mode
  910.     jc @f
  911.       inc ebx ;+1 - ìåñòî ïîä çíàê +,-
  912.     @@:
  913.     add bl,byte[edx+2];get level
  914.     imul bx,tl_img_cx
  915.     add ebx,tl_box_left
  916.  
  917.     shl ebx,16
  918.     mov bx,tl_img_cx
  919.     xor ecx,ecx
  920.     mov cx,tl_img_cy
  921.     imul ecx,eax
  922.     add ecx,tl_box_top
  923.     add cx,tl_capt_cy
  924.  
  925.     ;crop image if on the border
  926.     cmp esi,ecx ;åñëè óçåë âíèçó è åãî âîîáùå íå âèäíî
  927.     jl .end_draw
  928.  
  929.     sub esi,ecx
  930.     shl ecx,16
  931.     mov cx,tl_img_cy
  932.     cmp si,tl_img_cy
  933.     jge @f
  934.       mov cx,si ;åñëè óçåë âèäåí ÷àñòè÷íî (ïîïàë íà íèæíþþ ãðàíèöó)
  935.       jmp .crop ;ïðîïóñêàåì ðèñîâàíèå íàäïèñè, êîòîðàÿ ñêîðåå âñåãî òîæå âûëåçåò çà íèæíþþ ãðàíèöó
  936.     @@:
  937.       call tl_draw_node_caption
  938.     .crop:
  939.     mov esi,ecx ;save ecx
  940.  
  941.     cmp dword[edi+18],0 ;data_img
  942.     jne .draw_img_n
  943.     push edx
  944.       mov edx,tl_col_txt
  945.       mov eax,13
  946.       int 0x40 ;draw node rect
  947.     pop edx
  948.     jmp @f
  949.     .draw_img_n:
  950.     push ebx edx esi
  951.       xor esi,esi
  952.       mov si,word[edx] ;get icon type
  953.       mov edx,ebx
  954.       ror ecx,16
  955.       mov dx,cx
  956.       mov cx,bx
  957.       ror ecx,16
  958.       mov ebx,3 ;rgb = 3 bytes
  959.       imul bx,tl_img_cx
  960.       imul bx,tl_img_cy
  961.       imul ebx,esi ;esi = icon index
  962.       add ebx,dword[edi+18] ;data_img
  963.  
  964.       mov eax,7
  965.       int 0x40 ;draw node icon '-'
  966.     pop esi edx ebx
  967.     @@:
  968.  
  969.     mov al,byte[edx+2] ;draw minus '-'
  970.     mov ecx,tl_data_nodes
  971.     add ecx,sizeof.TreeList
  972.  
  973.     mov ah,10 ;get icon index '+' or '-' ?
  974.     cmp byte[edx+3],1
  975.     jne .close
  976.       dec ah
  977.     .close:
  978.  
  979.     call tl_draw_node_icon_opn_clo
  980.     bt tl_style,1
  981.     jae .end_draw
  982.       call tl_draw_node_icon_par_lin
  983.  
  984.     .end_draw:
  985.   pop esi edx ecx ebx eax
  986.   ret
  987.  
  988. ;input:
  989. ; ecx = pointer to 1 node struct
  990. ;...
  991. align 4
  992. tl_draw_node_icon_opn_clo:
  993.   push eax ebx ecx edx esi
  994.     inc al
  995.     call tl_iterat_next_all ;get next visible item
  996.     cmp edx,ecx
  997.     jle @f
  998.       mov ecx,esi ;load ecx
  999.       cmp al,byte[edx+2]
  1000.       jne @f
  1001.       ror ebx,16
  1002.       sub bx,tl_img_cx
  1003.       ror ebx,16
  1004.       cmp tl_data_img_sys,0
  1005.       jne .draw_img_s
  1006.         mov edx,tl_col_txt
  1007.         mov eax,13
  1008.         int 0x40 ;draw minus rect, if not system icons
  1009.         jmp @f
  1010.       .draw_img_s:
  1011.       mov ecx,esi ;load ecx
  1012.       mov edx,ebx
  1013.       ror ecx,16
  1014.       mov dx,cx
  1015.       mov cx,bx
  1016.       ror ecx,16
  1017.       mov ebx,3 ;rgb = 3 bytes
  1018.       imul bx,tl_img_cx
  1019.       imul bx,tl_img_cy
  1020.       shr eax,8
  1021.       and eax,0xff
  1022.       imul ebx,eax ;eax = icon index
  1023.       add ebx,tl_data_img_sys
  1024.       mov eax,7
  1025.       int 0x40 ;draw minus icon '-'
  1026.     @@:
  1027.   pop esi edx ecx ebx eax
  1028.   ret
  1029.  
  1030. ;input:
  1031. ;...
  1032. align 4
  1033. tl_draw_node_icon_par_lin:
  1034.   cmp byte[edx+3],1
  1035.   je .close
  1036.   push eax ebx ecx edx esi
  1037.     cmp al,0
  1038.     je @f
  1039. ;    dec al
  1040. ;    call tl_iterat_perv ;get perv visible item
  1041.  
  1042.     call tl_iterat_next_all ;get next visible item
  1043.     cmp edx,ecx
  1044.     jle .line3 ;if end of list
  1045.       cmp al,byte[edx+2]
  1046.       jne .line3 ;jg ???
  1047.       mov eax,3 ;line in middle element
  1048.       jmp .line2
  1049.     .line3:
  1050.       mov eax,6 ;line in end element
  1051.     .line2:
  1052.  
  1053.       mov ecx,esi ;load ecx
  1054.       ror ebx,16
  1055.       sub bx,tl_img_cx
  1056.       ror ebx,16
  1057.       cmp tl_data_img_sys,0
  1058.       jne .draw_img_s
  1059.         mov edx,tl_col_txt
  1060.         mov eax,13
  1061.         int 0x40 ;draw minus rect, if not system icons
  1062.         jmp @f
  1063.       .draw_img_s:
  1064.       mov ecx,esi ;load ecx
  1065.       mov edx,ebx
  1066.       ror ecx,16
  1067.       mov dx,cx
  1068.       mov cx,bx
  1069.       ror ecx,16
  1070.       mov ebx,3 ;rgb = 3 bytes
  1071.       imul bx,tl_img_cx
  1072.       imul bx,tl_img_cy
  1073.  
  1074. ;      shr eax,8
  1075. ;      and eax,0xff
  1076.       imul ebx,eax ;eax = icon index
  1077.       add ebx,tl_data_img_sys
  1078.       mov eax,7
  1079.       int 0x40 ;draw line icon
  1080.     @@:
  1081.   pop esi edx ecx ebx eax
  1082.   .close:
  1083.   ret
  1084.  
  1085. ;input:
  1086. ; edi = pointer to TreeInfo struct
  1087. ;output:
  1088. ; eax = rows
  1089. align 4
  1090. tl_get_rows_count:
  1091.   push ecx edx
  1092.     mov eax,tl_box_height
  1093.     sub ax,tl_capt_cy
  1094.     xor ecx,ecx
  1095.     mov cx,tl_img_cy
  1096.     xor edx,edx
  1097.     div ecx
  1098.   pop edx ecx
  1099.   ret
  1100.  
  1101. ;input:
  1102. ; eax = node position
  1103. ; ebx = [êîîðäèíàòà ïî îñè x]*65536 + [img_cx]
  1104. ; ecx = [êîîðäèíàòà ïî îñè y]*65536 + [img_cy]
  1105. ; edx = pointer to some node struct
  1106. ; edi = pointer to TreeInfo struct
  1107. align 4
  1108. tl_draw_node_caption:
  1109.     push ebx ecx edx esi
  1110.  
  1111.     xor esi,esi
  1112.     mov si,tl_info_size
  1113.     cmp esi,tl_info_capt_offs
  1114.     jle @f ;if caption size <= 0
  1115.  
  1116.     push eax
  1117.       call tl_get_node_index ;eax = node index
  1118.       imul esi,eax
  1119.     pop eax
  1120.       add esi,dword[edi]
  1121.       add esi,tl_info_capt_offs
  1122.       mov edx,esi
  1123.  
  1124.       shr ebx,16
  1125.       add bx,tl_img_cx ;ñäâèãàåì íàäïèñü ïî ãîðèçîíòàëè --->
  1126.       add bx,3 ;îòñòóï
  1127.       ;bx = coord. x
  1128.       call tl_strlen ;eax = strlen
  1129.       call tl_get_draw_text_len
  1130.       mov cx,bx
  1131.       ror ecx,16
  1132.       mov ebx,ecx
  1133.       add bx,tl_img_cy ;âûðàâíèâèíèå ïî íèæíåé ãðàíèöå èêîíêè
  1134.       sub bx,9 ;îòíèìàåì âûñîòó òåêñòà
  1135.       mov ecx,tl_col_txt
  1136.       and ecx,0xffffff
  1137. ;      or ecx,0x80000000 ;text is ASCIIZ
  1138.       mov eax,4
  1139.       int 0x40
  1140.     @@:
  1141.     pop esi edx ecx ebx
  1142.   ret
  1143.  
  1144. ;input:
  1145. ; eax = strlen
  1146. ; ebx = text coord x
  1147. ;output:
  1148. ; esi = text len
  1149. align 4
  1150. tl_get_draw_text_len:
  1151.   push eax ecx edx
  1152.     mov esi,eax ;áåðåì äëèííó ñòðîêè
  1153.  
  1154.     mov eax,tl_box_left
  1155.     add eax,tl_box_width
  1156.     cmp eax,ebx
  1157.     jle .text_null ;åñëè ïîäïèñü ïîëíîñòüþ âñÿ çà ýêðàíîì
  1158.     sub eax,ebx
  1159.     xor edx,edx
  1160.     mov ecx,6 ;øèðèíà ñèñòåìíîãî øðèôòà
  1161.     div ecx ;ñìîòðèì ñêîëüêî ñèìâîëîâ ìîæåò ïîìåñòèòüñÿ íà ýêðàíå
  1162.  
  1163.     cmp esi,eax
  1164.     jl @f
  1165.       mov esi,eax ;åñëè äëèííà òåêñòà ìåíüøå, ÷åì âñå ìåñòî ïîä ñòðîêó
  1166.     jmp @f
  1167.     .text_null:
  1168.       xor esi,esi
  1169.     @@:
  1170.   pop edx ecx eax
  1171.   ret
  1172.  
  1173. ;input:
  1174. ; esi = pointer to string
  1175. ;output:
  1176. ; eax = strlen
  1177. align 4
  1178. tl_strlen:
  1179.   mov eax,esi
  1180.   @@:
  1181.     cmp byte[eax],0
  1182.     je @f
  1183.     inc eax
  1184.     loop @b
  1185.   @@:
  1186.   sub eax,esi
  1187.   ret
  1188.  
  1189. ;input:
  1190. ;dword[ebp+ 8] - pointer to node info
  1191. ;dword[ebp+12] - options
  1192. ;dword[ebp+16] - pointer to 'TreeList' struct
  1193. align 4
  1194. tl_node_add: ;äîáàâèòü óçåë
  1195.   push ebp
  1196.   mov ebp,esp
  1197.   push eax ebx ecx edx edi
  1198.     mov edi,dword[ebp+16]
  1199.  
  1200.     call tl_info_set_undo
  1201.  
  1202.     mov ebx,sizeof.TreeList
  1203.     imul ebx,dword[edi+6] ;+6 ìàêñ. êîëè÷åñòâî óçëîâ
  1204.     add ebx,tl_data_nodes
  1205. ;--
  1206.     call tl_get_cur_node_index ;eax=po_t
  1207.     imul eax,sizeof.TreeList
  1208.     add eax,tl_data_nodes
  1209.     mov edx,eax
  1210.     call tl_move_perv
  1211.     call tl_get_node_index ;eax = index of pointer [edx]
  1212. ;--
  1213.     mov edx,sizeof.TreeList
  1214.     shl edx,1
  1215.     add edx,tl_data_nodes
  1216.     @@: ;for(i=2;i<nodeMax;i++)
  1217.       cmp dword [edx+12],0
  1218.       jne .u0
  1219.       cmp dword [edx+16],0
  1220.       jne .u0
  1221.  
  1222.         inc  tl_ch_tim
  1223.         push  word[ebp+14] ;get type
  1224.         pop   word[edx]
  1225.         mov   byte[edx+2], 0 ;node[i].lev=0
  1226.   bt tl_style,2 ;tl_list_box_mode
  1227.   jc .l_box_m
  1228.     mov cl,byte[ebp+12]
  1229.     mov byte[edx+2],cl  ;node[i].lev
  1230.   .l_box_m:
  1231.         push tl_ch_tim       ;node[i].tc=ch_tim;
  1232.         pop  dword[edx+12]
  1233.         mov  dword[edx+4], eax ;node[i].perv=po_t;
  1234.         ;*** copy node data ***
  1235.         push esi
  1236.         xor ecx,ecx
  1237.         mov cx,tl_info_size
  1238.         mov esi,ecx
  1239.  
  1240.         push eax
  1241.           call tl_get_node_index ;eax = node index
  1242.           imul esi,eax
  1243.         pop eax
  1244.         add esi,dword[edi]
  1245.         mov edi,dword[ebp+8] ;pointer to node data
  1246.         xchg edi,esi
  1247.         rep movsb
  1248.  
  1249.         mov esi,edi
  1250.         mov edi,dword[ebp+16] ;restore edi
  1251.         mov ecx,tl_info_capt_offs
  1252.         cmp cx,tl_info_size
  1253.         jge .no_text_data
  1254.           dec esi
  1255.           mov byte[esi],0
  1256.         .no_text_data:
  1257.         pop esi ;restore esi
  1258.  
  1259.         mov ecx,eax
  1260.         imul ecx,sizeof.TreeList
  1261.         add ecx,tl_data_nodes ; *** ecx = node[po_t] ***
  1262.         add ecx,8   ; *** ecx = node[po_t].next ***
  1263.         push dword [ecx] ;node[i].next=node[po_t].next;
  1264.         pop dword [edx+8]
  1265.  
  1266.         call tl_get_node_index ;*** eax = i ***
  1267.         cmp eax,dword[edi+6] ;info_max_count
  1268.         jge .u0
  1269.  
  1270.         mov [ecx],eax ;node[po_t].next=i; // ññûëêè ïåðåíàïðàâëÿåì
  1271.         mov ecx,[edx+8] ; *** ecx = node[i].next ***
  1272.         imul ecx,sizeof.TreeList
  1273.         add ecx,tl_data_nodes ; *** ecx = node[node[i].next] ***
  1274.         mov [ecx+4],eax ;node[node[i].next].perv=i;
  1275.  
  1276.         call tb_scrol_resize ;îáðàáîòêà ñêðîëëèíãà
  1277.     jmp @f
  1278.       .u0:
  1279.       add edx,sizeof.TreeList
  1280.       cmp edx,ebx ;enf of node memory ?
  1281.       jle @b
  1282.     @@:
  1283.   pop edi edx ecx ebx eax
  1284.   pop ebp
  1285.   ret 12
  1286.  
  1287. ;input:
  1288. ; edi = pointer to TreeInfo struct
  1289. align 4
  1290. tb_scrol_resize:
  1291.   push eax ecx edx
  1292.   cmp tl_p_scrol,0 ;îáðàáîòêà ñêðîëëèíãà
  1293.   je @f
  1294.     call tl_get_node_count ;eax = node count
  1295.     mov ecx,eax
  1296.     call tl_get_rows_count
  1297.     cmp ecx,eax
  1298.     jg .ye_sb
  1299.       xor ecx,ecx
  1300.     .ye_sb:
  1301.  
  1302.     mov edx,tl_p_scrol
  1303.     mov dword[edx+20],eax ;+20 .cur_area
  1304.     mov dword[edx+16],ecx ;+16 .max_area
  1305.     push dword edx ;pointer to scroll struct
  1306.     mov edx,tl_sb_draw ;pointer to scroll draw function
  1307.     call dword[edx]
  1308.   @@:
  1309.   pop edx ecx eax
  1310. ret
  1311.  
  1312. ;input:
  1313. ;dword[ebp+ 8] - pointer to node info
  1314. ;dword[ebp+12] - pointer to 'TreeList' struct
  1315. align 4
  1316. tl_node_set_data:
  1317.   push ebp
  1318.   mov ebp,esp
  1319.   push eax ecx edx edi esi
  1320.     mov edi,dword[ebp+12]
  1321.     call tl_get_cur_node_index ;eax=po_t
  1322.     cmp eax,2
  1323.     jl @f
  1324.       xor ecx,ecx
  1325.       mov cx,tl_info_size
  1326.       imul eax,ecx
  1327.       add eax,dword[edi]
  1328.       mov edi,eax
  1329.       mov esi,dword[ebp+8] ;pointer to node data
  1330.       rep movsb
  1331.  
  1332.       mov esi,edi
  1333.       mov edi,dword[ebp+12] ;restore edi
  1334.       mov ecx,tl_info_capt_offs
  1335.       cmp cx,tl_info_size
  1336.       jge .no_text_data
  1337.         dec esi
  1338.         mov byte[esi],0
  1339.       .no_text_data:
  1340.  
  1341.     @@:
  1342.   pop esi edi edx ecx eax
  1343.   pop ebp
  1344.   ret 8
  1345.  
  1346. ;input:
  1347. ;dword[ebp+ 8] - pointer to 'TreeList' struct
  1348. align 4
  1349. tl_node_get_data: ;âçÿòü óêàçàòåëü íà äàííûå óçëà ïîä êóðñîðîì
  1350.   push ebp
  1351.   mov ebp,esp
  1352.   push eax ecx edi
  1353.     mov edi,dword[ebp+8]
  1354.     call tl_get_cur_node_index ;eax=po_t
  1355.     mov dword[ebp+8],0 ;if return 0 pointer
  1356.     cmp eax,2
  1357.     jl @f
  1358.       xor ecx,ecx
  1359.       mov cx,tl_info_size
  1360.       imul eax,ecx
  1361.       add eax,dword[edi]
  1362.       mov dword[ebp+8],eax ;return node data pointer
  1363.     @@:
  1364.   pop edi ecx eax
  1365.   pop ebp
  1366.   ret
  1367.  
  1368. ;input:
  1369. ;dword[ebp+ 8] - node index
  1370. ;dword[ebp+12] - pointer to 'TreeList' struct
  1371. align 4
  1372. tl_node_poi_get_info: ;âçÿòü óêàçàòåëü íà ñòðóêòóðó óçëà â óêàçàííîé ïîçèöèè
  1373.   push ebp
  1374.   mov ebp,esp
  1375.   push eax ecx edx edi
  1376.     mov edi,dword[ebp+12]
  1377.     mov eax,dword[ebp+8]
  1378.  
  1379.     ;cycle to nodes
  1380.     mov edx,tl_data_nodes
  1381.     mov ecx,edx
  1382.     add ecx,sizeof.TreeList
  1383.     @@:
  1384.       call tl_iterat_next_all
  1385.       cmp edx,ecx
  1386.       jle @f
  1387.       dec eax
  1388.       cmp eax,0
  1389.       jg @b
  1390.       jmp .find
  1391.     @@:
  1392.       xor edx,edx
  1393.     .find:
  1394.     mov dword[ebp+12],edx
  1395.   pop edi edx ecx eax
  1396.   pop ebp
  1397.   ret 4
  1398.  
  1399. ;input:
  1400. ;dword[ebp+ 8] - node param struct
  1401. ;dword[ebp+12] - pointer to 'TreeList' struct
  1402. align 4
  1403. tl_node_poi_get_next_info: ;âçÿòü óêàçàòåëü íà ñëåäóùóþ ñòðóêòóðó óçëà
  1404.   push ebp
  1405.   mov ebp,esp
  1406.   push ecx edx edi
  1407.     mov edi,dword[ebp+12]
  1408.     mov edx,dword[ebp+8]
  1409.  
  1410.     mov ecx,tl_data_nodes
  1411.     add ecx,sizeof.TreeList
  1412.  
  1413.     call tl_iterat_next_all
  1414.     cmp edx,ecx
  1415.     jg @f
  1416.       xor edx,edx
  1417.     @@:
  1418.  
  1419.     mov dword[ebp+12],edx
  1420.   pop edi edx ecx
  1421.   pop ebp
  1422.   ret 4
  1423.  
  1424. ;input:
  1425. ;dword[ebp+ 8] - node param struct
  1426. ;dword[ebp+12] - pointer to 'TreeList' struct
  1427. align 4
  1428. tl_node_poi_get_data: ;âçÿòü óêàçàòåëü íà äàííûå óçëà
  1429.   push ebp
  1430.   mov ebp,esp
  1431.   push eax ecx edi
  1432.     mov edi,dword[ebp+12]
  1433.     mov edx,dword[ebp+8]
  1434.  
  1435.     mov dword[ebp+12],0
  1436.     call tl_get_node_index ;eax = node index
  1437.     cmp eax,2
  1438.     jl @f
  1439.       xor ecx,ecx
  1440.       mov cx,tl_info_size
  1441.       imul eax,ecx
  1442.       add eax,dword[edi]
  1443.       mov dword[ebp+12],eax ;return node data pointer
  1444.     @@:
  1445.   pop edi ecx eax
  1446.   pop ebp
  1447.   ret 4
  1448.  
  1449. ;input:
  1450. ; edi = pointer 'tl' struct
  1451. ;output:
  1452. ; eax = index of current node
  1453. align 4
  1454. tl_get_cur_node_index: ;áåðåò ïîçèöèþ ïîä êóðñîðîì
  1455.   push ecx edx
  1456.     ;cycle to nodes
  1457.     xor eax,eax
  1458.     mov edx,tl_data_nodes
  1459.     mov ecx,edx
  1460.     add ecx,sizeof.TreeList
  1461.     @@:
  1462.       call tl_iterat_next
  1463.       cmp edx,ecx
  1464.       jle @f
  1465.       cmp eax,tl_cur_pos
  1466.       je @f
  1467.       inc eax
  1468.       jmp @b
  1469.     @@:
  1470.   mov eax,edx
  1471.   sub eax,tl_data_nodes
  1472.   xor edx,edx
  1473.   mov ecx,sizeof.TreeList
  1474.   div ecx
  1475.   pop edx ecx
  1476.   ret
  1477.  
  1478. ;input:
  1479. ; edx = pointer node memory
  1480. ; edi = pointer 'tl' struct
  1481. ;output:
  1482. ; eax = struct index of current node
  1483. align 4
  1484. tl_get_node_index: ;áåðåò ïîçèöèþ óêàçàííîãî ñèìâîëà
  1485.   push ecx edx
  1486.   mov eax,edx
  1487.   sub eax,tl_data_nodes
  1488.   xor edx,edx
  1489.   mov ecx,sizeof.TreeList
  1490.   div ecx
  1491.   pop edx ecx
  1492.   ret
  1493.  
  1494. align 4
  1495. tl_node_delete: ;óäàëèòü óçåë
  1496.   push ebp
  1497.   mov ebp,esp
  1498.   push eax edx edi
  1499.     mov edi,dword[ebp+8]
  1500.     call tl_get_cur_node_index ;eax=po_t
  1501.     cmp eax,2
  1502.     jl @f
  1503.       imul eax,sizeof.TreeList
  1504.       add eax,tl_data_nodes
  1505.       mov edx,eax
  1506.       inc tl_ch_tim
  1507.       mov eax,tl_ch_tim
  1508.       mov dword[edx+16],eax
  1509.       call tb_scrol_resize ;îáðàáîòêà ñêðîëëèíãà
  1510.     @@:
  1511.   pop edi edx eax
  1512.   pop ebp
  1513.   ret 4
  1514.  
  1515. align 4
  1516. tl_cur_beg: ;ïîñòàâèòü êóðñîð íà ïåðâûé óçåë
  1517.   push ebp
  1518.   mov ebp,esp
  1519.   push edi
  1520.     mov edi,dword[ebp+8]
  1521.     mov tl_cur_pos,0
  1522.     cmp tl_p_scrol,0
  1523.     je @f
  1524.       mov edi,tl_p_scrol
  1525.       mov dword[edi+24],0
  1526.       push dword edi
  1527.       mov edi,dword[ebp+8]
  1528.       mov edi,tl_sb_draw
  1529.       call dword[edi]
  1530.     @@:
  1531.   pop edi
  1532.  
  1533.   pop ebp
  1534.   ret 4
  1535.  
  1536. align 4
  1537. tl_cur_next: ;ïåðåíåñòè êóðñîð íà 1 ïîçèöèþ íèæå
  1538.   push ebp
  1539.   mov ebp,esp
  1540.   push eax ebx edi esi
  1541.     mov edi,dword[ebp+8]
  1542.     call tl_get_node_count ;eax = node count
  1543.     ;inc eax
  1544.     cmp tl_cur_pos,eax
  1545.     jge .no_redraw
  1546.       mov esi,tl_box_top
  1547.       add esi,tl_box_height ;esi = coord bottom border
  1548.       call tl_draw_null_cursor ;ñòèðàåì êóðñîð
  1549.       inc tl_cur_pos
  1550.  
  1551.     cmp tl_p_scrol,0 ;if not scrol struct
  1552.     je @f
  1553.     call tl_get_rows_count ;eax = rows count
  1554.     mov ebx,tl_p_scrol
  1555.     add eax,dword[ebx+24] ;.position +24
  1556.     cmp tl_cur_pos,eax
  1557.     jl @f
  1558.       inc dword[ebx+24] ;.position +24
  1559.       push dword ebx
  1560.       mov edi,tl_sb_draw ;ïåðåðèñîâêà ñêðîëëèíãà
  1561.       call dword[edi]
  1562.  
  1563.       mov edi,dword[ebp+8] ;restore edi
  1564.       push dword edi
  1565.       call tl_draw ;ïîëíàÿ ïåðåðèñîâêà îêíà
  1566.       jmp .no_redraw
  1567.     @@:
  1568.       mov edi,dword[ebp+8] ;restore edi
  1569.       call tl_draw_cursor ;ïåðåðèñîâêà êóðñîðà
  1570.     .no_redraw:
  1571.   pop esi edi ebx eax
  1572.   pop ebp
  1573.   ret 4
  1574.  
  1575.  
  1576. ;input:
  1577. ; edi = pointer 'tl' struct
  1578. ;output:
  1579. ; eax = struct index of current node
  1580. align 4
  1581. tl_get_node_count: ;áåðåò ÷èñëî âñåõ âèäèìûõ óçëîâ (íå ñ÷èòàÿ çàêðûòûõ äî÷åðíèõ)
  1582.   push ecx edx
  1583.     ;cycle to nodes
  1584.     xor eax,eax
  1585.     mov edx,tl_data_nodes
  1586.     mov ecx,edx
  1587.     add ecx,sizeof.TreeList
  1588.     @@:
  1589.       call tl_iterat_next
  1590.       cmp edx,ecx
  1591.       jle @f
  1592.       inc eax
  1593.       jmp @b
  1594.     @@:
  1595.   pop edx ecx
  1596.   ret
  1597.  
  1598. align 4
  1599. tl_cur_perv: ;ïåðåíåñòè êóðñîð íà 1 ïîçèöèþ âûøå
  1600.   push ebp
  1601.   mov ebp,esp
  1602.   push eax edi esi
  1603.     mov edi,dword[ebp+8]
  1604.     cmp tl_cur_pos,0
  1605.     je .no_redraw
  1606.       mov esi,tl_box_top
  1607.       add esi,tl_box_height ;esi = coord bottom border
  1608.       call tl_draw_null_cursor ;ñòèðàåì êóðñîð
  1609.       dec tl_cur_pos ;äâèãàåì êóðñîð ââåðõ
  1610.  
  1611.     cmp tl_p_scrol,0 ;åñëè åñòü óêàçàòåëü íà ñêðîëëèíã
  1612.     je @f
  1613.     mov eax,tl_p_scrol
  1614.     cmp dword[eax+24],0 ;åñëè ñêðîëëèíã íà âåðõó, âûõîäèì
  1615.     je @f
  1616.     mov edi,tl_cur_pos
  1617.     cmp edi,dword[eax+24] ;åñëè êóðñîð óøåë âûøå ñêðîëëèíãà, òîãäà îïóñêàåì ñêðîëëèíã
  1618.     jge @f
  1619.       dec dword[eax+24]
  1620.       push dword eax
  1621.       mov edi,dword[ebp+8]
  1622.       mov edi,tl_sb_draw ;.redraw
  1623.       call dword[edi]
  1624.       mov edi,dword[ebp+8] ;restore edi
  1625.       push dword edi
  1626.       call tl_draw ;ïîëíàÿ ïåðåðèñîâêà îêíà
  1627.       jmp .no_redraw
  1628.     @@:
  1629.       mov edi,dword[ebp+8] ;restore edi
  1630.       ;mov esi,tl_box_top
  1631.       ;add esi,tl_box_height ;esi = coord bottom border
  1632.       call tl_draw_cursor ;ïåðåðèñîâêà êóðñîðà
  1633.     .no_redraw:
  1634.   pop esi edi eax
  1635.   pop ebp
  1636.   ret 4
  1637.  
  1638. align 4
  1639. tl_node_close_open: ;îòêðûòü/çàêðûòü óçåë (ðàáîòàåò ñ óçëàìè êîòîðûå èìåþò äî÷åðíèå óçëû)
  1640.   push ebp
  1641.   mov ebp,esp
  1642.   push eax edx edi
  1643.     mov edi,dword[ebp+8]
  1644.     call tl_get_cur_node_index ;eax = ïîçèöèÿ óçëà íà êîòîðîì ñòîèò êóðñîð
  1645.     cmp eax,2 ;êóðñîð ñòîèò íà óçëå ?
  1646.     jl @f
  1647.       imul eax,sizeof.TreeList
  1648.       add eax,tl_data_nodes
  1649.       ;eax = óêàçàòåëü íà ñòðóêòóðó óçëà âûáðàííîãî êóðñîðîì
  1650.       push dword edi
  1651.       push dword eax
  1652.       call tl_node_poi_get_next_info
  1653.       pop dword edx ;edx = óêàçàòåëü íà ñòðóêòóðó óçëà êîòîðûé èäåò ïîñëå óçëà eax
  1654.       cmp edx,0 ;åñòü ëè óçëû íèæå âûáðàííîãî íàìè ?
  1655.       je @f
  1656.         mov dl,byte[edx+2] ;áåðåì óðîâåíü íèæíåãî óçëà
  1657.         cmp byte[eax+2],dl ;+2 = .lev
  1658.         jge @f ;åñëè íèæíèå óçëû ìåíüøåãî óðîâíÿ, çíà÷èò îíè íå äî÷åðíèå, êîíåö ôóíêöèè
  1659.           xor byte[eax+3],1 ;+3 = .clo *** îòêðûòèå/çàêðûòèå óçëà ***
  1660.           call tb_scrol_resize ;îáðàáîòêà ñêðîëëèíãà
  1661.  
  1662.           push dword edi
  1663.           call tl_draw ;îáíîâëåíèå îêíà
  1664.     @@:
  1665.   pop edi edx eax
  1666.   pop ebp
  1667.   ret 4
  1668.  
  1669. align 4
  1670. tl_node_lev_inc: ;óâåëè÷èòü óðîâåíü
  1671.   push ebp
  1672.   mov ebp,esp
  1673.   push eax edx edi
  1674.     mov edi,dword[ebp+8]
  1675.     bt tl_style,2 ;tl_list_box_mode
  1676.     jc @f
  1677.     call tl_get_cur_node_index ;eax=po_t
  1678.     cmp eax,2
  1679.     jl @f
  1680.       imul eax,sizeof.TreeList
  1681.       add eax,tl_data_nodes
  1682.       mov edx,eax
  1683.       inc word[edx+2]
  1684.     @@:
  1685.   pop edi edx eax
  1686.   pop ebp
  1687.   ret 4
  1688.  
  1689. align 4
  1690. tl_node_lev_dec: ;óìåíüøèòü óðîâåíü
  1691.   push ebp
  1692.   mov ebp,esp
  1693.   push eax edx edi
  1694.     mov edi,dword[ebp+8]
  1695.     call tl_get_cur_node_index ;eax=po_t
  1696.     cmp eax,2
  1697.     jl @f
  1698.       imul eax,sizeof.TreeList
  1699.       add eax,tl_data_nodes
  1700.       mov edx,eax
  1701.       cmp word[edx+2],0
  1702.       je @f
  1703.       dec word[edx+2]
  1704.     @@:
  1705.   pop edi edx eax
  1706.   pop ebp
  1707.   ret 4
  1708.  
  1709. txt_capt_cur db '‘âப ',0
  1710. txt_capt_otm db 'Žâ¬¥­ë',0
  1711. }