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