Subversion Repositories Kolibri OS

Rev

Rev 7441 | Rev 7662 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
7360 IgorA 1
use32
2
	org 0
3
	db 'MENUET01'
4
	dd 1,start,i_end,mem,stacktop,0,sys_path
5
 
7365 pavelyakov 6
include '../../macros.inc'
7
include '../../proc32.inc'
8
include '../../KOSfuncs.inc'
9
include '../../load_img.inc'
10
include '../../develop/libraries/libs-dev/libimg/libimg.inc'
11
include '../../develop/libraries/box_lib/trunk/box_lib.mac'
7360 IgorA 12
include 'lang.inc'
13
include 'cnc_editor.inc'
14
include '../../develop/info3ds/info_fun_float.inc'
15
 
16
@use_library_mem mem.Alloc,mem.Free,mem.ReAlloc,dll.Load
7508 IgorA 17
caption db 'CNC editor 30.10.18',0 ;подпись окна
7360 IgorA 18
 
19
run_file_70 FileInfoBlock
20
 
21
offs_last_timer dd 0 ;последний сдвиг показаный в функции таймера
22
 
23
IMAGE_TOOLBAR_ICON_SIZE equ 16*16*3
24
image_data_toolbar dd 0 ;указатель на временную память. для нужен преобразования изображения
25
icon_tl_sys dd 0 ;указатель на память для хранения системных иконок
26
icon_toolbar dd 0 ;указатель на память для хранения иконок объектов
27
 
28
include 'wnd_point_coords.inc'
29
include 'wnd_scale.inc'
30
include 'wnd_new_file.inc'
31
 
32
align 4
33
start:
34
	load_libraries l_libs_start,l_libs_end
35
	;проверка на сколько удачно загузилась библиотека
36
	mov	ebp,lib_0
37
	cmp	dword [ebp+ll_struc_size-4],0
38
	jz	@f
39
		mcall SF_TERMINATE_PROCESS
40
	@@:
41
	mcall SF_STYLE_SETTINGS,SSF_GET_COLORS,sc,sizeof.system_colors
42
	mcall SF_SET_EVENTS_MASK,0xC0000027
43
	stdcall [OpenDialog_Init],OpenDialog_data ;подготовка диалога
44
 
45
	stdcall [buf2d_create], buf_0 ;создание буфера
46
 
47
	;шрифт делаем до создания панели (для экономии указателя image_data_toolbar)
48
	include_image_file '..\..\fs\kfar\trunk\font6x9.bmp', image_data_toolbar, buf_1.w,buf_1.h
49
	stdcall [buf2d_create_f_img], buf_1,[image_data_toolbar] ;создаем буфер
50
	stdcall mem.Free,[image_data_toolbar] ;освобождаем память
51
	stdcall [buf2d_conv_24_to_8], buf_1,1 ;делаем буфер прозрачности 8 бит
52
	stdcall [buf2d_convert_text_matrix], buf_1
53
	mov eax,[buf_1.h]
54
	shr eax,8
55
	mov [font_h],eax
56
 
57
	include_image_file 'toolbar.png', image_data_toolbar
58
 
59
	mov dword[w_scr_t1.type],1
60
	stdcall dword[tl_data_init], tree1
61
	;системные иконки 16*16 для tree_list
62
	include_image_file 'tl_sys_16.png', icon_tl_sys
63
	mov eax,dword[icon_tl_sys]
64
	mov dword[tree1.data_img_sys],eax
65
 
66
	include_image_file 'objects.png', icon_toolbar
67
	mov eax,dword[icon_toolbar]
68
	mov dword[tree1.data_img],eax
69
 
70
	;*** установка времени для таймера
71
	mcall SF_SYSTEM_GET,SSF_TIME_COUNT
72
	mov [last_time],eax
73
 
74
	;call but_new_file
75
 
76
align 4
77
red_win:
78
	call draw_window
79
 
80
align 4
81
still:
82
	mcall SF_SYSTEM_GET,SSF_TIME_COUNT
83
	mov ebx,[last_time]
84
	add ebx,10 ;задержка
85
	cmp ebx,eax
86
	jge @f
87
		mov ebx,eax
88
	@@:
89
	sub ebx,eax
90
	mcall SF_WAIT_EVENT_TIMEOUT
91
	cmp eax,0
92
	jne @f
93
		call timer_funct
94
		jmp still
95
	@@:
96
 
97
	cmp al,1
98
	jz red_win
99
	cmp al,2
100
	jz key
101
	cmp al,3
102
	jz button
103
	cmp al,6
104
	jne @f
105
		mcall SF_THREAD_INFO,procinfo,-1
106
		cmp ax,word[procinfo.window_stack_position]
107
		jne @f ;окно не активно
108
		call mouse
109
	@@:
110
	jmp still
111
 
112
align 4
113
mouse:
114
	push eax ebx ecx
115
	mcall SF_MOUSE_GET,SSF_BUTTON_EXT
116
	bt eax,8
117
	jnc @f
118
		;mouse l. but. press
119
		call mouse_left_d
120
		jmp .end_l
121
	@@:
122
	;bt eax,0
123
	;jnc @f
124
		;mouse l. but. move
125
		;call mouse_left_m
126
		;jmp .end_l
127
	;@@:
128
	bt eax,16
129
	jnc .end_l
130
		;mouse l. but. up
131
		call mouse_left_u
132
		;jmp .end_l
133
	.end_l:
134
	bt eax,9
135
	jnc @f
136
		;mouse r. but. press
137
		call mouse_right_d
138
		;jmp .end_r
139
	@@:
140
	;bt eax,1
141
	;jnc @f
142
		;mouse r. but. move
143
		;call mouse_right_m
144
		;jmp .end_r
145
	;@@:
146
	;.end_r:
147
 
148
	call buf_get_mouse_coord
149
	cmp eax,-1
150
	je .end0
151
		shl eax,1
152
		sub eax,[buf_0.w]
153
		sar eax,1
154
		mov [mouse_prop_x],eax
155
		stdcall [tl_node_get_data],tree1
156
		or eax,eax
157
		jz .end0
158
		cmp [eax+Figure.OType],'Fig'
159
		je @f
160
		cmp [eax+Figure.OType],'Obj'
161
		je .end1
162
			jmp .end0
163
		.end1:
164
			mov eax,ObjData
165
		@@:
166
		mov ecx,eax
167
		shl ebx,1
168
		sub ebx,[buf_0.h]
169
		sar ebx,1
170
		mov [mouse_prop_y],ebx
171
 
172
		mcall SF_MOUSE_GET,SSF_SCROLL_DATA
173
		test ax,ax
174
		jz .end0
175
		finit
176
		fld qword[zoom_plus]
177
		fld1
178
		fsubp
179
		fld st0 ;for Y coord
180
 
181
		;for X coord
182
		fild dword[mouse_prop_x]
183
		fmulp st1,st0
184
 
185
		mov ebx,eax
186
		test ax,0x8000
187
		jnz .decr
188
			;увеличение масштаба
189
			fchs
190
			fild dword[ecx+Figure.MCentrX] ;add old value
191
			fmul qword[zoom_plus]
192
			faddp
193
 
194
			fld qword[ecx+Figure.MScale]
195
			fmul qword[zoom_plus]
196
			;if (Figure.MScale>16.0)
197
			;...
198
			jmp @f
199
		.decr:
200
			;уменьшение масштаба
201
			fild dword[ecx+Figure.MCentrX] ;add old value
202
			fdiv qword[zoom_plus]
203
			faddp
204
 
205
			fld qword[ecx+Figure.MScale]
206
			fdiv qword[zoom_plus]
207
			fld1
208
			fcomp
209
			fstsw ax
210
			sahf
211
			jbe @f
212
				;if (Figure.MScale<1.0)
213
				ffree st0
214
				fincstp
215
				ffree st0
216
				fincstp
217
				fldz ;default Figure.MCentrX
218
				fld1 ;default Figure.MScale
219
				mov dword[ecx+Figure.MCentrY],0
220
		@@:
221
		fstp qword[ecx+Figure.MScale]
222
		fistp dword[ecx+Figure.MCentrX]
223
 
224
		;for Y coord
225
		fild dword[mouse_prop_y]
226
		fmulp st1,st0
227
		test bx,0x8000
228
		jnz .decr_y
229
			;увеличение масштаба
230
			fild dword[ecx+Figure.MCentrY] ;add old value
231
			fmul qword[zoom_plus]
232
			faddp
233
			jmp @f
234
		.decr_y:
235
			;уменьшение масштаба
236
			fchs
237
			fild dword[ecx+Figure.MCentrY] ;add old value
238
			fdiv qword[zoom_plus]
239
			faddp
240
		@@:
241
		fistp dword[ecx+Figure.MCentrY]
242
 
243
		mov dword[offs_last_timer],0
244
	.end0:
245
 
246
	stdcall [tl_mouse], tree1
247
	pop ecx ebx eax
248
	ret
249
 
250
;output:
251
; eax - buffer coord X (если курсор за буфером -1)
252
; ebx - buffer coord Y (если курсор за буфером -1)
253
align 4
254
proc buf_get_mouse_coord
255
	mcall SF_MOUSE_GET,SSF_WINDOW_POSITION
256
	cmp ax,word[buf_0.t]
257
	jl .no_buf ;не попали в окно буфера по оси y
258
	mov ebx,eax
259
	shr ebx,16
260
	cmp bx,word[buf_0.l]
261
	jl .no_buf ;не попали в окно буфера по оси x
262
 
263
	and eax,0xffff ;оставляем координату y
264
	sub ax,word[buf_0.t]
265
	cmp eax,[buf_0.h]
266
	jg .no_buf
267
	sub bx,word[buf_0.l]
268
	cmp ebx,[buf_0.w]
269
	jg .no_buf
270
	xchg eax,ebx
271
	jmp .end_f
272
	.no_buf:
273
		xor eax,eax
274
		not eax
275
		xor ebx,ebx
276
		not ebx
277
	.end_f:
278
	ret
279
endp
280
 
281
align 4
282
proc timer_funct
283
	pushad
284
	mcall SF_SYSTEM_GET,SSF_TIME_COUNT
285
	mov [last_time],eax
286
 
287
	;просматриваем выделенный блок данных
288
	stdcall [tl_node_get_data],tree1
289
	or eax,eax
290
	jz .end_f
291
	cmp dword[offs_last_timer],eax
292
	je .end_f
293
		;если выделенный блок данных не совпадает с последним запомненным
294
		mov dword[offs_last_timer],eax
295
 
296
		stdcall get_object_data,eax
297
		or ecx,ecx
298
		jz .end_oblo
299
			stdcall draw_obj2d,ecx
300
			stdcall [buf2d_draw], buf_0
301
			jmp .end_f
302
		.end_oblo:
303
 
304
		cmp [eax+Figure.OType],'Fig'
305
		jne .end_fblo
306
			stdcall draw_fig2d,eax
307
			stdcall [buf2d_draw], buf_0
308
			jmp .end_f
309
		.end_fblo:
310
 
311
	.end_f:
312
 
313
	popad
314
	ret
315
endp
316
 
317
align 4
318
draw_window:
319
pushad
320
	mcall SF_REDRAW,SSF_BEGIN_DRAW
321
 
322
	; *** рисование главного окна (выполняется 1 раз при запуске) ***
