Subversion Repositories Kolibri OS

Rev

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

Rev 8008 Rev 8016
Line 16... Line 16...
16
char line[500];
16
char line[500];
Line 17... Line 17...
17
 
17
 
18
struct _style {
18
struct _style {
19
	bool
19
	bool
-
 
20
	b, u, s, h,
20
	b, u, s, h,
21
	font,
21
	pre,
22
	pre,
22
	blq,
23
	blq,
23
	button,
24
	button,
24
	image;
25
	image;
Line 28... Line 29...
28
};
29
};
Line 29... Line 30...
29
 
30
 
30
struct TWebBrowser {
31
struct TWebBrowser {
31
	llist list;
32
	llist list;
-
 
33
	_style style;
32
	_style style;
34
	_img page_img;
33
	dword draw_y, stolbec;
35
	dword draw_y, stolbec;
34
	int zoom;
36
	int zoom;
35
	dword o_bufpointer;
37
	dword o_bufpointer;
36
	int cur_encoding, custom_encoding;
38
	int cur_encoding, custom_encoding;
Line 93... Line 95...
93
		if (style.button) {
95
		if (style.button) {
94
			DrawBuf.DrawBar(start_x, draw_y, line_length, list.item_h - calc(zoom*2), 0xCCCccc);
96
			DrawBuf.DrawBar(start_x, draw_y, line_length, list.item_h - calc(zoom*2), 0xCCCccc);
95
			DrawBuf.DrawBar(start_x, draw_y + list.item_h - calc(zoom*2), line_length, zoom, 0x999999);
97
			DrawBuf.DrawBar(start_x, draw_y + list.item_h - calc(zoom*2), line_length, zoom, 0x999999);
96
		}
98
		}
Line 97... Line 99...
97
 
99
 
98
		text_color__ = text_colors[text_color_index];
100
		text_color__ = text_colors.get_last();
Line 99... Line 101...
99
		if (link) && (text_colors[text_color_index]==text_colors[0]) text_color__ = link_color_default;
101
		if (link) && (text_color__ == text_colors.get(0)) text_color__ = link_color_default;
100
 
102
 
101
		DrawBuf.WriteText(start_x, draw_y, list.font_type, text_color__, #line, NULL);
103
		DrawBuf.WriteText(start_x, draw_y, list.font_type, text_color__, #line, NULL);
102
		if (style.b) DrawBuf.WriteText(start_x+1, draw_y, list.font_type, text_color__, #line, NULL);
104
		if (style.b) DrawBuf.WriteText(start_x+1, draw_y, list.font_type, text_color__, #line, NULL);
Line 115... Line 117...
115
}
117
}
116
//============================================================================================
118
//============================================================================================
117
void TWebBrowser::SetPageDefaults()
119
void TWebBrowser::SetPageDefaults()
118
{
120
{
119
	style.b = style.u = style.s = style.h = style.blq = t_html = t_body = style.pre =
121
	style.b = style.u = style.s = style.h = style.blq = t_html = t_body = style.pre =
120
	link = text_color_index = text_colors[0] = style.tag_title = false;
122
	link = style.tag_title = style.font = false;
121
	style.tag_list.reset();
123
	style.tag_list.reset();
122
	link_color_default = 0x0000FF;
124
	link_color_default = 0x0000FF;
123
	link_color_active = 0xFF0000;
125
	link_color_active = 0xFF0000;
124
	page_bg = 0xFFFFFF;
126
	page_bg = 0xFFFFFF;
125
	style.bg_color = page_bg;
127
	style.bg_color = page_bg;
126
	DrawBuf.Fill(0, page_bg);
128
	DrawBuf.Fill(0, page_bg);
127
	links.clear();
129
	links.clear();
128
	anchors.clear();
130
	anchors.clear();
-
 
131
	page_img.clear();
-
 
132
	text_colors.drop();
-
 
133
	text_colors.add(0);
129
	header = NULL;
134
	header = NULL;
130
	cur_encoding = CH_CP866;
135
	cur_encoding = CH_CP866;
131
	draw_y = BODY_MARGIN;
136
	draw_y = BODY_MARGIN;
132
	stolbec = 0;
137
	stolbec = 0;
133
	line = 0;
138
	line = 0;
Line 337... Line 342...
337
	}
342
	}
338
	if (tag.is("body")) {
343
	if (tag.is("body")) {
339
		t_body = tag.opened;
344
		t_body = tag.opened;
340
		if (value = tag.get_value_of("link="))   link_color_default = GetColor(value);
345
		if (value = tag.get_value_of("link="))   link_color_default = GetColor(value);
341
		if (value = tag.get_value_of("alink="))  link_color_active = GetColor(value);
346
		if (value = tag.get_value_of("alink="))  link_color_active = GetColor(value);
342
		if (value = tag.get_value_of("text="))   text_colors[0]=GetColor(value);
347
		if (value = tag.get_value_of("text="))   text_colors.set(0, GetColor(value));
343
		if (value = tag.get_value_of("bgcolor=")) {
348
		if (value = tag.get_value_of("bgcolor=")) {
344
			style.bg_color = page_bg = GetColor(value);
349
			style.bg_color = page_bg = GetColor(value);
345
			DrawBuf.Fill(0, page_bg);
350
			DrawBuf.Fill(0, page_bg);
346
		}
351
		}
347
		// Autodetecting encoding if no encoding was set
352
		// Autodetecting encoding if no encoding was set
Line 382... Line 387...
382
		Paint();
387
		Paint();
383
		link=false;
388
		link=false;
384
		NewLine();
389
		NewLine();
385
	}
390
	}
386
	if (tag.is("font")) {
391
	if (tag.is("font")) {
-
 
392
		style.font = tag.opened;
387
		style.bg_color = page_bg;
393
		style.bg_color = page_bg;
388
		if (tag.opened)
394
		if (tag.opened)
389
		{
395
		{
390
			text_color_index++;
-
 
391
			text_colors[text_color_index] = text_colors[text_color_index-1];
-
 
392
			if (value = tag.get_value_of("color=")) text_colors[text_color_index] = GetColor(value);
-
 
393
			if (value = tag.get_value_of("bg=")) style.bg_color = GetColor(value);
396
			if (value = tag.get_value_of("bg=")) style.bg_color = GetColor(value);
-
 
397
			if (value = tag.get_value_of("color=")) {
-
 
398
				text_colors.add(GetColor(value));
-
 
399
			} else {
-
 
400
				text_colors.add(text_colors.get_last());
-
 
401
			}
394
		}
402
		}
395
		else if (text_color_index > 0) text_color_index--;
403
		else text_colors.pop();
396
		return;
404
		return;
397
	}
405
	}
398
	if (tag.is("div")) {
406
	if (tag.is("div")) {
399
		if (streq(#tag.prior,"div")) && (tag.opened) return;
407
		if (streq(#tag.prior,"div")) && (tag.opened) return;
-
 
408
		if (!tag.opened) && (style.font) text_colors.pop();
400
		NewLine();
409
		NewLine();
401
		return;
410
		return;
402
	}
411
	}
403
	if (tag.is("header")) || (tag.is("article")) || (tag.is("footer")) || (tag.is("figure")) {
412
	if (tag.is("header")) || (tag.is("article")) || (tag.is("footer")) || (tag.is("figure")) {
404
		NewLine();
413
		NewLine();
Line 433... Line 442...
433
		if (value = tag.get_value_of("src=")) strlcpy(#img_path, value, sizeof(img_path)-1);
442
		if (value = tag.get_value_of("src=")) strlcpy(#img_path, value, sizeof(img_path)-1);
434
		if (value = tag.get_value_of("title=")) && (strlen(value)
443
		if (value = tag.get_value_of("title=")) && (strlen(value)
435
		if (value = tag.get_value_of("alt=")) && (strlen(value)
444
		if (value = tag.get_value_of("alt=")) && (strlen(value)
436
		if (!img_path) { line=0; return; }
445
		if (!img_path) { line=0; return; }
437
		style.image = true;
446
		style.image = true;
438
		text_color_index++;
447
		page_img.add(#img_path, stolbec+1*list.font_w+3, draw_y);
439
		text_colors[text_color_index] = 0x9A6F29;
448
		text_colors.add(0x9A6F29);
440
		if (!line) {
449
		if (!line) {
441
			if (!strncmp(#img_path, "data:", 5)) img_path=0;
450
			if (!strncmp(#img_path, "data:", 5)) img_path=0;
442
			replace_char(#img_path, '?', NULL, strlen(#img_path));
451
			replace_char(#img_path, '?', NULL, strlen(#img_path));
443
			sprintf(#line, "[%s]", #img_path+strrchr(#img_path, '/'));
452
			sprintf(#line, "[%s]", #img_path+strrchr(#img_path, '/'));
444
			line[50]= NULL;
453
			line[50]= NULL;
445
		}
454
		}
446
		while (CheckForLineBreak()) {};
455
		while (CheckForLineBreak()) {};
447
		Paint();
456
		Paint();
448
		text_color_index--;
457
		text_colors.pop();
449
		style.image = false;
458
		style.image = false;
450
		//ImgCache.Images( list.x, draw_y, list.w); 
-
 
451
		return; 
459
		return; 
452
	}
460
	}
453
	if (tag.is("h4")) {
461
	if (tag.is("h4")) {
454
		NewLine();
462
		NewLine();
455
		NewLine();
463
		NewLine();
Line 589... Line 597...
589
}
597
}
590
//============================================================================================
598
//============================================================================================
591
void TWebBrowser::DrawPage()
599
void TWebBrowser::DrawPage()
592
{
600
{
593
	PutPaletteImage(list.first * DrawBuf.bufw * 4 + buf_data+8, DrawBuf.bufw, list.h, DrawBuf.bufx, DrawBuf.bufy, 32, 0);	
601
	PutPaletteImage(list.first * DrawBuf.bufw * 4 + buf_data+8, DrawBuf.bufw, list.h, DrawBuf.bufx, DrawBuf.bufy, 32, 0);
-
 
602
	page_img.draw(list.x, list.y, list.first, list.h);
594
	DrawScroller();
603
	DrawScroller();
595
}
604
}
596
>
605
>