Subversion Repositories Kolibri OS

Rev

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

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