Subversion Repositories Kolibri OS

Rev

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