Subversion Repositories Kolibri OS

Rev

Rev 7415 | Rev 7508 | 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
7441 IgorA 17
caption db 'CNC editor 08.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
		;---
714
		stdcall FileInit,[open_file_data],[open_file_size]
715
		stdcall [buf2d_clear], buf_0, [buf_0.color] ;чистим буфер
716
		stdcall [buf2d_draw], buf_0 ;обновляем буфер на экране
717
	.end_open_file:
718
	popad
719
	ret
720
 
721
align 4
722
proc but_save_file
723
locals
724
	pCou dd ?
725
	pData dd ?
726
endl
727
	pushad
728
	copy_path open_dialog_name,communication_area_default_path,file_name,0
729
	mov [OpenDialog_data.type],1
730
	stdcall [OpenDialog_Start],OpenDialog_data
731
	cmp [OpenDialog_data.status],2
732
	je .end_save_file
733
	;код при удачном открытии диалога
734
 
735
	;*** определение примерного размера файла
736
	call get_file_save_size
737
	stdcall mem.ReAlloc,[open_file_data],ecx
738
	mov [open_file_data],eax
739
	mov [open_file_size],ecx
740
 
741
	;clear memory
742
	mov edi,eax
743
	xor eax,eax
744
	shr ecx,2
745
	rep stosd
746
 
747
	;*** пишем информацию в память
748
	mov edi,[open_file_data]
749
	mov ebx,ObjData
750
	mov edx,[ebx+Object.FigCount]
751
	or edx,edx
752
	jz .cycle1end
753
	mov esi,[ebx+Object.FigData]
754
align 4
755
	.cycle1: ;цикл по фигурам
756
		;param 1
757
		mov eax,[esi]
758
		or eax,eax
759
		jz .err_save
760
		mov eax,[eax+Figure.PoiCount]
761
		mov [pCou],eax
762
		or eax,eax
763
		jnz @f
764
			mov eax,[esi]
765
			lea eax,[eax+Figure.Caption]
766
			stdcall str_cat,edi,eax
767
			stdcall str_len,edi
768
			add edi,eax
769
			stdcall str_cat,edi,txt_nl
770
		@@:
771
		cmp dword[pCou],0
772
		je .cycle2end
773
		mov eax,[esi]
774
		mov eax,[eax+Figure.PoiData]
775
		mov [pData],eax
776
		mov word[NumberSymbolsAD],8
777
align 4
778
		.cycle2: ;цикл по точкам
779
			stdcall str_cat,edi,txt_s_poi
780
			;param 1
781
			push edi esi
782
			mov esi,[pData]
783
			lea esi,[esi+Point.CoordX]
784
			mov edi,Data_Double
785
			movsd
786
			movsd
787
			pop esi edi
788
			call DoubleFloat_to_String
789
			call String_crop_0
790
			stdcall str_cat,edi,Data_String
791
			stdcall str_cat,edi,txt_s_poi_Y
792
			;param 2
793
			push edi esi
794
			mov esi,[pData]
795
			lea esi,[esi+Point.CoordY]
796
			mov edi,Data_Double
797
			movsd
798
			movsd
799
			pop esi edi
800
			call DoubleFloat_to_String
801
			call String_crop_0
802
			stdcall str_cat,edi,Data_String
803
			;
804
			stdcall str_cat,edi,txt_nl
805
			add dword[pData],sizeof.Point
806
			dec dword[pCou]
807
			jnz .cycle2
808
		.cycle2end:
809
		add esi,4
810
		dec edx
811
		jnz .cycle1
812
	.cycle1end:
813
 
814
	jmp @f
815
	.err_save:
816
		notify_window_run txt_err_save_txt_file_1
817
	@@:
818
 
819
	;*** определение параметров файла
820
	mov edi,[open_file_data]
821
	stdcall str_len,edi
822
	;;cmp eax,[open_file_size]
823
	mov [run_file_70.Count],eax ;размер файла
824
 
825
	;*** сохраняем файл
826
	mov [run_file_70.Function], SSF_CREATE_FILE
827
	mov [run_file_70.Position], 0
828
	mov [run_file_70.Flags], 0
829
	mov ebx, dword[open_file_data]
830
	mov [run_file_70.Buffer], ebx
831
	mov byte[run_file_70+20], 0
832
	mov dword[run_file_70.FileName], openfile_path
833
	mcall SF_FILE,run_file_70
834
	or eax,eax
835
	jz .end_save_file
836
	or ebx,ebx
837
	jnz .end_save_file
838
		;сообщение о неудачном сохранении
839
		notify_window_run txt_err_save_txt_file_0
840
	.end_save_file:
841
	popad
842
	ret
843
endp
844
 
845
;output:
846
; ecx - memory size for save file
847
align 4
848
proc get_file_save_size uses eax ebx edx esi
849
	mov ecx,100 ;title
850
	mov ebx,ObjData
851
	add ecx,50 ;object
852
	mov edx,[ebx+Object.FigCount]
853
	or edx,edx
854
	jz .cycle1end
855
	mov esi,[ebx+Object.FigData]
856
align 4
857
	.cycle1: ; цикл по фигурам
858
		add ecx,80 ;figure
859
		mov eax,[esi]
860
		or eax,eax
861
		jz @f
862
			mov eax,[eax+Figure.PoiCount]
863
			imul eax,70
864
			add ecx,eax ;points
865
		@@:
866
		add esi,4
867
		dec edx
868
		jnz .cycle1
869
	.cycle1end:
870
	ret
871
endp
872
 
873
align 4
874
but_captions_on_off:
875
	xor dword[opt_draw],1
876
	mov dword[offs_last_timer],0 ;для обновления по таймеру
877
	ret
878
 
879
align 4
880
but_sel_figure_move_up:
881
	pushad
882
	stdcall [tl_node_get_data],tree1
883
	or eax,eax
884
	jz .end_fblo
885
	cmp [eax+Figure.OType],'Fig'
886
	jne .end_fblo
887
		stdcall found_parent_obj,eax
888
		or eax,eax
889
		jz .end_f ;if not found
890
		or ecx,ecx
891
		jz .fig_is_0 ;если фигура в начале списка
892
		mov ebx,[eax+Object.FigData]
893
		mov edx,[ebx+4*ecx] ;передвигаемая фигура
894
		mov edi,[ebx+4*ecx-4]
895
		;меняем фигуры местами
896
		mov [ebx+4*ecx],edi
897
		mov [ebx+4*ecx-4],edx
898
		;меняем фигуры в списке
899
		stdcall [tl_node_move_up],tree1
900
		jmp .end_f
901
	.fig_is_0:
902
		notify_window_run txt_err_figure_is_0
903
		jmp .end_f
904
	.end_fblo:
905
		notify_window_run txt_err_no_figure_select
906
	.end_f:
907
	popad
908
	ret
909
 
910
align 4
911
but_save_png:
912
	pushad
913
	stdcall [tl_node_get_data],tree1
914
	or eax,eax
915
	jz .end_save_file
916
 
917
	stdcall get_object_data,eax
918
	or ecx,ecx
919
	jz .end_oblo
920
		stdcall draw_obj2d_png,ecx
921
		jmp .beg0
922
	.end_oblo:
923
 
924
;       cmp [eax+Figure.OType],'Fig'
925
;       jne .end_fblo
926
;               stdcall draw_fig2d_png,eax
927
;               jmp .beg0
928
;       .end_fblo:
929
 
930
	jmp .end_save_file
931
	.beg0:
932
	copy_path open_dialog_name,communication_area_default_path,file_name,0
933
	mov [OpenDialog_data.type],1
934
	stdcall [OpenDialog_Start],OpenDialog_data
935
	cmp [OpenDialog_data.status],2
936
	je .end_save_file
937
		;код при удачном открытии диалога
938
		mov dword[png_data],0
939
 
940
		;create image struct
941
		stdcall [img_create], [buf_png.w], [buf_png.h], Image.bpp24
942
		mov ebx,eax
943
		test eax,eax
944
		jz @f
945
			;copy foto to image buffer
946
			mov edi,[eax+Image.Data]
947
			mov esi,[buf_png]
