Subversion Repositories Kolibri OS

Rev

Rev 4488 | Rev 4493 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4488 Rev 4491
Line 1... Line 1...
1
#include "..\lib\draw_buf.h"
1
#include "..\lib\draw_buf.h"
2
#include "..\lib\list_box.h"
2
#include "..\lib\list_box.h"
3
 
-
 
-
 
3
#include "..\TWB\links.h"
Line 4... Line 4...
4
 
4
 
Line 5... Line 5...
5
int	downloader_id;
5
int	downloader_id;
6
 
6
 
Line 33... Line 33...
33
	void TextGoDown();
33
	void TextGoDown();
34
};
34
};
Line 35... Line 35...
35
 
35
 
Line 36... Line 36...
36
TWebBrowser WB1;
36
TWebBrowser WB1;
37
 
37
 
38
byte rez, b_text, i_text, u_text, s_text, pre_text, blq_text, li_text, li_tab, 
38
byte b_text, i_text, u_text, s_text, pre_text, blq_text, li_text, li_tab, 
Line 39... Line 39...
39
	link, ignor_text, cur_encoding, text_align;
39
	link, ignor_text, cur_encoding, text_align;
Line 40... Line 40...
40
byte condition_text_active, condition_text_val, condition_href, condition_max;
40
byte condition_text_active, condition_text_val, condition_href, condition_max;
Line 41... Line 41...
41
 
41
 
42
enum { _WIN, _DOS, _KOI, _UTF };
42
enum { _WIN, _DOS, _KOI, _UTF };
-
 
43
 
43
 
44
enum { ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT};
44
enum { ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT};
45
 
Line 45... Line 46...
45
 
46
dword text_colors[300];
46
dword text_colors[300];
47
dword text_color_index;
47
dword text_color_index;
48
dword link_color_inactive;
Line 63... Line 64...
63
#include "..\TWB\history.h"
64
#include "..\TWB\history.h"
64
#include "..\TWB\colors.h"
65
#include "..\TWB\colors.h"
65
#include "..\TWB\unicode_tags.h"
66
#include "..\TWB\unicode_tags.h"
66
#include "..\TWB\img_cache.h"
67
#include "..\TWB\img_cache.h"
67
#include "..\TWB\parce_tag.h"
68
#include "..\TWB\parce_tag.h"
68
#include "..\TWB\links.h"
-
 
Line 69... Line 69...
69
 
69
 
Line 210... Line 210...
210
	b_text = i_text = u_text = s_text = blq_text = 
210
	b_text = i_text = u_text = s_text = blq_text = 
211
	li_text = link = ignor_text = text_color_index = text_colors[0] = li_tab = 
211
	li_text = link = ignor_text = text_color_index = text_colors[0] = li_tab = 
212
	condition_text_val = condition_text_active = 0; //îáíóëÿåì òåãè
212
	condition_text_val = condition_text_active = 0; //îáíóëÿåì òåãè
213
	condition_max = 255;
213
	condition_max = 255;
214
	text_align = ALIGN_LEFT;
214
	text_align = ALIGN_LEFT;
215
	link_color = 0x0000FF;
215
	link_color_inactive = 0x0000FF;
-
 
216
	link_color_active = 0xFF0000;
216
	bg_color = 0xFFFFFF;
217
	bg_color = 0xFFFFFF;
217
	DrawBuf.Fill(bg_color);
218
	DrawBuf.Fill(bg_color);
218
	PageLinks.Clear();
219
	PageLinks.Clear();
