Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 6971 → Rev 6972

/programs/develop/libraries/box_lib/trunk/tree_list.mac
File deleted
/programs/develop/libraries/box_lib/trunk/optionbox.mac
File deleted
\ No newline at end of file
/programs/develop/libraries/box_lib/trunk/bl_sys.mac
1,9 → 1,7
include 'optionbox.mac' ;macro implements optionbox
include 'scrollbar.mac' ;macro implements scrollbar
include 'd_button.mac' ;macro implements dinamic_button
include 'menubar.mac' ;macro implements menubar
include 'filebrowser.mac' ;macro implements filebrowser
include 'tree_list.mac' ;macro implements tree_list, image_list, list_box
include 'pathshow.mac' ;macro implements pathshow
include 't_edit.mac' ;macro implements text_editor
include 'frame.mac' ;macro implements frame
/programs/develop/libraries/box_lib/trunk/box_lib.asm
39,13 → 39,7
 
;--------------------------------------------------
;radiobutton Group
;--------------------------------------------------
align 16
use_optionbox_driver ;macro that control the operating modes
align 16
use_optionbox_draw ;macro reveals the function of the display.
align 16
use_optionbox_mouse ;macro reveals processing function of the mouse.
include 'optionbox.asm' ;macro implements optionbox
 
;--------------------------------------------------
;scrollbar Group
77,9 → 71,7
 
;--------------------------------------------------
;tree list
;--------------------------------------------------
align 16
use_tree_list
include 'tree_list.asm' ;macro implements tree_list, image_list, list_box
 
;--------------------------------------------------
;PathShow Group
/programs/develop/libraries/box_lib/trunk/optionbox.asm
0,0 → 1,173
; í«¥¬¥­â Optionbox ¤«ï ¡¨¡«¨®â¥ª¨ box_lib.obj
; ­  ª®¤ ¯à¨¬¥­¥­  GPL2 «¨æ¥­§¨ï
; ä ©« ᮧ¤ ­ 13.02.2009 <Lrz>
; ¯®á«¥¤­ïï ¬®¤¨ä¨ª æ¨ï 12.09.2017 IgorA
 
align 16
option_box_draw:
pusha
 
mov eax,dword[esp+36]
@@:
mov edi,dword[eax]
test edi,edi
je option_check
call option_box_draw_box
add eax,4
jmp @b
 
option_check:
mov eax,dword[esp+36]
@@:
mov edi,dword[eax]
test edi,edi
je @f
 
mov ebx,dword[edi]
mov ebx,dword[ebx]
cmp edi,ebx
jne .clear_op
 
pusha
call option_box_draw_op
popa
add eax,4
jmp @b
 
.clear_op:
pusha
call option_box_clear_op
popa
add eax,4
jmp @b
 
@@:
popa
ret 4
 
 
align 16
option_box_mouse:
pusha
mcall SF_MOUSE_GET,SSF_BUTTON
test eax,eax
jnz @f
popa
ret 4
 
@@:
mov eax,dword[esp+36]
@@:
mov edi,dword[eax]
test edi,edi
je option_check
call option_box_mouse_op
add eax,4
jmp @b
 
align 16
option_box_draw_box:
pusha ;á®åà ­¨¬ ¢á¥ ॣ¨áâàë
 
movzx ebx,word op_left
shl ebx,16
add ebx,dword op_size
movzx ecx,word op_top
shl ecx,16
add ecx,dword op_size
mcall SF_DRAW_RECT,,,op_border_color ;à¨á㥬 à ¬ªã
 
add ebx,1 shl 16 - 2
add ecx,1 shl 16 - 2
mcall ,,,op_color ;§ ªà è¨¢ ¥¬ ¢­ãâ७­®á⨠祪¡®ªá 
 
; mov eax,dword option_group
; mov eax,[eax]
; cmp eax,edi
; jne @f
; call option_box_draw_op ;­ à¨á®¢ âì ¢ª«î祭­ë© 祪 ¡®ªá
 
 
;----------------------------
;à áç¥â ªã¤  ¡ã¤¥â ¯à®¨§¢¥¤¥­ ¢ë¢®¤ ⥪áâ 
;----------------------------
@@:
movzx ebx,word op_left ;§ £à㧨âì §­ ç¥­¨¥ å ¤«ï 祪 ¡®ªá 
add ebx,dword op_size
add ebx,dword op_text_margin ;¤®¡ ¢¨âì à §¬¥à áâ®à®­ë ¨ à ááâ®ï­¨¥ ­  ª®â®à®¬ ­ ç­¥âáï ¢ë¢®¤ ⥪áâ 
shl ebx,16 ;ᤢ¨­¥¬ ­  16 à §à冷¢ ¢ «¥¢® (㬭®¦¨¬ ­  65536)
mov bx,word op_top ;§ £à㧨¬ §­ ç¥­¨¥ ¯® y
mov eax,op_size
shr eax,1
add eax,4
add ebx,eax
sub ebx,7 ;¤®¡ ¢¨¬ §­ ç¥­¨¥ ¤«¨­ë áâ®à®­ë -9+2
mov esi,dword op_text_length
mcall SF_DRAW_TEXT,,op_text_color,op_text_ptr ;‚뢮¤ ­ ¤¯¨á¨ ­  ª ­¢ã
popa ;¢®ááâ ­®¢¨âì §­ ç¥­¨ï ॣ¨áâ஢ ¨§ á⥪ 
ret ;¢ë©¤¥¬ ¨§ ¯à®æ¥¤ãàë
 
option_box_clear_op: ;®ç¨á⪠ 祪 ¡®ªá 
mov edx,dword op_color ;梥⠢­ãâਠ祪 ¡®ªá 
jmp @f ;¡¥§ãá«®¢­ë© ¯à릮ª ­  ­¨¦­îî ¬¥âªã @@
 
 
option_box_draw_op: ;­ à¨á®¢ âì ¢ª«î祭­ë© 祪 ¡®ªá
mov edx,dword op_border_color ;§ £à㧨âì 梥â
@@:
movzx ebx,word op_left ;§ £à㧨âì ª®®à¤¨­ âã ¯® å
mov eax,dword op_size
mov bp,ax
shr eax,2
push ax
 
push ax
add ebx,eax
shl ebx,16 ;ᤢ¨­¥¬ ­  16 à §à冷¢ ¢ «¥¢® (㬭®¦¨¬ ­  65536)
pop ax
lea eax,[eax*2]
sub bp,ax ;á®åà ­¨¬ ॣ¨áâà bx ¢ ॣ¨áâॠ㪠§ â¥«ï ¡ §ë
mov bx,bp
 
movzx ecx,word op_top ;§ £à㧨âì ª®®à¤¨­ âã ¯® ã
pop ax
add cx,ax
shl ecx,16 ;ᤢ¨­¥¬ ­  16 à §à冷¢ ¢ «¥¢® (㬭®¦¨¬ ­  65536)
mov cx,bp ;§ £à㧨¬ §­ ç¥­¨ï ॣ¨áâà  ãª § â¥«ï ¡ §ë ¢ cx
mcall SF_DRAW_RECT ;¢ë¢®¤ ¯®«®áë â.¥. ¯® áã⨠¯àאַ㣮«ì­¨ª , ª®â®àë© ®â®¡à ¦ ¥â ¢ª«î祭­ë© ª®¬¯®­¥­â 祪 ¡®ªá
ret ;¢ë©â¨ ¨§ ¯à®æ¥¤ãàë
 
 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Ž¡à ¡®â稪 mouse
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
align 16
option_box_mouse_op: ;®¡à ¡®âª  ¬ëè¨
pusha
mov esi,dword op_text_length ;§ £à㧨âì ª®«-¢® ᨬ¢®«®¢ ¢ ⥪á⮢®© áâப¥
imul esi,6 ;¨«¨ ¬®¦­® ¨ â ª 㬭®¦¨âì ­  6
add esi,dword op_text_margin ;¤®¡ ¢¨âì 3 - à ááâ®ï­¨¥ ®â 祪 ¡®ªá  ¤® ­ ¤¯¨á¨
 
mcall SF_MOUSE_GET,SSF_WINDOW_POSITION ;¯®«ãç¨âì ª®®à¤¨­ âë ªãàá®à  ®â­®á¨â¥«ì­® ®ª­ 
 
movzx ebx,word op_top ;§ £à㧨âì ¢ bx §­ ç¥­¨¥ ª®®à¤¨­ âë ã
cmp ax,bx ;áà ¢­¨âì á á ª®®à¤¨­ â®© ªãàá®à 
jl option_box_mouse_end ;SF <> OF ¥á«¨ ¬¥­ìè¥
add ebx,dword op_size ;¤®¡ ¢¨âì à §¬¥à
cmp ax,bx ;áà ¢­¨âì
jg option_box_mouse_end ;ZF = 0 ¨ SF = OF ¥á«¨ ¡®«ìè¥
 
shr eax,16 ;à §¤¥«¨¬ ­  65536 ¨«¨ ¯à®á⮠ᤢ¨­¥¬ ¡¨âë ­  16 §­ ç¥­¨©
movzx ebx,word op_left ;¯à®¨§¢¥¤¥¬  ­ «®£¨ç­®¥ áà ¢­¥­¨¥
cmp ax,bx ;áà ¢­¨âì ॣ¨áâàë
jl option_box_mouse_end ;¥á«¨ ¬¥­ìè¥
add ebx,dword op_size ;¤®¡ ¢¨âì ¤«¨­ã áâ®à®­ë ¯àאַ㣮«ì­¨ª 
add ebx,esi ;“ç¥áâì ¢ §­ ç¥­¨¨ ¯® å ¥é¥ ¨ ¤«¨­ã ­ ¤¯¨á¨ ª 祪¡®ªáã
cmp ax,bx ;áâà ¢­¨âì ॣ¨áâàë
jg option_box_mouse_end ;¥á«¨ ¡®«ìè¥
mov eax,dword option_group
mov [eax],edi
 
option_box_mouse_end:
popa ;¢®ááâ ­®¢¨âì ॣ¨áâàë ¨§ á⥪ 
ret ;¢ë©â¨
/programs/develop/libraries/box_lib/trunk/tree_list.asm
0,0 → 1,2234
; í«¥¬¥­â TreeList ¤«ï ¡¨¡«¨®â¥ª¨ box_lib.obj
; ­  ª®¤ ¯à¨¬¥­¥­  GPL2 «¨æ¥­§¨ï
; ¯®á«¥¤­ïï ¬®¤¨ä¨ª æ¨ï 12.09.2017 IgorA
 
 
struct TreeNode
type dw ? ;+ 0 ⨯ í«¥¬¥­â , ¨«¨ ¨­¤¥ªá ¨ª®­ª¨ ¤«ï 㧫 
level db ? ;+ 2 ã஢¥­ì í«¥¬¥­â 
close db ? ;+ 3 ä« £ § ªàëâ¨ï, ¨«¨ ®âªàëâ¨ï (¨¬¥¥â á¬ëá« ¤«ï த¨â¥«ì᪮£® 㧫 )
perv dd ? ;+ 4 ¨­¤¥ªá ¯à¥¤ë¤ã饣® í«¥¬¥­â 
next dd ? ;+ 8 ¨­¤¥ªá ¯®á«¥¤ãî饣® í«¥¬¥­â 
t_create dd ? ;+12 ¢à¥¬. ᮧ¤ ­¨ï
t_delete dd ? ;+16 ¢à¥¬. 㤠«¥­¨ï
ends
 
 
;¢ë¤¥«­¨¥ ¯ ¬ï⨠¤«ï áâàãªâãà ᯨ᪠ ¨ ®á­®¢­®© ¨­ä®à¬ æ¨¨ (ª®­áâàãªâ®à)
align 16
proc tl_data_init uses eax ecx edi, tlist:dword
mov edi,[tlist]
 
