Rev 7764 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 7764 | Rev 7771 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | #include "..\TWB\colors.h" |
1 | #include "..\TWB\colors.h" |
2 | #include "..\TWB\anchors.h" |
2 | #include "..\TWB\anchors.h" |
3 | #include "..\TWB\parce_tag.h" |
3 | #include "..\TWB\parse_tag.h" |
4 | #include "..\TWB\special.h" |
4 | #include "..\TWB\special.h" |
5 | #include "..\TWB\img_cache.h" |
5 | #include "..\TWB\img_cache.h" |
6 | #include "..\TWB\tag_list.h" |
6 | #include "..\TWB\tag_list.h" |
7 | dword page_bg; |
7 | dword page_bg; |
8 | dword link_color_default; |
8 | dword link_color_default; |
Line 10... | Line 10... | ||
10 | #include "..\TWB\links.h" |
10 | #include "..\TWB\links.h" |
Line 11... | Line 11... | ||
11 | 11 | ||
12 | #define BODY_MARGIN 6 |
12 | #define BODY_MARGIN 6 |
Line -... | Line 13... | ||
- | 13 | #define BASIC_LINE_H 18 |
|
- | 14 | ||
- | 15 | DrawBufer DrawBuf; |
|
13 | #define BASIC_LINE_H 18 |
16 | char line[500]; |
14 | 17 | ||
15 | struct _style { |
18 | struct _style { |
16 | bool |
19 | bool |
17 | b, u, s, h, |
20 | b, u, s, h, |
Line 25... | Line 28... | ||
25 | }; |
28 | }; |
Line 26... | Line 29... | ||
26 | 29 | ||
27 | struct TWebBrowser { |
30 | struct TWebBrowser { |
28 | llist list; |
31 | llist list; |
29 | _style style; |
- | |
30 | DrawBufer DrawBuf; |
32 | _style style; |
31 | dword draw_y, stolbec; |
33 | dword draw_y, stolbec; |
32 | int zoom; |
34 | int zoom; |
33 | dword o_bufpointer; |
35 | dword o_bufpointer; |
34 | int cur_encoding, custom_encoding; |
36 | int cur_encoding, custom_encoding; |
35 | bool link, t_html, t_body; |
37 | bool link, t_html, t_body; |
36 | dword bufpointer; |
38 | dword bufpointer; |
Line 37... | Line 39... | ||
37 | dword bufsize; |
39 | dword bufsize; |
38 | 40 | ||
39 | void DrawStyle(); |
41 | void Paint(); |
40 | void SetPageDefaults(); |
42 | void SetPageDefaults(); |
41 | void AddCharToTheLine(); |
43 | void AddCharToTheLine(); |
42 | void ParseHtml(); |
44 | void ParseHtml(); |
43 | void SetStyle(); |
45 | void SetStyle(); |
44 | bool CheckForLineBreak(); |
46 | bool CheckForLineBreak(); |
45 | void NewLine(); |
47 | void NewLine(); |
46 | void DrawScroller(); |
48 | void DrawScroller(); |
47 | void ChangeEncoding(); |
- | |
48 | void DrawPage(); |
49 | void ChangeEncoding(); |
49 | char line[500]; |
50 | void DrawPage(); |
Line 50... | Line 51... | ||
50 | char header[150]; |
51 | char header[150]; |
Line 51... | Line 52... | ||
51 | }; |
52 | }; |
52 | 53 | ||
53 | scroll_bar scroll_wv = { 15,NULL,NULL,NULL,0,2,NULL,0,0,0xeeeeee,0xBBBbbb,0xeeeeee}; |
54 | scroll_bar scroll_wv = { 15,NULL,NULL,NULL,0,2,NULL,0,0,0xeeeeee,0xBBBbbb,0xeeeeee}; |
54 | 55 | ||
55 | //============================================================================================ |
56 | //============================================================================================ |
Line 56... | Line 57... | ||
56 | void TWebBrowser::DrawStyle() |
57 | void TWebBrowser::Paint() |
Line 94... | Line 95... | ||
94 | } |
95 | } |
Line 95... | Line 96... | ||
95 | 96 | ||
96 | text_color__ = text_colors[text_color_index]; |
97 | text_color__ = text_colors[text_color_index]; |
Line 97... | Line -... | ||
97 | if (link) && (text_colors[text_color_index]==text_colors[0]) text_color__ = link_color_default; |
- | |
98 | 98 | if (link) && (text_colors[text_color_index]==text_colors[0]) text_color__ = link_color_default; |
|
99 | 99 | ||
100 | DrawBuf.WriteText(start_x, draw_y, list.font_type, text_color__, #line); |
100 | DrawBuf.WriteText(start_x, draw_y, list.font_type, text_color__, #line); |
101 | if (style.b) DrawBuf.WriteText(start_x+1, draw_y, list.font_type, text_color__, #line); |
101 | if (style.b) DrawBuf.WriteText(start_x+1, draw_y, list.font_type, text_color__, #line); |
102 | if (style.s) DrawBuf.DrawBar(start_x, list.item_h / 2 - zoom + draw_y, line_length, zoom, text_color__); |
102 | if (style.s) DrawBuf.DrawBar(start_x, list.item_h / 2 - zoom + draw_y, line_length, zoom, text_color__); |
Line 149... | Line 149... | ||
149 | if (!style.pre) && (_char == ' ') |
149 | if (!style.pre) && (_char == ' ') |
150 | { |
150 | { |
151 | if (line[line_len-1]==' ') return; //no double spaces |
151 | if (line[line_len-1]==' ') return; //no double spaces |
152 | if (!stolbec) && (!line) return; //no paces at the beginning of the line |
152 | if (!stolbec) && (!line) return; //no paces at the beginning of the line |
153 | } |
153 | } |
154 | if (line_len < sizeof(TWebBrowser.line)) chrcat(#line, _char); |
154 | if (line_len < sizeof(line)) chrcat(#line, _char); |
155 | CheckForLineBreak(); |
155 | CheckForLineBreak(); |
156 | } |
156 | } |
157 | //============================================================================================ |
157 | //============================================================================================ |
158 | void TWebBrowser::ParseHtml(dword _bufpointer, _bufsize){ |
158 | void TWebBrowser::ParseHtml(dword _bufpointer, _bufsize){ |
159 | word bukva[2]; |
159 | word bukva[2]; |
Line 162... | Line 162... | ||
162 | dword j; |
162 | dword j; |
163 | bool ignor_param=false; |
163 | bool ignor_param=false; |
164 | int tab_len; |
164 | int tab_len; |
165 | dword bufpos; |
165 | dword bufpos; |
166 | bufsize = _bufsize; |
166 | bufsize = _bufsize; |
- | 167 | if (bufpointer != _bufpointer) { |
|
167 | bufpointer = malloc(bufsize); |
168 | bufpointer = malloc(bufsize); |
168 | memmov(bufpointer, _bufpointer, bufsize); |
169 | memmov(bufpointer, _bufpointer, bufsize); |
- | 170 | } else { |
|
- | 171 | custom_encoding = CH_CP866; |
|
- | 172 | } |
|
169 | SetPageDefaults(); |
173 | SetPageDefaults(); |
170 | if (strstri(bufpointer, " |
174 | if (strstri(bufpointer, " |
171 | t_body = true; |
175 | t_body = true; |
172 | if (strstri(bufpointer, " |
176 | if (strstri(bufpointer, " |
173 | } |
177 | } |
Line 176... | Line 180... | ||
176 | bukva = ESBYTE[bufpos]; |
180 | bukva = ESBYTE[bufpos]; |
177 | switch (bukva) |
181 | switch (bukva) |
178 | { |
182 | { |
179 | case 0x0a: |
183 | case 0x0a: |
180 | if (style.pre) { |
184 | if (style.pre) { |
181 | DrawStyle(); |
185 | Paint(); |
182 | NewLine(); |
186 | NewLine(); |
183 | } else { |
187 | } else { |
184 | AddCharToTheLine(0x0a); |
188 | AddCharToTheLine(0x0a); |
185 | } |
189 | } |
186 | break; |
190 | break; |
Line 197... | Line 201... | ||
197 | for (j=1, unicode_symbol=0; (ESBYTE[bufpos+j]<>';') && (j<8); j++) |
201 | for (j=1, unicode_symbol=0; (ESBYTE[bufpos+j]<>';') && (j<8); j++) |
198 | { |
202 | { |
199 | bukva = ESBYTE[bufpos+j]; |
203 | bukva = ESBYTE[bufpos+j]; |
200 | chrcat(#unicode_symbol, bukva); |
204 | chrcat(#unicode_symbol, bukva); |
201 | } |
205 | } |
202 | if (GetUnicodeSymbol(#line, #unicode_symbol, sizeof(TWebBrowser.line)-1)) { |
206 | if (GetUnicodeSymbol(#line, #unicode_symbol, sizeof(line)-1)) { |
203 | bufpos += j; |
207 | bufpos += j; |
204 | CheckForLineBreak(); |
208 | CheckForLineBreak(); |
205 | } else { |
209 | } else { |
206 | AddCharToTheLine('&'); |
210 | AddCharToTheLine('&'); |
207 | } |
211 | } |
Line 254... | Line 258... | ||
254 | if (tag.name[strlen(#tag.name)-1]=='/') tag.name[strlen(#tag.name)-1]=NULL; //for br/ !!!!!!!! |
258 | if (tag.name[strlen(#tag.name)-1]=='/') tag.name[strlen(#tag.name)-1]=NULL; //for br/ !!!!!!!! |
255 | if (tag.params) tag.parse_params(); |
259 | if (tag.params) tag.parse_params(); |
Line 256... | Line 260... | ||
256 | 260 | ||
257 | if (tag.name) { |
261 | if (tag.name) { |
258 | CheckForLineBreak(); |
262 | CheckForLineBreak(); |
259 | DrawStyle(); |
263 | Paint(); |
260 | if (tag.name) SetStyle(); |
264 | if (tag.name) SetStyle(); |
261 | } |
265 | } |
262 | break; |
266 | break; |
263 | default: |
267 | default: |
264 | AddCharToTheLine(ESBYTE[bufpos]); |
268 | AddCharToTheLine(ESBYTE[bufpos]); |
265 | } |
269 | } |
266 | } |
270 | } |
267 | DrawStyle(); |
271 | Paint(); |
268 | NewLine(); |
272 | NewLine(); |
269 | list.count = draw_y; |
273 | list.count = draw_y; |
270 | list.CheckDoesValuesOkey(); |
274 | list.CheckDoesValuesOkey(); |
271 | anchors.current = NULL; |
275 | anchors.current = NULL; |
Line 294... | Line 298... | ||
294 | line_break_pos = list.column_max/zoom - stolbec; |
298 | line_break_pos = list.column_max/zoom - stolbec; |
295 | } |
299 | } |
296 | strcpy(#new_line_text, #line + line_break_pos); |
300 | strcpy(#new_line_text, #line + line_break_pos); |
297 | line[line_break_pos] = 0x00; |
301 | line[line_break_pos] = 0x00; |
Line 298... | Line 302... | ||
298 | 302 | ||
Line 299... | Line 303... | ||
299 | DrawStyle(); |
303 | Paint(); |
300 | 304 | ||
301 | strcpy(#line, #new_line_text); |
305 | strcpy(#line, #new_line_text); |
302 | NewLine(); |
306 | NewLine(); |
Line 357... | Line 361... | ||
357 | return; |
361 | return; |
358 | } |
362 | } |
359 | if (tag.is("iframe")) && (value = tag.get_value_of("src=")) { |
363 | if (tag.is("iframe")) && (value = tag.get_value_of("src=")) { |
360 | NewLine(); |
364 | NewLine(); |
361 | strcpy(#line, "IFRAME: "); |
365 | strcpy(#line, "IFRAME: "); |
362 | DrawStyle(); |
366 | Paint(); |
363 | link=true; |
367 | link=true; |
364 | PageLinks.AddLink(value); |
368 | PageLinks.AddLink(value); |
365 | strncpy(#line, value, sizeof(TWebBrowser.line)-1); |
369 | strncpy(#line, value, sizeof(line)-1); |
366 | while (CheckForLineBreak()) {}; |
370 | while (CheckForLineBreak()) {}; |
367 | DrawStyle(); |
371 | Paint(); |
368 | link=false; |
372 | link=false; |
369 | NewLine(); |
373 | NewLine(); |
370 | } |
374 | } |
371 | if (tag.is("font")) { |
375 | if (tag.is("font")) { |
372 | style.bg_color = page_bg; |
376 | style.bg_color = page_bg; |
Line 414... | Line 418... | ||
414 | if (tag.opened) style.bg_color = 0xe4ffcb; else style.bg_color = page_bg; |
418 | if (tag.opened) style.bg_color = 0xe4ffcb; else style.bg_color = page_bg; |
415 | style.pre = tag.opened; return; |
419 | style.pre = tag.opened; return; |
416 | } |
420 | } |
417 | if (tag.is("img")) { |
421 | if (tag.is("img")) { |
418 | if (value = tag.get_value_of("src=")) strlcpy(#img_path, value, sizeof(img_path)-1); |
422 | if (value = tag.get_value_of("src=")) strlcpy(#img_path, value, sizeof(img_path)-1); |
419 | if (value = tag.get_value_of("title=")) && (strlen(value) |
423 | if (value = tag.get_value_of("title=")) && (strlen(value) |
420 | if (value = tag.get_value_of("alt=")) && (strlen(value) |
424 | if (value = tag.get_value_of("alt=")) && (strlen(value) |
421 | if (!img_path) { line=0; return; } |
425 | if (!img_path) { line=0; return; } |
422 | style.image = true; |
426 | style.image = true; |
423 | text_color_index++; |
427 | text_color_index++; |
424 | text_colors[text_color_index] = 0x9A6F29; |
428 | text_colors[text_color_index] = 0x9A6F29; |
425 | if (!line) { |
429 | if (!line) { |
Line 427... | Line 431... | ||
427 | replace_char(#img_path, '?', NULL, strlen(#img_path)); |
431 | replace_char(#img_path, '?', NULL, strlen(#img_path)); |
428 | sprintf(#line, "[%s]", #img_path+strrchr(#img_path, '/')); |
432 | sprintf(#line, "[%s]", #img_path+strrchr(#img_path, '/')); |
429 | line[50]= NULL; |
433 | line[50]= NULL; |
430 | } |
434 | } |
431 | while (CheckForLineBreak()) {}; |
435 | while (CheckForLineBreak()) {}; |
432 | DrawStyle(); |
436 | Paint(); |
433 | text_color_index--; |
437 | text_color_index--; |
434 | style.image = false; |
438 | style.image = false; |
435 | //ImgCache.Images( list.x, draw_y, list.w); |
439 | //ImgCache.Images( list.x, draw_y, list.w); |
436 | return; |
440 | return; |
437 | } |
441 | } |