Subversion Repositories Kolibri OS

Rev

Rev 1285 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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