Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
4475 leency 1
#include "..\lib\draw_buf.h"
4488 leency 2
#include "..\lib\list_box.h"
4497 leency 3
#include "..\lib\cursor.h"
4491 leency 4
#include "..\TWB\links.h"
4411 leency 5
 
6
int	downloader_id;
7
 
4417 leency 8
dword buf;
9
dword filesize;
4411 leency 10
 
4416 leency 11
#define URL param
12
 
13
int	mouse_twb;
14
edit_box address_box= {250,207,16,0xffffff,0x94AECE,0xffffff,0xffffff,0,sizeof(URL),#editURL,#mouse_twb,2,19,19};
15
scroll_bar scroll_wv = { 18,200,398, 44,18,0,115,15,0,0xeeeeee,0xD2CED0,0x555555,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1};
16
 
4417 leency 17
char editURL[sizeof(URL)];
18
char header[2048];
4416 leency 19
 
20
 
4411 leency 21
char download_path[]="/rd/1/.download";
22
 
23
struct TWebBrowser {
4415 leency 24
	llist list; //need #include "..\lib\list_box.h"
4475 leency 25
	DrawBufer DrawBuf;
4411 leency 26
	void GetNewUrl();
4475 leency 27
	void ReadHtml();
4411 leency 28
	void ShowPage();
4475 leency 29
	void ParseHTML();
30
	void WhatTextStyle();
4411 leency 31
	void DrawPage();
32
	void DrawScroller();
4475 leency 33
	void TextGoDown();
4486 leency 34
};
35
 
4411 leency 36
TWebBrowser WB1;
37
 
4491 leency 38
byte b_text, i_text, u_text, s_text, pre_text, blq_text, li_text, li_tab,
4417 leency 39
	link, ignor_text, cur_encoding, text_align;
40
byte condition_text_active, condition_text_val, condition_href, condition_max;
4411 leency 41
 
4488 leency 42
enum { _WIN, _DOS, _KOI, _UTF };
4475 leency 43
 
4411 leency 44
enum { ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT};
45
 
4417 leency 46
dword text_colors[300];
47
dword text_color_index;
4491 leency 48
dword link_color_inactive;
49
dword link_color_active;
4417 leency 50
dword bg_color;
4411 leency 51
 
4417 leency 52
int stroka;
53
int stolbec;
54
int tab_len;
55
int anchor_line_num;
4411 leency 56
 
4417 leency 57
char line[500];
58
char tag[100];
59
char tagparam[10000];
60
char parametr[1200];
61
char options[4096];
62
char anchor[256];
4411 leency 63
 
4416 leency 64
#include "..\TWB\history.h"
4411 leency 65
#include "..\TWB\colors.h"
66
#include "..\TWB\unicode_tags.h"
67
#include "..\TWB\img_cache.h"
68
#include "..\TWB\parce_tag.h"
69
 
4475 leency 70
 
71
 
4411 leency 72
//=======================================================================
73
 
74
 
75
void TWebBrowser::DrawPage()
76
{
77
	int start_x, start_y, line_length, magrin_left=5;
78
 
79
	if (!header)
80
	{
81
		strcpy(#header, #line);
82
		strcat(#header, " -");
83
		strcat(#header, #version);
84
		line = 0;
85
		return;
86
	}
87
 
4415 leency 88
	if (stroka >= 0) && (stroka - 2 < list.visible) && (line) && (!anchor)
4411 leency 89
	{
4414 leency 90
		start_x = stolbec * 6 + list.x + magrin_left;
91
		start_y = stroka * 10 + list.y + magrin_left;
4411 leency 92
		line_length = strlen(#line) * 6;
93
 
4475 leency 94
		WriteBufText(start_x, 0, 0x88, text_colors[text_color_index], #line, buf_data);
95
		IF (b_text)	WriteBufText(start_x+1, 0, 0x88, text_colors[text_color_index], #line, buf_data);
96
		IF (i_text) { stolbec++; DrawBuf.Skew(start_x, 0, line_length, list.line_h); }
97
		IF (s_text) DrawBuf.DrawBar(start_x, 4, line_length, 1, text_colors[text_color_index]);
98
		IF (u_text) DrawBuf.DrawBar(start_x, 8, line_length, 1, text_colors[text_color_index]);
4411 leency 99
		IF (link) {
4493 leency 100
			UnsafeDefineButton(start_x-2, start_y, line_length + 3, 9, PageLinks.count + 400 + BT_HIDE, 0xB5BFC9);
4475 leency 101
			DrawBuf.DrawBar(start_x, 8, line_length, 1, text_colors[text_color_index]);
4493 leency 102
			PageLinks.AddText(#line, line_length, list.line_h);
4411 leency 103
		}
104
		stolbec += strlen(#line);
105
	}
106
}
107
//=======================================================================
108
 
109
 
110
 
111
char *ABSOLUTE_LINKS[]={ "http:", "mailto:", "ftp:", "/sys/", "/kolibrios/", "/rd/", "/bd", "/hd", "/cd", "/tmp", "/usbhd", 0};
112
//dword TWebBrowser::GetNewUrl(dword CUR_URL, NEW_URL){
113
void TWebBrowser::GetNewUrl(){
114
	int i, len;
115
 
116
	for (i=0; ABSOLUTE_LINKS[i]; i++)
117
	{
118
		len=strlen(ABSOLUTE_LINKS[i]);
119
		if (!strcmpn(#URL, ABSOLUTE_LINKS[i], len)) return;
120
	}
121
 
122
	IF (!strcmpn(#URL,"./", 2)) strcpy(#URL, #URL+2); //игнорим :)
123
	strcpy(#editURL, BrowserHistory.CurrentUrl()); //достаём адрес текущей страницы
124
 
125
	if (URL[0] == '/')
126
	{
127
		i = strchr(#editURL+8, '/');
128
		editURL[i+7]=0;
129
		strcpy(#URL, #URL+1);
130
	}
131
 
132
	_CUT_ST_LEVEL_MARK:
133
 
134
		if (editURL[strrchr(#editURL, '/')-2]<>'/')  // если не http://
135
		{
136
			editURL[strrchr(#editURL, '/')] = 0x00; //обрезаем её урл до последнего /
137
		}
138
 
4488 leency 139
		IF (!strncmp(#URL,"../",3)) //на уровень вверх
4411 leency 140
		{
141
			strcpy(#URL,#URL+3);
142
			editURL[strrchr(#editURL, '/')-1] = 0x00; //обрезаем её урл до последнего /
143
			goto _CUT_ST_LEVEL_MARK;
144
		}
145
 
146
		if (editURL[strlen(#editURL)-1]<>'/') strcat(#editURL, "/");
147
 
148
		strcat(#editURL, #URL); //клеим новый адрес
149
		strcpy(#URL, #editURL);
150
}
151
 
152
 
153
 
154
void TWebBrowser::ReadHtml(byte encoding)
155
{
4488 leency 156
	if (!strncmp(#URL,"http:",5))
4411 leency 157
		file_size stdcall (#download_path);
158
	else
159
		file_size stdcall (#URL);
160
 
161
	filesize = EBX;
162
	if (!filesize) return;
163
 
164
	mem_Free(buf);
165
	buf = mem_Alloc(filesize);
4488 leency 166
	if (!strncmp(#URL,"http:",5))
4411 leency 167
		ReadFile(0, filesize, buf, #download_path);
168
	else
169
		ReadFile(0, filesize, buf, #URL);
170
 
171
	cur_encoding = encoding;
172
	if (encoding==_WIN) wintodos(buf);
173
	if (encoding==_UTF) utf8rutodos(buf);
174
	if (encoding==_KOI) koitodos(buf);
175
}
176
 
177
 
178
void TWebBrowser::ShowPage()
179
{
180
	address_box.size = address_box.pos = strlen(#editURL);
181
	address_box.offset=0;
182
	edit_box_draw stdcall(#address_box);
4493 leency 183
	PageLinks.Clear();
4411 leency 184
 
185
	if (!filesize)
186
	{
4416 leency 187
		DrawBar(list.x, list.y, list.w+scroll_wv.size_x+1, list.h, 0xFFFFFF); //fill all
4414 leency 188
		if (GetProcessSlot(downloader_id)<>0) WriteText(list.x + 10, list.y + 18, 0x80, 0, "Loading...");
4411 leency 189
		else
190
		{
4414 leency 191
			WriteText(list.x + 10, list.y + 18, 0x80, 0, "Page not found. May be, URL contains some errors.");
4488 leency 192
			if (!strncmp(#URL,"http:",5)) WriteText(list.x + 10, list.y + 32, 0x80, 0, "Or Internet unavilable for your configuration.");
4411 leency 193
		}
194
		//return;
195
	}
196
	else
197
		ParseHTML(buf);
198
 
199
	if (!header) strcpy(#header, #version);
200
	if (!strcmp(#version, #header)) DrawTitle(#header);
201
}
202
 
203
 
204
 
205
void TWebBrowser::ParseHTML(dword bword){
206
	word bukva[2];
207
	int j, perenos_num;
208
	byte ignor_param;
209
	char temp[768];
210
 
211
	b_text = i_text = u_text = s_text = blq_text =
4417 leency 212
	li_text = link = ignor_text = text_color_index = text_colors[0] = li_tab =
213
	condition_text_val = condition_text_active = 0; //обнуляем теги
4475 leency 214
	condition_max = 255;
4411 leency 215
	text_align = ALIGN_LEFT;
4491 leency 216
	link_color_inactive = 0x0000FF;
217
	link_color_active = 0xFF0000;
4411 leency 218
	bg_color = 0xFFFFFF;
4475 leency 219
	DrawBuf.Fill(bg_color);
4411 leency 220
	strcpy(#header, #version);
4415 leency 221
	stroka = -list.first;
4411 leency 222
	stolbec = 0;
223
	line = 0;
224
 
225
	if (pre_text<>2)
226
	{
227
		pre_text=0;
228
		if (!strcmp(#URL + strlen(#URL) - 4, ".txt")) pre_text = 1;
229
		if (!strcmp(#URL + strlen(#URL) - 4, ".mht")) ignor_text = 1;
230
	}
231
 
232
	for ( ; buf+filesize > bword; bword++;)
233
	{
234
		bukva = ESBYTE[bword];
4417 leency 235
		if (ignor_text) && (bukva!='<') continue;
236
		if (condition_text_active) && (condition_text_val != condition_href) && (bukva!='<') continue;
4411 leency 237
		switch (bukva)
238
		{
239
		case 0x0a:
240
			if (pre_text)
241
			{
242
				bukva = temp = NULL;
243
				goto NEXT_MARK;
244
			}
245
		case '\9':
246
			if (pre_text) //иначе идём на 0x0d
247
			{
248
				tab_len=strlen(#line)/8;
249
				tab_len=tab_len*8;
250
				tab_len=8+tab_len-strlen(#line);
251
				for (j=0; j
252
				break;
253
			}
254
			goto DEFAULT_MARK;
255
		case '=': //quoted printable
256
			if (strcmp(#URL + strlen(#URL) - 4, ".mht")<>0) goto DEFAULT_MARK;
257
 
258
			temp[0] = ESBYTE[bword+1];
259
			temp[1] = ESBYTE[bword+2];
260
			temp[2] = '\0';
261
			if (bukva = Hex2Symb(#temp))
262
			{
263
				bword+=2;
264
				goto DEFAULT_MARK;
265
			}
266
			break;
267
 
268
		case '&': //  and so on
269
			bword++;
270
			tag=0;
271
			for (j=0; (ESBYTE[bword]<>';') && (j<7);   j++, bword++;)
272
			{
273
				bukva = ESBYTE[bword];
274
				chrcat(#tag, bukva);
275
			}
4417 leency 276
			if (bukva = GetUnicodeSymbol()) goto DEFAULT_MARK;
4411 leency 277
			break;
278
		case '<':
279
			bword++; //промотаем символ <
280
			tag = parametr = tagparam = ignor_param = NULL;
281
			if (ESBYTE[bword] == '!') //фильтрация внутри , дерзко
282
			{
283
				bword++;
284
				if (ESBYTE[bword] == '-')
285
				{
286
				HH_:
287
					do
288
					{
289
						bword++;
290
						if (buf + filesize <= bword) break 2;
291
					}
292
					while (ESBYTE[bword] <>'-');
293
 
294
					bword++;
295
					if (ESBYTE[bword] <>'-') goto HH_;
296
				}
297
			}
298
			while (ESBYTE[bword] !='>') && (bword < buf + filesize) //получаем тег и его параметры
299
			{
300
				bukva = ESBYTE[bword];
301
				if (bukva == '\9') || (bukva == '\x0a') || (bukva == '\x0d') bukva = ' ';
302
				if (!ignor_param) && (bukva <>' ')
303
				{
304
					if (strlen(#tag)
305
				}
306
				else
307
				{
308
					ignor_param = true;
309
					if (!ignor_text) && (strlen(#tagparam)+1
310
				}
311
				bword++;
312
			}
313
			strlwr(#tag);
314
			strlwr(#tagparam);
315
 
4417 leency 316
			if (condition_text_active) && (condition_text_val != condition_href)
317
			{
318
				if (strcmp(#tag, "/condition")!=0) break;
319
			}
4411 leency 320
			if (tag[strlen(#tag)-1]=='/') tag[strlen(#tag)-1]=NULL; //for br/
321
			if (tagparam) && (strlen(#tagparam) < 4000) GetNextParam();
322
 
4415 leency 323
			if (stolbec + strlen(#line) > list.column_max) //============the same as NEXT_MARK
4411 leency 324
			{
325
				perenos_num = strrchr(#line, ' ');
4415 leency 326
				if (!perenos_num) && (strlen(#line)>list.column_max) perenos_num=list.column_max;
4411 leency 327
				strcpy(#temp, #line + perenos_num); //перенос по словам
328
				line[perenos_num] = 0x00;
4415 leency 329
				if (stroka-1 > list.visible) && (list.first <>0) break 1; //уходим...
4411 leency 330
				DrawPage();
331
				strcpy(#line, #temp);
4414 leency 332
				TextGoDown(list.x + 5, stroka * 10 + list.y + 5, list.w - 20); //закрашиваем следущую строку
4411 leency 333
			}
334
			DrawPage();
335
 
4414 leency 336
			if (tag) WhatTextStyle(list.x + 5, stroka * 10 + list.y + 5, list.w - 20); //обработка тегов
4491 leency 337
			line=NULL;
4411 leency 338
 
339
			tag = parametr = tagparam = ignor_param = NULL;
340
			break;
341
		default:
342
			DEFAULT_MARK:
343
			if (bukva<=15) bukva=' ';
344
			if (!pre_text) && (bukva == ' ')
345
			{
346
				if (line[strlen(#line)-1]==' ') break; //убрать 2 пробела подряд
347
				if (!stolbec) && (!line) break; //строка не может начинаться с пробела
348
			}
349
			if (strlen(#line)
350
 
4415 leency 351
			if (stolbec + strlen(#line) > list.column_max)
4411 leency 352
			{
353
			NEXT_MARK:
354
				perenos_num = strrchr(#line, ' ');
4415 leency 355
				if (!perenos_num) && (strlen(#line)>list.column_max) perenos_num=list.column_max;
4411 leency 356
				strcpy(#temp, #line + perenos_num); //перенос по словам
357
				line[perenos_num] = 0x00;
4415 leency 358
				if (stroka-1 > list.visible) && (list.first <>0) break 1; //уходим...
4411 leency 359
				DrawPage();
360
				strcpy(#line, #temp);
4414 leency 361
				TextGoDown(list.x + 5, stroka * 10 + list.y + 5, list.w - 20); //закрашиваем следущую строку
4411 leency 362
			}
363
		}
364
	}
365
 
366
	DrawPage(); //рисует последнюю строку, потом это надо убрать, оптимизировав код
4414 leency 367
	TextGoDown(list.x + 5, stroka * 10 + list.y + 5, list.w - 20); //закрашиваем следущую строку
4411 leency 368
 
4415 leency 369
	if (list.visible * 10 + 25 <= list.h)
370
		DrawBar(list.x, list.visible * 10 + list.y + 25, list.w, -list.visible * 10 + list.h - 25, bg_color);
4414 leency 371
	if (stroka * 10 + 5 <= list.h)
372
		DrawBar(list.x, stroka * 10 + list.y + 5, list.w, -stroka * 10 + list.h - 5, bg_color); //закрашиваем всё до конца
4415 leency 373
	if (list.first == 0) list.count = stroka;
4411 leency 374
	if (anchor) //если посреди текста появится новый якорь - будет бесконечный цикл
375
	{
376
		anchor=NULL;
4415 leency 377
		list.first=anchor_line_num;
4411 leency 378
		ParseHTML(buf);
379
	}
380
	DrawScroller();
381
}
382
 
383
 
384
 
385
char oldtag[100];
386
void TWebBrowser::WhatTextStyle(int left1, top1, width1) {
387
	dword hr_color;
4491 leency 388
	byte opened;
4411 leency 389
 
390
	//проверяем тег открывается или закрывается
391
	if (tag[0] == '/')
392
	{
4491 leency 393
		 opened = 0;
4411 leency 394
		 strcpy(#tag, #tag+1);
395
	}
4491 leency 396
	else opened = 1;
4411 leency 397
 
4488 leency 398
	if (isTag("html"))
4411 leency 399
	{
4491 leency 400
		IF(!strcmp(#URL + strlen(#URL) - 4, ".mht")) IF (opened==0) ignor_text = 1; ELSE ignor_text = 0;
4411 leency 401
		return;
402
	}
403
 
4491 leency 404
	if (isTag("script")) || (isTag("style")) || (isTag("binary")) ignor_text = opened;
4411 leency 405
 
4488 leency 406
	if(isTag("title"))
4411 leency 407
	{
4491 leency 408
		if (opened) header=NULL;
4411 leency 409
		else if (!stroka) DrawTitle(#header); //тег закрылся - вывели строку
410
		return;
411
	}
412
 
413
	if (ignor_text) return;
414
 
4491 leency 415
	IF(isTag("q"))
416
	{
417
		if (opened)
418
		{
419
			TextGoDown(left1, top1, width1);
420
			strcat(#line, ' \"');
421
		}
422
		if (!opened)
423
		{
424
			chrcat(#line, '\"');
425
			TextGoDown(left1, top1, width1);
426
		}
427
	}
4411 leency 428
 
429
	if (anchor) && (!strcmp(#parametr, "id=")) //очень плохо!!! потому что если не последний тег, работать не будет
430
	{
4415 leency 431
		if (!strcmp(#anchor, #options))	anchor_line_num=list.first+stroka;
4411 leency 432
	}
433
 
4488 leency 434
	if (isTag("body"))
4411 leency 435
	{
436
		do{
4491 leency 437
			if (!strcmp(#parametr, "condition_max=")) condition_max = atoi(#options);
438
			if (!strcmp(#parametr, "link=")) link_color_inactive = GetColor(#options);
439
			if (!strcmp(#parametr, "alink=")) link_color_active = GetColor(#options);
4411 leency 440
			if (!strcmp(#parametr, "text=")) text_colors[0]=GetColor(#options);
441
			if (!strcmp(#parametr, "bgcolor="))
442
			{
443
				bg_color=GetColor(#options);
4475 leency 444
				DrawBuf.Fill(bg_color);
4411 leency 445
			}
446
		} while(GetNextParam());
447
		return;
448
	}
449
 
4488 leency 450
	if (isTag("a"))
4411 leency 451
	{
4491 leency 452
		if (opened)
4411 leency 453
		{
454
			if (link) IF(text_color_index > 0) text_color_index--; //если предыдущий тег а не был закрыт
455
 
456
			do{
457
				if (!strcmp(#parametr, "href="))
458
				{
4415 leency 459
					if (stroka - 1 > list.visible) || (stroka < -2) return;
4411 leency 460
 
461
					text_color_index++;
462
					text_colors[text_color_index] = text_colors[text_color_index-1];
463
 
464
					link = 1;
4491 leency 465
					text_colors[text_color_index] = link_color_inactive;
466
					PageLinks.AddLink(#options, stolbec*6+left1, top1);
4411 leency 467
				}
468
				if (anchor) && (!strcmp(#parametr, "name="))
469
				{
470
					if (!strcmp(#anchor, #options))
471
					{
4415 leency 472
						anchor_line_num=list.first+stroka;
4411 leency 473
					}
474
				}
475
			} while(GetNextParam());
476
		}
477
		else {
478
			link = 0;
479
			IF(text_color_index > 0) text_color_index--;
480
		}
481
		return;
482
	}
483
 
4488 leency 484
	if (isTag("font"))
4411 leency 485
	{
4491 leency 486
		if (opened)
4411 leency 487
		{
488
			text_color_index++;
489
			text_colors[text_color_index] = text_colors[text_color_index-1];
490
 
491
			do{
492
				if (strcmp(#parametr, "color=") == 0) //&& (parametr[1] == '#')
493
				{
494
					text_colors[text_color_index] = GetColor(#options);
495
				}
496
			} while(GetNextParam());
497
		}
498
		else
499
			if (text_color_index > 0) text_color_index--;
500
		return;
501
	}
4488 leency 502
	if(isTag("tr")) || (isTag("br")) {
4411 leency 503
		TextGoDown(left1, top1, width1);
504
		return;
505
	}
4488 leency 506
	if (isTag("div")) {
4411 leency 507
		IF(oldtag[0] <>'h') TextGoDown(left1, top1, width1);
508
		return;
509
	}
4488 leency 510
	if (isTag("p")) {
4411 leency 511
		IF(oldtag[0] == 'h') return;
512
		TextGoDown(left1, top1, width1);
4491 leency 513
		IF(opened) TextGoDown(left1, top1 + 10, width1);
4411 leency 514
		return;
515
	}
4475 leency 516
	/*
4488 leency 517
	if (isTag("center"))
4411 leency 518
	{
4491 leency 519
		if (opened) text_align = ALIGN_CENTER;
520
		if (!opened)
4411 leency 521
		{
522
			TextGoDown(left1, top1, width1);
523
			text_align = ALIGN_LEFT;
524
		}
525
		return;
526
	}
4488 leency 527
	if (isTag("right"))
4411 leency 528
	{
4491 leency 529
		if (opened) text_align = ALIGN_RIGHT;
530
		if (!opened)
4411 leency 531
		{
532
			TextGoDown(left1, top1, width1);
533
			text_align = ALIGN_LEFT;
534
		}
535
		return;
536
	}
4475 leency 537
	*/
4488 leency 538
	if (isTag("h1")) || (isTag("h2")) || (isTag("h3")) || (isTag("h4")) {
4411 leency 539
		TextGoDown(left1, top1, width1);
4491 leency 540
		if (opened) && (stroka>1) TextGoDown(left1, top1 + 10, width1);
4411 leency 541
		strcpy(#oldtag, #tag);
4491 leency 542
		if (opened)
4411 leency 543
		{
544
			if (!strcmp(#parametr, "align=")) && (!strcmp(#options,"center")) text_align = ALIGN_CENTER;
545
			if (!strcmp(#parametr, "align=")) && (!strcmp(#options,"right")) text_align = ALIGN_RIGHT;
546
			b_text = 1;
547
		}
4491 leency 548
		if (!opened)
4411 leency 549
		{
550
			text_align = ALIGN_LEFT;
551
			b_text = 0;
552
		}
553
		return;
554
	}
555
	else
556
		oldtag=NULL;
557
 
4488 leency 558
	if (isTag("b")) || (isTag("strong")) || (isTag("big")) {
4491 leency 559
		b_text = opened;
4411 leency 560
		return;
561
	}
4488 leency 562
	if(isTag("i")) || (isTag("em")) || (isTag("subtitle")) {
4491 leency 563
		i_text = opened;
4411 leency 564
		return;
565
	}
4488 leency 566
	if (isTag("dt"))
4411 leency 567
	{
4491 leency 568
		li_text = opened;
569
		IF(opened == 0) return;
4411 leency 570
		TextGoDown(left1, top1, width1);
571
		return;
572
	}
4488 leency 573
	if (isTag("condition"))
4417 leency 574
	{
4491 leency 575
		condition_text_active = opened;
576
		if (opened) && (!strcmp(#parametr, "show_if=")) condition_text_val = atoi(#options);
4417 leency 577
		return;
578
	}
4488 leency 579
	if (isTag("li")) || (isTag("dt")) //надо сделать вложенные списки
4411 leency 580
	{
4491 leency 581
		li_text = opened;
582
		if (opened)
4411 leency 583
		{
584
			TextGoDown(left1, top1, width1);
4475 leency 585
			if (stroka > -1) && (stroka - 2 < list.visible) DrawBuf.DrawBar(li_tab * 5 * 6 + left1 - 5, list.line_h/2-3, 2, 2, 0x555555);
4411 leency 586
		}
587
		return;
588
	}
4491 leency 589
	if (isTag("u")) || (isTag("ins")) u_text = opened;
590
	if (isTag("s")) || (isTag("strike")) || (isTag("del")) s_text = opened;
591
	if (isTag("ul")) || (isTag("ol")) IF(!opened)
4411 leency 592
	{
4491 leency 593
		li_text = opened;
4411 leency 594
		li_tab--;
595
		TextGoDown(left1, top1, width1);
596
	} ELSE li_tab++;
4488 leency 597
	if (isTag("dd")) stolbec += 5;
4491 leency 598
	if (isTag("blockquote")) blq_text = opened;
4497 leency 599
	if (isTag("pre")) || (isTag("code")) pre_text = opened;
4488 leency 600
	if (isTag("hr"))
4411 leency 601
	{
602
		if (anchor) || (stroka < -1)
603
		{
604
			stroka+=2;
605
			return;
606
		}
607
		if (strcmp(#parametr, "color=") == 0) hr_color = GetColor(#options); else hr_color = 0x999999;
608
		TextGoDown(left1, top1, width1);
4486 leency 609
		DrawBuf.DrawBar(5, list.line_h/2, list.w-10, 1, hr_color);
610
		TextGoDown(left1, top1+list.line_h, width1);
4411 leency 611
	}
4488 leency 612
	if (isTag("img"))
4411 leency 613
	{
4491 leency 614
		ImgCache.Images( left1, top1, width1);
4411 leency 615
		return;
616
	}
4488 leency 617
	if (isTag("meta")) || (isTag("?xml"))
4411 leency 618
	{
619
		do{
620
			if (!strcmp(#parametr, "charset=")) || (!strcmp(#parametr, "content=")) || (!strcmp(#parametr, "encoding="))
621
			{
622
				strcpy(#options, #options[strrchr(#options, '=')]); //поиск в content=
4475 leency 623
				if (!strcmp(#options, "utf-8"))  || (!strcmp(#options,"utf8"))      ReadHtml(_UTF);
4411 leency 624
				if (!strcmp(#options, "koi8-r")) || (!strcmp(#options, "koi8-u"))   ReadHtml(_KOI);
625
				if (!strcmp(#options, "dos"))    || (!strcmp(#options, "cp-866"))   ReadHtml(_DOS);
626
			}
627
		} while(GetNextParam());
628
		return;
629
	}
630
}
631
 
4491 leency 632
/*
633
char *encodings = {
634
	"utf-8",  _UTF,
635
	"utf8",   _UTF,
636
	"koi8-r", _KOI,
637
	"koi8-u", _KOI,
638
	"dos",    _DOS,
639
	"cp-866", _DOS
640
};
641
*/
4411 leency 642
 
643
void TWebBrowser::DrawScroller() //не оптимальная отрисовка, но зато в одном месте
644
{
4416 leency 645
	scroll_wv.max_area = list.count;
646
	scroll_wv.cur_area = list.visible;
647
	scroll_wv.position = list.first;
4411 leency 648
 
4416 leency 649
	scroll_wv.all_redraw=1;
4486 leency 650
	scroll_wv.start_x = list.x + list.w;
651
	scroll_wv.size_y=list.h;
4411 leency 652
 
4416 leency 653
	scrollbar_v_draw(#scroll_wv);
4411 leency 654
}
655
 
4475 leency 656
 
657
void TWebBrowser::TextGoDown(int left1, top1, width1)
658
{
4486 leency 659
	if (!stroka) DrawBar(list.x, list.y, list.w, 5, bg_color); //закрашиваем фон над первой строкой
660
	if (top1>=list.y) && ( top1 < list.h+list.y-10)  && (!anchor)
4475 leency 661
	{
4486 leency 662
		if (text_align == ALIGN_CENTER) DrawBuf.AlignCenter(left1,top1,list.w,list.line_h,stolbec * 6);
663
		if (text_align == ALIGN_RIGHT) DrawBuf.AlignRight(left1,top1,list.w,list.line_h,stolbec * 6);
664
		PutPaletteImage(buf_data+8, list.w, list.line_h, left1-5, top1, 32,0);
4475 leency 665
		DrawBuf.Fill(bg_color);
666
	}
667
	stroka++;
668
	if (blq_text) stolbec = 8; else stolbec = 0;
669
	if (li_text) stolbec = li_tab * 5;
4488 leency 670
}
671
 
672
 
673
 
674
int isTag(dword text)
675
{
676
	if (!strcmp(#tag,text)) return 1; else return 0;
677
}