Subversion Repositories Kolibri OS

Rev

Rev 7750 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7750 Rev 7752
Line -... Line 1...
-
 
1
#include "..\TWB\colors.h"
-
 
2
#include "..\TWB\anchors.h"
-
 
3
#include "..\TWB\parce_tag.h"
-
 
4
#include "..\TWB\absolute_url.h"
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};
5
char line[500];
2
 
6
#include "..\TWB\unicode_tags.h"
Line 3... Line 7...
3
enum { ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT};
7
 
Line 4... Line 8...
4
 
8
enum { ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT};
5
struct _style {
9
 
Line 11... Line 15...
11
	li_tab,
15
	li,
12
	button,
16
	li_tab,
13
	image,
17
	button,
14
	align;
18
	image,
15
dword 
19
	align;
16
	bg_color;
-
 
17
};
20
	dword bg_color;
18
 
21
};
Line 19... Line 22...
19
struct TWebBrowser {
22
 
20
	llist list;
23
struct TWebBrowser {
21
	_style style;
24
	llist list;
22
	DrawBufer DrawBuf;
25
	_style style;
-
 
26
	DrawBufer DrawBuf;
23
	int zoom;
27
	dword draw_y, stolbec;
24
	bool opened; //is this a "start tag" or "end tag"
28
	int zoom;
25
	void SetPageDefaults();
29
	dword o_bufpointer;
-
 
30
	void SetPageDefaults();
26
	void Prepare();
31
	void AddCharToTheLine();
27
	void SetStyle();
32
	void ParseHtml();
28
	void DrawStyle();
33
	void SetStyle();
29
	void DrawPage();
34
	void DrawStyle();
30
	void DrawScroller();
35
	void DrawPage();
31
	void NewLine();
36
	void DrawScroller();
32
	bool CheckForLineBreak();
37
	void NewLine();
33
	void BufEncode();
38
	bool CheckForLineBreak();
34
} WB1;
39
	void BufEncode();
Line -... Line 40...
-
 
40
} WB1;
-
 
41
 
-
 
42
dword link_color_inactive;
Line 35... Line 43...
35
 
43
dword link_color_active;
36
 
44
dword page_bg;
37
bool 	
45
 
38
	link,
46
bool 	
39
	cur_encoding,
47
	link,
Line -... Line 48...
-
 
48
	cur_encoding,
-
 
49
	t_html,
-
 
50
	t_body;
40
	t_html,
51
 
41
	t_body;
-
 
42
 
52
#include "..\TWB\img_cache.h"
Line 43... Line -...
43
dword bufpointer=0;
-
 
44
dword o_bufpointer=0;
-
 
45
dword bufsize=0;
-
 
46
 
-
 
47
dword text_colors[300];
-
 
48
dword text_color_index;
-
 
49
dword link_color_inactive;
-
 
50
dword link_color_active;
-
 
51
dword page_bg;
-
 
52
 
-
 
53
int draw_y;
53
#include "..\TWB\links.h"
54
int stolbec;
54
 
Line 55... Line -...
55
int tab_len;
-
 
56
 
55
dword bufpointer=0;
57
int body_magrin=5;
-
 
58
int basic_line_h=22;
-
 
59
 
-
 
60
char URL[10000];
56
dword bufsize=0;
61
char header[2048];
-
 
62
char line[500];
-
 
63
char tagparam[10000];
-
 
64
char tag[100];
-
 
65
char oldtag[100];
-
 
66
char attr[1200];
-
 
67
char val[4096];
-
 
68
 
-
 
69
#include "..\TWB\absolute_url.h"
-
 
70
#include "..\TWB\links.h"
-
 
Line -... Line 57...
-
 
57
 
Line 71... Line 58...
71
#include "..\TWB\anchors.h"
58
int body_magrin=6;
72
#include "..\TWB\colors.h"
59
int basic_line_h=22;
73
#include "..\TWB\unicode_tags.h"
60
 
74
#include "..\TWB\img_cache.h"
61
char header[150];
Line 75... Line 62...
75
#include "..\TWB\parce_tag.h"
62
char oldtag[100];
76
 
63
 
77
 
64
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};
78
//============================================================================================
65
 
