Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
259 mikedld 1
 
2
3
 
4
func flush_cur_tab ;///// SAVE CURRENT TAB DATA TO CONTROL ///////////////////
267 mikedld 5
;-----------------------------------------------------------------------------
259 mikedld 6
; EBP = TABITEM*
7
;-----------------------------------------------------------------------------
8
	push	ecx esi edi
9
	mov	esi,cur_tab
10
	mov	edi,[tab_bar.Current.Ptr]
11
	mov	ecx,sizeof.TABITEM/4
12
	cld
13
	rep	movsd
14
	pop	edi esi ecx
15
	ret
16
endf
17
18
 
19
func set_cur_tab ;///// SET SPECIFIED TAB CURRENT (FOCUS IT) /////////////////
267 mikedld 20
;-----------------------------------------------------------------------------
259 mikedld 21
; EBP = TABITEM*
22
;-----------------------------------------------------------------------------
23
	push	ecx esi edi
24
	cmp	[tab_bar.Current.Ptr],0
25
	je	@f
26
	call	flush_cur_tab
27
    @@: mov	esi,ebp
28
	mov	edi,cur_tab
29
	mov	ecx,sizeof.TABITEM/4
30
	rep	movsd
31
	mov	[tab_bar.Current.Ptr],ebp
32
	call	update_caption
33
	pop	edi esi ecx
34
	ret
35
endf
36
37
 
38
func make_tab_visible ;///// MAKE SPECIFIED TAB VISIBLE IF IT'S OFFSCREEN ////
267 mikedld 39
;-----------------------------------------------------------------------------
259 mikedld 40
	push	ebp
267 mikedld 41
	imul	eax,[tab_bar.Items.Left],sizeof.TABITEM
42
	add	eax,[tab_bar.Items]
43
	cmp	eax,ebp
44
	jb	.go_right
45
	ja	.go_left
46
	add	esp,4
47
	ret
48
49
 
50
	call	get_hidden_tabitems_number
51
	cmp	ebp,[esp]
52
	ja	.lp1
53
    @@: inc	[tab_bar.Items.Left]
54
	call	get_hidden_tabitems_number
55
	cmp	ebp,[esp]
56
	jbe	@b
57
    @@: inc	[tab_bar.Items.Left]
58
  .lp1: pop	ebp
59
	ret
60
61
 
62
	mov	eax,ebp
63
	sub	eax,[tab_bar.Items]
64
	jz	@f
65
	cwde
66
	mov	ebx,sizeof.TABITEM
67
	div	ebx
68
    @@: mov	[tab_bar.Items.Left],eax
69
	add	esp,4
70
	ret
71
endf
72
73
 
74
func create_tab ;///// ADD TAB TO THE END ////////////////////////////////////
75
;-----------------------------------------------------------------------------
76
	push	eax ecx esi edi
259 mikedld 77
78
 
79
	imul	ebx,[tab_bar.Items.Count],sizeof.TABITEM
80
	mov	eax,[tab_bar.Items]
81
	mov	ecx,eax
82
	call	mem.ReAlloc
83
	mov	[tab_bar.Items],eax
84
	sub	ecx,eax
85
	sub	[tab_bar.Current.Ptr],ecx
86
	lea	ebp,[eax+ebx-sizeof.TABITEM]
87
	call	set_cur_tab
88
	call	make_tab_visible
267 mikedld 89
259 mikedld 90
 
91
	call	mem.Alloc
92
	mov	[cur_editor.Lines],eax
267 mikedld 93
	mov	[cur_editor.Lines.Count],1
94
	mov	[cur_editor.Columns.Count],1
95
	xor	eax,eax
259 mikedld 96
	mov	[cur_editor.TopLeft.X],eax
267 mikedld 97
	mov	[cur_editor.TopLeft.Y],eax
98
	mov	[cur_editor.Caret.X],eax
99
	mov	[cur_editor.Caret.Y],eax
