Rev 7758 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 7758 | Rev 7759 | ||
---|---|---|---|
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\parce_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 | dword page_bg; |
7 | dword page_bg; |
7 | dword link_color_inactive; |
8 | dword link_color_default; |
8 | dword link_color_active; |
9 | dword link_color_active; |
9 | #include "..\TWB\links.h" |
10 | #include "..\TWB\links.h" |
Line -... | Line 11... | ||
- | 11 | ||
10 | 12 | #define BODY_MARGIN 6 |
|
Line 11... | Line 13... | ||
11 | enum { ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT}; |
13 | #define BASIC_LINE_H 18 |
12 | 14 | ||
13 | struct _style { |
15 | struct _style { |
14 | bool |
16 | bool |
15 | b, u, s, h, |
17 | b, u, s, h, |
16 | pre, |
- | |
17 | blq, |
- | |
18 | li, |
18 | pre, |
19 | li_tab, |
19 | blq, |
20 | button, |
- | |
21 | image, |
20 | button, |
22 | align; |
21 | image; |
23 | dword bg_color; |
22 | dword bg_color; |
24 | 23 | LIST tag_list; |
|
Line 25... | Line 24... | ||
25 | dword main_title; |
24 | dword tag_title; |
26 | }; |
25 | }; |
27 | 26 | ||
28 | struct TWebBrowser { |
27 | struct TWebBrowser { |
29 | llist list; |
28 | llist list; |
30 | _style style; |
29 | _style style; |
31 | DrawBufer DrawBuf; |
30 | DrawBufer DrawBuf; |
- | 31 | dword draw_y, stolbec; |
|
- | 32 | int zoom; |
|
- | 33 | dword o_bufpointer; |
|
- | 34 | int cur_encoding, custom_encoding; |
|
- | 35 | bool link, t_html, t_body; |
|
32 | dword draw_y, stolbec; |
36 | dword bufpointer; |
33 | int zoom; |
37 | dword bufsize; |
34 | dword o_bufpointer; |
38 | |
35 | void SetPageDefaults(); |
39 | void SetPageDefaults(); |
36 | void AddCharToTheLine(); |
40 | void AddCharToTheLine(); |
37 | void ParseHtml(); |
41 | void ParseHtml(); |
38 | void SetStyle(); |
42 | void SetStyle(); |
39 | void DrawStyle(); |
43 | void DrawStyle(); |
40 | void DrawPage(); |
44 | void DrawPage(); |
41 | void DrawScroller(); |
- | |
42 | void NewLine(); |
- | |
43 | bool CheckForLineBreak(); |
- | |
44 | void BufEncode(); |
45 | void DrawScroller(); |
45 | } WB1; |
- | |
46 | - | ||
47 | char line[500]; |
- | |
48 | - | ||
49 | bool link, cur_encoding, t_html, t_body; |
- | |
50 | - | ||
51 | - | ||
52 | dword bufpointer=0; |
46 | void NewLine(); |
53 | dword bufsize=0; |
47 | bool CheckForLineBreak(); |
54 | - | ||
55 | char header[150]; |
- | |
Line 56... | Line 48... | ||
56 | 48 | char line[500]; |
|
Line 57... | Line 49... | ||
57 | int body_magrin=6; |
49 | char header[150]; |
58 | int basic_line_h=22; |
50 | }; |
59 | 51 | ||
60 | scroll_bar scroll_wv = { 15,NULL,NULL,NULL,0,2,NULL,0,0,0xeeeeee,0xBBBbbb,0xeeeeee}; |
52 | scroll_bar scroll_wv = { 15,NULL,NULL,NULL,0,2,NULL,0,0,0xeeeeee,0xBBBbbb,0xeeeeee}; |
Line 61... | Line 53... | ||
61 | 53 | ||
62 | //============================================================================================ |
54 | //============================================================================================ |
63 | void TWebBrowser::DrawStyle() |
55 | void TWebBrowser::DrawStyle() |
64 | { |
56 | { |
65 | dword start_x, line_length, stolbec_len; |
57 | dword start_x, line_length, stolbec_len; |
66 | 58 | ||
67 | if (style.main_title) |
59 | if (style.tag_title) |
68 | { |
60 | { |
69 | strncpy(#header, #line, sizeof(header)-1); |
61 | strncpy(#header, #line, sizeof(TWebBrowser.header)-1); |
70 | strncat(#header, " - ", sizeof(header)-1); |
62 | strncat(#header, " - ", sizeof(TWebBrowser.header)-1); |
71 | strncat(#header, #version, sizeof(header)-1); |
63 | strncat(#header, #version, sizeof(TWebBrowser.header)-1); |
72 | line = 0; |
64 | line = 0; |
Line 73... | Line 65... | ||
73 | return; |
65 | return; |
74 | } |
66 | } |
75 | if (t_html) && (!t_body) { |
67 | if (t_html) && (!t_body) { |
76 | line = 0; |
68 | line = 0; |
77 | return; |
69 | return; |
Line 78... | Line 70... | ||
78 | } |
70 | } |
79 | 71 | ||
Line 103... | Line 95... | ||
103 | if (style.b) DrawBuf.WriteText(start_x+1, draw_y, list.font_type, text_colors[text_color_index], #line); |
95 | if (style.b) DrawBuf.WriteText(start_x+1, draw_y, list.font_type, text_colors[text_color_index], #line); |
104 | if (style.s) DrawBuf.DrawBar(start_x, list.item_h / 2 - zoom + draw_y, line_length, zoom, text_colors[text_color_index]); |
96 | if (style.s) DrawBuf.DrawBar(start_x, list.item_h / 2 - zoom + draw_y, line_length, zoom, text_colors[text_color_index]); |
105 | if (style.u) DrawBuf.DrawBar(start_x, list.item_h - zoom - zoom + draw_y, line_length, zoom, text_colors[text_color_index]); |
97 | if (style.u) DrawBuf.DrawBar(start_x, list.item_h - zoom - zoom + draw_y, line_length, zoom, text_colors[text_color_index]); |
106 | if (link) { |
98 | if (link) { |
107 | if (line[0]==' ') && (line[1]==NULL) {} else { |
99 | if (line[0]==' ') && (line[1]==NULL) {} else { |
108 | DrawBuf.DrawBar(start_x, draw_y + list.item_h - calc(zoom*2), line_length, zoom, link_color_inactive); |
100 | DrawBuf.DrawBar(start_x, draw_y + list.item_h - calc(zoom*2)-1, line_length, zoom, link_color_default); |
109 | PageLinks.AddText(start_x, draw_y + list.y, line_length, list.item_h - calc(zoom*2), UNDERLINE, zoom); |
101 | PageLinks.AddText(start_x, draw_y + list.y, line_length, list.item_h - calc(zoom*2)-1, UNDERLINE, zoom); |
110 | } |
102 | } |
111 | } |
103 | } |
112 | stolbec += stolbec_len; |
104 | stolbec += stolbec_len; |
113 | if (debug_mode) debug(#line); |
105 | if (debug_mode) debug(#line); |
114 | line = NULL; |
106 | line = NULL; |
Line 116... | Line 108... | ||
116 | } |
108 | } |
117 | //============================================================================================ |
109 | //============================================================================================ |
118 | void TWebBrowser::SetPageDefaults() |
110 | void TWebBrowser::SetPageDefaults() |
119 | { |
111 | { |
120 | style.b = style.u = style.s = style.h = style.blq = t_html = t_body = style.pre = |
112 | style.b = style.u = style.s = style.h = style.blq = t_html = t_body = style.pre = |
121 | style.li = link = text_color_index = text_colors[0] = style.li_tab = style.main_title = false; |
113 | link = text_color_index = text_colors[0] = style.tag_title = false; |
122 | style.align = ALIGN_LEFT; |
114 | style.tag_list.reset(); |
123 | link_color_inactive = 0x0000FF; |
115 | link_color_default = 0x0000FF; |
124 | link_color_active = 0xFF0000; |
116 | link_color_active = 0xFF0000; |
125 | page_bg = 0xFFFFFF; |
117 | page_bg = 0xFFFFFF; |
126 | style.bg_color = page_bg; |
118 | style.bg_color = page_bg; |
127 | DrawBuf.Fill(0, page_bg); |
119 | DrawBuf.Fill(0, page_bg); |
128 | PageLinks.Clear(); |
120 | PageLinks.Clear(); |
129 | anchors.clear(); |
121 | anchors.clear(); |
130 | header = NULL; |
122 | header = NULL; |
131 | cur_encoding = CH_NULL; |
123 | cur_encoding = CH_CP866; |
132 | draw_y = body_magrin; |
124 | draw_y = BODY_MARGIN; |
133 | stolbec = 0; |
125 | stolbec = 0; |
134 | line = 0; |
126 | line = 0; |
135 | zoom = 1; |
127 | zoom = 1; |
136 | //hold original buffer |
128 | //hold original buffer |
137 | if (o_bufpointer) o_bufpointer=free(o_bufpointer); |
129 | if (o_bufpointer) o_bufpointer=free(o_bufpointer); |
138 | o_bufpointer = malloc(bufsize); |
130 | o_bufpointer = malloc(bufsize); |
139 | memmov(o_bufpointer, bufpointer, bufsize); |
131 | memmov(o_bufpointer, bufpointer, bufsize); |
- | 132 | if (custom_encoding != -1) { |
|
- | 133 | cur_encoding = custom_encoding; |
|
- | 134 | bufpointer = ChangeCharset(cur_encoding*10+#charsets, "CP866", bufpointer); |
|
- | 135 | } |
|
140 | } |
136 | } |
141 | //============================================================================================ |
137 | //============================================================================================ |
142 | void TWebBrowser::AddCharToTheLine(unsigned char _char) |
138 | void TWebBrowser::AddCharToTheLine(unsigned char _char) |
143 | { |
139 | { |
144 | dword line_len; |
140 | dword line_len; |
Line 147... | Line 143... | ||
147 | if (!style.pre) && (_char == ' ') |
143 | if (!style.pre) && (_char == ' ') |
148 | { |
144 | { |
149 | if (line[line_len-1]==' ') return; //no double spaces |
145 | if (line[line_len-1]==' ') return; //no double spaces |
150 | if (!stolbec) && (!line) return; //no paces at the beginning of the line |
146 | if (!stolbec) && (!line) return; //no paces at the beginning of the line |
151 | } |
147 | } |
152 | if (line_len < sizeof(line)) chrcat(#line, _char); |
148 | if (line_len < sizeof(TWebBrowser.line)) chrcat(#line, _char); |
153 | CheckForLineBreak(); |
149 | CheckForLineBreak(); |
154 | } |
150 | } |
155 | //============================================================================================ |
151 | //============================================================================================ |
156 | void TWebBrowser::ParseHtml(){ |
152 | void TWebBrowser::ParseHtml(dword _bufpointer, _bufsize){ |
157 | word bukva[2]; |
153 | word bukva[2]; |
158 | char unicode_symbol[10]; |
154 | char unicode_symbol[10]; |
159 | dword unicode_symbol_result; |
155 | dword unicode_symbol_result; |
160 | dword j; |
156 | dword j; |
161 | bool ignor_param=false; |
157 | bool ignor_param=false; |
162 | int tab_len; |
158 | int tab_len; |
163 | dword bufpos; |
159 | dword bufpos; |
- | 160 | bufsize = _bufsize; |
|
- | 161 | bufpointer = malloc(bufsize); |
|
- | 162 | memmov(bufpointer, _bufpointer, bufsize); |
|
164 | SetPageDefaults(); |
163 | SetPageDefaults(); |
165 | if (strstri(bufpointer, " |
164 | if (strstri(bufpointer, " |
166 | t_body = true; |
165 | t_body = true; |
167 | if (strstri(bufpointer, " |
166 | if (strstri(bufpointer, " |
168 | } |
167 | } |
Line 192... | Line 191... | ||
192 | for (j=1, unicode_symbol=0; (ESBYTE[bufpos+j]<>';') && (j<8); j++) |
191 | for (j=1, unicode_symbol=0; (ESBYTE[bufpos+j]<>';') && (j<8); j++) |
193 | { |
192 | { |
194 | bukva = ESBYTE[bufpos+j]; |
193 | bukva = ESBYTE[bufpos+j]; |
195 | chrcat(#unicode_symbol, bukva); |
194 | chrcat(#unicode_symbol, bukva); |
196 | } |
195 | } |
197 | if (GetUnicodeSymbol(#line, #unicode_symbol, sizeof(line)-1)) { |
196 | if (GetUnicodeSymbol(#line, #unicode_symbol, sizeof(TWebBrowser.line)-1)) { |
198 | bufpos += j; |
197 | bufpos += j; |
199 | CheckForLineBreak(); |
198 | CheckForLineBreak(); |
200 | } else { |
199 | } else { |
201 | AddCharToTheLine('&'); |
200 | AddCharToTheLine('&'); |
202 | } |
201 | } |
Line 262... | Line 261... | ||
262 | DrawStyle(); |
261 | DrawStyle(); |
263 | NewLine(); |
262 | NewLine(); |
264 | list.count = draw_y; |
263 | list.count = draw_y; |
265 | list.CheckDoesValuesOkey(); |
264 | list.CheckDoesValuesOkey(); |
266 | anchors.current = NULL; |
265 | anchors.current = NULL; |
- | 266 | custom_encoding = -1; |
|
267 | if (!header) { |
267 | if (!header) { |
268 | strncpy(#header, #version, sizeof(header)-1); |
268 | strncpy(#header, #version, sizeof(TWebBrowser.header)-1); |
269 | DrawTitle(#header); |
269 | DrawTitle(#header); |
270 | } |
270 | } |
271 | } |
271 | } |
272 | //============================================================================================ |
272 | //============================================================================================ |
273 | bool TWebBrowser::CheckForLineBreak() |
273 | bool TWebBrowser::CheckForLineBreak() |
Line 282... | Line 282... | ||
282 | if (line_break_pos*zoom + stolbec > list.column_max) { |
282 | if (line_break_pos*zoom + stolbec > list.column_max) { |
283 | line_break_pos = list.column_max/zoom - stolbec; |
283 | line_break_pos = list.column_max/zoom - stolbec; |
284 | while(line_break_pos) && (line[line_break_pos]!=' ') line_break_pos--; |
284 | while(line_break_pos) && (line[line_break_pos]!=' ') line_break_pos--; |
285 | } |
285 | } |
286 | //Maybe a new line is too big for the whole new line? Then we have to split it |
286 | //Maybe a new line is too big for the whole new line? Then we have to split it |
287 | if (!line_break_pos) && (style.li_tab*5 + strlen(#line) * zoom >= list.column_max) { |
287 | if (!line_break_pos) && (style.tag_list.level*5 + strlen(#line) * zoom >= list.column_max) { |
288 | line_break_pos = list.column_max/zoom - stolbec; |
288 | line_break_pos = list.column_max/zoom - stolbec; |
289 | } |
289 | } |
290 | strcpy(#new_line_text, #line + line_break_pos); |
290 | strcpy(#new_line_text, #line + line_break_pos); |
291 | line[line_break_pos] = 0x00; |
291 | line[line_break_pos] = 0x00; |
Line 324... | Line 324... | ||
324 | } |
324 | } |
325 | if (!tag.opened) strcat(#line, "\" "); |
325 | if (!tag.opened) strcat(#line, "\" "); |
326 | return; |
326 | return; |
327 | } |
327 | } |
328 | if (tag.is("title")) { |
328 | if (tag.is("title")) { |
329 | style.main_title = tag.opened; |
329 | style.tag_title = tag.opened; |
330 | if (!tag.opened) DrawTitle(#header); |
330 | if (!tag.opened) DrawTitle(#header); |
331 | return; |
331 | return; |
332 | } |
332 | } |
333 | if (tag.is("body")) { |
333 | if (tag.is("body")) { |
334 | t_body = tag.opened; |
334 | t_body = tag.opened; |
335 | if (value = tag.get_value_of("link=")) link_color_inactive = GetColor(value); |
335 | if (value = tag.get_value_of("link=")) link_color_default = GetColor(value); |
336 | if (value = tag.get_value_of("alink=")) link_color_active = GetColor(value); |
336 | if (value = tag.get_value_of("alink=")) link_color_active = GetColor(value); |
337 | if (value = tag.get_value_of("text=")) text_colors[0]=GetColor(value); |
337 | if (value = tag.get_value_of("text=")) text_colors[0]=GetColor(value); |
338 | if (value = tag.get_value_of("bgcolor=")) { |
338 | if (value = tag.get_value_of("bgcolor=")) { |
339 | style.bg_color = page_bg = GetColor(value); |
339 | style.bg_color = page_bg = GetColor(value); |
340 | DrawBuf.Fill(0, page_bg); |
340 | DrawBuf.Fill(0, page_bg); |
Line 348... | Line 348... | ||
348 | if (value = tag.get_value_of("href=")) && (!strstr(value,"javascript:")) |
348 | if (value = tag.get_value_of("href=")) && (!strstr(value,"javascript:")) |
349 | { |
349 | { |
350 | text_color_index++; |
350 | text_color_index++; |
351 | text_colors[text_color_index] = text_colors[text_color_index-1]; |
351 | text_colors[text_color_index] = text_colors[text_color_index-1]; |
352 | link = 1; |
352 | link = 1; |
353 | text_colors[text_color_index] = link_color_inactive; |
353 | text_colors[text_color_index] = link_color_default; |
354 | PageLinks.AddLink(value); |
354 | PageLinks.AddLink(value); |
355 | } |
355 | } |
356 | } else { |
356 | } else { |
357 | link = 0; |
357 | link = 0; |
358 | IF(text_color_index > 0) text_color_index--; |
358 | IF(text_color_index > 0) text_color_index--; |
Line 392... | Line 392... | ||
392 | if (tag.is("button")) { style.button = tag.opened; stolbec++; return; } |
392 | if (tag.is("button")) { style.button = tag.opened; stolbec++; return; } |
393 | if (tag.is("u")) || (tag.is("ins")) { style.u=tag.opened; return;} |
393 | if (tag.is("u")) || (tag.is("ins")) { style.u=tag.opened; return;} |
394 | if (tag.is("s")) || (tag.is("strike")) || (tag.is("del")) { style.s=tag.opened; return; } |
394 | if (tag.is("s")) || (tag.is("strike")) || (tag.is("del")) { style.s=tag.opened; return; } |
395 | if (tag.is("dd")) { stolbec += 5; return; } |
395 | if (tag.is("dd")) { stolbec += 5; return; } |
396 | if (tag.is("blockquote")) { style.blq = tag.opened; return; } |
396 | if (tag.is("blockquote")) { style.blq = tag.opened; return; } |
397 | if (tag.is("pre")) || (tag.is("code")) { style.pre = tag.opened; return; } |
397 | if (tag.is("pre")) { style.pre = tag.opened; return; } |
- | 398 | if (tag.is("code")) { |
|
- | 399 | if (tag.opened) style.bg_color = 0xe4ffcb; else style.bg_color = page_bg; |
|
- | 400 | style.pre = tag.opened; return; |
|
- | 401 | } |
|
398 | if (tag.is("img")) { |
402 | if (tag.is("img")) { |
399 | if (value = tag.get_value_of("src=")) strlcpy(#img_path, value, sizeof(img_path)-1); |
403 | if (value = tag.get_value_of("src=")) strlcpy(#img_path, value, sizeof(img_path)-1); |
400 | if (value = tag.get_value_of("title=")) && (strlen(value) |
404 | if (value = tag.get_value_of("title=")) && (strlen(value) |
401 | if (value = tag.get_value_of("alt=")) && (strlen(value) |
405 | if (value = tag.get_value_of("alt=")) && (strlen(value) |
402 | if (!img_path) { line=0; return; } |
406 | if (!img_path) { line=0; return; } |
403 | style.image = true; |
407 | style.image = true; |
404 | text_color_index++; |
408 | text_color_index++; |
405 | text_colors[text_color_index] = 0x9A6F29; |
409 | text_colors[text_color_index] = 0x9A6F29; |
406 | if (!line) { |
410 | if (!line) { |
Line 411... | Line 415... | ||
411 | } |
415 | } |
412 | while (CheckForLineBreak()) {}; |
416 | while (CheckForLineBreak()) {}; |
413 | DrawStyle(); |
417 | DrawStyle(); |
414 | text_color_index--; |
418 | text_color_index--; |
415 | style.image = false; |
419 | style.image = false; |
416 | //ImgCache.Images( list.x, draw_y, WB1.list.w); |
420 | //ImgCache.Images( list.x, draw_y, list.w); |
417 | return; |
421 | return; |
418 | } |
422 | } |
419 | if (tag.is("h4")) { |
423 | if (tag.is("h4")) { |
420 | NewLine(); |
424 | NewLine(); |
- | 425 | NewLine(); |
|
421 | style.h = tag.opened; |
426 | style.h = tag.opened; |
422 | style.b = tag.opened; |
427 | style.b = tag.opened; |
423 | } |
428 | } |
424 | if (tag.is("h1")) || (tag.is("h2")) || (tag.is("h3")) || (tag.is("caption")) { |
429 | if (tag.is("h1")) || (tag.is("h2")) || (tag.is("h3")) || (tag.is("caption")) { |
425 | style.h = tag.opened; |
430 | style.h = tag.opened; |
426 | if (tag.opened) { |
431 | if (tag.opened) { |
427 | NewLine(); |
432 | if (!style.pre) NewLine(); |
428 | draw_y += 10; |
433 | draw_y += 10; |
429 | WB1.zoom=2; |
434 | zoom=2; |
430 | WB1.list.font_type |= 10011001b; |
435 | list.font_type |= 10011001b; |
431 | list.item_h = basic_line_h * 2 - 2; |
436 | list.item_h = BASIC_LINE_H * 2 - 2; |
432 | if (tag.is("h1")) style.b = true; |
437 | if (tag.is("h1")) style.b = true; |
433 | } else { |
438 | } else { |
434 | if (tag.is("h1")) style.b = false; |
439 | if (tag.is("h1")) style.b = false; |
435 | NewLine(); |
440 | NewLine(); |
436 | WB1.zoom=1; |
441 | zoom=1; |
437 | WB1.list.font_type = 10011000b; |
442 | list.font_type = 10011000b; |
438 | list.item_h = basic_line_h; |
443 | list.item_h = BASIC_LINE_H; |
439 | } |
444 | } |
440 | return; |
445 | return; |
441 | } |
446 | } |
442 | if (tag.is("dt")) { |
447 | if (tag.is("dt")) { |
443 | style.li = tag.opened; |
448 | style.tag_list.upd_level(tag.opened, DT); |
444 | if (tag.opened) NewLine(); |
449 | if (tag.opened) NewLine(); |
445 | return; |
450 | return; |
446 | } |
451 | } |
447 | if (tag.is("li")) || (tag.is("dt")) |
452 | if (tag.is("ul")) { |
448 | { |
- | |
449 | style.li = tag.opened; |
453 | style.tag_list.upd_level(tag.opened, UL); |
450 | if (tag.opened) |
- | |
451 | { |
- | |
452 | if (style.li_tab==0) style.li_tab++; |
454 | if (!tag.opened) && (!style.pre) NewLine(); |
453 | NewLine(); |
455 | return; |
454 | stolbec = style.li_tab * 5 - 2; |
- | |
455 | strcpy(#line, "\31 "); |
- | |
456 | //stolbec-=2; |
- | |
457 | } |
456 | } |
- | 457 | if (tag.is("ol")) { |
|
- | 458 | style.tag_list.upd_level(tag.opened, OL); |
|
- | 459 | if (!tag.opened) && (!style.pre) NewLine(); |
|
458 | return; |
460 | return; |
459 | } |
461 | } |
460 | if (tag.is("ul")) || (tag.is("ol")) { |
462 | if (tag.is("li")) && (tag.opened) |
461 | if (!tag.opened) |
- | |
462 | { |
463 | { |
- | 464 | if (!style.tag_list.level) style.tag_list.upd_level(1, UL); |
|
463 | style.li = false; |
465 | if (!style.pre) NewLine(); |
464 | if (style.li_tab>0) style.li_tab--; |
466 | if (style.tag_list.get_order_type() == UL) { |
465 | NewLine(); |
467 | strcpy(#line, "\31 "); |
- | 468 | stolbec = style.tag_list.level * 5 - 2; |
|
466 | } |
469 | } |
467 | else { |
470 | if (style.tag_list.get_order_type() == OL) { |
- | 471 | sprintf(#line, "%i. ", style.tag_list.inc_counter()); |
|
468 | if (style.li_tab<5) style.li_tab++; |
472 | stolbec = style.tag_list.level * 5 - strlen(#line); |
469 | } |
473 | } |
- | 474 | return; |
|
470 | } |
475 | } |
471 | if (tag.is("hr")) { |
476 | if (tag.is("hr")) { |
472 | if (value = tag.get_value_of("color=")) EDI = GetColor(value); else EDI = 0x999999; |
477 | if (value = tag.get_value_of("color=")) EDI = GetColor(value); else EDI = 0x999999; |
473 | $push edi; |
478 | $push edi; |
474 | NewLine(); |
479 | NewLine(); |
Line 477... | Line 482... | ||
477 | DrawBuf.DrawBar(5, draw_y - 1, list.w-10, 1, EDI); |
482 | DrawBuf.DrawBar(5, draw_y - 1, list.w-10, 1, EDI); |
478 | NewLine(); |
483 | NewLine(); |
479 | draw_y += 10; |
484 | draw_y += 10; |
480 | return; |
485 | return; |
481 | } |
486 | } |
482 | if (tag.is("meta")) || (tag.is("?xml")) { |
487 | if (custom_encoding == -1) && (tag.is("meta")) || (tag.is("?xml")) { |
483 | meta_encoding = CH_NULL; |
488 | meta_encoding = CH_CP866; |
484 | if (value = tag.get_value_of("charset=")) || (value = tag.get_value_of("content=")) || (value = tag.get_value_of("encoding=")) |
489 | if (value = tag.get_value_of("charset=")) || (value = tag.get_value_of("content=")) || (value = tag.get_value_of("encoding=")) |
485 | { |
490 | { |
486 | value += strrchr(value, '='); //search in content= |
491 | value += strrchr(value, '='); //search in content= |
487 | strlwr(value); |
492 | strlwr(value); |
488 | if (streq(value,"utf-8")) || (streq(value,"utf8")) meta_encoding = CH_UTF8; |
493 | if (streq(value,"utf-8")) || (streq(value,"utf8")) meta_encoding = CH_UTF8; |
489 | else if (streq(value,"windows-1251")) || (streq(value,"windows1251")) meta_encoding = CH_CP1251; |
494 | else if (streq(value,"windows-1251")) || (streq(value,"windows1251")) meta_encoding = CH_CP1251; |
490 | else if (streq(value,"dos")) || (streq(value,"cp-866")) meta_encoding = CH_CP866; |
495 | else if (streq(value,"dos")) || (streq(value,"cp-866")) meta_encoding = CH_CP866; |
491 | else if (streq(value,"iso-8859-5")) || (streq(value,"iso8859-5")) meta_encoding = CH_ISO8859_5; |
496 | else if (streq(value,"iso-8859-5")) || (streq(value,"iso8859-5")) meta_encoding = CH_ISO8859_5; |
492 | else if (streq(value,"koi8-r")) || (streq(value,"koi8-u")) meta_encoding = CH_KOI8; |
497 | else if (streq(value,"koi8-r")) || (streq(value,"koi8-u")) meta_encoding = CH_KOI8; |
493 | } |
498 | } |
494 | if (meta_encoding!=CH_NULL) { |
499 | if (meta_encoding != CH_CP866) && (cur_encoding != meta_encoding) { |
495 | BufEncode(meta_encoding); |
500 | cur_encoding = meta_encoding; |
- | 501 | bufpointer = ChangeCharset(cur_encoding*10+#charsets, "CP866", bufpointer); |
|
496 | if (header) { |
502 | if (header) { |
497 | ChangeCharset(charsets[cur_encoding], "CP866", #header); |
503 | ChangeCharset(cur_encoding*10+#charsets, "CP866", #header); |
498 | DrawTitle(#header); |
504 | DrawTitle(#header); |
499 | } |
505 | } |
500 | } |
506 | } |
501 | return; |
507 | return; |
502 | } |
508 | } |
503 | } |
509 | } |
504 | //============================================================================================ |
510 | //============================================================================================ |
505 | void TWebBrowser::BufEncode(dword set_new_encoding) |
- | |
506 | { |
- | |
507 | if (cur_encoding != set_new_encoding) { |
- | |
508 | cur_encoding = set_new_encoding; |
- | |
509 | bufpointer = ChangeCharset(charsets[cur_encoding], "CP866", bufpointer); |
- | |
510 | } |
- | |
511 | } |
- | |
512 | //============================================================================================ |
- | |
513 | void TWebBrowser::DrawScroller() |
511 | void TWebBrowser::DrawScroller() |
514 | { |
512 | { |
515 | scroll_wv.max_area = list.count; |
513 | scroll_wv.max_area = list.count; |
516 | scroll_wv.cur_area = list.visible; |
514 | scroll_wv.cur_area = list.visible; |
517 | scroll_wv.position = list.first; |
515 | scroll_wv.position = list.first; |
Line 525... | Line 523... | ||
525 | void TWebBrowser::NewLine() |
523 | void TWebBrowser::NewLine() |
526 | { |
524 | { |
527 | dword onleft, ontop; |
525 | dword onleft, ontop; |
528 | static int empty_line=0; |
526 | static int empty_line=0; |
Line 529... | Line 527... | ||
529 | 527 | ||
Line 530... | Line 528... | ||
530 | if (!stolbec) && (draw_y==body_magrin) return; |
528 | if (!stolbec) && (draw_y==BODY_MARGIN) return; |
531 | 529 | ||
532 | if (style.li) && (stolbec == style.li_tab * 5) { |
530 | if (style.tag_list.level) && (stolbec == style.tag_list.level * 5) { |
533 | if (empty_line<1) empty_line++; |
531 | if (empty_line<1) empty_line++; |
534 | else return; |
532 | else return; |
535 | } else if (!stolbec) { |
533 | } else if (!stolbec) { |
536 | if (empty_line<1) empty_line++; |
534 | if (empty_line<1) empty_line++; |
537 | else return; |
535 | else return; |
538 | } else { |
536 | } else { |
Line 539... | Line 537... | ||
539 | empty_line=0; |
537 | empty_line=0; |
540 | } |
538 | } |
541 | 539 | ||
542 | onleft = list.x + body_magrin; |
540 | onleft = list.x + BODY_MARGIN; |
543 | ontop = draw_y + list.y; |
541 | ontop = draw_y + list.y; |
544 | if (t_html) && (!t_body) return; |
542 | if (t_html) && (!t_body) return; |
545 | draw_y += list.item_h; |
543 | draw_y += list.item_h; |
546 | if (style.blq) stolbec = 6; else stolbec = 0; |
544 | if (style.blq) stolbec = 6; else stolbec = 0; |
547 | if (style.li) stolbec = style.li_tab * 5; |
545 | stolbec += style.tag_list.level * 5; |
548 | if (debug_mode) debugln(NULL); |
546 | if (debug_mode) debugln(NULL); |
549 | } |
547 | } |