323
	mov edx,[sc.work]
7441 IgorA 324
	or  edx,0x33000000
7360 IgorA 325
	mov edi,caption
326
	mcall SF_CREATE_WINDOW,(20 shl 16)+599,(20 shl 16)+415
327
 
328
	mcall SF_THREAD_INFO,procinfo,-1
329
	mov eax,dword[procinfo.box.height]
330
	cmp eax,120
331
	jge @f
332
		mov eax,120 ;min size
333
	@@:
334
	sub eax,65
335
	mov dword[tree1.box_height],eax
336
	mov word[w_scr_t1.y_size],ax ;новые размеры скроллинга
337
	mov ebx,dword[procinfo.box.width]
338
	cmp ebx,270
339
	jge @f
340
		mov ebx,270
341
	@@:
342
	sub ebx,215
343
	cmp eax,dword[buf_0.h] ;смотрим размер буфера
344
	jne @f
345
	cmp ebx,dword[buf_0.w]
346
	jne @f
347
		jmp .end0
348
	@@:
349
		stdcall [buf2d_resize],buf_0,ebx,eax,1
350
		mov eax,ObjData
351
		mov ecx,[eax+Object.FigCount]
352
		or ecx,ecx
353
		jz .end0
354
		mov eax,[eax+Object.FigData]
355
		xor edx,edx
356
		.cycle0:
357
			stdcall FigCalculateSizes,[eax+4*edx],0
358
			inc edx
359
			loop .cycle0
360
		stdcall ObjCalculateScale,ObjData
361
		mov dword[offs_last_timer],0
362
		call timer_funct
363
	.end0:
364
 
365
	; *** создание кнопок на панель ***
7441 IgorA 366
	mcall SF_DEFINE_BUTTON,(5 shl 16)+20,(5 shl 16)+20,3, [sc.work_button]
7360 IgorA 367
 
368
	add ebx,25 shl 16
7441 IgorA 369
	mcall ,,,4 ;open
370
	add ebx,25 shl 16
371
	mcall ,,,5 ;save
7360 IgorA 372
 
373
	add ebx,30 shl 16
7441 IgorA 374
	mcall ,,,6 ;captions on off
7360 IgorA 375
 
376
	add ebx,25 shl 16
7441 IgorA 377
	mcall ,,,7 ;figure move up
7360 IgorA 378
	add ebx,25 shl 16
7441 IgorA 379
	mcall ,,,8 ;figure move down
7360 IgorA 380
 
381
	add ebx,25 shl 16
7441 IgorA 382
	mcall ,,,9 ;sel points dlg
7360 IgorA 383
 
384
	add ebx,25 shl 16
7441 IgorA 385
	mcall ,,,10 ;sel points move up
7360 IgorA 386
	add ebx,25 shl 16
7441 IgorA 387
	mcall ,,,11 ;sel points move down
7360 IgorA 388
 
389
	add ebx,25 shl 16
7441 IgorA 390
	mcall ,,,12 ;align sel points left
7415 IgorA 391
	add ebx,25 shl 16
7441 IgorA 392
	mcall ,,,13 ;align sel points right
7415 IgorA 393
	add ebx,25 shl 16
7441 IgorA 394
	mcall ,,,14 ;align sel points top
7415 IgorA 395
	add ebx,25 shl 16
7441 IgorA 396
	mcall ,,,15 ;align sel points bottom
7360 IgorA 397
 
398
	add ebx,25 shl 16
7441 IgorA 399
	mcall ,,,16 ;copy to clipboard
7415 IgorA 400
	add ebx,25 shl 16
7441 IgorA 401
	mcall ,,,17 ;paste from clipboard
7360 IgorA 402
 
403
	add ebx,25 shl 16
7441 IgorA 404
	mcall ,,,18 ;sel points del
7360 IgorA 405
 
406
	add ebx,30 shl 16
7441 IgorA 407
	mcall ,,,19 ;restore zoom
7360 IgorA 408
 
409
	add ebx,30 shl 16
7441 IgorA 410
	mcall ,,,20 ;.png
7360 IgorA 411
 
412
	add ebx,25 shl 16
7441 IgorA 413
	mcall ,,,21 ;options scale
7360 IgorA 414
 
415
	; *** рисование иконок на кнопках ***
416
	mcall SF_PUT_IMAGE,[image_data_toolbar],(16 shl 16)+16,(7 shl 16)+7 ;icon new
417
 
418
	add ebx,IMAGE_TOOLBAR_ICON_SIZE
419
	add edx,(25 shl 16) ;icon open
420
	int 0x40
421
	add ebx,IMAGE_TOOLBAR_ICON_SIZE
422
	add edx,(25 shl 16) ;icon save
423
	int 0x40
424
 
425
	add ebx,IMAGE_TOOLBAR_ICON_SIZE
426
	add edx,(30 shl 16) ;captions on off
427
	int 0x40
428
	add ebx,IMAGE_TOOLBAR_ICON_SIZE
429
	add edx,(25 shl 16) ;figure move up
430
	int 0x40
431
	add ebx,IMAGE_TOOLBAR_ICON_SIZE
432
	add edx,(25 shl 16) ;figure move down
433
	int 0x40
434
	add ebx,IMAGE_TOOLBAR_ICON_SIZE
435
	add edx,(25 shl 16) ;sel points dlg
436
	int 0x40
437
	add ebx,IMAGE_TOOLBAR_ICON_SIZE
438
	add edx,(25 shl 16) ;sel points move up
439
	int 0x40
440
	add ebx,IMAGE_TOOLBAR_ICON_SIZE
441
	add edx,(25 shl 16) ;sel points move down
442
	int 0x40
443
	add ebx,IMAGE_TOOLBAR_ICON_SIZE
7415 IgorA 444
	add edx,(25 shl 16) ;aling sel points left
445
	int 0x40
446
	add ebx,IMAGE_TOOLBAR_ICON_SIZE
447
	add edx,(25 shl 16) ;aling sel points right
448
	int 0x40
449
	add ebx,IMAGE_TOOLBAR_ICON_SIZE
450
	add edx,(25 shl 16) ;aling sel points top
451
	int 0x40
452
	add ebx,IMAGE_TOOLBAR_ICON_SIZE
453
	add edx,(25 shl 16) ;aling sel points bottom
454
	int 0x40
455
	add ebx,IMAGE_TOOLBAR_ICON_SIZE
7360 IgorA 456
	add edx,(25 shl 16) ;copy to clipboard
457
	int 0x40
458
	add ebx,IMAGE_TOOLBAR_ICON_SIZE
459
	add edx,(25 shl 16) ;paste from clipboard
460
	int 0x40
461
	add ebx,IMAGE_TOOLBAR_ICON_SIZE
462
	add edx,(25 shl 16) ;sel points del
463
	int 0x40
464
	add ebx,IMAGE_TOOLBAR_ICON_SIZE
465
	add edx,(30 shl 16) ;restore zoom
466
	int 0x40
467
	add ebx,IMAGE_TOOLBAR_ICON_SIZE
468
	add edx,(30 shl 16) ;.png
469
	int 0x40
470
	add ebx,IMAGE_TOOLBAR_ICON_SIZE
471
	add edx,(25 shl 16) ;options scale
472
	int 0x40
473
 
474
	mov dword[w_scr_t1.all_redraw],1
475
	stdcall [tl_draw], tree1
476
	stdcall [buf2d_draw], buf_0
477
 
478
	mcall SF_REDRAW,SSF_END_DRAW
479
popad
480
	ret
481
 
482
align 4
483
key:
484
	mcall SF_GET_KEY
485
	cmp dword[el_focus], tree1
486
	jne @f
487
		stdcall [tl_key], tree1
488
		jmp .end0
489
	@@:
490
 
491
	cmp ah,178 ;Up
492
	jne @f
493
		call but_selection_move_up
494
		jmp .end0
495
	@@:
496
	cmp ah,177 ;Down
497
	jne @f
498
		call but_selection_move_down
499
		jmp .end0
500
	@@:
501
	cmp ah,176 ;Left
502
	jne @f
503
		call but_selection_move_up
504
		jmp .end0
505
	@@:
506
	cmp ah,179 ;Right
507
	jne @f
508
		call but_selection_move_down
509
		jmp .end0
510
	@@:
511
	cmp ah,182 ;Delete
512
	jne @f
513
		call but_sel_points_del
514
		jmp .end0
515
	@@:
516
 
517
	mov ecx,eax
518
	mcall SF_KEYBOARD,SSF_GET_CONTROL_KEYS
519
	bt eax,2 ;left Ctrl
520
	jc .key_Ctrl
521
	bt eax,3 ;right Ctrl
522
	jc .key_Ctrl
523
	jmp .end0
524
	.key_Ctrl:
525
		cmp ch,15 ;111 ;Ctrl+O
526
		jne @f
527
			call but_open_file
528
		@@:
529
		cmp ch,19 ;115 ;Ctrl+S
530
		jne @f
531
			call but_save_file
532
		@@:
533
		cmp ch,14 ;110 ;Ctrl+N
534
		jne @f
535
			call but_new_file
536
		@@:
537
		cmp ch,1 ;97 ;Ctrl+A
538
		jne @f
539
			call but_sel_points_all
540
		@@:
541
	.end0:
542
	jmp still
543
 
544
 
545
align 4
546
button:
547
	mcall SF_GET_BUTTON
548
	cmp ah,3
549
	jne @f
550
		call but_new_file
551
		jmp still
552
	@@:
553
	cmp ah,4
554
	jne @f
555
		call but_open_file
556
		jmp still
557
	@@:
558
	cmp ah,5
559
	jne @f
560
		call but_save_file
561
		jmp still
562
	@@:
563
	cmp ah,6
564
	jne @f
565
		call but_captions_on_off
566
		jmp still
567
	@@:
568
	cmp ah,7
569
	jne @f
570
		call but_sel_figure_move_up
571
		jmp still
572
	@@:
573
	cmp ah,8
574
	jne @f
575
		call but_sel_figure_move_down
576
		jmp still
577
	@@:
578
	cmp ah,9
579
	jne @f
580
		call but_dlg_point_coords
581
		jmp still
582
	@@:
583
	cmp ah,10
584
	jne @f
585
		call but_sel_points_move_up
586
		jmp still
587
	@@:
588
	cmp ah,11
589
	jne @f
590
		call but_sel_points_move_down
591
		jmp still
592
	@@:
593
	cmp ah,12
594
	jne @f
7415 IgorA 595
		call but_sel_points_align_coord_xmin
7360 IgorA 596
		jmp still
597
	@@:
598
	cmp ah,13
599
	jne @f
7415 IgorA 600
		call but_sel_points_align_coord_xmax
7360 IgorA 601
		jmp still
602
	@@:
603
	cmp ah,14
604
	jne @f
7415 IgorA 605
		call but_sel_points_align_coord_ymax
7360 IgorA 606
		jmp still
607
	@@:
608
	cmp ah,15
609
	jne @f
7415 IgorA 610
		call but_sel_points_align_coord_ymin
611
	@@:
612
	cmp ah,16
613
	jne @f
614
		call but_clipboard_copy_points
615
		jmp still
616
	@@:
617
	cmp ah,17
618
	jne @f
619
		call but_clipboard_paste_points
620
		jmp still
621
	@@:
622
	cmp ah,18
623
	jne @f
