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