Subversion Repositories Kolibri OS

Rev

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