948
			mov ecx,[buf_png.w]
949
			mov edx,[buf_png.h]
950
			imul ecx,edx
951
			imul ecx,3
952
			shr ecx,2 ;OpenGL buffer align to 4
953
			rep movsd
954
 
955
			;encode image
956
			stdcall [img_encode], eax, LIBIMG_FORMAT_PNG, 0
957
			test eax,eax
958
			jz @f
959
				mov [png_data],eax
960
				mov [png_size],ecx
961
		@@:
962
		stdcall [img_destroy],ebx
963
 
964
	; заполняем структуру для сохранения файла
965
	mov ebx,run_file_70
966
	mov dword[ebx],SSF_CREATE_FILE
967
	mov eax,[png_size]
968
	mov [ebx+12],eax ;file size
969
	mov eax,[png_data]
970
	mov [ebx+16],eax
971
	mov dword[ebx+FileInfoBlock.FileName], openfile_path
972
 
973
	mcall SF_FILE,run_file_70
974
	test eax,eax
975
	jnz .save_error
976
			;notify_window_run openfile_path
977
			jmp @f
978
		.save_error:
979
			;сообщение о неудачном сохранении
980
			notify_window_run txt_err_save_img_file
981
		@@:
982
		mcall SF_SYS_MISC, SSF_MEM_FREE, [png_data]
983
	.end_save_file:
984
	popad
985
	ret
986
 
987
;description:
988
; выделенные точки сдвигаются вверх
989
align 4
990
proc but_sel_points_move_up
991
locals
992
	pObj dd ?
993
	pFig dd ?
994
	idFig dd ?
995
endl
996
	pushad
997
	stdcall [tl_node_get_data],tree1
998
	or eax,eax
999
	jz .no_point
1000
	cmp [eax+Figure.OType],'Fig'
1001
	jne .no_point
1002
 
1003
	mov [pFig],eax
1004
	stdcall sel_points_get_count,eax
1005
	or eax,eax
1006
	jz .no_point
1007
 
1008
	stdcall found_parent_obj,[pFig]
1009
	or eax,eax
1010
	jz .end_f ;if not found
1011
	mov [pObj],eax
1012
	mov [idFig],ecx
1013
 
1014
	;проверяем выделенные точки
1015
	mov eax,[pFig]
1016
	mov ecx,[eax+Figure.PoiCount]
1017
	or ecx,ecx
1018
	jz .no_point
1019
	mov ebx,[eax+Figure.PoiData]
1020
	xor eax,eax
1021
	.cycle0:
1022
		bt dword[ebx+Point.Prop],PROP_BIT_SELECT
1023
		jnc @f
1024
			or eax,eax
1025
			jz .point_is_0
1026
			stdcall point_move_up, [pObj],[pFig],[idFig],ebx;,eax
1027
		@@:
1028
		inc eax
1029
		add ebx,sizeof.Point
1030
		loop .cycle0
1031
 
1032
		;для обновления по таймеру
1033
		mov dword[offs_last_timer],0
1034
		jmp .end_f
1035
	.point_is_0:
1036
		notify_window_run txt_err_poi_is_0
1037
		jmp .end_f
1038
	.no_point:
1039
		notify_window_run txt_err_no_point_sel
1040
	.end_f:
1041
	popad
1042
	ret
1043
endp
1044
 
1045
;description:
1046
; выделенные точки сдвигаются вниз
1047
align 4
1048
proc but_sel_points_move_down
1049
locals
1050
	pObj dd ?
1051
	pFig dd ?
1052
	idFig dd ?
1053
endl
1054
	pushad
1055
	stdcall [tl_node_get_data],tree1
1056
	or eax,eax
1057
	jz .no_point
1058
	cmp [eax+Figure.OType],'Fig'
1059
	jne .no_point
1060
 
1061
	mov [pFig],eax
1062
	stdcall sel_points_get_count,eax
1063
	or eax,eax
1064
	jz .no_point
1065
 
1066
	stdcall found_parent_obj,[pFig]
1067
	or eax,eax
1068
	jz .end_f ;if not found
1069
	mov [pObj],eax
1070
	mov [idFig],ecx
1071
 
1072
	;проверяем выделенные точки
1073
	mov eax,[pFig]
1074
	mov ecx,[eax+Figure.PoiCount]
1075
	or ecx,ecx
1076
	jz .no_point
1077
	mov ebx,ecx
1078
	dec ebx
1079
	imul ebx,sizeof.Point
1080
	add ebx,[eax+Figure.PoiData]
1081
	.cycle0:
1082
		bt dword[ebx+Point.Prop],PROP_BIT_SELECT
1083
		jnc @f
1084
			cmp ecx,[eax+Figure.PoiCount]
1085
			je .point_is_last
1086
			mov edi,ebx
1087
			add edi,sizeof.Point
1088
			stdcall point_move_up, [pObj],[pFig],[idFig],edi;,ecx
1089
		@@:
1090
		sub ebx,sizeof.Point
1091
		loop .cycle0
1092
 
1093
		;для обновления по таймеру
1094
		mov dword[offs_last_timer],0
1095
		jmp .end_f
1096
	.point_is_last:
1097
		notify_window_run txt_err_poi_is_last
1098
		jmp .end_f
1099
	.no_point:
1100
		notify_window_run txt_err_no_point_sel
1101
	.end_f:
1102
	popad
1103
	ret
1104
endp
1105
 
1106
;description:
1107
; выделение выбранной точки сдвигается вверх
1108
align 4
1109
proc but_selection_move_up
1110
locals
1111
	pFig dd ?
1112
endl
1113
	pushad
1114
	stdcall [tl_node_get_data],tree1
1115
	or eax,eax
1116
	jz .end_fblo
1117
	cmp [eax+Figure.OType],'Fig'
1118
	jne .end_fblo
1119
 
1120
	mov [pFig],eax
1121
	stdcall sel_points_get_count,eax
1122
	cmp eax,1
1123
	jne .no_point
1124
 
1125
	;проверяем выделенные точки
1126
	mov eax,[pFig]
1127
	mov ecx,[eax+Figure.PoiCount]
1128
	or ecx,ecx
1129
	jz .no_point
1130
	dec ecx
1131
	jecxz .end_f
1132
	mov ebx,[eax+Figure.PoiData]
1133
	.cycle0:
1134
		add ebx,sizeof.Point
1135
		bt dword[ebx+Point.Prop],PROP_BIT_SELECT
1136
		jnc @f
1137
			btr dword[ebx+Point.Prop],PROP_BIT_SELECT
1138
			bts dword[ebx+Point.Prop-sizeof.Point],PROP_BIT_SELECT
1139
			xor ecx,ecx
1140
			inc ecx ;ecx = 1 - for exit from cycle
1141
		@@:
1142
		loop .cycle0
1143
 
1144
		;для обновления по таймеру
1145
		mov dword[offs_last_timer],0
1146
		jmp .end_f
1147
	.no_point:
1148
		notify_window_run txt_err_no_point_sel_1
1149
		jmp .end_f
1150
	.end_fblo:
1151
		;notify_window_run txt_err_no_figure_select
1152
	.end_f:
1153
	popad
1154
	ret
1155
endp
1156
 
1157
;description:
1158
; выделение выбранной точки сдвигается вниз
1159
align 4
1160
proc but_selection_move_down
1161
locals
1162
	pFig dd ?
1163
endl
1164
	pushad
1165
	stdcall [tl_node_get_data],tree1
1166
	or eax,eax
1167
	jz .end_fblo
1168
	cmp [eax+Figure.OType],'Fig'
1169
	jne .end_fblo
1170
 
1171
	mov [pFig],eax
1172
	stdcall sel_points_get_count,eax
1173
	cmp eax,1
1174
	jne .no_point
1175
 
1176
	;проверяем выделенные точки
1177
	mov eax,[pFig]
1178
	mov ecx,[eax+Figure.PoiCount]
1179
	or ecx,ecx
1180
	jz .no_point
1181
	dec ecx
1182
	jecxz .end_f
1183
	mov ebx,[eax+Figure.PoiData]
1184
	.cycle0:
1185
		bt dword[ebx+Point.Prop],PROP_BIT_SELECT
