Subversion Repositories Kolibri OS

Rev

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