Subversion Repositories Kolibri OS

Rev

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