Subversion Repositories Kolibri OS

Rev

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

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