1186
		jnc @f
1187
			btr dword[ebx+Point.Prop],PROP_BIT_SELECT
1188
			bts dword[ebx+Point.Prop+sizeof.Point],PROP_BIT_SELECT
1189
			xor ecx,ecx
1190
			inc ecx ;ecx = 1 - for exit from cycle
1191
		@@:
1192
		add ebx,sizeof.Point
1193
		loop .cycle0
1194
 
1195
		;для обновления по таймеру
1196
		mov dword[offs_last_timer],0
1197
		jmp .end_f
1198
	.no_point:
1199
		notify_window_run txt_err_no_point_sel_1
1200
		jmp .end_f
1201
	.end_fblo:
1202
		;notify_window_run txt_err_no_figure_select
1203
	.end_f:
1204
	popad
1205
	ret
1206
endp
1207
 
1208
;output:
1209
; eax - couunt new points
1210
align 4
1211
proc but_clipboard_copy_points uses ebx ecx edx edi esi
1212
locals
1213
	pData dd 0
1214
	pBuf dd 0
1215
endl
1216
	stdcall [tl_node_get_data],tree1
1217
	or eax,eax
1218
	jz .no_point
1219
	cmp [eax+Figure.OType],'Fig'
1220
	jne .no_point
1221
 
1222
	mov ecx,[eax+Figure.PoiData]
1223
	mov [pData],ecx
1224
	mov ecx,[eax+Figure.PoiCount]
1225
	stdcall sel_points_get_count,eax
1226
	or eax,eax
1227
	jz .no_point
1228
	push eax
1229
		imul eax,32 ;for string 'X___.________ Y___.________^^'
1230
		stdcall mem.Alloc,eax
1231
		mov [pBuf],eax
1232
 
1233
		mov edx,eax
1234
		mov dword[edx+4],0 ;text data
1235
		mov dword[edx+8],1 ;code 866
1236
		add edx,12 ;system buffer header size
1237
		mov dword[edx],0
1238
		mov word[NumberSymbolsAD],8
1239
align 4
1240
		.cycle2: ;цикл по точкам
1241
			mov esi,[pData]
1242
			bt dword[esi+Point.Prop],PROP_BIT_SELECT
1243
			jnc .end0
1244
			stdcall str_cat,edx,txt_s_poi
1245
			;param 1
1246
			add esi,Point.CoordX
1247
			mov edi,Data_Double
1248
			movsd
1249
			movsd
1250
			call DoubleFloat_to_String
1251
			call String_crop_0
1252
			stdcall str_cat,edx,Data_String
1253
			stdcall str_cat,edx,txt_s_poi_Y
1254
			;param 2
1255
			;;mov esi,[pData]
1256
			;;lea esi,[esi+Point.CoordY]
1257
			mov edi,Data_Double
1258
			movsd
1259
			movsd
1260
			call DoubleFloat_to_String
1261
			call String_crop_0
1262
			stdcall str_cat,edx,Data_String
1263
			;
1264
			stdcall str_cat,edx,txt_nl
1265
			.end0:
1266
			add dword[pData],sizeof.Point
1267
			loop .cycle2
1268
		.cycle2end:
1269
 
1270
		mov edx,[pBuf]
1271
		add edx,12
1272
		stdcall str_len,edx
1273
		sub edx,12
1274
		mov [edx],eax
1275
		add eax,12
1276
		mov ecx,eax
1277
		mcall SF_CLIPBOARD,SSF_WRITE_CB ;,ecx,edx
1278
		stdcall mem.Free,[pBuf]
1279
	pop eax
1280
 
1281
	.no_point:
1282
	ret
1283
endp
1284
 
1285
;output:
1286
; eax - couunt new points
1287
align 4
1288
proc but_clipboard_paste_points uses ebx ecx edx esi edi
1289
locals
1290
	pFig dd ?
1291
	nCount dd ?
1292
endl
1293
	stdcall [tl_node_get_data],tree1
1294
	or eax,eax
1295
	jz .end0
1296
	cmp [eax+Figure.OType],'Fig'
1297
	jne .end0
1298
 
1299
	mov [pFig],eax
1300
 
1301
	mcall SF_CLIPBOARD,SSF_GET_SLOT_COUNT
1302
	cmp eax,1
1303
	jl .end0
1304
 
1305
	mov esi,eax
1306
	.cycle0: ;обратный цикл по слотам
1307
	dec esi ;номер текущего, проверяемого слота
1308
	mcall SF_CLIPBOARD,SSF_READ_CB,esi
1309
	cmp eax,1
1310
	je .end0
1311
	cmp eax,-1
1312
	je .end0
1313
		mov ecx,dword[eax]
1314
		cmp ecx,5 ;min text size
1315
		jl .end0
1316
		cmp dword[eax+4],0 ;text
1317
		je @f
1318
			cmp esi,1
1319
			jge .cycle0 ;если в буфере не текст, а слотов в буфере несколько, пробуем перейти к верхнему слоту
1320
			jmp .end0
1321
		@@:
1322
 
1323
	mov esi,eax
1324
	add esi,12 ;смещение начала текста в буфере
1325
	stdcall get_max_points
1326
	or eax,eax
1327
	jz .end_f
1328
		mov [nCount],eax
1329
		mov ebx,[pFig]
1330
		mov edi,[ebx+Figure.PoiCount]
1331
		add [ebx+Figure.PoiCount],eax
1332
		add eax,edi
1333
		imul eax,sizeof.Point
1334
		stdcall mem.ReAlloc,[ebx+Figure.PoiData],eax
1335
		mov [ebx+Figure.PoiData],eax
1336
 
1337
		mov ecx,edi
1338
		mov edx,eax
1339
align 4
1340
		.cycle1: ;цикл для снятия выделения со старых точек
1341
			btr dword[edx+Point.Prop],PROP_BIT_SELECT
1342
			add edx,sizeof.Point
1343
			loop .cycle1
1344
 
1345
		mov ecx,[nCount]
1346
		imul edi,sizeof.Point
1347
		add edi,eax
1348
		finit
1349
align 4
1350
		.cycle2: ;цикл для добавления новых точек
1351
			stdcall PointInit,edi
1352
			or eax,eax
1353
			jz .cycle2end
1354
			bts dword[edi+Point.Prop],PROP_BIT_SELECT
1355
			add edi,sizeof.Point
1356
			loop .cycle2
1357
		.cycle2end:
1358
		or ecx,ecx
1359
		jz .end1
1360
			;уменьшаем объем памяти выделенный для точек
1361
			sub [ebx+Figure.PoiCount],ecx
1362
			mov eax,[ebx+Figure.PoiCount]
1363
			imul eax,sizeof.Point
1364
			stdcall mem.ReAlloc,[ebx+Figure.PoiData],eax
1365
			mov [ebx+Figure.PoiData],eax
1366
		.end1:
1367
		stdcall found_parent_obj,ebx ;get figure number in ecx
1368
		stdcall figure_update_coords,ObjData,ecx
1369
 
1370
		mov eax,[nCount]
1371
		mov dword[offs_last_timer],0
1372
		jmp .end_f
1373
	.end0:
1374
		xor eax,eax
1375
	.end_f:
1376
	ret
1377
endp
1378
 
1379
align 4
1380
proc but_sel_points_del
1381
locals
1382
	pFig dd ?
1383
	nDel dd ? ;need delete
1384
endl
1385
	pushad
1386
	stdcall [tl_node_get_data],tree1
1387
	or eax,eax
1388
	jz .no_point
1389
	cmp [eax+Figure.OType],'Fig'
1390
	jne .no_point
1391
 
1392
	mov [pFig],eax
1393
	stdcall sel_points_get_count,eax
1394
	or eax,eax
1395
	jz .no_point
1396
	mov [nDel],eax
1397
 
1398
	;проверяем выделенные точки
1399
	mov ebx,[pFig]
1400
	mov ecx,[ebx+Figure.PoiCount]
1401
	or ecx,ecx
1402
	jz .no_point
1403
 
1404
	cmp ecx,eax
1405
	jle .no_all
1406
 
1407
	stdcall found_parent_obj,[pFig]