79
void TWebBrowser::DrawStyle()
66
//============================================================================================
80
{
67
void TWebBrowser::DrawStyle()
81
	dword start_x, line_length, stolbec_len;
68
{
Line 136... Line 123...
136
	page_bg = 0xFFFFFF;
123
	link_color_active = 0xFF0000;
137
	style.bg_color = page_bg;
124
	page_bg = 0xFFFFFF;
138
	DrawBuf.Fill(0, page_bg);
125
	style.bg_color = page_bg;
139
	PageLinks.Clear();
126
	DrawBuf.Fill(0, page_bg);
140
	strcpy(#header, #version);
127
	PageLinks.Clear();
-
 
128
	anchors.clear();
141
	cur_encoding = CH_NULL;
129
	strncpy(#header, #version, sizeof(header)-1);
142
	draw_y = body_magrin;
130
	cur_encoding = CH_NULL;
143
	stolbec = 0;
131
	draw_y = body_magrin;
144
	line = 0;
132
	stolbec = 0;
145
	zoom = 1;	
133
	line = 0;
146
}
134
	zoom = 1;
-
 
135
	if (o_bufpointer) free(o_bufpointer);
-
 
136
	o_bufpointer = 0;
147
//============================================================================================
137
}
148
void TWebBrowser::Prepare(){
138
//============================================================================================
-
 
139
void TWebBrowser::AddCharToTheLine(unsigned char _char)
-
 
140
{
-
 
141
	dword line_len;
-
 
142
	if (_char<=15) _char=' ';
-
 
143
	line_len = strlen(#line);
-
 
144
	if (!style.pre) && (_char == ' ')
-
 
145
	{
-
 
146
		if (line[line_len-1]==' ') return; //no double spaces
-
 
147
		if (!stolbec) && (!line) return; //no paces at the beginning of the line
-
 
148
	}
-
 
149
	if (line_len < sizeof(line)) chrcat(#line, _char);
-
 
150
	CheckForLineBreak();
-
 
151
}
-
 
152
//============================================================================================
149
	word bukva[2];
153
void TWebBrowser::ParseHtml(){
150
	dword j;
154
	word bukva[2];
-
 
155
	char unicode_symbol[10];
-
 
156
	dword unicode_symbol_result;
151
	bool ignor_param;
157
	dword j;
152
	dword bufpos;
158
	bool ignor_param=false;
-
 
159
	int tab_len;
153
	dword line_len;
160
	dword bufpos;
154
	SetPageDefaults();
-
 
155
	if (strstri(bufpointer, "
161
	SetPageDefaults();
156
		t_body = true;
162
	if (strstri(bufpointer, "
157
		if (strstri(bufpointer, "
163
		t_body = true;
158
	} 
164
		if (strstri(bufpointer, "
159
	for (bufpos=bufpointer ; (bufpos < bufpointer+bufsize) && (ESBYTE[bufpos]!=0) ; bufpos++;)
165
	} 
Line 161... Line 167...
161
		bukva = ESBYTE[bufpos];
167
	{
162
		switch (bukva)
168
		bukva = ESBYTE[bufpos];
163
		{
169
		switch (bukva)
164
		case 0x0a:
170
		{
165
			if (style.pre)
171
		case 0x0a:
166
			{
172
			if (style.pre) {
167
				DrawStyle();
-
 
168
				NewLine();
173
				DrawStyle();
169
				break;
174
				NewLine();
170
			}
175
			} else {
-
 
176
				AddCharToTheLine(0x0a);
171
			goto DEFAULT_MARK;
177
			}
172
		case '\9':
-
 
173
			if (style.pre) //otherwise go to 0x0d	
-
 
174
			{
-
 
175
				tab_len = strlen(#line) % 4;
-
 
176
				if (!tab_len) tab_len = 4;
-
 
177
				for (j=0; j
-
 
178
				break;
-
 
179
			}
178
			break;
-
 
179
		case 0x09:
-
 
180
			if (style.pre) {
-
 
181
				tab_len = strlen(#line) + stolbec % 4;
-
 
182
				if (!tab_len) tab_len = 4; else tab_len = 4 - tab_len;
-
 
183
				for (j=0; j
-
 
184
			} else {
-
 
185
				AddCharToTheLine(0x09);
180
			goto DEFAULT_MARK;
186
			}
181
		case '&': //  and so on
187
			break;
182
			for (j=1, tag=0; (ESBYTE[bufpos+j]<>';') && (j<8); j++)
188
		case '&': //  and so on
183
			{
189
			for (j=1, unicode_symbol=0; (ESBYTE[bufpos+j]<>';') && (j<8); j++)
184
				bukva = ESBYTE[bufpos+j];
190
			{
185
				chrcat(#tag, bukva);
191
				bukva = ESBYTE[bufpos+j];
186
			}
192
				chrcat(#unicode_symbol, bukva);
187
			if (bukva = GetUnicodeSymbol(#tag)) {
193
			}
188
				bufpos += j;
194
			if (bukva = GetUnicodeSymbol(#unicode_symbol)) {
189
				CheckForLineBreak();
195
				bufpos += j;
190
			} else {
196
				CheckForLineBreak();
191
				bukva = '&';
197
			} else {
192
				goto DEFAULT_MARK;
198
				AddCharToTheLine('&');
193
			}
-
 
194
			break;
199
			}
195
		case '<':
200
			break;
196
			bufpos++;
201
		case '<':
197
			if (!strncmp(bufpos,"!--",3))
202
			bufpos++;
198
			{
203
			if (!strncmp(bufpos,"!--",3))
Line 203... Line 208...
203
				}
208
					bufpos++;
204
				bufpos+=2;
209
				}
205
				break;
210
				bufpos+=2;
206
			}
211
				break;
207
			tag = attr = tagparam = ignor_param = NULL;
212
			}
-
 
213
			tag.reset();
-
 
214
			if (ESBYTE[bufpos] == '/') {
-
 
215
				tag.opened = false;
-
 
216
				bufpos++;
-
 
217
			}
-
 
218
 
208
			while (ESBYTE[bufpos] !='>') && (bufpos < bufpointer + bufsize) //ïîëó÷àåì òåã è åãî ïàðàìåòðû
219
			ignor_param=false;
209
			{
220
			while (ESBYTE[bufpos] !='>') && (bufpos < bufpointer + bufsize) //ïîëó÷àåì òåã è åãî ïàðàìåòðû
210
				bukva = ESBYTE[bufpos];
221
			{
211
				if (bukva == '\9') || (bukva == '\x0a') || (bukva == '\x0d') bukva = ' ';
222
				bukva = ESBYTE[bufpos];
212
				if (!ignor_param) && (bukva <>' ')
223
				if (bukva == '\9') || (bukva == '\x0a') || (bukva == '\x0d') bukva = ' ';
213
				{
224
				if (!ignor_param) && (bukva <>' ')
214
					if (strlen(#tag)+1
225
				{
215
				}
226
					if (strlen(#tag.name)+1
216
				else
227
				}
217
				{
228
				else
218
					ignor_param = true;
229
				{
219
					if (strlen(#tagparam)+1
230
					ignor_param = true;
220
					//	chrncat(#tagparam, bukva, sizeof(tagparam)-1);
231
					if (strlen(#tag.params)+1
221
				}
232
					//	chrncat(#tag.params, bukva, sizeof(tag.params)-1);
222
				bufpos++;
233
				}
223
			}
234
				bufpos++;
224
			strlwr(#tag);
235
			}
225
 
236
			strlwr(#tag.name);
Line 226... Line 237...
226
			// ignore text inside the next tags
237
 
227
			if (istag("script")) || (istag("style")) || (istag("binary")) || (istag("select"))  { 
238
			// ignore text inside the next tags
228
				sprintf(#tagparam, "", #tag);
239
			if (tag.is("script")) || (tag.is("style")) || (tag.is("binary")) || (tag.is("select"))  { 
229
				j = strstri(bufpos, #tagparam);
240
				sprintf(#tag.params, "", #tag.name);
230
				if (j!=-1) {
-
 
231
					bufpos = j-1;
241
				j = strstri(bufpos, #tag.params);
232
				}
-
 
233
				tag = tagparam = NULL;
-
 
234
				break;
242
				if (j!=-1) bufpos = j-1;
235
			}
243
				break;
Line 236... Line 244...
236
 
244
			}
237
			if (tag[strlen(#tag)-1]=='/') tag[strlen(#tag)-1]=NULL; //for br/
245
 
Line 238... Line -...
238
			if (tagparam) GetNextParam();
-
 
239
 
-
 
240
			if (tag[0] == '/') 
-
 
241
			{
-
 
242
				 opened = 0;
-
 
243
				 strcpy(#tag, #tag+1);
-
 
244
			}
-
 
245
			else opened = 1;
246
			if (tag.name[strlen(#tag.name)-1]=='/') tag.name[strlen(#tag.name)-1]=NULL; //for br/ !!!!!!!!
246
 
247
			if (tag.params) tag.parse_params();
247
			if (tag) && (!istag("span")) && (!istag("i")) && (!istag("svg")) {
248
 
248
				CheckForLineBreak();
249
			if (tag.name) && (!tag.is("i")) && (!tag.is("svg")) {
249
				DrawStyle();
250
				CheckForLineBreak();
250
				if (tag) SetStyle();
251
				DrawStyle();
251
			}
-
 
252
			strlcpy(#oldtag, #tag, sizeof(oldtag)-1);
252
				if (tag.name) SetStyle();
253
			tag = attr = tagparam = ignor_param = NULL;
253
			}
254
			break;
-
 
255
		default:
-
 
256
			DEFAULT_MARK:
-
 
257
			if (bukva<=15) bukva=' ';
-
 
258
			line_len = strlen(#line);
-
 
259
			if (!style.pre) && (bukva == ' ')
-
 
260
			{
-
 
261
				if (line[line_len-1]==' ') break; //no double spaces
-
 
262
				if (!stolbec) && (!line) break; //no paces at the beginning of the line
-
 
263
			}
254
			strncpy(#oldtag, #tag.name, sizeof(oldtag)-1);
264
			if (line_len < sizeof(line)) chrcat(#line, bukva);
255
			break;
265
			CheckForLineBreak();
256
		default:
266
		}
257
			AddCharToTheLine(ESBYTE[bufpos]);
267
	}
258
		}
268
	DrawStyle();
259
	}
269
	NewLine();
260
	DrawStyle();
270
	if (list.first == 0) list.count = draw_y;
261
	NewLine();
271
	DrawPage();
262
	list.count = draw_y;
272
}
263
	DrawPage();
273
//============================================================================================
264
}
Line 295... Line 286...
295
}
286
	return true;
296
//============================================================================================
287
}
297
void TWebBrowser::SetStyle() {
288
//============================================================================================
298
	char img_path[4096]=0;
289
void TWebBrowser::SetStyle() {
299
	int left1 = body_magrin + list.x;
290
	char img_path[4096]=0;
300
	int meta_encoding;
-
 
301
	if (istag("html")) {
291
	int meta_encoding;
-
 
292
 
-
 
293
	dword value;
-
 
294
 
302
		t_html = opened;
295
	if (tag.is("html")) {
303
		return;
296
		t_html = tag.opened;
304
	}
297
		return;
305
	if(istag("title")) {
298
	}
306
		if (opened) header=NULL;
299
	if(tag.is("title")) {
307
		return;
300
		if (tag.opened) header=NULL;
308
	}
301
		return;
309
	
302
	}
Line 310... Line 303...
310
	IF(istag("q"))
303
	
311
	{
304
	IF(tag.is("q"))
312
		if (opened)	{
305
	{
313
			meta_encoding = strlen(#line);
306
		if (tag.opened)	{
314
			if (line[meta_encoding-1] != ' ') chrcat(#line, ' ');
307
			meta_encoding = strlen(#line);
315
			chrcat(#line, '\"');
308
			if (line[meta_encoding-1] != ' ') chrcat(#line, ' ');
316
		}
309
			chrcat(#line, '\"');
317
		if (!opened) strcat(#line, "\" ");
310
		}
318
		return;
311
		if (!tag.opened) strcat(#line, "\" ");
319
	}
312
		return;
320
	if (isattr("id=")) || (isattr("name=")) { // TO FIX: works only if the param is the last
313
	}
321
		anchors.add(#val, draw_y);
314
	if (value = tag.get_value_of("name=")) || (value = tag.get_value_of("id=")) {
322
	}	
315
		anchors.add(value, draw_y);
323
	if (istag("body")) {
316
	}	
324
		t_body = opened;
317
	if (tag.is("body")) {
325
		do{
-
 
326
			if (isattr("link=")) link_color_inactive = GetColor(#val);
318
		t_body = tag.opened;
327
			if (isattr("alink=")) link_color_active = GetColor(#val);
319
		if (value = tag.get_value_of("link="))  link_color_inactive = GetColor(value);
328
			if (isattr("text=")) text_colors[0]=GetColor(#val);
320
		if (value = tag.get_value_of("alink=")) link_color_active = GetColor(value);
329
			if (isattr("bgcolor="))
321
		if (value = tag.get_value_of("text="))  text_colors[0]=GetColor(value);
330
			{
-
 
331
				style.bg_color = page_bg = GetColor(#val);
322
		if (value = tag.get_value_of("bgcolor=")) {
332
				DrawBuf.Fill(0, page_bg);
323
			style.bg_color = page_bg = GetColor(value);
333
			}
324
			DrawBuf.Fill(0, page_bg);
334
		} while(GetNextParam());
325
		}
335
		if (opened) && (cur_encoding==CH_NULL) {
326
		if (tag.opened) {
336
			cur_encoding = CH_CP866; 
327
			if (cur_encoding==CH_NULL) {
337
			//BufEncode(CH_UTF8);
328
				cur_encoding = CH_CP866; 
338
			debugln("Document has no information about encoding!");
329
				//BufEncode(CH_UTF8);
339
		}
330
				debugln("Document has no information about encoding!");
340
		if (opened) {
-
 
341
			if (strcmp(#header, #version) != 0) {
331
			}
342
				ChangeCharset(charsets[cur_encoding], "CP866", #header);
332
			if (!streq(#header, #version)) {
343
				sprintf(#header, "%s - %s", #header, #version);
333
				ChangeCharset(charsets[cur_encoding], "CP866", #header);
-
 
334
				strncat(#header, " - ", sizeof(header)-1);
344
			}
335
				strncat(#header, #version, sizeof(header)-1);
345
			DrawTitle(#header);
336
			}
346
		}
337
			DrawTitle(#header);
347
		return;
338
		}
348
	}
339
		return;
349
	if (istag("a")) {
340
	}
350
		if (opened)
341
	if (tag.is("a")) {
351
		{
342
		if (tag.opened)
352
			if (link) IF(text_color_index > 0) text_color_index--; //åñëè ïðåäûäóùèé òåã à íå áûë çàêðûò
343
		{
353
			do{
-
 
354
				if (isattr("href=")) && (!strstr(#val,"javascript:"))
344
			if (link) IF(text_color_index > 0) text_color_index--; //åñëè ïðåäûäóùèé òåã à íå áûë çàêðûò
355
				{
345
			if (value = tag.get_value_of("href=")) && (!strstr(value,"javascript:"))
356
					text_color_index++;
346
			{
357
					text_colors[text_color_index] = text_colors[text_color_index-1];
347
				text_color_index++;
358
					link = 1;
348
				text_colors[text_color_index] = text_colors[text_color_index-1];
359
					text_colors[text_color_index] = link_color_inactive;
349
				link = 1;
360
					PageLinks.AddLink(#val);
350
				text_colors[text_color_index] = link_color_inactive;
361
				}
-
 
362
			} while(GetNextParam());
-
 
363
		}
351
				PageLinks.AddLink(value);
364
		else {
352
			}
365
			link = 0;
353
		} else {
366
			IF(text_color_index > 0) text_color_index--;
354
			link = 0;
367
		}
355
			IF(text_color_index > 0) text_color_index--;
368
		return;
356
		}
369
	}
357
		return;
370
	if (istag("font")) {
358
	}
371
		style.bg_color = page_bg;
359
	if (tag.is("font")) {
372
		if (opened)
360
		style.bg_color = page_bg;
373
		{
361
		if (tag.opened)
374
			text_color_index++;
362
		{
375
			text_colors[text_color_index] = text_colors[text_color_index-1];
363
			text_color_index++;
376
			do{
-
 
377
				if (isattr("color=")) text_colors[text_color_index] = GetColor(#val);
364
			text_colors[text_color_index] = text_colors[text_color_index-1];
378
				if (isattr("bg=")) style.bg_color = GetColor(#val);
365
			if (value = tag.get_value_of("color=")) text_colors[text_color_index] = GetColor(value);
379
			} while(GetNextParam());
-
 
380
		}
366
			if (value = tag.get_value_of("bg=")) style.bg_color = GetColor(value);
381
		else if (text_color_index > 0) text_color_index--;
367
		}
382
		return;
368
		else if (text_color_index > 0) text_color_index--;
383
	}
369
		return;
384
	if (istag("div")) {
370
	}
385
		if (streq(#oldtag,"div")) && (opened) return;
371
	if (tag.is("div")) {
386
		NewLine();
372
		if (streq(#oldtag,"div")) && (tag.opened) return;
387
		//IF (oldtag[0] != 'h') 
373
		NewLine();
388
		return;
374
		//IF (oldtag[0] != 'h') 
389
	}
375
		return;
390
	if (istag("header")) || (istag("article")) || (istag("footer")) || (istag("figure")) {
376
	}
391
		NewLine();
377
	if (tag.is("header")) || (tag.is("article")) || (tag.is("footer")) || (tag.is("figure")) {
392
		return;
378
		NewLine();
393
	}
379
		return;
394
	if (istag("p")) {
380
	}
395
		IF (oldtag[0] == 'h') || (streq(#oldtag,"td")) || (streq(#oldtag,"p")) return;
381
	if (tag.is("p")) {
396
		NewLine();
382
		IF (oldtag[0] == 'h') || (streq(#oldtag,"td")) || (streq(#oldtag,"p")) return;
397
		//IF(opened) NewLine();
383
		NewLine();
398
		return;
384
		//IF(tag.opened) NewLine();
399
	}
385
		return;
400
	if (istag("br")) { NewLine(); return; }
386
	}
401
	if (istag("tr")) { if (opened) NewLine(); return; }
387
	if (tag.is("br")) { NewLine(); return; }
402
	if (istag("b")) || (istag("strong")) || (istag("big")) { style.b = opened; return; }
388
	if (tag.is("tr")) { if (tag.opened) NewLine(); return; }
403
	if (istag("button")) { style.button = opened; stolbec++; return; }
389
	if (tag.is("b")) || (tag.is("strong")) || (tag.is("big")) { style.b = tag.opened; return; }
404
	if (istag("u")) || (istag("ins")) { style.u=opened; return;}
390
	if (tag.is("button")) { style.button = tag.opened; stolbec++; return; }
405
	if (istag("s")) || (istag("strike")) || (istag("del")) { style.s=opened; return; }
391
	if (tag.is("u")) || (tag.is("ins")) { style.u=tag.opened; return;}
406
	if (istag("dd")) { stolbec += 5; return; }
392
	if (tag.is("s")) || (tag.is("strike")) || (tag.is("del")) { style.s=tag.opened; return; }
407
	if (istag("blockquote")) { style.blq = opened; return; }
393
	if (tag.is("dd")) { stolbec += 5; return; }
408
	if (istag("pre")) || (istag("code")) { style.pre = opened; return; }
394
	if (tag.is("blockquote")) { style.blq = tag.opened; return; }
409
	if (istag("img")) {
395
	if (tag.is("pre")) || (tag.is("code")) { style.pre = tag.opened; return; }
410
		do{
-
 
411
			if (isattr("src=")) strlcpy(#img_path, #val, sizeof(img_path)-1);
396
	if (tag.is("img")) {
412
			if (isattr("title=")) && (strlen(#val)
397
		if (value = tag.get_value_of("src=")) strlcpy(#img_path, value, sizeof(img_path)-1);
413
			if (isattr("alt=")) && (strlen(#val)
398
		if (value = tag.get_value_of("title=")) && (strlen(value)
414
		} while(GetNextParam());
-
 
415
		if (!img_path) { line=0; return; }
399
		if (value = tag.get_value_of("alt=")) && (strlen(value)
416
		style.image = true;
400
		if (!img_path) { line=0; return; }
417
		text_color_index++;
401
		style.image = true;
418
		text_colors[text_color_index] = 0x9A6F29;
402
		text_color_index++;
419
		if (!line) {
403
		text_colors[text_color_index] = 0x9A6F29;
Line 425... Line 409...
425
		while (CheckForLineBreak()) {};
409
		}
426
		DrawStyle();
410
		while (CheckForLineBreak()) {};
427
		text_color_index--;
411
		DrawStyle();
428
		style.image = false;
412
		text_color_index--;
429
		//ImgCache.Images( left1, draw_y, WB1.list.w); 
413
		style.image = false;
430
		return; 
414
		//ImgCache.Images( list.x, draw_y, WB1.list.w); 
431
	}
415
		return; 
432
	if (istag("h1")) || (istag("h2")) || (istag("h3")) || (istag("caption")) {
416
	}
433
		style.h = opened;
417
	if (tag.is("h1")) || (tag.is("h2")) || (tag.is("h3")) || (tag.is("caption")) {
434
		if (opened)
418
		style.h = tag.opened;
435
		{
419
		if (tag.opened)
436
			NewLine();
420
		{
437
			draw_y += 10;
421
			NewLine();
438
			WB1.zoom=2;
422
			draw_y += 10;
439
			WB1.list.font_type |= 10011001b;
423
			WB1.zoom=2;
440
			if (isattr("align=")) && (isval("center")) style.align = ALIGN_CENTER;
424
			WB1.list.font_type |= 10011001b;
-
 
425
			if (value = tag.get_value_of("align=")) {
441
			if (isattr("align=")) && (isval("right")) style.align = ALIGN_RIGHT;
426
				if (streq(value, "center")) style.align = ALIGN_CENTER;
442
			list.item_h = basic_line_h * 2;
427
				if (streq(value, "right")) style.align = ALIGN_RIGHT;
-
 
428
			}
443
			if (istag("h1")) style.b = true;
429
			list.item_h = basic_line_h * 2;
444
		}
430
			if (tag.is("h1")) style.b = true;
445
		else
431
		}
446
		{
432
		else
447
			if (istag("h1")) style.b = false;
433
		{
448
			NewLine();
434
			if (tag.is("h1")) style.b = false;
449
			WB1.zoom=1;
435
			NewLine();
450
			WB1.list.font_type = 10011000b;
436
			WB1.zoom=1;
451
			style.align = ALIGN_LEFT;
437
			WB1.list.font_type = 10011000b;
452
			list.item_h = basic_line_h;
438
			style.align = ALIGN_LEFT;
453
		}
439
			list.item_h = basic_line_h;
454
		return;
440
		}
455
	}
441
		return;
456
	if (istag("dt")) {
442
	}
457
		style.li = opened;
443
	if (tag.is("dt")) {
458
		if (opened) NewLine();
444
		style.li = tag.opened;
459
		return;
445
		if (tag.opened) NewLine();
460
	}
446
		return;
461
	if (istag("li")) || (istag("dt"))
447
	}
462
	{
448
	if (tag.is("li")) || (tag.is("dt"))
463
		style.li = opened;
449
	{
464
		if (opened)
450
		style.li = tag.opened;
465
		{
451
		if (tag.opened)
466
			NewLine();
452
		{
467
			stolbec = style.li_tab * 5 - 2;
453
			NewLine();
468
			strcpy(#line, "\31 ");
454
			stolbec = style.li_tab * 5 - 2;
469
			//stolbec-=2;
455
			strcpy(#line, "\31 ");
470
		}
456
			//stolbec-=2;
471
		return;
457
		}
472
	}
458
		return;
473
	if (istag("ul")) || (istag("ol")) {
459
	}
474
		if (!opened)
460
	if (tag.is("ul")) || (tag.is("ol")) {
475
		{
461
		if (!tag.opened)
476
			style.li = opened;
462
		{
477
			style.li_tab--;
463
			style.li = tag.opened;
478
			NewLine();
464
			style.li_tab--;
479
		} 
465
			NewLine();
480
		else style.li_tab++;
466
		} 
481
	}
467
		else style.li_tab++;
482
	if (istag("hr")) {
468
	}
483
		if (isattr("color=")) EDI = GetColor(#val); else EDI = 0x999999;
469
	if (tag.is("hr")) {
484
		$push edi;
470
		if (value = tag.get_value_of("color=")) EDI = GetColor(value); else EDI = 0x999999;
485
		NewLine();
471
		$push edi;
486
		$pop edi;
472
		NewLine();
487
		draw_y += 10;
473
		$pop edi;
488
		DrawBuf.DrawBar(5, draw_y - 1, list.w-10, 1, EDI);
474
		draw_y += 10;
489
		NewLine();
475
		DrawBuf.DrawBar(5, draw_y - 1, list.w-10, 1, EDI);
490
		draw_y += 10;
476
		NewLine();
491
		return;
477
		draw_y += 10;
492
	}
478
		return;
493
	if (istag("meta")) || (istag("?xml")) {
479
	}
494
		meta_encoding = CH_NULL;
480
	if (tag.is("meta")) || (tag.is("?xml")) {
495
		do{
481
		meta_encoding = CH_NULL;
496
			if (isattr("charset=")) || (isattr("content=")) || (isattr("encoding="))
-
 
497
			{
482
		if (value = tag.get_value_of("charset=")) || (value = tag.get_value_of("content=")) || (value = tag.get_value_of("encoding="))
498
				strcpy(#val, #val[strrchr(#val, '=')]); //search in content=
483
		{
499
				strlwr(#val);
484
			value += strrchr(value, '='); //search in content=
500
				if      (isval("utf-8"))        || (isval("utf8"))        meta_encoding = CH_UTF8;
485
			strlwr(value);
501
				else if (isval("koi8-r"))       || (isval("koi8-u"))      meta_encoding = CH_KOI8;
486
			if      (streq(value,"utf-8"))        || (streq(value,"utf8"))        meta_encoding = CH_UTF8;
502
				else if (isval("windows-1251")) || (isval("windows1251")) meta_encoding = CH_CP1251;
487
			else if (streq(value,"windows-1251")) || (streq(value,"windows1251")) meta_encoding = CH_CP1251;
503
				else if (isval("iso-8859-5"))   || (isval("iso8859-5"))   meta_encoding = CH_ISO8859_5;
488
			else if (streq(value,"dos"))          || (streq(value,"cp-866"))      meta_encoding = CH_CP866;
504
				else if (isval("dos"))          || (isval("cp-866"))      meta_encoding = CH_CP866;
489
			else if (streq(value,"iso-8859-5"))   || (streq(value,"iso8859-5"))   meta_encoding = CH_ISO8859_5;
505
			}
490
			else if (streq(value,"koi8-r"))       || (streq(value,"koi8-u"))      meta_encoding = CH_KOI8;
506
		} while(GetNextParam());
491
		}
507
		if (meta_encoding!=CH_NULL) BufEncode(meta_encoding);
-
 
508
		return;
492
		if (meta_encoding!=CH_NULL) BufEncode(meta_encoding);
509
	}
493
		return;
510
}
494
	}
511
//============================================================================================
495
}
512
void TWebBrowser::BufEncode(dword set_new_encoding)
496
//============================================================================================
513
{
497
void TWebBrowser::BufEncode(dword set_new_encoding)
514
	if (cur_encoding == set_new_encoding) return;
498
{
515
	if (o_bufpointer==0)
499
	if (cur_encoding == set_new_encoding) return;
516
	{
500
	if (o_bufpointer==0) {
517
		o_bufpointer = malloc(bufsize);
-
 
518
		strcpy(o_bufpointer, bufpointer);
501
		o_bufpointer = malloc(bufsize);
519
	}
502
		strcpy(o_bufpointer, bufpointer);
520
	else
-
 
521
	{
503
	} else {
522
		strcpy(bufpointer, o_bufpointer);
-
 
523
	}
504
		strcpy(bufpointer, o_bufpointer);
524
	//debugval("cur_encoding    ", cur_encoding);
505
	}
525
	//debugval("set_new_encoding", set_new_encoding);
506
	//debugval("cur_encoding    ", cur_encoding);
526
	cur_encoding = set_new_encoding;
507
	//debugval("set_new_encoding", set_new_encoding);
527
	bufpointer = ChangeCharset(charsets[cur_encoding], "CP866", bufpointer);
508
	cur_encoding = set_new_encoding;
Line 564... Line 545...
564
	if (style.li) stolbec = style.li_tab * 5;
545
	if (style.blq) stolbec = 6; else stolbec = 0;
565
	if (debug_mode) debugln(NULL);
546
	if (style.li) stolbec = style.li_tab * 5;
566
}
547
	if (debug_mode) debugln(NULL);
567
//============================================================================================
548
}
568
bool istag(dword text) { if (!strcmp(#tag,text)) return true; else return false; }
549
//============================================================================================
569
bool isattr(dword text) { if (!strcmp(#attr,text)) return true; else return false; }
-
 
570
bool isval(dword text) { if (!strcmp(#val,text)) return true; else return false; }
-
 
571
//============================================================================================
-
 
572
void TWebBrowser::DrawPage()
-
 
573
{
550
void TWebBrowser::DrawPage()
574
	PutPaletteImage(list.first * DrawBuf.bufw * 4 + buf_data+8, DrawBuf.bufw, list.h, DrawBuf.bufx, DrawBuf.bufy, 32, 0);	
551
{
575
	DrawScroller();
552
	PutPaletteImage(list.first * DrawBuf.bufw * 4 + buf_data+8, DrawBuf.bufw, list.h, DrawBuf.bufx, DrawBuf.bufy, 32, 0);	
576
}
553
	DrawScroller();
577
>
554
}
578
555
>