100
	mov	[cur_editor.SelStart.X],eax
101
	mov	[cur_editor.SelStart.Y],eax
102
	mov	edi,[cur_editor.Lines]
103
	add	edi,4
259 mikedld 104
	mov	ecx,10
105
	mov	[edi-4],ecx
106
	mov	[edi+10],eax
107
	mov	al,' '
108
	cld
109
	rep	stosb
110
111
 
112
	mov	edi,cur_editor.FilePath
267 mikedld 113
	mov	ecx,s_defname.size
259 mikedld 114
	rep	movsb
115
	mov	[cur_editor.FileName],0
267 mikedld 116
259 mikedld 117
 
118
	mov	[cur_editor.Modified],0
267 mikedld 119
	mov	[cur_editor.AsmMode],0
120
259 mikedld 121
 
122
	call	update_caption
123
	call	drawwindow
124
125
 
126
	pop	edi esi ecx eax
127
	ret
128
endf
129
130
 
131
func delete_tab ;///// DELETE SPECIFIED TAB //////////////////////////////////
267 mikedld 132
;-----------------------------------------------------------------------------
259 mikedld 133
	mov	eax,[ebp+TABITEM.Editor.Lines]
267 mikedld 134
	call	mem.Free
135
	imul	ecx,[tab_bar.Items.Count],sizeof.TABITEM
136
	add	ecx,[tab_bar.Items]
137
	sub	ecx,ebp
138
	sub	ecx,sizeof.TABITEM
139
	jle	@f
140
	cld
141
	shr	ecx,2
142
	mov	edi,ebp
143
	lea	esi,[edi+sizeof.TABITEM]
144
	rep	movsd
145
    @@: dec	[tab_bar.Items.Count]
146
	jz	.no_tabs
147
	imul	ebx,[tab_bar.Items.Count],sizeof.TABITEM
148
	push	ebx
149
	mov	eax,[tab_bar.Items]
150
	mov	ecx,eax
151
	call	mem.ReAlloc
152
	mov	[tab_bar.Items],eax
153
	sub	ecx,eax
154
	sub	ebp,ecx
155
156
 
157
	add	ecx,[tab_bar.Items]
158
	sub	ecx,ebp
159
	ja	@f
160
	add	ebp,-sizeof.TABITEM
161
162
 
163
	call	set_cur_tab
164
	call	make_tab_visible
165
	call	drawwindow
166
	ret
259 mikedld 167
168
 
267 mikedld 169
	mov	eax,[tab_bar.Items]
170
	call	mem.Free
171
	mov	[tab_bar.Items],0
172
	mov	[tab_bar.Current.Ptr],0
173
	ret
259 mikedld 174
endf
175
176
 
177
func draw_tabctl ;///// DRAW TAB CONTROL /////////////////////////////////////
267 mikedld 178
;-----------------------------------------------------------------------------
259 mikedld 179
180
 
267 mikedld 181
	js	.lp1
182
    @@: call	get_hidden_tabitems_number
183
	or	eax,eax
184
	jnz	.lp1
185
	dec	[tab_bar.Items.Left]
186
	jns	@b
187
  .lp1: inc	[tab_bar.Items.Left]
188
	mov	eax,[tab_bar.Items.Count]
189
	cmp	[tab_bar.Items.Left],eax
190
	jb	@f
191
	dec	eax
192
	mov	[tab_bar.Items.Left],eax
193
    @@:
194
195
 
196
	mov	edx,[tab_bar.Buttons.First]
197
    @@: cmp	edx,[tab_bar.Buttons.Last]
198
	ja	@f
199
	push	edx
200
	or	edx,0x80000000
201
	mcall
202
	pop	edx
203
	inc	edx
204
	jmp	@b
205
    @@:
206
207
 
259 mikedld 208
	mov	bx,word[tab_bar.Bounds.Right]
209
	sub	bx,word[tab_bar.Bounds.Left]
