Subversion Repositories Kolibri OS

Rev

Rev 6152 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
6043 leency 1
 
2
{
3
	list.SetSizes(0, TOOLBAR_H, Form.cwidth-scroll.size_x-1, Form.cheight-TOOLBAR_H, label.size.pt+2);
6053 leency 4
	strcpy(#title, history.current()+strrchr(history.current(),'/'));
5
	//get font chars width, need to increase performance
6043 leency 6
	get_label_symbols_size();
6053 leency 7
	ChangeCharset(charsets[encoding], "CP866", io.buffer_data);
8
	link.clear();
6058 leency 9
	if (strstri(io.buffer_data, "
6053 leency 10
		debugln("no  found");
6043 leency 11
		DrawProgress(STEP_2_COUNT_PAGE_HEIGHT);     ParceTxt(false);   //get page height to calculate buffer size
6053 leency 12
		DrawProgress(STEP_3_DRAW_PAGE_INTO_BUFFER); ParceTxt(true);    //draw text in buffer
13
	} else {
14
		debugln(" tag found");
6043 leency 15
		DrawProgress(STEP_2_COUNT_PAGE_HEIGHT);     ParceHtml(false);  //get page height to calculate buffer size
6053 leency 16
		DrawProgress(STEP_3_DRAW_PAGE_INTO_BUFFER); ParceHtml(true);   //draw text in buffer
17
	}
18
	strcat(#title, " - Aelia");
19
	DrawTitle(#title);
20
	DrawProgress(STEP_4_SMOOTH_FONT);           label.apply_smooth();
21
	DrawProgress(STEP_5_STOP);                  DrawPage();
22
}
6043 leency 23
24
 
25
{
26
byte ch, zeroch=0;
27
dword bufoff, buflen, line_start, srch_pos;
28
int stroka_y=5, line_length=0;
29
30
 
31
	buflen = strlen(io.buffer_data) + io.buffer_data;
32
	for (bufoff=io.buffer_data; bufoff
33
	{
34
		ch = ESBYTE[bufoff];
35
		line_length += char_width[ch];
36
		if (line_length>=list.w-30) || (ch==10) {
37
			srch_pos = bufoff;
38
			loop()
39
			{
40
				if (__isWhite(ESBYTE[srch_pos])) { bufoff=srch_pos+1; break; } //normal word-break
41
				if (srch_pos == line_start) break; //no white space found in whole line
42
				srch_pos--;
43
			}
44
			if (draw==true) {
45
				ESBYTE[bufoff] >< zeroch; //set line end
46
				WriteTextIntoBuf(8, stroka_y, 0x000000, line_start);
6053 leency 47
				ESBYTE[bufoff] >< zeroch; //restore line
6043 leency 48
			}
49
			stroka_y += list.item_h;
50
			line_start = bufoff;
51
			line_length = 0;
52
		}
53
	}
54
	if (draw==false) {
55
		list.count = stroka_y/list.item_h+3;
6059 leency 56
		if (list.count < list.visible) list.count = list.visible;
6043 leency 57
		label.size.height = list.count+5*list.item_h;
6059 leency 58
		label.raw_size = 0;
6043 leency 59
	}
60
	if (draw==true) WriteTextIntoBuf(8, stroka_y, 0x000000, line_start);
6053 leency 61
}
6043 leency 62
63
 
64
 
65
=                                                        =
66
=                        HTML                            =
67
=                                                        =
68
========================================================*/
69
70
 
6053 leency 71
#define HTML_PADDING_Y 5;
72
6043 leency 73
 
6053 leency 74
 
6043 leency 75
{
76
dword DOM_start, DOM_end, DOM_len, DOM_pos;
6216 leency 77
int stroka_x = HTML_PADDING_X;
6053 leency 78
int stroka_y = HTML_PADDING_Y;
79
dword line_break;
80
byte ch, zeroch;
81
_text text;
6043 leency 82
_tag tag;
83
84
 
6058 leency 85
	style.clear();
86
	/* Create DOM */
6043 leency 87
	debugln("creating DOM");
6053 leency 88
	DOM_len = strlen(io.buffer_data);
6216 leency 89
	DOM_start = malloc(DOM_len);
90
	DOM_end = DOM_start + DOM_len;
91
	strlcpy(DOM_start, io.buffer_data, DOM_len);
92
6043 leency 93
 
94
	debugln("starting DOM parce...");
6053 leency 95
	text.start = DOM_start;
6216 leency 96
	for (DOM_pos=DOM_start; DOM_pos
97
	{
6043 leency 98
		if (ESBYTE[DOM_pos]==0x0D) || (ESBYTE[DOM_pos]==0x0A) ESBYTE[DOM_pos]=' ';
6053 leency 99
		ch = ESBYTE[DOM_pos];
6043 leency 100
		if (ch=='<') {
101
			ESBYTE[DOM_pos] = '\0';
6053 leency 102
			tag.start = DOM_pos + 1;
6043 leency 103
			if (style.ignore) continue;
6053 leency 104
			if (tag.nameis("title")) {
105
				strcpy(#title, text.start);
106
				continue;
107
			}
108
			strtrim(text.start);
6059 leency 109
			while (get_label_len(text.start) + stroka_x + 30 > list.w)
6053 leency 110
			{
111
				zeroch = 0;
112
				for (line_break=tag.start-1; line_break>text.start; line_break--;)
113
				{
114
					ESBYTE[line_break] >< zeroch; //set line end
115
					if (get_label_len(text.start) + stroka_x + 30 <= list.w) break;
116
					ESBYTE[line_break] >< zeroch; //restore line
117
				}
118
				if (draw==true) {
119
					if (style.a) {
6058 leency 120
						link.add(stroka_x,stroka_y,get_label_len(text.start),list.item_h,text.start," ");
121
						label_draw_bar(stroka_x, stroka_y+label.size.pt+1, get_label_len(text.start), style.color);
122
					}
123
					WriteTextIntoBuf(stroka_x, stroka_y, style.color, text.start);
6053 leency 124
				}
125
				stroka_x+=char_width[' '];
6152 leency 126
				ESBYTE[line_break] >< zeroch; //restore line
6053 leency 127
				text.start = line_break;
128
				stroka_x = HTML_PADDING_X;
129
				stroka_y += list.item_h;
130
			}
131
			if (draw==true) {
132
				if (style.a) {
6058 leency 133
					link.add(stroka_x,stroka_y,get_label_len(text.start),list.item_h,text.start," ");
134
					label_draw_bar(stroka_x, stroka_y+label.size.pt+1, get_label_len(text.start), style.color);
135
				}
136
				WriteTextIntoBuf(stroka_x, stroka_y, style.color, text.start);
6053 leency 137
			}
138
			stroka_x+=char_width[' '];
6152 leency 139
			stroka_x += get_label_len(text.start);
6053 leency 140
		}
6043 leency 141
		if (ch=='>') {
142
			ESBYTE[DOM_pos] = '\0';
6053 leency 143
			text.start = DOM_pos + 1;
6043 leency 144
			tag.parce();
145
			if (tag.nameis("br"))
6059 leency 146
				|| (tag.nameis("p"))
147
				|| (tag.nameis("div"))
148
				|| (tag.nameis("tr")) {
149
				stroka_y+= list.item_h;
6053 leency 150
				stroka_x = HTML_PADDING_X;
151
				continue;
152
			}
153
			if 	(tag.nameis("h1")) || (tag.nameis("/h1"))
6059 leency 154
				|| (tag.nameis("h2")) || (tag.nameis("/h2")) {
155
					stroka_y+= list.item_h;
156
					stroka_x = HTML_PADDING_X;
157
					continue;
158
				}
159
			if (tag.nameis("script")) || (tag.nameis("style")) style.ignore = true;
6053 leency 160
			if (tag.nameis("/script")) || (tag.nameis("/style")) style.ignore = false;
161
			if (tag.nameis("a"))  { style.a = true;  style.color=0x0000FF; }
162
			if (tag.nameis("/a")) { style.a = false; style.color=0x000000; }
163
		}
6043 leency 164
	}
165
	if (draw==false) {
6053 leency 166
		list.count = stroka_y/list.item_h+3;
6059 leency 167
		if (list.count < list.visible) list.count = list.visible;
6053 leency 168
		label.size.height = list.count+5*list.item_h;
6059 leency 169
		label.raw_size = 0;
6053 leency 170
	}
171
	free(DOM_start);
6216 leency 172
}
6043 leency 173