Subversion Repositories Kolibri OS

Rev

Rev 4651 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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