210
	inc	ebx
211
	mov	ecx,[tab_bar.Bounds.Top-2]
212
	mov	cx,word[tab_bar.Bounds.Bottom]
213
	sub	cx,word[tab_bar.Bounds.Top]
214
	inc	ecx
215
	mov	edx,[cl_3d_normal]
216
	call	draw_framerect
217
218
 
219
	dec	al
220
	jz	.tabs_on_top
221
	dec	al
222
	jz	.tabs_on_bottom
223
	dec	al
224
	jz	.tabs_on_left
225
	dec	al
226
	jz	.tabs_on_right
227
	ret
228
229
 
230
	add	ebx,1*65536-2
231
	mov	ecx,[tab_bar.Bounds.Top-2]
232
	xor	cx,cx
233
	add	ecx,1*65536+TBARH
234
	mcall	13
235
	add	ecx,(TBARH-1)*65536-(TBARH-1)
267 mikedld 236
	mcall	,,,[sc.work]
237
	add	ecx,-1*65536+2
238
	mov	edx,[cl_3d_inset]
259 mikedld 239
	call	draw_framerect
240
267 mikedld 241
 
242
	inc	esi
243
	mov	edi,[tab_bar.Bounds.Top]
244
	inc	edi
245
	push	.curr_top .check_horz .next_horz
246
	call	.draw_tabs
247
	ret
259 mikedld 248
249
 
250
	add	ebx,1*65536-2
251
	mov	ecx,[tab_bar.Bounds.Bottom-2]
252
	xor	cx,cx
253
	add	ecx,-TBARH*65536+TBARH
254
	mcall	13
255
	mov	cx,1
256
	mcall	,,,[sc.work]
257
	add	ecx,-1*65536+2
267 mikedld 258
	mov	edx,[cl_3d_inset]
259 mikedld 259
	call	draw_framerect
260
261
 
262
	inc	esi
263
	mov	edi,[tab_bar.Bounds.Bottom]
264
	add	edi,-TBARH+1
265
	push	.curr_bottom .check_horz .next_horz
267 mikedld 266
	call	.draw_tabs
267
	ret
268
269
 
270
	call	get_max_tab_width
271
	mov	ebx,[tab_bar.Bounds.Left-2]
272
	mov	bx,ax
273
	add	ebx,1*65536-1
274
	add	ecx,1*65536-2
275
	push	eax
276
	mcall	13
277
	pop	ebx
278
	shl	ebx,16
279
	add	ebx,1*65536+1
280
	mcall	,,,[sc.work]
281
	add	ebx,-1*65536+2
282
	mov	edx,[cl_3d_inset]
283
	call	draw_framerect
284
285
 
286
	inc	esi
287
	mov	edi,[tab_bar.Bounds.Top]
288
	inc	edi
289
	push	.curr_left .check_vert .next_vert
290
	call	.draw_tabs
291
	ret
292
293
 
294
	call	get_max_tab_width
295
	push	eax
296
	mov	ebx,[tab_bar.Bounds.Right-2]
297
	mov	bx,ax
298
	shl	eax,16
299
	sub	ebx,eax
300
	add	ecx,1*65536-2
301
	mcall	13
302
	add	ebx,-1*65536
303
	mov	bx,1
304
	mcall	,,,[sc.work]
305
	add	ebx,-1*65536+2
306
	mov	edx,[cl_3d_inset]
307
	call	draw_framerect
308
309
 
310
	pop	eax
311
	sub	esi,eax
312
	mov	edi,[tab_bar.Bounds.Top]
313
	inc	edi
314
	push	.curr_right .check_vert .next_vert
315
	call	.draw_tabs
316
	ret
317
318
 
319
 
320
	mov	ecx,[tab_bar.Items.Count]
321
	mov	ebx,[tab_bar.Items.Left]
322
	imul	ebp,ebx,sizeof.TABITEM
