Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
8462 leency 1
CANVAS canvas;
2
 
8491 leency 3
void TWebBrowser::RenderLine()
8462 leency 4
{
5
	unsigned px; //paint x coordinate
6
	unsigned pw; //paint y coordinate
7
	   dword pc; //paint color
8
	   int zoom;
9
 
10
	if (style.title)
11
	{
8492 leency 12
		strncpy(#header, #linebuf, sizeof(TWebBrowser.header)-1);
8462 leency 13
		strncat(#header, " - ", sizeof(TWebBrowser.header)-1);
14
		strncat(#header, #version, sizeof(TWebBrowser.header)-1);
8492 leency 15
		linebuf = 0;
8462 leency 16
		return;
17
	}
18
	if (t_html) && (!t_body) {
8492 leency 19
		linebuf = 0;
8462 leency 20
		return;
21
	}
22
 
8492 leency 23
	if (linebuf)
8462 leency 24
	{
8492 leency 25
		pw = strlen(#linebuf) * list.font_w;
8462 leency 26
		zoom = list.font_w / BASIC_CHAR_W;
27
 
28
		style.cur_line_h = math.max(style.cur_line_h, list.item_h);
29
 
30
		if (bg_colors.get_last() - bg_colors.get(0)) {
31
			canvas.DrawBar(draw_x, draw_y, pw, list.item_h, bg_colors.get_last());
32
		}
33
 
34
		if (style.image) {
35
			canvas.DrawBar(draw_x, draw_y, pw, list.item_h-1, 0xF9DBCB);
36
		}
37
		if (style.button) {
38
			canvas.DrawBar(draw_x, draw_y, pw, list.item_h - calc(zoom*2), 0xCCCccc);
39
			canvas.DrawBar(draw_x, draw_y + list.item_h - calc(zoom*2), pw, zoom, 0x999999);
40
		}
41
 
42
		pc = text_colors.get_last();
43
		if (link) && (pc == text_colors.get(0)) pc = link_color_default;
44
 
8492 leency 45
		canvas.WriteText(draw_x, draw_y, list.font_type, pc, #linebuf, NULL);
46
		if (style.b) canvas.WriteText(draw_x+1, draw_y, list.font_type, pc, #linebuf, NULL);
8462 leency 47
		if (style.s) canvas.DrawBar(draw_x, list.item_h / 2 - zoom + draw_y, pw, zoom, pc);
48
		if (style.u) canvas.DrawBar(draw_x, list.item_h - zoom - zoom + draw_y, pw, zoom, pc);
49
		if (link) {
8492 leency 50
			if (linebuf[0]==' ') && (linebuf[1]==NULL) {} else {
8462 leency 51
				canvas.DrawBar(draw_x, draw_y + list.item_h - calc(zoom*2)-1, pw, zoom, link_color_default);
52
				links.add_text(draw_x, draw_y + list.y, pw, list.item_h - calc(zoom*2)-1, zoom);
53
			}
54
		}
55
		draw_x += pw;
8492 leency 56
		if (debug_mode) debugln(#linebuf);
57
		linebuf = NULL;
8462 leency 58
	}
59
}
60
 
8491 leency 61
void TWebBrowser::RenderTextbuf()
62
{
63
	int break_pos;
64
	char next_line[4096];
65
	int zoom = list.font_w / BASIC_CHAR_W;
66
 
67
	//Do we need a line break?
8492 leency 68
	while (strlen(#linebuf) * list.font_w + draw_x >= draw_w) {
8491 leency 69
		//Yes, we do. Lets calculate where...
8492 leency 70
		break_pos = strrchr(#linebuf, ' ');
8491 leency 71
 
72
		//Is a new line fits in the current line?
73
		if (break_pos * list.font_w + draw_x > draw_w) {
74
			break_pos = draw_w - draw_x /list.font_w;
8492 leency 75
			while(break_pos) && (linebuf[break_pos]!=' ') break_pos--;
8491 leency 76
		}
77
		//Maybe a new line is too big for the whole new line? Then we have to split it
8492 leency 78
		if (!break_pos) && (style.tag_list.level*5 + strlen(#linebuf) * zoom >= list.column_max) {
8491 leency 79
			break_pos = draw_w  - draw_x / list.font_w;
80
		}
81
 
8492 leency 82
		strcpy(#next_line, #linebuf + break_pos);
83
		linebuf[break_pos] = 0x00;
8491 leency 84
 
85
		RenderLine();
86
 
8492 leency 87
		strcpy(#linebuf, #next_line);
8491 leency 88
		NewLine();
89
	}
90
	RenderLine();
91
}
92
 
8462 leency 93
bool TWebBrowser::RenderImage(dword cur_img)
94
{
95
	int img_x, img_y, img_w, img_h;
96
	dword imgbuf[44];
97
 
98
	if (!cur_img) return false;
99
 
100
	img_h = ESDWORD[cur_img+8];
101
	img_w = ESDWORD[cur_img+4];
102
 
103
	if (img_w + draw_x >= draw_w) NewLine();
104
	img_y = draw_y;
105
	if (img_h < list.item_h) img_y += list.item_h - img_h / 2 - 1; else img_y -= 2;
106
	style.cur_line_h = math.max(style.cur_line_h, img_h);
107
 
108
	img_w = math.min(img_w, canvas.bufw - draw_x);
109
 
110
	if (link) links.add_text(draw_x + list.x, img_y + list.y, img_w, img_h, 0);
111
 
112
	if (img_y + img_h >= canvas.bufh) canvas.IncreaseBufSize();
113
 
114
	if (ESDWORD[cur_img+20] != IMAGE_BPP32) {
115
		img_convert stdcall(cur_img, 0, IMAGE_BPP32, 0, 0);
116
		$push eax
117
		img_destroy stdcall(cur_img);
118
		$pop eax
119
		cur_img = EAX;
120
		if (!EAX) return false;
121
	}
122
	imgbuf[04] = canvas.bufw;
123
	imgbuf[08] = canvas.bufh;
124
	imgbuf[20] = IMAGE_BPP32;
125
	imgbuf[24] = buf_data+8;
126
	img_blend stdcall(#imgbuf, cur_img, draw_x, img_y, 0, 0, img_w, img_h);
127
	img_destroy stdcall(cur_img);
128
 
129
	draw_x += img_w;
130
	if (draw_x >= draw_w) NewLine();
131
	return true;
132
}