Subversion Repositories Kolibri OS

Rev

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

Rev 7759 Rev 7762
Line 34... Line 34...
34
	int cur_encoding, custom_encoding;
34
	int cur_encoding, custom_encoding;
35
	bool link, t_html, t_body;
35
	bool link, t_html, t_body;
36
	dword bufpointer;
36
	dword bufpointer;
37
	dword bufsize;
37
	dword bufsize;
Line -... Line 38...
-
 
38
 
38
 
39
	void DrawStyle();
39
	void SetPageDefaults();
40
	void SetPageDefaults();
40
	void AddCharToTheLine();
41
	void AddCharToTheLine();
41
	void ParseHtml();
42
	void ParseHtml();
42
	void SetStyle();
-
 
43
	void DrawStyle();
-
 
44
	void DrawPage();
-
 
45
	void DrawScroller();
-
 
46
	void NewLine();
43
	void SetStyle();
-
 
44
	bool CheckForLineBreak();
-
 
45
	void NewLine();
-
 
46
	void DrawScroller();
-
 
47
	void ChangeEncoding();
47
	bool CheckForLineBreak();
48
	void DrawPage();
48
	char line[500];
49
	char line[500];
49
	char header[150];
50
	char header[150];
Line 50... Line 51...
50
};
51
};
Line 51... Line 52...
51
 
52
 
52
scroll_bar scroll_wv = { 15,NULL,NULL,NULL,0,2,NULL,0,0,0xeeeeee,0xBBBbbb,0xeeeeee};
53
scroll_bar scroll_wv = { 15,NULL,NULL,NULL,0,2,NULL,0,0,0xeeeeee,0xBBBbbb,0xeeeeee};
53
 
54
 
54
//============================================================================================
55
//============================================================================================
-
 
