Subversion Repositories Kolibri OS

Rev

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