1408
	or eax,eax
1409
	jz .end_f ;if not found
1410
		mov edi,[ebx+Figure.PoiData]
1411
		mov edx,[ebx+Figure.PoiCount]
1412
		imul edx,sizeof.Point
1413
		add edx,edi
1414
 
1415
		.cycle0: ;1-я выделенная точка
1416
			cmp edi,edx
1417
			jge .end0
1418
			bt dword[edi+Point.Prop],PROP_BIT_SELECT
1419
			jc .cycle0end
1420
				add edi,sizeof.Point
1421
				jmp .cycle0
1422
		.cycle0end:
1423
 
1424
		mov esi,edi ;следущая 1-я не выделенная точка
1425
		add esi,sizeof.Point
1426
		.cycle1:
1427
			cmp esi,edx
1428
			jge .end0
1429
			bt dword[esi+Point.Prop],PROP_BIT_SELECT
1430
			jnc .cycle1end
1431
				add esi,sizeof.Point
1432
				jmp .cycle1
1433
		.cycle1end:
1434
 
1435
		mov ecx,sizeof.Point
1436
		rep movsb ;замена выделенной точки
1437
		bts dword[esi+Point.Prop-sizeof.Point],PROP_BIT_SELECT ;ставим выделение на точку, что-бы потом ее удалить
1438
 
1439
		jmp .cycle0
1440
		.end0:
1441
 
1442
		;обновление памяти
1443
		mov eax,[ebx+Figure.PoiCount]
1444
		sub eax,[nDel]
1445
		mov [ebx+Figure.PoiCount],eax
1446
		imul eax,sizeof.Point
1447
		stdcall mem.ReAlloc,[ebx+Figure.PoiData],eax
1448
		mov [ebx+Figure.PoiData],eax
1449
 
1450
		;перерасчет размеров фигуры
1451
		stdcall found_parent_obj,ebx ;get figure number in ecx
1452
		stdcall figure_update_coords,ObjData,ecx
1453
 
1454
		;для обновления по таймеру
1455
		mov dword[offs_last_timer],0
1456
		jmp .end_f
1457
 
1458
	.no_all:
1459
		notify_window_run txt_err_no_point_del
1460
		jmp .end_f
1461
	.no_point:
1462
		notify_window_run txt_err_no_point_sel
1463
	.end_f:
1464
	popad
1465
	ret
1466
endp
1467
 
1468
align 4
1469
proc but_sel_points_all uses eax ecx
1470
	stdcall [tl_node_get_data],tree1
1471
	or eax,eax
1472
	jz .no_point
1473
	cmp [eax+Figure.OType],'Fig'
1474
	jne .no_point
1475
 
1476
	mov ecx,[eax+Figure.PoiCount]
1477
	or ecx,ecx
1478
	jz .no_point
1479
	mov eax,[eax+Figure.PoiData]
7415 IgorA 1480
	.cycle0: ;цикл для выделенния точек
7360 IgorA 1481
		bts dword[eax+Point.Prop],PROP_BIT_SELECT
1482
		add eax,sizeof.Point
1483
		loop .cycle0
1484
	;для обновления по таймеру
1485
	mov dword[offs_last_timer],0
1486
	.no_point:
1487
	ret
1488
endp
1489
 
1490
align 4
7415 IgorA 1491
proc but_sel_points_align_coord_xmin
1492
pushad
1493
	stdcall [tl_node_get_data],tree1
1494
	or eax,eax
1495
	jz .no_point
1496
	cmp [eax+Figure.OType],'Fig'
1497
	jne .no_point
1498
 
1499
	mov ebx,eax
1500
	stdcall sel_points_get_count,eax
1501
	cmp eax,1
1502
	jle .no_point
1503
	mov ecx,[ebx+Figure.PoiCount]
1504
	or ecx,ecx
1505
	jz .no_point
1506
	cmp eax,ecx
1507
	je .no_point ;если выделенны все точки, что-бы не портить контур
1508
 
1509
	mov edx,ecx
1510
	imul edx,sizeof.Point
1511
	mov ebx,[ebx+Figure.PoiData]
1512
	add edx,ebx
1513
align 4
1514
	.cycle0: ;1-я выделенная точка
1515
		cmp ebx,edx
1516
		jge .no_point
1517
		bt dword[ebx+Point.Prop],PROP_BIT_SELECT
1518
		jc .cycle0end
1519
		add ebx,sizeof.Point
1520
		jmp .cycle0
1521
	.cycle0end:
1522
	lea esi,[ebx+Point.CoordX]
1523
	mov edi,Data_Double
1524
	movsd
1525
	movsd
1526
	finit
1527
	fld qword[Data_Double]
1528
align 4
1529
	.cycle1: ;цикл для нахождения min(Point.CoordX)
1530
		bt dword[ebx+Point.Prop],PROP_BIT_SELECT
1531
		jnc .no_sel
1532
			fcom qword[ebx+Point.CoordX]
1533
			fstsw ax
1534
			sahf
1535
			jbe .no_sel
1536
				;if (st0>Point.CoordX)
1537
				ffree st0
1538
				fincstp
1539
				fld qword[ebx+Point.CoordX]
1540
		.no_sel:
1541
		add ebx,sizeof.Point
1542
		cmp ebx,edx
1543
		jl .cycle1
1544
	fstp qword[Data_Double]
1545
align 4
1546
	.cycle2: ;цикл для присваивания всем Point.CoordX = min(Point.CoordX)
1547
		sub edx,sizeof.Point
1548
		bt dword[edx+Point.Prop],PROP_BIT_SELECT
1549
		jnc @f
1550
			mov esi,Data_Double
1551
			lea edi,[edx+Point.CoordX]
1552
			movsd
1553
			movsd
1554
		@@:
1555
		loop .cycle2
1556
	;для обновления по таймеру
1557
	mov dword[offs_last_timer],0
1558
	.no_point:
1559
popad
1560
	ret
1561
endp
1562
 
1563
align 4
1564
proc but_sel_points_align_coord_ymin
1565
pushad
1566
	stdcall [tl_node_get_data],tree1
1567
	or eax,eax
1568
	jz .no_point
1569
	cmp [eax+Figure.OType],'Fig'
1570
	jne .no_point
1571
 
1572
	mov ebx,eax
1573
	stdcall sel_points_get_count,eax
1574
	cmp eax,1
1575
	jle .no_point
1576
	mov ecx,[ebx+Figure.PoiCount]
1577
	or ecx,ecx
1578
	jz .no_point
1579
	cmp eax,ecx
1580
	je .no_point ;если выделенны все точки, что-бы не портить контур
1581
 
1582
	mov edx,ecx
1583
	imul edx,sizeof.Point
1584
	mov ebx,[ebx+Figure.PoiData]
1585
	add edx,ebx
1586
align 4
1587
	.cycle0: ;1-я выделенная точка
1588
		cmp ebx,edx
1589
		jge .no_point
1590
		bt dword[ebx+Point.Prop],PROP_BIT_SELECT
1591
		jc .cycle0end
1592
		add ebx,sizeof.Point
1593
		jmp .cycle0
1594
	.cycle0end:
1595
	lea esi,[ebx+Point.CoordY]
1596
	mov edi,Data_Double
1597
	movsd
1598
	movsd
1599
	finit
1600
	fld qword[Data_Double]
1601
align 4
1602
	.cycle1: ;цикл для нахождения min(Point.CoordY)
1603
		bt dword[ebx+Point.Prop],PROP_BIT_SELECT
1604
		jnc .no_sel
1605
			fcom qword[ebx+Point.CoordY]
1606
			fstsw ax
1607
			sahf
1608
			jbe .no_sel
1609
				;if (st0>Point.CoordY)
1610
				ffree st0
1611
				fincstp
1612
				fld qword[ebx+Point.CoordY]
1613
		.no_sel:
1614
		add ebx,sizeof.Point
1615
		cmp ebx,edx
1616
		jl .cycle1
1617
	fstp qword[Data_Double]
1618
align 4
1619
	.cycle2: ;цикл для присваивания всем Point.CoordY = min(Point.CoordY)
1620
		sub edx,sizeof.Point
