Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
7752 | leency | 1 | #include "..\TWB\colors.h" |
2 | #include "..\TWB\anchors.h" |
||
3 | #include "..\TWB\parce_tag.h" |
||
7758 | leency | 4 | #include "..\TWB\special.h" |
7757 | leency | 5 | #include "..\TWB\img_cache.h" |
7759 | leency | 6 | #include "..\TWB\tag_list.h" |
7757 | leency | 7 | dword page_bg; |
7759 | leency | 8 | dword link_color_default; |
7757 | leency | 9 | dword link_color_active; |
10 | #include "..\TWB\links.h" |
||
4411 | leency | 11 | |
7759 | leency | 12 | #define BODY_MARGIN 6 |
13 | #define BASIC_LINE_H 18 |
||
4416 | leency | 14 | |
5746 | leency | 15 | struct _style { |
7752 | leency | 16 | bool |
6794 | leency | 17 | b, u, s, h, |
5746 | leency | 18 | pre, |
19 | blq, |
||
7742 | leency | 20 | button, |
7759 | leency | 21 | image; |
7752 | leency | 22 | dword bg_color; |
7759 | leency | 23 | LIST tag_list; |
24 | dword tag_title; |
||
5746 | leency | 25 | }; |
26 | |||
4411 | leency | 27 | struct TWebBrowser { |
4540 | leency | 28 | llist list; |
5746 | leency | 29 | _style style; |
4475 | leency | 30 | DrawBufer DrawBuf; |
7752 | leency | 31 | dword draw_y, stolbec; |
6803 | leency | 32 | int zoom; |
7752 | leency | 33 | dword o_bufpointer; |
7759 | leency | 34 | int cur_encoding, custom_encoding; |
35 | bool link, t_html, t_body; |
||
36 | dword bufpointer; |
||
37 | dword bufsize; |
||
38 | |||
7746 | leency | 39 | void SetPageDefaults(); |
7752 | leency | 40 | void AddCharToTheLine(); |
41 | void ParseHtml(); |
||
5766 | leency | 42 | void SetStyle(); |
43 | void DrawStyle(); |
||
4411 | leency | 44 | void DrawPage(); |
45 | void DrawScroller(); |
||
4650 | leency | 46 | void NewLine(); |
7750 | leency | 47 | bool CheckForLineBreak(); |
7759 | leency | 48 | char line[500]; |
49 | char header[150]; |
||
50 | }; |
||
4486 | leency | 51 | |
7757 | leency | 52 | scroll_bar scroll_wv = { 15,NULL,NULL,NULL,0,2,NULL,0,0,0xeeeeee,0xBBBbbb,0xeeeeee}; |
4411 | leency | 53 | |
5747 | leency | 54 | //============================================================================================ |
5766 | leency | 55 | void TWebBrowser::DrawStyle() |
4411 | leency | 56 | { |
6803 | leency | 57 | dword start_x, line_length, stolbec_len; |
4411 | leency | 58 | |
7759 | leency | 59 | if (style.tag_title) |
4411 | leency | 60 | { |
7759 | leency | 61 | strncpy(#header, #line, sizeof(TWebBrowser.header)-1); |
62 | strncat(#header, " - ", sizeof(TWebBrowser.header)-1); |
||
63 | strncat(#header, #version, sizeof(TWebBrowser.header)-1); |
||
4411 | leency | 64 | line = 0; |
65 | return; |
||
66 | } |
||
7758 | leency | 67 | if (t_html) && (!t_body) { |
68 | line = 0; |
||
69 | return; |
||
70 | } |
||
4411 | leency | 71 | |
6803 | leency | 72 | if (line) |
4411 | leency | 73 | { |
7759 | leency | 74 | start_x = stolbec * list.font_w + BODY_MARGIN + list.x; |
6803 | leency | 75 | stolbec_len = strlen(#line) * zoom; |
5768 | leency | 76 | line_length = stolbec_len * list.font_w; |
4411 | leency | 77 | |
7749 | leency | 78 | if (debug_mode) { |
7750 | leency | 79 | DrawBuf.DrawBar(start_x, draw_y, line_length, list.item_h, 0xDDDddd); |
7749 | leency | 80 | } |
81 | |||
7743 | leency | 82 | if (style.bg_color!=page_bg) { |
7750 | leency | 83 | DrawBuf.DrawBar(start_x, draw_y, line_length, list.item_h, style.bg_color); |
7743 | leency | 84 | } |
85 | |||
7742 | leency | 86 | if (style.image) { |
7743 | leency | 87 | DrawBuf.DrawBar(start_x, draw_y, line_length, list.item_h-1, 0xF9DBCB); |
7742 | leency | 88 | } |
89 | if (style.button) { |
||
90 | DrawBuf.DrawBar(start_x, draw_y, line_length, list.item_h - calc(zoom*2), 0xCCCccc); |
||
91 | DrawBuf.DrawBar(start_x, draw_y + list.item_h - calc(zoom*2), line_length, zoom, 0x999999); |
||
92 | } |
||
93 | |||
7738 | leency | 94 | DrawBuf.WriteText(start_x, 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); |
||
6803 | leency | 96 | if (style.s) DrawBuf.DrawBar(start_x, list.item_h / 2 - 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]); |
||
5519 | leency | 98 | if (link) { |
7747 | leency | 99 | if (line[0]==' ') && (line[1]==NULL) {} else { |
7759 | leency | 100 | DrawBuf.DrawBar(start_x, draw_y + list.item_h - calc(zoom*2)-1, line_length, zoom, link_color_default); |
101 | PageLinks.AddText(start_x, draw_y + list.y, line_length, list.item_h - calc(zoom*2)-1, UNDERLINE, zoom); |
||
7746 | leency | 102 | } |
4411 | leency | 103 | } |
4718 | leency | 104 | stolbec += stolbec_len; |
7750 | leency | 105 | if (debug_mode) debug(#line); |
106 | line = NULL; |
||
4411 | leency | 107 | } |
108 | } |
||
5747 | leency | 109 | //============================================================================================ |
7746 | leency | 110 | void TWebBrowser::SetPageDefaults() |
111 | { |
||
112 | style.b = style.u = style.s = style.h = style.blq = t_html = t_body = style.pre = |
||
7759 | leency | 113 | link = text_color_index = text_colors[0] = style.tag_title = false; |
114 | style.tag_list.reset(); |
||
115 | link_color_default = 0x0000FF; |
||
4491 | leency | 116 | link_color_active = 0xFF0000; |
7743 | leency | 117 | page_bg = 0xFFFFFF; |
118 | style.bg_color = page_bg; |
||
119 | DrawBuf.Fill(0, page_bg); |
||
4504 | leency | 120 | PageLinks.Clear(); |
7752 | leency | 121 | anchors.clear(); |
7758 | leency | 122 | header = NULL; |
7759 | leency | 123 | cur_encoding = CH_CP866; |
124 | draw_y = BODY_MARGIN; |
||
4411 | leency | 125 | stolbec = 0; |
126 | line = 0; |
||
7752 | leency | 127 | zoom = 1; |
7757 | leency | 128 | //hold original buffer |
129 | if (o_bufpointer) o_bufpointer=free(o_bufpointer); |
||
130 | o_bufpointer = malloc(bufsize); |
||
131 | memmov(o_bufpointer, bufpointer, bufsize); |
||
7759 | leency | 132 | if (custom_encoding != -1) { |
133 | cur_encoding = custom_encoding; |
||
134 | bufpointer = ChangeCharset(cur_encoding*10+#charsets, "CP866", bufpointer); |
||
135 | } |
||
7746 | leency | 136 | } |
137 | //============================================================================================ |
||
7752 | leency | 138 | void TWebBrowser::AddCharToTheLine(unsigned char _char) |
139 | { |
||
140 | dword line_len; |
||
141 | if (_char<=15) _char=' '; |
||
142 | line_len = strlen(#line); |
||
143 | if (!style.pre) && (_char == ' ') |
||
144 | { |
||
145 | if (line[line_len-1]==' ') return; //no double spaces |
||
146 | if (!stolbec) && (!line) return; //no paces at the beginning of the line |
||
147 | } |
||
7759 | leency | 148 | if (line_len < sizeof(TWebBrowser.line)) chrcat(#line, _char); |
7752 | leency | 149 | CheckForLineBreak(); |
150 | } |
||
151 | //============================================================================================ |
||
7759 | leency | 152 | void TWebBrowser::ParseHtml(dword _bufpointer, _bufsize){ |
7746 | leency | 153 | word bukva[2]; |
7752 | leency | 154 | char unicode_symbol[10]; |
155 | dword unicode_symbol_result; |
||
7746 | leency | 156 | dword j; |
7752 | leency | 157 | bool ignor_param=false; |
158 | int tab_len; |
||
7746 | leency | 159 | dword bufpos; |
7759 | leency | 160 | bufsize = _bufsize; |
161 | bufpointer = malloc(bufsize); |
||
162 | memmov(bufpointer, _bufpointer, bufsize); |
||
7746 | leency | 163 | SetPageDefaults(); |
7749 | leency | 164 | if (strstri(bufpointer, " |
165 | t_body = true; |
||
166 | if (strstri(bufpointer, " |
||
167 | } |
||
5773 | leency | 168 | for (bufpos=bufpointer ; (bufpos < bufpointer+bufsize) && (ESBYTE[bufpos]!=0) ; bufpos++;) |
4411 | leency | 169 | { |
4508 | leency | 170 | bukva = ESBYTE[bufpos]; |
4411 | leency | 171 | switch (bukva) |
172 | { |
||
173 | case 0x0a: |
||
7752 | leency | 174 | if (style.pre) { |
5781 | leency | 175 | DrawStyle(); |
176 | NewLine(); |
||
7752 | leency | 177 | } else { |
178 | AddCharToTheLine(0x0a); |
||
4411 | leency | 179 | } |
7752 | leency | 180 | break; |
181 | case 0x09: |
||
182 | if (style.pre) { |
||
183 | tab_len = strlen(#line) + stolbec % 4; |
||
184 | if (!tab_len) tab_len = 4; else tab_len = 4 - tab_len; |
||
4411 | leency | 185 | for (j=0; j |
7752 | leency | 186 | } else { |
187 | AddCharToTheLine(0x09); |
||
4411 | leency | 188 | } |
7752 | leency | 189 | break; |
4411 | leency | 190 | case '&': // and so on |
7752 | leency | 191 | for (j=1, unicode_symbol=0; (ESBYTE[bufpos+j]<>';') && (j<8); j++) |
4411 | leency | 192 | { |
7749 | leency | 193 | bukva = ESBYTE[bufpos+j]; |
7752 | leency | 194 | chrcat(#unicode_symbol, bukva); |
4411 | leency | 195 | } |
7759 | leency | 196 | if (GetUnicodeSymbol(#line, #unicode_symbol, sizeof(TWebBrowser.line)-1)) { |
7749 | leency | 197 | bufpos += j; |
7750 | leency | 198 | CheckForLineBreak(); |
7749 | leency | 199 | } else { |
7752 | leency | 200 | AddCharToTheLine('&'); |
7749 | leency | 201 | } |
4411 | leency | 202 | break; |
203 | case '<': |
||
5749 | leency | 204 | bufpos++; |
5768 | leency | 205 | if (!strncmp(bufpos,"!--",3)) |
4411 | leency | 206 | { |
6986 | leency | 207 | bufpos+=3; |
208 | while (strncmp(bufpos,"-->",3)!=0) && (bufpos < bufpointer + bufsize) |
||
209 | { |
||
210 | bufpos++; |
||
211 | } |
||
7746 | leency | 212 | bufpos+=2; |
6986 | leency | 213 | break; |
4411 | leency | 214 | } |
7752 | leency | 215 | tag.reset(); |
216 | if (ESBYTE[bufpos] == '/') { |
||
217 | tag.opened = false; |
||
218 | bufpos++; |
||
219 | } |
||
220 | |||
221 | ignor_param=false; |
||
6735 | leency | 222 | while (ESBYTE[bufpos] !='>') && (bufpos < bufpointer + bufsize) //ïîëó÷à åì òåã è åãî ïà ðà ìåòðû |
4411 | leency | 223 | { |
4508 | leency | 224 | bukva = ESBYTE[bufpos]; |
4411 | leency | 225 | if (bukva == '\9') || (bukva == '\x0a') || (bukva == '\x0d') bukva = ' '; |
226 | if (!ignor_param) && (bukva <>' ') |
||
227 | { |
||
7752 | leency | 228 | if (strlen(#tag.name)+1 |
4411 | leency | 229 | } |
230 | else |
||
231 | { |
||
232 | ignor_param = true; |
||
7752 | leency | 233 | if (strlen(#tag.params)+1 |
234 | // chrncat(#tag.params, bukva, sizeof(tag.params)-1); |
||
4411 | leency | 235 | } |
4508 | leency | 236 | bufpos++; |
4411 | leency | 237 | } |
7752 | leency | 238 | strlwr(#tag.name); |
4411 | leency | 239 | |
7746 | leency | 240 | // ignore text inside the next tags |
7752 | leency | 241 | if (tag.is("script")) || (tag.is("style")) || (tag.is("binary")) || (tag.is("select")) { |
242 | sprintf(#tag.params, "%s>", #tag.name); |
||
243 | j = strstri(bufpos, #tag.params); |
||
244 | if (j!=-1) bufpos = j-1; |
||
7746 | leency | 245 | break; |
246 | } |
||
247 | |||
7752 | leency | 248 | if (tag.name[strlen(#tag.name)-1]=='/') tag.name[strlen(#tag.name)-1]=NULL; //for br/ !!!!!!!! |
249 | if (tag.params) tag.parse_params(); |
||
7746 | leency | 250 | |
7757 | leency | 251 | if (tag.name) { |
7750 | leency | 252 | CheckForLineBreak(); |
7746 | leency | 253 | DrawStyle(); |
7752 | leency | 254 | if (tag.name) SetStyle(); |
7746 | leency | 255 | } |
4411 | leency | 256 | break; |
257 | default: |
||
7752 | leency | 258 | AddCharToTheLine(ESBYTE[bufpos]); |
4411 | leency | 259 | } |
260 | } |
||
5766 | leency | 261 | DrawStyle(); |
262 | NewLine(); |
||
7752 | leency | 263 | list.count = draw_y; |
7755 | leency | 264 | list.CheckDoesValuesOkey(); |
265 | anchors.current = NULL; |
||
7759 | leency | 266 | custom_encoding = -1; |
7758 | leency | 267 | if (!header) { |
7759 | leency | 268 | strncpy(#header, #version, sizeof(TWebBrowser.header)-1); |
7758 | leency | 269 | DrawTitle(#header); |
270 | } |
||
4411 | leency | 271 | } |
5747 | leency | 272 | //============================================================================================ |
7750 | leency | 273 | bool TWebBrowser::CheckForLineBreak() |
4718 | leency | 274 | { |
7750 | leency | 275 | int line_break_pos; |
4718 | leency | 276 | char new_line_text[4096]; |
7758 | leency | 277 | //Do we need a line break? |
7750 | leency | 278 | if (strlen(#line)*zoom + stolbec < list.column_max) return false; |
7758 | leency | 279 | //Yes, we do. Lets calculate where... |
7750 | leency | 280 | line_break_pos = strrchr(#line, ' '); |
7758 | leency | 281 | //Is a new line fits in the current line? |
7750 | leency | 282 | if (line_break_pos*zoom + stolbec > list.column_max) { |
283 | line_break_pos = list.column_max/zoom - stolbec; |
||
284 | while(line_break_pos) && (line[line_break_pos]!=' ') line_break_pos--; |
||
285 | } |
||
7758 | leency | 286 | //Maybe a new line is too big for the whole new line? Then we have to split it |
7759 | leency | 287 | if (!line_break_pos) && (style.tag_list.level*5 + strlen(#line) * zoom >= list.column_max) { |
7758 | leency | 288 | line_break_pos = list.column_max/zoom - stolbec; |
7742 | leency | 289 | } |
7750 | leency | 290 | strcpy(#new_line_text, #line + line_break_pos); |
7758 | leency | 291 | line[line_break_pos] = 0x00; |
292 | |||
5766 | leency | 293 | DrawStyle(); |
7758 | leency | 294 | |
4718 | leency | 295 | strcpy(#line, #new_line_text); |
296 | NewLine(); |
||
7750 | leency | 297 | //if (strlen(#line)*zoom + stolbec > list.column_max)CheckForLineBreak(); |
298 | return true; |
||
4718 | leency | 299 | } |
5747 | leency | 300 | //============================================================================================ |
5773 | leency | 301 | void TWebBrowser::SetStyle() { |
7749 | leency | 302 | char img_path[4096]=0; |
7742 | leency | 303 | int meta_encoding; |
7752 | leency | 304 | |
305 | dword value; |
||
306 | |||
7755 | leency | 307 | if (value = tag.get_value_of("name=")) || (value = tag.get_value_of("id=")) { |
308 | anchors.add(value, draw_y); |
||
309 | if (anchors.current) && (streq(value, #anchors.current+1)) { |
||
310 | list.first = draw_y; |
||
311 | anchors.current = NULL; |
||
312 | } |
||
7758 | leency | 313 | } |
7752 | leency | 314 | if (tag.is("html")) { |
315 | t_html = tag.opened; |
||
4411 | leency | 316 | return; |
317 | } |
||
7757 | leency | 318 | if (tag.is("q")) |
4491 | leency | 319 | { |
7752 | leency | 320 | if (tag.opened) { |
7750 | leency | 321 | meta_encoding = strlen(#line); |
322 | if (line[meta_encoding-1] != ' ') chrcat(#line, ' '); |
||
323 | chrcat(#line, '\"'); |
||
324 | } |
||
7752 | leency | 325 | if (!tag.opened) strcat(#line, "\" "); |
5749 | leency | 326 | return; |
4491 | leency | 327 | } |
7758 | leency | 328 | if (tag.is("title")) { |
7759 | leency | 329 | style.tag_title = tag.opened; |
7758 | leency | 330 | if (!tag.opened) DrawTitle(#header); |
331 | return; |
||
332 | } |
||
7752 | leency | 333 | if (tag.is("body")) { |
334 | t_body = tag.opened; |
||
7759 | leency | 335 | if (value = tag.get_value_of("link=")) link_color_default = GetColor(value); |
7752 | leency | 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); |
||
338 | if (value = tag.get_value_of("bgcolor=")) { |
||
339 | style.bg_color = page_bg = GetColor(value); |
||
340 | DrawBuf.Fill(0, page_bg); |
||
341 | } |
||
4411 | leency | 342 | return; |
343 | } |
||
7752 | leency | 344 | if (tag.is("a")) { |
345 | if (tag.opened) |
||
4411 | leency | 346 | { |
6735 | leency | 347 | if (link) IF(text_color_index > 0) text_color_index--; //åñëè ïðåäûäóùèé òåã à ÃÃ¥ áûë çà êðûò |
7752 | leency | 348 | if (value = tag.get_value_of("href=")) && (!strstr(value,"javascript:")) |
349 | { |
||
350 | text_color_index++; |
||
351 | text_colors[text_color_index] = text_colors[text_color_index-1]; |
||
352 | link = 1; |
||
7759 | leency | 353 | text_colors[text_color_index] = link_color_default; |
7752 | leency | 354 | PageLinks.AddLink(value); |
355 | } |
||
356 | } else { |
||
4411 | leency | 357 | link = 0; |
358 | IF(text_color_index > 0) text_color_index--; |
||
359 | } |
||
360 | return; |
||
361 | } |
||
7752 | leency | 362 | if (tag.is("font")) { |
7743 | leency | 363 | style.bg_color = page_bg; |
7752 | leency | 364 | if (tag.opened) |
4411 | leency | 365 | { |
366 | text_color_index++; |
||
367 | text_colors[text_color_index] = text_colors[text_color_index-1]; |
||
7752 | leency | 368 | if (value = tag.get_value_of("color=")) text_colors[text_color_index] = GetColor(value); |
369 | if (value = tag.get_value_of("bg=")) style.bg_color = GetColor(value); |
||
4411 | leency | 370 | } |
5749 | leency | 371 | else if (text_color_index > 0) text_color_index--; |
4411 | leency | 372 | return; |
373 | } |
||
7752 | leency | 374 | if (tag.is("div")) { |
7756 | leency | 375 | if (streq(#tag.prior,"div")) && (tag.opened) return; |
7746 | leency | 376 | NewLine(); |
4411 | leency | 377 | return; |
378 | } |
||
7752 | leency | 379 | if (tag.is("header")) || (tag.is("article")) || (tag.is("footer")) || (tag.is("figure")) { |
7746 | leency | 380 | NewLine(); |
381 | return; |
||
382 | } |
||
7752 | leency | 383 | if (tag.is("p")) { |
7756 | leency | 384 | IF (tag.prior[0] == 'h') || (streq(#tag.prior,"td")) || (streq(#tag.prior,"p")) return; |
4692 | leency | 385 | NewLine(); |
4411 | leency | 386 | return; |
387 | } |
||
7752 | leency | 388 | if (tag.is("br")) { NewLine(); return; } |
7757 | leency | 389 | if (tag.is("td")) { if (tag.opened) AddCharToTheLine(' '); return; } |
7752 | leency | 390 | if (tag.is("tr")) { if (tag.opened) NewLine(); return; } |
391 | if (tag.is("b")) || (tag.is("strong")) || (tag.is("big")) { style.b = tag.opened; 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;} |
||
394 | if (tag.is("s")) || (tag.is("strike")) || (tag.is("del")) { style.s=tag.opened; return; } |
||
395 | if (tag.is("dd")) { stolbec += 5; return; } |
||
396 | if (tag.is("blockquote")) { style.blq = tag.opened; return; } |
||
7759 | leency | 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 | } |
||
7752 | leency | 402 | if (tag.is("img")) { |
403 | if (value = tag.get_value_of("src=")) strlcpy(#img_path, value, sizeof(img_path)-1); |
||
7759 | leency | 404 | if (value = tag.get_value_of("title=")) && (strlen(value) |
405 | if (value = tag.get_value_of("alt=")) && (strlen(value) |
||
7750 | leency | 406 | if (!img_path) { line=0; return; } |
7742 | leency | 407 | style.image = true; |
408 | text_color_index++; |
||
409 | text_colors[text_color_index] = 0x9A6F29; |
||
410 | if (!line) { |
||
411 | if (!strncmp(#img_path, "data:", 5)) img_path=0; |
||
7749 | leency | 412 | replace_char(#img_path, '?', NULL, strlen(#img_path)); |
7742 | leency | 413 | sprintf(#line, "[%s]", #img_path+strrchr(#img_path, '/')); |
414 | line[50]= NULL; |
||
415 | } |
||
7750 | leency | 416 | while (CheckForLineBreak()) {}; |
7742 | leency | 417 | DrawStyle(); |
418 | text_color_index--; |
||
419 | style.image = false; |
||
7759 | leency | 420 | //ImgCache.Images( list.x, draw_y, list.w); |
7742 | leency | 421 | return; |
422 | } |
||
7758 | leency | 423 | if (tag.is("h4")) { |
424 | NewLine(); |
||
7759 | leency | 425 | NewLine(); |
7758 | leency | 426 | style.h = tag.opened; |
427 | style.b = tag.opened; |
||
428 | } |
||
7752 | leency | 429 | if (tag.is("h1")) || (tag.is("h2")) || (tag.is("h3")) || (tag.is("caption")) { |
430 | style.h = tag.opened; |
||
7758 | leency | 431 | if (tag.opened) { |
7759 | leency | 432 | if (!style.pre) NewLine(); |
6794 | leency | 433 | draw_y += 10; |
7759 | leency | 434 | zoom=2; |
435 | list.font_type |= 10011001b; |
||
436 | list.item_h = BASIC_LINE_H * 2 - 2; |
||
7752 | leency | 437 | if (tag.is("h1")) style.b = true; |
7758 | leency | 438 | } else { |
7752 | leency | 439 | if (tag.is("h1")) style.b = false; |
6794 | leency | 440 | NewLine(); |
7759 | leency | 441 | zoom=1; |
442 | list.font_type = 10011000b; |
||
443 | list.item_h = BASIC_LINE_H; |
||
4411 | leency | 444 | } |
445 | return; |
||
446 | } |
||
7752 | leency | 447 | if (tag.is("dt")) { |
7759 | leency | 448 | style.tag_list.upd_level(tag.opened, DT); |
7752 | leency | 449 | if (tag.opened) NewLine(); |
4411 | leency | 450 | return; |
451 | } |
||
7759 | leency | 452 | if (tag.is("ul")) { |
453 | style.tag_list.upd_level(tag.opened, UL); |
||
454 | if (!tag.opened) && (!style.pre) NewLine(); |
||
455 | return; |
||
456 | } |
||
457 | if (tag.is("ol")) { |
||
458 | style.tag_list.upd_level(tag.opened, OL); |
||
459 | if (!tag.opened) && (!style.pre) NewLine(); |
||
460 | return; |
||
461 | } |
||
462 | if (tag.is("li")) && (tag.opened) |
||
4411 | leency | 463 | { |
7759 | leency | 464 | if (!style.tag_list.level) style.tag_list.upd_level(1, UL); |
465 | if (!style.pre) NewLine(); |
||
466 | if (style.tag_list.get_order_type() == UL) { |
||
7742 | leency | 467 | strcpy(#line, "\31 "); |
7759 | leency | 468 | stolbec = style.tag_list.level * 5 - 2; |
469 | } |
||
470 | if (style.tag_list.get_order_type() == OL) { |
||
471 | sprintf(#line, "%i. ", style.tag_list.inc_counter()); |
||
472 | stolbec = style.tag_list.level * 5 - strlen(#line); |
||
4411 | leency | 473 | } |
474 | return; |
||
475 | } |
||
7752 | leency | 476 | if (tag.is("hr")) { |
477 | if (value = tag.get_value_of("color=")) EDI = GetColor(value); else EDI = 0x999999; |
||
5773 | leency | 478 | $push edi; |
4692 | leency | 479 | NewLine(); |
5773 | leency | 480 | $pop edi; |
7746 | leency | 481 | draw_y += 10; |
6794 | leency | 482 | DrawBuf.DrawBar(5, draw_y - 1, list.w-10, 1, EDI); |
4692 | leency | 483 | NewLine(); |
7746 | leency | 484 | draw_y += 10; |
5773 | leency | 485 | return; |
4411 | leency | 486 | } |
7759 | leency | 487 | if (custom_encoding == -1) && (tag.is("meta")) || (tag.is("?xml")) { |
488 | meta_encoding = CH_CP866; |
||
7752 | leency | 489 | if (value = tag.get_value_of("charset=")) || (value = tag.get_value_of("content=")) || (value = tag.get_value_of("encoding=")) |
490 | { |
||
491 | value += strrchr(value, '='); //search in content= |
||
492 | strlwr(value); |
||
493 | if (streq(value,"utf-8")) || (streq(value,"utf8")) meta_encoding = CH_UTF8; |
||
494 | else if (streq(value,"windows-1251")) || (streq(value,"windows1251")) meta_encoding = CH_CP1251; |
||
495 | else if (streq(value,"dos")) || (streq(value,"cp-866")) meta_encoding = CH_CP866; |
||
496 | else if (streq(value,"iso-8859-5")) || (streq(value,"iso8859-5")) meta_encoding = CH_ISO8859_5; |
||
497 | else if (streq(value,"koi8-r")) || (streq(value,"koi8-u")) meta_encoding = CH_KOI8; |
||
498 | } |
||
7759 | leency | 499 | if (meta_encoding != CH_CP866) && (cur_encoding != meta_encoding) { |
500 | cur_encoding = meta_encoding; |
||
501 | bufpointer = ChangeCharset(cur_encoding*10+#charsets, "CP866", bufpointer); |
||
7758 | leency | 502 | if (header) { |
7759 | leency | 503 | ChangeCharset(cur_encoding*10+#charsets, "CP866", #header); |
7758 | leency | 504 | DrawTitle(#header); |
505 | } |
||
506 | } |
||
4411 | leency | 507 | return; |
508 | } |
||
509 | } |
||
7746 | leency | 510 | //============================================================================================ |
4674 | leency | 511 | void TWebBrowser::DrawScroller() |
4411 | leency | 512 | { |
4416 | leency | 513 | scroll_wv.max_area = list.count; |
514 | scroll_wv.cur_area = list.visible; |
||
515 | scroll_wv.position = list.first; |
||
5519 | leency | 516 | scroll_wv.all_redraw = 0; |
4486 | leency | 517 | scroll_wv.start_x = list.x + list.w; |
4508 | leency | 518 | scroll_wv.start_y = list.y; |
5678 | leency | 519 | scroll_wv.size_y = list.h; |
4416 | leency | 520 | scrollbar_v_draw(#scroll_wv); |
4411 | leency | 521 | } |
5747 | leency | 522 | //============================================================================================ |
4692 | leency | 523 | void TWebBrowser::NewLine() |
4475 | leency | 524 | { |
6803 | leency | 525 | dword onleft, ontop; |
7742 | leency | 526 | static int empty_line=0; |
4692 | leency | 527 | |
7759 | leency | 528 | if (!stolbec) && (draw_y==BODY_MARGIN) return; |
7742 | leency | 529 | |
7759 | leency | 530 | if (style.tag_list.level) && (stolbec == style.tag_list.level * 5) { |
7742 | leency | 531 | if (empty_line<1) empty_line++; |
532 | else return; |
||
7749 | leency | 533 | } else if (!stolbec) { |
534 | if (empty_line<1) empty_line++; |
||
535 | else return; |
||
7742 | leency | 536 | } else { |
537 | empty_line=0; |
||
538 | } |
||
6794 | leency | 539 | |
7759 | leency | 540 | onleft = list.x + BODY_MARGIN; |
6794 | leency | 541 | ontop = draw_y + list.y; |
4637 | leency | 542 | if (t_html) && (!t_body) return; |
6794 | leency | 543 | draw_y += list.item_h; |
5746 | leency | 544 | if (style.blq) stolbec = 6; else stolbec = 0; |
7759 | leency | 545 | stolbec += style.tag_list.level * 5; |
7750 | leency | 546 | if (debug_mode) debugln(NULL); |
4488 | leency | 547 | } |
5747 | leency | 548 | //============================================================================================ |
5766 | leency | 549 | void TWebBrowser::DrawPage() |
550 | { |
||
6794 | leency | 551 | PutPaletteImage(list.first * DrawBuf.bufw * 4 + buf_data+8, DrawBuf.bufw, list.h, DrawBuf.bufx, DrawBuf.bufy, 32, 0); |
5766 | leency | 552 | DrawScroller(); |
553 | }1)>1)>>>>>': |