Subversion Repositories Kolibri OS

Rev

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