Subversion Repositories Kolibri OS

Rev

Rev 7032 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7032 Rev 7043
1
scroll_bar scroll_wv = { 15,200,398,44,0,2,115,15,0,0xeeeeee,0xBBBbbb,0xeeeeee,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1};
1
scroll_bar scroll_wv = { 15,200,398,44,0,2,115,15,0,0xeeeeee,0xBBBbbb,0xeeeeee,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1};
2
 
2
 
3
enum { ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT};
3
enum { ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT};
4
 
4
 
5
struct _style {
5
struct _style {
6
byte
6
byte
7
	b, u, s, h,
7
	b, u, s, h,
8
	pre,
8
	pre,
9
	blq,
9
	blq,
10
	li,
10
	li,
11
	li_tab,
11
	li_tab,
12
	align;
12
	align;
13
};
13
};
14
 
14
 
15
struct TWebBrowser {
15
struct TWebBrowser {
16
	llist list;
16
	llist list;
17
	_style style;
17
	_style style;
18
	DrawBufer DrawBuf;
18
	DrawBufer DrawBuf;
19
	int zoom;
19
	int zoom;
20
	void Prepare();
20
	void Prepare();
21
	void SetStyle();
21
	void SetStyle();
22
	void DrawStyle();
22
	void DrawStyle();
23
	void DrawPage();
23
	void DrawPage();
24
	void DrawScroller();
24
	void DrawScroller();
25
	void LoadInternalPage();
25
	void LoadInternalPage();
26
	void NewLine();
26
	void NewLine();
27
	void Perenos();
27
	void Perenos();
28
	void BufEncode();
28
	void BufEncode();
29
} WB1;
29
} WB1;
30
 
30
 
31
 
31
 
32
byte 	
32
byte 	
33
	link,
33
	link,
34
	ignor_text,
34
	ignor_text,
35
	cur_encoding,
35
	cur_encoding,
36
	t_html,
36
	t_html,
37
	t_body;
37
	t_body;
38
 
38
 
39
dword bufpointer=0;
39
dword bufpointer=0;
40
dword o_bufpointer=0;
40
dword o_bufpointer=0;
41
dword bufsize=0;
41
dword bufsize=0;
42
 
42
 
43
dword text_colors[300];
43
dword text_colors[300];
44
dword text_color_index;
44
dword text_color_index;
45
dword link_color_inactive;
45
dword link_color_inactive;
46
dword link_color_active;
46
dword link_color_active;
47
dword bg_color;
47
dword bg_color;
48
 
48
 
49
int draw_y;
49
int draw_y;
50
int stolbec;
50
int stolbec;
51
int tab_len;
51
int tab_len;
52
int anchor_y;
52
int anchor_y;
53
 
53
 
54
int body_magrin=5;
54
int body_magrin=5;
55
int basic_line_h=22;
55
int basic_line_h=22;
56
 
56
 
57
char URL[10000];
57
char URL[10000];
58
char header[2048];
58
char header[2048];
59
char line[500];
59
char line[500];
60
char tagparam[10000];
60
char tagparam[10000];
61
char tag[100];
61
char tag[100];
62
char oldtag[100];
62
char oldtag[100];
63
char attr[1200];
63
char attr[1200];
64
char val[4096];
64
char val[4096];
65
 
65
 
66
#include "..\TWB\absolute_url.h"
66
#include "..\TWB\absolute_url.h"
67
#include "..\TWB\links.h"
67
#include "..\TWB\links.h"
68
#include "..\TWB\colors.h"
68
#include "..\TWB\colors.h"
69
#include "..\TWB\unicode_tags.h"
69
#include "..\TWB\unicode_tags.h"
70
#include "..\TWB\img_cache.h"
70
#include "..\TWB\img_cache.h"
71
#include "..\TWB\parce_tag.h"
71
#include "..\TWB\parce_tag.h"
72
 
72
 
73
 
73
 