xor ecx,ecx
mov cx,tl_info_size
imul ecx,tl_info_max_count
invoke mem.alloc,ecx
mov tl_data_info,eax ;ª®¯¨à㥬 㪠§ â¥«ì ­  ¯®«ã祭ãî ¯ ¬ïâì ¢ áâàãªâãàã
mov tl_data_img,0 ;®¡­ã«ï¥¬ 㪠§ â¥«ì 'data_img'
mov tl_data_img_sys,0 ;®¡­ã«ï¥¬ 㪠§ â¥«ì 'data_img_sys'
 
mov ecx,sizeof.TreeNode
imul ecx,tl_info_max_count
invoke mem.alloc,ecx
mov tl_data_nodes,eax ;ª®¯¨à㥬 㪠§ â¥«ì ­  ¯®«ã祭ãî ¯ ¬ïâì ¢ áâàãªâãàã
 
stdcall tl_info_clear, edi
 
;­ áâனª¨ ¤®ç¥à­¥£® áªà®««¨­£ 
cmp tl_p_scroll,0
je @f
mov eax,tl_p_scroll
;*** æ¢¥â®¢ë¥ ­ áâனª¨ ***
mov ecx,tl_col_bkg
mov dword[eax+sb_offs_bckg_col],ecx
mov ecx,tl_col_zag
mov dword[eax+sb_offs_frnt_col],ecx
mov ecx,tl_col_txt
mov dword[eax+sb_offs_line_col],ecx
;*** ­ áâனª¨ à §¬¥à®¢ ***
mov ecx,tl_box_left
add ecx,tl_box_width
mov word[eax+2],cx
mov ecx,tl_box_height
mov word[eax+4],cx
mov ecx,tl_box_top
mov word[eax+6],cx
@@:
ret
endp
 
;®ç¨á⪠ ¯ ¬ïâ¨ í«¥¬¥­â  (¤¥áâàãªâ®à)
align 4
proc tl_data_clear uses eax edi, tlist:dword
mov edi,[tlist]
cmp tl_data_img,0
je @f
invoke mem.free,tl_data_img ;ç¨á⪠ á¨á⥬­ëå ¨ª®­®ª
@@:
cmp tl_data_img_sys,0
je @f
invoke mem.free,tl_data_img_sys ;ç¨á⪠ á¨á⥬­ëå ¨ª®­®ª
@@:
invoke mem.free,tl_data_info
invoke mem.free,tl_data_nodes
ret
endp
 
;®ç¨á⪠ ᯨ᪠ (¨­ä®à¬ æ¨¨)
align 4
proc tl_info_clear uses eax ecx edi, tlist:dword
mov edi,[tlist]
mov tl_ch_tim,0
mov tl_tim_undo,0
mov tl_cur_pos,0
mov ecx,sizeof.TreeNode
imul ecx,tl_info_max_count
mov eax,tl_data_nodes
@@:
mov byte[eax],0 ;ç¨á⨬ 㧫ë 0-¬¨
inc eax
loop @b
mov eax,tl_data_nodes ;㪠§ â¥«ì ­  0-© 㧥«
mov dword[eax+TreeNode.next],1 ;㪠§ â¥«ì next ¢ 0-¬ 㧫¥ ¯à¨à ¢­¨¢ ¥¬ ª 1
 
cmp tl_p_scroll,0 ;®¡à ¡®âª  áªà®««¨­£ 
je @f
mov eax,tl_p_scroll
mov dword[eax+sb_offs_position],0
call tb_scrol_resize
@@:
ret
endp
 
;ॠªæ¨ï ­  ª« ¢¨ âãàã
align 4
proc tl_key uses ebx ecx edi, tlist:dword
mov edi,[tlist]
 
mov ebx,tl_el_focus
cmp [ebx],edi
jne .no_focus ;í«¥¬¥­â ­¥ ¢ 䮪ãá¥
 
push eax
mcall SF_KEYBOARD,SSF_GET_INPUT_MODE ;¯®«ãç¨âì ०¨¬ ¢¢®¤  á ª« ¢¨ âãàë
 
lea ecx,[tl_key_scan]
cmp eax,1 ;1 = ᪠­ª®¤ë
je @f
lea ecx,[tl_key_ascii]
@@:
pop eax
 
xor bx,bx
cmp ah,byte[ecx] ;Enter
jne @f
cmp tl_on_press,0
je @f
call tl_on_press
@@:
cmp ah,byte[ecx+1] ;Space
jne @f
stdcall tl_node_close_open, edi
@@:
cmp ah,byte[ecx+2] ;Up
jne @f
stdcall tl_cur_perv, edi
@@:
cmp ah,byte[ecx+3] ;Down
jne @f
stdcall tl_cur_next, edi
@@:
cmp ah,byte[ecx+7] ;Page Up
jne @f
stdcall tl_cur_page_up, edi
@@:
cmp ah,byte[ecx+8] ;Page Down
jne @f
stdcall tl_cur_page_down, edi
@@:
 
bt tl_style,0 ;tl_key_no_edit
jc .no_edit
cmp ah,byte[ecx+4] ;Left
jne @f
stdcall tl_node_lev_dec, edi
mov bx,1
@@:
cmp ah,byte[ecx+5] ;Right
jne @f
stdcall tl_node_lev_inc, edi
mov bx,1
@@:
cmp ah,byte[ecx+6] ;Delete
jne @f
stdcall tl_node_delete, edi
mov bx,1
@@:
.no_edit:
 
cmp bx,1
jne .no_focus
stdcall tl_draw, edi
.no_focus:
ret
endp
 
;ॠªæ¨ï ­  ¬ëèì
align 4
proc tl_mouse, tlist:dword
pushad
mov edi,[tlist]
 
mcall SF_MOUSE_GET,SSF_WINDOW_POSITION ;ª®®à¤¨­ âë ¬ëè¨ ®â­®á¨â¥«ì­® ®ª­ 
 
mov ebx,tl_box_left
shl ebx,16
cmp eax,ebx ;«¥¢ ï £à ­¨æ  ®ª­ 
jl .no_in_wnd ;.test_scroll ­¥ ¯à¨¬¥­ï¥¬
shr ebx,16
add ebx,tl_box_width
shl ebx,16
cmp eax,ebx ;¯à ¢ ï £à ­¨æ  ®ª­ 
jg .test_scroll
 
mov ebx,tl_box_top
add ebx,tl_box_height
cmp ax,bx ;­¨¦­ïï £à ­¨æ  ®ª­ 
jg .test_scroll
 
sub ebx,tl_box_height
add bx,tl_capt_cy
cmp ax,bx ;¢¥àå­ïï £à ­¨æ  ®ª­  + ¢ëá®â  ¯®¤¯¨á¨
jl .test_scroll
 
push eax ebx
mcall SF_MOUSE_GET,SSF_SCROLL_DATA
mov edx,eax
xor ecx,ecx
test eax,eax
jz .mouse_next
test ax,0x8000
jnz .decr
shr eax,16
test ax,0x8000
jnz .decr_1
 
mov cx,dx ;dx = mouse scroll data vertical
test ecx,ecx
jnz @f
shr edx,16
mov cx,dx ;dx = mouse scroll data horizontal
test ecx,ecx
jz .mouse_next
@@:
stdcall tl_cur_next, edi
loop @r
jmp .mouse_next
;------------------------------------------------
.decr: ;¢¥à⨪ «ì­ ï ¯à®ªàã⪠ ®âà¨æ â¥«ì­ ï
mov bx,ax ;ax = mouse scroll data vertical
jmp @f
.decr_1: ;£®à¨§®­â «ì­ ï ¯à®ªàã⪠ ®âà¨æ â¥«ì­ ï
mov bx,ax ;ax = mouse scroll data horizontal
@@:
mov ecx,0xffff
sub ecx,ebx
inc ecx
@@:
stdcall tl_cur_perv, edi
loop @r
;------------------------------------------------
.mouse_next:
 
mcall SF_MOUSE_GET,SSF_BUTTON
bt eax,0 ;left mouse button press
pop ebx eax
jae .no_draw
 
mov esi,tl_el_focus
mov [esi],edi ;set focus
 
; if '+' or '-' press
mov esi,eax
shr esi,16
sub esi,tl_box_left ;esi = mouse x coord in element window
 
and eax,0xffff
sub eax,ebx
xor edx,edx
movzx ecx,tl_img_cy
div ecx
cmp tl_p_scroll,0 ;ãç¨â뢠¥¬ áªà®««¨­£
je @f
mov edx,tl_p_scroll
add eax,[edx+sb_offs_position] ;¤®¡ ¢«ï¥¬ áªà®««¨­£ ­  ¢¥àåã
@@:
 
mov ecx,eax
call tl_get_node_count ;eax = node count
cmp eax,ecx
jl @f
mov eax,ecx ;¥á«¨ ªãàá®à ­¥ ¢ë襫 §  ¯à¥¤¥«ë 㧫®¢, ¢®ááâ ­ ¢«¨¢ ¥¬ áâ à®¥ §­ ç¥­¨¥ eax
@@:
 
cmp eax,tl_cur_pos ;¥á«¨ ­®¢®¥ §­ ç¥­¨¥ ªãàá®à  ᮢ¯ «® á ¯à¥¤ë¤ã騬
je @f ;â® ­¥ áâ¨à ¥¬ ªãàá®à
push esi
mov esi,tl_box_top
add esi,tl_box_height ;esi = coord bottom border
call tl_draw_null_cursor ;áâ¨à ¥¬ ªãàá®à
pop esi
@@:
 
mov tl_cur_pos,eax
 
; if '+' or '-' press
call tl_get_cur_node_index ;eax = node index
cmp eax,2
jl .no_open_close ;ªãàá®à á⮨⠭  ¯ãá⮬ ¬¥áâ¥, ¡¥§ 㧫®¢
imul eax,sizeof.TreeNode
add eax,tl_data_nodes
xor bx,bx
mov bl,byte[eax+TreeNode.level] ;á®å࠭塞 ã஢¥­ì ⥪ã饣® 㧫 
inc bx ;+ ¯®«¥ ¤«ï ªãàá®à 
 
cmp si,tl_img_cx
jl .no_open_close ;¬ë襩 ¯®¯ «¨ ­  «¥¢®¥ ¯®«¥ ¤«ï ªãàá®à , £¤¥ â®ç­® ­¥â '+' ¨ '-'
mov eax,esi
xor edx,edx
xor ecx,ecx
mov cx,tl_img_cx
div ecx
 
cmp ax,bx
jne .no_open_close
 
stdcall tl_node_close_open, edi
.no_open_close:
 
mov esi,tl_box_top
add esi,tl_box_height ;esi = coord bottom border
call tl_draw_cursor ;¯¥à¥à¨á®¢ª  ªãàá®à 
call tl_draw_caption_cur_pos
jmp .no_draw
;--- mouse event for children scrollbar ----------------------------------------
.test_scroll:
mov edx,tl_p_scroll
or edx,edx
jz .no_in_wnd ;¯®«ì§®¢ â¥«ì ­¥ ᮧ¤ « ¤®ç¥à­¥£® áªà®««¨­£ 
shr ebx,16
add bx,word[edx] ;+0 .size_x
shl ebx,16
cmp eax,ebx ;¯à ¢ ï £à ­¨æ  ®ª­ 
jg .no_in_wnd
 
mov eax,[edx+sb_offs_max_area]
cmp eax,[edx+sb_offs_cur_area]
jbe .no_in_wnd ;¢á¥ ã§«ë ¯®¯ ¤ îâ ¢ ®ª­® áªà®««¨­£ 
stdcall scroll_bar_vertical.mouse, edx ;scrollbar_ver_mouse
 
