Subversion Repositories Kolibri OS

Rev

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

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