323
	add	ebp,[tab_bar.Items]
324
	push	ecx
325
	sub	[esp],ebx
326
	add	ebx,1000
327
	mov	[tab_bar.Buttons.First],ebx
328
	dec	ebx
329
	mov	[tab_bar.Buttons.Last],ebx
330
    @@: push	ecx
259 mikedld 331
332
 
333
267 mikedld 334
 
335
	jc	.draw_tabs.dontfit
336
337
 
259 mikedld 338
	mov	bx,si
339
	rol	ebx,16
340
	rol	ecx,16
341
	mov	cx,di
342
	rol	ecx,16
343
	mov	edx,[cl_3d_inset]
344
	call	draw_framerect
345
346
 
267 mikedld 347
	cmp	ebp,[tab_bar.Current.Ptr]
259 mikedld 348
	jne	.draw_tabs.inactive
267 mikedld 349
	push	ebx ecx
259 mikedld 350
	call	dword[esp+(8+4)+8+8]
267 mikedld 351
	mcall	13,,,[sc.work]
259 mikedld 352
	pop	ecx ebx
353
	mov	edx,[color_tbl+4*0]
267 mikedld 354
  .draw_tabs.inactive:
355
356
 
357
	lea	eax,[ebp+TABITEM.Editor.FilePath]
259 mikedld 358
	add	eax,[ebp+TABITEM.Editor.FileName]
359
	mov	edx,eax
360
	call	strlen
361
	mov	esi,eax
362
	shr	ecx,16
363
	mov	bx,cx
364
	add	ebx,0x00050005
365
	pop	ecx
267 mikedld 366
	mcall	4
367
	pop	esi ecx ebx
368
259 mikedld 369
 
267 mikedld 370
	cmp	ebp,[tab_bar.Current.Ptr]
371
	je	.draw_tabs.active
372
	push	ebx ecx
373
	dec	ebx
374
	dec	ecx
375
	mov	edx,[tab_bar.Buttons.Last]
376
	or	edx,0x40000000
377
	mcall	8
378
	pop	ecx ebx
379
  .draw_tabs.active:
380
381
 
382
	add	ebp,sizeof.TABITEM
259 mikedld 383
384
 
385
	dec	ecx
386
	dec	dword[esp]
267 mikedld 387
	jnz	@b
259 mikedld 388
389
 
267 mikedld 390
	or	ecx,ecx
391
	jnz	@f
392
393
 
394
395
 
396
397
 
398
399
 
400
	shl	ebx,16
401
	mov	ecx,[tab_bar.Bounds.Bottom]
402
	shl	ecx,16
403
	add	ecx,(-SCRLW-1)*65536+SCRLW
404
	call	get_max_tab_width
405
	mov	edx,eax
406
407
 
408
	dec	al
409
	jz	.scroll_on_top
410
	dec	al
411
	jz	.scroll_on_bottom
412
	dec	al
413
	jz	.scroll_on_left
414
	dec	al
415
	jz	.scroll_on_right
416
	ret
259 mikedld 417
418
 
267 mikedld 419
	add	ebx,(-SCRLW*2-1)*65536+SCRLW
420
	mov	ecx,[tab_bar.Bounds.Top]
421
	shl	ecx,16
422
	add	ecx,1*65536+SCRLW
423
	jmp	.draw_tabs.draw_scroll
424
  .scroll_on_bottom:
425
	add	ebx,(-SCRLW*2-1)*65536+SCRLW
426
	jmp	.draw_tabs.draw_scroll
427
  .scroll_on_left:
428
	mov	ebx,[tab_bar.Bounds.Left]
429
	add	ebx,edx
430
	shl	ebx,16
431
	add	ebx,(-SCRLW*2)*65536+SCRLW
432
	jmp	.draw_tabs.draw_scroll
433
  .scroll_on_right:
434
	shl	edx,16
435
	sub	ebx,edx
436
	add	ebx,SCRLW