624
		call but_sel_points_del
625
		jmp still
626
	@@:
627
	cmp ah,19
628
	jne @f
7360 IgorA 629
		call but_restore_zoom
630
		jmp still
631
	@@:
7415 IgorA 632
	cmp ah,20
7360 IgorA 633
	jne @f
634
		call but_save_png
635
		jmp still
636
	@@:
7415 IgorA 637
	cmp ah,21
7360 IgorA 638
	jne @f
639
		call but_dlg_opt_scale
640
		jmp still
641
	@@:
642
 
7415 IgorA 643
	;cmp ah,22
7360 IgorA 644
	;jne @f
645
		;call but_...
646
		;jmp still
647
	;@@:
648
	cmp ah,1
649
	jne still
650
.exit:
651
	stdcall [buf2d_delete],buf_0
652
	stdcall mem.Free,[image_data_toolbar]
653
	stdcall mem.Free,[open_file_data]
654
	mcall SF_TERMINATE_PROCESS
655
 
656
 
657
align 4
658
but_new_file:
659
	cmp byte[wnd_n_file],0
660
	jne .end_f
661
pushad
662
	mcall SF_CREATE_THREAD,1,start_n_file,thread_n_file
663
popad
664
	.end_f:
665
	ret
666
 
667
align 4
668
open_file_data dd 0 ;указатель на память для открытия файлов
669
open_file_size dd 0 ;размер открытого файла
670
 
671
align 4
672
but_open_file:
673
	pushad
674
	copy_path open_dialog_name,communication_area_default_path,file_name,0
675
	mov [OpenDialog_data.type],0
676
	stdcall [OpenDialog_Start],OpenDialog_data
677
	cmp [OpenDialog_data.status],2
678
	je .end_open_file
679
	;код при удачном открытии диалога
680
 
681
	mov [run_file_70.Function], SSF_GET_INFO
682
	mov [run_file_70.Position], 0
683
	mov [run_file_70.Flags], 0
684
	mov dword[run_file_70.Count], 0
685
	mov dword[run_file_70.Buffer], open_b
686
	mov byte[run_file_70+20], 0
687
	mov dword[run_file_70.FileName], openfile_path
688
	mcall SF_FILE,run_file_70
689
 
690
	mov ecx,dword[open_b+32] ;+32 qword: размер файла в байтах
691
	inc ecx ;for text files
692
	stdcall mem.ReAlloc,[open_file_data],ecx
693
	mov [open_file_data],eax
694
	dec ecx ;for text files
695
	mov byte[eax+ecx],0 ;for text files
696
 
697
	mov [run_file_70.Function], SSF_READ_FILE
698
	mov [run_file_70.Position], 0
699
	mov [run_file_70.Flags], 0
700
	mov dword[run_file_70.Count], ecx
701
	m2m dword[run_file_70.Buffer], dword[open_file_data]
702
	mov byte[run_file_70+20], 0
703
	mov dword[run_file_70.FileName], openfile_path
704
	mcall SF_FILE,run_file_70 ;загружаем файл изображения
705
	test eax,eax
706
	jnz .end_open_file
707
	cmp ebx,0xffffffff
708
	je .end_open_file
709
 
710
		mov [open_file_size],ebx
711
		mcall SF_SET_CAPTION,1,openfile_path
712
 
713
		;---
7508 IgorA 714
		and dword[tree1.style],not tl_cursor_pos_limited
7360 IgorA 715
		stdcall FileInit,[open_file_data],[open_file_size]
7508 IgorA 716
		or dword[tree1.style], tl_cursor_pos_limited
7360 IgorA 717
		stdcall [buf2d_clear], buf_0, [buf_0.color] ;чистим буфер
718
		stdcall [buf2d_draw], buf_0 ;обновляем буфер на экране
719
	.end_open_file:
720
	popad
721
	ret
722
 
723
align 4
724
proc but_save_file
725
locals
726
	pCou dd ?
727
	pData dd ?
728
endl
729
	pushad
730
	copy_path open_dialog_name,communication_area_default_path,file_name,0
731
	mov [OpenDialog_data.type],1
732
	stdcall [OpenDialog_Start],OpenDialog_data
733
	cmp [OpenDialog_data.status],2
734
	je .end_save_file
735
	;код при удачном открытии диалога
736
 
737
	;*** определение примерного размера файла
738
	call get_file_save_size
739
	stdcall mem.ReAlloc,[open_file_data],ecx
740
	mov [open_file_data],eax
741
	mov [open_file_size],ecx
742
 
743
	;clear memory
744
	mov edi,eax
745
	xor eax,eax
746
	shr ecx,2
747
	rep stosd
748
 
749
	;*** пишем информацию в память
750
	mov edi,[open_file_data]
751
	mov ebx,ObjData
752
	mov edx,[ebx+Object.FigCount]
753
	or edx,edx
754
	jz .cycle1end
755
	mov esi,[ebx+Object.FigData]
756
align 4
757
	.cycle1: ;цикл по фигурам
758
		;param 1
759
		mov eax,[esi]
760
		or eax,eax
761
		jz .err_save
762
		mov eax,[eax+Figure.PoiCount]
763
		mov [pCou],eax
764
		or eax,eax
765
		jnz @f
766
			mov eax,[esi]
767
			lea eax,[eax+Figure.Caption]
768
			stdcall str_cat,edi,eax
769
			stdcall str_len,edi
770
			add edi,eax
771
			stdcall str_cat,edi,txt_nl
772
		@@:
773
		cmp dword[pCou],0
774
		je .cycle2end
775
		mov eax,[esi]
776
		mov eax,[eax+Figure.PoiData]
777
		mov [pData],eax
778
		mov word[NumberSymbolsAD],8
779
align 4
780
		.cycle2: ;цикл по точкам
781
			stdcall str_cat,edi,txt_s_poi
782
			;param 1
783
			push edi esi
784
			mov esi,[pData]
785
			lea esi,[esi+Point.CoordX]
786
			mov edi,Data_Double
787
			movsd
788
			movsd
789
			pop esi edi
790
			call DoubleFloat_to_String
791
			call String_crop_0
792
			stdcall str_cat,edi,Data_String
793
			stdcall str_cat,edi,txt_s_poi_Y
794
			;param 2
795
			push edi esi
796
			mov esi,[pData]
797
			lea esi,[esi+Point.CoordY]
798
			mov edi,Data_Double
799
			movsd
800
			movsd
801
			pop esi edi
802
			call DoubleFloat_to_String
803
			call String_crop_0
804
			stdcall str_cat,edi,Data_String
805
			;
806
			stdcall str_cat,edi,txt_nl
807
			add dword[pData],sizeof.Point
808
			dec dword[pCou]
809
			jnz .cycle2
810
		.cycle2end:
811
		add esi,4
812
		dec edx
813
		jnz .cycle1
814
	.cycle1end:
815
 
816
	jmp @f
817
	.err_save:
818
		notify_window_run txt_err_save_txt_file_1
819
	@@:
820
 
821
	;*** определение параметров файла
822
	mov edi,[open_file_data]
823
	stdcall str_len,edi
824
	;;cmp eax,[open_file_size]
825
	mov [run_file_70.Count],eax ;размер файла
826
 
827
	;*** сохраняем файл
828
	mov [run_file_70.Function], SSF_CREATE_FILE
829
	mov [run_file_70.Position], 0
830
	mov [run_file_70.Flags], 0
831
	mov ebx, dword[open_file_data]
832
	mov [run_file_70.Buffer], ebx
833
	mov byte[run_file_70+20], 0
834
	mov dword[run_file_70.FileName], openfile_path
835
	mcall SF_FILE,run_file_70
836
	or eax,eax
837
	jz .end_save_file
838
	or ebx,ebx
839
	jnz .end_save_file
840
		;сообщение о неудачном сохранении
841
		notify_window_run txt_err_save_txt_file_0
842
	.end_save_file:
843
	popad
844
	ret
845
endp
846
 
847
;output:
848
; ecx - memory size for save file
849
align 4
850
proc get_file_save_size uses eax ebx edx esi
851
	mov ecx,100 ;title
852
	mov ebx,ObjData
853
	add ecx,50 ;object
854
	mov edx,[ebx+Object.FigCount]
855
	or edx,edx
856
	jz .cycle1end
857
	mov esi,[ebx+Object.FigData]
858
align 4
859
	.cycle1: ; цикл по фигурам
860
		add ecx,80 ;figure
861
		mov eax,[esi]
862
		or eax,eax
863
		jz @f
864
			mov eax,[eax+Figure.PoiCount]
865
			imul eax,70
866
			add ecx,eax ;points
867
		@@:
868
		add esi,4
869
		dec edx
870
		jnz .cycle1
871
	.cycle1end:
872
	ret
873
endp
874
 
875
align 4
876
but_captions_on_off:
877
	xor dword[opt_draw],1
878
	mov dword[offs_last_timer],0 ;для обновления по таймеру
879
	ret
880
 
881
align 4
882
but_sel_figure_move_up:
883
	pushad
884
	stdcall [tl_node_get_data],tree1
885
	or eax,eax
886
	jz .end_fblo
887
	cmp [eax+Figure.OType],'Fig'
888
	jne .end_fblo
889
		stdcall found_parent_obj,eax
890
		or eax,eax
891
		jz .end_f ;if not found
892
		or ecx,ecx
893
		jz .fig_is_0 ;если фигура в начале списка
894
		mov ebx,[eax+Object.FigData]
895
		mov edx,[ebx+4*ecx] ;передвигаемая фигура
896
		mov edi,[ebx+4*ecx-4]
897
		;меняем фигуры местами
898
		mov [ebx+4*ecx],edi
899
		mov [ebx+4*ecx-4],edx
900
		;меняем фигуры в списке
901
		stdcall [tl_node_move_up],tree1
902
		jmp .end_f
903
	.fig_is_0:
904
		notify_window_run txt_err_figure_is_0
905
		jmp .end_f
906
	.end_fblo:
907
		notify_window_run txt_err_no_figure_select
908
	.end_f:
909
	popad
910
	ret
911
 
912
align 4
913
but_save_png:
914
	pushad
915
	stdcall [tl_node_get_data],tree1
916
	or eax,eax
917
	jz .end_save_file
918
 
919
	stdcall get_object_data,eax
920
	or ecx,ecx
921
	jz .end_oblo
922
		stdcall draw_obj2d_png,ecx
923
		jmp .beg0
924
	.end_oblo:
925
 
926
;       cmp [eax+Figure.OType],'Fig'
927
;       jne .end_fblo
928
;               stdcall draw_fig2d_png,eax
929
;               jmp .beg0
930
;       .end_fblo:
931
 
932
	jmp .end_save_file
933
	.beg0:
934
	copy_path open_dialog_name,communication_area_default_path,file_name,0
935
	mov [OpenDialog_data.type],1
936
	stdcall [OpenDialog_Start],OpenDialog_data
937
	cmp [OpenDialog_data.status],2
938
	je .end_save_file
939
		;код при удачном открытии диалога
940
		mov dword[png_data],0
941
 
942
		;create image struct
943
		stdcall [img_create], [buf_png.w], [buf_png.h], Image.bpp24
944
		mov ebx,eax
945
		test eax,eax
946
		jz @f
947
			;copy foto to image buffer
948
			mov edi,[eax+Image.Data]
949
			mov esi,[buf_png]
