Subversion Repositories Kolibri OS

Rev

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