Subversion Repositories Kolibri OS

Rev

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

Rev 5772 Rev 5773
Line 99... Line 99...
99
		if (style.s) DrawBuf.DrawBar(start_x, list.line_h / 2 - DrawBuf.zoom + start_y, line_length, DrawBuf.zoom, text_colors[text_color_index]);
99
		if (style.s) DrawBuf.DrawBar(start_x, list.line_h / 2 - DrawBuf.zoom + start_y, line_length, DrawBuf.zoom, text_colors[text_color_index]);
100
		if (style.u) DrawBuf.DrawBar(start_x, list.line_h - DrawBuf.zoom - DrawBuf.zoom + start_y, line_length, DrawBuf.zoom, text_colors[text_color_index]);
100
		if (style.u) DrawBuf.DrawBar(start_x, list.line_h - DrawBuf.zoom - DrawBuf.zoom + start_y, line_length, DrawBuf.zoom, text_colors[text_color_index]);
101
		if (link) {
101
		if (link) {
102
			DrawBuf.DrawBar(start_x, list.line_h - DrawBuf.zoom - DrawBuf.zoom + start_y, line_length, DrawBuf.zoom, text_colors[text_color_index]);
102
			DrawBuf.DrawBar(start_x, list.line_h*style.h + list.line_h - DrawBuf.zoom - DrawBuf.zoom + start_y, line_length, DrawBuf.zoom, text_colors[text_color_index]);
103
			PageLinks.AddText(#line, line_length, list.line_h, UNDERLINE);
103
			PageLinks.AddText(#line, line_length, list.line_h*style.h + list.line_h, UNDERLINE);
104
		}
104
		}
105
		stolbec += stolbec_len;
105
		stolbec += stolbec_len;
106
	}
106
	}