950
			mov ecx,[buf_png.w]
951
			mov edx,[buf_png.h]
952
			imul ecx,edx
953
			imul ecx,3
954
			shr ecx,2 ;OpenGL buffer align to 4
955
			rep movsd
956
 
957
			;encode image
958
			stdcall [img_encode], eax, LIBIMG_FORMAT_PNG, 0
959
			test eax,eax
960
			jz @f
961
				mov [png_data],eax
962
				mov [png_size],ecx
963
		@@:
964
		stdcall [img_destroy],ebx
965
 
966
	; заполняем структуру для сохранения файла
967
	mov ebx,run_file_70
968
	mov dword[ebx],SSF_CREATE_FILE
969
	mov eax,[png_size]
970
	mov [ebx+12],eax ;file size
971
	mov eax,[png_data]
972
	mov [ebx+16],eax
973
	mov dword[ebx+FileInfoBlock.FileName], openfile_path
974
 
975
	mcall SF_FILE,run_file_70
976
	test eax,eax
977
	jnz .save_error
978
			;notify_window_run openfile_path
979
			jmp @f
980
		.save_error:
981
			;сообщение о неудачном сохранении
982
			notify_window_run txt_err_save_img_file
983
		@@:
984
		mcall SF_SYS_MISC, SSF_MEM_FREE, [png_data]
985
	.end_save_file:
986
	popad
987
	ret
988
 
989
;description:
990
; выделенные точки сдвигаются вверх
991
align 4
992
proc but_sel_points_move_up
993
locals
994
	pObj dd ?
995
	pFig dd ?
996
	idFig dd ?
997
endl
998
	pushad
999
	stdcall [tl_node_get_data],tree1
1000
	or eax,eax
1001
	jz .no_point
1002
	cmp [eax+Figure.OType],'Fig'
1003
	jne .no_point
1004
 
1005
	mov [pFig],eax
1006
	stdcall sel_points_get_count,eax
1007
	or eax,eax
1008
	jz .no_point
1009
 
1010
	stdcall found_parent_obj,[pFig]
1011
	or eax,eax
1012
	jz .end_f ;if not found
1013
	mov [pObj],eax
1014
	mov [idFig],ecx
1015
 
1016
	;проверяем выделенные точки
1017
	mov eax,[pFig]
1018
	mov ecx,[eax+Figure.PoiCount]
1019
	or ecx,ecx
1020
	jz .no_point
1021
	mov ebx,[eax+Figure.PoiData]
1022
	xor eax,eax
1023
	.cycle0:
1024
		bt dword[ebx+Point.Prop],PROP_BIT_SELECT
1025
		jnc @f
1026
			or eax,eax
1027
			jz .point_is_0
1028
			stdcall point_move_up, [pObj],[pFig],[idFig],ebx;,eax
1029
		@@:
1030
		inc eax
1031
		add ebx,sizeof.Point
1032
		loop .cycle0
1033
 
1034
		;для обновления по таймеру
1035
		mov dword[offs_last_timer],0
1036
		jmp .end_f
1037
	.point_is_0:
1038
		notify_window_run txt_err_poi_is_0
1039
		jmp .end_f
1040
	.no_point:
1041
		notify_window_run txt_err_no_point_sel
1042
	.end_f:
1043
	popad
1044
	ret
1045
endp
1046
 
1047
;description:
1048
; выделенные точки сдвигаются вниз
1049
align 4
1050
proc but_sel_points_move_down
1051
locals
1052
	pObj dd ?
1053
	pFig dd ?
1054
	idFig dd ?
1055
endl
1056
	pushad
1057
	stdcall [tl_node_get_data],tree1
1058
	or eax,eax
1059
	jz .no_point
1060
	cmp [eax+Figure.OType],'Fig'
1061
	jne .no_point
1062
 
1063
	mov [pFig],eax
1064
	stdcall sel_points_get_count,eax
1065
	or eax,eax
1066
	jz .no_point
1067
 
1068
	stdcall found_parent_obj,[pFig]
1069
	or eax,eax
1070
	jz .end_f ;if not found
1071
	mov [pObj],eax
1072
	mov [idFig],ecx
1073
 
1074
	;проверяем выделенные точки
1075
	mov eax,[pFig]
1076
	mov ecx,[eax+Figure.PoiCount]
1077
	or ecx,ecx
1078
	jz .no_point
1079
	mov ebx,ecx
1080
	dec ebx
1081
	imul ebx,sizeof.Point
1082
	add ebx,[eax+Figure.PoiData]
1083
	.cycle0:
1084
		bt dword[ebx+Point.Prop],PROP_BIT_SELECT
1085
		jnc @f
1086
			cmp ecx,[eax+Figure.PoiCount]
1087
			je .point_is_last
1088
			mov edi,ebx
1089
			add edi,sizeof.Point
1090
			stdcall point_move_up, [pObj],[pFig],[idFig],edi;,ecx
1091
		@@:
1092
		sub ebx,sizeof.Point
1093
		loop .cycle0
1094
 
1095
		;для обновления по таймеру
1096
		mov dword[offs_last_timer],0
1097
		jmp .end_f
1098
	.point_is_last:
1099
		notify_window_run txt_err_poi_is_last
1100
		jmp .end_f
1101
	.no_point:
1102
		notify_window_run txt_err_no_point_sel
1103
	.end_f:
1104
	popad
1105
	ret
1106
endp
1107
 
1108
;description:
1109
; выделение выбранной точки сдвигается вверх
1110
align 4
1111
proc but_selection_move_up
1112
locals
1113
	pFig dd ?
1114
endl
1115
	pushad
1116
	stdcall [tl_node_get_data],tree1
1117
	or eax,eax
1118
	jz .end_fblo
1119
	cmp [eax+Figure.OType],'Fig'
1120
	jne .end_fblo
1121
 
1122
	mov [pFig],eax
1123
	stdcall sel_points_get_count,eax
1124
	cmp eax,1
1125
	jne .no_point
1126
 
1127
	;проверяем выделенные точки
1128
	mov eax,[pFig]
1129
	mov ecx,[eax+Figure.PoiCount]
1130
	or ecx,ecx
1131
	jz .no_point
1132
	dec ecx
1133
	jecxz .end_f
1134
	mov ebx,[eax+Figure.PoiData]
1135
	.cycle0:
1136
		add ebx,sizeof.Point
1137
		bt dword[ebx+Point.Prop],PROP_BIT_SELECT
1138
		jnc @f
1139
			btr dword[ebx+Point.Prop],PROP_BIT_SELECT
1140
			bts dword[ebx+Point.Prop-sizeof.Point],PROP_BIT_SELECT
1141
			xor ecx,ecx
1142
			inc ecx ;ecx = 1 - for exit from cycle
1143
		@@:
1144
		loop .cycle0
1145
 
1146
		;для обновления по таймеру
1147
		mov dword[offs_last_timer],0
1148
		jmp .end_f
1149
	.no_point:
1150
		notify_window_run txt_err_no_point_sel_1
1151
		jmp .end_f
1152
	.end_fblo:
1153
		;notify_window_run txt_err_no_figure_select
1154
	.end_f:
1155
	popad
1156
	ret
1157
endp
1158
 
1159
;description:
1160
; выделение выбранной точки сдвигается вниз
1161
align 4
1162
proc but_selection_move_down
1163
locals
1164
	pFig dd ?
1165
endl
1166
	pushad
1167
	stdcall [tl_node_get_data],tree1
1168
	or eax,eax
1169
	jz .end_fblo
1170
	cmp [eax+Figure.OType],'Fig'
1171
	jne .end_fblo
1172
 
1173
	mov [pFig],eax
1174
	stdcall sel_points_get_count,eax
1175
	cmp eax,1
1176
	jne .no_point
1177
 
1178
	;проверяем выделенные точки
1179
	mov eax,[pFig]
1180
	mov ecx,[eax+Figure.PoiCount]
1181
	or ecx,ecx
1182
	jz .no_point
1183
	dec ecx
1184
	jecxz .end_f
1185
	mov ebx,[eax+Figure.PoiData]
1186
	.cycle0:
1187
		bt dword[ebx+Point.Prop],PROP_BIT_SELECT
1188
		jnc @f
1189
			btr dword[ebx+Point.Prop],PROP_BIT_SELECT
1190
			bts dword[ebx+Point.Prop+sizeof.Point],PROP_BIT_SELECT
1191
			xor ecx,ecx
1192
			inc ecx ;ecx = 1 - for exit from cycle
1193
		@@:
1194
		add ebx,sizeof.Point
1195
		loop .cycle0
1196
 
1197
		;для обновления по таймеру
1198
		mov dword[offs_last_timer],0
1199
		jmp .end_f
1200
	.no_point:
1201
		notify_window_run txt_err_no_point_sel_1
1202
		jmp .end_f
1203
	.end_fblo:
1204
		;notify_window_run txt_err_no_figure_select
1205
	.end_f:
1206
	popad
1207
	ret
1208
endp
1209
 
1210
;output:
1211
; eax - couunt new points
1212
align 4
1213
proc but_clipboard_copy_points uses ebx ecx edx edi esi
1214
locals
1215
	pData dd 0
1216
	pBuf dd 0
1217
endl
1218
	stdcall [tl_node_get_data],tree1
1219
	or eax,eax
1220
	jz .no_point
1221
	cmp [eax+Figure.OType],'Fig'
1222
	jne .no_point
1223
 
1224
	mov ecx,[eax+Figure.PoiData]
1225
	mov [pData],ecx
1226
	mov ecx,[eax+Figure.PoiCount]
1227
	stdcall sel_points_get_count,eax
1228
	or eax,eax
1229
	jz .no_point
1230
	push eax
1231
		imul eax,32 ;for string 'X___.________ Y___.________^^'
1232
		stdcall mem.Alloc,eax
1233
		mov [pBuf],eax
1234
 
1235
		mov edx,eax
1236
		mov dword[edx+4],0 ;text data
1237
		mov dword[edx+8],1 ;code 866
1238
		add edx,12 ;system buffer header size
1239
		mov dword[edx],0
1240
		mov word[NumberSymbolsAD],8
1241
align 4
1242
		.cycle2: ;цикл по точкам
1243
			mov esi,[pData]
1244
			bt dword[esi+Point.Prop],PROP_BIT_SELECT
1245
			jnc .end0
1246
			stdcall str_cat,edx,txt_s_poi
1247
			;param 1
1248
			add esi,Point.CoordX
1249
			mov edi,Data_Double
1250
			movsd
1251
			movsd
1252
			call DoubleFloat_to_String
1253
			call String_crop_0
1254
			stdcall str_cat,edx,Data_String
1255
			stdcall str_cat,edx,txt_s_poi_Y
1256
			;param 2
1257
			;;mov esi,[pData]
1258
			;;lea esi,[esi+Point.CoordY]
1259
			mov edi,Data_Double
1260
			movsd
1261
			movsd
1262
			call DoubleFloat_to_String
1263
			call String_crop_0
1264
			stdcall str_cat,edx,Data_String
1265
			;
1266
			stdcall str_cat,edx,txt_nl
1267
			.end0:
1268
			add dword[pData],sizeof.Point
1269
			loop .cycle2
1270
		.cycle2end:
1271
 
1272
		mov edx,[pBuf]
1273
		add edx,12