56
void TWebBrowser::DrawStyle()
Line 55... Line 57...
55
void TWebBrowser::DrawStyle()
57
{
56
{
58
	dword start_x, line_length, stolbec_len;
57
	dword start_x, line_length, stolbec_len;
59
	dword text_color__;
58
	
60
	
Line 89... Line 91...
89
		if (style.button) {
91
		if (style.button) {
90
			DrawBuf.DrawBar(start_x, draw_y, line_length, list.item_h - calc(zoom*2), 0xCCCccc);
92
			DrawBuf.DrawBar(start_x, draw_y, line_length, list.item_h - calc(zoom*2), 0xCCCccc);
91
			DrawBuf.DrawBar(start_x, draw_y + list.item_h - calc(zoom*2), line_length, zoom, 0x999999);
93
			DrawBuf.DrawBar(start_x, draw_y + list.item_h - calc(zoom*2), line_length, zoom, 0x999999);
92
		}
94
		}
Line -... Line 95...
-
 
95
 
-
 
96
		text_color__ = text_colors[text_color_index];
-
 
97
		if (link) && (text_colors[text_color_index]==text_colors[0]) text_color__ = link_color_default;
-
 
98
 
93
 
99
 
94
		DrawBuf.WriteText(start_x, draw_y, list.font_type, text_colors[text_color_index], #line);
100
		DrawBuf.WriteText(start_x, draw_y, list.font_type, text_color__, #line);
95
		if (style.b) DrawBuf.WriteText(start_x+1, draw_y, list.font_type, text_colors[text_color_index], #line);
101
		if (style.b) DrawBuf.WriteText(start_x+1, draw_y, list.font_type, text_color__, #line);
96
		if (style.s) DrawBuf.DrawBar(start_x, list.item_h / 2 - zoom + draw_y, line_length, zoom, text_colors[text_color_index]);
102
		if (style.s) DrawBuf.DrawBar(start_x, list.item_h / 2 - zoom + draw_y, line_length, zoom, text_color__);
97
		if (style.u) DrawBuf.DrawBar(start_x, list.item_h - zoom - zoom + draw_y, line_length, zoom, text_colors[text_color_index]);
103
		if (style.u) DrawBuf.DrawBar(start_x, list.item_h - zoom - zoom + draw_y, line_length, zoom, text_color__);
98
		if (link) {
104
		if (link) {
99
			if (line[0]==' ') && (line[1]==NULL) {} else {
105
			if (line[0]==' ') && (line[1]==NULL) {} else {
100
				DrawBuf.DrawBar(start_x, draw_y + list.item_h - calc(zoom*2)-1, line_length, zoom, link_color_default);
106
				DrawBuf.DrawBar(start_x, draw_y + list.item_h - calc(zoom*2)-1, line_length, zoom, link_color_default);
101
				PageLinks.AddText(start_x, draw_y + list.y, line_length, list.item_h - calc(zoom*2)-1, UNDERLINE, zoom);				
107
				PageLinks.AddText(start_x, draw_y + list.y, line_length, list.item_h - calc(zoom*2)-1, UNDERLINE, zoom);				
Line 220... Line 226...
220
 
226
 
221
			ignor_param=false;
227
			ignor_param=false;
222
			while (ESBYTE[bufpos] !='>') && (bufpos < bufpointer + bufsize) //ïîëó÷àåì òåã è åãî ïàðàìåòðû
228
			while (ESBYTE[bufpos] !='>') && (bufpos < bufpointer + bufsize) //ïîëó÷àåì òåã è åãî ïàðàìåòðû
223
			{
229
			{
224
				bukva = ESBYTE[bufpos];
230
				bukva = ESBYTE[bufpos];
225
				if (bukva == '\9') || (bukva == '\x0a') || (bukva == '\x0d') bukva = ' ';
231
				if (bukva == '\x9') || (bukva == '\x0a') || (bukva == '\x0d') bukva = ' ';
226
				if (!ignor_param) && (bukva <>' ')
232
				if (!ignor_param) && (bukva <>' ')
227
				{
233
				{
228
					if (strlen(#tag.name)+1
234
					if (strlen(#tag.name)+1
229
				}
235
				}
Line 292... Line 298...
292
	
298
	
Line 293... Line 299...
293
	DrawStyle();
299
	DrawStyle();
294
 
300
 
295
	strcpy(#line, #new_line_text);
301
	strcpy(#line, #new_line_text);
296
	NewLine();
302
	NewLine();
297
	//if (strlen(#line)*zoom + stolbec > list.column_max)CheckForLineBreak();
303
	//while (CheckForLineBreak()==true) {};
298
	return true;
304
	return true;
299
}
305
}
300
//============================================================================================
306
//============================================================================================
301
void TWebBrowser::SetStyle() {
-
 
Line 302... Line 307...
302
	char img_path[4096]=0;
307
void TWebBrowser::SetStyle() {
Line 303... Line 308...
303
	int meta_encoding;
308
	char img_path[4096]=0;
304
 
309
 
Line 313... Line 318...
313
	}
318
	}
314
	if (tag.is("html")) {
319
	if (tag.is("html")) {
315
		t_html = tag.opened;
320
		t_html = tag.opened;
316
		return;
321
		return;
317
	}
322
	}
318
	if (tag.is("q"))
-
 
319
	{
-
 
320
		if (tag.opened)	{
-
 
321
			meta_encoding = strlen(#line);
-
 
322
			if (line[meta_encoding-1] != ' ') chrcat(#line, ' ');
-
 
323
			chrcat(#line, '\"');
-
 
324
		}
-
 
325
		if (!tag.opened) strcat(#line, "\" ");
-
 
326
		return;
-
 
327
	}
-
 
328
	if (tag.is("title")) {
323
	if (tag.is("title")) {
329
		style.tag_title = tag.opened;
324
		style.tag_title = tag.opened;
330
		if (!tag.opened) DrawTitle(#header);
325
		if (!tag.opened) DrawTitle(#header);
331
		return;
326
		return;
332
	}
327
	}
Line 337... Line 332...
337
		if (value = tag.get_value_of("text="))  text_colors[0]=GetColor(value);
332
		if (value = tag.get_value_of("text="))  text_colors[0]=GetColor(value);
338
		if (value = tag.get_value_of("bgcolor=")) {
333
		if (value = tag.get_value_of("bgcolor=")) {
339
			style.bg_color = page_bg = GetColor(value);
334
			style.bg_color = page_bg = GetColor(value);
340
			DrawBuf.Fill(0, page_bg);
335
			DrawBuf.Fill(0, page_bg);
341
		}
336
		}
-
 
337
		// Autodetecting encoding if no encoding was set
-
 
338
		if (tag.opened) && (custom_encoding==-1) && (cur_encoding == CH_CP866) {
-
 
339
			if (strstr(bufpointer, "\208\190")) ChangeEncoding(CH_UTF8);
-
 
340
			else if (chrnum(bufpointer, '\x246')>5) ChangeEncoding(CH_CP1251);
-
 
341
		}
342
		return;
342
		return;
343
	}
343
	}
-
 
344
	if (tag.is("br")) { NewLine(); return; }
-
 
345
	if (tag.is("b")) || (tag.is("strong")) || (tag.is("big")) { style.b = tag.opened; return; }
344
	if (tag.is("a")) {
346
	if (tag.is("a")) {
345
		if (tag.opened)
347
		if (tag.opened)
346
		{
348
		{
347
			if (link) IF(text_color_index > 0) text_color_index--; //åñëè ïðåäûäóùèé òåã à íå áûë çàêðûò
-
 
348
			if (value = tag.get_value_of("href=")) && (!strstr(value,"javascript:"))
349
			if (value = tag.get_value_of("href=")) && (!strstr(value,"javascript:"))
349
			{
350
			{
350
				text_color_index++;
-
 
351
				text_colors[text_color_index] = text_colors[text_color_index-1];
-
 
352
				link = 1;
351
				link = true;
353
				text_colors[text_color_index] = link_color_default;
-
 
354
				PageLinks.AddLink(value);
352
				PageLinks.AddLink(value);
355
			}
353
			}
356
		} else {
354
		} else {
357
			link = 0;
355
			link = false;
358
			IF(text_color_index > 0) text_color_index--;
-
 
359
		}
356
		}
360
		return;
357
		return;
361
	}
358
	}
-
 
359
	if (tag.is("iframe")) && (value = tag.get_value_of("src=")) {
-
 
360
		NewLine();
-
 
361
		strcpy(#line, "IFRAME: ");
-
 
362
		DrawStyle();
-
 
363
		link=true;
-
 
364
		PageLinks.AddLink(value);
-
 
365
		strncpy(#line, value, sizeof(TWebBrowser.line)-1);
-
 
366
		while (CheckForLineBreak()) {};
-
 
367
		DrawStyle();
-
 
368
		link=false;
-
 
369
		NewLine();
-
 
370
	}
362
	if (tag.is("font")) {
371
	if (tag.is("font")) {
363
		style.bg_color = page_bg;
372
		style.bg_color = page_bg;
364
		if (tag.opened)
373
		if (tag.opened)
365
		{
374
		{
366
			text_color_index++;
375
			text_color_index++;
Line 383... Line 392...
383
	if (tag.is("p")) {
392
	if (tag.is("p")) {
384
		IF (tag.prior[0] == 'h') || (streq(#tag.prior,"td")) || (streq(#tag.prior,"p")) return;
393
		IF (tag.prior[0] == 'h') || (streq(#tag.prior,"td")) || (streq(#tag.prior,"p")) return;
385
		NewLine();
394
		NewLine();
386
		return;
395
		return;
387
	}
396
	}
388
	if (tag.is("br")) { NewLine(); return; }
397
	if (tag.is("pre")) { style.pre = tag.opened; return; }
389
	if (tag.is("td")) { if (tag.opened) AddCharToTheLine(' '); return; }
398
	if (tag.is("td")) { if (tag.opened) AddCharToTheLine(' '); return; }
390
	if (tag.is("tr")) { if (tag.opened) NewLine(); return; }
399
	if (tag.is("tr")) { if (tag.opened) NewLine(); return; }
391
	if (tag.is("b")) || (tag.is("strong")) || (tag.is("big")) { style.b = tag.opened; return; }
-
 
392
	if (tag.is("button")) { style.button = tag.opened; stolbec++; return; }
400
	if (tag.is("button")) { style.button = tag.opened; stolbec++; return; }
393
	if (tag.is("u")) || (tag.is("ins")) { style.u=tag.opened; return;}
401
	if (tag.is("u")) || (tag.is("ins")) { style.u=tag.opened; return;}
394
	if (tag.is("s")) || (tag.is("strike")) || (tag.is("del")) { style.s=tag.opened; return; }
402
	if (tag.is("s")) || (tag.is("strike")) || (tag.is("del")) { style.s=tag.opened; return; }
395
	if (tag.is("dd")) { stolbec += 5; return; }
403
	//if (tag.is("dd")) { stolbec += 5; return; } //stolbec overflow!
396
	if (tag.is("blockquote")) { style.blq = tag.opened; return; }
404
	if (tag.is("blockquote")) { style.blq = tag.opened; return; }
397
	if (tag.is("pre")) { style.pre = tag.opened; return; }
-
 
398
	if (tag.is("code")) { 
405
	if (tag.is("code")) { 
399
		if (tag.opened) style.bg_color = 0xe4ffcb; else style.bg_color = page_bg;
406
		if (tag.opened) style.bg_color = 0xe4ffcb; else style.bg_color = page_bg;
400
		style.pre = tag.opened; return; 
407
		style.pre = tag.opened; return; 
401
	}
408
	}
402
	if (tag.is("img")) {
409
	if (tag.is("img")) {
Line 471... Line 478...
471
			sprintf(#line, "%i. ", style.tag_list.inc_counter());
478
			sprintf(#line, "%i. ", style.tag_list.inc_counter());
472
			stolbec = style.tag_list.level * 5 - strlen(#line);
479
			stolbec = style.tag_list.level * 5 - strlen(#line);
473
		}
480
		}
474
		return;
481
		return;
475
	}
482
	}
-
 
483
	if (tag.is("q"))
-
 
484
	{
-
 
485
		if (tag.opened)	{
-
 
486
			EAX = strlen(#line);
-
 
487
			if (line[EAX-1] != ' ') chrcat(#line, ' ');
-
 
488
			chrcat(#line, '\"');
-
 
489
		}
-
 
490
		if (!tag.opened) strcat(#line, "\" ");
-
 
491
		return;
-
 
492
	}
476
	if (tag.is("hr")) {
493
	if (tag.is("hr")) {
477
		if (value = tag.get_value_of("color=")) EDI = GetColor(value); else EDI = 0x999999;
494
		if (value = tag.get_value_of("color=")) EDI = GetColor(value); else EDI = 0x999999;
478
		$push edi;
495
		$push edi;
479
		NewLine();
496
		NewLine();
480
		$pop edi;
497
		$pop edi;
Line 483... Line 500...
483
		NewLine();
500
		NewLine();
484
		draw_y += 10;
501
		draw_y += 10;
485
		return;
502
		return;
486
	}
503
	}
487
	if (custom_encoding == -1) && (tag.is("meta")) || (tag.is("?xml")) {
504
	if (custom_encoding == -1) && (tag.is("meta")) || (tag.is("?xml")) {
488
		meta_encoding = CH_CP866;
-
 
489
		if (value = tag.get_value_of("charset=")) || (value = tag.get_value_of("content=")) || (value = tag.get_value_of("encoding="))
505
		if (value = tag.get_value_of("charset=")) || (value = tag.get_value_of("content=")) || (value = tag.get_value_of("encoding="))
490
		{
506
		{
491
			value += strrchr(value, '='); //search in content=
507
			value += strrchr(value, '='); //search in content=
492
			strlwr(value);
508
			strlwr(value);
493
			if      (streq(value,"utf-8"))        || (streq(value,"utf8"))        meta_encoding = CH_UTF8;
509
			if      (streq(value,"utf-8"))        || (streq(value,"utf8"))        ChangeEncoding(CH_UTF8);
494
			else if (streq(value,"windows-1251")) || (streq(value,"windows1251")) meta_encoding = CH_CP1251;
510
			else if (streq(value,"windows-1251")) || (streq(value,"windows1251")) ChangeEncoding(CH_CP1251);
495
			else if (streq(value,"dos"))          || (streq(value,"cp-866"))      meta_encoding = CH_CP866;
511
			else if (streq(value,"dos"))          || (streq(value,"cp-866"))      ChangeEncoding(CH_CP866);
496
			else if (streq(value,"iso-8859-5"))   || (streq(value,"iso8859-5"))   meta_encoding = CH_ISO8859_5;
512
			else if (streq(value,"iso-8859-5"))   || (streq(value,"iso8859-5"))   ChangeEncoding(CH_ISO8859_5);
497
			else if (streq(value,"koi8-r"))       || (streq(value,"koi8-u"))      meta_encoding = CH_KOI8;
513
			else if (streq(value,"koi8-r"))       || (streq(value,"koi8-u"))      ChangeEncoding(CH_KOI8);
498
		}
-
 
499
		if (meta_encoding != CH_CP866) && (cur_encoding != meta_encoding) {
-
 
500
			cur_encoding = meta_encoding;
-
 
501
			bufpointer = ChangeCharset(cur_encoding*10+#charsets, "CP866", bufpointer);
-
 
502
			if (header) {
-
 
503
				ChangeCharset(cur_encoding*10+#charsets, "CP866", #header);
-
 
504
				DrawTitle(#header);
-
 
505
			}
-
 
506
		}
514
		}
507
		return;
515
		return;
508
	}
516
	}
509
}
517
}
510
//============================================================================================
518
//============================================================================================
Line 518... Line 526...
518
	scroll_wv.start_y = list.y;
526
	scroll_wv.start_y = list.y;
519
	scroll_wv.size_y = list.h;
527
	scroll_wv.size_y = list.h;
520
	scrollbar_v_draw(#scroll_wv);
528
	scrollbar_v_draw(#scroll_wv);
521
}
529
}
522
//============================================================================================
530
//============================================================================================
-
 
531
void TWebBrowser::ChangeEncoding(int _new_encoding)
-
 
532
{
-
 
533
	if (cur_encoding == _new_encoding) return;
-
 
534
	cur_encoding = _new_encoding;
-
 
535
	bufpointer = ChangeCharset(cur_encoding*10+#charsets, "CP866", bufpointer);
-
 
536
	if (header) {
-
 
537
		ChangeCharset(cur_encoding*10+#charsets, "CP866", #header);
-
 
538
		DrawTitle(#header);
-
 
539
	}
-
 
540
}
-
 
541
//============================================================================================
523
void TWebBrowser::NewLine()
542
void TWebBrowser::NewLine()
524
{
543
{
525
	dword onleft, ontop;
544
	dword onleft, ontop;
526
	static int empty_line=0;
545
	static int empty_line=0;