Subversion Repositories Kolibri OS

Rev

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