219
	strcpy(#header, #version);
220
	strcpy(#header, #version);
220
	stroka = -list.first;
221
	stroka = -list.first;
Line 329... Line 330...
329
				DrawPage();
330
				DrawPage();
330
				strcpy(#line, #temp);				
331
				strcpy(#line, #temp);				
331
				TextGoDown(list.x + 5, stroka * 10 + list.y + 5, list.w - 20); //çàêðàøèâàåì ñëåäóùóþ ñòðîêó
332
				TextGoDown(list.x + 5, stroka * 10 + list.y + 5, list.w - 20); //çàêðàøèâàåì ñëåäóùóþ ñòðîêó
332
			}
333
			}
333
			DrawPage();
334
			DrawPage();
334
			line=NULL;
-
 
Line 335... Line 335...
335
 
335
 
-
 
336
			if (tag) WhatTextStyle(list.x + 5, stroka * 10 + list.y + 5, list.w - 20); //îáðàáîòêà òåãîâ
Line 336... Line 337...
336
			if (tag) WhatTextStyle(list.x + 5, stroka * 10 + list.y + 5, list.w - 20); //îáðàáîòêà òåãîâ
337
			line=NULL;
337
 
338
 
338
			tag = parametr = tagparam = ignor_param = NULL;
339
			tag = parametr = tagparam = ignor_param = NULL;
339
			break;
340
			break;
Line 382... Line 383...
382
 
383
 
383
 
384
 
384
char oldtag[100];
385
char oldtag[100];
-
 
386
void TWebBrowser::WhatTextStyle(int left1, top1, width1) {
Line 385... Line 387...
385
void TWebBrowser::WhatTextStyle(int left1, top1, width1) {
387
	dword hr_color;
386
	dword hr_color;
388
	byte opened;
387
 
389
 
388
	//ïðîâåðÿåì òåã îòêðûâàåòñÿ èëè çàêðûâàåòñÿ
390
	//ïðîâåðÿåì òåã îòêðûâàåòñÿ èëè çàêðûâàåòñÿ
389
	if (tag[0] == '/') 
391
	if (tag[0] == '/') 
390
	{
392
	{
391
		 rez = 0;
393
		 opened = 0;
Line 392... Line 394...
392
		 strcpy(#tag, #tag+1);
394
		 strcpy(#tag, #tag+1);
393
	}
395
	}
394
	else rez = 1;
396
	else opened = 1;
395
		
397
		
396
	if (isTag("html"))
398
	if (isTag("html"))
Line 397... Line 399...
397
	{
399
	{
Line 398... Line 400...
398
		IF(!strcmp(#URL + strlen(#URL) - 4, ".mht")) IF (rez==0) ignor_text = 1; ELSE ignor_text = 0;
400
		IF(!strcmp(#URL + strlen(#URL) - 4, ".mht")) IF (opened==0) ignor_text = 1; ELSE ignor_text = 0;
399
		return;
401
		return;
400
	}
402
	}
401
 
403
 
402
	if (isTag("script")) || (isTag("style")) || (isTag("binary")) ignor_text = rez;
404
	if (isTag("script")) || (isTag("style")) || (isTag("binary")) ignor_text = opened;
403
 
405
 
Line 404... Line 406...
404
	if(isTag("title"))
406
	if(isTag("title"))
Line -... Line 407...
-
 
407
	{
405
	{
408
		if (opened) header=NULL;
-
 
409
		else if (!stroka) DrawTitle(#header); //òåã çàêðûëñÿ - âûâåëè ñòðîêó
406
		if (rez) header=NULL;
410
		return;
-
 
411
	}
-
 
412
 
-
 
413
	if (ignor_text) return;
-
 
414
	
-
 
415
	IF(isTag("q"))
407
		else if (!stroka) DrawTitle(#header); //òåã çàêðûëñÿ - âûâåëè ñòðîêó
416
	{
-
 
417
		if (opened)
-
 
418
		{
-
 
419
			TextGoDown(left1, top1, width1);
Line 408... Line 420...
408
		return;
420
			strcat(#line, ' \"');
409
	}
421
		}
410
 
422
		if (!opened)
411
	if (ignor_text) return;
423
		{
Line 412... Line 424...
412
 
424
			chrcat(#line, '\"');
413
 
425
			TextGoDown(left1, top1, width1);
414
	
426
		} 
415
	IF(isTag("q")) chrcat(#line, '\"');
427
	}
-
 
428
 
416
 
429
	if (anchor) && (!strcmp(#parametr, "id=")) //î÷åíü ïëîõî!!! ïîòîìó ÷òî åñëè íå ïîñëåäíèé òåã, ðàáîòàòü íå áóäåò
417
	if (anchor) && (!strcmp(#parametr, "id=")) //î÷åíü ïëîõî!!! ïîòîìó ÷òî åñëè íå ïîñëåäíèé òåã, ðàáîòàòü íå áóäåò
430
	{
418
	{
431
		if (!strcmp(#anchor, #options))	anchor_line_num=list.first+stroka;
419
		if (!strcmp(#anchor, #options))	anchor_line_num=list.first+stroka;
432
	}
420
	}
433
	
421
	
434
	if (isTag("body"))
Line 434... Line 447...
434
		return;
447
		return;
435
	}
448
	}
Line 436... Line 449...
436
 
449
 
437
	if (isTag("a"))
450
	if (isTag("a"))
438
	{
451
	{
439
		if (rez)
452
		if (opened)
440
		{
453
		{
Line 441... Line 454...
441
			if (link) IF(text_color_index > 0) text_color_index--; //åñëè ïðåäûäóùèé òåã à íå áûë çàêðûò
454
			if (link) IF(text_color_index > 0) text_color_index--; //åñëè ïðåäûäóùèé òåã à íå áûë çàêðûò
442
 
455
 
Line 448... Line 461...
448
					text_color_index++;
461
					text_color_index++;
449
					text_colors[text_color_index] = text_colors[text_color_index-1];
462
					text_colors[text_color_index] = text_colors[text_color_index-1];
Line 450... Line 463...
450
					
463
					
451
					link = 1;
464
					link = 1;
452
					blink++;
465
					blink++;
453
					text_colors[text_color_index] = link_color;
466
					text_colors[text_color_index] = link_color_inactive;
454
					PageLinks.Add(#options);
467
					PageLinks.AddLink(#options, stolbec*6+left1, top1);
455
				}
468
				}
456
				if (anchor) && (!strcmp(#parametr, "name="))
469
				if (anchor) && (!strcmp(#parametr, "name="))
457
				{
470
				{
458
					if (!strcmp(#anchor, #options))
471
					if (!strcmp(#anchor, #options))
Line 462... Line 475...
462
				}
475
				}
463
			} while(GetNextParam());
476
			} while(GetNextParam());
464
		}
477
		}
465
		else {
478
		else {
466
			link = 0;
479
			link = 0;
-
 
480
			PageLinks.AddText(#line, strlen(#line)*6, list.line_h);
467
			IF(text_color_index > 0) text_color_index--;
481
			IF(text_color_index > 0) text_color_index--;
468
		}
482
		}
469
		return;
483
		return;
470
	}
484
	}
Line 471... Line 485...
471
 
485
 
472
	if (isTag("font"))
486
	if (isTag("font"))
473
	{
487
	{
474
		if (rez)
488
		if (opened)
475
		{
489
		{
476
			text_color_index++;
490
			text_color_index++;
Line 477... Line 491...
477
			text_colors[text_color_index] = text_colors[text_color_index-1];
491
			text_colors[text_color_index] = text_colors[text_color_index-1];
Line 496... Line 510...
496
		return;
510
		return;
497
	}
511
	}
498
	if (isTag("p")) {
512
	if (isTag("p")) {
499
		IF(oldtag[0] == 'h') return;
513
		IF(oldtag[0] == 'h') return;
500
		TextGoDown(left1, top1, width1);
514
		TextGoDown(left1, top1, width1);
501
		IF(rez) TextGoDown(left1, top1 + 10, width1);
515
		IF(opened) TextGoDown(left1, top1 + 10, width1);
502
		return;
516
		return;
503
	}
517
	}
504
	/*
518
	/*
505
	if (isTag("center"))
519
	if (isTag("center"))
506
	{
520
	{
507
		if (rez) text_align = ALIGN_CENTER;
521
		if (opened) text_align = ALIGN_CENTER;
508
		if (!rez)
522
		if (!opened)
509
		{
523
		{
510
			TextGoDown(left1, top1, width1);
524
			TextGoDown(left1, top1, width1);
511
			text_align = ALIGN_LEFT;
525
			text_align = ALIGN_LEFT;
512
		}
526
		}
513
		return;
527
		return;
514
	}
528
	}
515
	if (isTag("right"))
529
	if (isTag("right"))
516
	{
530
	{
517
		if (rez) text_align = ALIGN_RIGHT;
531
		if (opened) text_align = ALIGN_RIGHT;
518
		if (!rez)
532
		if (!opened)
519
		{
533
		{
520
			TextGoDown(left1, top1, width1);
534
			TextGoDown(left1, top1, width1);
521
			text_align = ALIGN_LEFT;
535
			text_align = ALIGN_LEFT;
522
		}
536
		}
523
		return;
537
		return;
524
	}
538
	}
525
	*/
539
	*/
526
	if (isTag("h1")) || (isTag("h2")) || (isTag("h3")) || (isTag("h4")) {
540
	if (isTag("h1")) || (isTag("h2")) || (isTag("h3")) || (isTag("h4")) {
527
		TextGoDown(left1, top1, width1);
541
		TextGoDown(left1, top1, width1);
528
		if (rez) && (stroka>1) TextGoDown(left1, top1 + 10, width1);
542
		if (opened) && (stroka>1) TextGoDown(left1, top1 + 10, width1);
529
		strcpy(#oldtag, #tag);
543
		strcpy(#oldtag, #tag);
530
		if (rez)
544
		if (opened)
531
		{
545
		{
532
			if (!strcmp(#parametr, "align=")) && (!strcmp(#options,"center")) text_align = ALIGN_CENTER;
546
			if (!strcmp(#parametr, "align=")) && (!strcmp(#options,"center")) text_align = ALIGN_CENTER;
533
			if (!strcmp(#parametr, "align=")) && (!strcmp(#options,"right")) text_align = ALIGN_RIGHT;
547
			if (!strcmp(#parametr, "align=")) && (!strcmp(#options,"right")) text_align = ALIGN_RIGHT;
534
			b_text = 1;
548
			b_text = 1;
535
		}
549
		}
536
		if (!rez)
550
		if (!opened)
537
		{
551
		{
538
			text_align = ALIGN_LEFT;
552
			text_align = ALIGN_LEFT;
539
			b_text = 0;
553
			b_text = 0;
540
		}
554
		}
541
		return;
555
		return;
542
	}
556
	}
543
	else
557
	else
544
		oldtag=NULL;
558
		oldtag=NULL;
Line 545... Line 559...
545
		
559
		
546
	if (isTag("b")) || (isTag("strong")) || (isTag("big")) {
560
	if (isTag("b")) || (isTag("strong")) || (isTag("big")) {
547
		b_text = rez;
561
		b_text = opened;
548
		return;
562
		return;
549
	}
563
	}
550
	if(isTag("i")) || (isTag("em")) || (isTag("subtitle")) {
564
	if(isTag("i")) || (isTag("em")) || (isTag("subtitle")) {
551
		i_text = rez;
565
		i_text = opened;
552
		return;
566
		return;
553
	}	
567
	}	
554
	if (isTag("dt"))
568
	if (isTag("dt"))
555
	{
569
	{
556
		li_text = rez;
570
		li_text = opened;
557
		IF(rez == 0) return;
571
		IF(opened == 0) return;
558
		TextGoDown(left1, top1, width1);
572
		TextGoDown(left1, top1, width1);
559
		return;
573
		return;
560
	}
574
	}
561
	if (isTag("condition"))
575
	if (isTag("condition"))
562
	{
576
	{
563
		condition_text_active = rez;
577
		condition_text_active = opened;
564
		if (rez) && (!strcmp(#parametr, "show_if=")) condition_text_val = atoi(#options);
578
		if (opened) && (!strcmp(#parametr, "show_if=")) condition_text_val = atoi(#options);
565
		return;
579
		return;
566
	}
580
	}
567
	if (isTag("li")) || (isTag("dt")) //íàäî ñäåëàòü âëîæåííûå ñïèñêè
581
	if (isTag("li")) || (isTag("dt")) //íàäî ñäåëàòü âëîæåííûå ñïèñêè
568
	{
582
	{
569
		li_text = rez;
583
		li_text = opened;
570
		if (rez)
584
		if (opened)
571
		{
585
		{
572
			TextGoDown(left1, top1, width1);
586
			TextGoDown(left1, top1, width1);
573
			if (stroka > -1) && (stroka - 2 < list.visible) DrawBuf.DrawBar(li_tab * 5 * 6 + left1 - 5, list.line_h/2-3, 2, 2, 0x555555);
587
			if (stroka > -1) && (stroka - 2 < list.visible) DrawBuf.DrawBar(li_tab * 5 * 6 + left1 - 5, list.line_h/2-3, 2, 2, 0x555555);
574
		}
588
		}
575
		return;
589
		return;
576
	}
590
	}
577
	if (isTag("u")) || (isTag("ins")) u_text = rez;
591
	if (isTag("u")) || (isTag("ins")) u_text = opened;
578
	if (isTag("s")) || (isTag("strike")) || (isTag("del")) s_text = rez;
592
	if (isTag("s")) || (isTag("strike")) || (isTag("del")) s_text = opened;
579
	if (isTag("ul")) || (isTag("ol")) IF(!rez)
593
	if (isTag("ul")) || (isTag("ol")) IF(!opened)
580
	{
594
	{
581
		li_text = rez;
595
		li_text = opened;
582
		li_tab--;
596
		li_tab--;
583
		TextGoDown(left1, top1, width1);
597
		TextGoDown(left1, top1, width1);
584
	} ELSE li_tab++;
598
	} ELSE li_tab++;
585
	if (isTag("dd")) stolbec += 5;
599
	if (isTag("dd")) stolbec += 5;
586
	if (isTag("blockquote")) blq_text = rez;
600
	if (isTag("blockquote")) blq_text = opened;
587
	if (isTag("pre")) pre_text = rez; 
601
	if (isTag("pre")) pre_text = opened; 
588
	if (isTag("hr"))
602
	if (isTag("hr"))
589
	{
603
	{
590
		if (anchor) || (stroka < -1)
604
		if (anchor) || (stroka < -1)
591
		{
605
		{
Line 597... Line 611...
597
		DrawBuf.DrawBar(5, list.line_h/2, list.w-10, 1, hr_color);
611
		DrawBuf.DrawBar(5, list.line_h/2, list.w-10, 1, hr_color);
598
		TextGoDown(left1, top1+list.line_h, width1);
612
		TextGoDown(left1, top1+list.line_h, width1);
599
	}
613
	}
600
	if (isTag("img"))
614
	if (isTag("img"))
601
	{
615
	{
602
		ImgCache1.Images( left1, top1, width1);
616
		ImgCache.Images( left1, top1, width1);
603
		return;
617
		return;
604
	}
618
	}
605
	if (isTag("meta")) || (isTag("?xml"))
619
	if (isTag("meta")) || (isTag("?xml"))
606
	{
620
	{
607
		do{
621
		do{
Line 615... Line 629...
615
		} while(GetNextParam());
629
		} while(GetNextParam());
616
		return;
630
		return;
617
	}
631
	}
618
}
632
}
Line -... Line 633...
-
 
633
 
-
 
634
/*
-
 
635
char *encodings = {
-
 
636
	"utf-8",  _UTF,
-
 
637
	"utf8",   _UTF,
-
 
638
	"koi8-r", _KOI,
-
 
639
	"koi8-u", _KOI,
-
 
640
	"dos",    _DOS,
-
 
641
	"cp-866", _DOS
-
 
642
};
Line 619... Line 643...
619
 
643
*/
620
 
644
 
621
void TWebBrowser::DrawScroller() //íå îïòèìàëüíàÿ îòðèñîâêà, íî çàòî â îäíîì ìåñòå
645
void TWebBrowser::DrawScroller() //íå îïòèìàëüíàÿ îòðèñîâêà, íî çàòî â îäíîì ìåñòå
622
{
646
{