1274
		stdcall str_len,edx
1275
		sub edx,12
1276
		mov [edx],eax
1277
		add eax,12
1278
		mov ecx,eax
1279
		mcall SF_CLIPBOARD,SSF_WRITE_CB ;,ecx,edx
1280
		stdcall mem.Free,[pBuf]
1281
	pop eax
1282
 
1283
	.no_point:
1284
	ret
1285
endp
1286
 
1287
;output:
1288
; eax - couunt new points
1289
align 4
1290
proc but_clipboard_paste_points uses ebx ecx edx esi edi
1291
locals
1292
	pFig dd ?
1293
	nCount dd ?
1294
endl
1295
	stdcall [tl_node_get_data],tree1
1296
	or eax,eax
1297
	jz .end0
1298
	cmp [eax+Figure.OType],'Fig'
1299
	jne .end0
1300
 
1301
	mov [pFig],eax
1302
 
1303
	mcall SF_CLIPBOARD,SSF_GET_SLOT_COUNT
1304
	cmp eax,1
1305
	jl .end0
1306
 
1307
	mov esi,eax
1308
	.cycle0: ;обратный цикл по слотам
1309
	dec esi ;номер текущего, проверяемого слота
1310
	mcall SF_CLIPBOARD,SSF_READ_CB,esi
1311
	cmp eax,1
1312
	je .end0
1313
	cmp eax,-1
1314
	je .end0
1315
		mov ecx,dword[eax]
1316
		cmp ecx,5 ;min text size
1317
		jl .end0
1318
		cmp dword[eax+4],0 ;text
1319
		je @f
1320
			cmp esi,1
1321
			jge .cycle0 ;если в буфере не текст, а слотов в буфере несколько, пробуем перейти к верхнему слоту
1322
			jmp .end0
1323
		@@:
1324
 
1325
	mov esi,eax
1326
	add esi,12 ;смещение начала текста в буфере
1327
	stdcall get_max_points
1328
	or eax,eax
1329
	jz .end_f
1330
		mov [nCount],eax
1331
		mov ebx,[pFig]
1332
		mov edi,[ebx+Figure.PoiCount]
1333
		add [ebx+Figure.PoiCount],eax
1334
		add eax,edi
1335
		imul eax,sizeof.Point
1336
		stdcall mem.ReAlloc,[ebx+Figure.PoiData],eax
1337
		mov [ebx+Figure.PoiData],eax
1338
 
1339
		mov ecx,edi
1340
		mov edx,eax
1341
align 4
1342
		.cycle1: ;цикл для снятия выделения со старых точек
1343
			btr dword[edx+Point.Prop],PROP_BIT_SELECT
1344
			add edx,sizeof.Point
1345
			loop .cycle1
1346
 
1347
		mov ecx,[nCount]
1348
		imul edi,sizeof.Point
1349
		add edi,eax
1350
		finit
1351
align 4
1352
		.cycle2: ;цикл для добавления новых точек
1353
			stdcall PointInit,edi
1354
			or eax,eax
1355
			jz .cycle2end
1356
			bts dword[edi+Point.Prop],PROP_BIT_SELECT
1357
			add edi,sizeof.Point
1358
			loop .cycle2
1359
		.cycle2end:
1360
		or ecx,ecx
1361
		jz .end1
1362
			;уменьшаем объем памяти выделенный для точек
1363
			sub [ebx+Figure.PoiCount],ecx
1364
			mov eax,[ebx+Figure.PoiCount]
1365
			imul eax,sizeof.Point
1366
			stdcall mem.ReAlloc,[ebx+Figure.PoiData],eax
1367
			mov [ebx+Figure.PoiData],eax
1368
		.end1:
1369
		stdcall found_parent_obj,ebx ;get figure number in ecx
1370
		stdcall figure_update_coords,ObjData,ecx
1371
 
1372
		mov eax,[nCount]
1373
		mov dword[offs_last_timer],0
1374
		jmp .end_f
1375
	.end0:
1376
		xor eax,eax
1377
	.end_f:
1378
	ret
1379
endp
1380
 
1381
align 4
1382
proc but_sel_points_del
1383
locals
1384
	pFig dd ?
1385
	nDel dd ? ;need delete
1386
endl
1387
	pushad
1388
	stdcall [tl_node_get_data],tree1
1389
	or eax,eax
1390
	jz .no_point
1391
	cmp [eax+Figure.OType],'Fig'
1392
	jne .no_point
1393
 
1394
	mov [pFig],eax
1395
	stdcall sel_points_get_count,eax
1396
	or eax,eax
1397
	jz .no_point
1398
	mov [nDel],eax
1399
 
1400
	;проверяем выделенные точки
1401
	mov ebx,[pFig]
1402
	mov ecx,[ebx+Figure.PoiCount]
1403
	or ecx,ecx
1404
	jz .no_point
1405
 
1406
	cmp ecx,eax
1407
	jle .no_all
1408
 
1409
	stdcall found_parent_obj,[pFig]
1410
	or eax,eax
1411
	jz .end_f ;if not found
1412
		mov edi,[ebx+Figure.PoiData]
1413
		mov edx,[ebx+Figure.PoiCount]
1414
		imul edx,sizeof.Point
1415
		add edx,edi
1416
 
1417
		.cycle0: ;1-я выделенная точка
1418
			cmp edi,edx
1419
			jge .end0
1420
			bt dword[edi+Point.Prop],PROP_BIT_SELECT
1421
			jc .cycle0end
1422
				add edi,sizeof.Point
1423
				jmp .cycle0
1424
		.cycle0end:
1425
 
1426
		mov esi,edi ;следущая 1-я не выделенная точка
1427
		add esi,sizeof.Point
1428
		.cycle1:
1429
			cmp esi,edx
1430
			jge .end0
1431
			bt dword[esi+Point.Prop],PROP_BIT_SELECT
1432
			jnc .cycle1end
1433
				add esi,sizeof.Point
1434
				jmp .cycle1
1435
		.cycle1end:
1436
 
1437
		mov ecx,sizeof.Point
1438
		rep movsb ;замена выделенной точки
1439
		bts dword[esi+Point.Prop-sizeof.Point],PROP_BIT_SELECT ;ставим выделение на точку, что-бы потом ее удалить
1440
 
1441
		jmp .cycle0
1442
		.end0:
1443
 
1444
		;обновление памяти
1445
		mov eax,[ebx+Figure.PoiCount]
1446
		sub eax,[nDel]
1447
		mov [ebx+Figure.PoiCount],eax
1448
		imul eax,sizeof.Point
1449
		stdcall mem.ReAlloc,[ebx+Figure.PoiData],eax
1450
		mov [ebx+Figure.PoiData],eax
1451
 
1452
		;перерасчет размеров фигуры
1453
		stdcall found_parent_obj,ebx ;get figure number in ecx
1454
		stdcall figure_update_coords,ObjData,ecx
1455
 
1456
		;для обновления по таймеру
1457
		mov dword[offs_last_timer],0
1458
		jmp .end_f
1459
 
1460
	.no_all:
1461
		notify_window_run txt_err_no_point_del
1462
		jmp .end_f
1463
	.no_point:
1464
		notify_window_run txt_err_no_point_sel
1465
	.end_f:
1466
	popad
1467
	ret
1468
endp
1469
 
1470
align 4
1471
proc but_sel_points_all uses eax ecx
1472
	stdcall [tl_node_get_data],tree1
1473
	or eax,eax
1474
	jz .no_point
1475
	cmp [eax+Figure.OType],'Fig'
1476
	jne .no_point
1477
 
1478
	mov ecx,[eax+Figure.PoiCount]
1479
	or ecx,ecx
1480
	jz .no_point
1481
	mov eax,[eax+Figure.PoiData]
7415 IgorA 1482
	.cycle0: ;цикл для выделенния точек
7360 IgorA 1483
		bts dword[eax+Point.Prop],PROP_BIT_SELECT
1484
		add eax,sizeof.Point
1485
		loop .cycle0
1486
	;для обновления по таймеру
1487
	mov dword[offs_last_timer],0
1488
	.no_point:
1489
	ret
1490
endp
1491
 
1492
align 4
7415 IgorA 1493
proc but_sel_points_align_coord_xmin
1494
pushad
1495
	stdcall [tl_node_get_data],tree1
1496
	or eax,eax
1497
	jz .no_point
1498
	cmp [eax+Figure.OType],'Fig'
1499
	jne .no_point
1500
 
1501
	mov ebx,eax
1502
	stdcall sel_points_get_count,eax
1503
	cmp eax,1
1504
	jle .no_point
1505
	mov ecx,[ebx+Figure.PoiCount]
1506
	or ecx,ecx
1507
	jz .no_point
1508
	cmp eax,ecx
1509
	je .no_point ;если выделенны все точки, что-бы не портить контур
1510
 
1511
	mov edx,ecx
1512
	imul edx,sizeof.Point
1513
	mov ebx,[ebx+Figure.PoiData]
1514
	add edx,ebx
1515
align 4
1516
	.cycle0: ;1-я выделенная точка
1517
		cmp ebx,edx
1518
		jge .no_point
1519
		bt dword[ebx+Point.Prop],PROP_BIT_SELECT
1520
		jc .cycle0end
1521
		add ebx,sizeof.Point
1522
		jmp .cycle0
1523
	.cycle0end:
1524
	lea esi,[ebx+Point.CoordX]
1525
	mov edi,Data_Double
1526
	movsd
1527
	movsd
1528
	finit
1529
	fld qword[Data_Double]
1530
align 4
1531
	.cycle1: ;цикл для нахождения min(Point.CoordX)
1532
		bt dword[ebx+Point.Prop],PROP_BIT_SELECT
1533
		jnc .no_sel
1534
			fcom qword[ebx+Point.CoordX]
1535
			fstsw ax
1536
			sahf
1537
			jbe .no_sel
1538
				;if (st0>Point.CoordX)
1539
				ffree st0
1540
				fincstp
1541
				fld qword[ebx+Point.CoordX]
1542
		.no_sel:
1543
		add ebx,sizeof.Point
1544
		cmp ebx,edx
1545
		jl .cycle1
1546
	fstp qword[Data_Double]
1547
align 4
1548
	.cycle2: ;цикл для присваивания всем Point.CoordX = min(Point.CoordX)
1549
		sub edx,sizeof.Point
1550
		bt dword[edx+Point.Prop],PROP_BIT_SELECT
1551
		jnc @f
1552
			mov esi,Data_Double
1553
			lea edi,[edx+Point.CoordX]
1554
			movsd
1555
			movsd
1556
		@@:
1557
		loop .cycle2
1558
	;для обновления по таймеру
1559
	mov dword[offs_last_timer],0
1560
	.no_point:
1561
popad
1562
	ret
1563
endp
1564
 
1565
align 4
1566
proc but_sel_points_align_coord_ymin
1567
pushad
1568
	stdcall [tl_node_get_data],tree1
1569
	or eax,eax
1570
	jz .no_point
1571
	cmp [eax+Figure.OType],'Fig'
1572
	jne .no_point
1573
 
1574
	mov ebx,eax
1575
	stdcall sel_points_get_count,eax
1576
	cmp eax,1
1577
	jle .no_point
1578
	mov ecx,[ebx+Figure.PoiCount]
1579
	or ecx,ecx
1580
	jz .no_point
1581
	cmp eax,ecx
