Subversion Repositories Kolibri OS

Rev

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