Rev 7746 | 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 | for (bufpos=bufpointer ; (bufpos < bufpointer+bufsize) && (ESBYTE[bufpos]!=0) ; bufpos++;) |
||
5773 | leency | 158 | { |
4411 | leency | 159 | bukva = ESBYTE[bufpos]; |
4508 | leency | 160 | switch (bukva) |
4411 | leency | 161 | { |
162 | case 0x0a: |
||
163 | if (style.pre) |
||
5746 | leency | 164 | { |
4411 | leency | 165 | DrawStyle(); |
5781 | leency | 166 | line = NULL; |
6783 | leency | 167 | NewLine(); |
5781 | leency | 168 | break; |
4726 | leency | 169 | } |
4411 | leency | 170 | goto DEFAULT_MARK; |
6783 | leency | 171 | case '\9': |
4411 | leency | 172 | if (style.pre) //otherwise go to 0x0d |
6735 | leency | 173 | { |
4411 | leency | 174 | tab_len = strlen(#line) % 4; |
4725 | leency | 175 | if (!tab_len) tab_len = 4; |
176 | for (j=0; j |
||
4411 | leency | 177 | break; |
178 | } |
||
179 | goto DEFAULT_MARK; |
||
6783 | leency | 180 | case '&': // and so on |
4411 | leency | 181 | bufpos++; |
4508 | leency | 182 | tag=0; |
4411 | leency | 183 | for (j=0; (ESBYTE[bufpos]<>';') && (j<7); j++, bufpos++;) |
4508 | leency | 184 | { |
4411 | leency | 185 | bukva = ESBYTE[bufpos]; |
4508 | leency | 186 | chrcat(#tag, bukva); |
4411 | leency | 187 | } |
188 | if (bukva = GetUnicodeSymbol()) goto DEFAULT_MARK; |
||
4417 | leency | 189 | break; |
4411 | leency | 190 | case '<': |
191 | bufpos++; |
||
5749 | leency | 192 | if (!strncmp(bufpos,"!--",3)) |
5768 | leency | 193 | { |
4411 | leency | 194 | bufpos+=3; |
6986 | leency | 195 | while (strncmp(bufpos,"-->",3)!=0) && (bufpos < bufpointer + bufsize) |
196 | { |
||
197 | bufpos++; |
||
198 | } |
||
199 | bufpos+=2; |
||
7746 | leency | 200 | break; |
6986 | leency | 201 | } |
4411 | leency | 202 | tag = attr = tagparam = ignor_param = NULL; |
5768 | leency | 203 | while (ESBYTE[bufpos] !='>') && (bufpos < bufpointer + bufsize) //ïîëó÷à åì òåã è åãî ïà ðà ìåòðû |
6735 | leency | 204 | { |
4411 | leency | 205 | bukva = ESBYTE[bufpos]; |
4508 | leency | 206 | if (bukva == '\9') || (bukva == '\x0a') || (bukva == '\x0d') bukva = ' '; |
4411 | leency | 207 | if (!ignor_param) && (bukva <>' ') |
208 | { |
||
209 | if (strlen(#tag)+1 |
||
6686 | leency | 210 | } |
4411 | leency | 211 | else |
212 | { |
||
213 | ignor_param = true; |
||
214 | if (strlen(#tagparam)+1 |
||
7746 | leency | 215 | } |
4411 | leency | 216 | bufpos++; |
4508 | leency | 217 | } |
4411 | leency | 218 | strlwr(#tag); |
219 | |||
220 | |||
7746 | leency | 221 | if (istag("script")) || (istag("style")) || (istag("binary")) || (istag("select")) { |
222 | for (j=10; j>0; j--) tag[j]=tag[j-1]; |
||
223 | tag[0] = '/'; |
||
224 | j = strstri(bufpos, #tag); |
||
225 | if (j!=-1) { |
||
226 | bufpos = j; |
||
227 | } |
||
228 | break; |
||
229 | } |
||
230 | |||
231 | |||
4411 | leency | 232 | if (tagparam) GetNextParam(); |
4726 | leency | 233 | |
7746 | leency | 234 | |
235 | { |
||
236 | opened = 0; |
||
237 | strcpy(#tag, #tag+1); |
||
238 | } |
||
239 | else opened = 1; |
||
240 | |||
241 | |||
242 | Perenos(); |
||
243 | DrawStyle(); |
||
244 | line = NULL; |
||
245 | if (tag) SetStyle(); |
||
246 | } |
||
247 | strlcpy(#oldtag, #tag, sizeof(oldtag)); |
||
6686 | leency | 248 | tag = attr = tagparam = ignor_param = NULL; |
5746 | leency | 249 | break; |
4411 | leency | 250 | default: |
251 | DEFAULT_MARK: |
||
252 | if (bukva<=15) bukva=' '; |
||
253 | line_len = strlen(#line); |
||
6021 | leency | 254 | if (!style.pre) && (bukva == ' ') |
5746 | leency | 255 | { |
4411 | leency | 256 | if (line[line_len-1]==' ') break; //no double spaces |
4726 | leency | 257 | if (!stolbec) && (!line) break; //no paces at the beginning of the line |
258 | } |
||
4411 | leency | 259 | if (line_len < sizeof(line)) chrcat(#line, bukva); |
4726 | leency | 260 | Perenos(); |
5768 | leency | 261 | } |
4411 | leency | 262 | } |
263 | DrawStyle(); |
||
5766 | leency | 264 | NewLine(); |
265 | if (list.first == 0) list.count = draw_y; |
||
6794 | leency | 266 | DrawPage(); |
4692 | leency | 267 | } |
4411 | leency | 268 | //============================================================================================ |
5747 | leency | 269 | void TWebBrowser::Perenos() |
4718 | leency | 270 | { |
271 | int perenos_num; |
||
272 | char new_line_text[4096]; |
||
273 | if (strlen(#line)*zoom + stolbec < list.column_max) return; |
||
6803 | leency | 274 | perenos_num = strrchr(#line, ' '); |
4718 | leency | 275 | if (!perenos_num) && (strlen(#line)*zoom>list.column_max) { |
7742 | leency | 276 | perenos_num=list.column_max/zoom; |
277 | if (!stolbec)&&(style.pre) draw_y-=list.item_h; //hack to fix https://prnt.sc/rk3kyt |
||
278 | } |
||
279 | strcpy(#new_line_text, #line + perenos_num); |
||
4718 | leency | 280 | line[perenos_num] = 0x00; |
281 | DrawStyle(); |
||
5766 | leency | 282 | strcpy(#line, #new_line_text); |
4718 | leency | 283 | NewLine(); |
284 | } |
||
285 | //============================================================================================ |
||
5747 | leency | 286 | void TWebBrowser::SetStyle() { |
5773 | leency | 287 | char img_path[4096]; |
7742 | leency | 288 | int left1 = body_magrin + list.x; |
6794 | leency | 289 | int meta_encoding; |
7742 | leency | 290 | if (istag("html")) { |
5749 | leency | 291 | t_html = opened; |
4637 | leency | 292 | return; |
4411 | leency | 293 | } |
294 | if(istag("title")) { |
||
5749 | leency | 295 | if (opened) header=NULL; |
4491 | leency | 296 | return; |
4411 | leency | 297 | } |
298 | |||
299 | |||
5746 | leency | 300 | { |
4491 | leency | 301 | if (opened) strcat(#line, " \""); |
5746 | leency | 302 | if (!opened) strcat(#line, "\" "); |
303 | return; |
||
5749 | leency | 304 | } |
4491 | leency | 305 | if (isattr("id=")) || (isattr("name=")) { // TO FIX: works only if the param is the last |
7738 | leency | 306 | anchors.add(#val, draw_y); |
307 | } |
||
308 | if (istag("body")) { |
||
5749 | leency | 309 | t_body = opened; |
4637 | leency | 310 | do{ |
4411 | leency | 311 | if (isattr("link=")) link_color_inactive = GetColor(#val); |
5746 | leency | 312 | if (isattr("alink=")) link_color_active = GetColor(#val); |
313 | if (isattr("text=")) text_colors[0]=GetColor(#val); |
||
314 | if (isattr("bgcolor=")) |
||
315 | { |
||
4411 | leency | 316 | style.bg_color = page_bg = GetColor(#val); |
7743 | leency | 317 | DrawBuf.Fill(0, page_bg); |
318 | } |
||
4411 | leency | 319 | } while(GetNextParam()); |
320 | if (opened) && (cur_encoding==CH_NULL) { |
||
7032 | leency | 321 | cur_encoding = CH_CP866; |
7742 | leency | 322 | //BufEncode(CH_UTF8); |
323 | debugln("Document has no information about encoding!"); |
||
324 | } |
||
7032 | leency | 325 | if (opened) { |
326 | if (strcmp(#header, #version) != 0) { |
||
7208 | leency | 327 | ChangeCharset(charsets[cur_encoding], "CP866", #header); |
7056 | leency | 328 | sprintf(#header, "%s - %s", #header, #version); |
329 | } |
||
330 | DrawTitle(#header); |
||
7032 | leency | 331 | } |
332 | return; |
||
4411 | leency | 333 | } |
334 | if (istag("a")) { |
||
5749 | leency | 335 | if (opened) |
4491 | leency | 336 | { |
4411 | leency | 337 | if (link) IF(text_color_index > 0) text_color_index--; //åñëè ïðåäûäóùèé òåã à ÃÃ¥ áûë çà êðûò |
6735 | leency | 338 | do{ |
4411 | leency | 339 | if (isattr("href=")) && (!strstr(#val,"javascript:")) |
6001 | leency | 340 | { |
4411 | leency | 341 | text_color_index++; |
342 | text_colors[text_color_index] = text_colors[text_color_index-1]; |
||
343 | link = 1; |
||
344 | text_colors[text_color_index] = link_color_inactive; |
||
4491 | leency | 345 | PageLinks.AddLink(#val); |
6795 | leency | 346 | } |
4411 | leency | 347 | } while(GetNextParam()); |
348 | } |
||
349 | else { |
||
350 | link = 0; |
||
351 | IF(text_color_index > 0) text_color_index--; |
||
352 | } |
||
353 | return; |
||
354 | } |
||
355 | if (istag("font")) { |
||
5749 | leency | 356 | style.bg_color = page_bg; |
7743 | leency | 357 | if (opened) |
4491 | leency | 358 | { |
4411 | leency | 359 | text_color_index++; |
360 | text_colors[text_color_index] = text_colors[text_color_index-1]; |
||
361 | do{ |
||
362 | if (isattr("color=")) text_colors[text_color_index] = GetColor(#val); |
||
5749 | leency | 363 | if (isattr("bg=")) style.bg_color = GetColor(#val); |
7743 | leency | 364 | } while(GetNextParam()); |
4411 | leency | 365 | } |
366 | else if (text_color_index > 0) text_color_index--; |
||
5749 | leency | 367 | return; |
4411 | leency | 368 | } |
369 | if (istag("div")) { |
||
7746 | leency | 370 | if (streq(#oldtag,"div")) && (opened) return; |
371 | NewLine(); |
||
372 | //IF (oldtag[0] != 'h') |
||
373 | return; |
||
4411 | leency | 374 | } |
375 | if (istag("header")) || (istag("article")) || (istag("footer")) || (istag("figure")) { |
||
7746 | leency | 376 | NewLine(); |
377 | return; |
||
378 | } |
||
379 | if (istag("p")) { |
||
5746 | leency | 380 | IF (oldtag[0] == 'h') || (streq(#oldtag,"td")) || (streq(#oldtag,"p")) return; |
7746 | leency | 381 | NewLine(); |
4692 | leency | 382 | //IF(opened) NewLine(); |
7746 | leency | 383 | return; |
4411 | leency | 384 | } |
385 | if (istag("br")) { NewLine(); return; } |
||
5749 | leency | 386 | if (istag("tr")) { if (opened) NewLine(); return; } |
5990 | leency | 387 | if (istag("b")) || (istag("strong")) || (istag("big")) { style.b = opened; return; } |
5749 | leency | 388 | if (istag("button")) { style.button = opened; stolbec++; return; } |
7742 | leency | 389 | if (istag("u")) || (istag("ins")) { style.u=opened; return;} |
5749 | leency | 390 | if (istag("s")) || (istag("strike")) || (istag("del")) { style.s=opened; return; } |
391 | if (istag("dd")) { stolbec += 5; return; } |
||
392 | if (istag("blockquote")) { style.blq = opened; return; } |
||
393 | if (istag("pre")) || (istag("code")) { style.pre = opened; return; } |
||
394 | if (istag("img")) { |
||
7742 | leency | 395 | do{ |
396 | if (isattr("src=")) strcpy(#img_path, #val); |
||
397 | if (isattr("alt=")) sprintf(#line, "[%s]", #val); |
||
398 | if (isattr("title=")) sprintf(#line, "[%s]", #val); |
||
7746 | leency | 399 | } while(GetNextParam()); |
7742 | leency | 400 | debugln(#val); |
7746 | leency | 401 | style.image = true; |
7742 | leency | 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);>>> |