1621
		bt dword[edx+Point.Prop],PROP_BIT_SELECT
1622
		jnc @f
1623
			mov esi,Data_Double
1624
			lea edi,[edx+Point.CoordY]
1625
			movsd
1626
			movsd
1627
		@@:
1628
		loop .cycle2
1629
	;для обновления по таймеру
1630
	mov dword[offs_last_timer],0
1631
	.no_point:
1632
popad
1633
	ret
1634
endp
1635
 
1636
align 4
1637
proc but_sel_points_align_coord_xmax
1638
pushad
1639
	stdcall [tl_node_get_data],tree1
1640
	or eax,eax
1641
	jz .no_point
1642
	cmp [eax+Figure.OType],'Fig'
1643
	jne .no_point
1644
 
1645
	mov ebx,eax
1646
	stdcall sel_points_get_count,eax
1647
	cmp eax,1
1648
	jle .no_point
1649
	mov ecx,[ebx+Figure.PoiCount]
1650
	or ecx,ecx
1651
	jz .no_point
1652
	cmp eax,ecx
1653
	je .no_point ;если выделенны все точки, что-бы не портить контур
1654
 
1655
	mov edx,ecx
1656
	imul edx,sizeof.Point
1657
	mov ebx,[ebx+Figure.PoiData]
1658
	add edx,ebx
1659
align 4
1660
	.cycle0: ;1-я выделенная точка
1661
		cmp ebx,edx
1662
		jge .no_point
1663
		bt dword[ebx+Point.Prop],PROP_BIT_SELECT
1664
		jc .cycle0end
1665
		add ebx,sizeof.Point
1666
		jmp .cycle0
1667
	.cycle0end:
1668
	lea esi,[ebx+Point.CoordX]
1669
	mov edi,Data_Double
1670
	movsd
1671
	movsd
1672
	finit
1673
	fld qword[Data_Double]
1674
align 4
1675
	.cycle1: ;цикл для нахождения max(Point.CoordX)
1676
		bt dword[ebx+Point.Prop],PROP_BIT_SELECT
1677
		jnc .no_sel
1678
			fcom qword[ebx+Point.CoordX]
1679
			fstsw ax
1680
			sahf
1681
			jae .no_sel
