Subversion Repositories Kolibri OS

Rev

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