Subversion Repositories Kolibri OS

Rev

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

Rev 4692 Rev 4718
Line 15... Line 15...
15
	void Parse();
15
	void Parse();
16
	void SetTextStyle();
16
	void SetTextStyle();
17
	void DrawPage();
17
	void DrawPage();
18
	void DrawScroller();
18
	void DrawScroller();
19
	void NewLine();
19
	void NewLine();
-
 
20
	void Perenos();
-
 
21
	byte end_parsing;
20
} WB1;
22
} WB1;
Line 21... Line 23...
21
 
23
 
22
byte b_text, i_text, u_text, s_text, pre_text, blq_text, li_text, li_tab, 
24
byte b_text, i_text, u_text, s_text, pre_text, blq_text, li_text, li_tab, 
23
	link, ignor_text, cur_encoding, text_align, t_html, t_body;
25
	link, ignor_text, cur_encoding, text_align, t_html, t_body;
Line 52... Line 54...
52
#include "..\TWB\img_cache.h"
54
#include "..\TWB\img_cache.h"
53
#include "..\TWB\parce_tag.h"
55
#include "..\TWB\parce_tag.h"
54
#include "..\TWB\table.h"
56
#include "..\TWB\table.h"
Line 55... Line -...
55
 
-
 
56
 
57
 
Line 57... Line 58...
57
 
58
 
58
//=======================================================================
59
//=======================================================================
59
 
60
 
Line 60... Line 61...
60
 
61
 