1682
				;if (st0
1683
				ffree st0
1684
				fincstp
1685
				fld qword[ebx+Point.CoordX]
1686
		.no_sel:
1687
		add ebx,sizeof.Point
1688
		cmp ebx,edx
1689
		jl .cycle1
1690
	fstp qword[Data_Double]
1691
align 4
1692
	.cycle2: ;цикл для присваивания всем Point.CoordX = max(Point.CoordX)
1693
		sub edx,sizeof.Point
1694
		bt dword[edx+Point.Prop],PROP_BIT_SELECT
1695
		jnc @f
1696
			mov esi,Data_Double
1697
			lea edi,[edx+Point.CoordX]
1698
			movsd
1699
			movsd
1700
		@@:
1701
		loop .cycle2
1702
	;для обновления по таймеру
1703
	mov dword[offs_last_timer],0
1704
	.no_point:
1705
popad
1706
	ret
1707
endp
1708
 
1709
align 4
1710
proc but_sel_points_align_coord_ymax
1711
pushad
1712
	stdcall [tl_node_get_data],tree1
1713
	or eax,eax
1714
	jz .no_point
1715
	cmp [eax+Figure.OType],'Fig'
1716
	jne .no_point
1717
 
1718
	mov ebx,eax
1719
	stdcall sel_points_get_count,eax
1720
	cmp eax,1
1721
	jle .no_point
1722
	mov ecx,[ebx+Figure.PoiCount]
1723
	or ecx,ecx
1724
	jz .no_point
1725
	cmp eax,ecx
1726
	je .no_point ;если выделенны все точки, что-бы не портить контур
1727
 
1728
	mov edx,ecx
1729
	imul edx,sizeof.Point
1730
	mov ebx,[ebx+Figure.PoiData]
1731
	add edx,ebx
1732
align 4
1733
	.cycle0: ;1-я выделенная точка
1734
		cmp ebx,edx
1735
		jge .no_point
1736
		bt dword[ebx+Point.Prop],PROP_BIT_SELECT
1737
		jc .cycle0end
1738
		add ebx,sizeof.Point
1739
		jmp .cycle0
1740
	.cycle0end:
1741
	lea esi,[ebx+Point.CoordY]
1742
	mov edi,Data_Double
1743
	movsd
1744
	movsd
1745
	finit
1746
	fld qword[Data_Double]
1747
align 4
1748
	.cycle1: ;цикл для нахождения max(Point.CoordY)
1749
		bt dword[ebx+Point.Prop],PROP_BIT_SELECT
1750
		jnc .no_sel
1751
			fcom qword[ebx+Point.CoordY]
1752
			fstsw ax
1753
			sahf
1754
			jae .no_sel
1755
				;if (st0
1756
				ffree st0
1757
				fincstp
1758
				fld qword[ebx+Point.CoordY]
1759
		.no_sel:
1760
		add ebx,sizeof.Point
1761
		cmp ebx,edx
1762
		jl .cycle1
1763
	fstp qword[Data_Double]
1764
align 4
1765
	.cycle2: ;цикл для присваивания всем Point.CoordY = max(Point.CoordY)
1766
		sub edx,sizeof.Point
1767
		bt dword[edx+Point.Prop],PROP_BIT_SELECT
1768
		jnc @f
1769
			mov esi,Data_Double
1770
			lea edi,[edx+Point.CoordY]
1771
			movsd
1772
			movsd
1773
		@@:
1774
		loop .cycle2
1775
	;для обновления по таймеру
1776
	mov dword[offs_last_timer],0
1777
	.no_point:
1778
popad
1779
	ret
1780
endp
1781
 
1782
align 4
7360 IgorA 1783
proc but_restore_zoom uses eax
1784
	stdcall [tl_node_get_data],tree1
1785
	or eax,eax
1786
	jz .end_f
1787
	cmp [eax+Figure.OType],'Fig'
1788
	je @f
1789
	cmp [eax+Figure.OType],'Obj'
1790
	je .end0
1791
		jmp .end_f
1792
	.end0:
1793
		mov eax,ObjData
1794
	@@:
1795
		finit
1796
		fld1
1797
		fstp qword[eax+Figure.MScale]
1798
		mov dword[eax+Figure.MCentrX],0
1799
		mov dword[eax+Figure.MCentrY],0
1800
		mov dword[offs_last_timer],0
1801
	.end_f:
1802
	ret
1803
endp
1804
 
1805
align 4
1806
but_sel_figure_move_down:
1807
	pushad
1808
	stdcall [tl_node_get_data],tree1
1809
	or eax,eax
1810
	jz .end_fblo
1811
	cmp [eax+Figure.OType],'Fig'
1812
	jne .end_fblo
1813
		stdcall found_parent_obj,eax
1814
		or eax,eax
1815
		jz .end_f ;if not found
1816
		inc ecx
1817
		cmp ecx,[eax+Object.FigCount]
1818
		jge .fig_is_last ;если фигура в конце списка
1819
		mov ebx,[eax+Object.FigData]
1820
		mov edx,[ebx+4*ecx] ;передвигаемая фигура
1821
		mov edi,[ebx+4*ecx-4]
1822
		;меняем фигуры местами
1823
		mov [ebx+4*ecx],edi
1824
		mov [ebx+4*ecx-4],edx
1825
		;меняем фигуры в списке
1826
		stdcall [tl_node_move_down],tree1
1827
		jmp .end_f
1828
	.fig_is_last:
1829
		notify_window_run txt_err_figure_is_last
1830
		jmp .end_f
1831
	.end_fblo:
1832
		notify_window_run txt_err_no_figure_select
1833
	.end_f:
1834
	popad
1835
	ret
1836
 
1837
;description:
1838
; запуск окна создания/редактирования точки
1839
align 4
1840
but_dlg_point_coords:
1841
	cmp byte[wnd_run_prop],0
1842
	jne .end_f
1843
pushad
1844
	stdcall [tl_node_get_data],tree1
1845
	or eax,eax
1846
	jz .end_fblo
1847
	cmp [eax+Figure.OType],'Fig'
1848
	jne .end_fblo
1849
	mov [wnd_pFig],eax ;фигура
1850
	stdcall sel_points_get_count,eax
1851
	cmp eax,1
1852
	jne .no_select_1
1853
		stdcall found_parent_obj,[wnd_pFig]
1854
		or eax,eax
1855
		jz .end0 ;if not found
1856
 
1857
		mov [wnd_pObj],eax ;obj
1858
		mov [wnd_FigN],ecx ;fig number
1859
		stdcall sel_points_get_first,[wnd_pFig]
1860
		mov [wnd_pPoi],eax
1861
		mov edx,[wnd_pFig]
1862
		sub eax,[edx+Figure.PoiData]
1863
		xor edx,edx
1864
		mov ecx,sizeof.Point
1865
		div ecx
1866
		jmp .end1
1867
	.no_select_1:
1868
	or eax,eax
1869
	jnz .end_fblo
1870
		stdcall found_parent_obj,[wnd_pFig]
1871
		or eax,eax
1872
		jz .end0 ;if not found
1873
 
1874
		mov [wnd_pObj],eax ;obj
1875
		mov [wnd_FigN],ecx ;fig number
1876
		xor eax,eax
1877
		mov [wnd_pPoi],eax
1878
		mov edx,[wnd_pFig]
1879
		mov eax,[edx+Figure.PoiCount]
1880
	.end1:
1881
		mov [wnd_PoiN],eax
1882
		mcall SF_CREATE_THREAD,1,start_prop,thread_coords
1883
		jmp .end0
1884
	.end_fblo:
1885
		notify_window_run txt_err_no_1_point_sel
1886
		;jmp @f
1887
	;.end_fblo:
1888
		;notify_window_run txt_err_...
1889
	.end0:
1890
popad
1891
	.end_f:
1892
	ret
1893
 
1894
align 4
1895
but_dlg_opt_scale:
1896
	cmp byte[wnd_run_scale],0
1897
	jne .end_f
1898
pushad
1899
	mcall SF_CREATE_THREAD,1,start_scale,thread_scale
1900
popad
1901
	.end_f:
1902
	ret
1903
 
1904
 
1905
 
1906
;input:
1907
; buf - указатель на строку, число должно быть в 10 или 16 ричном виде
1908
;output:
1909
; eax - число
1910
align 4
1911
proc conv_str_to_int uses ebx ecx esi, buf:dword
1912
	xor eax,eax
1913
	xor ebx,ebx
1914
	mov esi,[buf]
1915
 
1916
	;на случай если перед числом находятся пробелы
1917
	@@:
1918
	cmp byte[esi],' '
1919
	jne @f
1920
		inc esi
1921
		jmp @b
1922
	@@:
1923
 
1924
	;определение отрицательных чисел
1925
	xor ecx,ecx
1926
	inc ecx
1927
	cmp byte[esi],'-'
1928
	jne @f
1929
		dec ecx
1930
		inc esi
1931
	@@:
1932
 
1933
	cmp word[esi],'0x'
1934
	je .load_digit_16
1935
 
1936
	.load_digit_10: ;считывание 10-тичных цифр
1937
		mov bl,byte[esi]
1938
		cmp bl,'0'
1939
		jl @f
1940
		cmp bl,'9'
1941
		jg @f
1942
			sub bl,'0'
1943
			imul eax,10
1944
			add eax,ebx
1945
			inc esi
1946
			jmp .load_digit_10
1947
	jmp @f
1948
 
1949
	.load_digit_16: ;считывание 16-ричных цифр
1950
		add esi,2
1951
	.cycle_16:
1952
		mov bl,byte[esi]
1953
		cmp bl,'0'
1954
		jl @f
1955
		cmp bl,'f'
1956
		jg @f
1957
		cmp bl,'9'
1958
		jle .us1
1959
			cmp bl,'A'
1960
			jl @f ;отсеиваем символы >'9' и <'A'
1961
		.us1: ;составное условие
1962
		cmp bl,'F'
1963
		jle .us2
1964
			cmp bl,'a'
1965
			jl @f ;отсеиваем символы >'F' и <'a'
1966
			sub bl,32 ;переводим символы в верхний регистр, для упрощения их последущей обработки
1967
		.us2: ;составное условие
1968
			sub bl,'0'
1969
			cmp bl,9
1970
			jle .cor1
1971
				sub bl,7 ;convert 'A' to '10'
1972
			.cor1:
1973
			shl eax,4
1974
			add eax,ebx
1975
			inc esi
1976
			jmp .cycle_16
1977
	@@:
1978
	cmp ecx,0 ;если число отрицательное
1979
	jne @f
1980
		sub ecx,eax
1981
		mov eax,ecx
1982
	@@:
1983
	ret
1984
endp
1985
 
1986
 
1987
;данные для диалога открытия файлов
1988
align 4
1989
OpenDialog_data:
1990
.type			dd 0 ;0 - открыть, 1 - сохранить, 2 - выбрать дтректорию
1991
.procinfo		dd procinfo	;+4
1992
.com_area_name		dd communication_area_name	;+8
1993
.com_area		dd 0	;+12
1994
.opendir_path		dd plugin_path	;+16
1995
.dir_default_path	dd default_dir ;+20
1996
.start_path		dd file_name ;+24 путь к диалогу открытия файлов
1997
.draw_window		dd draw_window	;+28
1998
.status 		dd 0	;+32
1999
.openfile_path		dd openfile_path	;+36 путь к открываемому файлу
2000
.filename_area		dd filename_area	;+40
2001
.filter_area		dd Filter
2002
.x:
2003
.x_size 		dw 420 ;+48 ; Window X size
2004
.x_start		dw 10 ;+50 ; Window X position
2005
.y:
2006
.y_size 		dw 320 ;+52 ; Window y size
2007
.y_start		dw 10 ;+54 ; Window Y position
2008
 
2009
default_dir db '/rd/1',0
2010
 
2011
communication_area_name:
2012
	db 'FFFFFFFF_open_dialog',0
2013
open_dialog_name:
2014
	db 'opendial',0
2015
communication_area_default_path:
2016
	db '/rd/1/File managers/',0
2017
 
2018
Filter:
2019
dd Filter.end - Filter ;.1
2020
.1:
2021
db 'NC',0
2022
db 'PNG',0
2023
.end:
2024
db 0
2025
 
2026
 
2027
 
2028
head_f_i:
2029
head_f_l db 'Системная ошибка',0
2030
 
2031
system_dir_0 db '/sys/lib/'
2032
lib_name_0 db 'proc_lib.obj',0
2033
err_message_found_lib_0 db 'Не найдена библиотека ',39,'proc_lib.obj',39,0
2034
err_message_import_0 db 'Ошибка при импорте библиотеки ',39,'proc_lib.obj',39,0
2035
 
2036
system_dir_1 db '/sys/lib/'
2037
lib_name_1 db 'libimg.obj',0
2038
err_message_found_lib_1 db 'Не найдена библиотека ',39,'libimg.obj',39,0
2039
err_message_import_1 db 'Ошибка при импорте библиотеки ',39,'libimg.obj',39,0
2040
 
2041
system_dir_2 db '/sys/lib/'
2042
lib_name_2 db 'buf2d.obj',0
2043
err_msg_found_lib_2 db 'Не найдена библиотека ',39,'buf2d.obj',39,0
2044
err_msg_import_2 db 'Ошибка при импорте библиотеки ',39,'buf2d',39,0
2045
 
2046
system_dir_3 db '/sys/lib/'
2047
lib_name_3 db 'box_lib.obj',0
2048
err_msg_found_lib_3 db 'Не найдена библиотека ',39,'box_lib.obj',39,0
2049
err_msg_import_3 db 'Ошибка при импорте библиотеки ',39,'box_lib',39,0
2050
 
2051
l_libs_start:
2052
	lib_0 l_libs lib_name_0, sys_path, file_name, system_dir_0,\
2053
		err_message_found_lib_0, head_f_l, proclib_import,err_message_import_0, head_f_i
2054
	lib_1 l_libs lib_name_1, sys_path, file_name, system_dir_1,\
2055
		err_message_found_lib_1, head_f_l, import_libimg, err_message_import_1, head_f_i
2056
	lib_2 l_libs lib_name_2, sys_path, library_path, system_dir_2,\
2057
		err_msg_found_lib_2,head_f_l,import_buf2d,err_msg_import_2,head_f_i
2058
	lib_3 l_libs lib_name_3, sys_path, file_name,  system_dir_3,\
2059
		err_msg_found_lib_3, head_f_l, import_box_lib,err_msg_import_3,head_f_i
2060
l_libs_end:
2061
 
2062
align 4
2063
import_libimg:
2064
	dd alib_init1
2065
	img_is_img  dd aimg_is_img
2066
	img_info    dd aimg_info
2067
	img_from_file dd aimg_from_file
2068
	img_to_file dd aimg_to_file
2069
	img_from_rgb dd aimg_from_rgb
2070
	img_to_rgb  dd aimg_to_rgb
2071
	img_to_rgb2 dd aimg_to_rgb2
2072
	img_decode  dd aimg_decode
2073
	img_encode  dd aimg_encode
2074
	img_create  dd aimg_create
2075
	img_destroy dd aimg_destroy
2076
	img_destroy_layer dd aimg_destroy_layer
2077
	img_count   dd aimg_count
2078
	img_lock_bits dd aimg_lock_bits
2079
	img_unlock_bits dd aimg_unlock_bits
2080
	img_flip    dd aimg_flip
2081
	img_flip_layer dd aimg_flip_layer
2082
	img_rotate  dd aimg_rotate
2083
	img_rotate_layer dd aimg_rotate_layer
2084
	img_draw    dd aimg_draw
2085
 
2086
	dd 0,0
2087
	alib_init1   db 'lib_init',0
2088
	aimg_is_img  db 'img_is_img',0 ;определяет по данным, может ли библиотека сделать из них изображение
2089
	aimg_info    db 'img_info',0
2090
	aimg_from_file db 'img_from_file',0
2091
	aimg_to_file db 'img_to_file',0
2092
	aimg_from_rgb db 'img_from_rgb',0
2093
	aimg_to_rgb  db 'img_to_rgb',0 ;преобразование изображения в данные RGB
2094
	aimg_to_rgb2 db 'img_to_rgb2',0
2095
	aimg_decode  db 'img_decode',0 ;автоматически определяет формат графических данных
2096
	aimg_encode  db 'img_encode',0
2097
	aimg_create  db 'img_create',0
2098
	aimg_destroy db 'img_destroy',0
2099
	aimg_destroy_layer db 'img_destroy_layer',0
2100
	aimg_count   db 'img_count',0
2101
	aimg_lock_bits db 'img_lock_bits',0
2102
	aimg_unlock_bits db 'img_unlock_bits',0
2103
	aimg_flip    db 'img_flip',0
2104
	aimg_flip_layer db 'img_flip_layer',0
2105
	aimg_rotate  db 'img_rotate',0
2106
	aimg_rotate_layer db 'img_rotate_layer',0
2107
	aimg_draw    db 'img_draw',0
2108
 
2109
align 4
2110
proclib_import: ;описание экспортируемых функций
2111
	OpenDialog_Init dd aOpenDialog_Init
2112
	OpenDialog_Start dd aOpenDialog_Start
2113
dd 0,0
2114
	aOpenDialog_Init db 'OpenDialog_init',0
2115
	aOpenDialog_Start db 'OpenDialog_start',0
2116
 
2117
align 4
2118
import_buf2d:
2119
	init dd sz_init
2120
	buf2d_create dd sz_buf2d_create
2121
	buf2d_create_f_img dd sz_buf2d_create_f_img
2122
	buf2d_clear dd sz_buf2d_clear
2123
	buf2d_draw dd sz_buf2d_draw
2124
	buf2d_delete dd sz_buf2d_delete
2125
	buf2d_resize dd sz_buf2d_resize
2126
	buf2d_line dd sz_buf2d_line
2127
	buf2d_line_sm dd sz_buf2d_line_sm
2128
	buf2d_rect_by_size dd sz_buf2d_rect_by_size
2129
	buf2d_filled_rect_by_size dd sz_buf2d_filled_rect_by_size
2130
	buf2d_circle dd sz_buf2d_circle
2131
	buf2d_img_hdiv2 dd sz_buf2d_img_hdiv2
2132
	buf2d_img_wdiv2 dd sz_buf2d_img_wdiv2
2133
	buf2d_conv_24_to_8 dd sz_buf2d_conv_24_to_8
2134
	buf2d_conv_24_to_32 dd sz_buf2d_conv_24_to_32
2135
	buf2d_bit_blt dd sz_buf2d_bit_blt
2136
	buf2d_bit_blt_transp dd sz_buf2d_bit_blt_transp
2137
	buf2d_bit_blt_alpha dd sz_buf2d_bit_blt_alpha
2138
	buf2d_curve_bezier dd sz_buf2d_curve_bezier
2139
	buf2d_convert_text_matrix dd sz_buf2d_convert_text_matrix
2140
	buf2d_draw_text dd sz_buf2d_draw_text
2141
	buf2d_crop_color dd sz_buf2d_crop_color
2142
	buf2d_flip_h dd sz_buf2d_flip_h
2143
	buf2d_flip_v dd sz_buf2d_flip_v
2144
	buf2d_offset_h dd sz_buf2d_offset_h
2145
	buf2d_flood_fill dd sz_buf2d_flood_fill
2146
	buf2d_set_pixel dd sz_buf2d_set_pixel
2147
	dd 0,0
2148
	sz_init db 'lib_init',0
2149
	sz_buf2d_create db 'buf2d_create',0
2150
	sz_buf2d_create_f_img db 'buf2d_create_f_img',0
2151
	sz_buf2d_clear db 'buf2d_clear',0
2152
	sz_buf2d_draw db 'buf2d_draw',0
2153
	sz_buf2d_delete db 'buf2d_delete',0
2154
	sz_buf2d_resize db 'buf2d_resize',0
2155
	sz_buf2d_line db 'buf2d_line',0
2156
	sz_buf2d_line_sm db 'buf2d_line_sm',0
2157
	sz_buf2d_rect_by_size db 'buf2d_rect_by_size',0
2158
	sz_buf2d_filled_rect_by_size db 'buf2d_filled_rect_by_size',0
2159
	sz_buf2d_circle db 'buf2d_circle',0
2160
	sz_buf2d_img_hdiv2 db 'buf2d_img_hdiv2',0
2161
	sz_buf2d_img_wdiv2 db 'buf2d_img_wdiv2',0
2162
	sz_buf2d_conv_24_to_8 db 'buf2d_conv_24_to_8',0
2163
	sz_buf2d_conv_24_to_32 db 'buf2d_conv_24_to_32',0
2164
	sz_buf2d_bit_blt db 'buf2d_bit_blt',0
2165
	sz_buf2d_bit_blt_transp db 'buf2d_bit_blt_transp',0
2166
	sz_buf2d_bit_blt_alpha db 'buf2d_bit_blt_alpha',0
2167
	sz_buf2d_curve_bezier db 'buf2d_curve_bezier',0
2168
	sz_buf2d_convert_text_matrix db 'buf2d_convert_text_matrix',0
2169
	sz_buf2d_draw_text db 'buf2d_draw_text',0
2170
	sz_buf2d_crop_color db 'buf2d_crop_color',0
2171
	sz_buf2d_flip_h db 'buf2d_flip_h',0
2172
	sz_buf2d_flip_v db 'buf2d_flip_v',0
2173
	sz_buf2d_offset_h db 'buf2d_offset_h',0
2174
	sz_buf2d_flood_fill db 'buf2d_flood_fill',0
2175
	sz_buf2d_set_pixel db 'buf2d_set_pixel',0
2176
 
2177
align 4
2178
import_box_lib:
2179
	dd sz_init1
2180
 
2181
	init_checkbox   dd sz_Init_checkbox
2182
	check_box_draw  dd sz_Check_box_draw
2183
	check_box_mouse dd sz_Check_box_mouse
2184
	;version_ch     dd sz_Version_ch
2185
 
2186
	option_box_draw	 dd sz_Option_box_draw
2187
	option_box_mouse dd sz_Option_box_mouse
2188
	;version_op      dd sz_Version_op
2189
 
2190
	edit_box_draw      dd sz_edit_box_draw
2191
	edit_box_key       dd sz_edit_box_key
2192
	edit_box_mouse     dd sz_edit_box_mouse
2193
	edit_box_set_text  dd sz_edit_box_set_text
2194
	scrollbar_ver_draw dd sz_scrollbar_ver_draw
2195
	scrollbar_hor_draw dd sz_scrollbar_hor_draw
2196
 
2197
	tl_data_init dd sz_tl_data_init
2198
	tl_data_clear dd sz_tl_data_clear
2199
	tl_info_clear dd sz_tl_info_clear
2200
	tl_key dd sz_tl_key
2201
	tl_mouse dd sz_tl_mouse
2202
	tl_draw dd sz_tl_draw
2203
	tl_info_undo dd sz_tl_info_undo
2204
	tl_info_redo dd sz_tl_info_redo
2205
	tl_node_add dd sz_tl_node_add
2206
	tl_node_set_data dd sz_tl_node_set_data
2207
	tl_node_get_data dd sz_tl_node_get_data
2208
	tl_node_delete dd sz_tl_node_delete
2209
	tl_node_move_up dd sz_tl_node_move_up
2210
	tl_node_move_down dd sz_tl_node_move_down
2211
	tl_cur_beg dd sz_tl_cur_beg
2212
	tl_cur_next dd sz_tl_cur_next
2213
	tl_cur_perv dd sz_tl_cur_perv
2214
	tl_node_close_open dd sz_tl_node_close_open
2215
	tl_node_lev_inc dd sz_tl_node_lev_inc
2216
	tl_node_lev_dec dd sz_tl_node_lev_dec
2217
	tl_node_poi_get_info dd sz_tl_node_poi_get_info
2218
	tl_node_poi_get_next_info dd sz_tl_node_poi_get_next_info
2219
	tl_node_poi_get_data dd sz_tl_node_poi_get_data
2220
 
2221
	dd 0,0
2222
	sz_init1 db 'lib_init',0
2223
 
2224
	sz_Init_checkbox   db 'init_checkbox2',0
2225
	sz_Check_box_draw  db 'check_box_draw2',0
2226
	sz_Check_box_mouse db 'check_box_mouse2',0
2227
	;sz_Version_ch     db 'version_ch2',0
2228
 
2229
	sz_Option_box_draw	db 'option_box_draw',0
2230
	sz_Option_box_mouse	db 'option_box_mouse',0
2231
	;sz_Version_op      db 'version_op',0
2232
 
2233
	sz_edit_box_draw      db 'edit_box',0
2234
	sz_edit_box_key       db 'edit_box_key',0
2235
	sz_edit_box_mouse     db 'edit_box_mouse',0
2236
	sz_edit_box_set_text  db 'edit_box_set_text',0
2237
	sz_scrollbar_ver_draw db 'scrollbar_v_draw',0
2238
	sz_scrollbar_hor_draw db 'scrollbar_h_draw',0
2239
 
2240
	sz_tl_data_init db 'tl_data_init',0
2241
	sz_tl_data_clear db 'tl_data_clear',0
2242
	sz_tl_info_clear db 'tl_info_clear',0
2243
	sz_tl_key db 'tl_key',0
2244
	sz_tl_mouse db 'tl_mouse',0
2245
	sz_tl_draw db 'tl_draw',0
2246
	sz_tl_info_undo db 'tl_info_undo',0
2247
	sz_tl_info_redo db 'tl_info_redo',0
2248
	sz_tl_node_add db 'tl_node_add',0
2249
	sz_tl_node_set_data db 'tl_node_set_data',0
2250
	sz_tl_node_get_data db 'tl_node_get_data',0
2251
	sz_tl_node_delete db 'tl_node_delete',0
2252
	sz_tl_node_move_up db 'tl_node_move_up',0
2253
	sz_tl_node_move_down db 'tl_node_move_down',0
2254
	sz_tl_cur_beg db 'tl_cur_beg',0
2255
	sz_tl_cur_next db 'tl_cur_next',0
2256
	sz_tl_cur_perv db 'tl_cur_perv',0
2257
	sz_tl_node_close_open db 'tl_node_close_open',0
2258
	sz_tl_node_lev_inc db 'tl_node_lev_inc',0
2259
	sz_tl_node_lev_dec db 'tl_node_lev_dec',0
2260
	sz_tl_node_poi_get_info db 'tl_node_poi_get_info',0
2261
	sz_tl_node_poi_get_next_info db 'tl_node_poi_get_next_info',0
2262
	sz_tl_node_poi_get_data db 'tl_node_poi_get_data',0
2263
 
2264
align 4
2265
mouse_dd dd 0
2266
last_time dd 0
2267
 
2268
align 16
2269
sc system_colors
2270
 
2271
align 16
2272
procinfo process_information
2273
 
2274
align 4
2275
buf_0: dd 0 ;указатель на буфер изображения
2276
.l: dw 205 ;+4 left
2277
.t: dw 35 ;+6 top
2278
.w: dd 384 ;+8 w
2279
.h: dd 350 ;+12 h
2280
.color: dd 0xffffd0 ;+16 color
2281
	db 24 ;+20 bit in pixel
2282
 
2283
align 4
2284
buf_1:
2285
	dd 0 ;указатель на буфер изображения
2286
	dd 0 ;+4 left,top
2287
.w: dd 0
2288
.h: dd 0,0,24 ;+12 color,bit in pixel
2289
 
2290
font_h dd 0 ;высота шрифта
2291
 
2292
align 4
2293
buf_png:
2294
	dd 0,0
2295
.w: dd 0
2296
.h: dd 0,0xffffff,24
2297
 
2298
align 4
2299
el_focus dd tree1
2300
tree1 tree_list size_one_list,1000+2, tl_key_no_edit+tl_draw_par_line,\
2301
	16,16, 0xffffff,0xb0d0ff,0x400040, 5,35,195-16,340, 16,Figure.Caption,0,\
2302
	el_focus,w_scr_t1,0
2303
 
2304
align 4
2305
w_scr_t1 scrollbar 16,0, 3,0, 15, 100, 0,0, 0,0,0, 1
2306
 
2307
;input:
2308
; eax - число
2309
; edi - буфер для строки
2310
; len - длинна буфера
2311
;output:
2312
align 4
2313
proc convert_int_to_str uses eax ecx edx edi esi, len:dword
2314
	mov esi,[len]
2315
	add esi,edi
2316
	dec esi
2317
	call .str
2318
	ret
2319
endp
2320
 
2321
align 4
2322
.str:
2323
	mov ecx,10
2324
	cmp eax,ecx
2325
	jb @f
2326
		xor edx,edx
2327
		div ecx
2328
		push edx
2329
		;dec edi  ;смещение необходимое для записи с конца строки
2330
		call .str
2331
		pop eax
2332
	@@:
2333
	cmp edi,esi
2334
	jge @f
2335
		or al,0x30
2336
		stosb
2337
		mov byte[edi],0 ;в конец строки ставим 0, что-бы не вылазил мусор
2338
	@@:
2339
	ret
2340
 
2341
align 4
2342
proc mem_copy uses ecx esi edi, destination:dword, source:dword, len:dword
2343
	cld
2344
	mov esi, dword[source]
2345
	mov edi, dword[destination]
2346
	mov ecx, dword[len]
2347
	rep movsb
2348
	ret
2349
endp
2350
 
2351
align 16
2352
i_end:
2353
	rb 2048
2354
thread_coords:
2355
	rb 2048
2356
thread_scale:
2357
	rb 2048
2358
thread_n_file:
2359
	rb 2048
2360
stacktop:
2361
	sys_path rb 1024
2362
	file_name:
2363
		rb 1024 ;4096
2364
	library_path rb 1024
2365
	plugin_path rb 4096
2366
	openfile_path rb 4096
2367
	filename_area rb 256
2368
mem:
2369