Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
7752 leency 1
#include "..\TWB\colors.h"
2
#include "..\TWB\anchors.h"
7771 leency 3
#include "..\TWB\parse_tag.h"
7758 leency 4
#include "..\TWB\special.h"
7757 leency 5
#include "..\TWB\img_cache.h"
7759 leency 6
#include "..\TWB\tag_list.h"
7757 leency 7
dword page_bg;
7759 leency 8
dword link_color_default;
7757 leency 9
dword link_color_active;
10
#include "..\TWB\links.h"
4411 leency 11
 
7759 leency 12
#define BODY_MARGIN 6
13
#define BASIC_LINE_H 18
4416 leency 14
 
7771 leency 15
DrawBufer DrawBuf;
16
char line[500];
17
 
5746 leency 18
struct _style {
7752 leency 19
	bool
6794 leency 20
	b, u, s, h,
5746 leency 21
	pre,
22
	blq,
7742 leency 23
	button,
7759 leency 24
	image;
7752 leency 25
	dword bg_color;
7759 leency 26
	LIST tag_list;
27
	dword tag_title;
5746 leency 28
};
29
 
4411 leency 30
struct TWebBrowser {
4540 leency 31
	llist list;
5746 leency 32
	_style style;
7752 leency 33
	dword draw_y, stolbec;
6803 leency 34
	int zoom;
7752 leency 35
	dword o_bufpointer;
7759 leency 36
	int cur_encoding, custom_encoding;
37
	bool link, t_html, t_body;
7893 leency 38
	dword link_bg;
7759 leency 39
	dword bufpointer;
40
	dword bufsize;
7945 leency 41
	dword is_html;
7759 leency 42
 
7771 leency 43
	void Paint();
7746 leency 44
	void SetPageDefaults();
7752 leency 45
	void AddCharToTheLine();
46
	void ParseHtml();
5766 leency 47
	void SetStyle();
7762 leency 48
	bool CheckForLineBreak();
49
	void NewLine();
50
	void DrawScroller();
51
	void ChangeEncoding();
4411 leency 52
	void DrawPage();
7759 leency 53
	char header[150];
54
};
4486 leency 55
 
7757 leency 56
scroll_bar scroll_wv = { 15,NULL,NULL,NULL,0,2,NULL,0,0,0xeeeeee,0xBBBbbb,0xeeeeee};
4411 leency 57
 