cmp dword[edx+sb_offs_redraw],0
je @f
mov dword[edx+sb_offs_redraw],0
stdcall tl_draw, edi ;¯à®¨§®è«¨ ¨§¬¥­¥­¨ï áªà®««¨­£ 
@@:
cmp dword[edx+sb_offs_delta2],0
jne .no_draw ;¯®¯ «¨ ­  áªà®««¨­£ - ­¥ á­¨¬ ¥¬ 䮪ãá á TreeList
;-------------------------------------------------------------------------------
.no_in_wnd: ;­¥ ¯®¯ «¨ ¢ ®ª­® - ¯®â¥àï 䮪ãá  (¯à¨ ãá«®¢¨¨ ç⮠䮪ãá ¡ë« ­  ¤ ­­®¬ í¥«¥¬¥­â¥)
mcall SF_MOUSE_GET,SSF_BUTTON
or eax,eax ;­¨ç¥£® ­¥ ­ ¦ «¨ eax=0
jz .no_draw
mov ebx,tl_el_focus
cmp [ebx],edi
jne .no_draw ;í«¥¬¥­â ­¥ ¢ 䮪ãá¥
mov dword[ebx],0 ;reset focus
mov esi,tl_box_top
add esi,tl_box_height ;esi = coord bottom border
call tl_draw_cursor ;à¨á㥬 ªãàá®à á ¯®â¥àï­ë¬ 䮪ãᮬ
.no_draw:
 
popad
ret
endp
 
;®â¬¥­  ¤¥©á⢨ï
align 4
proc tl_info_undo uses eax edi, tlist:dword
mov edi,[tlist]
mov eax,tl_tim_undo
cmp tl_ch_tim,eax
jbe @f
inc tl_tim_undo
call tb_scrol_resize ;®¡à ¡®âª  áªà®««¨­£ 
@@:
ret
endp
 
;¯®¢â®à ¤¥©á⢨ï
align 4
proc tl_info_redo uses edi, tlist:dword
mov edi,[tlist]
cmp tl_tim_undo,1
jl @f
dec tl_tim_undo
call tb_scrol_resize ;®¡à ¡®âª  áªà®««¨­£ 
@@:
ret
endp
 
;㤠«¥­¨¥ ®â¬¥­¥­­ëå ¤¥©á⢨©
;¢­ãâ७­ïï äã­ªæ¨ï, ­¥ ¤«ï íªá¯®àâ 
align 4
tl_info_set_undo:
cmp tl_tim_undo,1
jl .no_work
 
push eax ebx ecx edx
mov edx,tl_data_nodes
mov ecx,edx
add ecx,sizeof.TreeNode
call tl_move_next ;long i=node[0].next;
 
mov eax,tl_tim_undo
sub tl_ch_tim,eax ;ch_tim-=tim_undo;
 
