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