5747 leency 58
//============================================================================================
7771 leency 59
void TWebBrowser::Paint()
4411 leency 60
{
6803 leency 61
	dword start_x, line_length, stolbec_len;
7762 leency 62
	dword text_color__;
4411 leency 63
 
7759 leency 64
	if (style.tag_title)
4411 leency 65
	{
7759 leency 66
		strncpy(#header, #line, sizeof(TWebBrowser.header)-1);
67
		strncat(#header, " - ", sizeof(TWebBrowser.header)-1);
68
		strncat(#header, #version, sizeof(TWebBrowser.header)-1);
4411 leency 69
		line = 0;
70
		return;
71
	}
7758 leency 72
	if (t_html) && (!t_body) {
73
		line = 0;
74
		return;
75
	}
4411 leency 76
 
6803 leency 77
	if (line)
4411 leency 78
	{
7759 leency 79
		start_x = stolbec * list.font_w + BODY_MARGIN + list.x;
6803 leency 80
		stolbec_len = strlen(#line) * zoom;
5768 leency 81
		line_length = stolbec_len * list.font_w;
4411 leency 82
 
7749 leency 83
		if (debug_mode) {
7750 leency 84
			DrawBuf.DrawBar(start_x, draw_y, line_length, list.item_h, 0xDDDddd);
7749 leency 85
		}
86
 
7743 leency 87
		if (style.bg_color!=page_bg) {
7750 leency 88
			DrawBuf.DrawBar(start_x, draw_y, line_length, list.item_h, style.bg_color);
7743 leency 89
		}
90
 
7742 leency 91
		if (style.image) {
7743 leency 92
			DrawBuf.DrawBar(start_x, draw_y, line_length, list.item_h-1, 0xF9DBCB);
7742 leency 93
		}
94
		if (style.button) {
95
			DrawBuf.DrawBar(start_x, draw_y, line_length, list.item_h - calc(zoom*2), 0xCCCccc);
96
			DrawBuf.DrawBar(start_x, draw_y + list.item_h - calc(zoom*2), line_length, zoom, 0x999999);
97
		}
98
 
7762 leency 99
		text_color__ = text_colors[text_color_index];
100
		if (link) && (text_colors[text_color_index]==text_colors[0]) text_color__ = link_color_default;
101
 
7889 leency 102
		DrawBuf.WriteText(start_x, draw_y, list.font_type, text_color__, #line, NULL);
103
		if (style.b) DrawBuf.WriteText(start_x+1, draw_y, list.font_type, text_color__, #line, NULL);
7762 leency 104
		if (style.s) DrawBuf.DrawBar(start_x, list.item_h / 2 - zoom + draw_y, line_length, zoom, text_color__);
105
		if (style.u) DrawBuf.DrawBar(start_x, list.item_h - zoom - zoom + draw_y, line_length, zoom, text_color__);
5519 leency 106
		if (link) {
7747 leency 107
			if (line[0]==' ') && (line[1]==NULL) {} else {
7759 leency 108
				DrawBuf.DrawBar(start_x, draw_y + list.item_h - calc(zoom*2)-1, line_length, zoom, link_color_default);
109
				PageLinks.AddText(start_x, draw_y + list.y, line_length, list.item_h - calc(zoom*2)-1, UNDERLINE, zoom);
7746 leency 110
			}
4411 leency 111
		}
4718 leency 112
		stolbec += stolbec_len;
7750 leency 113
		if (debug_mode) debug(#line);
114
		line = NULL;
4411 leency 115
	}
116
}
5747 leency 117
//============================================================================================
7746 leency 118
void TWebBrowser::SetPageDefaults()
119
{
120
	style.b = style.u = style.s = style.h = style.blq = t_html = t_body = style.pre =
7759 leency 121
	link = text_color_index = text_colors[0] = style.tag_title = false;
122
	style.tag_list.reset();
123
	link_color_default = 0x0000FF;
4491 leency 124
	link_color_active = 0xFF0000;
7743 leency 125
	page_bg = 0xFFFFFF;
7893 leency 126
	link_bg = 0xFFFFFF;
7743 leency 127
	style.bg_color = page_bg;
128
	DrawBuf.Fill(0, page_bg);
4504 leency 129
	PageLinks.Clear();
7752 leency 130
	anchors.clear();
7758 leency 131
	header = NULL;
7759 leency 132
	cur_encoding = CH_CP866;
133
	draw_y = BODY_MARGIN;
4411 leency 134
	stolbec = 0;
135
	line = 0;
7752 leency 136
	zoom = 1;
7757 leency 137
	//hold original buffer
138
	if (o_bufpointer) o_bufpointer=free(o_bufpointer);
139
	o_bufpointer = malloc(bufsize);
140
	memmov(o_bufpointer, bufpointer, bufsize);
7759 leency 141
	if (custom_encoding != -1) {
142
		cur_encoding = custom_encoding;
7781 leency 143
		bufpointer = ChangeCharset(cur_encoding, "CP866", bufpointer);
7759 leency 144
	}
7746 leency 145
}
146
//============================================================================================
7752 leency 147
void TWebBrowser::AddCharToTheLine(unsigned char _char)
148
{
149
	dword line_len;
150
	if (_char<=15) _char=' ';
151
	line_len = strlen(#line);
152
	if (!style.pre) && (_char == ' ')
153
	{
154
		if (line[line_len-1]==' ') return; //no double spaces
155
		if (!stolbec) && (!line) return; //no paces at the beginning of the line
156
	}
7771 leency 157
	if (line_len < sizeof(line)) chrcat(#line, _char);
7752 leency 158
	CheckForLineBreak();
159
}
160
//============================================================================================
7759 leency 161
void TWebBrowser::ParseHtml(dword _bufpointer, _bufsize){
7746 leency 162
	word bukva[2];
7752 leency 163
	char unicode_symbol[10];
164
	dword unicode_symbol_result;
7746 leency 165
	dword j;
7752 leency 166
	bool ignor_param=false;
167
	int tab_len;
7746 leency 168
	dword bufpos;
7759 leency 169
	bufsize = _bufsize;
7771 leency 170
	if (bufpointer != _bufpointer) {
171
		bufpointer = malloc(bufsize);
172
		memmov(bufpointer, _bufpointer, bufsize);
173
	} else {
174
		custom_encoding = CH_CP866;
175
	}
7746 leency 176
	SetPageDefaults();
7945 leency 177
	is_html = true;
178
	if (!strstri(bufpointer, "
7749 leency 179
		t_body = true;
7945 leency 180
		if (!strstri(bufpointer, "
181
			style.pre = true; //show linebreaks for a plaint text
182
			is_html = false;
183
		}
7749 leency 184
	}
5773 leency 185
	for (bufpos=bufpointer ; (bufpos < bufpointer+bufsize) && (ESBYTE[bufpos]!=0) ; bufpos++;)
4411 leency 186
	{
4508 leency 187
		bukva = ESBYTE[bufpos];
4411 leency 188
		switch (bukva)
189
		{
190
		case 0x0a:
7752 leency 191
			if (style.pre) {
7771 leency 192
				Paint();
5781 leency 193
				NewLine();
7752 leency 194
			} else {
195
				AddCharToTheLine(0x0a);
4411 leency 196
			}
7752 leency 197
			break;
198
		case 0x09:
199
			if (style.pre) {
200
				tab_len = strlen(#line) + stolbec % 4;
201
				if (!tab_len) tab_len = 4; else tab_len = 4 - tab_len;
4411 leency 202
				for (j=0; j
7752 leency 203
			} else {
204
				AddCharToTheLine(0x09);
4411 leency 205
			}
7752 leency 206
			break;
4411 leency 207
		case '&': //  and so on
7752 leency 208
			for (j=1, unicode_symbol=0; (ESBYTE[bufpos+j]<>';') && (j<8); j++)
4411 leency 209
			{
7749 leency 210
				bukva = ESBYTE[bufpos+j];
7752 leency 211
				chrcat(#unicode_symbol, bukva);
4411 leency 212
			}
7771 leency 213
			if (GetUnicodeSymbol(#line, #unicode_symbol, sizeof(line)-1)) {
7749 leency 214
				bufpos += j;
7750 leency 215
				CheckForLineBreak();
7749 leency 216
			} else {
7752 leency 217
				AddCharToTheLine('&');
7749 leency 218
			}
4411 leency 219
			break;
220
		case '<':
7945 leency 221
			if (!is_html) goto _default;
5749 leency 222
			bufpos++;
5768 leency 223
			if (!strncmp(bufpos,"!--",3))
4411 leency 224
			{
6986 leency 225
				bufpos+=3;
226
				while (strncmp(bufpos,"-->",3)!=0) && (bufpos < bufpointer + bufsize)
227
				{
228
					bufpos++;
229
				}
7746 leency 230
				bufpos+=2;
6986 leency 231
				break;
4411 leency 232
			}
7752 leency 233
			tag.reset();
234
			if (ESBYTE[bufpos] == '/') {
235
				tag.opened = false;
236
				bufpos++;
237
			}
238
 
239
			ignor_param=false;
6735 leency 240
			while (ESBYTE[bufpos] !='>') && (bufpos < bufpointer + bufsize) //ïîëó÷àåì òåã è åãî ïàðàìåòðû
4411 leency 241
			{
4508 leency 242
				bukva = ESBYTE[bufpos];
7762 leency 243
				if (bukva == '\x9') || (bukva == '\x0a') || (bukva == '\x0d') bukva = ' ';
4411 leency 244
				if (!ignor_param) && (bukva <>' ')
245
				{
7752 leency 246
					if (strlen(#tag.name)+1
4411 leency 247
				}
248
				else
249
				{
250
					ignor_param = true;
7752 leency 251
					if (strlen(#tag.params)+1
7762 leency 252
					//chrncat(#tag.params, bukva, sizeof(tag.params)-1);
4411 leency 253
				}
4508 leency 254
				bufpos++;
4411 leency 255
			}
7752 leency 256
			strlwr(#tag.name);
4411 leency 257
 
7746 leency 258
			// ignore text inside the next tags
7752 leency 259
			if (tag.is("script")) || (tag.is("style")) || (tag.is("binary")) || (tag.is("select"))  {
260
				sprintf(#tag.params, "", #tag.name);
7945 leency 261
				if (j = strstri(bufpos, #tag.params)) bufpos = j-1;
7746 leency 262
				break;
263
			}
264
 
7752 leency 265
			if (tag.name[strlen(#tag.name)-1]=='/') tag.name[strlen(#tag.name)-1]=NULL; //for br/ !!!!!!!!
266
			if (tag.params) tag.parse_params();
7746 leency 267
 
7757 leency 268
			if (tag.name) {
7750 leency 269
				CheckForLineBreak();
7771 leency 270
				Paint();
7752 leency 271
				if (tag.name) SetStyle();
7746 leency 272
			}
4411 leency 273
			break;
274
		default:
7945 leency 275
			_default:
7752 leency 276
			AddCharToTheLine(ESBYTE[bufpos]);
4411 leency 277
		}
278
	}
7771 leency 279
	Paint();
5766 leency 280
	NewLine();
7752 leency 281
	list.count = draw_y;
7755 leency 282
	list.CheckDoesValuesOkey();
283
	anchors.current = NULL;
7759 leency 284
	custom_encoding = -1;
7758 leency 285
	if (!header) {
7759 leency 286
		strncpy(#header, #version, sizeof(TWebBrowser.header)-1);
7758 leency 287
		DrawTitle(#header);
288
	}
4411 leency 289
}
5747 leency 290
//============================================================================================
7750 leency 291
bool TWebBrowser::CheckForLineBreak()
4718 leency 292
{
7750 leency 293
	int line_break_pos;
4718 leency 294
	char new_line_text[4096];
7758 leency 295
	//Do we need a line break?
7750 leency 296
	if (strlen(#line)*zoom + stolbec < list.column_max) return false;
7758 leency 297
	//Yes, we do. Lets calculate where...
7750 leency 298
	line_break_pos = strrchr(#line, ' ');
7758 leency 299
	//Is a new line fits in the current line?
7750 leency 300
	if (line_break_pos*zoom + stolbec > list.column_max) {
301
		line_break_pos = list.column_max/zoom - stolbec;
302
		while(line_break_pos) && (line[line_break_pos]!=' ') line_break_pos--;
303
	}
7758 leency 304
	//Maybe a new line is too big for the whole new line? Then we have to split it
7759 leency 305
	if (!line_break_pos) && (style.tag_list.level*5 + strlen(#line) * zoom >= list.column_max) {
7758 leency 306
		line_break_pos = list.column_max/zoom - stolbec;
7742 leency 307
	}
7750 leency 308
	strcpy(#new_line_text, #line + line_break_pos);
7758 leency 309
	line[line_break_pos] = 0x00;
310
 
7771 leency 311
	Paint();
7758 leency 312
 
4718 leency 313
	strcpy(#line, #new_line_text);
314
	NewLine();
7762 leency 315
	//while (CheckForLineBreak()==true) {};
7750 leency 316
	return true;
4718 leency 317
}
5747 leency 318
//============================================================================================
5773 leency 319
void TWebBrowser::SetStyle() {
7749 leency 320
	char img_path[4096]=0;
7752 leency 321
 
322
	dword value;
323
 
7755 leency 324
	if (value = tag.get_value_of("name=")) || (value = tag.get_value_of("id=")) {
325
		anchors.add(value, draw_y);
326
		if (anchors.current) && (streq(value, #anchors.current+1)) {
327
			list.first = draw_y;
328
			anchors.current = NULL;
329
		}
7758 leency 330
	}
7752 leency 331
	if (tag.is("html")) {
332
		t_html = tag.opened;
4411 leency 333
		return;
334
	}
7758 leency 335
	if (tag.is("title")) {
7759 leency 336
		style.tag_title = tag.opened;
7758 leency 337
		if (!tag.opened) DrawTitle(#header);
338
		return;
339
	}
7752 leency 340
	if (tag.is("body")) {
341
		t_body = tag.opened;
7893 leency 342
		if (value = tag.get_value_of("link="))   link_color_default = GetColor(value);
343
		if (value = tag.get_value_of("alink="))  link_color_active = GetColor(value);
344
		if (value = tag.get_value_of("bglink=")) link_bg=GetColor(value);
345
		if (value = tag.get_value_of("text="))   text_colors[0]=GetColor(value);
7752 leency 346
		if (value = tag.get_value_of("bgcolor=")) {
7937 leency 347
			style.bg_color = page_bg = link_bg = GetColor(value);
7752 leency 348
			DrawBuf.Fill(0, page_bg);
349
		}
7762 leency 350
		// Autodetecting encoding if no encoding was set
351
		if (tag.opened) && (custom_encoding==-1) && (cur_encoding == CH_CP866) {
352
			if (strstr(bufpointer, "\208\190")) ChangeEncoding(CH_UTF8);
7799 leency 353
			else if (chrnum(bufpointer, '\246')>5) ChangeEncoding(CH_CP1251);
7762 leency 354
		}
4411 leency 355
		return;
356
	}
7762 leency 357
	if (tag.is("br")) { NewLine(); return; }
7797 leency 358
	if (tag.is("b")) || (tag.is("strong")) || (tag.is("big")) || (tag.is("w:b")) {
7780 leency 359
		style.b = tag.opened;
360
		return;
361
	}
7797 leency 362
	if (tag.is("w:r")) && (!tag.opened) { style.b = false; return; }
7752 leency 363
	if (tag.is("a")) {
364
		if (tag.opened)
4411 leency 365
		{
7752 leency 366
			if (value = tag.get_value_of("href=")) && (!strstr(value,"javascript:"))
367
			{
7762 leency 368
				link = true;
7752 leency 369
				PageLinks.AddLink(value);
7893 leency 370
				style.bg_color = link_bg;
7752 leency 371
			}
372
		} else {
7762 leency 373
			link = false;
7893 leency 374
			style.bg_color = page_bg;
4411 leency 375
		}
376
		return;
377
	}
7762 leency 378
	if (tag.is("iframe")) && (value = tag.get_value_of("src=")) {
379
		NewLine();
380
		strcpy(#line, "IFRAME: ");
7771 leency 381
		Paint();
7762 leency 382
		link=true;
383
		PageLinks.AddLink(value);
7771 leency 384
		strncpy(#line, value, sizeof(line)-1);
7762 leency 385
		while (CheckForLineBreak()) {};
7771 leency 386
		Paint();
7762 leency 387
		link=false;
388
		NewLine();
389
	}
7752 leency 390
	if (tag.is("font")) {
7743 leency 391
		style.bg_color = page_bg;
7752 leency 392
		if (tag.opened)
4411 leency 393
		{
394
			text_color_index++;
395
			text_colors[text_color_index] = text_colors[text_color_index-1];
7752 leency 396
			if (value = tag.get_value_of("color=")) text_colors[text_color_index] = GetColor(value);
397
			if (value = tag.get_value_of("bg=")) style.bg_color = GetColor(value);
4411 leency 398
		}
5749 leency 399
		else if (text_color_index > 0) text_color_index--;
4411 leency 400
		return;
401
	}
7752 leency 402
	if (tag.is("div")) {
7756 leency 403
		if (streq(#tag.prior,"div")) && (tag.opened) return;
7746 leency 404
		NewLine();
4411 leency 405
		return;
406
	}
7752 leency 407
	if (tag.is("header")) || (tag.is("article")) || (tag.is("footer")) || (tag.is("figure")) {
7746 leency 408
		NewLine();
409
		return;
410
	}
7780 leency 411
	if (tag.is("p")) || (tag.is("w:p"))  {
7756 leency 412
		IF (tag.prior[0] == 'h') || (streq(#tag.prior,"td")) || (streq(#tag.prior,"p")) return;
4692 leency 413
		NewLine();
4411 leency 414
		return;
415
	}
7762 leency 416
	if (tag.is("pre")) { style.pre = tag.opened; return; }
7757 leency 417
	if (tag.is("td")) { if (tag.opened) AddCharToTheLine(' '); return; }
7752 leency 418
	if (tag.is("tr")) { if (tag.opened) NewLine(); return; }
419
	if (tag.is("button")) { style.button = tag.opened; stolbec++; return; }
420
	if (tag.is("u")) || (tag.is("ins")) { style.u=tag.opened; return;}
421
	if (tag.is("s")) || (tag.is("strike")) || (tag.is("del")) { style.s=tag.opened; return; }
7764 leency 422
	if (tag.is("dl")) {
423
		if (tag.opened) NewLine();
424
		return;
425
	}
426
	if (tag.is("dd")) {
427
		//NewLine();
428
		//if (tag.opened) stolbec += 5;  //stolbec overflow!
429
		return;
430
	}
7752 leency 431
	if (tag.is("blockquote")) { style.blq = tag.opened; return; }
7759 leency 432
	if (tag.is("code")) {
433
		if (tag.opened) style.bg_color = 0xe4ffcb; else style.bg_color = page_bg;
434
		style.pre = tag.opened; return;
435
	}
7752 leency 436
	if (tag.is("img")) {
437
		if (value = tag.get_value_of("src=")) strlcpy(#img_path, value, sizeof(img_path)-1);
7771 leency 438
		if (value = tag.get_value_of("title=")) && (strlen(value)
439
		if (value = tag.get_value_of("alt=")) && (strlen(value)
7750 leency 440
		if (!img_path) { line=0; return; }
7742 leency 441
		style.image = true;
442
		text_color_index++;
443
		text_colors[text_color_index] = 0x9A6F29;
444
		if (!line) {
445
			if (!strncmp(#img_path, "data:", 5)) img_path=0;
7749 leency 446
			replace_char(#img_path, '?', NULL, strlen(#img_path));
7742 leency 447
			sprintf(#line, "[%s]", #img_path+strrchr(#img_path, '/'));
448
			line[50]= NULL;
449
		}
7750 leency 450
		while (CheckForLineBreak()) {};
7771 leency 451
		Paint();
7742 leency 452
		text_color_index--;
453
		style.image = false;
7759 leency 454
		//ImgCache.Images( list.x, draw_y, list.w);
7742 leency 455
		return;
456
	}
7758 leency 457
	if (tag.is("h4")) {
458
		NewLine();
7759 leency 459
		NewLine();
7758 leency 460
		style.h = tag.opened;
461
		style.b = tag.opened;
462
	}
7752 leency 463
	if (tag.is("h1")) || (tag.is("h2")) || (tag.is("h3")) || (tag.is("caption")) {
464
		style.h = tag.opened;
7758 leency 465
		if (tag.opened) {
7759 leency 466
			if (!style.pre) NewLine();
6794 leency 467
			draw_y += 10;
7759 leency 468
			zoom=2;
469
			list.font_type |= 10011001b;
470
			list.item_h = BASIC_LINE_H * 2 - 2;
7752 leency 471
			if (tag.is("h1")) style.b = true;
7758 leency 472
		} else {
7752 leency 473
			if (tag.is("h1")) style.b = false;
6794 leency 474
			NewLine();
7759 leency 475
			zoom=1;
476
			list.font_type = 10011000b;
477
			list.item_h = BASIC_LINE_H;
4411 leency 478
		}
479
		return;
480
	}
7752 leency 481
	if (tag.is("dt")) {
7759 leency 482
		style.tag_list.upd_level(tag.opened, DT);
7752 leency 483
		if (tag.opened) NewLine();
4411 leency 484
		return;
485
	}
7759 leency 486
	if (tag.is("ul")) {
487
		style.tag_list.upd_level(tag.opened, UL);
488
		if (!tag.opened) && (!style.pre) NewLine();
489
		return;
490
	}
491
	if (tag.is("ol")) {
492
		style.tag_list.upd_level(tag.opened, OL);
493
		if (!tag.opened) && (!style.pre) NewLine();
494
		return;
495
	}
496
	if (tag.is("li")) && (tag.opened)
4411 leency 497
	{
7759 leency 498
		if (!style.tag_list.level) style.tag_list.upd_level(1, UL);
499
		if (!style.pre) NewLine();
500
		if (style.tag_list.get_order_type() == UL) {
7742 leency 501
			strcpy(#line, "\31 ");
7759 leency 502
			stolbec = style.tag_list.level * 5 - 2;
503
		}
504
		if (style.tag_list.get_order_type() == OL) {
505
			sprintf(#line, "%i. ", style.tag_list.inc_counter());
506
			stolbec = style.tag_list.level * 5 - strlen(#line);
4411 leency 507
		}
508
		return;
509
	}
7762 leency 510
	if (tag.is("q"))
511
	{
512
		if (tag.opened)	{
513
			EAX = strlen(#line);
514
			if (line[EAX-1] != ' ') chrcat(#line, ' ');
515
			chrcat(#line, '\"');
516
		}
517
		if (!tag.opened) strcat(#line, "\" ");
518
		return;
519
	}
7752 leency 520
	if (tag.is("hr")) {
521
		if (value = tag.get_value_of("color=")) EDI = GetColor(value); else EDI = 0x999999;
5773 leency 522
		$push edi;
4692 leency 523
		NewLine();
5773 leency 524
		$pop edi;
7746 leency 525
		draw_y += 10;
6794 leency 526
		DrawBuf.DrawBar(5, draw_y - 1, list.w-10, 1, EDI);
4692 leency 527
		NewLine();
7746 leency 528
		draw_y += 10;
5773 leency 529
		return;
4411 leency 530
	}
7759 leency 531
	if (custom_encoding == -1) && (tag.is("meta")) || (tag.is("?xml")) {
7752 leency 532
		if (value = tag.get_value_of("charset=")) || (value = tag.get_value_of("content=")) || (value = tag.get_value_of("encoding="))
533
		{
534
			value += strrchr(value, '='); //search in content=
535
			strlwr(value);
7762 leency 536
			if      (streq(value,"utf-8"))        || (streq(value,"utf8"))        ChangeEncoding(CH_UTF8);
537
			else if (streq(value,"windows-1251")) || (streq(value,"windows1251")) ChangeEncoding(CH_CP1251);
538
			else if (streq(value,"dos"))          || (streq(value,"cp-866"))      ChangeEncoding(CH_CP866);
539
			else if (streq(value,"iso-8859-5"))   || (streq(value,"iso8859-5"))   ChangeEncoding(CH_ISO8859_5);
540
			else if (streq(value,"koi8-r"))       || (streq(value,"koi8-u"))      ChangeEncoding(CH_KOI8);
7752 leency 541
		}
4411 leency 542
		return;
543
	}
544
}
7746 leency 545
//============================================================================================
4674 leency 546
void TWebBrowser::DrawScroller()
4411 leency 547
{
4416 leency 548
	scroll_wv.max_area = list.count;
549
	scroll_wv.cur_area = list.visible;
550
	scroll_wv.position = list.first;
5519 leency 551
	scroll_wv.all_redraw = 0;
4486 leency 552
	scroll_wv.start_x = list.x + list.w;
4508 leency 553
	scroll_wv.start_y = list.y;
5678 leency 554
	scroll_wv.size_y = list.h;
4416 leency 555
	scrollbar_v_draw(#scroll_wv);
4411 leency 556
}
5747 leency 557
//============================================================================================
7762 leency 558
void TWebBrowser::ChangeEncoding(int _new_encoding)
559
{
560
	if (cur_encoding == _new_encoding) return;
561
	cur_encoding = _new_encoding;
7781 leency 562
	bufpointer = ChangeCharset(cur_encoding, "CP866", bufpointer);
7762 leency 563
	if (header) {
7781 leency 564
		ChangeCharset(cur_encoding, "CP866", #header);
7762 leency 565
		DrawTitle(#header);
566
	}
567
}
568
//============================================================================================
4692 leency 569
void TWebBrowser::NewLine()
4475 leency 570
{
6803 leency 571
	dword onleft, ontop;
7742 leency 572
	static int empty_line=0;
4692 leency 573
 
7759 leency 574
	if (!stolbec) && (draw_y==BODY_MARGIN) return;
7742 leency 575
 
7759 leency 576
	if (style.tag_list.level) && (stolbec == style.tag_list.level * 5) {
7742 leency 577
		if (empty_line<1) empty_line++;
578
		else return;
7749 leency 579
	} else if (!stolbec) {
580
		if (empty_line<1) empty_line++;
581
		else return;
7742 leency 582
	} else {
583
		empty_line=0;
584
	}
6794 leency 585
 
7759 leency 586
	onleft = list.x + BODY_MARGIN;
6794 leency 587
	ontop = draw_y + list.y;
4637 leency 588
	if (t_html) && (!t_body) return;
6794 leency 589
	draw_y += list.item_h;
5746 leency 590
	if (style.blq) stolbec = 6; else stolbec = 0;
7759 leency 591
	stolbec += style.tag_list.level * 5;
7750 leency 592
	if (debug_mode) debugln(NULL);
4488 leency 593
}
5747 leency 594
//============================================================================================
5766 leency 595
void TWebBrowser::DrawPage()
596
{
6794 leency 597
	PutPaletteImage(list.first * DrawBuf.bufw * 4 + buf_data+8, DrawBuf.bufw, list.h, DrawBuf.bufx, DrawBuf.bufy, 32, 0);
5766 leency 598
	DrawScroller();
599
}