437
438
 
439
	mcall	8,,,'TBG' or 0x40000000
440
	push	ebx
441
	add	ebx,SCRLW*65536
442
	mcall	8,,,'TBL' or 0x40000000
443
	pop	ebx
444
	push	ebx ecx
445
	sar	ebx,16
446
	sar	ecx,16
447
	push	ebx ecx SCRLW SCRLW
448
	call	draw_3d_panel
449
	add	ebx,SCRLW
450
	push	ebx ecx SCRLW SCRLW
451
	call	draw_3d_panel
452
	pop	ecx ebx
453
454
 
455
	shr	ecx,16
456
	mov	bx,cx
457
	add	ebx,(SCRLW/2-2)*65536+SCRLW/2-3
458
	mcall	4,,[sc.work_text],esp,1
459
	add	ebx,0x00020000
460
	mcall
461
	add	ebx,(SCRLW-2)*65536
462
	mov	byte[esp],'>'
463
	mcall
464
	add	ebx,0x00020000
465
	mcall
466
	add	esp,4
467
468
 
469
470
 
471
	add	ebx,0x00010000
472
	add	ecx,1*65536-2
259 mikedld 473
	ret
267 mikedld 474
  .curr_top:
475
	add	ebx,1*65536-2
476
	add	ecx,0x00010000
477
	ret
478
  .curr_right:
479
	dec	ebx
480
	add	ecx,1*65536-2
481
	ret
482
  .curr_bottom:
483
	add	ebx,1*65536-2
484
	dec	ecx
485
	ret
486
487
 
488
	lea	eax,[ebx-1]
489
	add	eax,esi
490
	sub	eax,[tab_bar.Bounds.Right]
491
	jge	.check.dontfit
492
	add	eax,SCRLW*2+2
493
	jl	.check.fit
494
	cmp	dword[esp+4],1
495
	jbe	.check.fit
496
  .check.dontfit:
497
	stc
498
	ret
499
  .check_vert:
500
	lea	eax,[ecx-1]
501
	add	eax,edi
502
	sub	eax,[tab_bar.Bounds.Bottom]
503
	jge	.check.dontfit
504
	add	eax,SCRLW+2
505
	jl	.check.fit
506
	cmp	dword[esp+4],1
507
	ja	.check.dontfit
508
  .check.fit:
509
	clc
510
	ret
511
512
 
513
	movzx	ebx,bx
514
	lea	esi,[esi+ebx+1]
515
	ret
516
  .next_vert:
517
	movzx	ecx,cx
518
	lea	edi,[edi+ecx+1]
519
	ret
520
endf
521
522
 
523
func get_tab_size ;///// GET TAB WIDTH ///////////////////////////////////////
524
;-----------------------------------------------------------------------------
525
; EBP = TABITEM*
526
;-----------------------------------------------------------------------------
527
	push	eax
259 mikedld 528
	cmp	[tab_bar.Style],3
267 mikedld 529
	jae	.lp1
530
	lea	eax,[ebp+TABITEM.Editor.FilePath]
531
	add	eax,[ebp+TABITEM.Editor.FileName]
532
	call	strlen
533
	imul	ebx,eax,6
534
	add	ebx,9
535
	jmp	.lp2
536
  .lp1: call	get_max_tab_width
537
	mov	ebx,eax
538
  .lp2: mov	ecx,TBARH-1
539
	pop	eax
259 mikedld 540
	ret
541
endf
267 mikedld 542
259 mikedld 543
 
267 mikedld 544
func get_max_tab_width ;///// GET WIDTH OF LONGEST TAB ///////////////////////
545
;-----------------------------------------------------------------------------
546
	push	ebx ecx ebp
547
	mov	ecx,[tab_bar.Items.Count]
548
	mov	ebp,[tab_bar.Items]
549
	xor	ebx,ebx
550
    @@: dec	ecx
551
	js	@f
552
553
 