cmp edx,ecx
jle @f
;if(node[i].tc>ch_tim){ // ¥á«¨ ᮧ¤ ­¨¥ ᨬ¢®«  ¡ë«® ®â¬¥­¥­®
mov eax,tl_ch_tim
cmp [edx+TreeNode.t_create],eax
jle .no_u1
mov dword[edx+TreeNode.t_create],0
mov dword[edx+TreeNode.t_delete],0
 
mov ebx, [edx+TreeNode.perv]
imul ebx,sizeof.TreeNode
add ebx, tl_data_nodes ;.next
push dword[edx+TreeNode.next] ;node[node[i].perv].next=node[i].next;
pop dword[ebx+TreeNode.next]
 
mov ebx, [edx+TreeNode.next]
imul ebx,sizeof.TreeNode
add ebx, tl_data_nodes ;.perv
push dword[edx+TreeNode.perv] ;node[node[i].next].perv=node[i].perv;
pop dword[ebx+TreeNode.perv]
.no_u1:
 
;else if(node[i].td>ch_tim) node[i].td=0; // ¥á«¨ 㤠«¥­¨¥ ᨬ¢®«  ¡ë«® ®â¬¥­¥­®
cmp [edx+TreeNode.t_delete],eax
jle .no_u2
mov dword[edx+TreeNode.t_delete],0
.no_u2:
call tl_move_next
jmp @b
@@:
mov tl_tim_undo,0
pop edx ecx ebx eax
.no_work:
ret
 
;¢ë¢®¤ ᯨ᪠ ­  íªà ­
align 4
proc tl_draw, tlist:dword
pushad
;draw dir_list main rect
mov edi,[tlist]
mov ebx,tl_box_left
shl ebx,16
add ebx,tl_box_width
mov ecx,tl_box_top
shl ecx,16
mov cx,tl_capt_cy
mov edx,tl_col_zag
mcall SF_DRAW_RECT ;draw window caption
 
add ecx,tl_box_top
shl ecx,16
add ecx,tl_box_height
sub cx,tl_capt_cy
mcall ,,,tl_col_bkg ;draw window client rect
 
cmp tl_capt_cy,9 ;9 - minimum caption height
jl @f
mov ebx,edi ;calculate cursor position
mov eax,tl_cur_pos
inc eax
lea edi,[txt_capt_cur.v]
stdcall tl_convert_to_str, 5
 
mov edi,ebx
mov eax,tl_tim_undo
lea edi,[txt_capt_otm.v]
stdcall tl_convert_to_str, 5
mov edi,ebx ;restore edi
 
mov eax,SF_DRAW_TEXT ;captions
mov ebx,tl_box_left
shl ebx,16
add ebx,5*65536+3
add ebx,tl_box_top
mov ecx,tl_col_txt
or ecx,0x80000000
lea edx,[txt_capt_cur]
int 0x40
 
mov ebx,tl_box_left
shl ebx,16
add ebx,100*65536+3
add ebx,tl_box_top
lea edx,[txt_capt_otm]
int 0x40
@@:
 
;cycle to nodes
xor eax,eax
mov edx,tl_data_nodes
mov ecx,edx
add ecx,sizeof.TreeNode
 
;*** ¯à®¯ã᪠㧫®¢, ª®â®àë¥ ¯à®¬®â ­ë áªà®««¨­£®¬ ***
cmp tl_p_scroll,0 ;¥á«¨ ¥áâì 㪠§ â¥«ì ­  áªà®««¨­£
je .end_c1
mov esi,tl_p_scroll
cmp dword[esi+sb_offs_position],0 ;¥á«¨ áªà®««¨­£ ­  ¢¥àåã, ¢ë室¨¬
je .end_c1
@@:
call tl_iterat_next
cmp edx,ecx
jle .end_draw
inc eax
cmp eax,dword[esi+sb_offs_position]
jl @b
.end_c1:
 
xor eax,eax
mov esi,tl_box_top
add esi,tl_box_height ;esi = coord bottom border
@@:
call tl_iterat_next
cmp edx,ecx
jle @f
call tl_draw_node
inc eax
jmp @b
@@:
 
call tl_draw_cursor
 
mov edi,tl_p_scroll ;à¨á㥬 ¤®ç¥à­¨© áªà®««¨­£
cmp edi,0 ;¤«ï ⮣® çâ®-¡ë ¥£® ­¥ ¯à¨è«®áì à¨á®¢ âì ¢ ¯®«ì§®¢ â¥«ì᪮© ¯à®£à ¬¬¥
je .end_draw ;¥á«¨ ­¥â áªà®««¨­£  ¢ë室¨¬
stdcall scroll_bar_vertical.draw, edi
.end_draw:
popad
ret
endp
 
;¯¥à¥å®¤ ­  á«¥¤ã騩 ¢¨¤¨¬ë© 㧥« (¯à®¯ãáª ï § ªàëâë¥)
;input:
; ecx = pointer to 1 node struct
; edx = pointer to node struct
; edi = pointer to 'TreeList' struct
;output:
; edx = pointer to next node struct
align 4
tl_iterat_next:
push bx
mov bl,0x7f
cmp byte[edx+TreeNode.close],1
jne @f
mov bl,byte[edx+TreeNode.level]
@@:
 
cmp tl_tim_undo,0
je .else
 
push eax
.beg0:
call tl_move_next
cmp edx,ecx
jle @f
call tl_node_not_vis ;¯à®¯ã᪠㤠«¥­­ëå ¨ ®â¬¥­¥­­ëå
cmp al,1
je .beg0
cmp bl,byte[edx+TreeNode.level] ;¯à®¯ã᪠§ ªàëâëå
jl .beg0
@@:
pop eax
pop bx
ret
 
.else:
call tl_move_next
cmp edx,ecx
jle .endif
cmp dword[edx+TreeNode.t_delete],0 ;¯à®¯ã᪠㤠«¥­­ëå
jne .else
cmp bl,byte[edx+TreeNode.level] ;¯à®¯ã᪠§ ªàëâëå
jl .else
.endif:
pop bx
ret
 
;¯¥à¥å®¤ ­  á«¥¤ã騩 ¢¨¤¨¬ë© 㧥« (¨ ­  § ªàëâë¥ â®¦¥)
;input:
; ecx = pointer to 1 node struct
; edx = pointer to node struct
; edi = pointer to 'TreeList' struct
;output:
; edx = pointer to next visible node struct
align 4
tl_iterat_next_all:
cmp tl_tim_undo,0
je .else
 
push eax
@@:
call tl_move_next
cmp edx,ecx
jle @f
call tl_node_not_vis
cmp al,1
je @b
@@:
pop eax
ret
.else:
call tl_move_next
cmp edx,ecx
jle .endif
cmp dword[edx+TreeNode.t_delete],0 ;td -> time delete
jne .else
.endif:
ret
 
;¯¥à¥å®¤ ­  ¯à¥¤ë¤ã騩 ¢¨¤¨¬ë© 㧥« (¯à®¯ãáª ï § ªàëâë¥)
;input:
; ecx = pointer to 1 node struct
; edx = pointer to node struct
; edi = pointer to 'TreeList' struct
align 4
proc tl_iterat_perv uses eax
cmp tl_tim_undo,0
je .beg1
 
.beg0:
call tl_move_perv
cmp edx,ecx
jle @f
call tl_node_not_vis ;¯à®¯ã᪠㤠«¥­­ëå ¨ ®â¬¥­¥­­ëå
cmp al,1
je .beg0
 
.beg1:
call tl_move_perv
cmp edx,ecx
jle @f
cmp dword[edx+TreeNode.t_delete],0 ;td = 'time delete' -> ¯à®¯ã᪠㤠«¥­­ëå
jne .beg1
 
@@:
call tl_move_max_clo_par
ret
endp
 
;­ å®¤¨â த¨â¥«ì᪨© § ªàëâë© ã§¥« ¬ ªá¨¬ «ì­®£® ã஢­ï
;input:
; edx = pointer to node struct
; edi = pointer to 'TreeList' struct
;output:
; edx = pointer closed parent node with maximum level
align 4
proc tl_move_max_clo_par uses eax ebx
mov eax,edx
xor ebx,ebx
.beg:
call tl_move_par
cmp byte[edx+TreeNode.close],1 ;த¨â¥«ì᪨© 㧥« § ªàëâ ?
jne @f
mov eax,edx
@@:
cmp ebx,edx
je .end_f
mov ebx,edx
jmp .beg
.end_f:
mov edx,eax
ret
endp
 
;input:
; edx = pointer to node struct
; edi = pointer to 'TreeList' struct
;output:
; edx = pointer to next node struct
align 4
tl_move_next:
mov edx,[edx+TreeNode.next]
imul edx,sizeof.TreeNode
add edx,tl_data_nodes
ret
 
;input:
; edx = pointer to node struct
; edi = pointer to 'TreeList' struct
;output:
; edx = pointer to perv node struct
align 4
tl_move_perv:
mov edx,[edx+TreeNode.perv]
imul edx,sizeof.TreeNode
add edx,tl_data_nodes
ret
 
;¯¥à¥¤¢¨£ ¥¬áï ­  த¨â¥«ì᪨© 㧥«, ¥á«¨ â ª®£® ­¥â, â® ®áâ ¢«ï¥¬ áâ à®¥ §­ ç¥­¨¥ 㪠§ â¥«ï
;input:
; ecx = pointer to 1 node struct
; edx = pointer to node struct
; edi = pointer to 'TreeList' struct
;output:
; edx = pointer to parent node struct
align 4
tl_move_par:
cmp byte[edx+TreeNode.level],0
je .end_f ;㧥« 0-£® ã஢­ï ­¥ ¬®¦¥â ¡ëâì ¤®ç¥à­¨¬
push eax ebx esi
mov esi,edx ;copy node pointer (edx)
mov bl,byte[edx+TreeNode.level]
@@:
call tl_move_perv
cmp edx,ecx
jle @f ;¢á¥ ¢ëè¥ áâ®ï騥 ã§«ë ­¥ த¨â¥«ì᪨¥
call tl_node_not_vis ;¯à®¯ã᪠㤠«¥­­ëå ¨ ®â¬¥­¥­­ëå
cmp al,1
je @b
cmp byte[edx+TreeNode.level],bl
jl .end_0 ;㤠筮 ­ è«¨ த¨â¥«ì᪨© 㧥«
jmp @b
@@:
mov esi,ebx ;restore node pointer
.end_0:
pop esi ebx eax
.end_f:
ret
 
;¯à®¢¥àï¥â ¢¨¤¨¬ë© «¨ 㪠§ ­­ë© 㧥« á ãç¥â®¬: ¤®¡ ¢«¥­¨©, 㤠«¥­¨©, ®â¬¥­ ¤¥©á⢨©
;input:
; edx = pointer to node struct
; edi = pointer to 'TreeList' struct
;output:
; al = 1 if sumbol not visible
; (node[i].td+tim_Undo<=ch_tim && node[i].td) || (node[i].tc>ch_tim-tim_Undo)
align 4
tl_node_not_vis:
cmp dword[edx+TreeNode.t_delete],0
je @f
mov eax,[edx+TreeNode.t_delete] ;eax=node[i].td
add eax,tl_tim_undo
cmp eax,tl_ch_tim
jg @f
mov al,1
ret
@@:
 
mov eax,tl_ch_tim
sub eax,tl_tim_undo
cmp [edx+TreeNode.t_create],eax ;time create
jle @f
mov al,1
ret
@@:
xor al,al
ret
 
;à¨á㥬 ªãàá®à ­  íªà ­¥
;input:
; edi = pointer to TreeInfo struct
; esi = coord bottom border
align 4
proc tl_draw_cursor uses eax ebx ecx edx esi
call tl_get_display_cur_pos ;eax = cursor pos in screen
cmp eax,0
jl .end_f ;ªãàá®à ­ å®¤¨âáï ¢ëè¥ ®ª­ , ¢ ®¡« á⨠¯à®ªàã祭­®© áªà®««¨­£®¬
 
cmp tl_data_img_sys,0 ;ᬮâਬ ¥áâì «¨ 㪠§ â¥«ì ­  ª à⨭ªã á¨á⥬­ëå ¨ª®­®ª
jne @f
mov ebx,tl_box_left
shl ebx,16
mov bx,tl_img_cx
movzx ecx,tl_img_cy
imul ecx,eax
add ecx,tl_box_top
add cx,tl_capt_cy
 
;crop image if on the border
cmp esi,ecx ;¥á«¨ ªãàá®à ¢­¨§ã ¨ ¥£® ¢®®¡é¥ ­¥ ¢¨¤­®
jl .end_f
 
sub esi,ecx
shl ecx,16
mov cx,tl_img_cy
cmp si,tl_img_cy
jge .crop0
mov cx,si ;¥á«¨ ªãàá®à ¢¨¤¥­ ç áâ¨ç­® (¯®¯ « ­  ­¨¦­îî £à ­¨æã)
.crop0:
 
mov edx,tl_col_txt
mcall SF_DRAW_RECT ;à¨á㥬 ¯à®á⮩ ¯àאַ㣮«ì­¨ª, â.ª. ­¥â á¨á⥬­ëå ¨ª®­®ª
jmp .end_f
@@:
mov ebx,tl_data_img_sys
imul ax,tl_img_cy
mov edx,tl_box_left
shl edx,16
mov dx,ax
add edx,tl_box_top
add dx,tl_capt_cy
 
mov ecx,tl_el_focus ;¯à®¢¥à塞 ¢ 䮪ãá¥ í«¥¬¥­â ¨«¨ ­¥â
cmp dword[ecx],edi
je .focus
;¥á«¨ ­¥ ¢ 䮪ãᥠᤢ¨£ ¥¬ ª®®à¤¨­ âë ­  ¨ª®­ªã ­¥  ªâ¨¢­®£® ªãàá®à 
movzx ecx,tl_img_cx
movzx eax,tl_img_cy
imul eax,ecx
imul eax,4*3 ;4=icon index 3=rgb
add ebx,eax
.focus:
 
mov cx,tl_img_cx
shl ecx,16
mov cx,tl_img_cy
 
;crop image if on the border
cmp si,dx ;¥á«¨ ªãàá®à ¢­¨§ã ¨ ¥£® ¢®®¡é¥ ­¥ ¢¨¤­®
jl .end_f
 
sub si,dx
cmp si,tl_img_cy
jge .crop1
mov cx,si ;¥á«¨ ªãàá®à ¢¨¤¥­ ç áâ¨ç­® (¯®¯ « ­  ­¨¦­îî £à ­¨æã)
.crop1:
 
mcall SF_PUT_IMAGE ;à¨á㥬 ¨ª®­ªã ªãàá®à 
.end_f:
ret
endp
 
;áâ¨à ¥¬ ªãàá®à ­  íªà ­¥
;input:
; edi = pointer to TreeInfo struct
; esi = coord bottom border
align 4
proc tl_draw_null_cursor uses eax ebx ecx edx esi
call tl_get_display_cur_pos ;eax = cursor pos in screen
cmp eax,0
jl .end_f ;ªãàá®à ­ å®¤¨âáï ¢ëè¥ ®ª­ , ¢ ®¡« á⨠¯à®ªàã祭­®© áªà®««¨­£®¬
mov ebx,tl_box_left
shl ebx,16
mov bx,tl_img_cx
movzx ecx,tl_img_cy
imul ecx,eax
add ecx,tl_box_top
add cx,tl_capt_cy
 
;crop image if on the border
cmp esi,ecx ;¥á«¨ ªãàá®à ¢­¨§ã ¨ ¥£® ¢®®¡é¥ ­¥ ¢¨¤­®
jl .end_f
 
sub esi,ecx
shl ecx,16
mov cx,tl_img_cy
cmp si,tl_img_cy
jge @f
mov cx,si ;¥á«¨ ªãàá®à ¢¨¤¥­ ç áâ¨ç­® (¯®¯ « ­  ­¨¦­îî £à ­¨æã)
@@:
mcall SF_DRAW_RECT,,,tl_col_bkg ;à¨á㥬 ¯à®á⮩ ¯àאַ㣮«ì­¨ª á ä®­®¢ë¬ 梥⮬
.end_f:
ret
endp
 
;¡¥à¥â ¯®§¨æ¨î ªãàá®à , ®â­®á¨â¥«ì­® íªà ­ 
;input:
; edi = pointer to TreeInfo struct
;output:
; eax = index
align 4
tl_get_display_cur_pos:
mov eax,tl_cur_pos
cmp tl_p_scroll,0
je @f
push ebx
mov ebx,tl_p_scroll
mov ebx,dword[ebx+sb_offs_position]
sub eax,ebx ;®â­¨¬ ¥¬ ¯®§¨æ¨î áªà®««¨­£ 
pop ebx
@@:
ret
 
;à¨áã¥â 㧥« á: ª à⨭ª®©, ¯®¤¯¨áìî, ¨ª®­ª®© ®âªàëâ¨ï/§ ªàëâ¨ï ¨ «¨­¨ï¬¨ ª த¨â. 㧫ã
;input:
; eax = node position (0, ..., max_nodes-scroll_pos) ­¥ ¤® tl_box_height/tl_img_cy
; edx = pointer to node struct
; edi = pointer to 'TreeList' struct
; esi = coord of bottom border
align 4
proc tl_draw_node uses eax ebx ecx edx esi
mov ebx,1 ;1 - ¬¥áâ® ¯®¤ ªãàá®à
bt tl_style,2 ;tl_list_box_mode
jc @f
inc ebx ;+1 - ¬¥áâ® ¯®¤ §­ ª +,-
add bl,byte[edx+TreeNode.level] ;¤®¡ ¢«ï¥¬ ã஢¥­ì í«¥¬¥­â  ¤«ï ¥£® ãç¥â  ¢ «¥¢®¬ ®âáâ㯥 ¨ª®­ª¨
@@:
imul bx,tl_img_cx
add ebx,tl_box_left
 
shl ebx,16
mov bx,tl_img_cx
movzx ecx,tl_img_cy
imul ecx,eax
add cx,tl_capt_cy
jc .end_draw ;ª®£¤  ¬­®£® 㧫®¢, â® ¬®¦¥â ¡ëâì ¯¥à¥¯®«­¥­¨¥ ª®®à¤¨­ âë cx
add ecx,tl_box_top
 
;crop image if on the border
cmp esi,ecx ;¥á«¨ 㧥« ¢­¨§ã ¨ ¥£® ¢®®¡é¥ ­¥ ¢¨¤­®
jl .end_draw
 
sub esi,ecx
shl ecx,16
mov cx,tl_img_cy
cmp si,tl_img_cy
jge @f
mov cx,si ;¥á«¨ 㧥« ¢¨¤¥­ ç áâ¨ç­® (¯®¯ « ­  ­¨¦­îî £à ­¨æã)
jmp .crop ;¯à®¯ã᪠¥¬ à¨á®¢ ­¨¥ ­ ¤¯¨á¨, ª®â®à ï ᪮॥ ¢á¥£® ⮦¥ ¢ë«¥§¥â §  ­¨¦­îî £à ­¨æã
@@:
call tl_draw_node_caption
.crop:
mov esi,ecx ;save ecx
 
push edx
cmp tl_data_img,0
jne .draw_img_n
mcall SF_DRAW_RECT,,,tl_col_txt ;draw node rect
jmp @f
.draw_img_n:
push ebx esi
movzx esi,word[edx+TreeNode.type] ;get icon type
mov edx,ebx
ror ecx,16
mov dx,cx
mov cx,bx
ror ecx,16
mov ebx,3 ;rgb = 3 bytes
imul bx,tl_img_cx
imul bx,tl_img_cy
imul ebx,esi ;esi = icon index
add ebx,tl_data_img
 
mcall SF_PUT_IMAGE ;draw node icon '-'
pop esi ebx
@@:
pop edx
 
mov al,byte[edx+TreeNode.level] ;draw minus '-'
mov ecx,tl_data_nodes
add ecx,sizeof.TreeNode
 
mov ah,10 ;get icon index '+' or '-' ?
cmp byte[edx+TreeNode.close],1
jne .close
dec ah
.close:
 
call tl_draw_node_icon_opn_clo ;à¨á®¢ ­¨¥ ¨ª®­ª¨ ®âªàë⮣® ¨«¨ § ªàë⮣® 㧫 
bt tl_style,1
jae .end_draw
call tl_draw_node_icon_par_lin ;à¨á®¢ ­¨¥ «¨­¨¨ ª த¨â¥«ì᪮¬ã í«¥¬¥­âã
call tl_draw_node_icon_par_lin_up ;à¨á®¢ ­¨¥ ¢¥à⨪ «ì­®© «¨­¨¨ ª த¨â¥«ì᪮¬ã í«¥¬¥­âã
.end_draw:
ret
endp
 
;à¨áã¥â ¨ª®­ª¨ ®âªàë⮣® ¨«¨ § ªàë⮣® 㧫  (®¡ëç­® + ¨«¨ -)
;input:
; al = ã஢¥­ì í«¥¬¥­â 
; ecx = pointer to 1 node struct
; edx = pointer to node struct
;...
align 4
proc tl_draw_node_icon_opn_clo uses eax ebx ecx edx esi
inc al
call tl_iterat_next_all ;get next visible item
cmp edx,ecx
jle @f
mov ecx,esi ;load ecx
cmp al,byte[edx+TreeNode.level]
jne @f
ror ebx,16
sub bx,tl_img_cx
ror ebx,16
cmp tl_data_img_sys,0
jne .draw_img_s
mcall SF_DRAW_RECT,,,tl_col_txt ;draw minus rect, if not system icons
jmp @f
.draw_img_s:
mov ecx,esi ;load ecx
mov edx,ebx
ror ecx,16
mov dx,cx
mov cx,bx
ror ecx,16
mov ebx,3 ;rgb = 3 bytes
imul bx,tl_img_cx
imul bx,tl_img_cy
shr eax,8
and eax,0xff
imul ebx,eax ;eax = icon index
add ebx,tl_data_img_sys
mcall SF_PUT_IMAGE ;draw minus icon '-'
@@:
ret
endp
 
;à¨á®¢ ­¨¥ «¨­¨¨ ª த¨â¥«ì᪮¬ã í«¥¬¥­âã
;input:
; al = ã஢¥­ì í«¥¬¥­â 
; ecx = pointer to 1 node struct
; edx = pointer to node struct
;...
align 4
tl_draw_node_icon_par_lin:
cmp byte[edx+TreeNode.close],1
je .close
or al,al
jz .close
push eax ebx ecx edx esi
call tl_iterat_next_all ;get next visible item
cmp edx,ecx
jle .line3 ;if end of list
cmp al,byte[edx+TreeNode.level]
jne .line3 ;jg ???
mov eax,3 ;line in middle element
jmp .line2
.line3:
mov eax,6 ;line in end element
.line2:
 
mov ecx,esi ;load ecx
ror ebx,16
sub bx,tl_img_cx
ror ebx,16
cmp tl_data_img_sys,0
jne .draw_img_s
mcall SF_DRAW_RECT,,,tl_col_txt ;draw minus rect, if not system icons
jmp @f
.draw_img_s:
mov edx,ebx
ror ecx,16
mov dx,cx
mov cx,bx
ror ecx,16
mov ebx,3 ;rgb = 3 bytes
imul bx,tl_img_cx
imul bx,tl_img_cy
 
imul ebx,eax ;eax = icon index
add ebx,tl_data_img_sys
mcall SF_PUT_IMAGE ;draw line icon
@@:
pop esi edx ecx ebx eax
.close:
ret
 
 
;input:
; al = ã஢¥­ì í«¥¬¥­â 
; ebx = (node.left shl 16) + tl_img_cx
; ecx = pointer to 1 node struct
; edx = pointer to node struct
; edi = pointer to 'TreeList' struct
align 4
proc tl_draw_node_icon_par_lin_up uses eax ebx ecx edx esi
cmp tl_data_img_sys,0 ;if not image
je @f
or al,al
jz @f
xor esi,esi ;¢ si ¡ã¤¥¬ ­ áç¨â뢠âì ª®«-¢® ¨ª®­®ª, ­ã¦­ëå ¤«ï ¯à®à¨á®¢ª¨ «¨­¨¨
;--- 横« ¤«ï ¢ëç¨á«¥­¨ï ª®««¨ç¥á⢠ ¢¥à⨪ «ì­ëå «¨­¨© ---
.cycle0:
call tl_iterat_perv ;get perv visible item
cmp edx,ecx
jle .cycle1 ;if begin of list
 
cmp byte[edx+TreeNode.level],al
jle .cycle0end ;ã஢¥­ì ¢¥àå­¥£® í«¥¬¥­â  ­¥ âॡã¥â ¯à®à¨á®¢ª¨
inc si
jmp .cycle0
.cycle0end:
or si,si ;si = ª®«-¢® ¨ª®­®ª «¨­¨¨ ª®â®àë¥ ­ã¦­® ­ à¨á®¢ âì ᢥàåã
jz @f
shl esi,16
 
pop ecx ;esi->ecx
push ecx ;save esi
 
ror ebx,16
sub bx,tl_img_cx
ror ebx,16
 
mov edx,ebx
ror ecx,16
mov dx,cx
mov cx,bx
ror ecx,16
mov cx,tl_img_cy ;restore size y (if crop)
mov ebx,3 ;rgb = 3 bytes
imul bx,tl_img_cx
imul bx,tl_img_cy
add ebx,tl_data_img_sys
 
add esi,tl_box_top
add si,tl_capt_cy ;si = ¢¥àå­ïï £à ­¨æ  ®ª­ 
mov eax,SF_PUT_IMAGE
;--- 横« ¤«ï à¨á®¢ ­¨ï ¢¥à⨪ «ì­®© «¨­¨¨ ---
.cycle1:
sub dx,tl_img_cy ;¯®¤­¨¬ ¥¬ ª®®à¤¨­ âã y ¢¢¥àå
cmp dx,si
jl @f
cmp esi,0x10000
jl @f
int 0x40 ;draw line icon
sub esi,0x10000 ;㬥­ìè ¥¬ áç¥â稪 ¨ª®­®ª
jmp .cycle1
@@:
ret
endp
 
;input:
; edi = pointer to TreeInfo struct
;output:
; eax = rows
align 4
tl_get_rows_count:
push ecx edx
mov eax,tl_box_height
sub ax,tl_capt_cy
movzx ecx,tl_img_cy
xor edx,edx
div ecx
pop edx ecx
ret
 
;input:
; eax = node position
; ebx = [ª®®à¤¨­ â  ¯® ®á¨ x]*65536 + [img_cx]
; ecx = [ª®®à¤¨­ â  ¯® ®á¨ y]*65536 + [img_cy]
; edx = pointer to node struct
; edi = pointer to TreeInfo struct
align 4
proc tl_draw_node_caption uses ebx ecx edx esi
xor esi,esi
mov si,tl_info_size
cmp si,tl_info_capt_offs
jle @f ;if caption size <= 0
push eax
call tl_get_node_index ;eax = node index
imul esi,eax
pop eax
add si,tl_info_capt_offs
add esi,tl_data_info
mov edx,esi
 
shr ebx,16
add bx,tl_img_cx ;ᤢ¨£ ¥¬ ­ ¤¯¨áì ¯® £®à¨§®­â «¨ --->
add bx,3 ;®âáâã¯
;bx = coord.x
call tl_strlen ;eax = strlen
call tl_get_draw_text_len
mov cx,bx
ror ecx,16
mov ebx,ecx
add bx,tl_img_cy ;¢ëà ¢­¨¢¨­¨¥ ¯® ­¨¦­¥© £à ­¨æ¥ ¨ª®­ª¨
sub bx,9 ;®â­¨¬ ¥¬ ¢ëá®âã ⥪áâ 
mov ecx,tl_col_txt
and ecx,0xffffff
mcall SF_DRAW_TEXT
@@:
ret
endp
 
;input:
; eax = strlen
; ebx = text coord x
;output:
; esi = text len
align 4
proc tl_get_draw_text_len uses eax ecx edx
mov esi,eax ;¡¥à¥¬ ¤«¨­­ã áâப¨
mov eax,tl_box_left
add eax,tl_box_width
cmp eax,ebx
jle .text_null ;¥á«¨ ¯®¤¯¨áì ¯®«­®áâìî ¢áï §  íªà ­®¬
sub eax,ebx
xor edx,edx
mov ecx,6 ;è¨à¨­  á¨á⥬­®£® èà¨äâ 
div ecx ;ᬮâਬ ᪮«ìª® ᨬ¢®«®¢ ¬®¦¥â ¯®¬¥áâ¨âìáï ­  íªà ­¥
cmp esi,eax
jl @f
mov esi,eax ;¥á«¨ ¤«¨­­  ⥪áâ  ¬¥­ìè¥, 祬 ¢á¥ ¬¥áâ® ¯®¤ áâபã
jmp @f
.text_null:
xor esi,esi
@@:
ret
endp
 
;input:
; esi = pointer to string
;output:
; eax = strlen
align 4
tl_strlen:
mov eax,esi
@@:
cmp byte[eax],0
je @f
inc eax
jmp @b
@@:
sub eax,esi
ret
 
;¤®¡ ¢¨âì 㧥«
;input:
; tlist - 㪠§ â¥«ì ­  áâàãªâãàã «¨áâ 
; n_opt - ®¯æ¨¨ ¤®¡ ¢«¥­¨ï
; n_info - 㪠§ â¥«ì ­  ¤®¡ ¢«ï¥¬ë¥ ¤ ­­ë¥
align 4
proc tl_node_add uses eax ebx ecx edx edi, tlist:dword, n_opt:dword, n_info:dword
mov edi,[tlist]
 
call tl_info_set_undo
 
mov ebx,sizeof.TreeNode
imul ebx,tl_info_max_count
add ebx,tl_data_nodes
;--
call tl_get_cur_node_index ;eax=po_t
imul eax,sizeof.TreeNode
add eax,tl_data_nodes
mov edx,eax
call tl_move_perv
call tl_get_node_index ;eax = index of pointer [edx]
;--
mov edx,sizeof.TreeNode
shl edx,1
add edx,tl_data_nodes
@@: ;for(i=2;i<nodeMax;i++)
cmp dword[edx+TreeNode.t_create],0
jne .u0
cmp dword[edx+TreeNode.t_delete],0
jne .u0
 
inc tl_ch_tim
mov ecx,dword[n_opt]
ror ecx,16 ;cx = type
mov word[edx+TreeNode.type],cx
rol ecx,8 ;cl = close|open
mov byte[edx+TreeNode.close],cl ;node[i].clo
mov byte[edx+TreeNode.level],0 ;node[i].lev=0
bt tl_style,2 ;tl_list_box_mode
jc .l_box_m
mov cl,byte[n_opt]
mov byte[edx+TreeNode.level],cl ;node[i].lev
.l_box_m:
push tl_ch_tim ;node[i].tc=ch_tim;
pop dword[edx+TreeNode.t_create]
mov [edx+TreeNode.perv],eax ;node[i].perv=po_t;
;*** copy node data ***
push esi
xor ecx,ecx
mov cx,tl_info_size
mov esi,ecx
 
push eax
call tl_get_node_index ;eax = node index
imul esi,eax
pop eax
add esi,tl_data_info
mov edi,dword[n_info] ;pointer to node data
xchg edi,esi
rep movsb
 
mov esi,edi
mov edi,[tlist] ;restore edi
mov cx,tl_info_capt_offs
cmp cx,tl_info_size
jge .no_text_data
cmp tl_info_capt_len,0 ;¯à®¢¥à塞 ¥áâì «¨ ®£à ­¨ç¥­¨¥ ­  ¤«¨­­ã áâப¨
je .no_len_ogran
add cx,tl_info_capt_len
and ecx,0xffff
add esi,ecx
mov cx,tl_info_size
sub esi,ecx
.no_len_ogran:
dec esi
mov byte[esi],0
.no_text_data:
pop esi ;restore esi
 
mov ecx,eax
imul ecx,sizeof.TreeNode
add ecx,tl_data_nodes ; *** ecx = node[po_t] ***
add ecx,TreeNode.next ; *** ecx = node[po_t].next ***
push dword[ecx] ;node[i].next=node[po_t].next;
pop dword[edx+TreeNode.next]
 
call tl_get_node_index ;*** eax = i ***
cmp eax,tl_info_max_count
jge .u0
mov [ecx],eax ;node[po_t].next=i; // áá뫪¨ ¯¥à¥­ ¯à ¢«ï¥¬
mov ecx,[edx+TreeNode.next] ; *** ecx = node[i].next ***
imul ecx,sizeof.TreeNode
add ecx,tl_data_nodes ; *** ecx = node[node[i].next] ***
mov [ecx+TreeNode.perv],eax ;node[node[i].next].perv=i;
 
call tb_scrol_resize ;®¡à ¡®âª  áªà®««¨­£ 
jmp @f
.u0:
add edx,sizeof.TreeNode
cmp edx,ebx ;enf of node memory ?
jle @b
@@:
ret
endp
 
;input:
; edi = pointer to TreeInfo struct
align 4
proc tb_scrol_resize uses eax ecx edx
cmp tl_p_scroll,0 ;®¡à ¡®âª  áªà®««¨­£ 
je @f
call tl_get_node_count ;eax = node count
mov ecx,eax
call tl_get_rows_count
cmp ecx,eax
jg .ye_sb
xor ecx,ecx
.ye_sb:
mov edx,tl_p_scroll
mov dword[edx+sb_offs_cur_area],eax
mov dword[edx+sb_offs_max_area],ecx
stdcall scroll_bar_vertical.draw,edx
@@:
ret
endp
 
;input:
;n_info - pointer to node info
align 4
proc tl_node_set_data uses eax ecx edx edi esi, tlist:dword, n_info:dword
mov edi,[tlist]
call tl_get_cur_node_index ;eax=po_t
cmp eax,2
jl @f
xor ecx,ecx
mov cx,tl_info_size
imul eax,ecx
add eax,tl_data_info
mov edi,eax
mov esi,dword[n_info] ;pointer to node data
rep movsb
 
mov esi,edi
mov edi,[tlist] ;restore edi
mov cx,tl_info_capt_offs
cmp cx,tl_info_size
jge .no_text_data
mov ax,tl_info_capt_len ;¯à®¢¥à塞 ¥áâì «¨ ®£à ­¨ç¥­¨¥ ­  ¤«¨­­ã ⥪áâ 
or ax,ax
jz .no_limit
add cx,ax ;cx = tl_info_capt_offs + tl_info_capt_len
and ecx,0xffff
xor eax,eax
mov ax,tl_info_size
cmp eax,ecx
jl .no_limit ;¯®«ì§®¢ â¥«ì § ¤ « ᫨誮¬ ¡®«ìèãî ¤«¨­­ã ⥪áâ 
add esi,ecx
sub esi,eax
.no_limit:
dec esi
mov byte[esi],0 ;®¡­ã«ï¥¬ ¯®á«¥¤­¨© ᨬ¢®« ¯®¤¯¨á¨, çâ®-¡ë ­¥ £«î稫® ¥á«¨ ¯®«ì§®¢ â¥«ì § ¤ « ­¥¯à ¢¨«ì­ãî áâàãªâãàã
.no_text_data:
@@:
ret
endp
 
;¢§ïâì 㪠§ â¥«ì ­  ¤ ­­ë¥ 㧫  ¯®¤ ªãàá®à®¬
;input:
; tlist - pointer to 'TreeList' struct
;output:
; eax - pointer to node data
align 4
proc tl_node_get_data uses ecx edi, tlist:dword
mov edi,[tlist]
call tl_get_cur_node_index ;eax=po_t
cmp eax,2
jl @f
movzx ecx,tl_info_size
imul eax,ecx
add eax,tl_data_info
jmp .end_f ;return node data pointer
@@:
xor eax,eax
.end_f:
ret
endp
 
;¢§ïâì 㪠§ â¥«ì ­  áâàãªâãàã 㧫  ¢ 㪠§ ­­®© ¯®§¨æ¨¨
;input:
; tlist - pointer to 'TreeList' struct
; node_ind - node index
;output:
; eax - pointer to node info
align 4
proc tl_node_poi_get_info uses ebx ecx edx edi, tlist:dword, node_ind:dword
mov edi,[tlist]
mov ebx,dword[node_ind]
 
;cycle to nodes
mov edx,tl_data_nodes
mov ecx,edx
add ecx,sizeof.TreeNode
@@:
call tl_iterat_next_all
cmp edx,ecx
jle @f
dec ebx
cmp ebx,0
jg @b
jmp .find
@@:
xor edx,edx
.find:
mov eax,edx
ret
endp
 
;¢§ïâì 㪠§ â¥«ì ­  á«¥¤ãéãî áâàãªâãàã 㧫 
;input:
; tlist - pointer to 'TreeList' struct
; node_p - node param struct
;output:
; eax - pointer to next node struct
align 4
proc tl_node_poi_get_next_info uses ecx edx edi, tlist:dword, node_p:dword
mov edi,[tlist]
mov edx,dword[node_p]
 
mov ecx,tl_data_nodes
add ecx,sizeof.TreeNode
 
call tl_iterat_next_all
cmp edx,ecx
jg @f
xor edx,edx
@@:
mov eax,edx
ret
endp
 
;¢§ïâì 㪠§ â¥«ì ­  ¤ ­­ë¥ 㧫 
;input:
; tlist - pointer to 'TreeList' struct
; node_p - node param struct
;output:
; eax - pointer
align 4
proc tl_node_poi_get_data uses ecx edx edi, tlist:dword, node_p:dword
mov edi,[tlist]
mov edx,dword[node_p]
 
call tl_get_node_index ;eax = node index
cmp eax,2
jl @f
xor ecx,ecx
mov cx,tl_info_size
imul eax,ecx
add eax,tl_data_info
jmp .end_f ;return node data pointer
@@:
xor eax,eax ;¢®§¢à é ¥¬ 0 ¢ á«ãç ¥ ­¥ 㤠筮£® ¯®¨áª 
.end_f:
ret
endp
 
;¡¥à¥â ¯®§¨æ¨î ¯®¤ ªãàá®à®¬
;input:
; edi = pointer 'tl' struct
;output:
; eax = index of current node
align 4
proc tl_get_cur_node_index uses ecx edx
;cycle to nodes
xor eax,eax
mov edx,tl_data_nodes
mov ecx,edx
add ecx,sizeof.TreeNode
@@:
call tl_iterat_next
cmp edx,ecx
jle @f
cmp eax,tl_cur_pos
je @f
inc eax
jmp @b
@@:
mov eax,edx
sub eax,tl_data_nodes
xor edx,edx
mov ecx,sizeof.TreeNode
div ecx
ret
endp
 
;¡¥à¥â ¯®§¨æ¨î 㪠§ ­­®£® ᨬ¢®« 
;input:
; edx = pointer node memory
; edi = pointer 'tl' struct
;output:
; eax = struct index of current node
align 4
tl_get_node_index:
push ecx edx
mov eax,edx
sub eax,tl_data_nodes
xor edx,edx
mov ecx,sizeof.TreeNode
div ecx
pop edx ecx
ret
 
;㤠«¨âì 㧥«
align 4
proc tl_node_delete uses eax edx edi, tlist:dword
mov edi,[tlist]
call tl_get_cur_node_index ;eax=po_t
cmp eax,2
jl @f
imul eax,sizeof.TreeNode
add eax,tl_data_nodes
mov edx,eax
inc tl_ch_tim
mov eax,tl_ch_tim
mov dword[edx+TreeNode.t_delete],eax
call tb_scrol_resize ;®¡à ¡®âª  áªà®««¨­£ 
@@:
ret
endp
 
;¯®áâ ¢¨âì ªãàá®à ­  ¯¥à¢ë© 㧥«
align 4
proc tl_cur_beg uses edi, tlist:dword
mov edi,[tlist]
mov tl_cur_pos,0
cmp tl_p_scroll,0
je @f
mov edi,tl_p_scroll
mov dword[edi+sb_offs_position],0
stdcall scroll_bar_vertical.draw, edi
@@:
ret
endp
 
;¯¥à¥­¥á⨠ªãàá®à ­  1 ¯®§¨æ¨î ­¨¦¥
align 4
proc tl_cur_next uses eax ebx edi esi, tlist:dword
mov edi,[tlist]
call tl_get_node_count ;eax = node count
cmp tl_cur_pos,eax
jge .no_redraw
mov esi,tl_box_top
add esi,tl_box_height ;esi = coord bottom border
call tl_draw_null_cursor ;áâ¨à ¥¬ ªãàá®à
inc tl_cur_pos
 
cmp tl_p_scroll,0 ;if not scrol struct
je @f
call tl_get_rows_count ;eax = rows count
mov ebx,tl_p_scroll
add eax,dword[ebx+sb_offs_position]
cmp tl_cur_pos,eax
jl @f
inc dword[ebx+sb_offs_position]
stdcall scroll_bar_vertical.draw,ebx
stdcall tl_draw,dword[tlist] ;¯®«­ ï ¯¥à¥à¨á®¢ª  ®ª­ 
jmp .no_redraw
@@:
mov edi,[tlist] ;restore edi
call tl_draw_cursor ;¯¥à¥à¨á®¢ª  ªãàá®à 
call tl_draw_caption_cur_pos
.no_redraw:
ret
endp
 
;¡¥à¥â ç¨á«® ¢á¥å ¢¨¤¨¬ëå 㧫®¢ (­¥ áç¨â ï § ªàëâëå ¤®ç¥à­¨å)
;input:
; edi = pointer 'tl' struct
;output:
; eax = struct index of current node
align 4
tl_get_node_count:
push ecx edx
;cycle to nodes
xor eax,eax
mov edx,tl_data_nodes
mov ecx,edx
add ecx,sizeof.TreeNode
@@:
call tl_iterat_next
cmp edx,ecx
jle @f
inc eax
jmp @b
@@:
pop edx ecx
ret
 
;¡¥à¥â ç¨á«® ¢á¥å ¢¨¤¨¬ëå 㧫®¢ (áç¨â ï § ªàëâë¥ ¤®ç¥à­¨¥)
;input:
; edi = pointer 'tl' struct
;output:
; eax = struct index of current node
align 4
tl_get_node_count_all:
push ecx edx
;cycle to nodes
xor eax,eax
mov edx,tl_data_nodes
mov ecx,edx
add ecx,sizeof.TreeNode
@@:
call tl_iterat_next_all
cmp edx,ecx
jle @f
inc eax
jmp @b
@@:
pop edx ecx
ret
 
;¯¥à¥­¥á⨠ªãàá®à ­  1 ¯®§¨æ¨î ¢ëè¥
align 4
proc tl_cur_perv uses eax edi esi, tlist:dword
mov edi,[tlist]
cmp tl_cur_pos,0
je .no_redraw
mov esi,tl_box_top
add esi,tl_box_height ;esi = coord bottom border
call tl_draw_null_cursor ;áâ¨à ¥¬ ªãàá®à
dec tl_cur_pos ;¤¢¨£ ¥¬ ªãàá®à ¢¢¥àå
 
cmp tl_p_scroll,0 ;¥á«¨ ¥áâì 㪠§ â¥«ì ­  áªà®««¨­£
je @f
mov eax,tl_p_scroll
cmp dword[eax+sb_offs_position],0 ;¥á«¨ áªà®««¨­£ ­  ¢¥àåã, ¢ë室¨¬
je @f
mov edi,tl_cur_pos
cmp edi,dword[eax+sb_offs_position] ;¥á«¨ ªãàá®à ã襫 ¢ëè¥ áªà®««¨­£ , ⮣¤  ®¯ã᪠¥¬ áªà®««¨­£
jge @f
dec dword[eax+sb_offs_position]
stdcall scroll_bar_vertical.draw, eax
stdcall tl_draw, dword[tlist] ;¯®«­ ï ¯¥à¥à¨á®¢ª  ®ª­ 
jmp .no_redraw
@@:
mov edi,[tlist] ;restore edi
call tl_draw_cursor ;¯¥à¥à¨á®¢ª  ªãàá®à 
call tl_draw_caption_cur_pos
.no_redraw:
ret
endp
 
;¯¥à¥­¥á⨠ªãàá®à ­  1 áâà ­¨æã ¢ëè¥
align 4
proc tl_cur_page_up uses eax edi esi, tlist:dword
mov edi,[tlist]
 
cmp tl_p_scroll,0 ;¥á«¨ ¥áâì 㪠§ â¥«ì ­  áªà®««¨­£
je .no_redraw
mov esi,tl_p_scroll
call tl_get_rows_count ;eax = rows count
 
cmp tl_cur_pos,0
jne @f
cmp dword[esi+sb_offs_position],0 ;¥á«¨ áªà®««¨­£ ­  ¢¥àåã, ¢ë室¨¬
jne @f
jmp .no_redraw
@@:
cmp tl_cur_pos,eax ;¯à®¢¥à塞 ¯®§¨æ¨î ªãàá®à  ¨ ª®«-¢® á⮪ ­  áâà ­¨æ¥
jl @f ;¥á«¨ ¬¥­ìè¥, â® ¯à¨à ¢­¨¢ ¥¬ ª 0, çâ®-¡ë ­¥ ®â­ïâì ¡®«ìè¥ ç¥¬ ­ ¤®
sub tl_cur_pos,eax
jmp .cursor
@@:
mov tl_cur_pos,0
.cursor:
cmp dword[esi+sb_offs_position],eax
jl @f
sub dword[esi+sb_offs_position],eax
jmp .scroll
@@:
mov dword[esi+sb_offs_position],0
.scroll:
;¯¥à¥à¨á®¢ª¨ ®ª­  ¨ áªà®««¨­£ 
stdcall tl_draw, edi ;draw window
stdcall scroll_bar_vertical.draw, esi
.no_redraw:
ret
endp
 
;¯¥à¥­¥á⨠ªãàá®à ­  1 áâà ­¨æã ­¨¦¥
align 4
proc tl_cur_page_down uses eax ebx ecx edi esi, tlist:dword
;eax - ª®«-¢® áâப ­  áâà ­¨æ¥
;ebx - ¬ ªá. ¯®§¨æ¨ï ªãàá®à 
;ecx - ¬ ªá. ¯®§¨æ¨ï áªà®««¨­£ 
mov edi,[tlist]
cmp tl_p_scroll,0 ;¥á«¨ ¥áâì 㪠§ â¥«ì ­  áªà®««¨­£
je .no_redraw
mov esi,tl_p_scroll
call tl_get_node_count ;eax = node count
mov ebx,eax
call tl_get_rows_count ;eax = rows count
 
mov ecx,ebx
inc ecx ;¥á«¨ ­¨¦­¨© 㧥« ¢¨¤¥­ ­  ¯®«®¢¨­ã
cmp ecx,eax ;if (ecx>eax) { ecx=ecx-eax } else { ecx=0 }
jl @f
sub ecx,eax ;㬥­ìè ¥¬ ¬ ªá¨¬ «ì­ãî ¯®§¨æ¨î áªà®««¨­£ , â ª çâ®-¡ë ¡ë«¨ ¢¨¤­ë ¯®á«¥¤­¨¥ 㧫ë
jmp .control
@@:
xor ecx,ecx ;ecx=0 - ¢á¥ ã§«ë ¢« §ïâ ¢ íªà ­, áªà®««¨­£ ­¥ ­ã¦¥­
.control:
 
cmp tl_cur_pos,ebx ;ªãàá®à ¢­¨§ã ?
jl @f
cmp dword[esi+sb_offs_position],ecx ;áªà®««¨­£ ¢­¨§ã ?
jl @f
jmp .no_redraw
@@:
add tl_cur_pos,eax ;¯¥à¥¬¥é ¥¬ ªãàá®à
cmp tl_cur_pos,ebx
jl @f
mov tl_cur_pos,ebx
@@:
add dword[esi+sb_offs_position],eax ;¯¥à¥¬¥é ¥¬ áªà®««¨­£
cmp dword[esi+sb_offs_position],ecx
jl @f
mov dword[esi+sb_offs_position],ecx
@@:
 
;¯¥à¥à¨á®¢ª¨ ®ª­  ¨ áªà®««¨­£ 
stdcall tl_draw, edi ;draw window
stdcall scroll_bar_vertical.draw, esi
.no_redraw:
ret
endp
 
;®âªàëâì/§ ªàëâì 㧥« (à ¡®â ¥â á 㧫 ¬¨ ª®â®àë¥ ¨¬¥îâ ¤®ç¥à­¨¥ 㧫ë)
align 4
proc tl_node_close_open uses eax edx edi, tlist:dword
mov edi,[tlist]
call tl_get_cur_node_index ;eax = ¯®§¨æ¨ï 㧫  ­  ª®â®à®¬ á⮨⠪ãàá®à
cmp eax,2 ;ªãàá®à á⮨⠭  㧫¥ ?
jl @f
imul eax,sizeof.TreeNode
add eax,tl_data_nodes
;eax = 㪠§ â¥«ì ­  áâàãªâãàã 㧫  ¢ë¡à ­­®£® ªãàá®à®¬
push eax
stdcall tl_node_poi_get_next_info, edi,eax
mov edx,eax ;edx = 㪠§ â¥«ì ­  áâàãªâãàã 㧫  ª®â®àë© ¨¤¥â ¯®á«¥ 㧫  eax
pop eax
or edx,edx ;¥áâì «¨ ã§«ë ­¨¦¥ ¢ë¡à ­­®£® ­ ¬¨ ?
jz @f
mov dl,byte[edx+TreeNode.level] ;¡¥à¥¬ ã஢¥­ì ­¨¦­¥£® 㧫 
cmp byte[eax+TreeNode.level],dl
jge @f ;¥á«¨ ­¨¦­¨¥ ã§«ë ¬¥­ì襣® ã஢­ï, §­ ç¨â ®­¨ ­¥ ¤®ç¥à­¨¥, ª®­¥æ ä㭪樨
xor byte[eax+TreeNode.close],1 ;*** ®âªàë⨥/§ ªàë⨥ 㧫  ***
call tb_scrol_resize ;®¡à ¡®âª  áªà®««¨­£ 
 
stdcall tl_draw, edi ;®¡­®¢«¥­¨¥ ®ª­ 
@@:
ret
endp
 
;㢥«¨ç¨âì ã஢¥­ì
align 4
proc tl_node_lev_inc uses eax ecx edx edi, tlist:dword
mov edi,[tlist]
bt tl_style,2 ;tl_list_box_mode
jc @f
call tl_get_cur_node_index ;eax=po_t
cmp eax,2
jl @f
mov ecx,tl_data_nodes
imul eax,sizeof.TreeNode
add eax,ecx ;eax = pointer to node struct
add ecx,sizeof.TreeNode ;ecx = pointer to 1 node struct
 
mov edx,eax
call tl_iterat_perv ;¯à®¢¥à塞 ¥áâì «¨ ¢¥àå­¨© 㧥«
cmp edx,ecx
jle @f ;¥á«¨ ¢¥àå­¥£® 㧫  ­¥â ⮠⥪ã騩 㧥« ­¥ ¤¢¨£ ¥¬
mov cl,byte[edx+TreeNode.level] ;¡¥à¥¬ ã஢¥­ì த¨â¥«ì᪮£® 㧫 
inc cl ;¤®¡ ¢«ï¥¬ 1 ¨ ¯®«ãç ¥¬ ¬ ªá¨¬ «ì­®¥ §­ ç¥­¨¥
cmp byte[eax+TreeNode.level],cl
jge @f
inc byte[eax+TreeNode.level] ;㢥«¨ç¨¢ ¥¬ §­ ç¥­¨¥ 㧫 
@@:
ret
endp
 
;㬥­ìè¨âì ã஢¥­ì
align 4
proc tl_node_lev_dec uses eax edi, tlist:dword
mov edi,[tlist]
call tl_get_cur_node_index ;eax=po_t
cmp eax,2
jl @f
imul eax,sizeof.TreeNode
add eax,tl_data_nodes
cmp byte[eax+2],0
je @f
dec byte[eax+2]
@@:
ret
endp
 
;¯¥à¥¬¥é ¥¬ 㧥« ¢¢¥àå
align 4
proc tl_node_move_up tlist:dword
pushad
mov edi,[tlist]
call tl_get_cur_node_index ;eax=po_t
cmp eax,2
jl @f
mov ebx,eax ;copy index of node struct
mov edx,tl_data_nodes
mov ecx,edx
add ecx,sizeof.TreeNode
imul eax,sizeof.TreeNode
add eax,edx ;eax = pointer to 2 node struct
mov edx,eax ;edx = pointer to 2 node struct
mov esi,eax ;esi = pointer to 2 node struct
call tl_iterat_perv ;edx = pointer to 1 node struct
call tl_get_node_index ;eax = index of 1 node struct
cmp edx,ecx
jle @f
cmp dword[edx+TreeNode.next],ebx
jne .po8
call tl_node_move_po6 ;ã§«ë ¨¤ãâ ¯®¤àï¤ ¬¥­ï¥¬ 6 ááë«®ª
jmp .cur_mov
.po8:
call tl_node_move_po8 ;ã§«ë ¨¤ãâ ­¥ ¯®¤àï¤ ¬¥­ï¥¬ 8 ááë«®ª
.cur_mov:
push dword edi
call tl_cur_perv
push dword edi
call tl_draw
@@:
popad
ret
endp
 
;¯¥à¥¬¥é ¥¬ 㧥« ¢­¨§
align 4
proc tl_node_move_down tlist:dword
pushad
mov edi,[tlist]
call tl_get_cur_node_index ;eax=po_t
cmp eax,2
jl @f
mov ebx,eax ;copy index of node struct
mov edx,tl_data_nodes
mov ecx,edx
add ecx,sizeof.TreeNode
imul eax,sizeof.TreeNode
add eax,edx ;eax = pointer to 1 node struct
mov edx,eax ;edx = pointer to 1 node struct
mov esi,eax ;esi = pointer to 1 node struct
call tl_iterat_next ;edx = pointer to 2 node struct
call tl_get_node_index ;eax = index of 2 node struct
cmp edx,ecx
jle @f
cmp dword[esi+TreeNode.next],eax
jne .po8
xchg eax,ebx ;¬¥­ï¥ ¯®à冷ª á«¥¤®¢ ­¨ï § ¬¥­ï¥¬ëå 㧫®¢
xchg edx,esi
call tl_node_move_po6 ;ã§«ë ¨¤ãâ ¯®¤àï¤ ¬¥­ï¥¬ 6 ááë«®ª
jmp .cur_mov
.po8: ;  âãâ ¯®à冷ª á«¥¤®¢ ­¨ï 㧫®¢ ­¥ ¬¥­ï¥¬
call tl_node_move_po8 ;ã§«ë ¨¤ãâ ­¥ ¯®¤àï¤ ¬¥­ï¥¬ 8 ááë«®ª
.cur_mov:
stdcall tl_cur_next, edi
stdcall tl_draw, edi
@@:
ret
popad
endp
 
align 4
tl_node_move_po6:
mov ecx,edx ;save node pointer
call tl_move_perv
mov dword[edx+TreeNode.next],ebx
 
mov edx,esi
call tl_move_next
mov dword[edx+TreeNode.perv],eax
mov edx,ecx ;restore node pointer
 
mov ecx,dword[edx+TreeNode.perv]
mov dword[esi+TreeNode.perv],ecx
mov ecx,dword[esi+TreeNode.next]
mov dword[edx+TreeNode.next],ecx
 
mov dword[edx+TreeNode.perv],ebx
mov dword[esi+TreeNode.next],eax
ret
 
;input
;eax = index 1 node struct
;ebx = index 2 node struct
;edx = pointer 1 node struct
;esi = pointer 2 node struct
;edi = pointer to 'TreeList' struct
;output:
;eax = ?
;ebx = ?
;ecx = ?
align 4
tl_node_move_po8:
mov ecx,edx ;save node pointer
call tl_move_perv
mov dword[edx+TreeNode.next],ebx
mov edx,ecx
call tl_move_next
mov dword[edx+TreeNode.perv],ebx
mov edx,esi
call tl_move_perv
mov dword[edx+TreeNode.next],eax
mov edx,esi
call tl_move_next
mov dword[edx+TreeNode.perv],eax
mov edx,ecx ;restore node pointer
 
mov eax,dword[edx+TreeNode.perv]
mov ebx,dword[esi+TreeNode.perv]
xchg eax,ebx
mov dword[edx+TreeNode.perv],eax
mov dword[esi+TreeNode.perv],ebx
 
mov eax,dword[edx+TreeNode.next]
mov ebx,dword[esi+TreeNode.next]
xchg eax,ebx
mov dword[edx+TreeNode.next],eax
mov dword[esi+TreeNode.next],ebx
ret
 
;input:
; edi = pointer to 'TreeList' struct
align 4
tl_draw_caption_cur_pos:
cmp tl_capt_cy,9 ;9 - minimum caption height
jl @f
pushad
mov ebx,edi ;calculate cursor position
mov eax,tl_cur_pos
inc eax
lea edi,[txt_capt_cur.v]
stdcall tl_convert_to_str, 5
mov edi,ebx
 
mov ebx,tl_box_left
shl ebx,16
add ebx,5*65536+3
add ebx,tl_box_top
mov ecx,tl_col_txt
or ecx,0xc0000000 ;0x40000000 § ªà è¨¢ âì ä®­ 梥⮬ edi
lea edx,[txt_capt_cur]
mov edi,tl_col_zag
mcall SF_DRAW_TEXT ;captions
popad
@@:
ret
 
;input:
; tlist - pointer to 'TreeList' struct
; opt - options: 0 - first element, 1 - add next element
; h_mem - pointer to memory
; mem_size - memory size
;output:
; eax - error code
align 4
proc tl_save_mem uses ebx ecx edx edi esi, tlist:dword, opt:dword, h_mem:dword, mem_size:dword
mov esi,[h_mem]
mov edi,[tlist]
 
cmp dword[opt],0 ;add mode
je @f
stdcall tl_get_mem_size, edi,esi ;eax = à §¬¥à à ­¥¥ á®åà ­ñ­­ëå ¤ ­­ëå
add esi,eax
@@:
 
xor ebx,ebx
mov bx,tl_info_size
 
call tl_get_node_count_all ;eax = all node count
 
mov ecx,eax ;¢ëç¨á«ï¥¬ ᪮«ìª® ¯ ¬ï⨠¤®«¦­® ¡ëâì § ¯®«­¥­®
imul ecx,ebx ;㬭®¦ ¥¬ ­  à §¬¥à áâàãªâãàë 㧫 
add ecx,tl_save_load_heder_size+1 ;element header +1 end element sumbol
add ecx,esi ;¤®¡ ¢«ï¥¬ 㪠§ â¥«ì ­  ­ ç «® ¯ ¬ï⨠(á ãç¥â®¬ à ­¥¥ § ¯¨á ­­ëå áâàãªâãà)
sub ecx,dword[h_mem] ;®â­¨¬ ¥¬ 㪠§ â¥«ì ­  ­ ç «® ¯ ¬ï⨠(¡¥§ à ­¥¥ § ¯¨á ­­ëå áâàãªâãà)
cmp ecx,dword[mem_size] ;ecx = element memory size
jg .err_mem_size
 
;save tree params (in header)
mov dword[esi],'tree'
mov word[esi+4],bx
mov dword[esi+6],eax ;element count
 
mov eax,tl_style
mov dword[esi+10],eax
 
mov eax,tl_cur_pos
mov dword[esi+14],eax
 
mov ax,tl_info_capt_offs
mov word[esi+18],ax
 
mov ax,tl_info_capt_len
mov word[esi+20],ax
 
;copy scroll position
mov edx,tl_p_scroll
mov eax,dword[edx+sb_offs_position]
mov dword[esi+22],eax
 
add esi,tl_save_load_heder_size ;add header size
 
;cycle to nodes
mov edx,tl_data_nodes
mov ecx,edx
add ecx,sizeof.TreeNode
@@:
call tl_iterat_next_all
cmp edx,ecx
jle @f
;save node params
call tl_get_node_index ;eax = index of pointer [edx]
mov dword[esi],eax
 
add esi,4
mov eax,dword[edx+TreeNode.type] ;eax = (type; level; close)
mov dword[esi],eax
add esi,4
 
stdcall tl_node_poi_get_data, edi,edx ;eax - pointer node data
 
;call tl_node_copy_data
push ecx edi
mov edi,eax
mov ecx,ebx
xchg esi,edi
rep movsb
mov esi,edi
pop edi ecx
;add esi,ebx
jmp @b
@@:
mov byte[esi],0 ;end of 'treelist'
xor eax,eax ;return error code
jmp @f
.err_mem_size:
mov eax,tl_err_save_memory_size
@@:
ret
endp
 
;input:
; tlist - pointer to 'TreeList' struct
; opt - options: element index + (2*(add mode)+(init mode)) shl 16
; h_mem - pointer to memory
; mem_size - memory size
; à §¬¥à ¯ ¬ïâ¨, ¯®ª  ­¥ ¨á¯®«ì§ã¥âáï (­ §­ ç «áï ¤«ï ª®­â஫ï)
; ¤«ï ¥£® ¨á¯®«ì§®¢ ­¨ï ­ã¦­® ¤®à ¡®â âì äã­ªæ¨î
;output:
; eax - error code
;memory header format:
; +0 - (4) 'tree'
; +4 - (2) info size
; +6 - (4) count nodes
; +10 - (4) tlist style
; +14 - (4) cursor pos
; +18 - (2) info capt offs
; +20 - (2) info capt len
; +22 - (4) scroll pos
;memory data format:
; +26 - (info size + 8) * count nodes
align 4
proc tl_load_mem uses ebx ecx edx edi esi, tlist:dword, opt:dword, h_mem:dword, mem_size:dword
locals
er_code dd ?
endl
mov esi,[h_mem]
mov edi,[tlist]
 
mov dword[er_code],0 ;return error code
 
mov ecx,[opt]
or cx,cx ;load in array mode
jz @f
;stdcall tl_get_mem_size, esi,edi ;¡¥à¥¬ à §¬¥à à ­¥¥ á®åà ­ñ­­ëå ¤ ­­ëå
;add esi,eax
and ecx,0xffff
cld
.beg_cycle:
cmp dword[esi],'tree'
jne .no_tree
movzx ebx,word[esi+4]
add bx,8
imul ebx,dword[esi+6]
add ebx,tl_save_load_heder_size
add esi,ebx
loop .beg_cycle
@@:
 
cmp dword[esi],'tree'
jne .no_tree
bt dword[opt],17 ;load in add mode
jc @f
stdcall tl_info_clear, edi
@@:
 
xor ebx,ebx
mov bx,word[esi+4] ;info_size
cmp bx,tl_info_size
je @f
or dword[er_code],tl_err_load_info_size
@@:
mov ecx,[esi+6] ;count nodes
cmp ecx,1
jl .end_f
mov edx,esi ;save header pointer
add esi,tl_save_load_heder_size
 
cld
@@: ;load node params
mov eax,dword[esi+4]
ror eax,16 ;eax - options (type; level; close)
add esi,8
stdcall tl_node_add, edi,eax,esi
stdcall tl_cur_next, edi
;...
add esi,ebx
loop @b
 
bt dword[opt],17 ;load in add mode
jc .no_tree
mov eax,dword[edx+14] ;set cursor pos
mov tl_cur_pos,eax
mov ebx,tl_p_scroll
or ebx,ebx
jz .end_f
mov eax,dword[edx+22] ;set scroll pos
mov dword[ebx+sb_offs_position],eax
stdcall scroll_bar_vertical.draw, ebx
jmp .end_f
.no_tree:
mov dword[er_code],tl_err_load_caption
.end_f:
mov eax,dword[er_code]
ret
endp
 
;¡¥à¥â à §¬¥à ¯ ¬ï⨠§ ­ï⮩ ä㭪樥© tl_save_mem ¯à¨ á®åà ­¥­¨¨ í«¥¬¥­â®¢
;output:
; eax - error code
align 4
proc tl_get_mem_size uses ebx edi, tlist:dword, h_mem:dword
mov edi,[tlist]
mov eax,[h_mem]
@@:
cmp dword[eax],'tree'
jne @f
xor ebx,ebx
mov bx,word[eax+4]
add bx,8 ;à §¬¥à ¤®¯®«­¨â¥«ì­®© ¨­ä®à¬ æ¨¨ ®¡ 㧫¥ (¨­¤¥ªá § ¯¨á¨; ¨­¤¥ªá ¨ª®­ª¨, ã஢¥­ì, ...)
imul ebx,dword[eax+6]
add ebx,tl_save_load_heder_size
add eax,ebx
jmp @b
@@:
sub eax,dword[h_mem] ;®â­¨¬ ¥¬ 㪠§ â¥«ì ­  ­ ç «® ¯ ¬ïâ¨
;¨ ¯®«ãç ¥¬ à §¬¥à ¡«®ª  ¯ ¬ïâ¨
ret
endp
 
 
;ascii scan key
; 13 28 Enter
; 32 57 Space
; 178 72 Up
; 177 80 Down
; 176 75 Left
; 179 77 Right
; 182 83 Delete
; 184 73 Pg Up
; 183 81 Pg Dn
 
tl_key_ascii db 13,32,178,177,176,179,182,184,183
tl_key_scan db 28,57, 72, 80, 75, 77, 83, 73, 81
 
txt_capt_cur: db '‘âப  '
.v: db ' ',0
txt_capt_otm: db 'Žâ¬¥­ë '
.v: db ' ',0
 
;description:
; ¯à¥à¥¢®¤ ç¨á«  ¢ ASCII áâபã
;input:
; eax = value
; edi = string buffer
align 4
proc tl_convert_to_str, len:dword
pushad
mov esi,[len]
add esi,edi
dec esi
call .str
popad
ret
endp
 
align 4
.str:
mov ecx,10 ;§ ¤ ¥âáï á¨á⥬  áç¨á«¥­¨ï
cmp eax,ecx ;áà ¢­¨âì ¥á«¨ ¢ eax ¬¥­ìè¥ ç¥¬ ¢ ecx â® ¯¥à¥©â¨ ­  @@-1 â.¥. ­  pop eax
jb @f
xor edx,edx ;®ç¨áâ¨âì edx
div ecx ;à §¤¥«¨âì - ®áâ â®ª ¢ edx
push edx ;¯®«®¦¨âì ¢ á⥪
call .str ;¢ë§¢ âì á ¬ã á¥¡ï ¨ â ª ¤® ⮣® ¬®¬¥­â  ¯®ª  ¢ eax ­¥ áâ ­¥â ¬¥­ìè¥ ç¥¬ ¢ ecx
pop eax
@@:
cmp edi,esi
jge @f
or al,0x30 ;¤®¡ ¢«ï¥¬ ᨬ¢®« '0'
stosb ;§ ¯¨á âì al ¢ ï祪㠯 ¬ï⨠[edi]
mov byte[edi],0
@@:
ret