61
void TWebBrowser::DrawPage()
62
void TWebBrowser::DrawPage()
62
{
63
{
63
	int start_x, start_y, line_length, magrin_left=5;
64
	int start_x, start_y, line_length, stolbec_len, magrin_left=5;
Line 73... Line 74...
73
	if (t_html) && (!t_body) return;
74
	if (t_html) && (!t_body) return;
Line 74... Line 75...
74
	
75
	
75
	if (stroka >= 0) && (stroka - 2 < list.visible) && (line) && (!anchor)
76
	if (stroka >= 0) && (stroka - 2 < list.visible) && (line) && (!anchor)
76
	{
77
	{
77
		start_x = stolbec * 6 + list.x + magrin_left;
78
		start_x = stolbec * 6 + list.x + magrin_left;
-
 
79
		start_y = stroka * list.line_h + list.y + magrin_left;
78
		start_y = stroka * 10 + list.y + magrin_left;
80
		stolbec_len = strlen(#line);
Line 79... Line 81...
79
		line_length = strlen(#line) * 6;
81
		line_length = stolbec_len * 6;
80
 
82
 
81
		WriteBufText(start_x, 0, 0x88, text_colors[text_color_index], #line, buf_data);
83
		WriteBufText(start_x, 0, 0x88, text_colors[text_color_index], #line, buf_data);
82
		IF (b_text)	WriteBufText(start_x+1, 0, 0x88, text_colors[text_color_index], #line, buf_data);
84
		IF (b_text)	WriteBufText(start_x+1, 0, 0x88, text_colors[text_color_index], #line, buf_data);
83
		IF (i_text) { stolbec++; DrawBuf.Skew(start_x, 0, line_length, list.line_h); }
85
		IF (i_text) { stolbec++; DrawBuf.Skew(start_x, 0, line_length, list.line_h); }
84
		IF (s_text) DrawBuf.DrawBar(start_x, 4, line_length, 1, text_colors[text_color_index]);
86
		IF (s_text) DrawBuf.DrawBar(start_x, 4, line_length, 1, text_colors[text_color_index]);
85
		IF (u_text) DrawBuf.DrawBar(start_x, 8, line_length, 1, text_colors[text_color_index]);
87
		IF (u_text) DrawBuf.DrawBar(start_x, 8, line_length, 1, text_colors[text_color_index]);
86
		IF (link) {
88
		IF (link) {
87
			UnsafeDefineButton(start_x-2, start_y, line_length + 3, 9, PageLinks.count + 400 + BT_HIDE, 0xB5BFC9);
89
			UnsafeDefineButton(start_x-2, start_y-1, line_length + 3, 10, PageLinks.count + 400 + BT_HIDE, 0xB5BFC9);
88
			DrawBuf.DrawBar(start_x, 8, line_length, 1, text_colors[text_color_index]);
90
			DrawBuf.DrawBar(start_x, 8, line_length, 1, text_colors[text_color_index]);
89
			PageLinks.AddText(#line, line_length, list.line_h, UNDERLINE);
91
			PageLinks.AddText(#line, line_length, list.line_h, UNDERLINE);
90
		}
92
		}
91
		stolbec += strlen(#line);
93
		stolbec += stolbec_len;
92
	}
94
	}
Line 119... Line 121...
119
}
121
}
Line 120... Line 122...
120
 
122
 
121
 
123
 
122
void TWebBrowser::Parse(){
124
void TWebBrowser::Parse(){
123
	word bukva[2];
125
	word bukva[2];
124
	int j, perenos_num;
126
	int j;
125
	byte ignor_param;
127
	byte ignor_param;
Line 126... Line 128...
126
	char temp[768];
128
	char temp[768];
127
	dword bufpos = bufpointer;
129
	dword bufpos = bufpointer;
128
	
130
	
-
 
131
	b_text = i_text = u_text = s_text = blq_text = t_html = t_body =
129
	b_text = i_text = u_text = s_text = blq_text = t_html = t_body =
132
	li_text = link = ignor_text = text_color_index = text_colors[0] = li_tab = 
130
	li_text = link = ignor_text = text_color_index = text_colors[0] = li_tab = 
133
	condition_text_val = condition_text_active = 0; //îáíóëÿåì òåãè
131
	condition_text_val = condition_text_active = 0; //îáíóëÿåì òåãè
134
	end_parsing = false;
132
	condition_max = 255;
135
	condition_max = 255;
133
	text_align = ALIGN_LEFT;
136
	text_align = ALIGN_LEFT;
Line 146... Line 149...
146
		pre_text=0;
149
		pre_text=0;
147
		if (!strcmp(#URL + strlen(#URL) - 4, ".txt")) pre_text = 1;
150
		if (!strcmp(#URL + strlen(#URL) - 4, ".txt")) pre_text = 1;
148
		if (!strcmp(#URL + strlen(#URL) - 4, ".mht")) ignor_text = 1;
151
		if (!strcmp(#URL + strlen(#URL) - 4, ".mht")) ignor_text = 1;
149
	}
152
	}
Line 150... Line 153...
150
	
153
	
151
	for ( ; bufpointer+bufsize > bufpos; bufpos++;)
154
	for ( ; (bufpointer+bufsize > bufpos) && (ESBYTE[bufpos]!=0); bufpos++;)
-
 
155
	{
152
	{
156
		if (end_parsing) break;
153
		bukva = ESBYTE[bufpos];
157
		bukva = ESBYTE[bufpos];
154
		if (ignor_text) && (bukva!='<') continue;
158
		if (ignor_text) && (bukva!='<') continue;
155
		if (condition_text_active) && (condition_text_val != condition_href) && (bukva!='<') continue;
159
		if (condition_text_active) && (condition_text_val != condition_href) && (bukva!='<') continue;
156
		switch (bukva)
160
		switch (bukva)
157
		{
161
		{
158
		case 0x0a:
162
		case 0x0a:
159
			if (pre_text)
163
			if (pre_text)
160
			{
164
			{
161
				chrcat(#line, ' ');
165
				chrcat(#line, ' ');
162
				bukva = temp = NULL;
166
				bukva = temp = NULL;
163
				goto NEXT_MARK;
167
				Perenos();
164
			}
168
			}
165
		case '\9':
169
		case '\9':
166
			if (pre_text) //èíà÷å èä¸ì íà 0x0d	
170
			if (pre_text) //èíà÷å èä¸ì íà 0x0d	
167
			{
171
			{
Line 237... Line 241...
237
				if (strcmp(#tag, "/condition")!=0) break;
241
				if (strcmp(#tag, "/condition")!=0) break;
238
			}
242
			}
239
			if (tag[strlen(#tag)-1]=='/') tag[strlen(#tag)-1]=NULL; //for br/
243
			if (tag[strlen(#tag)-1]=='/') tag[strlen(#tag)-1]=NULL; //for br/
240
			if (tagparam) && (strlen(#tagparam) < 4000) GetNextParam();
244
			if (tagparam) && (strlen(#tagparam) < 4000) GetNextParam();
Line 241... Line 245...
241
 
245
 
242
			if (stolbec + strlen(#line) > list.column_max) //============the same as NEXT_MARK
-
 
243
			{
-
 
244
				perenos_num = strrchr(#line, ' ');
-
 
245
				if (!perenos_num) && (strlen(#line)>list.column_max) perenos_num=list.column_max;
-
 
246
				strcpy(#temp, #line + perenos_num); //ïåðåíîñ ïî ñëîâàì
-
 
247
				line[perenos_num] = 0x00;
-
 
248
				if (stroka-1 > list.visible) && (list.first <>0) break 1; //óõîäèì...
-
 
249
				DrawPage();
-
 
250
				strcpy(#line, #temp);
-
 
251
				NewLine(); //çàêðàøèâàåì ñëåäóùóþ ñòðîêó
-
 
252
			}
246
			if (stolbec + strlen(#line) > list.column_max) Perenos();
253
			DrawPage();
247
			DrawPage();
254
			line = NULL;
248
			line = NULL;
255
			if (tag) SetTextStyle(list.x + 5, stroka * list.line_h + list.y + 5); //îáðàáîòêà òåãîâ
249
			if (tag) SetTextStyle(list.x + 5, stroka * list.line_h + list.y + 5); //îáðàáîòêà òåãîâ
256
			tag = parametr = tagparam = ignor_param = NULL;
250
			tag = parametr = tagparam = ignor_param = NULL;
Line 262... Line 256...
262
			{
256
			{
263
				if (line[strlen(#line)-1]==' ') break; //óáðàòü 2 ïðîáåëà ïîäðÿä
257
				if (line[strlen(#line)-1]==' ') break; //óáðàòü 2 ïðîáåëà ïîäðÿä
264
				if (!stolbec) && (!line) break; //ñòðîêà íå ìîæåò íà÷èíàòüñÿ ñ ïðîáåëà
258
				if (!stolbec) && (!line) break; //ñòðîêà íå ìîæåò íà÷èíàòüñÿ ñ ïðîáåëà
265
			}
259
			}
266
			if (strlen(#line)
260
			if (strlen(#line)
267
 
-
 
268
			if (stolbec + strlen(#line) > list.column_max)
261
			if (stolbec + strlen(#line) > list.column_max) Perenos();
269
			{
-
 
270
			NEXT_MARK:
-
 
271
				perenos_num = strrchr(#line, ' ');
-
 
272
				if (!perenos_num) && (strlen(#line)>list.column_max) perenos_num=list.column_max;
-
 
273
				strcpy(#temp, #line + perenos_num);
-
 
274
				line[perenos_num] = 0x00;
-
 
275
				if (stroka-1 > list.visible) && (list.first <>0) break 1;
-
 
276
				DrawPage();
-
 
277
				strcpy(#line, #temp);
-
 
278
				NewLine();
-
 
279
			}
-
 
280
		}
262
		}
281
	}
263
	}
282
 
-
 
283
	DrawPage();
264
	DrawPage();
284
	NewLine();
265
	NewLine();
285
	DrawBar(list.x, stroka * list.line_h + list.y + 5, list.w, -stroka * list.line_h + list.h - 5, bg_color);
266
	DrawBar(list.x, stroka * list.line_h + list.y + 5, list.w, -stroka * list.line_h + list.h - 5, bg_color);
286
	DrawBar(list.x, list.visible * list.line_h + list.y + 4, list.w, -list.visible * list.line_h + list.h - 4, bg_color);
267
	DrawBar(list.x, list.visible * list.line_h + list.y + 4, list.w, -list.visible * list.line_h + list.h - 4, bg_color);
287
	if (list.first == 0) list.count = stroka;
268
	if (list.first == 0) list.count = stroka;
Line 292... Line 273...
292
		Parse();
273
		Parse();
293
	}
274
	}
294
	DrawScroller();
275
	DrawScroller();
295
}
276
}
Line -... Line 277...
-
 
277
 
-
 
278
void TWebBrowser::Perenos()
-
 
279
{
-
 
280
	int perenos_num;
-
 
281
	char new_line_text[4096];
-
 
282
	perenos_num = strrchr(#line, ' ');
-
 
283
	if (!perenos_num) && (strlen(#line)>list.column_max) perenos_num=list.column_max;
-
 
284
	strcpy(#new_line_text, #line + perenos_num);
-
 
285
	line[perenos_num] = 0x00;
-
 
286
	if (stroka-1 > list.visible) && (list.first <>0) end_parsing=true;
-
 
287
	DrawPage();
-
 
288
	strcpy(#line, #new_line_text);
-
 
289
	NewLine();
Line 296... Line 290...
296
 
290
}
297
 
291
 
298
 
292
 
Line 382... Line 376...
382
					text_color_index++;
376
					text_color_index++;
383
					text_colors[text_color_index] = text_colors[text_color_index-1];
377
					text_colors[text_color_index] = text_colors[text_color_index-1];
Line 384... Line 378...
384
					
378
					
385
					link = 1;
379
					link = 1;
386
					text_colors[text_color_index] = link_color_inactive;
380
					text_colors[text_color_index] = link_color_inactive;
387
					PageLinks.AddLink(#options, stolbec*6+left1, top1);
381
					PageLinks.AddLink(#options, stolbec*6+left1, top1-2);
388
				}
382
				}
389
				if (anchor) && (!strcmp(#parametr, "name="))
383
				if (anchor) && (!strcmp(#parametr, "name="))
390
				{
384
				{
391
					if (!strcmp(#anchor, #options))
385
					if (!strcmp(#anchor, #options))
Line 545... Line 539...
545
	{
539
	{
546
		li_text = opened;
540
		li_text = opened;
547
		if (opened)
541
		if (opened)
548
		{
542
		{
549
			NewLine();
543
			NewLine();
550
			if (stroka > -1) && (stroka - 2 < list.visible) DrawBuf.DrawBar(li_tab * 5 * 6 + left1 - 5, list.line_h/2-3, 2, 2, 0x555555);
544
			if (stroka > -1) && (stroka - 2 < list.visible) DrawBuf.DrawBar(li_tab * 5 * 6 + left1 - 5, list.line_h/2-2, 2, 2, 0x555555);
551
		}
545
		}
552
		return;
546
		return;
553
	}
547
	}
554
	if (isTag("u")) || (isTag("ins")) u_text = opened;
548
	if (isTag("u")) || (isTag("ins")) u_text = opened;
555
	if (isTag("s")) || (isTag("strike")) || (isTag("del")) s_text = opened;
549
	if (isTag("s")) || (isTag("strike")) || (isTag("del")) s_text = opened;