Subversion Repositories Kolibri OS

Rev

Rev 8533 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. ; í«¥¬¥­â TreeList ¤«ï ¡¨¡«¨®â¥ª¨ box_lib.obj
  2. ; ­  ª®¤ ¯à¨¬¥­¥­  GPL2 «¨æ¥­§¨ï
  3. ; ¯®á«¥¤­ïï ¬®¤¨ä¨ª æ¨ï 12.01.2021 IgorA
  4.  
  5.  
  6. struct TreeNode
  7.         type dw ? ;+ 0 ⨯ í«¥¬¥­â , ¨«¨ ¨­¤¥ªá ¨ª®­ª¨ ¤«ï 㧫 
  8.         level db ? ;+ 2 ã஢¥­ì í«¥¬¥­â 
  9.         close db ? ;+ 3 ä« £ § ªàëâ¨ï, ¨«¨ ®âªàëâ¨ï (¨¬¥¥â á¬ëá« ¤«ï த¨â¥«ì᪮£® 㧫 )
  10.         perv dd ? ;+ 4 ¨­¤¥ªá ¯à¥¤ë¤ã饣® í«¥¬¥­â 
  11.         next dd ? ;+ 8 ¨­¤¥ªá ¯®á«¥¤ãî饣® í«¥¬¥­â 
  12.         t_create dd ? ;+12 ¢à¥¬. ᮧ¤ ­¨ï
  13.         t_delete dd ? ;+16 ¢à¥¬. 㤠«¥­¨ï
  14. ends
  15.  
  16.  
  17. ;¢ë¤¥«­¨¥ ¯ ¬ï⨠¤«ï áâàãªâãà ᯨ᪠ ¨ ®á­®¢­®© ¨­ä®à¬ æ¨¨ (ª®­áâàãªâ®à)
  18. align 16
  19. proc tl_data_init uses eax ecx edi, tlist:dword
  20.         mov edi,[tlist]
  21.  
  22.         xor ecx,ecx
  23.         mov cx,tl_info_size
  24.         imul ecx,tl_info_max_count
  25.         invoke mem.alloc,ecx
  26.         mov tl_data_info,eax ;ª®¯¨à㥬 㪠§ â¥«ì ­  ¯®«ã祭ãî ¯ ¬ïâì ¢ áâàãªâãàã
  27.         mov tl_data_img,0  ;®¡­ã«ï¥¬ 㪠§ â¥«ì 'data_img'
  28.         mov tl_data_img_sys,0 ;®¡­ã«ï¥¬ 㪠§ â¥«ì 'data_img_sys'
  29.  
  30.         mov ecx,sizeof.TreeNode
  31.         imul ecx,tl_info_max_count
  32.         invoke mem.alloc,ecx
  33.         mov tl_data_nodes,eax ;ª®¯¨à㥬 㪠§ â¥«ì ­  ¯®«ã祭ãî ¯ ¬ïâì ¢ áâàãªâãàã
  34.  
  35.         stdcall tl_info_clear, edi
  36.  
  37.         ;­ áâனª¨ ¤®ç¥à­¥£® áªà®««¨­£ 
  38.         cmp tl_p_scroll,0
  39.         je @f
  40.                 mov eax,tl_p_scroll
  41.                 ;*** æ¢¥â®¢ë¥ ­ áâனª¨ ***
  42.                 mov ecx,tl_col_bkg
  43.                 mov dword[eax+sb_offs_bckg_col],ecx
  44.                 mov ecx,tl_col_zag
  45.                 mov dword[eax+sb_offs_frnt_col],ecx
  46.                 mov ecx,tl_col_txt
  47.                 mov dword[eax+sb_offs_line_col],ecx
  48.                 ;*** ­ áâனª¨ à §¬¥à®¢ ***
  49.                 mov ecx,tl_box_left
  50.                 add ecx,tl_box_width
  51.                 mov word[eax+2],cx
  52.                 mov ecx,tl_box_height
  53.                 mov word[eax+4],cx
  54.                 mov ecx,tl_box_top
  55.                 mov word[eax+6],cx
  56.         @@:
  57.         ret
  58. endp
  59.  
  60. ;®ç¨á⪠ ¯ ¬ïâ¨ í«¥¬¥­â  (¤¥áâàãªâ®à)
  61. align 4
  62. proc tl_data_clear uses eax edi, tlist:dword
  63.         mov edi,[tlist]
  64.         cmp tl_data_img,0
  65.         je @f
  66.                 invoke mem.free,tl_data_img ;ç¨á⪠ á¨á⥬­ëå ¨ª®­®ª
  67.         @@:
  68.         cmp tl_data_img_sys,0
  69.         je @f
  70.                 invoke mem.free,tl_data_img_sys ;ç¨á⪠ á¨á⥬­ëå ¨ª®­®ª
  71.         @@:
  72.         invoke mem.free,tl_data_info
  73.         invoke mem.free,tl_data_nodes
  74.         ret
  75. endp
  76.  
  77. ;®ç¨á⪠ ᯨ᪠ (¨­ä®à¬ æ¨¨)
  78. align 4
  79. proc tl_info_clear uses eax ecx edi, tlist:dword
  80.         mov edi,[tlist]
  81.         mov tl_ch_tim,0
  82.         mov tl_tim_undo,0
  83.         mov tl_cur_pos,0
  84.         mov ecx,sizeof.TreeNode
  85.         imul ecx,tl_info_max_count
  86.         mov eax,tl_data_nodes
  87.         @@:
  88.                 mov byte[eax],0 ;ç¨á⨬ 㧫ë 0-¬¨
  89.                 inc eax
  90.                 loop @b
  91.         mov eax,tl_data_nodes ;㪠§ â¥«ì ­  0-© 㧥«
  92.         mov dword[eax+TreeNode.next],1 ;㪠§ â¥«ì next ¢ 0-¬ 㧫¥ ¯à¨à ¢­¨¢ ¥¬ ª 1
  93.  
  94.         cmp tl_p_scroll,0 ;®¡à ¡®âª  áªà®««¨­£ 
  95.         je @f
  96.                 mov eax,tl_p_scroll
  97.                 mov dword[eax+sb_offs_position],0
  98.                 call tb_scrol_resize
  99.         @@:
  100.         ret
  101. endp
  102.  
  103. ;ॠªæ¨ï ­  ª« ¢¨ âãàã
  104. align 4
  105. proc tl_key uses ebx ecx edi, tlist:dword
  106.         mov edi,[tlist]
  107.  
  108.         mov ebx,tl_el_focus
  109.         cmp [ebx],edi
  110.         jne .no_focus ;í«¥¬¥­â ­¥ ¢ 䮪ãá¥
  111.  
  112.         push eax
  113.         mcall SF_KEYBOARD,SSF_GET_INPUT_MODE ;¯®«ãç¨âì ०¨¬ ¢¢®¤  á ª« ¢¨ âãàë
  114.  
  115.         lea ecx,[tl_key_scan]
  116.         cmp eax,1 ;1 = ᪠­ª®¤ë
  117.         je @f
  118.                 lea ecx,[tl_key_ascii]
  119.         @@:
  120.         pop eax
  121.  
  122.         xor bx,bx
  123.         cmp ah,byte[ecx] ;Enter
  124.         jne @f
  125.         cmp tl_on_press,0
  126.         je @f
  127.                 call tl_on_press
  128.         @@:
  129.         cmp ah,byte[ecx+1] ;Space
  130.         jne @f
  131.                 stdcall tl_node_close_open, edi
  132.         @@:
  133.         cmp ah,byte[ecx+2] ;Up
  134.         jne @f
  135.                 stdcall tl_cur_perv, edi
  136.         @@:
  137.         cmp ah,byte[ecx+3] ;Down
  138.         jne @f
  139.                 stdcall tl_cur_next, edi
  140.         @@:
  141.         cmp ah,byte[ecx+7] ;Page Up
  142.         jne @f
  143.                 stdcall tl_cur_page_up, edi
  144.         @@:
  145.         cmp ah,byte[ecx+8] ;Page Down
  146.         jne @f
  147.                 stdcall tl_cur_page_down, edi
  148.         @@:
  149.  
  150.         bt tl_style,0 ;tl_key_no_edit
  151.         jc .no_edit
  152.                 cmp ah,byte[ecx+4] ;Left
  153.                 jne @f
  154.                         stdcall tl_node_lev_dec, edi
  155.                         mov bx,1
  156.                 @@:
  157.                 cmp ah,byte[ecx+5] ;Right
  158.                 jne @f
  159.                         stdcall tl_node_lev_inc, edi
  160.                         mov bx,1
  161.                 @@:
  162.                 cmp ah,byte[ecx+6] ;Delete
  163.                 jne @f
  164.                         stdcall tl_node_delete, edi
  165.                         mov bx,1
  166.                 @@:
  167.         .no_edit:
  168.  
  169.         cmp bx,1
  170.         jne .no_focus
  171.                 stdcall tl_draw, edi
  172.         .no_focus:
  173.         ret
  174. endp
  175.  
  176. ;ॠªæ¨ï ­  ¬ëèì
  177. align 4
  178. proc tl_mouse, tlist:dword
  179.         pushad
  180.         mov edi,[tlist]
  181.  
  182.         mcall SF_MOUSE_GET,SSF_WINDOW_POSITION ;ª®®à¤¨­ âë ¬ëè¨ ®â­®á¨â¥«ì­® ®ª­ 
  183.  
  184.         mov ebx,tl_box_left
  185.         shl ebx,16
  186.         cmp eax,ebx ;«¥¢ ï £à ­¨æ  ®ª­ 
  187.         jl .no_in_wnd ;.test_scroll ­¥ ¯à¨¬¥­ï¥¬
  188.                 shr ebx,16
  189.                 add ebx,tl_box_width
  190.                 shl ebx,16
  191.                 cmp eax,ebx ;¯à ¢ ï £à ­¨æ  ®ª­ 
  192.                 jg .test_scroll
  193.  
  194.                 mov ebx,tl_box_top
  195.                 add ebx,tl_box_height
  196.                 cmp ax,bx ;­¨¦­ïï £à ­¨æ  ®ª­ 
  197.                 jg .test_scroll
  198.  
  199.                 sub ebx,tl_box_height
  200.                 add bx,tl_capt_cy
  201.                 cmp ax,bx ;¢¥àå­ïï £à ­¨æ  ®ª­  + ¢ëá®â  ¯®¤¯¨á¨
  202.                 jl .test_scroll
  203.  
  204. push eax ebx
  205.         mcall SF_MOUSE_GET,SSF_SCROLL_DATA
  206.         mov edx,eax
  207.         xor     ecx,ecx
  208.         test eax,eax
  209.         jz .mouse_next
  210.         test ax,0x8000
  211.         jnz .decr
  212.         shr eax,16
  213.         test ax,0x8000
  214.         jnz .decr_1
  215.  
  216.         mov cx,dx ;dx = mouse scroll data vertical
  217.         test ecx,ecx
  218.         jnz @f
  219.         shr edx,16
  220.         mov cx,dx ;dx = mouse scroll data horizontal
  221.         test ecx,ecx
  222.         jz .mouse_next
  223. @@:
  224.         stdcall tl_cur_next, edi
  225.         loop @r
  226.         jmp .mouse_next
  227. ;------------------------------------------------
  228. .decr: ;¢¥à⨪ «ì­ ï ¯à®ªàã⪠ ®âà¨æ â¥«ì­ ï
  229.         mov bx,ax ;ax = mouse scroll data vertical
  230.         jmp @f
  231. .decr_1: ;£®à¨§®­â «ì­ ï ¯à®ªàã⪠ ®âà¨æ â¥«ì­ ï
  232.         mov bx,ax ;ax = mouse scroll data horizontal
  233. @@:
  234.         mov ecx,0xffff
  235.         sub ecx,ebx
  236.         inc ecx
  237. @@:
  238.         stdcall tl_cur_perv, edi
  239.         loop @r
  240. ;------------------------------------------------
  241. .mouse_next:
  242.  
  243.                 mcall SF_MOUSE_GET,SSF_BUTTON_EXT
  244.                 test eax,$01000000
  245.                 jz @f
  246.                 cmp tl_on_press,0
  247.                 je @f
  248.                 call tl_on_press
  249.                 add esp,8
  250.                 popad
  251.                 ret
  252. @@:    
  253.                 bt eax,0 ;left mouse button press
  254. pop ebx eax
  255.                 jae .no_draw
  256.  
  257.                 mov esi,tl_el_focus
  258.                 mov [esi],edi ;set focus
  259.  
  260.                 ; if '+' or '-' press
  261.                 mov esi,eax
  262.                 shr esi,16
  263.                 sub esi,tl_box_left ;esi = mouse x coord in element window
  264.  
  265.                 and eax,0xffff
  266.                 sub eax,ebx
  267.                 xor edx,edx
  268.                 movzx ecx,tl_img_cy
  269.                 div ecx
  270.                 cmp tl_p_scroll,0 ;ãç¨â뢠¥¬ áªà®««¨­£
  271.                 je @f
  272.                         mov edx,tl_p_scroll
  273.                         add eax,[edx+sb_offs_position] ;¤®¡ ¢«ï¥¬ áªà®««¨­£ ­  ¢¥àåã
  274.                 @@:
  275.  
  276.                 mov ecx,eax
  277.                 call tl_get_node_count ;eax = node count
  278.                 bt tl_style,3 ;tl_cursor_pos_limited
  279.                 jnc @f
  280.                 or eax,eax
  281.                 jz @f
  282.                         dec eax ;¥á«¨ ªãàá®à á⠥⠭  áãé¥áâ¢ãî騥 㧫ë
  283.                 @@:
  284.                 cmp eax,ecx
  285.                 jl @f
  286.                         mov eax,ecx ;¥á«¨ ªãàá®à ­¥ ¢ë襫 §  ¯à¥¤¥«ë 㧫®¢, ¢®ááâ ­ ¢«¨¢ ¥¬ áâ à®¥ §­ ç¥­¨¥ eax
  287.                 @@:
  288.  
  289.                 cmp eax,tl_cur_pos ;¥á«¨ ­®¢®¥ §­ ç¥­¨¥ ªãàá®à  ᮢ¯ «® á ¯à¥¤ë¤ã騬
  290.                 je @f ;â® ­¥ áâ¨à ¥¬ ªãàá®à
  291.                 push esi
  292.                         mov esi,tl_box_top
  293.                         add esi,tl_box_height ;esi = coord bottom border
  294.                         call tl_draw_null_cursor ;áâ¨à ¥¬ ªãàá®à
  295.                 pop esi
  296.                 mov tl_cur_pos,eax
  297.                 @@:
  298.  
  299.                 ; if '+' or '-' press
  300.                 call tl_get_cur_node_index ;eax = node index
  301.                 cmp eax,2
  302.                 jl .no_open_close ;ªãàá®à á⮨⠭  ¯ãá⮬ ¬¥áâ¥, ¡¥§ 㧫®¢
  303.                 imul eax,sizeof.TreeNode
  304.                 add eax,tl_data_nodes
  305.                 movzx bx,byte[eax+TreeNode.level] ;á®å࠭塞 ã஢¥­ì ⥪ã饣® 㧫 
  306.                 inc bx ;+ ¯®«¥ ¤«ï ªãàá®à 
  307.  
  308.                 cmp si,tl_img_cx
  309.                 jl .no_open_close ;¬ë襩 ¯®¯ «¨ ­  «¥¢®¥ ¯®«¥ ¤«ï ªãàá®à , £¤¥ â®ç­® ­¥â '+' ¨ '-'
  310.                         mov eax,esi
  311.                         xor edx,edx
  312.                         movzx ecx,tl_img_cx
  313.                         div ecx
  314.  
  315.                         cmp ax,bx
  316.                         jne .no_open_close
  317.  
  318.                         stdcall tl_node_close_open, edi
  319.                 .no_open_close:
  320.  
  321.                 mov esi,tl_box_top
  322.                 add esi,tl_box_height ;esi = coord bottom border
  323.                 call tl_draw_cursor ;¯¥à¥à¨á®¢ª  ªãàá®à 
  324.                 call tl_draw_caption_cur_pos
  325.                 jmp .no_draw
  326. ;--- mouse event for children scrollbar ----------------------------------------
  327. .test_scroll:
  328.         mov edx,tl_p_scroll
  329.         or edx,edx
  330.         jz .no_in_wnd ;¯®«ì§®¢ â¥«ì ­¥ ᮧ¤ « ¤®ç¥à­¥£® áªà®««¨­£ 
  331.                 shr ebx,16
  332.                 add bx,word[edx] ;+0 .size_x
  333.                 shl ebx,16
  334.                 cmp eax,ebx ;¯à ¢ ï £à ­¨æ  ®ª­ 
  335.                 jg .no_in_wnd
  336.  
  337.                 mov eax,[edx+sb_offs_max_area]
  338.                 cmp eax,[edx+sb_offs_cur_area]
  339.                 jbe .no_in_wnd ;¢á¥ ã§«ë ¯®¯ ¤ îâ ¢ ®ª­® áªà®««¨­£ 
  340.                         stdcall scroll_bar_vertical.mouse, edx ;scrollbar_ver_mouse
  341.  
  342.                         cmp dword[edx+sb_offs_redraw],0
  343.                         je @f
  344.                                 mov dword[edx+sb_offs_redraw],0
  345.                                 stdcall tl_draw, edi ;¯à®¨§®è«¨ ¨§¬¥­¥­¨ï áªà®««¨­£ 
  346.                         @@:
  347.                         cmp dword[edx+sb_offs_delta2],0
  348.                         jne .no_draw ;¯®¯ «¨ ­  áªà®««¨­£ - ­¥ á­¨¬ ¥¬ 䮪ãá á TreeList
  349. ;-------------------------------------------------------------------------------
  350.         .no_in_wnd: ;­¥ ¯®¯ «¨ ¢ ®ª­® - ¯®â¥àï 䮪ãá  (¯à¨ ãá«®¢¨¨ ç⮠䮪ãá ¡ë« ­  ¤ ­­®¬ í¥«¥¬¥­â¥)
  351.         mcall SF_MOUSE_GET,SSF_BUTTON
  352.         or eax,eax ;­¨ç¥£® ­¥ ­ ¦ «¨ eax=0
  353.         jz .no_draw
  354.                 mov ebx,tl_el_focus
  355.                 cmp [ebx],edi
  356.                 jne .no_draw ;í«¥¬¥­â ­¥ ¢ 䮪ãá¥
  357.                         mov dword[ebx],0 ;reset focus
  358.                         mov esi,tl_box_top
  359.                         add esi,tl_box_height ;esi = coord bottom border
  360.                         call tl_draw_cursor ;à¨á㥬 ªãàá®à á ¯®â¥àï­ë¬ 䮪ãᮬ
  361.         .no_draw:
  362.  
  363.         popad
  364.         ret
  365. endp
  366.  
  367. ;®â¬¥­  ¤¥©á⢨ï
  368. align 4
  369. proc tl_info_undo uses eax edi, tlist:dword
  370.         mov edi,[tlist]
  371.         mov eax,tl_tim_undo
  372.         cmp tl_ch_tim,eax
  373.         jbe @f
  374.                 inc tl_tim_undo
  375.                 call tb_scrol_resize ;®¡à ¡®âª  áªà®««¨­£ 
  376.         @@:
  377.         ret
  378. endp
  379.  
  380. ;¯®¢â®à ¤¥©á⢨ï
  381. align 4
  382. proc tl_info_redo uses edi, tlist:dword
  383.         mov edi,[tlist]
  384.         cmp tl_tim_undo,1
  385.         jl @f
  386.                 dec tl_tim_undo
  387.                 call tb_scrol_resize ;®¡à ¡®âª  áªà®««¨­£ 
  388.         @@:
  389.         ret
  390. endp
  391.  
  392. ;㤠«¥­¨¥ ®â¬¥­¥­­ëå ¤¥©á⢨©
  393. ;¢­ãâ७­ïï äã­ªæ¨ï, ­¥ ¤«ï íªá¯®àâ 
  394. align 4
  395. tl_info_set_undo:
  396.         cmp tl_tim_undo,1
  397.         jl .no_work
  398.  
  399.         push eax ebx ecx edx
  400.         mov edx,tl_data_nodes
  401.         mov ecx,edx
  402.         add ecx,sizeof.TreeNode
  403.         call tl_move_next ;long i=node[0].next;
  404.  
  405.         mov eax,tl_tim_undo
  406.         sub tl_ch_tim,eax ;ch_tim-=tim_undo;
  407.  
  408.         cmp edx,ecx
  409.         jle @f
  410.                 ;if(node[i].tc>ch_tim){ // ¥á«¨ ᮧ¤ ­¨¥ ᨬ¢®«  ¡ë«® ®â¬¥­¥­®
  411.                 mov eax,tl_ch_tim
  412.                 cmp [edx+TreeNode.t_create],eax
  413.                 jle .no_u1
  414.                         mov dword[edx+TreeNode.t_create],0
  415.                         mov dword[edx+TreeNode.t_delete],0
  416.  
  417.                         mov ebx, [edx+TreeNode.perv]
  418.                         imul ebx,sizeof.TreeNode
  419.                         add ebx, tl_data_nodes ;.next
  420.                         push dword[edx+TreeNode.next] ;node[node[i].perv].next=node[i].next;
  421.                         pop dword[ebx+TreeNode.next]
  422.  
  423.                         mov ebx, [edx+TreeNode.next]
  424.                         imul ebx,sizeof.TreeNode
  425.                         add ebx, tl_data_nodes ;.perv
  426.                         push dword[edx+TreeNode.perv] ;node[node[i].next].perv=node[i].perv;
  427.                         pop dword[ebx+TreeNode.perv]
  428.                 .no_u1:
  429.  
  430.                 ;else if(node[i].td>ch_tim) node[i].td=0; // ¥á«¨ 㤠«¥­¨¥ ᨬ¢®«  ¡ë«® ®â¬¥­¥­®
  431.                 cmp [edx+TreeNode.t_delete],eax
  432.                 jle .no_u2
  433.                         mov dword[edx+TreeNode.t_delete],0
  434.                 .no_u2:
  435.                 call tl_move_next
  436.                 jmp @b
  437.         @@:
  438.         mov tl_tim_undo,0
  439.         pop edx ecx ebx eax
  440.         .no_work:
  441.         ret
  442.  
  443. ;¢ë¢®¤ ᯨ᪠ ­  íªà ­
  444. align 4
  445. proc tl_draw, tlist:dword
  446.         pushad
  447.         ;draw dir_list main rect
  448.         mov edi,[tlist]
  449.         mov ebx,tl_box_left
  450.         shl ebx,16
  451.         add ebx,tl_box_width
  452.         mov ecx,tl_box_top
  453.         shl ecx,16
  454.         mov cx,tl_capt_cy
  455.         mov edx,tl_col_zag
  456.         mcall SF_DRAW_RECT ;draw window caption
  457.  
  458.         add ecx,tl_box_top
  459.         shl ecx,16
  460.         add ecx,tl_box_height
  461.         sub cx,tl_capt_cy
  462.         mcall ,,,tl_col_bkg ;draw window client rect
  463.  
  464.         cmp tl_capt_cy,9 ;9 - minimum caption height
  465.         jl @f
  466.         mov ebx,edi ;calculate cursor position
  467.         mov eax,tl_cur_pos
  468.         inc eax
  469.         lea edi,[txt_capt_cur.v]
  470.         stdcall tl_convert_to_str, 5
  471.  
  472.         mov edi,ebx
  473.         mov eax,tl_tim_undo
  474.         lea edi,[txt_capt_otm.v]
  475.         stdcall tl_convert_to_str, 5
  476.         mov edi,ebx ;restore edi
  477.  
  478.         mov eax,SF_DRAW_TEXT ;captions
  479.         mov ebx,tl_box_left
  480.         shl ebx,16
  481.         add ebx,5*65536+3
  482.         add ebx,tl_box_top
  483.         mov ecx,tl_col_txt
  484.         or  ecx,0x80000000
  485.         lea edx,[txt_capt_cur]
  486.         int 0x40
  487.  
  488.         mov ebx,tl_box_left
  489.         shl ebx,16
  490.         add ebx,100*65536+3
  491.         add ebx,tl_box_top
  492.         lea edx,[txt_capt_otm]
  493.         int 0x40
  494.         @@:
  495.  
  496.         ;cycle to nodes
  497.         xor eax,eax
  498.         mov edx,tl_data_nodes
  499.         mov ecx,edx
  500.         add ecx,sizeof.TreeNode
  501.  
  502.         ;*** ¯à®¯ã᪠㧫®¢, ª®â®àë¥ ¯à®¬®â ­ë áªà®««¨­£®¬ ***
  503.         cmp tl_p_scroll,0 ;¥á«¨ ¥áâì 㪠§ â¥«ì ­  áªà®««¨­£
  504.         je .end_c1
  505.                 mov esi,tl_p_scroll
  506.                 cmp dword[esi+sb_offs_position],0 ;¥á«¨ áªà®««¨­£ ­  ¢¥àåã, ¢ë室¨¬
  507.                 je .end_c1
  508.                 @@:
  509.                         call tl_iterat_next
  510.                         cmp edx,ecx
  511.                         jle .end_draw
  512.                         inc eax
  513.                         cmp eax,dword[esi+sb_offs_position]
  514.                         jl @b
  515.         .end_c1:
  516.  
  517.         xor eax,eax
  518.         mov esi,tl_box_top
  519.         add esi,tl_box_height ;esi = coord bottom border
  520.         @@:
  521.                 call tl_iterat_next
  522.                 cmp edx,ecx
  523.                 jle @f
  524.                 call tl_draw_node
  525.                 inc eax
  526.                 jmp @b
  527.         @@:
  528.  
  529.         call tl_draw_cursor
  530.  
  531.         mov edi,tl_p_scroll ;à¨á㥬 ¤®ç¥à­¨© áªà®««¨­£
  532.         cmp edi,0    ;¤«ï ⮣® çâ®-¡ë ¥£® ­¥ ¯à¨è«®áì à¨á®¢ âì ¢ ¯®«ì§®¢ â¥«ì᪮© ¯à®£à ¬¬¥
  533.         je .end_draw ;¥á«¨ ­¥â áªà®««¨­£  ¢ë室¨¬
  534.                 stdcall scroll_bar_vertical.draw, edi
  535.         .end_draw:
  536.         popad
  537.         ret
  538. endp
  539.  
  540. ;¯¥à¥å®¤ ­  á«¥¤ã騩 ¢¨¤¨¬ë© 㧥« (¯à®¯ãáª ï § ªàëâë¥)
  541. ;input:
  542. ; ecx = pointer to 1 node struct
  543. ; edx = pointer to node struct
  544. ; edi = pointer to 'TreeList' struct
  545. ;output:
  546. ; edx = pointer to next node struct
  547. align 4
  548. tl_iterat_next:
  549.         push bx
  550.         mov bl,0x7f
  551.         cmp byte[edx+TreeNode.close],1
  552.         jne @f
  553.                 mov bl,byte[edx+TreeNode.level]
  554.         @@:
  555.  
  556.         cmp tl_tim_undo,0
  557.         je .else
  558.  
  559.         push eax
  560.         .beg0:
  561.                 call tl_move_next
  562.                 cmp edx,ecx
  563.                 jle @f
  564.                 call tl_node_not_vis ;¯à®¯ã᪠㤠«¥­­ëå ¨ ®â¬¥­¥­­ëå
  565.                 cmp al,1
  566.                 je .beg0
  567.                 cmp bl,byte[edx+TreeNode.level] ;¯à®¯ã᪠§ ªàëâëå
  568.                 jl .beg0
  569.                 @@:
  570.         pop eax
  571.         pop bx
  572.         ret
  573.  
  574.         .else:
  575.                 call tl_move_next
  576.                 cmp edx,ecx
  577.                 jle .endif
  578.                 cmp dword[edx+TreeNode.t_delete],0 ;¯à®¯ã᪠㤠«¥­­ëå
  579.                 jne .else
  580.                 cmp bl,byte[edx+TreeNode.level] ;¯à®¯ã᪠§ ªàëâëå
  581.                 jl .else
  582.         .endif:
  583.         pop bx
  584.         ret
  585.  
  586. ;¯¥à¥å®¤ ­  á«¥¤ã騩 ¢¨¤¨¬ë© 㧥« (¨ ­  § ªàëâë¥ â®¦¥)
  587. ;input:
  588. ; ecx = pointer to 1 node struct
  589. ; edx = pointer to node struct
  590. ; edi = pointer to 'TreeList' struct
  591. ;output:
  592. ; edx = pointer to next visible node struct
  593. align 4
  594. tl_iterat_next_all:
  595.         cmp tl_tim_undo,0
  596.         je .else
  597.  
  598.         push eax
  599.         @@:
  600.                 call tl_move_next
  601.                 cmp edx,ecx
  602.                 jle @f
  603.                 call tl_node_not_vis
  604.                 cmp al,1
  605.                 je @b
  606.         @@:
  607.         pop eax
  608.         ret
  609.         .else:
  610.                 call tl_move_next
  611.                 cmp edx,ecx
  612.                 jle .endif
  613.                 cmp dword[edx+TreeNode.t_delete],0 ;td -> time delete
  614.                 jne .else
  615.         .endif:
  616.         ret
  617.  
  618. ;¯¥à¥å®¤ ­  ¯à¥¤ë¤ã騩 ¢¨¤¨¬ë© 㧥« (¯à®¯ãáª ï § ªàëâë¥)
  619. ;input:
  620. ; ecx = pointer to 1 node struct
  621. ; edx = pointer to node struct
  622. ; edi = pointer to 'TreeList' struct
  623. align 4
  624. proc tl_iterat_perv uses eax
  625.         cmp tl_tim_undo,0
  626.         je .beg1
  627.  
  628.         .beg0:
  629.                 call tl_move_perv
  630.                 cmp edx,ecx
  631.                 jle @f
  632.                 call tl_node_not_vis ;¯à®¯ã᪠㤠«¥­­ëå ¨ ®â¬¥­¥­­ëå
  633.                 cmp al,1
  634.                 je .beg0
  635.  
  636.         .beg1:
  637.                 call tl_move_perv
  638.                 cmp edx,ecx
  639.                 jle @f
  640.                 cmp dword[edx+TreeNode.t_delete],0 ;td = 'time delete' -> ¯à®¯ã᪠㤠«¥­­ëå
  641.                 jne .beg1
  642.  
  643.         @@:
  644.         call tl_move_max_clo_par
  645.         ret
  646. endp
  647.  
  648. ;­ å®¤¨â த¨â¥«ì᪨© § ªàëâë© ã§¥« ¬ ªá¨¬ «ì­®£® ã஢­ï
  649. ;input:
  650. ; edx = pointer to node struct
  651. ; edi = pointer to 'TreeList' struct
  652. ;output:
  653. ; edx = pointer closed parent node with maximum level
  654. align 4
  655. proc tl_move_max_clo_par uses eax ebx
  656.         mov eax,edx
  657.         xor ebx,ebx
  658.         .beg:
  659.                 call tl_move_par
  660.                 cmp byte[edx+TreeNode.close],1 ;த¨â¥«ì᪨© 㧥« § ªàëâ ?
  661.                 jne @f
  662.                         mov eax,edx
  663.                 @@:
  664.                 cmp ebx,edx
  665.                 je .end_f
  666.                         mov ebx,edx
  667.                         jmp .beg
  668.         .end_f:
  669.         mov edx,eax
  670.         ret
  671. endp
  672.  
  673. ;input:
  674. ; edx = pointer to node struct
  675. ; edi = pointer to 'TreeList' struct
  676. ;output:
  677. ; edx = pointer to next node struct
  678. align 4
  679. tl_move_next:
  680.         mov edx,[edx+TreeNode.next]
  681.         imul edx,sizeof.TreeNode
  682.         add edx,tl_data_nodes
  683.         ret
  684.  
  685. ;input:
  686. ; edx = pointer to node struct
  687. ; edi = pointer to 'TreeList' struct
  688. ;output:
  689. ; edx = pointer to perv node struct
  690. align 4
  691. tl_move_perv:
  692.         mov edx,[edx+TreeNode.perv]
  693.         imul edx,sizeof.TreeNode
  694.         add edx,tl_data_nodes
  695.         ret
  696.  
  697. ;¯¥à¥¤¢¨£ ¥¬áï ­  த¨â¥«ì᪨© 㧥«, ¥á«¨ â ª®£® ­¥â, â® ®áâ ¢«ï¥¬ áâ à®¥ §­ ç¥­¨¥ 㪠§ â¥«ï
  698. ;input:
  699. ; ecx = pointer to 1 node struct
  700. ; edx = pointer to node struct
  701. ; edi = pointer to 'TreeList' struct
  702. ;output:
  703. ; edx = pointer to parent node struct
  704. align 4
  705. tl_move_par:
  706.         cmp byte[edx+TreeNode.level],0
  707.         je .end_f ;㧥« 0-£® ã஢­ï ­¥ ¬®¦¥â ¡ëâì ¤®ç¥à­¨¬
  708.         push eax ebx esi
  709.         mov esi,edx ;copy node pointer (edx)
  710.         mov bl,byte[edx+TreeNode.level]
  711.         @@:
  712.                 call tl_move_perv
  713.                 cmp edx,ecx
  714.                 jle @f ;¢á¥ ¢ëè¥ áâ®ï騥 ã§«ë ­¥ த¨â¥«ì᪨¥
  715.                 call tl_node_not_vis ;¯à®¯ã᪠㤠«¥­­ëå ¨ ®â¬¥­¥­­ëå
  716.                 cmp al,1
  717.                 je @b
  718.                 cmp byte[edx+TreeNode.level],bl
  719.                 jl .end_0 ;㤠筮 ­ è«¨ த¨â¥«ì᪨© 㧥«
  720.                 jmp @b
  721.         @@:
  722.                 mov esi,ebx ;restore node pointer
  723.         .end_0:
  724.         pop esi ebx eax
  725.         .end_f:
  726.         ret
  727.  
  728. ;¯à®¢¥àï¥â ¢¨¤¨¬ë© «¨ 㪠§ ­­ë© 㧥« á ãç¥â®¬: ¤®¡ ¢«¥­¨©, 㤠«¥­¨©, ®â¬¥­ ¤¥©á⢨©
  729. ;input:
  730. ; edx = pointer to node struct
  731. ; edi = pointer to 'TreeList' struct
  732. ;output:
  733. ; al = 1 if sumbol not visible
  734. ; (node[i].td+tim_Undo<=ch_tim && node[i].td) || (node[i].tc>ch_tim-tim_Undo)
  735. align 4
  736. tl_node_not_vis:
  737.         cmp dword[edx+TreeNode.t_delete],0
  738.         je @f
  739.         mov eax,[edx+TreeNode.t_delete] ;eax=node[i].td
  740.         add eax,tl_tim_undo
  741.         cmp eax,tl_ch_tim
  742.         jg @f
  743.                 mov al,1
  744.                 ret
  745.         @@:
  746.  
  747.         mov eax,tl_ch_tim
  748.         sub eax,tl_tim_undo
  749.         cmp [edx+TreeNode.t_create],eax ;time create
  750.         jle @f
  751.                 mov al,1
  752.                 ret
  753.         @@:
  754.         xor al,al
  755.         ret
  756.  
  757. ;à¨á㥬 ªãàá®à ­  íªà ­¥
  758. ;input:
  759. ; edi = pointer to TreeInfo struct
  760. ; esi = coord bottom border
  761. align 4
  762. proc tl_draw_cursor uses eax ebx ecx edx esi
  763.         call tl_get_display_cur_pos ;eax = cursor pos in screen
  764.         cmp eax,0
  765.         jl .end_f ;ªãàá®à ­ å®¤¨âáï ¢ëè¥ ®ª­ , ¢ ®¡« á⨠¯à®ªàã祭­®© áªà®««¨­£®¬
  766.  
  767.         cmp tl_data_img_sys,0 ;ᬮâਬ ¥áâì «¨ 㪠§ â¥«ì ­  ª à⨭ªã á¨á⥬­ëå ¨ª®­®ª
  768.         jne @f
  769.                 mov ebx,tl_box_left
  770.                 shl ebx,16
  771.                 mov bx,tl_img_cx
  772.                 movzx ecx,tl_img_cy
  773.                 imul ecx,eax
  774.                 add ecx,tl_box_top
  775.                 add cx,tl_capt_cy
  776.  
  777.                 ;crop image if on the border
  778.                 cmp esi,ecx ;¥á«¨ ªãàá®à ¢­¨§ã ¨ ¥£® ¢®®¡é¥ ­¥ ¢¨¤­®
  779.                 jl .end_f
  780.  
  781.                 sub esi,ecx
  782.                 shl ecx,16
  783.                 mov cx,tl_img_cy
  784.                 cmp si,tl_img_cy
  785.                 jge .crop0
  786.                         mov cx,si ;¥á«¨ ªãàá®à ¢¨¤¥­ ç áâ¨ç­® (¯®¯ « ­  ­¨¦­îî £à ­¨æã)
  787.                 .crop0:
  788.  
  789.                 mov edx,tl_col_txt
  790.                 mcall SF_DRAW_RECT ;à¨á㥬 ¯à®á⮩ ¯àאַ㣮«ì­¨ª, â.ª. ­¥â á¨á⥬­ëå ¨ª®­®ª
  791.                 jmp .end_f
  792.         @@:
  793.         mov ebx,tl_data_img_sys
  794.         imul ax,tl_img_cy
  795.         mov edx,tl_box_left
  796.         shl edx,16
  797.         mov dx,ax
  798.         add edx,tl_box_top
  799.         add dx,tl_capt_cy
  800.  
  801.         mov ecx,tl_el_focus ;¯à®¢¥à塞 ¢ 䮪ãá¥ í«¥¬¥­â ¨«¨ ­¥â
  802.         cmp dword[ecx],edi
  803.         je .focus
  804.                 ;¥á«¨ ­¥ ¢ 䮪ãᥠᤢ¨£ ¥¬ ª®®à¤¨­ âë ­  ¨ª®­ªã ­¥  ªâ¨¢­®£® ªãàá®à 
  805.                 movzx ecx,tl_img_cx
  806.                 movzx eax,tl_img_cy
  807.                 imul eax,ecx
  808.                 imul eax,4*3 ;4=icon index 3=rgb
  809.                 add ebx,eax
  810.         .focus:
  811.  
  812.         mov cx,tl_img_cx
  813.         shl ecx,16
  814.         mov cx,tl_img_cy
  815.  
  816.         ;crop image if on the border
  817.         cmp si,dx ;¥á«¨ ªãàá®à ¢­¨§ã ¨ ¥£® ¢®®¡é¥ ­¥ ¢¨¤­®
  818.         jl .end_f
  819.  
  820.                 sub si,dx
  821.                 cmp si,tl_img_cy
  822.                 jge .crop1
  823.                         mov cx,si ;¥á«¨ ªãàá®à ¢¨¤¥­ ç áâ¨ç­® (¯®¯ « ­  ­¨¦­îî £à ­¨æã)
  824.                 .crop1:
  825.  
  826.                 mcall SF_PUT_IMAGE ;à¨á㥬 ¨ª®­ªã ªãàá®à 
  827.         .end_f:
  828.         ret
  829. endp
  830.  
  831. ;áâ¨à ¥¬ ªãàá®à ­  íªà ­¥
  832. ;input:
  833. ; edi = pointer to TreeInfo struct
  834. ; esi = coord bottom border
  835. align 4
  836. proc tl_draw_null_cursor uses eax ebx ecx edx esi
  837.         call tl_get_display_cur_pos ;eax = cursor pos in screen
  838.         cmp eax,0
  839.         jl .end_f ;ªãàá®à ­ å®¤¨âáï ¢ëè¥ ®ª­ , ¢ ®¡« á⨠¯à®ªàã祭­®© áªà®««¨­£®¬
  840.                 mov ebx,tl_box_left
  841.                 shl ebx,16
  842.                 mov bx,tl_img_cx
  843.                 movzx ecx,tl_img_cy
  844.                 imul ecx,eax
  845.                 add ecx,tl_box_top
  846.                 add cx,tl_capt_cy
  847.  
  848.                 ;crop image if on the border
  849.                 cmp esi,ecx ;¥á«¨ ªãàá®à ¢­¨§ã ¨ ¥£® ¢®®¡é¥ ­¥ ¢¨¤­®
  850.                 jl .end_f
  851.  
  852.                 sub esi,ecx
  853.                 shl ecx,16
  854.                 mov cx,tl_img_cy
  855.                 cmp si,tl_img_cy
  856.                 jge @f
  857.                         mov cx,si ;¥á«¨ ªãàá®à ¢¨¤¥­ ç áâ¨ç­® (¯®¯ « ­  ­¨¦­îî £à ­¨æã)
  858.                 @@:
  859.                 mcall SF_DRAW_RECT,,,tl_col_bkg ;à¨á㥬 ¯à®á⮩ ¯àאַ㣮«ì­¨ª á ä®­®¢ë¬ 梥⮬
  860.         .end_f:
  861.         ret
  862. endp
  863.  
  864. ;¡¥à¥â ¯®§¨æ¨î ªãàá®à , ®â­®á¨â¥«ì­® íªà ­ 
  865. ;input:
  866. ; edi = pointer to TreeInfo struct
  867. ;output:
  868. ; eax = index
  869. align 4
  870. tl_get_display_cur_pos:
  871.         mov eax,tl_cur_pos
  872.         cmp tl_p_scroll,0
  873.         je @f
  874.                 push ebx
  875.                 mov ebx,tl_p_scroll
  876.                 mov ebx,dword[ebx+sb_offs_position]
  877.                 sub eax,ebx ;®â­¨¬ ¥¬ ¯®§¨æ¨î áªà®««¨­£ 
  878.                 pop ebx
  879.         @@:
  880.         ret
  881.  
  882. ;à¨áã¥â 㧥« á: ª à⨭ª®©, ¯®¤¯¨áìî, ¨ª®­ª®© ®âªàëâ¨ï/§ ªàëâ¨ï ¨ «¨­¨ï¬¨ ª த¨â. 㧫ã
  883. ;input:
  884. ; eax = node position (0, ..., max_nodes-scroll_pos) ­¥ ¤® tl_box_height/tl_img_cy
  885. ; edx = pointer to node struct
  886. ; edi = pointer to 'TreeList' struct
  887. ; esi = coord of bottom border
  888. align 4
  889. proc tl_draw_node uses eax ebx ecx edx esi
  890.         mov ebx,1 ;1 - ¬¥áâ® ¯®¤ ªãàá®à
  891.         bt tl_style,2 ;tl_list_box_mode
  892.         jc @f
  893.                 inc ebx ;+1 - ¬¥áâ® ¯®¤ §­ ª +,-
  894.                 add bl,byte[edx+TreeNode.level] ;¤®¡ ¢«ï¥¬ ã஢¥­ì í«¥¬¥­â  ¤«ï ¥£® ãç¥â  ¢ «¥¢®¬ ®âáâ㯥 ¨ª®­ª¨
  895.         @@:
  896.         imul bx,tl_img_cx
  897.         add ebx,tl_box_left
  898.  
  899.         shl ebx,16
  900.         mov bx,tl_img_cx
  901.         movzx ecx,tl_img_cy
  902.         imul ecx,eax
  903.         add cx,tl_capt_cy
  904.         jc .end_draw ;ª®£¤  ¬­®£® 㧫®¢, â® ¬®¦¥â ¡ëâì ¯¥à¥¯®«­¥­¨¥ ª®®à¤¨­ âë cx
  905.         add ecx,tl_box_top
  906.  
  907.         ;crop image if on the border
  908.         cmp esi,ecx ;¥á«¨ 㧥« ¢­¨§ã ¨ ¥£® ¢®®¡é¥ ­¥ ¢¨¤­®
  909.         jl .end_draw
  910.  
  911.         sub esi,ecx
  912.         shl ecx,16
  913.         mov cx,tl_img_cy
  914.         cmp si,tl_img_cy
  915.         jge @f
  916.                 mov cx,si ;¥á«¨ 㧥« ¢¨¤¥­ ç áâ¨ç­® (¯®¯ « ­  ­¨¦­îî £à ­¨æã)
  917.                 jmp .crop ;¯à®¯ã᪠¥¬ à¨á®¢ ­¨¥ ­ ¤¯¨á¨, ª®â®à ï ᪮॥ ¢á¥£® ⮦¥ ¢ë«¥§¥â §  ­¨¦­îî £à ­¨æã
  918.         @@:
  919.                 call tl_draw_node_caption
  920.         .crop:
  921.         mov esi,ecx ;save ecx
  922.  
  923.         push edx
  924.         cmp tl_data_img,0
  925.         jne .draw_img_n
  926.                 mcall SF_DRAW_RECT,,,tl_col_txt ;draw node rect
  927.                 jmp @f
  928.         .draw_img_n:
  929.         push ebx esi
  930.                 movzx esi,word[edx+TreeNode.type] ;get icon type
  931.                 mov edx,ebx
  932.                 ror ecx,16
  933.                 mov dx,cx
  934.                 mov cx,bx
  935.                 ror ecx,16
  936.                 mov ebx,3 ;rgb = 3 bytes
  937.                 imul bx,tl_img_cx
  938.                 imul bx,tl_img_cy
  939.                 imul ebx,esi ;esi = icon index
  940.                 add ebx,tl_data_img
  941.  
  942.                 mcall SF_PUT_IMAGE ;draw node icon '-'
  943.         pop esi ebx
  944.         @@:
  945.         pop edx
  946.  
  947.         mov al,byte[edx+TreeNode.level] ;draw minus '-'
  948.         mov ecx,tl_data_nodes
  949.         add ecx,sizeof.TreeNode
  950.  
  951.         mov ah,10 ;get icon index '+' or '-' ?
  952.         cmp byte[edx+TreeNode.close],1
  953.         jne .close
  954.                 dec ah
  955.         .close:
  956.  
  957.         call tl_draw_node_icon_opn_clo ;à¨á®¢ ­¨¥ ¨ª®­ª¨ ®âªàë⮣® ¨«¨ § ªàë⮣® 㧫 
  958.         bt tl_style,1
  959.         jae .end_draw
  960.                 call tl_draw_node_icon_par_lin ;à¨á®¢ ­¨¥ «¨­¨¨ ª த¨â¥«ì᪮¬ã í«¥¬¥­âã
  961.                 call tl_draw_node_icon_par_lin_up ;à¨á®¢ ­¨¥ ¢¥à⨪ «ì­®© «¨­¨¨ ª த¨â¥«ì᪮¬ã í«¥¬¥­âã
  962.         .end_draw:
  963.         ret
  964. endp
  965.  
  966. ;à¨áã¥â ¨ª®­ª¨ ®âªàë⮣® ¨«¨ § ªàë⮣® 㧫  (®¡ëç­® + ¨«¨ -)
  967. ;input:
  968. ; al = ã஢¥­ì í«¥¬¥­â 
  969. ; ecx = pointer to 1 node struct
  970. ; edx = pointer to node struct
  971. ;...
  972. align 4
  973. proc tl_draw_node_icon_opn_clo uses eax ebx ecx edx esi
  974.         inc al
  975.         call tl_iterat_next_all ;get next visible item
  976.         cmp edx,ecx
  977.         jle @f
  978.                 mov ecx,esi ;load ecx
  979.                 cmp al,byte[edx+TreeNode.level]
  980.                 jne @f
  981.                 ror ebx,16
  982.                 sub bx,tl_img_cx
  983.                 ror ebx,16
  984.                 cmp tl_data_img_sys,0
  985.                 jne .draw_img_s
  986.                         mcall SF_DRAW_RECT,,,tl_col_txt ;draw minus rect, if not system icons
  987.                         jmp @f
  988.                 .draw_img_s:
  989.                 mov ecx,esi ;load ecx
  990.                 mov edx,ebx
  991.                 ror ecx,16
  992.                 mov dx,cx
  993.                 mov cx,bx
  994.                 ror ecx,16
  995.                 mov ebx,3 ;rgb = 3 bytes
  996.                 imul bx,tl_img_cx
  997.                 imul bx,tl_img_cy
  998.                 shr eax,8
  999.                 and eax,0xff
  1000.                 imul ebx,eax ;eax = icon index
  1001.                 add ebx,tl_data_img_sys
  1002.                 mcall SF_PUT_IMAGE ;draw minus icon '-'
  1003.         @@:
  1004.         ret
  1005. endp
  1006.  
  1007. ;à¨á®¢ ­¨¥ «¨­¨¨ ª த¨â¥«ì᪮¬ã í«¥¬¥­âã
  1008. ;input:
  1009. ; al = ã஢¥­ì í«¥¬¥­â 
  1010. ; ecx = pointer to 1 node struct
  1011. ; edx = pointer to node struct
  1012. ;...
  1013. align 4
  1014. tl_draw_node_icon_par_lin:
  1015.         cmp byte[edx+TreeNode.close],1
  1016.         je .close
  1017.         or al,al
  1018.         jz .close
  1019.         push eax ebx ecx edx esi
  1020.                 call tl_iterat_next_all ;get next visible item
  1021.                 cmp edx,ecx
  1022.                 jle .line3 ;if end of list
  1023.                         cmp al,byte[edx+TreeNode.level]
  1024.                         jne .line3 ;jg ???
  1025.                         mov eax,3 ;line in middle element
  1026.                         jmp .line2
  1027.                 .line3:
  1028.                         mov eax,6 ;line in end element
  1029.                 .line2:
  1030.  
  1031.                 mov ecx,esi ;load ecx
  1032.                 ror ebx,16
  1033.                 sub bx,tl_img_cx
  1034.                 ror ebx,16
  1035.                 cmp tl_data_img_sys,0
  1036.                 jne .draw_img_s
  1037.                         mcall SF_DRAW_RECT,,,tl_col_txt ;draw minus rect, if not system icons
  1038.                         jmp @f
  1039.                 .draw_img_s:
  1040.                 mov edx,ebx
  1041.                 ror ecx,16
  1042.                 mov dx,cx
  1043.                 mov cx,bx
  1044.                 ror ecx,16
  1045.                 mov ebx,3 ;rgb = 3 bytes
  1046.                 imul bx,tl_img_cx
  1047.                 imul bx,tl_img_cy
  1048.  
  1049.                 imul ebx,eax ;eax = icon index
  1050.                 add ebx,tl_data_img_sys
  1051.                 mcall SF_PUT_IMAGE ;draw line icon
  1052.                 @@:
  1053.         pop esi edx ecx ebx eax
  1054.         .close:
  1055.         ret
  1056.  
  1057.  
  1058. ;input:
  1059. ; al = ã஢¥­ì í«¥¬¥­â 
  1060. ; ebx = (node.left shl 16) + tl_img_cx
  1061. ; ecx = pointer to 1 node struct
  1062. ; edx = pointer to node struct
  1063. ; edi = pointer to 'TreeList' struct
  1064. align 4
  1065. proc tl_draw_node_icon_par_lin_up uses eax ebx ecx edx esi
  1066.         cmp tl_data_img_sys,0 ;if not image
  1067.         je @f
  1068.         or al,al
  1069.         jz @f
  1070.                 xor esi,esi ;¢ si ¡ã¤¥¬ ­ áç¨â뢠âì ª®«-¢® ¨ª®­®ª, ­ã¦­ëå ¤«ï ¯à®à¨á®¢ª¨ «¨­¨¨
  1071. ;--- 横« ¤«ï ¢ëç¨á«¥­¨ï ª®««¨ç¥á⢠ ¢¥à⨪ «ì­ëå «¨­¨© ---
  1072.                 .cycle0:
  1073.                         call tl_iterat_perv ;get perv visible item
  1074.                         cmp edx,ecx
  1075.                         jle .cycle1 ;if begin of list
  1076.  
  1077.                         cmp byte[edx+TreeNode.level],al
  1078.                         jle .cycle0end ;ã஢¥­ì ¢¥àå­¥£® í«¥¬¥­â  ­¥ âॡã¥â ¯à®à¨á®¢ª¨
  1079.                         inc si
  1080.                         jmp .cycle0
  1081.                 .cycle0end:
  1082.                 or si,si ;si = ª®«-¢® ¨ª®­®ª «¨­¨¨ ª®â®àë¥ ­ã¦­® ­ à¨á®¢ âì ᢥàåã
  1083.                 jz @f
  1084.                 shl esi,16
  1085.  
  1086.                 pop ecx ;esi->ecx
  1087.                 push ecx ;save esi
  1088.  
  1089.                 ror ebx,16
  1090.                 sub bx,tl_img_cx
  1091.                 ror ebx,16
  1092.  
  1093.                 mov edx,ebx
  1094.                 ror ecx,16
  1095.                 mov dx,cx
  1096.                 mov cx,bx
  1097.                 ror ecx,16
  1098.                 mov cx,tl_img_cy ;restore size y (if crop)
  1099.                 mov ebx,3 ;rgb = 3 bytes
  1100.                 imul bx,tl_img_cx
  1101.                 imul bx,tl_img_cy
  1102.                 add ebx,tl_data_img_sys
  1103.  
  1104.                 add esi,tl_box_top
  1105.                 add si,tl_capt_cy ;si = ¢¥àå­ïï £à ­¨æ  ®ª­ 
  1106.                 mov eax,SF_PUT_IMAGE
  1107. ;--- 横« ¤«ï à¨á®¢ ­¨ï ¢¥à⨪ «ì­®© «¨­¨¨ ---
  1108.                 .cycle1:
  1109.                 sub dx,tl_img_cy ;¯®¤­¨¬ ¥¬ ª®®à¤¨­ âã y ¢¢¥àå
  1110.                 cmp dx,si
  1111.                 jl @f
  1112.                         cmp esi,0x10000
  1113.                         jl @f
  1114.                         int 0x40 ;draw line icon
  1115.                         sub esi,0x10000 ;㬥­ìè ¥¬ áç¥â稪 ¨ª®­®ª
  1116.                 jmp .cycle1
  1117.         @@:
  1118.         ret
  1119. endp
  1120.  
  1121. ;input:
  1122. ; edi = pointer to TreeInfo struct
  1123. ;output:
  1124. ; eax = rows
  1125. align 4
  1126. tl_get_rows_count:
  1127.         push ecx edx
  1128.                 mov eax,tl_box_height
  1129.                 sub ax,tl_capt_cy
  1130.                 movzx ecx,tl_img_cy
  1131.                 xor edx,edx
  1132.                 div ecx
  1133.         pop edx ecx
  1134.         ret
  1135.  
  1136. ;input:
  1137. ; eax = node position
  1138. ; ebx = [ª®®à¤¨­ â  ¯® ®á¨ x]*65536 + [img_cx]
  1139. ; ecx = [ª®®à¤¨­ â  ¯® ®á¨ y]*65536 + [img_cy]
  1140. ; edx = pointer to node struct
  1141. ; edi = pointer to TreeInfo struct
  1142. align 4
  1143. proc tl_draw_node_caption uses ebx ecx edx esi
  1144.         xor esi,esi
  1145.         mov si,tl_info_size
  1146.         cmp si,tl_info_capt_offs
  1147.         jle @f ;if caption size <= 0
  1148.                 push eax
  1149.                         call tl_get_node_index ;eax = node index
  1150.                         imul esi,eax
  1151.                 pop eax
  1152.                 add si,tl_info_capt_offs
  1153.                 add esi,tl_data_info
  1154.                 mov edx,esi
  1155.  
  1156.                 shr ebx,16
  1157.                 add bx,tl_img_cx ;ᤢ¨£ ¥¬ ­ ¤¯¨áì ¯® £®à¨§®­â «¨ --->
  1158.                 add bx,3 ;®âáâã¯
  1159.                 ;bx = coord.x
  1160.                 call tl_strlen ;eax = strlen
  1161.                 call tl_get_draw_text_len
  1162.                 mov cx,bx
  1163.                 ror ecx,16
  1164.                 mov ebx,ecx
  1165.                 add bx,tl_img_cy ;¢ëà ¢­¨¢¨­¨¥ ¯® ­¨¦­¥© £à ­¨æ¥ ¨ª®­ª¨
  1166.                 sub bx,9 ;®â­¨¬ ¥¬ ¢ëá®âã ⥪áâ 
  1167.                 mov ecx,tl_col_txt
  1168.                 and ecx,0xffffff
  1169.                 mcall SF_DRAW_TEXT
  1170.         @@:
  1171.         ret
  1172. endp
  1173.  
  1174. ;input:
  1175. ; eax = strlen
  1176. ; ebx = text coord x
  1177. ;output:
  1178. ; esi = text len
  1179. align 4
  1180. proc tl_get_draw_text_len uses eax ecx edx
  1181.         mov esi,eax ;¡¥à¥¬ ¤«¨­­ã áâப¨
  1182.         mov eax,tl_box_left
  1183.         add eax,tl_box_width
  1184.         cmp eax,ebx
  1185.         jle .text_null ;¥á«¨ ¯®¤¯¨áì ¯®«­®áâìî ¢áï §  íªà ­®¬
  1186.                 sub eax,ebx
  1187.                 xor edx,edx
  1188.                 mov ecx,6 ;è¨à¨­  á¨á⥬­®£® èà¨äâ 
  1189.                 div ecx ;ᬮâਬ ᪮«ìª® ᨬ¢®«®¢ ¬®¦¥â ¯®¬¥áâ¨âìáï ­  íªà ­¥
  1190.                 cmp esi,eax
  1191.                 jl @f
  1192.                         mov esi,eax ;¥á«¨ ¤«¨­­  ⥪áâ  ¬¥­ìè¥, 祬 ¢á¥ ¬¥áâ® ¯®¤ áâபã
  1193.                         jmp @f
  1194.         .text_null:
  1195.         xor esi,esi
  1196.         @@:
  1197.         ret
  1198. endp
  1199.  
  1200. ;input:
  1201. ; esi = pointer to string
  1202. ;output:
  1203. ; eax = strlen
  1204. align 4
  1205. tl_strlen:
  1206.         mov eax,esi
  1207.         @@:
  1208.                 cmp byte[eax],0
  1209.                 je @f
  1210.                 inc eax
  1211.                 jmp @b
  1212.         @@:
  1213.         sub eax,esi
  1214.         ret
  1215.  
  1216. ;¤®¡ ¢¨âì 㧥«
  1217. ;input:
  1218. ; tlist - 㪠§ â¥«ì ­  áâàãªâãàã «¨áâ 
  1219. ; n_opt - ®¯æ¨¨ ¤®¡ ¢«¥­¨ï
  1220. ; n_info - 㪠§ â¥«ì ­  ¤®¡ ¢«ï¥¬ë¥ ¤ ­­ë¥
  1221. align 4
  1222. proc tl_node_add uses eax ebx ecx edx edi, tlist:dword, n_opt:dword, n_info:dword
  1223.         mov edi,[tlist]
  1224.  
  1225.         call tl_info_set_undo
  1226.  
  1227.         mov ebx,sizeof.TreeNode
  1228.         imul ebx,tl_info_max_count
  1229.         add ebx,tl_data_nodes
  1230. ;--
  1231.         call tl_get_cur_node_index ;eax=po_t
  1232.         imul eax,sizeof.TreeNode
  1233.         add eax,tl_data_nodes
  1234.         mov edx,eax
  1235.         call tl_move_perv
  1236.         call tl_get_node_index ;eax = index of pointer [edx]
  1237. ;--
  1238.         mov edx,sizeof.TreeNode
  1239.         shl edx,1
  1240.         add edx,tl_data_nodes
  1241.         @@: ;for(i=2;i<nodeMax;i++)
  1242.                 cmp dword[edx+TreeNode.t_create],0
  1243.                 jne .u0
  1244.                 cmp dword[edx+TreeNode.t_delete],0
  1245.                 jne .u0
  1246.  
  1247.                 inc tl_ch_tim
  1248.                 mov ecx,dword[n_opt]
  1249.                 ror ecx,16 ;cx = type
  1250.                 mov word[edx+TreeNode.type],cx
  1251.                 rol ecx,8 ;cl = close|open
  1252.                 mov byte[edx+TreeNode.close],cl ;node[i].clo
  1253.                 mov byte[edx+TreeNode.level],0 ;node[i].lev=0
  1254.                 bt tl_style,2 ;tl_list_box_mode
  1255.                 jc .l_box_m
  1256.                         mov cl,byte[n_opt]
  1257.                         mov byte[edx+TreeNode.level],cl ;node[i].lev
  1258.                 .l_box_m:
  1259.                 push tl_ch_tim       ;node[i].tc=ch_tim;
  1260.                 pop dword[edx+TreeNode.t_create]
  1261.                 mov [edx+TreeNode.perv],eax ;node[i].perv=po_t;
  1262.                 ;*** copy node data ***
  1263.                 push esi
  1264.                 xor ecx,ecx
  1265.                 mov cx,tl_info_size
  1266.                 mov esi,ecx
  1267.  
  1268.                 push eax
  1269.                         call tl_get_node_index ;eax = node index
  1270.                         imul esi,eax
  1271.                 pop eax
  1272.                 add esi,tl_data_info
  1273.                 mov edi,dword[n_info] ;pointer to node data
  1274.                 xchg edi,esi
  1275.                 rep movsb
  1276.  
  1277.                 mov esi,edi
  1278.                 mov edi,[tlist] ;restore edi
  1279.                 mov cx,tl_info_capt_offs
  1280.                 cmp cx,tl_info_size
  1281.                 jge .no_text_data
  1282.                 cmp tl_info_capt_len,0 ;¯à®¢¥à塞 ¥áâì «¨ ®£à ­¨ç¥­¨¥ ­  ¤«¨­­ã áâப¨
  1283.                 je .no_len_ogran
  1284.                         add cx,tl_info_capt_len
  1285.                         and ecx,0xffff
  1286.                         add esi,ecx
  1287.                         mov cx,tl_info_size
  1288.                         sub esi,ecx
  1289.                 .no_len_ogran:
  1290.                 dec esi
  1291.                 mov byte[esi],0
  1292.                 .no_text_data:
  1293.                 pop esi ;restore esi
  1294.  
  1295.                 mov ecx,eax
  1296.                 imul ecx,sizeof.TreeNode
  1297.                 add ecx,tl_data_nodes ; *** ecx = node[po_t] ***
  1298.                 add ecx,TreeNode.next ; *** ecx = node[po_t].next ***
  1299.                 push dword[ecx] ;node[i].next=node[po_t].next;
  1300.                 pop dword[edx+TreeNode.next]
  1301.  
  1302.                 call tl_get_node_index ;*** eax = i ***
  1303.                 cmp eax,tl_info_max_count
  1304.                 jge .u0
  1305.                         mov [ecx],eax ;node[po_t].next=i; // áá뫪¨ ¯¥à¥­ ¯à ¢«ï¥¬
  1306.                         mov ecx,[edx+TreeNode.next] ; *** ecx = node[i].next ***
  1307.                         imul ecx,sizeof.TreeNode
  1308.                         add ecx,tl_data_nodes ; *** ecx = node[node[i].next] ***
  1309.                         mov [ecx+TreeNode.perv],eax ;node[node[i].next].perv=i;
  1310.  
  1311.                         call tb_scrol_resize ;®¡à ¡®âª  áªà®««¨­£ 
  1312.                         jmp @f
  1313.                 .u0:
  1314.                 add edx,sizeof.TreeNode
  1315.                 cmp edx,ebx ;enf of node memory ?
  1316.                 jle @b
  1317.         @@:
  1318.         ret
  1319. endp
  1320.  
  1321. ;input:
  1322. ; edi = pointer to TreeInfo struct
  1323. align 4
  1324. proc tb_scrol_resize uses eax ecx edx
  1325.         cmp tl_p_scroll,0 ;®¡à ¡®âª  áªà®««¨­£ 
  1326.         je @f
  1327.                 call tl_get_node_count ;eax = node count
  1328.                 mov ecx,eax
  1329.                 call tl_get_rows_count
  1330.                 cmp ecx,eax
  1331.                 jg .ye_sb
  1332.                         xor ecx,ecx
  1333.                 .ye_sb:
  1334.                 mov edx,tl_p_scroll
  1335.                 mov dword[edx+sb_offs_cur_area],eax
  1336.                 mov dword[edx+sb_offs_max_area],ecx
  1337.                 stdcall scroll_bar_vertical.draw,edx
  1338.         @@:
  1339.         ret
  1340. endp
  1341.  
  1342. ;input:
  1343. ;n_info - pointer to node info
  1344. align 4
  1345. proc tl_node_set_data uses eax ecx edx edi esi, tlist:dword, n_info:dword
  1346.         mov edi,[tlist]
  1347.         call tl_get_cur_node_index ;eax=po_t
  1348.         cmp eax,2
  1349.         jl @f
  1350.                 xor ecx,ecx
  1351.                 mov cx,tl_info_size
  1352.                 imul eax,ecx
  1353.                 add eax,tl_data_info
  1354.                 mov edi,eax
  1355.                 mov esi,dword[n_info] ;pointer to node data
  1356.                 rep movsb
  1357.  
  1358.                 mov esi,edi
  1359.                 mov edi,[tlist] ;restore edi
  1360.                 mov cx,tl_info_capt_offs
  1361.                 cmp cx,tl_info_size
  1362.                 jge .no_text_data
  1363.                         mov ax,tl_info_capt_len ;¯à®¢¥à塞 ¥áâì «¨ ®£à ­¨ç¥­¨¥ ­  ¤«¨­­ã ⥪áâ 
  1364.                         or ax,ax
  1365.                         jz .no_limit
  1366.                                 add cx,ax ;cx = tl_info_capt_offs + tl_info_capt_len
  1367.                                 and ecx,0xffff
  1368.                                 xor eax,eax
  1369.                                 mov ax,tl_info_size
  1370.                                 cmp eax,ecx
  1371.                                 jl .no_limit ;¯®«ì§®¢ â¥«ì § ¤ « ᫨誮¬ ¡®«ìèãî ¤«¨­­ã ⥪áâ 
  1372.                                 add esi,ecx
  1373.                                 sub esi,eax
  1374.                         .no_limit:
  1375.                         dec esi
  1376.                         mov byte[esi],0 ;®¡­ã«ï¥¬ ¯®á«¥¤­¨© ᨬ¢®« ¯®¤¯¨á¨, çâ®-¡ë ­¥ £«î稫® ¥á«¨ ¯®«ì§®¢ â¥«ì § ¤ « ­¥¯à ¢¨«ì­ãî áâàãªâãàã
  1377.                 .no_text_data:
  1378.         @@:
  1379.         ret
  1380. endp
  1381.  
  1382. ;¢§ïâì 㪠§ â¥«ì ­  ¤ ­­ë¥ 㧫  ¯®¤ ªãàá®à®¬
  1383. ;input:
  1384. ; tlist - pointer to 'TreeList' struct
  1385. ;output:
  1386. ; eax - pointer to node data
  1387. align 4
  1388. proc tl_node_get_data uses ecx edi, tlist:dword
  1389.         mov edi,[tlist]
  1390.         call tl_get_cur_node_index ;eax=po_t
  1391.         cmp eax,2
  1392.         jl @f
  1393.                 movzx ecx,tl_info_size
  1394.                 imul eax,ecx
  1395.                 add eax,tl_data_info
  1396.                 jmp .end_f ;return node data pointer
  1397.         @@:
  1398.         xor eax,eax
  1399.         .end_f:
  1400.   ret
  1401. endp
  1402.  
  1403. ;¢§ïâì 㪠§ â¥«ì ­  áâàãªâãàã 㧫  ¢ 㪠§ ­­®© ¯®§¨æ¨¨
  1404. ;input:
  1405. ; tlist - pointer to 'TreeList' struct
  1406. ; node_ind - node index
  1407. ;output:
  1408. ; eax - pointer to node info
  1409. align 4
  1410. proc tl_node_poi_get_info uses ebx ecx edx edi, tlist:dword, node_ind:dword
  1411.         mov edi,[tlist]
  1412.         mov ebx,[node_ind]
  1413.         inc ebx
  1414.  
  1415.         ;cycle to nodes
  1416.         mov edx,tl_data_nodes
  1417.         lea ecx,[edx+sizeof.TreeNode]
  1418.         @@:
  1419.                 call tl_iterat_next
  1420.                 cmp edx,ecx
  1421.                 jle @f
  1422.                 dec ebx
  1423.                 cmp ebx,0
  1424.                 jg @b
  1425.                 jmp .find
  1426.         @@:
  1427.                 xor edx,edx
  1428.         .find:
  1429.         mov eax,edx
  1430.         ret
  1431. endp
  1432.  
  1433. ;¢§ïâì 㪠§ â¥«ì ­  á«¥¤ãéãî áâàãªâãàã 㧫 
  1434. ;input:
  1435. ; tlist - pointer to 'TreeList' struct
  1436. ; node_p - node param struct
  1437. ;output:
  1438. ; eax - pointer to next node struct
  1439. align 4
  1440. proc tl_node_poi_get_next_info uses ecx edx edi, tlist:dword, node_p:dword
  1441.         mov edi,[tlist]
  1442.         mov edx,dword[node_p]
  1443.  
  1444.         mov ecx,tl_data_nodes
  1445.         add ecx,sizeof.TreeNode
  1446.  
  1447.         call tl_iterat_next_all
  1448.         cmp edx,ecx
  1449.         jg @f
  1450.                 xor edx,edx
  1451.         @@:
  1452.         mov eax,edx
  1453.         ret
  1454. endp
  1455.  
  1456. ;¢§ïâì 㪠§ â¥«ì ­  ¤ ­­ë¥ 㧫 
  1457. ;input:
  1458. ; tlist - pointer to 'TreeList' struct
  1459. ; node_p - node param struct
  1460. ;output:
  1461. ; eax - pointer
  1462. align 4
  1463. proc tl_node_poi_get_data uses ecx edx edi, tlist:dword, node_p:dword
  1464.         mov edi,[tlist]
  1465.         mov edx,dword[node_p]
  1466.  
  1467.         call tl_get_node_index ;eax = node index
  1468.         cmp eax,2
  1469.         jl @f
  1470.                 xor ecx,ecx
  1471.                 mov cx,tl_info_size
  1472.                 imul eax,ecx
  1473.                 add eax,tl_data_info
  1474.                 jmp .end_f ;return node data pointer
  1475.         @@:
  1476.                 xor eax,eax ;¢®§¢à é ¥¬ 0 ¢ á«ãç ¥ ­¥ 㤠筮£® ¯®¨áª 
  1477.         .end_f:
  1478.         ret
  1479. endp
  1480.  
  1481. ;¡¥à¥â ¯®§¨æ¨î ¯®¤ ªãàá®à®¬
  1482. ;input:
  1483. ; edi = pointer 'tl' struct
  1484. ;output:
  1485. ; eax = index of current node
  1486. align 4
  1487. proc tl_get_cur_node_index uses ecx edx
  1488.         ;cycle to nodes
  1489.         xor eax,eax
  1490.         mov edx,tl_data_nodes
  1491.         mov ecx,edx
  1492.         add ecx,sizeof.TreeNode
  1493.         @@:
  1494.                 call tl_iterat_next
  1495.                 cmp edx,ecx
  1496.                 jle @f
  1497.                 cmp eax,tl_cur_pos
  1498.                 je @f
  1499.                 inc eax
  1500.                 jmp @b
  1501.         @@:
  1502.         mov eax,edx
  1503.         sub eax,tl_data_nodes
  1504.         xor edx,edx
  1505.         mov ecx,sizeof.TreeNode
  1506.         div ecx
  1507.         ret
  1508. endp
  1509.  
  1510. ;¡¥à¥â ¯®§¨æ¨î 㪠§ ­­®£® ᨬ¢®« 
  1511. ;input:
  1512. ; edx = pointer node memory
  1513. ; edi = pointer 'tl' struct
  1514. ;output:
  1515. ; eax = struct index of current node
  1516. align 4
  1517. tl_get_node_index:
  1518.         push ecx edx
  1519.         mov eax,edx
  1520.         sub eax,tl_data_nodes
  1521.         xor edx,edx
  1522.         mov ecx,sizeof.TreeNode
  1523.         div ecx
  1524.         pop edx ecx
  1525.         ret
  1526.  
  1527. ;㤠«¨âì 㧥«
  1528. align 4
  1529. proc tl_node_delete uses eax edx edi, tlist:dword
  1530.         mov edi,[tlist]
  1531.         call tl_get_cur_node_index ;eax=po_t
  1532.         cmp eax,2
  1533.         jl @f
  1534.                 imul eax,sizeof.TreeNode
  1535.                 add eax,tl_data_nodes
  1536.                 mov edx,eax
  1537.                 inc tl_ch_tim
  1538.                 mov eax,tl_ch_tim
  1539.                 mov dword[edx+TreeNode.t_delete],eax
  1540.                 call tb_scrol_resize ;®¡à ¡®âª  áªà®««¨­£ 
  1541.         @@:
  1542.         ret
  1543. endp
  1544.  
  1545. ;¯®áâ ¢¨âì ªãàá®à ­  ¯¥à¢ë© 㧥«
  1546. align 4
  1547. proc tl_cur_beg uses edi, tlist:dword
  1548.         mov edi,[tlist]
  1549.         mov tl_cur_pos,0
  1550.         cmp tl_p_scroll,0
  1551.         je @f
  1552.                 mov edi,tl_p_scroll
  1553.                 mov dword[edi+sb_offs_position],0
  1554.                 stdcall scroll_bar_vertical.draw, edi
  1555.         @@:
  1556.         ret
  1557. endp
  1558.  
  1559. ;¯¥à¥­¥á⨠ªãàá®à ­  1 ¯®§¨æ¨î ­¨¦¥
  1560. align 4
  1561. proc tl_cur_next uses eax ebx edi esi, tlist:dword
  1562.         mov edi,[tlist]
  1563.         call tl_get_node_count ;eax = node count
  1564.         bt tl_style,3 ;tl_cursor_pos_limited
  1565.         jnc @f
  1566.         or eax,eax
  1567.         jz @f
  1568.                 dec eax ;¥á«¨ ªãàá®à á⠥⠭  áãé¥áâ¢ãî騥 㧫ë
  1569.         @@:
  1570.         cmp tl_cur_pos,eax
  1571.         jge .no_redraw
  1572.                 mov esi,tl_box_top
  1573.                 add esi,tl_box_height ;esi = coord bottom border
  1574.                 call tl_draw_null_cursor ;áâ¨à ¥¬ ªãàá®à
  1575.                 inc tl_cur_pos
  1576.  
  1577.                 cmp tl_p_scroll,0 ;if not scrol struct
  1578.                 je @f
  1579.                 call tl_get_rows_count ;eax = rows count
  1580.                 mov ebx,tl_p_scroll
  1581.                 add eax,dword[ebx+sb_offs_position]
  1582.                 cmp tl_cur_pos,eax
  1583.                 jl @f
  1584.                         inc dword[ebx+sb_offs_position]
  1585.                         stdcall scroll_bar_vertical.draw,ebx
  1586.                         stdcall tl_draw,dword[tlist] ;¯®«­ ï ¯¥à¥à¨á®¢ª  ®ª­ 
  1587.                         jmp .no_redraw
  1588.                 @@:
  1589.                 mov edi,[tlist] ;restore edi
  1590.                 call tl_draw_cursor ;¯¥à¥à¨á®¢ª  ªãàá®à 
  1591.                 call tl_draw_caption_cur_pos
  1592.         .no_redraw:
  1593.         ret
  1594. endp
  1595.  
  1596. ;¡¥à¥â ç¨á«® ¢á¥å ¢¨¤¨¬ëå 㧫®¢ (­¥ áç¨â ï § ªàëâëå ¤®ç¥à­¨å)
  1597. ;input:
  1598. ; edi = pointer 'tl' struct
  1599. ;output:
  1600. ; eax = struct index of current node
  1601. align 4
  1602. tl_get_node_count:
  1603. push ecx edx
  1604.         ;cycle to nodes
  1605.         xor eax,eax
  1606.         mov edx,tl_data_nodes
  1607.         mov ecx,edx
  1608.         add ecx,sizeof.TreeNode
  1609.         @@:
  1610.                 call tl_iterat_next
  1611.                 cmp edx,ecx
  1612.                 jle @f
  1613.                 inc eax
  1614.                 jmp @b
  1615.         @@:
  1616. pop edx ecx
  1617.         ret
  1618.  
  1619. ;¡¥à¥â ç¨á«® ¢á¥å ¢¨¤¨¬ëå 㧫®¢ (áç¨â ï § ªàëâë¥ ¤®ç¥à­¨¥)
  1620. ;input:
  1621. ; edi = pointer 'tl' struct
  1622. ;output:
  1623. ; eax = struct index of current node
  1624. align 4
  1625. tl_get_node_count_all:
  1626. push ecx edx
  1627.         ;cycle to nodes
  1628.         xor eax,eax
  1629.         mov edx,tl_data_nodes
  1630.         mov ecx,edx
  1631.         add ecx,sizeof.TreeNode
  1632.         @@:
  1633.                 call tl_iterat_next_all
  1634.                 cmp edx,ecx
  1635.                 jle @f
  1636.                 inc eax
  1637.                 jmp @b
  1638.         @@:
  1639. pop edx ecx
  1640.         ret
  1641.  
  1642. ;¯¥à¥­¥á⨠ªãàá®à ­  1 ¯®§¨æ¨î ¢ëè¥
  1643. align 4
  1644. proc tl_cur_perv uses eax edi esi, tlist:dword
  1645.         mov edi,[tlist]
  1646.         cmp tl_cur_pos,0
  1647.         je .no_redraw
  1648.                 mov esi,tl_box_top
  1649.                 add esi,tl_box_height ;esi = coord bottom border
  1650.                 call tl_draw_null_cursor ;áâ¨à ¥¬ ªãàá®à
  1651.                 dec tl_cur_pos ;¤¢¨£ ¥¬ ªãàá®à ¢¢¥àå
  1652.  
  1653.                 cmp tl_p_scroll,0 ;¥á«¨ ¥áâì 㪠§ â¥«ì ­  áªà®««¨­£
  1654.                 je @f
  1655.                 mov eax,tl_p_scroll
  1656.                 cmp dword[eax+sb_offs_position],0 ;¥á«¨ áªà®««¨­£ ­  ¢¥àåã, ¢ë室¨¬
  1657.                 je @f
  1658.                 mov edi,tl_cur_pos
  1659.                 cmp edi,dword[eax+sb_offs_position] ;¥á«¨ ªãàá®à ã襫 ¢ëè¥ áªà®««¨­£ , ⮣¤  ®¯ã᪠¥¬ áªà®««¨­£
  1660.                 jge @f
  1661.                         dec dword[eax+sb_offs_position]
  1662.                         stdcall scroll_bar_vertical.draw, eax
  1663.                         stdcall tl_draw, dword[tlist] ;¯®«­ ï ¯¥à¥à¨á®¢ª  ®ª­ 
  1664.                         jmp .no_redraw
  1665.                 @@:
  1666.                         mov edi,[tlist] ;restore edi
  1667.                         call tl_draw_cursor ;¯¥à¥à¨á®¢ª  ªãàá®à 
  1668.                         call tl_draw_caption_cur_pos
  1669.         .no_redraw:
  1670.         ret
  1671. endp
  1672.  
  1673. ;¯¥à¥­¥á⨠ªãàá®à ­  1 áâà ­¨æã ¢ëè¥
  1674. align 4
  1675. proc tl_cur_page_up uses eax edi esi, tlist:dword
  1676.         mov edi,[tlist]
  1677.  
  1678.         cmp tl_p_scroll,0 ;¥á«¨ ¥áâì 㪠§ â¥«ì ­  áªà®««¨­£
  1679.         je .no_redraw
  1680.                 mov esi,tl_p_scroll
  1681.                 call tl_get_rows_count ;eax = rows count
  1682.  
  1683.                 cmp tl_cur_pos,0
  1684.                 jne @f
  1685.                 cmp dword[esi+sb_offs_position],0 ;¥á«¨ áªà®««¨­£ ­  ¢¥àåã, ¢ë室¨¬
  1686.                 jne @f
  1687.                         jmp .no_redraw
  1688.                 @@:
  1689.                 cmp tl_cur_pos,eax ;¯à®¢¥à塞 ¯®§¨æ¨î ªãàá®à  ¨ ª®«-¢® á⮪ ­  áâà ­¨æ¥
  1690.                 jl @f ;¥á«¨ ¬¥­ìè¥, â® ¯à¨à ¢­¨¢ ¥¬ ª 0, çâ®-¡ë ­¥ ®â­ïâì ¡®«ìè¥ ç¥¬ ­ ¤®
  1691.                         sub tl_cur_pos,eax
  1692.                         jmp .cursor
  1693.                 @@:
  1694.                         mov tl_cur_pos,0
  1695.                 .cursor:
  1696.                 cmp dword[esi+sb_offs_position],eax
  1697.                 jl @f
  1698.                         sub dword[esi+sb_offs_position],eax
  1699.                         jmp .scroll
  1700.                 @@:
  1701.                 mov dword[esi+sb_offs_position],0
  1702.                 .scroll:
  1703.                 ;¯¥à¥à¨á®¢ª¨ ®ª­  ¨ áªà®««¨­£ 
  1704.                 stdcall tl_draw, edi ;draw window
  1705.                 stdcall scroll_bar_vertical.draw, esi
  1706.         .no_redraw:
  1707.         ret
  1708. endp
  1709.  
  1710. ;¯¥à¥­¥á⨠ªãàá®à ­  1 áâà ­¨æã ­¨¦¥
  1711. align 4
  1712. proc tl_cur_page_down uses eax ebx ecx edi esi, tlist:dword
  1713. ;eax - ª®«-¢® áâப ­  áâà ­¨æ¥
  1714. ;ebx - ¬ ªá. ¯®§¨æ¨ï ªãàá®à 
  1715. ;ecx - ¬ ªá. ¯®§¨æ¨ï áªà®««¨­£ 
  1716.         mov edi,[tlist]
  1717.         cmp tl_p_scroll,0 ;¥á«¨ ¥áâì 㪠§ â¥«ì ­  áªà®««¨­£
  1718.         je .no_redraw
  1719.                 mov esi,tl_p_scroll
  1720.                 call tl_get_node_count ;eax = node count
  1721.                 bt tl_style,3 ;tl_cursor_pos_limited
  1722.                 jnc @f
  1723.                 or eax,eax
  1724.                 jz @f
  1725.                         dec eax ;¥á«¨ ªãàá®à á⠥⠭  áãé¥áâ¢ãî騥 㧫ë
  1726.                 @@:
  1727.                 mov ebx,eax
  1728.                 call tl_get_rows_count ;eax = rows count
  1729.  
  1730.                 mov ecx,ebx
  1731.                 inc ecx ;¥á«¨ ­¨¦­¨© 㧥« ¢¨¤¥­ ­  ¯®«®¢¨­ã
  1732.                 cmp ecx,eax ;if (ecx>eax) { ecx=ecx-eax } else { ecx=0 }
  1733.                 jl @f
  1734.                         sub ecx,eax ;㬥­ìè ¥¬ ¬ ªá¨¬ «ì­ãî ¯®§¨æ¨î áªà®««¨­£ , â ª çâ®-¡ë ¡ë«¨ ¢¨¤­ë ¯®á«¥¤­¨¥ 㧫ë
  1735.                         jmp .control
  1736.                 @@:
  1737.                         xor ecx,ecx ;ecx=0 - ¢á¥ ã§«ë ¢« §ïâ ¢ íªà ­, áªà®««¨­£ ­¥ ­ã¦¥­
  1738.                 .control:
  1739.  
  1740.                 cmp tl_cur_pos,ebx ;ªãàá®à ¢­¨§ã ?
  1741.                 jl @f
  1742.                 cmp dword[esi+sb_offs_position],ecx ;áªà®««¨­£ ¢­¨§ã ?
  1743.                 jl @f
  1744.                         jmp .no_redraw
  1745.                 @@:
  1746.                 add tl_cur_pos,eax ;¯¥à¥¬¥é ¥¬ ªãàá®à
  1747.                 cmp tl_cur_pos,ebx
  1748.                 jl @f
  1749.                         mov tl_cur_pos,ebx
  1750.                 @@:
  1751.                 add dword[esi+sb_offs_position],eax ;¯¥à¥¬¥é ¥¬ áªà®««¨­£
  1752.                 cmp dword[esi+sb_offs_position],ecx
  1753.                 jl @f
  1754.                         mov dword[esi+sb_offs_position],ecx
  1755.                 @@:
  1756.  
  1757.                 ;¯¥à¥à¨á®¢ª¨ ®ª­  ¨ áªà®««¨­£ 
  1758.                 stdcall tl_draw, edi ;draw window
  1759.                 stdcall scroll_bar_vertical.draw, esi
  1760.         .no_redraw:
  1761.         ret
  1762. endp
  1763.  
  1764. ;®âªàëâì/§ ªàëâì 㧥« (à ¡®â ¥â á 㧫 ¬¨ ª®â®àë¥ ¨¬¥îâ ¤®ç¥à­¨¥ 㧫ë)
  1765. align 4
  1766. proc tl_node_close_open uses eax edx edi, tlist:dword
  1767.         mov edi,[tlist]
  1768.         call tl_get_cur_node_index ;eax = ¯®§¨æ¨ï 㧫  ­  ª®â®à®¬ á⮨⠪ãàá®à
  1769.         cmp eax,2 ;ªãàá®à á⮨⠭  㧫¥ ?
  1770.         jl @f
  1771.                 imul eax,sizeof.TreeNode
  1772.                 add eax,tl_data_nodes
  1773.                 ;eax = 㪠§ â¥«ì ­  áâàãªâãàã 㧫  ¢ë¡à ­­®£® ªãàá®à®¬
  1774.                 push eax
  1775.                         stdcall tl_node_poi_get_next_info, edi,eax
  1776.                         mov edx,eax ;edx = 㪠§ â¥«ì ­  áâàãªâãàã 㧫  ª®â®àë© ¨¤¥â ¯®á«¥ 㧫  eax
  1777.                 pop eax
  1778.                 or edx,edx ;¥áâì «¨ ã§«ë ­¨¦¥ ¢ë¡à ­­®£® ­ ¬¨ ?
  1779.                 jz @f
  1780.                         mov dl,byte[edx+TreeNode.level] ;¡¥à¥¬ ã஢¥­ì ­¨¦­¥£® 㧫 
  1781.                         cmp byte[eax+TreeNode.level],dl
  1782.                         jge @f ;¥á«¨ ­¨¦­¨¥ ã§«ë ¬¥­ì襣® ã஢­ï, §­ ç¨â ®­¨ ­¥ ¤®ç¥à­¨¥, ª®­¥æ ä㭪樨
  1783.                                 xor byte[eax+TreeNode.close],1 ;*** ®âªàë⨥/§ ªàë⨥ 㧫  ***
  1784.                                 call tb_scrol_resize ;®¡à ¡®âª  áªà®««¨­£ 
  1785.  
  1786.                                 stdcall tl_draw, edi ;®¡­®¢«¥­¨¥ ®ª­ 
  1787.         @@:
  1788.         ret
  1789. endp
  1790.  
  1791. ;㢥«¨ç¨âì ã஢¥­ì
  1792. align 4
  1793. proc tl_node_lev_inc uses eax ecx edx edi, tlist:dword
  1794.         mov edi,[tlist]
  1795.         bt tl_style,2 ;tl_list_box_mode
  1796.         jc @f
  1797.         call tl_get_cur_node_index ;eax=po_t
  1798.         cmp eax,2
  1799.         jl @f
  1800.                 mov ecx,tl_data_nodes
  1801.                 imul eax,sizeof.TreeNode
  1802.                 add eax,ecx ;eax = pointer to node struct
  1803.                 add ecx,sizeof.TreeNode ;ecx = pointer to 1 node struct
  1804.  
  1805.                 mov edx,eax
  1806.                 call tl_iterat_perv ;¯à®¢¥à塞 ¥áâì «¨ ¢¥àå­¨© 㧥«
  1807.                 cmp edx,ecx
  1808.                 jle @f ;¥á«¨ ¢¥àå­¥£® 㧫  ­¥â ⮠⥪ã騩 㧥« ­¥ ¤¢¨£ ¥¬
  1809.                 mov cl,byte[edx+TreeNode.level] ;¡¥à¥¬ ã஢¥­ì த¨â¥«ì᪮£® 㧫 
  1810.                 inc cl ;¤®¡ ¢«ï¥¬ 1 ¨ ¯®«ãç ¥¬ ¬ ªá¨¬ «ì­®¥ §­ ç¥­¨¥
  1811.                 cmp byte[eax+TreeNode.level],cl
  1812.                 jge @f
  1813.                         inc byte[eax+TreeNode.level] ;㢥«¨ç¨¢ ¥¬ §­ ç¥­¨¥ 㧫 
  1814.         @@:
  1815.         ret
  1816. endp
  1817.  
  1818. ;㬥­ìè¨âì ã஢¥­ì
  1819. align 4
  1820. proc tl_node_lev_dec uses eax edi, tlist:dword
  1821.         mov edi,[tlist]
  1822.         call tl_get_cur_node_index ;eax=po_t
  1823.         cmp eax,2
  1824.         jl @f
  1825.                 imul eax,sizeof.TreeNode
  1826.                 add eax,tl_data_nodes
  1827.                 cmp byte[eax+2],0
  1828.                 je @f
  1829.                 dec byte[eax+2]
  1830.         @@:
  1831.         ret
  1832. endp
  1833.  
  1834. ;¯¥à¥¬¥é ¥¬ 㧥« ¢¢¥àå
  1835. align 4
  1836. proc tl_node_move_up tlist:dword
  1837. pushad
  1838.         mov edi,[tlist]
  1839.         call tl_get_cur_node_index ;eax=po_t
  1840.         cmp eax,2
  1841.         jl @f
  1842.                 mov ebx,eax ;copy index of node struct
  1843.                 mov edx,tl_data_nodes
  1844.                 mov ecx,edx
  1845.                 add ecx,sizeof.TreeNode
  1846.                 imul eax,sizeof.TreeNode
  1847.                 add eax,edx ;eax = pointer to 2 node struct
  1848.                 mov edx,eax ;edx = pointer to 2 node struct
  1849.                 mov esi,eax ;esi = pointer to 2 node struct
  1850.                 call tl_iterat_perv ;edx = pointer to 1 node struct
  1851.                 call tl_get_node_index ;eax = index of 1 node struct
  1852.                 cmp edx,ecx
  1853.                 jle @f
  1854.                         cmp dword[edx+TreeNode.next],ebx
  1855.                         jne .po8
  1856.                                 call tl_node_move_po6 ;ã§«ë ¨¤ãâ ¯®¤àï¤ ¬¥­ï¥¬ 6 ááë«®ª
  1857.                                 jmp .cur_mov
  1858.                         .po8:
  1859.                                 call tl_node_move_po8 ;ã§«ë ¨¤ãâ ­¥ ¯®¤àï¤ ¬¥­ï¥¬ 8 ááë«®ª
  1860.                         .cur_mov:
  1861.                                 push dword edi
  1862.                                 call tl_cur_perv
  1863.                                 push dword edi
  1864.                                 call tl_draw
  1865.         @@:
  1866. popad
  1867.         ret
  1868. endp
  1869.  
  1870. ;¯¥à¥¬¥é ¥¬ 㧥« ¢­¨§
  1871. align 4
  1872. proc tl_node_move_down tlist:dword
  1873. pushad
  1874.         mov edi,[tlist]
  1875.         call tl_get_cur_node_index ;eax=po_t
  1876.         cmp eax,2
  1877.         jl @f
  1878.                 mov ebx,eax ;copy index of node struct
  1879.                 mov edx,tl_data_nodes
  1880.                 mov ecx,edx
  1881.                 add ecx,sizeof.TreeNode
  1882.                 imul eax,sizeof.TreeNode
  1883.                 add eax,edx ;eax = pointer to 1 node struct
  1884.                 mov edx,eax ;edx = pointer to 1 node struct
  1885.                 mov esi,eax ;esi = pointer to 1 node struct
  1886.                 call tl_iterat_next ;edx = pointer to 2 node struct
  1887.                 call tl_get_node_index ;eax = index of 2 node struct
  1888.                 cmp edx,ecx
  1889.                 jle @f
  1890.                         cmp dword[esi+TreeNode.next],eax
  1891.                         jne .po8
  1892.                                 xchg eax,ebx ;¬¥­ï¥ ¯®à冷ª á«¥¤®¢ ­¨ï § ¬¥­ï¥¬ëå 㧫®¢
  1893.                                 xchg edx,esi
  1894.                                 call tl_node_move_po6 ;ã§«ë ¨¤ãâ ¯®¤àï¤ ¬¥­ï¥¬ 6 ááë«®ª
  1895.                                 jmp .cur_mov
  1896.                         .po8: ;  âãâ ¯®à冷ª á«¥¤®¢ ­¨ï 㧫®¢ ­¥ ¬¥­ï¥¬
  1897.                                 call tl_node_move_po8 ;ã§«ë ¨¤ãâ ­¥ ¯®¤àï¤ ¬¥­ï¥¬ 8 ááë«®ª
  1898.                         .cur_mov:
  1899.                                 stdcall tl_cur_next, edi
  1900.                                 stdcall tl_draw, edi
  1901.         @@:
  1902.         ret
  1903. popad
  1904. endp
  1905.  
  1906. align 4
  1907. tl_node_move_po6:
  1908.         mov ecx,edx ;save node pointer
  1909.         call tl_move_perv
  1910.         mov dword[edx+TreeNode.next],ebx
  1911.  
  1912.         mov edx,esi
  1913.         call tl_move_next
  1914.         mov dword[edx+TreeNode.perv],eax
  1915.         mov edx,ecx ;restore node pointer
  1916.  
  1917.         mov ecx,dword[edx+TreeNode.perv]
  1918.         mov dword[esi+TreeNode.perv],ecx
  1919.         mov ecx,dword[esi+TreeNode.next]
  1920.         mov dword[edx+TreeNode.next],ecx
  1921.  
  1922.         mov dword[edx+TreeNode.perv],ebx
  1923.         mov dword[esi+TreeNode.next],eax
  1924.         ret
  1925.  
  1926. ;input
  1927. ;eax = index 1 node struct
  1928. ;ebx = index 2 node struct
  1929. ;edx = pointer 1 node struct
  1930. ;esi = pointer 2 node struct
  1931. ;edi = pointer to 'TreeList' struct
  1932. ;output:
  1933. ;eax = ?
  1934. ;ebx = ?
  1935. ;ecx = ?
  1936. align 4
  1937. tl_node_move_po8:
  1938.         mov ecx,edx ;save node pointer
  1939.         call tl_move_perv
  1940.         mov dword[edx+TreeNode.next],ebx
  1941.         mov edx,ecx
  1942.         call tl_move_next
  1943.         mov dword[edx+TreeNode.perv],ebx
  1944.         mov edx,esi
  1945.         call tl_move_perv
  1946.         mov dword[edx+TreeNode.next],eax
  1947.         mov edx,esi
  1948.         call tl_move_next
  1949.         mov dword[edx+TreeNode.perv],eax
  1950.         mov edx,ecx ;restore node pointer
  1951.  
  1952.         mov eax,dword[edx+TreeNode.perv]
  1953.         mov ebx,dword[esi+TreeNode.perv]
  1954.         xchg eax,ebx
  1955.         mov dword[edx+TreeNode.perv],eax
  1956.         mov dword[esi+TreeNode.perv],ebx
  1957.  
  1958.         mov eax,dword[edx+TreeNode.next]
  1959.         mov ebx,dword[esi+TreeNode.next]
  1960.         xchg eax,ebx
  1961.         mov dword[edx+TreeNode.next],eax
  1962.         mov dword[esi+TreeNode.next],ebx
  1963.         ret
  1964.  
  1965. ;input:
  1966. ; edi = pointer to 'TreeList' struct
  1967. align 4
  1968. tl_draw_caption_cur_pos:
  1969.         cmp tl_capt_cy,9 ;9 - minimum caption height
  1970.         jl @f
  1971.         pushad
  1972.                 mov ebx,edi ;calculate cursor position
  1973.                 mov eax,tl_cur_pos
  1974.                 inc eax
  1975.                 lea edi,[txt_capt_cur.v]
  1976.                 stdcall tl_convert_to_str, 5
  1977.                 mov edi,ebx
  1978.  
  1979.                 mov ebx,tl_box_left
  1980.                 shl ebx,16
  1981.                 add ebx,5*65536+3
  1982.                 add ebx,tl_box_top
  1983.                 mov ecx,tl_col_txt
  1984.                 or  ecx,0xc0000000 ;0x40000000 § ªà è¨¢ âì ä®­ 梥⮬ edi
  1985.                 lea edx,[txt_capt_cur]
  1986.                 mov edi,tl_col_zag
  1987.                 mcall SF_DRAW_TEXT ;captions
  1988.         popad
  1989.         @@:
  1990.         ret
  1991.  
  1992. ;input:
  1993. ; tlist - pointer to 'TreeList' struct
  1994. ; opt - options: 0 - first element, 1 - add next element
  1995. ; h_mem - pointer to memory
  1996. ; mem_size - memory size
  1997. ;output:
  1998. ; eax - error code
  1999. align 4
  2000. proc tl_save_mem uses ebx ecx edx edi esi, tlist:dword, opt:dword, h_mem:dword, mem_size:dword
  2001.         mov esi,[h_mem]
  2002.         mov edi,[tlist]
  2003.  
  2004.         cmp dword[opt],0 ;add mode
  2005.         je @f
  2006.                 stdcall tl_get_mem_size, edi,esi ;eax = à §¬¥à à ­¥¥ á®åà ­ñ­­ëå ¤ ­­ëå
  2007.                 add esi,eax
  2008.         @@:
  2009.  
  2010.         xor ebx,ebx
  2011.         mov bx,tl_info_size
  2012.  
  2013.         call tl_get_node_count_all ;eax = all node count
  2014.  
  2015.         mov ecx,eax  ;¢ëç¨á«ï¥¬ ᪮«ìª® ¯ ¬ï⨠¤®«¦­® ¡ëâì § ¯®«­¥­®
  2016.         imul ecx,ebx ;㬭®¦ ¥¬ ­  à §¬¥à áâàãªâãàë 㧫 
  2017.         add ecx,tl_save_load_heder_size+1 ;element header +1 end element sumbol
  2018.         add ecx,esi  ;¤®¡ ¢«ï¥¬ 㪠§ â¥«ì ­  ­ ç «® ¯ ¬ï⨠(á ãç¥â®¬ à ­¥¥ § ¯¨á ­­ëå áâàãªâãà)
  2019.         sub ecx,dword[h_mem] ;®â­¨¬ ¥¬ 㪠§ â¥«ì ­  ­ ç «® ¯ ¬ï⨠(¡¥§ à ­¥¥ § ¯¨á ­­ëå áâàãªâãà)
  2020.         cmp ecx,dword[mem_size] ;ecx = element memory size
  2021.         jg .err_mem_size
  2022.  
  2023.                 ;save tree params (in header)
  2024.                 mov dword[esi],'tree'
  2025.                 mov word[esi+4],bx
  2026.                 mov dword[esi+6],eax ;element count
  2027.  
  2028.                 mov eax,tl_style
  2029.                 mov dword[esi+10],eax
  2030.  
  2031.                 mov eax,tl_cur_pos
  2032.                 mov dword[esi+14],eax
  2033.  
  2034.                 mov ax,tl_info_capt_offs
  2035.                 mov word[esi+18],ax
  2036.  
  2037.                 mov ax,tl_info_capt_len
  2038.                 mov word[esi+20],ax
  2039.  
  2040.                 ;copy scroll position
  2041.                 mov edx,tl_p_scroll
  2042.                 mov eax,dword[edx+sb_offs_position]
  2043.                 mov dword[esi+22],eax
  2044.  
  2045.                 add esi,tl_save_load_heder_size ;add header size
  2046.  
  2047.                 ;cycle to nodes
  2048.                 mov edx,tl_data_nodes
  2049.                 mov ecx,edx
  2050.                 add ecx,sizeof.TreeNode
  2051.                 @@:
  2052.                         call tl_iterat_next_all
  2053.                         cmp edx,ecx
  2054.                         jle @f
  2055.                 ;save node params
  2056.                 call tl_get_node_index ;eax = index of pointer [edx]
  2057.                 mov dword[esi],eax
  2058.  
  2059.                 add esi,4
  2060.                 mov eax,dword[edx+TreeNode.type] ;eax = (type; level; close)
  2061.                 mov dword[esi],eax
  2062.                 add esi,4
  2063.  
  2064.                         stdcall tl_node_poi_get_data, edi,edx ;eax - pointer node data
  2065.  
  2066.                 ;call tl_node_copy_data
  2067.                 push ecx edi
  2068.                 mov edi,eax
  2069.                 mov ecx,ebx
  2070.                 xchg esi,edi
  2071.                 rep movsb
  2072.                 mov esi,edi
  2073.                 pop edi ecx
  2074.                 ;add esi,ebx
  2075.                 jmp @b
  2076.         @@:
  2077.         mov byte[esi],0 ;end of 'treelist'
  2078.                 xor eax,eax ;return error code
  2079.         jmp @f
  2080.         .err_mem_size:
  2081.                 mov eax,tl_err_save_memory_size
  2082.         @@:
  2083.         ret
  2084. endp
  2085.  
  2086. ;input:
  2087. ; tlist - pointer to 'TreeList' struct
  2088. ; opt   - options: element index + (2*(add mode)+(init mode)) shl 16
  2089. ; h_mem - pointer to memory
  2090. ; mem_size - memory size
  2091. ;   à §¬¥à ¯ ¬ïâ¨, ¯®ª  ­¥ ¨á¯®«ì§ã¥âáï (­ §­ ç «áï ¤«ï ª®­â஫ï)
  2092. ;   ¤«ï ¥£® ¨á¯®«ì§®¢ ­¨ï ­ã¦­® ¤®à ¡®â âì äã­ªæ¨î
  2093. ;output:
  2094. ; eax - error code
  2095. ;memory header format:
  2096. ;  +0 - (4) 'tree'
  2097. ;  +4 - (2) info size
  2098. ;  +6 - (4) count nodes
  2099. ; +10 - (4) tlist style
  2100. ; +14 - (4) cursor pos
  2101. ; +18 - (2) info capt offs
  2102. ; +20 - (2) info capt len
  2103. ; +22 - (4) scroll pos
  2104. ;memory data format:
  2105. ; +26 - (info size + 8) * count nodes
  2106. align 4
  2107. proc tl_load_mem uses ebx ecx edx edi esi, tlist:dword, opt:dword, h_mem:dword, mem_size:dword
  2108. locals
  2109.         er_code dd ?
  2110. endl
  2111.         mov esi,[h_mem]
  2112.         mov edi,[tlist]
  2113.  
  2114.         mov dword[er_code],0 ;return error code
  2115.  
  2116.         mov ecx,[opt]
  2117.         or cx,cx ;load in array mode
  2118.         jz @f
  2119.                 ;stdcall tl_get_mem_size, esi,edi ;¡¥à¥¬ à §¬¥à à ­¥¥ á®åà ­ñ­­ëå ¤ ­­ëå
  2120.                 ;add esi,eax
  2121.                 and ecx,0xffff
  2122.                 cld
  2123.                 .beg_cycle:
  2124.                         cmp dword[esi],'tree'
  2125.                         jne .no_tree
  2126.                         movzx ebx,word[esi+4]
  2127.                         add bx,8
  2128.                         imul ebx,dword[esi+6]
  2129.                         add ebx,tl_save_load_heder_size
  2130.                         add esi,ebx
  2131.                         loop .beg_cycle
  2132.         @@:
  2133.  
  2134.         cmp dword[esi],'tree'
  2135.         jne .no_tree
  2136.                 bt dword[opt],17 ;load in add mode
  2137.                 jc @f
  2138.                         stdcall tl_info_clear, edi
  2139.                 @@:
  2140.  
  2141.                 xor ebx,ebx
  2142.                 mov bx,word[esi+4] ;info_size
  2143.                 cmp bx,tl_info_size
  2144.                 je @f
  2145.                         or dword[er_code],tl_err_load_info_size
  2146.                 @@:
  2147.                 mov ecx,[esi+6] ;count nodes
  2148.                 cmp ecx,1
  2149.                 jl .end_f
  2150.                 mov edx,esi ;save header pointer
  2151.                 add esi,tl_save_load_heder_size
  2152.  
  2153.                 cld
  2154.                 @@: ;load node params
  2155.                         mov eax,dword[esi+4]
  2156.                         ror eax,16 ;eax - options (type; level; close)
  2157.                         add esi,8
  2158.                         stdcall tl_node_add, edi,eax,esi
  2159.                         stdcall tl_cur_next, edi
  2160. ;...
  2161.                         add esi,ebx
  2162.                         loop @b
  2163.  
  2164.                 bt dword[opt],17 ;load in add mode
  2165.                 jc .no_tree
  2166.                         mov eax,dword[edx+14] ;set cursor pos
  2167.                         mov tl_cur_pos,eax
  2168.                         mov ebx,tl_p_scroll
  2169.                         or ebx,ebx
  2170.                         jz .end_f
  2171.                                 mov eax,dword[edx+22] ;set scroll pos
  2172.                                 mov dword[ebx+sb_offs_position],eax
  2173.                                 stdcall scroll_bar_vertical.draw, ebx
  2174.                                 jmp .end_f
  2175.         .no_tree:
  2176.         mov dword[er_code],tl_err_load_caption
  2177.         .end_f:
  2178.         mov eax,dword[er_code]
  2179.         ret
  2180. endp
  2181.  
  2182. ;¡¥à¥â à §¬¥à ¯ ¬ï⨠§ ­ï⮩ ä㭪樥© tl_save_mem ¯à¨ á®åà ­¥­¨¨ í«¥¬¥­â®¢
  2183. ;output:
  2184. ; eax - error code
  2185. align 4
  2186. proc tl_get_mem_size uses ebx edi, tlist:dword, h_mem:dword
  2187.         mov edi,[tlist]
  2188.         mov eax,[h_mem]
  2189.         @@:
  2190.                 cmp dword[eax],'tree'
  2191.                 jne @f
  2192.                 xor ebx,ebx
  2193.                 mov bx,word[eax+4]
  2194.                 add bx,8 ;à §¬¥à ¤®¯®«­¨â¥«ì­®© ¨­ä®à¬ æ¨¨ ®¡ 㧫¥ (¨­¤¥ªá § ¯¨á¨; ¨­¤¥ªá ¨ª®­ª¨, ã஢¥­ì, ...)
  2195.                 imul ebx,dword[eax+6]
  2196.                 add ebx,tl_save_load_heder_size
  2197.                 add eax,ebx
  2198.                 jmp @b
  2199.         @@:
  2200.         sub eax,dword[h_mem] ;®â­¨¬ ¥¬ 㪠§ â¥«ì ­  ­ ç «® ¯ ¬ïâ¨
  2201.                 ;¨ ¯®«ãç ¥¬ à §¬¥à ¡«®ª  ¯ ¬ïâ¨
  2202.         ret
  2203. endp
  2204.  
  2205.  
  2206. ;ascii scan key
  2207. ;  13    28 Enter
  2208. ;  32    57 Space
  2209. ; 178    72 Up
  2210. ; 177    80 Down
  2211. ; 176    75 Left
  2212. ; 179    77 Right
  2213. ; 182    83 Delete
  2214. ; 184    73 Pg Up
  2215. ; 183    81 Pg Dn
  2216.  
  2217. tl_key_ascii db 13,32,178,177,176,179,182,184,183
  2218. tl_key_scan  db 28,57, 72, 80, 75, 77, 83, 73, 81
  2219.  
  2220. txt_capt_cur: db '‘âப  '
  2221. .v: db '     ',0
  2222. txt_capt_otm: db 'Žâ¬¥­ë '
  2223. .v: db '     ',0
  2224.  
  2225. ;description:
  2226. ; ¯à¥à¥¢®¤ ç¨á«  ¢ ASCII áâபã
  2227. ;input:
  2228. ; eax = value
  2229. ; edi = string buffer
  2230. align 4
  2231. proc tl_convert_to_str, len:dword
  2232. pushad
  2233.         mov esi,[len]
  2234.         add esi,edi
  2235.         dec esi
  2236.         call .str
  2237. popad
  2238.         ret
  2239. endp
  2240.  
  2241. align 4
  2242. .str:
  2243.         mov ecx,10 ;§ ¤ ¥âáï á¨á⥬  áç¨á«¥­¨ï
  2244.         cmp eax,ecx  ;áà ¢­¨âì ¥á«¨ ¢ eax ¬¥­ìè¥ ç¥¬ ¢ ecx â® ¯¥à¥©â¨ ­  @@-1 â.¥. ­  pop eax
  2245.         jb @f
  2246.                 xor edx,edx ;®ç¨áâ¨âì edx
  2247.                 div ecx     ;à §¤¥«¨âì - ®áâ â®ª ¢ edx
  2248.                 push edx    ;¯®«®¦¨âì ¢ á⥪
  2249.                 call .str   ;¢ë§¢ âì á ¬ã á¥¡ï ¨ â ª ¤® ⮣® ¬®¬¥­â  ¯®ª  ¢ eax ­¥ áâ ­¥â ¬¥­ìè¥ ç¥¬ ¢ ecx
  2250.                 pop eax
  2251.         @@:
  2252.         cmp edi,esi
  2253.         jge @f
  2254.                 or al,0x30  ;¤®¡ ¢«ï¥¬ ᨬ¢®« '0'
  2255.                 stosb       ;§ ¯¨á âì al ¢ ï祪㠯 ¬ï⨠[edi]
  2256.                 mov byte[edi],0
  2257.         @@:
  2258.         ret
  2259.