Subversion Repositories Kolibri OS

Rev

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