74
//============================================================================================
74
//============================================================================================
75
void TWebBrowser::DrawStyle()
75
void TWebBrowser::DrawStyle()
76
{
76
{
77
	dword start_x, line_length, stolbec_len;
77
	dword start_x, line_length, stolbec_len;
78
	
78
	
79
	if (!header)
79
	if (!header)
80
	{
80
	{
81
		strcpy(#header, #line);
81
		strcpy(#header, #line);
82
		line = 0;
82
		line = 0;
83
		return;
83
		return;
84
	}
84
	}
85
	if (t_html) && (!t_body) return;
85
	if (t_html) && (!t_body) return;
86
	
86
	
87
	if (line)
87
	if (line)
88
	{
88
	{
89
		start_x = stolbec * list.font_w + body_magrin + list.x;
89
		start_x = stolbec * list.font_w + body_magrin + list.x;
90
		stolbec_len = strlen(#line) * zoom;
90
		stolbec_len = strlen(#line) * zoom;
91
		line_length = stolbec_len * list.font_w;
91
		line_length = stolbec_len * list.font_w;
92
 
92
 
93
		WriteBufText(start_x, draw_y, list.font_type, text_colors[text_color_index], #line, buf_data);
93
		WriteBufText(start_x, draw_y, list.font_type, text_colors[text_color_index], #line, buf_data);
94
		if (style.b) WriteBufText(start_x+1, draw_y, list.font_type, text_colors[text_color_index], #line, buf_data);
94
		if (style.b) WriteBufText(start_x+1, draw_y, list.font_type, text_colors[text_color_index], #line, buf_data);
95
		if (style.s) DrawBuf.DrawBar(start_x, list.item_h / 2 - zoom + draw_y, line_length, zoom, text_colors[text_color_index]);
95
		if (style.s) DrawBuf.DrawBar(start_x, list.item_h / 2 - zoom + draw_y, line_length, zoom, text_colors[text_color_index]);
96
		if (style.u) DrawBuf.DrawBar(start_x, list.item_h - zoom - zoom + draw_y, line_length, zoom, text_colors[text_color_index]);
96
		if (style.u) DrawBuf.DrawBar(start_x, list.item_h - zoom - zoom + draw_y, line_length, zoom, text_colors[text_color_index]);
97
		if (link) {
97
		if (link) {
98
			DrawBuf.DrawBar(start_x, draw_y + list.item_h - calc(zoom*2), line_length, zoom, text_colors[text_color_index]);
98
			DrawBuf.DrawBar(start_x, draw_y + list.item_h - calc(zoom*2), line_length, zoom, text_colors[text_color_index]);
99
			PageLinks.AddText(start_x, draw_y + list.y, line_length, list.item_h - calc(zoom*2), UNDERLINE, zoom); //TODO: set bigger underline_h for style.h
99
			PageLinks.AddText(start_x, draw_y + list.y, line_length, list.item_h - calc(zoom*2), UNDERLINE, zoom); //TODO: set bigger underline_h for style.h
100
		}
100
		}
101
		stolbec += stolbec_len;
101
		stolbec += stolbec_len;
102
	}
102
	}
103
}
103
}
104
//============================================================================================
104
//============================================================================================
105
void TWebBrowser::LoadInternalPage(dword bufpos, in_filesize){
105
void TWebBrowser::LoadInternalPage(dword bufpos, in_filesize){
106
	bufsize = in_filesize;
106
	bufsize = in_filesize;
107
	bufpointer = bufpos;
107
	bufpointer = bufpos;
108
	Prepare();
108
	Prepare();
109
}
109
}
110
//============================================================================================
110
//============================================================================================
111
void TWebBrowser::Prepare(){
111
void TWebBrowser::Prepare(){
112
	word bukva[2];
112
	word bukva[2];
113
	dword j;
113
	dword j;
114
	byte ignor_param;
114
	byte ignor_param;
115
	dword bufpos;
115
	dword bufpos;
116
	dword line_len;	
116
	dword line_len;	
117
	style.b = style.u = style.s = style.h = style.blq = t_html = t_body =
117
	style.b = style.u = style.s = style.h = style.blq = t_html = t_body =
118
	style.li = link = ignor_text = text_color_index = text_colors[0] = style.li_tab = 0;
118
	style.li = link = ignor_text = text_color_index = text_colors[0] = style.li_tab = 0;
119
	style.align = ALIGN_LEFT;
119
	style.align = ALIGN_LEFT;
120
	link_color_inactive = 0x0000FF;
120
	link_color_inactive = 0x0000FF;
121
	link_color_active = 0xFF0000;
121
	link_color_active = 0xFF0000;
122
	bg_color = 0xFFFFFF;
122
	bg_color = 0xFFFFFF;
123
	DrawBuf.Fill(bg_color);
123
	DrawBuf.Fill(bg_color);
124
	PageLinks.Clear();
124
	PageLinks.Clear();
125
	strcpy(#header, #version);
125
	strcpy(#header, #version);
126
	draw_y = body_magrin;
126
	draw_y = body_magrin;
127
	stolbec = 0;
127
	stolbec = 0;
128
	line = 0;
128
	line = 0;
129
	zoom = 1;
129
	zoom = 1;
130
	//for plaint text use CP866 for other UTF
130
	//for plaint text use CP866 for other UTF
131
	if (strstri(bufpointer, "html")!=-1) 
131
	if (strstri(bufpointer, "html")!=-1) 
132
	{
132
	{
133
		debugln(" found");
133
		debugln(" found");
134
		style.pre = false;
134
		style.pre = false;
135
		cur_encoding = CH_NULL;
135
		cur_encoding = CH_NULL;
136
	}
136
	}
137
	else
137
	else
138
	{
138
	{
139
		debugln("no ");
139
		debugln("no ");
140
		style.pre = true;
140
		style.pre = true;
141
		cur_encoding = CH_NULL;
141
		cur_encoding = CH_NULL;
142
	}
142
	}
143
	for (bufpos=bufpointer ; (bufpos < bufpointer+bufsize) && (ESBYTE[bufpos]!=0) ; bufpos++;)
143
	for (bufpos=bufpointer ; (bufpos < bufpointer+bufsize) && (ESBYTE[bufpos]!=0) ; bufpos++;)
144
	{
144
	{
145
		if (ignor_text) && (ESBYTE[bufpos]!='<') continue;
145
		if (ignor_text) && (ESBYTE[bufpos]!='<') continue;
146
		bukva = ESBYTE[bufpos];
146
		bukva = ESBYTE[bufpos];
147
		switch (bukva)
147
		switch (bukva)
148
		{
148
		{
149
		case 0x0a:
149
		case 0x0a:
150
			if (style.pre)
150
			if (style.pre)
151
			{
151
			{
152
				DrawStyle();
152
				DrawStyle();
153
				line = NULL;
153
				line = NULL;
154
				NewLine();
154
				NewLine();
155
				break;
155
				break;
156
			}
156
			}
157
			goto DEFAULT_MARK;
157
			goto DEFAULT_MARK;
158
		case '\9':
158
		case '\9':
159
			if (style.pre) //otherwise go to 0x0d	
159
			if (style.pre) //otherwise go to 0x0d	
160
			{
160
			{
161
				tab_len = strlen(#line) % 4;
161
				tab_len = strlen(#line) % 4;
162
				if (!tab_len) tab_len = 4;
162
				if (!tab_len) tab_len = 4;
163
				for (j=0; j
163
				for (j=0; j
164
				break;
164
				break;
165
			}
165
			}
166
			goto DEFAULT_MARK;
166
			goto DEFAULT_MARK;
167
		case '&': //  and so on
167
		case '&': //  and so on
168
			bufpos++;
168
			bufpos++;
169
			tag=0;
169
			tag=0;
170
			for (j=0; (ESBYTE[bufpos]<>';') && (j<7);   j++, bufpos++;)
170
			for (j=0; (ESBYTE[bufpos]<>';') && (j<7);   j++, bufpos++;)
171
			{
171
			{
172
				bukva = ESBYTE[bufpos];
172
				bukva = ESBYTE[bufpos];
173
				chrcat(#tag, bukva);
173
				chrcat(#tag, bukva);
174
			}
174
			}
175
			if (bukva = GetUnicodeSymbol()) goto DEFAULT_MARK;
175
			if (bukva = GetUnicodeSymbol()) goto DEFAULT_MARK;
176
			break;
176
			break;
177
		case '<':
177
		case '<':
178
			bufpos++;
178
			bufpos++;
179
			if (!strncmp(bufpos,"!--",3))
179
			if (!strncmp(bufpos,"!--",3))
180
			{
180
			{
181
				bufpos+=3;
181
				bufpos+=3;
182
				while (strncmp(bufpos,"-->",3)!=0) && (bufpos < bufpointer + bufsize)
182
				while (strncmp(bufpos,"-->",3)!=0) && (bufpos < bufpointer + bufsize)
183
				{
183
				{
184
					bufpos++;
184
					bufpos++;
185
				}
185
				}
186
				bufpos+=3;
186
				bufpos+=3;
187
				break;
187
				break;
188
			}
188
			}
189
			tag = attr = tagparam = ignor_param = NULL;
189
			tag = attr = tagparam = ignor_param = NULL;
190
			while (ESBYTE[bufpos] !='>') && (bufpos < bufpointer + bufsize) //ïîëó÷àåì òåã è åãî ïàðàìåòðû
190
			while (ESBYTE[bufpos] !='>') && (bufpos < bufpointer + bufsize) //ïîëó÷àåì òåã è åãî ïàðàìåòðû
191
			{
191
			{
192
				bukva = ESBYTE[bufpos];
192
				bukva = ESBYTE[bufpos];
193
				if (bukva == '\9') || (bukva == '\x0a') || (bukva == '\x0d') bukva = ' ';
193
				if (bukva == '\9') || (bukva == '\x0a') || (bukva == '\x0d') bukva = ' ';
194
				if (!ignor_param) && (bukva <>' ')
194
				if (!ignor_param) && (bukva <>' ')
195
				{
195
				{
196
					if (strlen(#tag)+1
196
					if (strlen(#tag)+1
197
				}
197
				}
198
				else
198
				else
199
				{
199
				{
200
					ignor_param = true;
200
					ignor_param = true;
201
					if (!ignor_text) && (strlen(#tagparam)+1
201
					if (!ignor_text) && (strlen(#tagparam)+1
202
				}
202
				}
203
				bufpos++;
203
				bufpos++;
204
			}
204
			}
205
			strlwr(#tag);
205
			strlwr(#tag);
206
 
206
 
207
			if (tag[strlen(#tag)-1]=='/') tag[strlen(#tag)-1]=NULL; //for br/
207
			if (tag[strlen(#tag)-1]=='/') tag[strlen(#tag)-1]=NULL; //for br/
208
			if (tagparam) GetNextParam();
208
			if (tagparam) GetNextParam();
209
			Perenos();
209
			Perenos();
210
			DrawStyle();
210
			DrawStyle();
211
			line = NULL;
211
			line = NULL;
212
			if (tag) SetStyle();
212
			if (tag) SetStyle();
213
			strlcpy(#oldtag, #tag, sizeof(oldtag));
213
			strlcpy(#oldtag, #tag, sizeof(oldtag));
214
			tag = attr = tagparam = ignor_param = NULL;
214
			tag = attr = tagparam = ignor_param = NULL;
215
			break;
215
			break;
216
		default:
216
		default:
217
			DEFAULT_MARK:
217
			DEFAULT_MARK:
218
			if (bukva<=15) bukva=' ';
218
			if (bukva<=15) bukva=' ';
219
			line_len = strlen(#line);
219
			line_len = strlen(#line);
220
			if (!style.pre) && (bukva == ' ')
220
			if (!style.pre) && (bukva == ' ')
221
			{
221
			{
222
				if (line[line_len-1]==' ') break; //no double spaces
222
				if (line[line_len-1]==' ') break; //no double spaces
223
				if (!stolbec) && (!line) break; //no paces at the beginning of the line
223
				if (!stolbec) && (!line) break; //no paces at the beginning of the line
224
			}
224
			}
225
			if (line_len < sizeof(line)) chrcat(#line, bukva);
225
			if (line_len < sizeof(line)) chrcat(#line, bukva);
226
			Perenos();
226
			Perenos();
227
		}
227
		}
228
	}
228
	}
229
	DrawStyle();
229
	DrawStyle();
230
	NewLine();
230
	NewLine();
231
	if (list.first == 0) list.count = draw_y;
231
	if (list.first == 0) list.count = draw_y;
232
	DrawPage();
232
	DrawPage();
233
}
233
}
234
//============================================================================================
234
//============================================================================================
235
void TWebBrowser::Perenos()
235
void TWebBrowser::Perenos()
236
{
236
{
237
	int perenos_num;
237
	int perenos_num;
238
	char new_line_text[4096];
238
	char new_line_text[4096];
239
	if (strlen(#line)*zoom + stolbec < list.column_max) return;
239
	if (strlen(#line)*zoom + stolbec < list.column_max) return;
240
	perenos_num = strrchr(#line, ' ');
240
	perenos_num = strrchr(#line, ' ');
241
	if (!perenos_num) && (strlen(#line)*zoom>list.column_max) perenos_num=list.column_max/zoom;
241
	if (!perenos_num) && (strlen(#line)*zoom>list.column_max) perenos_num=list.column_max/zoom;
242
	strcpy(#new_line_text, #line + perenos_num);
242
	strcpy(#new_line_text, #line + perenos_num);
243
	line[perenos_num] = 0x00;
243
	line[perenos_num] = 0x00;
244
	DrawStyle();
244
	DrawStyle();
245
	strcpy(#line, #new_line_text);
245
	strcpy(#line, #new_line_text);
246
	NewLine();
246
	NewLine();
247
}
247
}
248
//============================================================================================
248
//============================================================================================
249
void TWebBrowser::SetStyle() {
249
void TWebBrowser::SetStyle() {
250
	int left1 = body_magrin + list.x;
250
	int left1 = body_magrin + list.x;
251
	byte opened;
251
	byte opened;
252
	byte meta_encoding;
252
	byte meta_encoding;
253
	if (tag[0] == '/') 
253
	if (tag[0] == '/') 
254
	{
254
	{
255
		 opened = 0;
255
		 opened = 0;
256
		 strcpy(#tag, #tag+1);
256
		 strcpy(#tag, #tag+1);
257
	}
257
	}
258
	else opened = 1;
258
	else opened = 1;
259
	if (istag("html")) {
259
	if (istag("html")) {
260
		t_html = opened;
260
		t_html = opened;
261
		return;
261
		return;
262
	}
262
	}
263
	if (istag("script")) || (istag("style")) || (istag("binary")) || (istag("select")) { ignor_text = opened; return; }
263
	if (istag("script")) || (istag("style")) || (istag("binary")) || (istag("select")) { ignor_text = opened; return; }
264
	if (istag("form")) if (!opened) ignor_text = false;
264
	if (istag("form")) if (!opened) ignor_text = false;
265
	if(istag("title")) {
265
	if(istag("title")) {
266
		if (opened) header=NULL;
266
		if (opened) header=NULL;
267
		return;
267
		return;
268
	}
268
	}
269
	if (ignor_text) return;
269
	if (ignor_text) return;
270
	
270
	
271
	IF(istag("q"))
271
	IF(istag("q"))
272
	{
272
	{
273
		if (opened)	strcat(#line, " \"");
273
		if (opened)	strcat(#line, " \"");
274
		if (!opened) strcat(#line, "\" ");
274
		if (!opened) strcat(#line, "\" ");
275
		return;
275
		return;
276
	}
276
	}
277
	//if (isattr("id=")) || (isattr("name=")) { //very bad: if the tag is not the last it wound work
277
	//if (isattr("id=")) || (isattr("name=")) { //very bad: if the tag is not the last it wound work
278
		//add anchor
278
		//add anchor
279
	//}	
279
	//}	
280
	if (istag("body")) {
280
	if (istag("body")) {
281
		t_body = opened;
281
		t_body = opened;
282
		do{
282
		do{
283
			if (isattr("link=")) link_color_inactive = GetColor(#val);
283
			if (isattr("link=")) link_color_inactive = GetColor(#val);
284
			if (isattr("alink=")) link_color_active = GetColor(#val);
284
			if (isattr("alink=")) link_color_active = GetColor(#val);
285
			if (isattr("text=")) text_colors[0]=GetColor(#val);
285
			if (isattr("text=")) text_colors[0]=GetColor(#val);
286
			if (isattr("bgcolor="))
286
			if (isattr("bgcolor="))
287
			{
287
			{
288
				bg_color = GetColor(#val);
288
				bg_color = GetColor(#val);
289
				DrawBuf.Fill(bg_color);
289
				DrawBuf.Fill(bg_color);
290
			}
290
			}
291
		} while(GetNextParam());
291
		} while(GetNextParam());
292
		if (opened) && (cur_encoding==CH_NULL) {
292
		if (opened) && (cur_encoding==CH_NULL) {
293
			cur_encoding = CH_UTF8; 
293
			cur_encoding = CH_UTF8; 
294
			debugln("Document has no information about encoding, UTF will be used");
294
			debugln("Document has no information about encoding, UTF will be used");
295
		}
295
		}
296
		if (opened) {
296
		if (opened) {
297
			ChangeCharset(charsets[cur_encoding], "CP866", #header);
297
			ChangeCharset(charsets[cur_encoding], "CP866", #header);
298
			sprintf(#header, "%s - %s", #header, #version);
298
			sprintf(#header, "%s - %s", #header, #version);
299
			DrawTitle(#header);
299
			DrawTitle(#header);
300
		}
300
		}
301
		return;
301
		return;
302
	}
302
	}
303
	if (istag("a")) {
303
	if (istag("a")) {
304
		if (opened)
304
		if (opened)
305
		{
305
		{
306
			if (link) IF(text_color_index > 0) text_color_index--; //åñëè ïðåäûäóùèé òåã à íå áûë çàêðûò
306
			if (link) IF(text_color_index > 0) text_color_index--; //åñëè ïðåäûäóùèé òåã à íå áûë çàêðûò
307
			do{
307
			do{
308
				if (isattr("href=")) && (!strstr(#val,"javascript:"))
308
				if (isattr("href=")) && (!strstr(#val,"javascript:"))
309
				{
309
				{
310
					text_color_index++;
310
					text_color_index++;
311
					text_colors[text_color_index] = text_colors[text_color_index-1];
311
					text_colors[text_color_index] = text_colors[text_color_index-1];
312
					link = 1;
312
					link = 1;
313
					text_colors[text_color_index] = link_color_inactive;
313
					text_colors[text_color_index] = link_color_inactive;
314
					PageLinks.AddLink(#val);
314
					PageLinks.AddLink(#val);
315
				}
315
				}
316
			} while(GetNextParam());
316
			} while(GetNextParam());
317
		}
317
		}
318
		else {
318
		else {
319
			link = 0;
319
			link = 0;
320
			IF(text_color_index > 0) text_color_index--;
320
			IF(text_color_index > 0) text_color_index--;
321
		}
321
		}
322
		return;
322
		return;
323
	}
323
	}
324
	if (istag("font")) {
324
	if (istag("font")) {
325
		if (opened)
325
		if (opened)
326
		{
326
		{
327
			text_color_index++;
327
			text_color_index++;
328
			text_colors[text_color_index] = text_colors[text_color_index-1];
328
			text_colors[text_color_index] = text_colors[text_color_index-1];
329
			do{
329
			do{
330
				if (isattr("color=")) text_colors[text_color_index] = GetColor(#val);
330
				if (isattr("color=")) text_colors[text_color_index] = GetColor(#val);
331
			} while(GetNextParam());
331
			} while(GetNextParam());
332
		}
332
		}
333
		else if (text_color_index > 0) text_color_index--;
333
		else if (text_color_index > 0) text_color_index--;
334
		return;
334
		return;
335
	}
335
	}
336
	if (istag("div")) || (istag("header")) || (istag("article")) || (istag("footer")) {
336
	if (istag("div")) || (istag("header")) || (istag("article")) || (istag("footer")) {
337
		IF(oldtag[0] != 'h') NewLine();
337
		IF(oldtag[0] != 'h') NewLine();
338
		return;
338
		return;
339
	}
339
	}
340
	if (istag("p")) {
340
	if (istag("p")) {
341
		IF(oldtag[0] == 'h') return;
341
		IF(oldtag[0] == 'h') return;
342
		NewLine();
342
		NewLine();
343
		IF(opened) NewLine();
343
		IF(opened) NewLine();
344
		return;
344
		return;
345
	}
345
	}
346
	if (istag("br")) { NewLine(); return; }
346
	if (istag("br")) { NewLine(); return; }
347
	if (istag("tr")) { if (opened) NewLine(); return; }
347
	if (istag("tr")) { if (opened) NewLine(); return; }
348
	if (istag("b")) || (istag("strong")) || (istag("big")) { style.b = opened; return; }
348
	if (istag("b")) || (istag("strong")) || (istag("big")) { style.b = opened; return; }
349
	if (istag("u")) || (istag("ins")) { style.u=opened; return;}
349
	if (istag("u")) || (istag("ins")) { style.u=opened; return;}
350
	if (istag("s")) || (istag("strike")) || (istag("del")) { style.s=opened; return; }
350
	if (istag("s")) || (istag("strike")) || (istag("del")) { style.s=opened; return; }
351
	if (istag("dd")) { stolbec += 5; return; }
351
	if (istag("dd")) { stolbec += 5; return; }
352
	if (istag("blockquote")) { style.blq = opened; return; }
352
	if (istag("blockquote")) { style.blq = opened; return; }
353
	if (istag("pre")) || (istag("code")) { style.pre = opened; return; }
353
	if (istag("pre")) || (istag("code")) { style.pre = opened; return; }
354
	if (istag("img")) { ImgCache.Images( left1, draw_y, WB1.list.w); return; }
354
	if (istag("img")) { ImgCache.Images( left1, draw_y, WB1.list.w); return; }
355
	if (istag("h1")) || (istag("h2")) || (istag("h3")) || (istag("h4")) || (istag("caption")) {
355
	if (istag("h1")) || (istag("h2")) || (istag("h3")) || (istag("h4")) || (istag("caption")) {
356
		style.h = opened;
356
		style.h = opened;
357
		if (opened)
357
		if (opened)
358
		{
358
		{
359
			NewLine();
359
			NewLine();
360
			draw_y += 10;
360
			draw_y += 10;
361
			WB1.zoom=2;
361
			WB1.zoom=2;
362
			WB1.list.font_type |= 10011001b;
362
			WB1.list.font_type |= 10011001b;
363
			if (isattr("align=")) && (isval("center")) style.align = ALIGN_CENTER;
363
			if (isattr("align=")) && (isval("center")) style.align = ALIGN_CENTER;
364
			if (isattr("align=")) && (isval("right")) style.align = ALIGN_RIGHT;
364
			if (isattr("align=")) && (isval("right")) style.align = ALIGN_RIGHT;
365
			list.item_h = basic_line_h * 2;
365
			list.item_h = basic_line_h * 2;
366
		}
366
		}
367
		else
367
		else
368
		{
368
		{
369
			NewLine();
369
			NewLine();
370
			WB1.zoom=1;
370
			WB1.zoom=1;
371
			WB1.list.font_type = 10011000b;
371
			WB1.list.font_type = 10011000b;
372
			style.align = ALIGN_LEFT;
372
			style.align = ALIGN_LEFT;
373
			list.item_h = basic_line_h;
373
			list.item_h = basic_line_h;
374
		}
374
		}
375
		return;
375
		return;
376
	}
376
	}
377
	if (istag("dt")) {
377
	if (istag("dt")) {
378
		style.li = opened;
378
		style.li = opened;
379
		if (opened) NewLine();
379
		if (opened) NewLine();
380
		return;
380
		return;
381
	}
381
	}
382
	if (istag("li")) || (istag("dt"))
382
	if (istag("li")) || (istag("dt"))
383
	{
383
	{
384
		style.li = opened;
384
		style.li = opened;
385
		if (opened)
385
		if (opened)
386
		{
386
		{
387
			NewLine();
387
			NewLine();
388
			strcpy(#line, "\31 \0");
388
			strcpy(#line, "\31 \0");
389
		}
389
		}
390
		return;
390
		return;
391
	}
391
	}
392
	if (istag("ul")) || (istag("ol")) {
392
	if (istag("ul")) || (istag("ol")) {
393
		if (!opened)
393
		if (!opened)
394
		{
394
		{
395
			style.li = opened;
395
			style.li = opened;
396
			style.li_tab--;
396
			style.li_tab--;
397
			NewLine();
397
			NewLine();
398
		} 
398
		} 
399
		else style.li_tab++;
399
		else style.li_tab++;
400
	}
400
	}
401
	if (istag("hr")) {
401
	if (istag("hr")) {
402
		if (isattr("color=")) EDI = GetColor(#val); else EDI = 0x999999;
402
		if (isattr("color=")) EDI = GetColor(#val); else EDI = 0x999999;
403
		$push edi;
403
		$push edi;
404
		NewLine();
404
		NewLine();
405
		$pop edi;
405
		$pop edi;
406
		DrawBuf.DrawBar(5, draw_y - 1, list.w-10, 1, EDI);
406
		DrawBuf.DrawBar(5, draw_y - 1, list.w-10, 1, EDI);
407
		NewLine();
407
		NewLine();
408
		return;
408
		return;
409
	}
409
	}
410
	if (istag("meta")) || (istag("?xml")) {
410
	if (istag("meta")) || (istag("?xml")) {
411
		meta_encoding = CH_NULL;
411
		meta_encoding = CH_NULL;
412
		do{
412
		do{
413
			if (isattr("charset=")) || (isattr("content=")) || (isattr("encoding="))
413
			if (isattr("charset=")) || (isattr("content=")) || (isattr("encoding="))
414
			{
414
			{
415
				strcpy(#val, #val[strrchr(#val, '=')]); //search in content=
415
				strcpy(#val, #val[strrchr(#val, '=')]); //search in content=
416
				strlwr(#val);
416
				strlwr(#val);
417
				if      (isval("utf-8"))        || (isval("utf8"))        meta_encoding = CH_UTF8;
417
				if      (isval("utf-8"))        || (isval("utf8"))        meta_encoding = CH_UTF8;
418
				else if (isval("koi8-r"))       || (isval("koi8-u"))      meta_encoding = CH_KOI8;
418
				else if (isval("koi8-r"))       || (isval("koi8-u"))      meta_encoding = CH_KOI8;
419
				else if (isval("windows-1251")) || (isval("windows1251")) meta_encoding = CH_CP1251;
419
				else if (isval("windows-1251")) || (isval("windows1251")) meta_encoding = CH_CP1251;
420
				else if (isval("iso-8859-5"))   || (isval("iso8859-5"))   meta_encoding = CH_ISO8859_5;
420
				else if (isval("iso-8859-5"))   || (isval("iso8859-5"))   meta_encoding = CH_ISO8859_5;
421
				else if (isval("dos"))          || (isval("cp-866"))      meta_encoding = CH_CP866;
421
				else if (isval("dos"))          || (isval("cp-866"))      meta_encoding = CH_CP866;
422
			}
422
			}
423
		} while(GetNextParam());
423
		} while(GetNextParam());
424
		if (meta_encoding!=CH_NULL) BufEncode(meta_encoding);
424
		if (meta_encoding!=CH_NULL) BufEncode(meta_encoding);
425
		return;
425
		return;
426
	}
426
	}
427
}
427
}
428
 
428
 
429
void TWebBrowser::BufEncode(dword set_new_encoding)
429
void TWebBrowser::BufEncode(dword set_new_encoding)
430
{
430
{
431
	if (cur_encoding == set_new_encoding) return;
431
	if (cur_encoding == set_new_encoding) return;
432
	if (o_bufpointer==0)
432
	if (o_bufpointer==0)
433
	{
433
	{
434
		o_bufpointer = malloc(bufsize);
434
		o_bufpointer = malloc(bufsize);
435
		strcpy(o_bufpointer, bufpointer);
435
		strcpy(o_bufpointer, bufpointer);
436
	}
436
	}
437
	else
437
	else
438
	{
438
	{
439
		strcpy(bufpointer, o_bufpointer);
439
		strcpy(bufpointer, o_bufpointer);
440
	}
440
	}
441
	debugval("cur_encoding    ", cur_encoding);
441
	debugval("cur_encoding    ", cur_encoding);
442
	debugval("set_new_encoding", set_new_encoding);
442
	debugval("set_new_encoding", set_new_encoding);
443
	cur_encoding = set_new_encoding;
443
	cur_encoding = set_new_encoding;
444
	bufpointer = ChangeCharset(charsets[cur_encoding], "CP866", bufpointer);
444
	bufpointer = ChangeCharset(charsets[cur_encoding], "CP866", bufpointer);
445
}
445
}
446
//============================================================================================
446
//============================================================================================
447
void TWebBrowser::DrawScroller()
447
void TWebBrowser::DrawScroller()
448
{
448
{
449
	scroll_wv.max_area = list.count;
449
	scroll_wv.max_area = list.count;
450
	scroll_wv.cur_area = list.visible;
450
	scroll_wv.cur_area = list.visible;
451
	scroll_wv.position = list.first;
451
	scroll_wv.position = list.first;
452
	scroll_wv.all_redraw = 0;
452
	scroll_wv.all_redraw = 0;
453
	scroll_wv.start_x = list.x + list.w;
453
	scroll_wv.start_x = list.x + list.w;
454
	scroll_wv.start_y = list.y;
454
	scroll_wv.start_y = list.y;
455
	scroll_wv.size_y = list.h;
455
	scroll_wv.size_y = list.h;
456
	scroll_wv.start_x = list.w + list.x;
456
	scrollbar_v_draw(#scroll_wv);
457
	scrollbar_v_draw(#scroll_wv);
-
 
458
}
457
}
459
//============================================================================================
458
//============================================================================================
460
void TWebBrowser::NewLine()
459
void TWebBrowser::NewLine()
461
{
460
{
462
	dword onleft, ontop;
461
	dword onleft, ontop;
463
 
462
 
464
	if (!stolbec) && (draw_y==body_magrin) return;
463
	if (!stolbec) && (draw_y==body_magrin) return;
465
 
464
 
466
	onleft = list.x + body_magrin;
465
	onleft = list.x + body_magrin;
467
	ontop = draw_y + list.y;
466
	ontop = draw_y + list.y;
468
	if (t_html) && (!t_body) return;
467
	if (t_html) && (!t_body) return;
469
	draw_y += list.item_h;
468
	draw_y += list.item_h;
470
	if (style.blq) stolbec = 6; else stolbec = 0;
469
	if (style.blq) stolbec = 6; else stolbec = 0;
471
	if (style.li) stolbec = style.li_tab * 5;
470
	if (style.li) stolbec = style.li_tab * 5;
472
}
471
}
473
//============================================================================================
472
//============================================================================================
474
bool istag(dword text) { if (!strcmp(#tag,text)) return true; else return false; }
473
bool istag(dword text) { if (!strcmp(#tag,text)) return true; else return false; }
475
bool isattr(dword text) { if (!strcmp(#attr,text)) return true; else return false; }
474
bool isattr(dword text) { if (!strcmp(#attr,text)) return true; else return false; }
476
bool isval(dword text) { if (!strcmp(#val,text)) return true; else return false; }
475
bool isval(dword text) { if (!strcmp(#val,text)) return true; else return false; }
477
//============================================================================================
476
//============================================================================================
478
void TWebBrowser::DrawPage()
477
void TWebBrowser::DrawPage()
479
{
478
{
480
	PutPaletteImage(list.first * DrawBuf.bufw * 4 + buf_data+8, DrawBuf.bufw, list.h, DrawBuf.bufx, DrawBuf.bufy, 32, 0);	
479
	PutPaletteImage(list.first * DrawBuf.bufw * 4 + buf_data+8, DrawBuf.bufw, list.h, DrawBuf.bufx, DrawBuf.bufy, 32, 0);	
481
	DrawScroller();
480
	DrawScroller();
482
}
481
}
483
>
482
>