1582
	je .no_point ;если выделенны все точки, что-бы не портить контур
1583
 
1584
	mov edx,ecx
1585
	imul edx,sizeof.Point
1586
	mov ebx,[ebx+Figure.PoiData]
1587
	add edx,ebx
1588
align 4
1589
	.cycle0: ;1-я выделенная точка
1590
		cmp ebx,edx
1591
		jge .no_point
1592
		bt dword[ebx+Point.Prop],PROP_BIT_SELECT
1593
		jc .cycle0end
1594
		add ebx,sizeof.Point
1595
		jmp .cycle0
1596
	.cycle0end:
1597
	lea esi,[ebx+Point.CoordY]
1598
	mov edi,Data_Double
1599
	movsd
1600
	movsd
1601
	finit
1602
	fld qword[Data_Double]
1603
align 4
1604
	.cycle1: ;цикл для нахождения min(Point.CoordY)
1605
		bt dword[ebx+Point.Prop],PROP_BIT_SELECT
1606
		jnc .no_sel
1607
			fcom qword[ebx+Point.CoordY]
1608
			fstsw ax
1609
			sahf
1610
			jbe .no_sel
1611
				;if (st0>Point.CoordY)
1612
				ffree st0
1613
				fincstp
1614
				fld qword[ebx+Point.CoordY]
1615
		.no_sel:
1616
		add ebx,sizeof.Point
1617
		cmp ebx,edx
1618
		jl .cycle1
1619
	fstp qword[Data_Double]
1620
align 4
1621
	.cycle2: ;цикл для присваивания всем Point.CoordY = min(Point.CoordY)
1622
		sub edx,sizeof.Point
1623
		bt dword[edx+Point.Prop],PROP_BIT_SELECT
1624
		jnc @f
1625
			mov esi,Data_Double
1626
			lea edi,[edx+Point.CoordY]
1627
			movsd
1628
			movsd
1629
		@@:
1630
		loop .cycle2
1631
	;для обновления по таймеру
1632
	mov dword[offs_last_timer],0
1633
	.no_point:
1634
popad
1635
	ret
1636
endp
1637
 
1638
align 4
1639
proc but_sel_points_align_coord_xmax
1640
pushad
1641
	stdcall [tl_node_get_data],tree1
1642
	or eax,eax
1643
	jz .no_point
1644
	cmp [eax+Figure.OType],'Fig'
1645
	jne .no_point
1646
 
1647
	mov ebx,eax
1648
	stdcall sel_points_get_count,eax
1649
	cmp eax,1
1650
	jle .no_point
1651
	mov ecx,[ebx+Figure.PoiCount]
1652
	or ecx,ecx
1653
	jz .no_point
1654
	cmp eax,ecx
1655
	je .no_point ;если выделенны все точки, что-бы не портить контур
1656
 
1657
	mov edx,ecx
1658
	imul edx,sizeof.Point
1659
	mov ebx,[ebx+Figure.PoiData]
1660
	add edx,ebx
1661
align 4
1662
	.cycle0: ;1-я выделенная точка
1663
		cmp ebx,edx
1664
		jge .no_point
1665
		bt dword[ebx+Point.Prop],PROP_BIT_SELECT
1666
		jc .cycle0end
1667
		add ebx,sizeof.Point
1668
		jmp .cycle0
1669
	.cycle0end:
1670
	lea esi,[ebx+Point.CoordX]
1671
	mov edi,Data_Double
1672
	movsd
1673
	movsd
1674
	finit
1675
	fld qword[Data_Double]
1676
align 4
1677
	.cycle1: ;цикл для нахождения max(Point.CoordX)
1678
		bt dword[ebx+Point.Prop],PROP_BIT_SELECT
1679
		jnc .no_sel
1680
			fcom qword[ebx+Point.CoordX]
1681
			fstsw ax
1682
			sahf
1683
			jae .no_sel
