Subversion Repositories Kolibri OS

Rev

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