554
	add	eax,[ebp+TABITEM.Editor.FileName]
555
	call	strlen
556
	imul	eax,6
557
	add	eax,9
558
559
 
560
	cmp	ebx,eax
561
	jae	@b
562
	mov	ebx,eax
563
	jmp	@b
564
    @@: mov	eax,ebx
565
	cmp	eax,SCRLW*2+2
566
	jae	@f
567
	mov	eax,SCRLW*2+2
568
    @@: pop	ebp ecx ebx
569
	ret
259 mikedld 570
endf
571
572
 
267 mikedld 573
func get_hidden_tabitems_number ;/////////////////////////////////////////////
574
;-----------------------------------------------------------------------------
575
	mov	al,[tab_bar.Style]
576
	dec	al
577
	dec	al
578
	jle	.tabs_horz
579
	dec	al
580
	dec	al
581
	jle	.tabs_vert
582
	ret
259 mikedld 583
267 mikedld 584
 
585
	push	draw_tabctl.check_horz draw_tabctl.next_horz
586
	call	.calc_tabs
587
	ret
588
589
 
590
	push	draw_tabctl.check_vert draw_tabctl.next_vert
591
	call	.calc_tabs
592
	ret
593
594
 
595
	mov	esi,[tab_bar.Bounds.Left]
596
	inc	esi
597
	mov	edi,[tab_bar.Bounds.Top]
598
	inc	edi
599
	mov	ecx,[tab_bar.Items.Count]
600
	mov	ebp,[tab_bar.Items]
601
	imul	eax,[tab_bar.Items.Left],sizeof.TABITEM
602
	add	ebp,eax
603
	mov	eax,ecx
604
	sub	eax,[tab_bar.Items.Left]
605
	push	eax
606
    @@: push	ecx
607
608
 
609
610
 
611
	jc	.calc_tabs.dontfit
612
613
 
614
	add	ebp,sizeof.TABITEM
615
616
 
617
	dec	ecx
618
	dec	dword[esp]
619
	jnz	@b
620
621
 
622
623
 
624
625
 
626
    @@: pop	ecx
627
	mov	eax,ecx
628
	ret	8
629
endf
259 mikedld 630
631
 
267 mikedld 632
func align_editor_in_tab ;///// ADJUST EDITOR POSITION TO FIT IN TAB /////////
633
;-----------------------------------------------------------------------------
634
	m2m	[cur_editor.Bounds.Left],[tab_bar.Bounds.Left]
635
	m2m	[cur_editor.Bounds.Top],[tab_bar.Bounds.Top]
636
	m2m	[cur_editor.Bounds.Right],[tab_bar.Bounds.Right]
637
	m2m	[cur_editor.Bounds.Bottom],[tab_bar.Bounds.Bottom]
638
259 mikedld 639
 
267 mikedld 640
	inc	[cur_editor.Bounds.Top]
641
	dec	[cur_editor.Bounds.Right]
642
	dec	[cur_editor.Bounds.Bottom]
643
259 mikedld 644
 
267 mikedld 645
	lea	ebx,[eax+1]
646
647
 
259 mikedld 648
	dec	al
649
	jz	.tabs_on_top
650
	dec	al
651
	jz	.tabs_on_bottom
652
	dec	al
653
	jz	.tabs_on_left
654
	dec	al
655
	jz	.tabs_on_right
656
	ret
657
658
 
659
	add	[cur_editor.Bounds.Top],TBARH
267 mikedld 660
	ret
259 mikedld 661
662
 
663
	sub	[cur_editor.Bounds.Bottom],TBARH
267 mikedld 664
	ret
259 mikedld 665
666
 
667
	add	[cur_editor.Bounds.Left],ebx
267 mikedld 668
	ret
259 mikedld 669
670
 
671
	sub	[cur_editor.Bounds.Right],ebx
267 mikedld 672
	ret
259 mikedld 673
endf
267 mikedld 674
>