1684
				;if (st0
1685
				ffree st0
1686
				fincstp
1687
				fld qword[ebx+Point.CoordX]
1688
		.no_sel:
1689
		add ebx,sizeof.Point
1690
		cmp ebx,edx
1691
		jl .cycle1
1692
	fstp qword[Data_Double]
1693
align 4
1694
	.cycle2: ;цикл для присваивания всем Point.CoordX = max(Point.CoordX)
1695
		sub edx,sizeof.Point
1696
		bt dword[edx+Point.Prop],PROP_BIT_SELECT
1697
		jnc @f
1698
			mov esi,Data_Double
1699
			lea edi,[edx+Point.CoordX]
1700
			movsd
1701
			movsd
1702
		@@:
1703
		loop .cycle2
1704
	;для обновления по таймеру
1705
	mov dword[offs_last_timer],0
1706
	.no_point:
1707
popad
1708
	ret
1709
endp
1710
 
1711
align 4
1712
proc but_sel_points_align_coord_ymax
1713
pushad
1714
	stdcall [tl_node_get_data],tree1
1715
	or eax,eax
1716
	jz .no_point
1717
	cmp [eax+Figure.OType],'Fig'
1718
	jne .no_point
1719
 
1720
	mov ebx,eax
1721
	stdcall sel_points_get_count,eax
1722
	cmp eax,1
1723
	jle .no_point
1724
	mov ecx,[ebx+Figure.PoiCount]
1725
	or ecx,ecx
1726
	jz .no_point
1727
	cmp eax,ecx
1728
	je .no_point ;если выделенны все точки, что-бы не портить контур
1729
 
1730
	mov edx,ecx
1731
	imul edx,sizeof.Point
1732
	mov ebx,[ebx+Figure.PoiData]
1733
	add edx,ebx
1734
align 4
1735
	.cycle0: ;1-я выделенная точка
1736
		cmp ebx,edx
1737
		jge .no_point
1738
		bt dword[ebx+Point.Prop],PROP_BIT_SELECT
1739
		jc .cycle0end
1740
		add ebx,sizeof.Point
1741
		jmp .cycle0
1742
	.cycle0end:
1743
	lea esi,[ebx+Point.CoordY]
1744
	mov edi,Data_Double
1745
	movsd
1746
	movsd
1747
	finit
1748
	fld qword[Data_Double]
1749
align 4
1750
	.cycle1: ;цикл для нахождения max(Point.CoordY)
1751
		bt dword[ebx+Point.Prop],PROP_BIT_SELECT
1752
		jnc .no_sel
1753
			fcom qword[ebx+Point.CoordY]
1754
			fstsw ax
1755
			sahf
1756
			jae .no_sel
1757
				;if (st0
1758
				ffree st0
1759
				fincstp
1760
				fld qword[ebx+Point.CoordY]
1761
		.no_sel:
1762
		add ebx,sizeof.Point
1763
		cmp ebx,edx
1764
		jl .cycle1
1765
	fstp qword[Data_Double]
1766
align 4
1767
	.cycle2: ;цикл для присваивания всем Point.CoordY = max(Point.CoordY)
1768
		sub edx,sizeof.Point
1769
		bt dword[edx+Point.Prop],PROP_BIT_SELECT
1770
		jnc @f
1771
			mov esi,Data_Double
1772
			lea edi,[edx+Point.CoordY]
1773
			movsd
1774
			movsd
1775
		@@:
1776
		loop .cycle2
1777
	;для обновления по таймеру
1778
	mov dword[offs_last_timer],0
1779
	.no_point:
1780
popad
1781
	ret
1782
endp
1783
 
1784
align 4
7360 IgorA 1785
proc but_restore_zoom uses eax
1786
	stdcall [tl_node_get_data],tree1
1787
	or eax,eax
1788
	jz .end_f
1789
	cmp [eax+Figure.OType],'Fig'
1790
	je @f
1791
	cmp [eax+Figure.OType],'Obj'
1792
	je .end0
1793
		jmp .end_f
1794
	.end0:
1795
		mov eax,ObjData
1796
	@@:
1797
		finit
1798
		fld1
1799
		fstp qword[eax+Figure.MScale]
1800
		mov dword[eax+Figure.MCentrX],0
1801
		mov dword[eax+Figure.MCentrY],0
1802
		mov dword[offs_last_timer],0
1803
	.end_f:
1804
	ret
1805
endp
1806
 
1807
align 4
1808
but_sel_figure_move_down:
1809
	pushad
1810
	stdcall [tl_node_get_data],tree1
1811
	or eax,eax
1812
	jz .end_fblo
1813
	cmp [eax+Figure.OType],'Fig'
1814
	jne .end_fblo
1815
		stdcall found_parent_obj,eax
1816
		or eax,eax
1817
		jz .end_f ;if not found
1818
		inc ecx
1819
		cmp ecx,[eax+Object.FigCount]
1820
		jge .fig_is_last ;если фигура в конце списка
1821
		mov ebx,[eax+Object.FigData]
1822
		mov edx,[ebx+4*ecx] ;передвигаемая фигура
1823
		mov edi,[ebx+4*ecx-4]
1824
		;меняем фигуры местами
1825
		mov [ebx+4*ecx],edi
1826
		mov [ebx+4*ecx-4],edx
1827
		;меняем фигуры в списке
1828
		stdcall [tl_node_move_down],tree1
1829
		jmp .end_f
1830
	.fig_is_last:
1831
		notify_window_run txt_err_figure_is_last
1832
		jmp .end_f
1833
	.end_fblo:
1834
		notify_window_run txt_err_no_figure_select
1835
	.end_f:
1836
	popad
1837
	ret
1838
 
1839
;description:
1840
; запуск окна создания/редактирования точки
1841
align 4
1842
but_dlg_point_coords:
1843
	cmp byte[wnd_run_prop],0
1844
	jne .end_f
1845
pushad
1846
	stdcall [tl_node_get_data],tree1
1847
	or eax,eax
1848
	jz .end_fblo
1849
	cmp [eax+Figure.OType],'Fig'
1850
	jne .end_fblo
1851
	mov [wnd_pFig],eax ;фигура
1852
	stdcall sel_points_get_count,eax
1853
	cmp eax,1
1854
	jne .no_select_1
1855
		stdcall found_parent_obj,[wnd_pFig]
1856
		or eax,eax
1857
		jz .end0 ;if not found
1858
 
1859
		mov [wnd_pObj],eax ;obj
1860
		mov [wnd_FigN],ecx ;fig number
1861
		stdcall sel_points_get_first,[wnd_pFig]
1862
		mov [wnd_pPoi],eax
1863
		mov edx,[wnd_pFig]
1864
		sub eax,[edx+Figure.PoiData]
1865
		xor edx,edx
1866
		mov ecx,sizeof.Point
1867
		div ecx
1868
		jmp .end1
1869
	.no_select_1:
1870
	or eax,eax
1871
	jnz .end_fblo
1872
		stdcall found_parent_obj,[wnd_pFig]
1873
		or eax,eax
1874
		jz .end0 ;if not found
1875
 
1876
		mov [wnd_pObj],eax ;obj
1877
		mov [wnd_FigN],ecx ;fig number
1878
		xor eax,eax
1879
		mov [wnd_pPoi],eax
1880
		mov edx,[wnd_pFig]
1881
		mov eax,[edx+Figure.PoiCount]
1882
	.end1:
1883
		mov [wnd_PoiN],eax
1884
		mcall SF_CREATE_THREAD,1,start_prop,thread_coords
1885
		jmp .end0
1886
	.end_fblo:
1887
		notify_window_run txt_err_no_1_point_sel
1888
		;jmp @f
1889
	;.end_fblo:
1890
		;notify_window_run txt_err_...
1891
	.end0:
1892
popad
1893
	.end_f:
1894
	ret
1895
 
1896
align 4
1897
but_dlg_opt_scale:
1898
	cmp byte[wnd_run_scale],0
1899
	jne .end_f
1900
pushad
1901
	mcall SF_CREATE_THREAD,1,start_scale,thread_scale
1902
popad
1903
	.end_f:
1904
	ret
1905
 
1906
 
1907
 
1908
;input:
1909
; buf - указатель на строку, число должно быть в 10 или 16 ричном виде
1910
;output:
1911
; eax - число
1912
align 4
1913
proc conv_str_to_int uses ebx ecx esi, buf:dword
1914
	xor eax,eax
1915
	xor ebx,ebx
1916
	mov esi,[buf]
1917
 
1918
	;на случай если перед числом находятся пробелы
1919
	@@:
1920
	cmp byte[esi],' '
1921
	jne @f
1922
		inc esi
1923
		jmp @b
1924
	@@:
1925
 
1926
	;определение отрицательных чисел
1927
	xor ecx,ecx
1928
	inc ecx
1929
	cmp byte[esi],'-'
1930
	jne @f
1931
		dec ecx
1932
		inc esi
1933
	@@:
1934
 
1935
	cmp word[esi],'0x'
1936
	je .load_digit_16
1937
 
1938
	.load_digit_10: ;считывание 10-тичных цифр
1939
		mov bl,byte[esi]
1940
		cmp bl,'0'
1941
		jl @f
1942
		cmp bl,'9'
1943
		jg @f
1944
			sub bl,'0'
1945
			imul eax,10
1946
			add eax,ebx
1947
			inc esi
1948
			jmp .load_digit_10
1949
	jmp @f
1950
 
1951
	.load_digit_16: ;считывание 16-ричных цифр
1952
		add esi,2
1953
	.cycle_16:
1954
		mov bl,byte[esi]
1955
		cmp bl,'0'
1956
		jl @f
1957
		cmp bl,'f'
1958
		jg @f
1959
		cmp bl,'9'
1960
		jle .us1
1961
			cmp bl,'A'
1962
			jl @f ;отсеиваем символы >'9' и <'A'
1963
		.us1: ;составное условие
1964
		cmp bl,'F'
1965
		jle .us2
1966
			cmp bl,'a'
1967
			jl @f ;отсеиваем символы >'F' и <'a'
1968
			sub bl,32 ;переводим символы в верхний регистр, для упрощения их последущей обработки
1969
		.us2: ;составное условие
1970
			sub bl,'0'
1971
			cmp bl,9
1972
			jle .cor1
1973
				sub bl,7 ;convert 'A' to '10'
1974
			.cor1:
1975
			shl eax,4
1976
			add eax,ebx
1977
			inc esi
1978
			jmp .cycle_16
1979
	@@:
1980
	cmp ecx,0 ;если число отрицательное
1981
	jne @f
1982
		sub ecx,eax
1983
		mov eax,ecx
1984
	@@:
1985
	ret
1986
endp
1987
 
1988
 
1989
;данные для диалога открытия файлов
1990
align 4
1991
OpenDialog_data:
1992
.type			dd 0 ;0 - открыть, 1 - сохранить, 2 - выбрать дтректорию
1993
.procinfo		dd procinfo	;+4
1994
.com_area_name		dd communication_area_name	;+8
1995
.com_area		dd 0	;+12
1996
.opendir_path		dd plugin_path	;+16
1997
.dir_default_path	dd default_dir ;+20
1998
.start_path		dd file_name ;+24 путь к диалогу открытия файлов
1999
.draw_window		dd draw_window	;+28
2000
.status 		dd 0	;+32
2001
.openfile_path		dd openfile_path	;+36 путь к открываемому файлу
2002
.filename_area		dd filename_area	;+40
2003
.filter_area		dd Filter
2004
.x:
2005
.x_size 		dw 420 ;+48 ; Window X size
2006
.x_start		dw 10 ;+50 ; Window X position
2007
.y:
2008
.y_size 		dw 320 ;+52 ; Window y size
2009
.y_start		dw 10 ;+54 ; Window Y position
2010
 
2011
default_dir db '/rd/1',0
2012
 
2013
communication_area_name:
2014
	db 'FFFFFFFF_open_dialog',0
2015
open_dialog_name:
2016
	db 'opendial',0
2017
communication_area_default_path:
2018
	db '/rd/1/File managers/',0
2019
 
2020
Filter:
2021
dd Filter.end - Filter ;.1
2022
.1:
2023
db 'NC',0
2024
db 'PNG',0
2025
.end:
2026
db 0
2027
 
2028
 
2029
 
2030
head_f_i:
2031
head_f_l db 'Системная ошибка',0
2032
 
2033
system_dir_0 db '/sys/lib/'
2034
lib_name_0 db 'proc_lib.obj',0
2035
err_message_found_lib_0 db 'Не найдена библиотека ',39,'proc_lib.obj',39,0
2036
err_message_import_0 db 'Ошибка при импорте библиотеки ',39,'proc_lib.obj',39,0
2037
 
2038
system_dir_1 db '/sys/lib/'
2039
lib_name_1 db 'libimg.obj',0
2040
err_message_found_lib_1 db 'Не найдена библиотека ',39,'libimg.obj',39,0
2041
err_message_import_1 db 'Ошибка при импорте библиотеки ',39,'libimg.obj',39,0
2042
 
2043
system_dir_2 db '/sys/lib/'
2044
lib_name_2 db 'buf2d.obj',0
2045
err_msg_found_lib_2 db 'Не найдена библиотека ',39,'buf2d.obj',39,0
2046
err_msg_import_2 db 'Ошибка при импорте библиотеки ',39,'buf2d',39,0
2047
 
2048
system_dir_3 db '/sys/lib/'
2049
lib_name_3 db 'box_lib.obj',0
2050
err_msg_found_lib_3 db 'Не найдена библиотека ',39,'box_lib.obj',39,0
2051
err_msg_import_3 db 'Ошибка при импорте библиотеки ',39,'box_lib',39,0
2052
 
2053
l_libs_start:
2054
	lib_0 l_libs lib_name_0, sys_path, file_name, system_dir_0,\
2055
		err_message_found_lib_0, head_f_l, proclib_import,err_message_import_0, head_f_i
2056
	lib_1 l_libs lib_name_1, sys_path, file_name, system_dir_1,\
2057
		err_message_found_lib_1, head_f_l, import_libimg, err_message_import_1, head_f_i
2058
	lib_2 l_libs lib_name_2, sys_path, library_path, system_dir_2,\
2059
		err_msg_found_lib_2,head_f_l,import_buf2d,err_msg_import_2,head_f_i
2060
	lib_3 l_libs lib_name_3, sys_path, file_name,  system_dir_3,\
2061
		err_msg_found_lib_3, head_f_l, import_box_lib,err_msg_import_3,head_f_i
2062
l_libs_end:
2063
 
2064
align 4
2065
import_libimg:
2066
	dd alib_init1
2067
	img_is_img  dd aimg_is_img
2068
	img_info    dd aimg_info
2069
	img_from_file dd aimg_from_file
2070
	img_to_file dd aimg_to_file
2071
	img_from_rgb dd aimg_from_rgb
2072
	img_to_rgb  dd aimg_to_rgb
2073
	img_to_rgb2 dd aimg_to_rgb2
2074
	img_decode  dd aimg_decode
2075
	img_encode  dd aimg_encode
2076
	img_create  dd aimg_create
2077
	img_destroy dd aimg_destroy
2078
	img_destroy_layer dd aimg_destroy_layer
2079
	img_count   dd aimg_count
2080
	img_lock_bits dd aimg_lock_bits
2081
	img_unlock_bits dd aimg_unlock_bits
2082
	img_flip    dd aimg_flip
2083
	img_flip_layer dd aimg_flip_layer
2084
	img_rotate  dd aimg_rotate
2085
	img_rotate_layer dd aimg_rotate_layer
2086
	img_draw    dd aimg_draw
2087
 
2088
	dd 0,0
2089
	alib_init1   db 'lib_init',0
2090
	aimg_is_img  db 'img_is_img',0 ;определяет по данным, может ли библиотека сделать из них изображение
2091
	aimg_info    db 'img_info',0
2092
	aimg_from_file db 'img_from_file',0
2093
	aimg_to_file db 'img_to_file',0
2094
	aimg_from_rgb db 'img_from_rgb',0
2095
	aimg_to_rgb  db 'img_to_rgb',0 ;преобразование изображения в данные RGB
2096
	aimg_to_rgb2 db 'img_to_rgb2',0
2097
	aimg_decode  db 'img_decode',0 ;автоматически определяет формат графических данных
2098
	aimg_encode  db 'img_encode',0
2099
	aimg_create  db 'img_create',0
2100
	aimg_destroy db 'img_destroy',0
2101
	aimg_destroy_layer db 'img_destroy_layer',0
2102
	aimg_count   db 'img_count',0
2103
	aimg_lock_bits db 'img_lock_bits',0
2104
	aimg_unlock_bits db 'img_unlock_bits',0
2105
	aimg_flip    db 'img_flip',0
2106
	aimg_flip_layer db 'img_flip_layer',0
2107
	aimg_rotate  db 'img_rotate',0
2108
	aimg_rotate_layer db 'img_rotate_layer',0
2109
	aimg_draw    db 'img_draw',0
2110
 
2111
align 4
2112
proclib_import: ;описание экспортируемых функций
2113
	OpenDialog_Init dd aOpenDialog_Init
2114
	OpenDialog_Start dd aOpenDialog_Start
2115
dd 0,0
2116
	aOpenDialog_Init db 'OpenDialog_init',0
2117
	aOpenDialog_Start db 'OpenDialog_start',0
2118
 
2119
align 4
2120
import_buf2d:
2121
	init dd sz_init
2122
	buf2d_create dd sz_buf2d_create
2123
	buf2d_create_f_img dd sz_buf2d_create_f_img
2124
	buf2d_clear dd sz_buf2d_clear
2125
	buf2d_draw dd sz_buf2d_draw
2126
	buf2d_delete dd sz_buf2d_delete
2127
	buf2d_resize dd sz_buf2d_resize
2128
	buf2d_line dd sz_buf2d_line
2129
	buf2d_line_sm dd sz_buf2d_line_sm
2130
	buf2d_rect_by_size dd sz_buf2d_rect_by_size
2131
	buf2d_filled_rect_by_size dd sz_buf2d_filled_rect_by_size
2132
	buf2d_circle dd sz_buf2d_circle
2133
	buf2d_img_hdiv2 dd sz_buf2d_img_hdiv2
2134
	buf2d_img_wdiv2 dd sz_buf2d_img_wdiv2
2135
	buf2d_conv_24_to_8 dd sz_buf2d_conv_24_to_8
2136
	buf2d_conv_24_to_32 dd sz_buf2d_conv_24_to_32
2137
	buf2d_bit_blt dd sz_buf2d_bit_blt
2138
	buf2d_bit_blt_transp dd sz_buf2d_bit_blt_transp
2139
	buf2d_bit_blt_alpha dd sz_buf2d_bit_blt_alpha
2140
	buf2d_curve_bezier dd sz_buf2d_curve_bezier
2141
	buf2d_convert_text_matrix dd sz_buf2d_convert_text_matrix
2142
	buf2d_draw_text dd sz_buf2d_draw_text
2143
	buf2d_crop_color dd sz_buf2d_crop_color
2144
	buf2d_flip_h dd sz_buf2d_flip_h
2145
	buf2d_flip_v dd sz_buf2d_flip_v
2146
	buf2d_offset_h dd sz_buf2d_offset_h
2147
	buf2d_flood_fill dd sz_buf2d_flood_fill
2148
	buf2d_set_pixel dd sz_buf2d_set_pixel
2149
	dd 0,0
2150
	sz_init db 'lib_init',0
2151
	sz_buf2d_create db 'buf2d_create',0
2152
	sz_buf2d_create_f_img db 'buf2d_create_f_img',0
2153
	sz_buf2d_clear db 'buf2d_clear',0
2154
	sz_buf2d_draw db 'buf2d_draw',0
2155
	sz_buf2d_delete db 'buf2d_delete',0
2156
	sz_buf2d_resize db 'buf2d_resize',0
2157
	sz_buf2d_line db 'buf2d_line',0
2158
	sz_buf2d_line_sm db 'buf2d_line_sm',0
2159
	sz_buf2d_rect_by_size db 'buf2d_rect_by_size',0
2160
	sz_buf2d_filled_rect_by_size db 'buf2d_filled_rect_by_size',0
2161
	sz_buf2d_circle db 'buf2d_circle',0
2162
	sz_buf2d_img_hdiv2 db 'buf2d_img_hdiv2',0
2163
	sz_buf2d_img_wdiv2 db 'buf2d_img_wdiv2',0
2164
	sz_buf2d_conv_24_to_8 db 'buf2d_conv_24_to_8',0
2165
	sz_buf2d_conv_24_to_32 db 'buf2d_conv_24_to_32',0
2166
	sz_buf2d_bit_blt db 'buf2d_bit_blt',0
2167
	sz_buf2d_bit_blt_transp db 'buf2d_bit_blt_transp',0
2168
	sz_buf2d_bit_blt_alpha db 'buf2d_bit_blt_alpha',0
2169
	sz_buf2d_curve_bezier db 'buf2d_curve_bezier',0
2170
	sz_buf2d_convert_text_matrix db 'buf2d_convert_text_matrix',0
2171
	sz_buf2d_draw_text db 'buf2d_draw_text',0
2172
	sz_buf2d_crop_color db 'buf2d_crop_color',0
2173
	sz_buf2d_flip_h db 'buf2d_flip_h',0
2174
	sz_buf2d_flip_v db 'buf2d_flip_v',0
2175
	sz_buf2d_offset_h db 'buf2d_offset_h',0
2176
	sz_buf2d_flood_fill db 'buf2d_flood_fill',0
2177
	sz_buf2d_set_pixel db 'buf2d_set_pixel',0
2178
 
2179
align 4
2180
import_box_lib:
2181
	dd sz_init1
2182
 
2183
	init_checkbox   dd sz_Init_checkbox
2184
	check_box_draw  dd sz_Check_box_draw
2185
	check_box_mouse dd sz_Check_box_mouse
2186
	;version_ch     dd sz_Version_ch
2187
 
2188
	option_box_draw	 dd sz_Option_box_draw
2189
	option_box_mouse dd sz_Option_box_mouse
2190
	;version_op      dd sz_Version_op
2191
 
2192
	edit_box_draw      dd sz_edit_box_draw
2193
	edit_box_key       dd sz_edit_box_key
2194
	edit_box_mouse     dd sz_edit_box_mouse
2195
	edit_box_set_text  dd sz_edit_box_set_text
2196
	scrollbar_ver_draw dd sz_scrollbar_ver_draw
2197
	scrollbar_hor_draw dd sz_scrollbar_hor_draw
2198
 
2199
	tl_data_init dd sz_tl_data_init
2200
	tl_data_clear dd sz_tl_data_clear
2201
	tl_info_clear dd sz_tl_info_clear
2202
	tl_key dd sz_tl_key
2203
	tl_mouse dd sz_tl_mouse
2204
	tl_draw dd sz_tl_draw
2205
	tl_info_undo dd sz_tl_info_undo
2206
	tl_info_redo dd sz_tl_info_redo
2207
	tl_node_add dd sz_tl_node_add
2208
	tl_node_set_data dd sz_tl_node_set_data
2209
	tl_node_get_data dd sz_tl_node_get_data
2210
	tl_node_delete dd sz_tl_node_delete
2211
	tl_node_move_up dd sz_tl_node_move_up
2212
	tl_node_move_down dd sz_tl_node_move_down
2213
	tl_cur_beg dd sz_tl_cur_beg
2214
	tl_cur_next dd sz_tl_cur_next
2215
	tl_cur_perv dd sz_tl_cur_perv
2216
	tl_node_close_open dd sz_tl_node_close_open
2217
	tl_node_lev_inc dd sz_tl_node_lev_inc
2218
	tl_node_lev_dec dd sz_tl_node_lev_dec
2219
	tl_node_poi_get_info dd sz_tl_node_poi_get_info
2220
	tl_node_poi_get_next_info dd sz_tl_node_poi_get_next_info
2221
	tl_node_poi_get_data dd sz_tl_node_poi_get_data
2222
 
2223
	dd 0,0
2224
	sz_init1 db 'lib_init',0
2225
 
2226
	sz_Init_checkbox   db 'init_checkbox2',0
2227
	sz_Check_box_draw  db 'check_box_draw2',0
2228
	sz_Check_box_mouse db 'check_box_mouse2',0
2229
	;sz_Version_ch     db 'version_ch2',0
2230
 
2231
	sz_Option_box_draw	db 'option_box_draw',0
2232
	sz_Option_box_mouse	db 'option_box_mouse',0
2233
	;sz_Version_op      db 'version_op',0
2234
 
2235
	sz_edit_box_draw      db 'edit_box',0
2236
	sz_edit_box_key       db 'edit_box_key',0
2237
	sz_edit_box_mouse     db 'edit_box_mouse',0
2238
	sz_edit_box_set_text  db 'edit_box_set_text',0
2239
	sz_scrollbar_ver_draw db 'scrollbar_v_draw',0
2240
	sz_scrollbar_hor_draw db 'scrollbar_h_draw',0
2241
 
2242
	sz_tl_data_init db 'tl_data_init',0
2243
	sz_tl_data_clear db 'tl_data_clear',0
2244
	sz_tl_info_clear db 'tl_info_clear',0
2245
	sz_tl_key db 'tl_key',0
2246
	sz_tl_mouse db 'tl_mouse',0
2247
	sz_tl_draw db 'tl_draw',0
2248
	sz_tl_info_undo db 'tl_info_undo',0
2249
	sz_tl_info_redo db 'tl_info_redo',0
2250
	sz_tl_node_add db 'tl_node_add',0
2251
	sz_tl_node_set_data db 'tl_node_set_data',0
2252
	sz_tl_node_get_data db 'tl_node_get_data',0
2253
	sz_tl_node_delete db 'tl_node_delete',0
2254
	sz_tl_node_move_up db 'tl_node_move_up',0
2255
	sz_tl_node_move_down db 'tl_node_move_down',0
2256
	sz_tl_cur_beg db 'tl_cur_beg',0
2257
	sz_tl_cur_next db 'tl_cur_next',0
2258
	sz_tl_cur_perv db 'tl_cur_perv',0
2259
	sz_tl_node_close_open db 'tl_node_close_open',0
2260
	sz_tl_node_lev_inc db 'tl_node_lev_inc',0
2261
	sz_tl_node_lev_dec db 'tl_node_lev_dec',0
2262
	sz_tl_node_poi_get_info db 'tl_node_poi_get_info',0
2263
	sz_tl_node_poi_get_next_info db 'tl_node_poi_get_next_info',0
2264
	sz_tl_node_poi_get_data db 'tl_node_poi_get_data',0
2265
 
2266
align 4
2267
mouse_dd dd 0
2268
last_time dd 0
2269
 
2270
align 16
2271
sc system_colors
2272
 
2273
align 16
2274
procinfo process_information
2275
 
2276
align 4
2277
buf_0: dd 0 ;указатель на буфер изображения
2278
.l: dw 205 ;+4 left
2279
.t: dw 35 ;+6 top
2280
.w: dd 384 ;+8 w
2281
.h: dd 350 ;+12 h
2282
.color: dd 0xffffd0 ;+16 color
2283
	db 24 ;+20 bit in pixel
2284
 
2285
align 4
2286
buf_1:
2287
	dd 0 ;указатель на буфер изображения
2288
	dd 0 ;+4 left,top
2289
.w: dd 0
2290
.h: dd 0,0,24 ;+12 color,bit in pixel
2291
 
2292
font_h dd 0 ;высота шрифта
2293
 
2294
align 4
2295
buf_png:
2296
	dd 0,0
2297
.w: dd 0
2298
.h: dd 0,0xffffff,24
2299
 
2300
align 4
2301
el_focus dd tree1
2302
tree1 tree_list size_one_list,1000+2, tl_key_no_edit+tl_draw_par_line,\
2303
	16,16, 0xffffff,0xb0d0ff,0x400040, 5,35,195-16,340, 16,Figure.Caption,0,\
2304
	el_focus,w_scr_t1,0
2305
 
2306
align 4
2307
w_scr_t1 scrollbar 16,0, 3,0, 15, 100, 0,0, 0,0,0, 1
2308
 
2309
;input:
2310
; eax - число
2311
; edi - буфер для строки
2312
; len - длинна буфера
2313
;output:
2314
align 4
2315
proc convert_int_to_str uses eax ecx edx edi esi, len:dword
2316
	mov esi,[len]
2317
	add esi,edi
2318
	dec esi
2319
	call .str
2320
	ret
2321
endp
2322
 
2323
align 4
2324
.str:
2325
	mov ecx,10
2326
	cmp eax,ecx
2327
	jb @f
2328
		xor edx,edx
2329
		div ecx
2330
		push edx
2331
		;dec edi  ;смещение необходимое для записи с конца строки
2332
		call .str
2333
		pop eax
2334
	@@:
2335
	cmp edi,esi
2336
	jge @f
2337
		or al,0x30
2338
		stosb
2339
		mov byte[edi],0 ;в конец строки ставим 0, что-бы не вылазил мусор
2340
	@@:
2341
	ret
2342
 
2343
align 4
2344
proc mem_copy uses ecx esi edi, destination:dword, source:dword, len:dword
2345
	cld
2346
	mov esi, dword[source]
2347
	mov edi, dword[destination]
2348
	mov ecx, dword[len]
2349
	rep movsb
2350
	ret
2351
endp
2352
 
2353
align 16
2354
i_end:
2355
	rb 2048
2356
thread_coords:
2357
	rb 2048
2358
thread_scale:
2359
	rb 2048
2360
thread_n_file:
2361
	rb 2048
2362
stacktop:
2363
	sys_path rb 1024
2364
	file_name:
2365
		rb 1024 ;4096
2366
	library_path rb 1024
2367
	plugin_path rb 4096
2368
	openfile_path rb 4096
2369
	filename_area rb 256
2370
mem:
2371