Rev 8440 | Rev 8444 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 8440 | Rev 8443 | ||
---|---|---|---|
1 | #include "TWB\colors.h" |
1 | #include "TWB\colors.h" |
2 | #include "TWB\anchors.h" |
2 | #include "TWB\anchors.h" |
3 | #include "TWB\parse_tag.h" |
3 | #include "TWB\parse_tag.h" |
4 | #include "TWB\special.h" |
4 | #include "TWB\special.h" |
5 | #include "TWB\tag_list.h" |
5 | #include "TWB\tag_list.h" |
6 | dword page_bg; |
6 | dword page_bg; |
7 | dword link_color_default; |
7 | dword link_color_default; |
8 | dword link_color_active; |
8 | dword link_color_active; |
9 | #include "TWB\links.h" |
9 | #include "TWB\links.h" |
10 | 10 | ||
11 | #define BODY_MARGIN 6 |
11 | #define BODY_MARGIN 6 |
12 | #define BASIC_LINE_H 18 |
12 | #define BASIC_LINE_H 18 |
13 | 13 | ||
14 | CANVAS canvas; |
14 | CANVAS canvas; |
15 | char line[500]; |
15 | char line[500]; |
16 | 16 | ||
17 | struct STYLE { |
17 | struct STYLE { |
18 | bool |
18 | bool |
19 | b, u, s, h, |
19 | b, u, s, h, |
20 | font, |
20 | font, |
21 | pre, |
21 | pre, |
22 | blq, |
22 | blq, |
23 | button, |
23 | button, |
24 | image; |
24 | image; |
25 | dword bg_color; |
25 | dword bg_color; |
26 | LIST tag_list; |
26 | LIST tag_list; |
27 | dword title; |
27 | dword title; |
28 | void reset(); |
28 | void reset(); |
29 | }; |
29 | }; |
30 | 30 | ||
31 | void STYLE::reset() |
31 | void STYLE::reset() |
32 | { |
32 | { |
33 | b = u = s = h = blq = pre = title = false; |
33 | b = u = s = h = blq = pre = title = false; |
34 | font = false; |
34 | font = false; |
35 | tag_list.reset(); |
35 | tag_list.reset(); |
36 | } |
36 | } |
37 | 37 | ||
38 | struct TWebBrowser { |
38 | struct TWebBrowser { |
39 | llist list; |
39 | llist list; |
40 | STYLE style; |
40 | STYLE style; |
41 | dword draw_y, stolbec; |
41 | dword draw_y, stolbec; |
42 | int zoom; |
42 | int zoom; |
43 | dword o_bufpointer; |
43 | dword o_bufpointer; |
44 | int cur_encoding, custom_encoding; |
44 | int cur_encoding, custom_encoding; |
45 | bool link, t_html, t_body; |
45 | bool link, t_html, t_body; |
46 | dword bufpointer; |
46 | dword bufpointer; |
47 | dword bufsize; |
47 | dword bufsize; |
48 | dword is_html; |
48 | dword is_html; |
49 | collection img_url; |
49 | collection img_url; |
50 | char header[150]; |
50 | char header[150]; |
51 | char redirect[URL_SIZE]; |
51 | char redirect[URL_SIZE]; |
52 | 52 | ||
53 | void Paint(); |
53 | void Paint(); |
54 | void SetPageDefaults(); |
54 | void SetPageDefaults(); |
55 | void AddCharToTheLine(); |
55 | void AddCharToTheLine(); |
56 | void ParseHtml(); |
56 | void ParseHtml(); |
57 | void SetStyle(); |
57 | void SetStyle(); |
58 | bool CheckForLineBreak(); |
58 | bool CheckForLineBreak(); |
59 | void NewLine(); |
59 | void NewLine(); |
60 | void ChangeEncoding(); |
60 | void ChangeEncoding(); |
61 | void DrawPage(); |
61 | void DrawPage(); |
62 | 62 | ||
63 | void tag_a(); |
63 | void tag_a(); |
64 | void tag_p(); |
64 | void tag_p(); |
65 | void tag_img(); |
65 | void tag_img(); |
66 | void tag_div(); |
66 | void tag_div(); |
67 | void tag_h1234_caption(); |
67 | void tag_h1234_caption(); |
68 | void tag_ol_ul_dt(); |
68 | void tag_ol_ul_dt(); |
69 | void tag_li(); |
69 | void tag_li(); |
70 | void tag_q(); |
70 | void tag_q(); |
71 | void tag_hr(); |
71 | void tag_hr(); |
72 | void tag_code(); |
72 | void tag_code(); |
73 | void tag_meta_xml(); |
73 | void tag_meta_xml(); |
74 | void tag_body(); |
74 | void tag_body(); |
75 | void tag_iframe(); |
75 | void tag_iframe(); |
76 | void tag_title(); |
76 | void tag_title(); |
77 | void tag_font(); |
77 | void tag_font(); |
78 | }; |
78 | }; |
79 | 79 | ||
80 | #include "TWB\set_style.h" |
80 | #include "TWB\set_style.h" |
81 | 81 | ||
82 | //============================================================================================ |
82 | //============================================================================================ |
83 | void TWebBrowser::Paint() |
83 | void TWebBrowser::Paint() |
84 | { |
84 | { |
85 | dword start_x, line_length, stolbec_len; |
85 | dword start_x, line_length, stolbec_len; |
86 | dword text_color__; |
86 | dword text_color__; |
87 | 87 | ||
88 | if (style.title) |
88 | if (style.title) |
89 | { |
89 | { |
90 | strncpy(#header, #line, sizeof(TWebBrowser.header)-1); |
90 | strncpy(#header, #line, sizeof(TWebBrowser.header)-1); |
91 | strncat(#header, " - ", sizeof(TWebBrowser.header)-1); |
91 | strncat(#header, " - ", sizeof(TWebBrowser.header)-1); |
92 | strncat(#header, #version, sizeof(TWebBrowser.header)-1); |
92 | strncat(#header, #version, sizeof(TWebBrowser.header)-1); |
93 | line = 0; |
93 | line = 0; |
94 | return; |
94 | return; |
95 | } |
95 | } |
96 | if (t_html) && (!t_body) { |
96 | if (t_html) && (!t_body) { |
97 | line = 0; |
97 | line = 0; |
98 | return; |
98 | return; |
99 | } |
99 | } |
100 | 100 | ||
101 | if (line) |
101 | if (line) |
102 | { |
102 | { |
103 | start_x = stolbec * list.font_w + BODY_MARGIN + list.x; |
103 | start_x = stolbec * list.font_w + BODY_MARGIN + list.x; |
104 | stolbec_len = strlen(#line) * zoom; |
104 | stolbec_len = strlen(#line) * zoom; |
105 | line_length = stolbec_len * list.font_w; |
105 | line_length = stolbec_len * list.font_w; |
106 | 106 | ||
107 | if (style.bg_color!=page_bg) { |
107 | if (style.bg_color!=page_bg) { |
108 | canvas.DrawBar(start_x, draw_y, line_length, list.item_h, style.bg_color); |
108 | canvas.DrawBar(start_x, draw_y, line_length, list.item_h, style.bg_color); |
109 | } |
109 | } |
110 | 110 | ||
111 | if (style.image) { |
111 | if (style.image) { |
112 | canvas.DrawBar(start_x, draw_y, line_length, list.item_h-1, 0xF9DBCB); |
112 | canvas.DrawBar(start_x, draw_y, line_length, list.item_h-1, 0xF9DBCB); |
113 | } |
113 | } |
114 | if (style.button) { |
114 | if (style.button) { |
115 | canvas.DrawBar(start_x, draw_y, line_length, list.item_h - calc(zoom*2), 0xCCCccc); |
115 | canvas.DrawBar(start_x, draw_y, line_length, list.item_h - calc(zoom*2), 0xCCCccc); |
116 | canvas.DrawBar(start_x, draw_y + list.item_h - calc(zoom*2), line_length, zoom, 0x999999); |
116 | canvas.DrawBar(start_x, draw_y + list.item_h - calc(zoom*2), line_length, zoom, 0x999999); |
117 | } |
117 | } |
118 | 118 | ||
119 | text_color__ = text_colors.get_last(); |
119 | text_color__ = text_colors.get_last(); |
120 | if (link) && (text_color__ == text_colors.get(0)) text_color__ = link_color_default; |
120 | if (link) && (text_color__ == text_colors.get(0)) text_color__ = link_color_default; |
121 | 121 | ||
122 | canvas.WriteText(start_x, draw_y, list.font_type, text_color__, #line, NULL); |
122 | canvas.WriteText(start_x, draw_y, list.font_type, text_color__, #line, NULL); |
123 | if (style.b) canvas.WriteText(start_x+1, draw_y, list.font_type, text_color__, #line, NULL); |
123 | if (style.b) canvas.WriteText(start_x+1, draw_y, list.font_type, text_color__, #line, NULL); |
124 | if (style.s) canvas.DrawBar(start_x, list.item_h / 2 - zoom + draw_y, line_length, zoom, text_color__); |
124 | if (style.s) canvas.DrawBar(start_x, list.item_h / 2 - zoom + draw_y, line_length, zoom, text_color__); |
125 | if (style.u) canvas.DrawBar(start_x, list.item_h - zoom - zoom + draw_y, line_length, zoom, text_color__); |
125 | if (style.u) canvas.DrawBar(start_x, list.item_h - zoom - zoom + draw_y, line_length, zoom, text_color__); |
126 | if (link) { |
126 | if (link) { |
127 | if (line[0]==' ') && (line[1]==NULL) {} else { |
127 | if (line[0]==' ') && (line[1]==NULL) {} else { |
128 | canvas.DrawBar(start_x, draw_y + list.item_h - calc(zoom*2)-1, line_length, zoom, link_color_default); |
128 | canvas.DrawBar(start_x, draw_y + list.item_h - calc(zoom*2)-1, line_length, zoom, link_color_default); |
129 | links.add_text(start_x, draw_y + list.y, line_length, list.item_h - calc(zoom*2)-1, zoom); |
129 | links.add_text(start_x, draw_y + list.y, line_length, list.item_h - calc(zoom*2)-1, zoom); |
130 | } |
130 | } |
131 | } |
131 | } |
132 | stolbec += stolbec_len; |
132 | stolbec += stolbec_len; |
133 | if (debug_mode) debugln(#line); |
133 | if (debug_mode) debugln(#line); |
134 | line = NULL; |
134 | line = NULL; |
135 | } |
135 | } |
136 | } |
136 | } |
137 | //============================================================================================ |
137 | //============================================================================================ |
138 | void TWebBrowser::SetPageDefaults() |
138 | void TWebBrowser::SetPageDefaults() |
139 | { |
139 | { |
140 | t_html = t_body = link = false; |
140 | t_html = t_body = link = false; |
141 | style.reset(); |
141 | style.reset(); |
142 | link_color_default = 0x0000FF; |
142 | link_color_default = 0x0000FF; |
143 | link_color_active = 0xFF0000; |
143 | link_color_active = 0xFF0000; |
144 | page_bg = 0xffEBE8E9; //E0E3E3 EBE8E9 |
144 | style.bg_color = page_bg = 0xffEBE8E9; //E0E3E3 EBE8E9 |
145 | style.bg_color = page_bg; |
- | |
146 | canvas.Fill(0, page_bg); |
145 | canvas.Fill(0, page_bg); |
147 | links.clear(); |
146 | links.clear(); |
148 | anchors.clear(); |
147 | anchors.clear(); |
149 | img_url.drop(); |
148 | img_url.drop(); |
150 | text_colors.drop(); |
149 | text_colors.drop(); |
151 | text_colors.add(0); |
150 | text_colors.add(0); |
152 | header = NULL; |
151 | header = NULL; |
153 | cur_encoding = CH_CP866; |
152 | cur_encoding = CH_CP866; |
154 | draw_y = BODY_MARGIN; |
153 | draw_y = BODY_MARGIN; |
155 | stolbec = 0; |
154 | stolbec = 0; |
156 | line = 0; |
155 | line = 0; |
157 | zoom = 1; |
156 | zoom = 1; |
158 | redirect = '\0'; |
157 | redirect = '\0'; |
159 | //hold original buffer |
158 | //hold original buffer |
160 | if (o_bufpointer) o_bufpointer=free(o_bufpointer); |
159 | if (o_bufpointer) o_bufpointer=free(o_bufpointer); |
161 | o_bufpointer = malloc(bufsize); |
160 | o_bufpointer = malloc(bufsize); |
162 | memmov(o_bufpointer, bufpointer, bufsize); |
161 | memmov(o_bufpointer, bufpointer, bufsize); |
163 | if (custom_encoding != -1) { |
162 | if (custom_encoding != -1) { |
164 | cur_encoding = custom_encoding; |
163 | cur_encoding = custom_encoding; |
165 | bufpointer = ChangeCharset(cur_encoding, "CP866", bufpointer); |
164 | bufpointer = ChangeCharset(cur_encoding, "CP866", bufpointer); |
166 | } |
165 | } |
167 | } |
166 | } |
168 | //============================================================================================ |
167 | //============================================================================================ |
169 | void TWebBrowser::AddCharToTheLine(unsigned char _char) |
168 | void TWebBrowser::AddCharToTheLine(unsigned char _char) |
170 | { |
169 | { |
171 | dword line_len; |
170 | dword line_len; |
172 | if (_char<=15) _char=' '; |
171 | if (_char<=15) _char=' '; |
173 | line_len = strlen(#line); |
172 | line_len = strlen(#line); |
174 | if (!style.pre) && (_char == ' ') |
173 | if (!style.pre) && (_char == ' ') |
175 | { |
174 | { |
176 | if (line[line_len-1]==' ') return; //no double spaces |
175 | if (line[line_len-1]==' ') return; //no double spaces |
177 | if (!stolbec) && (!line) return; //no paces at the beginning of the line |
176 | if (!stolbec) && (!line) return; //no paces at the beginning of the line |
178 | if (link) && (line_len==0) return; |
177 | if (link) && (line_len==0) return; |
179 | } |
178 | } |
180 | if (line_len < sizeof(line)) chrcat(#line, _char); |
179 | if (line_len < sizeof(line)) chrcat(#line, _char); |
181 | CheckForLineBreak(); |
180 | CheckForLineBreak(); |
182 | } |
181 | } |
183 | //============================================================================================ |
182 | //============================================================================================ |
184 | void TWebBrowser::ParseHtml(dword _bufpointer, _bufsize){ |
183 | void TWebBrowser::ParseHtml(dword _bufpointer, _bufsize){ |
185 | char unicode_symbol[10]; |
184 | char unicode_symbol[10]; |
186 | dword j; |
185 | dword j; |
187 | int tab_len; |
186 | int tab_len; |
188 | dword bufpos; |
187 | dword bufpos; |
189 | bufsize = _bufsize; |
188 | bufsize = _bufsize; |
190 | 189 | ||
191 | if (bufpointer != _bufpointer) { |
190 | if (bufpointer != _bufpointer) { |
192 | bufpointer = malloc(bufsize); |
191 | bufpointer = malloc(bufsize); |
193 | memmov(bufpointer, _bufpointer, bufsize); |
192 | memmov(bufpointer, _bufpointer, bufsize); |
194 | } else { |
193 | } else { |
195 | custom_encoding = CH_CP866; |
194 | custom_encoding = CH_CP866; |
196 | } |
195 | } |
197 | SetPageDefaults(); |
196 | SetPageDefaults(); |
198 | is_html = true; |
197 | is_html = true; |
199 | if (!strstri(bufpointer, " |
198 | if (!strstri(bufpointer, " |
200 | t_body = true; |
199 | t_body = true; |
201 | if (!strstri(bufpointer, " |
200 | if (!strstri(bufpointer, " |
202 | style.pre = true; //show linebreaks for a plaint text |
201 | style.pre = true; //show linebreaks for a plaint text |
203 | is_html = false; |
202 | is_html = false; |
204 | } |
203 | } |
205 | } |
204 | } |
206 | for (bufpos=bufpointer ; (bufpos < bufpointer+bufsize) && (ESBYTE[bufpos]!=0) ; bufpos++;) |
205 | for (bufpos=bufpointer ; (bufpos < bufpointer+bufsize) && (ESBYTE[bufpos]!=0) ; bufpos++;) |
207 | { |
206 | { |
208 | switch (ESBYTE[bufpos]) |
207 | switch (ESBYTE[bufpos]) |
209 | { |
208 | { |
210 | case 0x0a: |
209 | case 0x0a: |
211 | if (style.pre) { |
210 | if (style.pre) { |
212 | Paint(); |
211 | Paint(); |
213 | NewLine(); |
212 | NewLine(); |
214 | } else { |
213 | } else { |
215 | AddCharToTheLine(0x0a); |
214 | AddCharToTheLine(0x0a); |
216 | } |
215 | } |
217 | break; |
216 | break; |
218 | case 0x09: |
217 | case 0x09: |
219 | if (style.pre) { |
218 | if (style.pre) { |
220 | tab_len = strlen(#line) + stolbec % 4; |
219 | tab_len = strlen(#line) + stolbec % 4; |
221 | if (!tab_len) tab_len = 4; else tab_len = 4 - tab_len; |
220 | if (!tab_len) tab_len = 4; else tab_len = 4 - tab_len; |
222 | for (j=0; j |
221 | for (j=0; j |
223 | } else { |
222 | } else { |
224 | AddCharToTheLine(0x09); |
223 | AddCharToTheLine(0x09); |
225 | } |
224 | } |
226 | break; |
225 | break; |
227 | case '&': // and so on |
226 | case '&': // and so on |
228 | for (j=1, unicode_symbol=0; (ESBYTE[bufpos+j]<>';') && (!__isWhite(ESBYTE[bufpos+j])) && (j<8); j++) |
227 | for (j=1, unicode_symbol=0; (ESBYTE[bufpos+j]<>';') && (!__isWhite(ESBYTE[bufpos+j])) && (j<8); j++) |
229 | { |
228 | { |
230 | chrcat(#unicode_symbol, ESBYTE[bufpos+j]); |
229 | chrcat(#unicode_symbol, ESBYTE[bufpos+j]); |
231 | } |
230 | } |
232 | if (GetUnicodeSymbol(#line, #unicode_symbol, sizeof(line)-1)) { |
231 | if (GetUnicodeSymbol(#line, #unicode_symbol, sizeof(line)-1)) { |
233 | bufpos += j; |
232 | bufpos += j; |
234 | CheckForLineBreak(); |
233 | CheckForLineBreak(); |
235 | } else { |
234 | } else { |
236 | AddCharToTheLine('&'); |
235 | AddCharToTheLine('&'); |
237 | } |
236 | } |
238 | break; |
237 | break; |
239 | case '<': |
238 | case '<': |
240 | if (!is_html) goto _DEFAULT; |
239 | if (!is_html) goto _DEFAULT; |
241 | bufpos++; |
240 | bufpos++; |
242 | switch (ESBYTE[bufpos]) { |
241 | switch (ESBYTE[bufpos]) { |
243 | case '!': case '/': case '?': |
242 | case '!': case '/': case '?': |
244 | case 'a'...'z': case 'A'...'Z': |
243 | case 'a'...'z': case 'A'...'Z': |
245 | goto _TAG; |
244 | goto _TAG; |
246 | default: |
245 | default: |
247 | goto _DEFAULT; |
246 | goto _DEFAULT; |
248 | } |
247 | } |
249 | _TAG: |
248 | _TAG: |
250 | if (tag.parse(#bufpos, bufpointer + bufsize)) { |
249 | if (tag.parse(#bufpos, bufpointer + bufsize)) { |
251 | CheckForLineBreak(); |
250 | CheckForLineBreak(); |
252 | Paint(); |
251 | Paint(); |
253 | $push cur_encoding |
252 | $push cur_encoding |
254 | SetStyle(); |
253 | SetStyle(); |
255 | $pop eax |
254 | $pop eax |
256 | // The thing is that UTF if longer than other encodings. |
255 | // The thing is that UTF if longer than other encodings. |
257 | // So if encoding was changed from UTF to DOS than $bufpos position got wrong, |
256 | // So if encoding was changed from UTF to DOS than $bufpos position got wrong, |
258 | // and we have to start parse from the very beginning |
257 | // and we have to start parse from the very beginning |
259 | if (EAX != cur_encoding) && (cur_encoding == CH_UTF8) { |
258 | if (EAX != cur_encoding) && (cur_encoding == CH_UTF8) { |
260 | ParseHtml(bufpointer, bufsize); |
259 | ParseHtml(bufpointer, bufsize); |
261 | return; |
260 | return; |
262 | } |
261 | } |
263 | } |
262 | } |
264 | break; |
263 | break; |
265 | default: |
264 | default: |
266 | _DEFAULT: |
265 | _DEFAULT: |
267 | AddCharToTheLine(ESBYTE[bufpos]); |
266 | AddCharToTheLine(ESBYTE[bufpos]); |
268 | } |
267 | } |
269 | } |
268 | } |
270 | Paint(); |
269 | Paint(); |
271 | NewLine(); |
270 | NewLine(); |
272 | list.count = draw_y; |
271 | list.count = draw_y; |
273 | 272 | ||
274 | canvas.bufh = math.max(list.visible, draw_y); |
273 | canvas.bufh = math.max(list.visible, draw_y); |
275 | buf_data = realloc(buf_data, canvas.bufh * canvas.bufw * 4 + 8); |
274 | buf_data = realloc(buf_data, canvas.bufh * canvas.bufw * 4 + 8); |
276 | 275 | ||
277 | list.CheckDoesValuesOkey(); |
276 | list.CheckDoesValuesOkey(); |
278 | anchors.current = NULL; |
277 | anchors.current = NULL; |
279 | custom_encoding = -1; |
278 | custom_encoding = -1; |
280 | if (!header) { |
279 | if (!header) { |
281 | strncpy(#header, #version, sizeof(TWebBrowser.header)-1); |
280 | strncpy(#header, #version, sizeof(TWebBrowser.header)-1); |
282 | DrawTitle(#header); |
281 | DrawTitle(#header); |
283 | } |
282 | } |
284 | } |
283 | } |
285 | //============================================================================================ |
284 | //============================================================================================ |
286 | bool TWebBrowser::CheckForLineBreak() |
285 | bool TWebBrowser::CheckForLineBreak() |
287 | { |
286 | { |
288 | int line_break_pos; |
287 | int line_break_pos; |
289 | char new_line_text[4096]; |
288 | char new_line_text[4096]; |
290 | //Do we need a line break? |
289 | //Do we need a line break? |
291 | if (strlen(#line)*zoom + stolbec < list.column_max) return false; |
290 | if (strlen(#line)*zoom + stolbec < list.column_max) return false; |
292 | //Yes, we do. Lets calculate where... |
291 | //Yes, we do. Lets calculate where... |
293 | line_break_pos = strrchr(#line, ' '); |
292 | line_break_pos = strrchr(#line, ' '); |
294 | //Is a new line fits in the current line? |
293 | //Is a new line fits in the current line? |
295 | if (line_break_pos*zoom + stolbec > list.column_max) { |
294 | if (line_break_pos*zoom + stolbec > list.column_max) { |
296 | line_break_pos = list.column_max/zoom - stolbec; |
295 | line_break_pos = list.column_max/zoom - stolbec; |
297 | while(line_break_pos) && (line[line_break_pos]!=' ') line_break_pos--; |
296 | while(line_break_pos) && (line[line_break_pos]!=' ') line_break_pos--; |
298 | } |
297 | } |
299 | //Maybe a new line is too big for the whole new line? Then we have to split it |
298 | //Maybe a new line is too big for the whole new line? Then we have to split it |
300 | if (!line_break_pos) && (style.tag_list.level*5 + strlen(#line) * zoom >= list.column_max) { |
299 | if (!line_break_pos) && (style.tag_list.level*5 + strlen(#line) * zoom >= list.column_max) { |
301 | line_break_pos = list.column_max/zoom - stolbec; |
300 | line_break_pos = list.column_max/zoom - stolbec; |
302 | } |
301 | } |
303 | strcpy(#new_line_text, #line + line_break_pos); |
302 | strcpy(#new_line_text, #line + line_break_pos); |
304 | line[line_break_pos] = 0x00; |
303 | line[line_break_pos] = 0x00; |
305 | 304 | ||
306 | Paint(); |
305 | Paint(); |
307 | 306 | ||
308 | strcpy(#line, #new_line_text); |
307 | strcpy(#line, #new_line_text); |
309 | NewLine(); |
308 | NewLine(); |
310 | return true; |
309 | return true; |
311 | } |
310 | } |
312 | //============================================================================================ |
311 | //============================================================================================ |
313 | void TWebBrowser::ChangeEncoding(int _new_encoding) |
312 | void TWebBrowser::ChangeEncoding(int _new_encoding) |
314 | { |
313 | { |
315 | if (cur_encoding == _new_encoding) return; |
314 | if (cur_encoding == _new_encoding) return; |
316 | cur_encoding = _new_encoding; |
315 | cur_encoding = _new_encoding; |
317 | bufpointer = ChangeCharset(cur_encoding, "CP866", bufpointer); |
316 | bufpointer = ChangeCharset(cur_encoding, "CP866", bufpointer); |
318 | if (header) { |
317 | if (header) { |
319 | ChangeCharset(cur_encoding, "CP866", #header); |
318 | ChangeCharset(cur_encoding, "CP866", #header); |
320 | DrawTitle(#header); |
319 | DrawTitle(#header); |
321 | } |
320 | } |
322 | } |
321 | } |
323 | //============================================================================================ |
322 | //============================================================================================ |
324 | void TWebBrowser::NewLine() |
323 | void TWebBrowser::NewLine() |
325 | { |
324 | { |
326 | static int empty_line=0; |
325 | static int empty_line=0; |
327 | 326 | ||
328 | if (!stolbec) && (draw_y==BODY_MARGIN) return; |
327 | if (!stolbec) && (draw_y==BODY_MARGIN) return; |
329 | 328 | ||
330 | if (style.tag_list.level) && (stolbec == style.tag_list.level * 5) { |
329 | if (style.tag_list.level) && (stolbec == style.tag_list.level * 5) { |
331 | if (empty_line<1) empty_line++; |
330 | if (empty_line<1) empty_line++; |
332 | else return; |
331 | else return; |
333 | } else if (!stolbec) { |
332 | } else if (!stolbec) { |
334 | if (empty_line<1) empty_line++; |
333 | if (empty_line<1) empty_line++; |
335 | else return; |
334 | else return; |
336 | } else { |
335 | } else { |
337 | empty_line=0; |
336 | empty_line=0; |
338 | } |
337 | } |
339 | 338 | ||
340 | if (t_html) && (!t_body) return; |
339 | if (t_html) && (!t_body) return; |
341 | draw_y += list.item_h; |
340 | draw_y += list.item_h; |
342 | if (style.blq) stolbec = 6; else stolbec = 0; |
341 | if (style.blq) stolbec = 6; else stolbec = 0; |
343 | stolbec += style.tag_list.level * 5; |
342 | stolbec += style.tag_list.level * 5; |
344 | } |
343 | } |
345 | //============================================================================================ |
344 | //============================================================================================ |
346 | scroll_bar scroll_wv = |
345 | scroll_bar scroll_wv = |
347 | { 15,NULL,NULL,NULL,0,2,NULL, |
346 | { 15,NULL,NULL,NULL,0,2,NULL, |
348 | 0,0,0xeeeeee,0xBBBbbb,0xeeeeee}; |
347 | 0,0,0xeeeeee,0xBBBbbb,0xeeeeee}; |
349 | 348 | ||
350 | void TWebBrowser::DrawPage() |
349 | void TWebBrowser::DrawPage() |
351 | { |
350 | { |
352 | scroll_wv.max_area = list.count; |
351 | scroll_wv.max_area = list.count; |
353 | scroll_wv.cur_area = list.visible; |
352 | scroll_wv.cur_area = list.visible; |
354 | scroll_wv.position = list.first; |
353 | scroll_wv.position = list.first; |
355 | scroll_wv.all_redraw = 0; |
354 | scroll_wv.all_redraw = 0; |
356 | scroll_wv.start_x = list.x + list.w; |
355 | scroll_wv.start_x = list.x + list.w; |
357 | scroll_wv.start_y = list.y; |
356 | scroll_wv.start_y = list.y; |
358 | scroll_wv.size_y = list.h; |
357 | scroll_wv.size_y = list.h; |
359 | scrollbar_v_draw(#scroll_wv); |
358 | scrollbar_v_draw(#scroll_wv); |
360 | 359 | ||
361 | canvas.Show(list.first, list.h); |
360 | canvas.Show(list.first, list.h); |
362 | }1)>1)>>': |
361 | }1)>1)>>': |
363 | >8);>>>?xml"))>>=15)> |
362 | >8);>>>?xml"))>>=15)> |