107
}
107
}
108
//============================================================================================
108
//============================================================================================
109
void TWebBrowser::LoadInternalPage(dword bufpos, in_filesize){
109
void TWebBrowser::LoadInternalPage(dword bufpos, in_filesize){
110
	bufsize = in_filesize;
110
	bufsize = in_filesize;
Line 116... Line 116...
116
	word bukva[2];
116
	word bukva[2];
117
	int j;
117
	int j;
118
	byte ignor_param;
118
	byte ignor_param;
119
	char temp[768];
119
	dword bufpos;
120
	dword bufpos = bufpointer;
120
	int line_len;	
121
	int line_len;
-
 
122
	
121
	style.b = style.i = style.u = style.s = style.h = style.blq = t_html = t_body =
123
	style.b = style.i = style.u = style.s = style.h = style.blq = t_html = t_body =
122
	style.li = link = ignor_text = text_color_index = text_colors[0] = style.li_tab = 0;
124
	style.li = link = ignor_text = text_color_index = text_colors[0] = style.li_tab = 0;
-
 
125
	style.align = ALIGN_LEFT;
123
	style.align = ALIGN_LEFT;
126
	link_color_inactive = 0x0000FF;
124
	link_color_inactive = 0x0000FF;
127
	link_color_active = 0xFF0000;
125
	link_color_active = 0xFF0000;
128
	bg_color = 0xFFFFFF;
126
	bg_color = 0xFFFFFF;
129
	DrawBuf.Fill(bg_color);
127
	DrawBuf.Fill(bg_color);
Line 132... Line 130...
132
	stroka = -list.first;
130
	stroka = -list.first;
133
	stolbec = 0;
131
	stolbec = 0;
134
	line = 0;
132
	line = 0;
135
 
133
	//for plaint text use CP866 for other UTF
136
	//for plaint text use CP866 for other UTF
134
	if (strstri(bufpointer, "html")) 
137
	if (strstri(bufpointer, "html")) 
-
 
138
	{
135
	{
139
		style.pre = 0;
136
		style.pre = 0;
140
		cur_encoding = CH_CP866;
137
		cur_encoding = CH_UTF8;
141
	}
138
	}
142
	else
139
	else
143
	{
140
	{
144
		style.pre = 1;
141
		style.pre = 1;
145
		cur_encoding = CH_UTF8;
142
		cur_encoding = CH_CP866;
146
	}
143
	}
147
 
144
	for (bufpos=bufpointer ; (bufpos < bufpointer+bufsize) && (ESBYTE[bufpos]!=0) ; bufpos++;)
148
	for ( ; (bufpointer+bufsize > bufpos) && (ESBYTE[bufpos]!=0); bufpos++;)
145
	{
149
	{
-
 
150
		bukva = ESBYTE[bufpos];
146
		if (ignor_text) && (ESBYTE[bufpos]!='<') continue;
151
		if (ignor_text) && (bukva!='<') continue;
147
		bukva = ESBYTE[bufpos];
-
 
148
		switch (bukva)
152
		switch (bukva)
149
		{
153
		{
-
 
154
		case 0x0a:
150
		case 0x0a:
155
			if (style.pre)
151
			if (style.pre)
156
			{
152
			{
157
				chrcat(#line, ' ');
153
				chrcat(#line, ' ');
158
				bukva = temp = NULL;
154
				Perenos();
159
				Perenos();
155
				break;
160
				break;
-
 
161
			}
156
			}
162
		case '\9':
157
		case '\9':
163
			if (style.pre) //èíà÷å èä¸ì íà 0x0d	
158
			if (style.pre) //èíà÷å èä¸ì íà 0x0d	
164
			{
159
			{
165
				tab_len = strlen(#line) % 4;
160
				tab_len = strlen(#line) % 4;
Line 168... Line 163...
168
				break;
163
				break;
169
			}
164
			}
170
			goto DEFAULT_MARK;		
165
			goto DEFAULT_MARK;		
171
			
166
		case '&': //  and so on
172
		case '&': //  and so on
167
			bufpos++;
173
			bufpos++;
-
 
174
			tag=0;
168
			tag=0;
175
			for (j=0; (ESBYTE[bufpos]<>';') && (j<7);   j++, bufpos++;)
169
			for (j=0; (ESBYTE[bufpos]<>';') && (j<7);   j++, bufpos++;)
176
			{
170
			{
177
				bukva = ESBYTE[bufpos];
171
				bukva = ESBYTE[bufpos];
178
				chrcat(#tag, bukva);
172
				chrcat(#tag, bukva);
Line 210... Line 204...
210
			Perenos();
204
			Perenos();
Line 211... Line 205...
211
			DrawStyle();
205
			DrawStyle();
212
			line = NULL;
206
			line = NULL;
213
			if (tag) SetStyle(WB1.DrawBuf.zoom * 5 + list.x, stroka * list.line_h + list.y + 5); //îáðàáîòêà òåãîâ
207
			if (tag) SetStyle(); //îáðàáîòêà òåãîâ
214
			strcpy(#oldtag, #tag);
208
			strcpy(#oldtag, #tag);
215
			tag = attr = tagparam = ignor_param = NULL;
209
			tag = attr = tagparam = ignor_param = NULL;
216
			break;
210
			break;
217
		default:
211
		default:
218
			DEFAULT_MARK:
212
			DEFAULT_MARK:
219
			if (bukva<=15) bukva=' ';
213
			if (bukva<=15) bukva=' ';
Line 243... Line 237...
243
{
237
{
244
	int perenos_num;
238
	int perenos_num;
245
	char new_line_text[4096];
239
	char new_line_text[4096];
246
	if (stolbec + utf8_strlen(#line) < list.column_max) return;
240
	if (utf8_strlen(#line)*DrawBuf.zoom + stolbec < list.column_max) return;
247
	perenos_num = strrchr(#line, ' ');
241
	perenos_num = strrchr(#line, ' ');
248
	if (!perenos_num) && (utf8_strlen(#line)>list.column_max) perenos_num=list.column_max;
242
	if (!perenos_num) && (utf8_strlen(#line)*DrawBuf.zoom>list.column_max) perenos_num=list.column_max/DrawBuf.zoom;
249
	strcpy(#new_line_text, #line + perenos_num);
243
	strcpy(#new_line_text, #line + perenos_num);
250
	line[perenos_num] = 0x00;
244
	line[perenos_num] = 0x00;
251
	DrawStyle();
245
	DrawStyle();
252
	strcpy(#line, #new_line_text);
246
	strcpy(#line, #new_line_text);
253
	NewLine();
247
	NewLine();
254
}
248
}
255
//============================================================================================
249
//============================================================================================
256
void TWebBrowser::SetStyle(int left1, top1) {
250
void TWebBrowser::SetStyle() {
257
	dword hr_color;
251
	int left1 = 5 + list.x;
258
	byte opened;
252
	int top1 = stroka * list.line_h + list.y + 5;
259
	byte meta_encoding;
253
	byte opened;
-
 
254
	byte meta_encoding;
260
	//ïðîâåðÿåì òåã îòêðûâàåòñÿ èëè çàêðûâàåòñÿ
255
	//ïðîâåðÿåì òåã îòêðûâàåòñÿ èëè çàêðûâàåòñÿ
261
	if (tag[0] == '/') 
256
	if (tag[0] == '/') 
262
	{
257
	{
263
		 opened = 0;
258
		 opened = 0;
264
		 strcpy(#tag, #tag+1);
259
		 strcpy(#tag, #tag+1);
265
	}
260
	}
266
	else opened = 1;
261
	else opened = 1;
267
 
262
	if (istag("html")) {
268
	if (istag("html")) {
263
		t_html = opened;
269
		t_html = opened;
-
 
270
		return;
264
		return;
271
	}
265
	}
272
	if (istag("script")) || (istag("style")) || (istag("binary")) || (istag("select")) { ignor_text = opened; return; }
266
	if (istag("script")) || (istag("style")) || (istag("binary")) || (istag("select")) { ignor_text = opened; return; }
273
	if (istag("form")) if (!opened) ignor_text = false;
267
	if (istag("form")) if (!opened) ignor_text = false;
274
	if(istag("title")) {
268
	if(istag("title")) {
Line 392... Line 386...
392
		if (opened) NewLine();
386
		if (opened) NewLine();
393
		return;
387
		return;
394
	}
388
	}
395
	if (istag("li")) || (istag("dt")) //íàäî ñäåëàòü âëîæåííûå ñïèñêè
389
	if (istag("li")) || (istag("dt"))
396
	{
390
	{
397
		style.li = opened;
391
		style.li = opened;
398
		if (opened)
392
		if (opened)
399
		{
393
		{
400
			NewLine();
394
			NewLine();
401
			if (stroka > -1) && (stroka - 2 < list.visible) 
395
			DrawBuf.DrawBar(style.li_tab * 5 * list.font_w * DrawBuf.zoom + list.x, stroka +1 * list.line_h - 3
402
				DrawBuf.DrawBar(style.li_tab * 5 * list.font_w * DrawBuf.zoom + list.x, list.line_h 
396
			 - DrawBuf.zoom - DrawBuf.zoom, DrawBuf.zoom*2, DrawBuf.zoom*2, 0x454545);
403
					/ 2 - DrawBuf.zoom - DrawBuf.zoom, DrawBuf.zoom*2, DrawBuf.zoom*2, 0x555555);
-
 
404
		}
397
		}
405
		return;
398
		return;
406
	}
399
	}
407
	if (istag("ul")) || (istag("ol")) {
400
	if (istag("ul")) || (istag("ol")) {
408
		if (!opened)
401
		if (!opened)
409
		{
402
		{
410
			style.li = opened;
403
			style.li = opened;
Line 414... Line 407...
414
		else style.li_tab++;
407
		else style.li_tab++;
415
	}
408
	}
416
	if (istag("hr")) {
409
	if (istag("hr")) {
417
		if (anchor) || (stroka < -1)
410
		if (isattr("color=")) EDI = GetColor(#val); else EDI = 0x999999;
418
		{
411
		$push edi;
419
			stroka+=2;
412
		NewLine();
420
			return;
-
 
421
		}
413
		$pop edi;
422
		if (strcmp(#attr, "color=") == 0) hr_color = GetColor(#val); else hr_color = 0x999999;
-
 
423
		NewLine();
-
 
424
		DrawBuf.DrawBar(5, list.line_h/2, list.w-10, 1, hr_color);
-
 
425
		NewLine();
414
		DrawBuf.DrawBar(5, list.line_h*stroka+4, list.w-10, 1, EDI);
-
 
415
		NewLine();
426
	}
416
		return;
427
	if (istag("meta")) || (istag("?xml")) {
417
	}
-
 
418
	if (istag("meta")) || (istag("?xml")) {
428
		do{
419
		do{
429
			if (isattr("charset=")) || (isattr("content=")) || (isattr("encoding="))
420
			if (isattr("charset=")) || (isattr("content=")) || (isattr("encoding="))
430
			{
421
			{
431
				strcpy(#val, #val[strrchr(#val, '=')]); //ïîèñê â content=
422
				strcpy(#val, #val[strrchr(#val, '=')]); //ïîèñê â content=
432
				strlwr(#val);
423
				strlwr(#val);