Rev 5747 | Rev 5766 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4411 | leency | 1 | |
5749 | leency | 2 | |
4677 | leency | 3 | enum { ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT}; |
4416 | leency | 4 | |
5746 | leency | 5 | struct _style { |
4416 | leency | 6 | |
5746 | leency | 7 | b, i, u, s, |
8 | pre, |
||
9 | blq, |
||
10 | li, |
||
11 | li_tab, |
||
12 | align; |
||
13 | }; |
||
14 | |||
15 | struct TWebBrowser { |
||
16 | |||
4411 | leency | 17 | _style style; |
4540 | leency | 18 | dword draw_line_width; |
5746 | leency | 19 | DrawBufer DrawBuf; |
5678 | leency | 20 | void Parse(); |
4475 | leency | 21 | void SetTextStyle(); |
4550 | leency | 22 | void DrawPage(); |
4650 | leency | 23 | void DrawScroller(); |
4411 | leency | 24 | void LoadInternalPage(); |
25 | void NewLine(); |
||
5747 | leency | 26 | void Perenos(); |
4650 | leency | 27 | void BufEncode(); |
4718 | leency | 28 | byte end_parsing; |
5749 | leency | 29 | } WB1; |
4718 | leency | 30 | |
4686 | leency | 31 | |
4486 | leency | 32 | |
5746 | leency | 33 | |
34 | |||
35 | ignor_text, |
||
36 | cur_encoding, |
||
37 | t_html, |
||
38 | t_body; |
||
39 | |||
40 | dword bufpointer; |
||
41 | |||
5749 | leency | 42 | dword bufsize; |
43 | |||
44 | dword text_colors[300]; |
||
4411 | leency | 45 | |
4417 | leency | 46 | dword link_color_inactive; |
47 | dword link_color_active; |
||
4491 | leency | 48 | dword bg_color; |
49 | |||
4417 | leency | 50 | int stroka; |
4411 | leency | 51 | |
4417 | leency | 52 | int tab_len; |
53 | int anchor_line_num; |
||
54 | |||
55 | char URL[10000]; |
||
4636 | leency | 56 | |
5746 | leency | 57 | char line[500]; |
58 | char tagparam[10000]; |
||
4417 | leency | 59 | char tag[100]; |
5746 | leency | 60 | char attr[1200]; |
4417 | leency | 61 | char val[4096]; |
5746 | leency | 62 | char anchor[256]; |
63 | |||
4417 | leency | 64 | #include "..\TWB\history.h" |
4411 | leency | 65 | |
4416 | leency | 66 | #include "..\TWB\colors.h" |
4686 | leency | 67 | #include "..\TWB\unicode_tags.h" |
4411 | leency | 68 | #include "..\TWB\img_cache.h" |
69 | #include "..\TWB\parce_tag.h" |
||
70 | |||
71 | |||
72 | |||
4475 | leency | 73 | |
5747 | leency | 74 | { |
4411 | leency | 75 | int start_x, start_y, line_length, stolbec_len, magrin_left=5; |
76 | |||
5678 | leency | 77 | if (!header) |
4411 | leency | 78 | |
79 | ChangeCharset("UTF-8", "CP866", #line); |
||
80 | strcpy(#header, #line); |
||
5718 | leency | 81 | strcat(#header, " -"); |
4411 | leency | 82 | strcat(#header, #version); |
83 | line = 0; |
||
84 | return; |
||
85 | } |
||
86 | if (t_html) && (!t_body) return; |
||
87 | |||
4637 | leency | 88 | if (stroka >= 0) && (stroka - 2 < list.visible) && (line) && (!anchor) |
4411 | leency | 89 | |
4415 | leency | 90 | start_x = stolbec * list.font_w + magrin_left * DrawBuf.zoom + list.x; |
4411 | leency | 91 | start_y = stroka * list.line_h + magrin_left + list.y; |
5710 | leency | 92 | stolbec_len = utf8_strlen(#line); |
5678 | leency | 93 | line_length = stolbec_len * list.font_w * DrawBuf.zoom; |
5712 | leency | 94 | |
5710 | leency | 95 | WriteBufText(start_x, 0, list.font_type, text_colors[text_color_index], #line, buf_data); |
4411 | leency | 96 | |
5711 | leency | 97 | if (style.i) { stolbec++; DrawBuf.Skew(start_x, 0, line_length, list.line_h); } // bug with zoom>1 |
5747 | leency | 98 | if (style.s) DrawBuf.DrawBar(start_x, list.line_h / 2 - DrawBuf.zoom, line_length, DrawBuf.zoom, text_colors[text_color_index]); |
5746 | leency | 99 | if (style.u) DrawBuf.DrawBar(start_x, list.line_h - DrawBuf.zoom - DrawBuf.zoom, line_length, DrawBuf.zoom, text_colors[text_color_index]); |
100 | if (link) { |
||
101 | DrawBuf.DrawBar(start_x, list.line_h - DrawBuf.zoom - DrawBuf.zoom, line_length, DrawBuf.zoom, text_colors[text_color_index]); |
||
5519 | leency | 102 | UnsafeDefineButton(start_x-2, start_y-1, line_length + 3, DrawBuf.zoom * list.font_h, PageLinks.count + 400 + BT_HIDE, 0xB5BFC9); |
5678 | leency | 103 | PageLinks.AddText(#line, line_length, list.line_h, UNDERLINE); |
5711 | leency | 104 | } |
5678 | leency | 105 | stolbec += stolbec_len; |
4411 | leency | 106 | } |
4718 | leency | 107 | } |
4411 | leency | 108 | //============================================================================================ |
109 | void TWebBrowser::LoadInternalPage(dword bufpos, in_filesize){ |
||
5747 | leency | 110 | bufsize = in_filesize; |
111 | bufpointer = bufpos; |
||
112 | Parse(); |
||
113 | } |
||
114 | //============================================================================================ |
||
115 | void TWebBrowser::Parse(){ |
||
116 | word bukva[2]; |
||
4636 | leency | 117 | int j; |
4411 | leency | 118 | byte ignor_param; |
4718 | leency | 119 | char temp[768]; |
4411 | leency | 120 | dword bufpos = bufpointer; |
121 | int line_len; |
||
4636 | leency | 122 | |
4726 | leency | 123 | style.b = style.i = style.u = style.s = style.blq = t_html = t_body = |
4411 | leency | 124 | |
5746 | leency | 125 | end_parsing = false; |
5749 | leency | 126 | style.align = ALIGN_LEFT; |
4718 | leency | 127 | link_color_inactive = 0x0000FF; |
5746 | leency | 128 | link_color_active = 0xFF0000; |
4491 | leency | 129 | bg_color = 0xFFFFFF; |
130 | DrawBuf.Fill(bg_color); |
||
4411 | leency | 131 | PageLinks.Clear(); |
4475 | leency | 132 | strcpy(#header, #version); |
4504 | leency | 133 | stroka = -list.first; |
4411 | leency | 134 | stolbec = 0; |
4415 | leency | 135 | line = 0; |
4411 | leency | 136 | |
137 | draw_line_width = list.w * DrawBuf.zoom; |
||
138 | |||
5678 | leency | 139 | //for plaint text use CP866 for other UTF |
5519 | leency | 140 | |
5749 | leency | 141 | { |
142 | style.pre = 0; |
||
143 | cur_encoding = CH_CP866; |
||
144 | //WB1.list.SetFont(8, 14, 10111000b); |
||
145 | //list.line_h = list.font_h + 4; |
||
146 | } |
||
147 | else |
||
148 | { |
||
149 | style.pre = 1; |
||
150 | cur_encoding = CH_UTF8; |
||
151 | //WB1.list.SetFont(8, 14, 10001000b); |
||
152 | //list.line_h = list.font_h + 4; |
||
153 | } |
||
154 | |||
155 | for ( ; (bufpointer+bufsize > bufpos) && (ESBYTE[bufpos]!=0); bufpos++;) |
||
4411 | leency | 156 | |
4718 | leency | 157 | if (end_parsing) break; |
4411 | leency | 158 | bukva = ESBYTE[bufpos]; |
4718 | leency | 159 | if (ignor_text) && (bukva!='<') continue; |
4508 | leency | 160 | switch (bukva) |
4417 | leency | 161 | { |
4411 | leency | 162 | case 0x0a: |
163 | if (style.pre) |
||
164 | { |
||
5746 | leency | 165 | chrcat(#line, ' '); |
4411 | leency | 166 | bukva = temp = NULL; |
4686 | leency | 167 | Perenos(); |
4411 | leency | 168 | break; |
4718 | leency | 169 | } |
4726 | leency | 170 | case '\9': |
4411 | leency | 171 | if (style.pre) //иначе идём на 0x0d |
172 | { |
||
5746 | leency | 173 | tab_len = strlen(#line) % 4; |
4411 | leency | 174 | if (!tab_len) tab_len = 4; |
4725 | leency | 175 | for (j=0; j |
176 | break; |
||
4411 | leency | 177 | } |
178 | goto DEFAULT_MARK; |
||
179 | |||
180 | case '&': // and so on |
||
181 | |||
182 | tag=0; |
||
4508 | leency | 183 | for (j=0; (ESBYTE[bufpos]<>';') && (j<7); j++, bufpos++;) |
4411 | leency | 184 | { |
4508 | leency | 185 | bukva = ESBYTE[bufpos]; |
4411 | leency | 186 | chrcat(#tag, bukva); |
4508 | leency | 187 | } |
4411 | leency | 188 | if (bukva = GetUnicodeSymbol()) goto DEFAULT_MARK; |
189 | break; |
||
4417 | leency | 190 | case '<': |
4411 | leency | 191 | bufpos++; |
192 | tag = attr = tagparam = ignor_param = NULL; |
||
5749 | leency | 193 | if (ESBYTE[bufpos] == '!') //фильтрация внутри , дерзко |
5746 | leency | 194 | { |
4508 | leency | 195 | bufpos++; |
4411 | leency | 196 | if (ESBYTE[bufpos] == '-') |
4508 | leency | 197 | { |
198 | HH_: |
||
4411 | leency | 199 | do |
200 | { |
||
201 | bufpos++; |
||
202 | if (bufpointer + bufsize <= bufpos) break 2; |
||
4508 | leency | 203 | } |
4550 | leency | 204 | while (ESBYTE[bufpos] <>'-'); |
4411 | leency | 205 | |
4508 | leency | 206 | bufpos++; |
4411 | leency | 207 | |
4508 | leency | 208 | } |
209 | } |
||
4411 | leency | 210 | while (ESBYTE[bufpos] !='>') && (bufpos < bufpointer + bufsize) //получаем тег и его параметры |
211 | { |
||
4550 | leency | 212 | bukva = ESBYTE[bufpos]; |
4411 | leency | 213 | if (bukva == '\9') || (bukva == '\x0a') || (bukva == '\x0d') bukva = ' '; |
4508 | leency | 214 | if (!ignor_param) && (bukva <>' ') |
4411 | leency | 215 | { |
216 | if (strlen(#tag) |
||
217 | } |
||
4726 | leency | 218 | else |
4411 | leency | 219 | { |
220 | ignor_param = true; |
||
221 | if (!ignor_text) && (strlen(#tagparam)+1 |
||
222 | } |
||
223 | bufpos++; |
||
224 | } |
||
4508 | leency | 225 | strlwr(#tag); |
4411 | leency | 226 | |
227 | if (tag[strlen(#tag)-1]=='/') tag[strlen(#tag)-1]=NULL; //for br/ |
||
228 | |||
229 | |||
4726 | leency | 230 | if (stolbec + utf8_strlen(#line) > list.column_max) Perenos(); |
4411 | leency | 231 | |
5712 | leency | 232 | line = NULL; |
4411 | leency | 233 | if (tag) SetTextStyle(WB1.DrawBuf.zoom * 5 + list.x, stroka * list.line_h + list.y + 5); //обработка тегов |
4677 | leency | 234 | tag = attr = tagparam = ignor_param = NULL; |
5678 | leency | 235 | break; |
5746 | leency | 236 | default: |
4411 | leency | 237 | DEFAULT_MARK: |
238 | if (bukva<=15) bukva=' '; |
||
239 | line_len = utf8_strlen(#line); |
||
240 | if (!style.pre) && (bukva == ' ') |
||
5712 | leency | 241 | { |
5746 | leency | 242 | if (line[line_len-1]==' ') break; //no double spaces |
4411 | leency | 243 | if (!stolbec) && (!line) break; //no paces at the beginning of the line |
4726 | leency | 244 | } |
245 | if (line_len < sizeof(line)) chrcat(#line, bukva); |
||
4411 | leency | 246 | if (stolbec + line_len > list.column_max) Perenos(); |
4726 | leency | 247 | } |
248 | } |
||
4411 | leency | 249 | DrawPage(); |
250 | NewLine(); |
||
4692 | leency | 251 | DrawBar(list.x, stroka * list.line_h + list.y + 5, draw_line_width, -stroka * list.line_h + list.h - 5, bg_color); |
252 | DrawBar(list.x, list.visible * list.line_h + list.y + 4, draw_line_width, -list.visible * list.line_h + list.h - 4, bg_color); |
||
5678 | leency | 253 | if (list.first == 0) list.count = stroka; |
254 | if (anchor) //если посреди текста появится новый якорь - будет бесконечный цикл |
||
4415 | leency | 255 | { |
4411 | leency | 256 | anchor=NULL; |
257 | list.first=anchor_line_num; |
||
258 | Parse(); |
||
4415 | leency | 259 | } |
4636 | leency | 260 | DrawScroller(); |
4411 | leency | 261 | } |
262 | //============================================================================================ |
||
263 | void TWebBrowser::Perenos() |
||
5747 | leency | 264 | { |
4718 | leency | 265 | int perenos_num; |
266 | char new_line_text[4096]; |
||
267 | perenos_num = strrchr(#line, ' '); |
||
268 | if (!perenos_num) && (utf8_strlen(#line)>list.column_max) perenos_num=list.column_max; |
||
269 | strcpy(#new_line_text, #line + perenos_num); |
||
5712 | leency | 270 | line[perenos_num] = 0x00; |
4718 | leency | 271 | if (stroka-1 > list.visible) && (list.first <>0) end_parsing=true; |
272 | DrawPage(); |
||
273 | strcpy(#line, #new_line_text); |
||
274 | NewLine(); |
||
275 | } |
||
276 | //============================================================================================ |
||
277 | char oldtag[100]; |
||
5747 | leency | 278 | void TWebBrowser::SetTextStyle(int left1, top1) { |
4411 | leency | 279 | dword hr_color; |
4650 | leency | 280 | byte opened; |
4411 | leency | 281 | byte meta_encoding; |
4491 | leency | 282 | //проверяем тег открывается или закрывается |
4636 | leency | 283 | if (tag[0] == '/') |
4411 | leency | 284 | { |
285 | opened = 0; |
||
286 | strcpy(#tag, #tag+1); |
||
4491 | leency | 287 | } |
4411 | leency | 288 | else opened = 1; |
289 | |||
4491 | leency | 290 | if (istag("html")) { |
5749 | leency | 291 | |
292 | return; |
||
4637 | leency | 293 | } |
4411 | leency | 294 | if (istag("script")) || (istag("style")) || (istag("binary")) || (istag("select")) { ignor_text = opened; return; } |
295 | if (istag("form")) if (!opened) ignor_text = false; |
||
5749 | leency | 296 | if(istag("title")) { |
5746 | leency | 297 | if (opened) header=NULL; |
5749 | leency | 298 | else if (!stroka) DrawTitle(#header); //тег закрылся - вывели строку |
4491 | leency | 299 | return; |
4411 | leency | 300 | } |
301 | if (ignor_text) return; |
||
302 | |||
303 | IF(istag("q")) |
||
304 | |||
5746 | leency | 305 | if (opened) strcat(#line, " \""); |
4491 | leency | 306 | if (!opened) strcat(#line, "\" "); |
5746 | leency | 307 | return; |
308 | } |
||
5749 | leency | 309 | if (anchor) && (isattr("id=")) { //очень плохо!!! потому что если не последний тег, работать не будет |
4491 | leency | 310 | if (!strcmp(#anchor, #val)) anchor_line_num=list.first+stroka; |
5749 | leency | 311 | } |
5746 | leency | 312 | if (istag("body")) { |
5749 | leency | 313 | t_body = opened; |
314 | do{ |
||
4637 | leency | 315 | if (isattr("link=")) link_color_inactive = GetColor(#val); |
4411 | leency | 316 | if (isattr("alink=")) link_color_active = GetColor(#val); |
5746 | leency | 317 | if (isattr("text=")) text_colors[0]=GetColor(#val); |
318 | if (isattr("bgcolor=")) |
||
319 | { |
||
320 | bg_color=GetColor(#val); |
||
4411 | leency | 321 | DrawBuf.Fill(bg_color); |
5746 | leency | 322 | } |
4475 | leency | 323 | } while(GetNextParam()); |
4411 | leency | 324 | if (opened) && (cur_encoding==CH_NULL) debugln("Document has no information about encoding, UTF will be used"); |
325 | return; |
||
5749 | leency | 326 | } |
4411 | leency | 327 | if (istag("a")) { |
328 | if (opened) |
||
5749 | leency | 329 | { |
4491 | leency | 330 | if (link) IF(text_color_index > 0) text_color_index--; //если предыдущий тег а не был закрыт |
4411 | leency | 331 | do{ |
332 | if (isattr("href=")) |
||
333 | { |
||
5746 | leency | 334 | if (stroka - 1 > list.visible) || (stroka < -2) return; |
4411 | leency | 335 | text_color_index++; |
4415 | leency | 336 | text_colors[text_color_index] = text_colors[text_color_index-1]; |
4411 | leency | 337 | link = 1; |
338 | text_colors[text_color_index] = link_color_inactive; |
||
339 | PageLinks.AddLink(#val, DrawBuf.zoom * stolbec * list.font_w + left1, top1-DrawBuf.zoom); |
||
4491 | leency | 340 | } |
5746 | leency | 341 | if (anchor) && (isattr("name=")) |
4411 | leency | 342 | { |
5746 | leency | 343 | if (!strcmp(#anchor, #val)) |
4411 | leency | 344 | { |
5746 | leency | 345 | anchor_line_num=list.first+stroka; |
4411 | leency | 346 | } |
4415 | 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")) { |
||
357 | if (opened) |
||
5749 | leency | 358 | { |
4491 | leency | 359 | text_color_index++; |
4411 | leency | 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); |
||
363 | } while(GetNextParam()); |
||
5749 | leency | 364 | } |
4411 | leency | 365 | else if (text_color_index > 0) text_color_index--; |
366 | return; |
||
5749 | leency | 367 | } |
4411 | leency | 368 | if (istag("div")) || (istag("header")) || (istag("article")) || (istag("footer")) { |
369 | IF(oldtag[0] != 'h') NewLine(); |
||
5746 | leency | 370 | if (isattr("bgcolor=")) |
5749 | leency | 371 | { |
5746 | leency | 372 | bg_color=GetColor(#val); |
5493 | leency | 373 | DrawBuf.Fill(bg_color); |
5746 | leency | 374 | } |
5493 | leency | 375 | return; |
376 | } |
||
4411 | leency | 377 | if (istag("p")) { |
378 | IF(oldtag[0] == 'h') return; |
||
5746 | leency | 379 | NewLine(); |
4411 | leency | 380 | IF(opened) NewLine(); |
4692 | leency | 381 | return; |
382 | } |
||
4411 | leency | 383 | if (istag("br")) { NewLine(); return; } |
384 | if (istag("tr")) { if (opened) { NewLine(); strcat(#line, "| "); } return; } |
||
5749 | leency | 385 | if (istag("td")) || (istag("th")) { if (!opened) strcat(#line, " | "); return; } |
386 | if (istag("b")) || (istag("strong")) || (istag("big")) { style.b = opened; return; } |
||
387 | if (istag("i")) || (istag("em")) || (istag("subtitle")) { style.i=opened; return; } |
||
388 | if (istag("u")) || (istag("ins")) { style.u=opened; return;} |
||
389 | if (istag("s")) || (istag("strike")) || (istag("del")) { style.s=opened; return; } |
||
390 | if (istag("dd")) { stolbec += 5; return; } |
||
391 | if (istag("blockquote")) { style.blq = opened; return; } |
||
392 | if (istag("pre")) || (istag("code")) { style.pre = opened; return; } |
||
393 | if (istag("img")) { ImgCache.Images( left1, top1, WB1.list.w); return; } |
||
394 | /* |
||
395 | if (istag("center")) |
||
4475 | leency | 396 | { |
5746 | leency | 397 | if (opened) style.align = ALIGN_CENTER; |
4411 | leency | 398 | if (!opened) |
5746 | leency | 399 | { |
4491 | leency | 400 | NewLine(); |
4411 | leency | 401 | style.align = ALIGN_LEFT; |
4692 | leency | 402 | } |
5746 | leency | 403 | return; |
4411 | leency | 404 | } |
405 | if (istag("right")) |
||
406 | { |
||
5746 | leency | 407 | if (opened) style.align = ALIGN_RIGHT; |
4411 | leency | 408 | if (!opened) |
5746 | leency | 409 | { |
4491 | leency | 410 | NewLine(); |
4411 | leency | 411 | style.align = ALIGN_LEFT; |
4692 | leency | 412 | } |
5746 | leency | 413 | return; |
4411 | leency | 414 | } |
415 | */ |
||
416 | if (istag("h1")) || (istag("h2")) || (istag("h3")) || (istag("h4")) || (istag("caption")) { |
||
4475 | leency | 417 | NewLine(); |
5749 | leency | 418 | if (opened) && (stroka>1) NewLine(); |
4692 | leency | 419 | strcpy(#oldtag, #tag); |
420 | if (opened) |
||
4411 | leency | 421 | { |
4491 | leency | 422 | if (isattr("align=")) && (isval("center")) style.align = ALIGN_CENTER; |
4411 | leency | 423 | if (isattr("align=")) && (isval("right")) style.align = ALIGN_RIGHT; |
5746 | leency | 424 | style.b = 1; |
425 | } |
||
426 | if (!opened) |
||
4411 | leency | 427 | { |
4491 | leency | 428 | style.align = ALIGN_LEFT; |
4411 | leency | 429 | style.b = 0; |
5746 | leency | 430 | } |
431 | return; |
||
4411 | leency | 432 | } |
433 | else |
||
434 | oldtag=NULL; |
||
435 | if (istag("dt")) { |
||
436 | style.li = opened; |
||
5749 | leency | 437 | if (opened) NewLine(); |
5746 | leency | 438 | return; |
5749 | leency | 439 | } |
4411 | leency | 440 | if (istag("li")) || (istag("dt")) //надо сделать вложенные списки |
441 | { |
||
5746 | leency | 442 | style.li = opened; |
4411 | leency | 443 | if (opened) |
5746 | leency | 444 | { |
4491 | leency | 445 | NewLine(); |
4411 | leency | 446 | if (stroka > -1) && (stroka - 2 < list.visible) |
4692 | leency | 447 | DrawBuf.DrawBar(style.li_tab * 5 * list.font_w * DrawBuf.zoom + list.x, list.line_h |
5678 | leency | 448 | / 2 - DrawBuf.zoom - DrawBuf.zoom, DrawBuf.zoom*2, DrawBuf.zoom*2, 0x555555); |
5747 | leency | 449 | } |
450 | return; |
||
4411 | leency | 451 | } |
452 | if (istag("ul")) || (istag("ol")) { |
||
453 | if (!opened) |
||
5749 | leency | 454 | { |
455 | style.li = opened; |
||
456 | style.li_tab--; |
||
457 | NewLine(); |
||
458 | } |
||
459 | else style.li_tab++; |
||
460 | } |
||
461 | if (istag("hr")) { |
||
462 | if (anchor) || (stroka < -1) |
||
463 | { |
||
4411 | leency | 464 | stroka+=2; |
465 | return; |
||
466 | } |
||
467 | if (strcmp(#attr, "color=") == 0) hr_color = GetColor(#val); else hr_color = 0x999999; |
||
468 | NewLine(); |
||
5746 | leency | 469 | DrawBuf.DrawBar(5, list.line_h/2, list.w-10, 1, hr_color); |
4692 | leency | 470 | NewLine(); |
4486 | leency | 471 | } |
4692 | leency | 472 | if (istag("meta")) || (istag("?xml")) { |
4411 | leency | 473 | do{ |
5749 | leency | 474 | if (isattr("charset=")) || (isattr("content=")) || (isattr("encoding=")) |
4411 | leency | 475 | { |
5746 | leency | 476 | strcpy(#val, #val[strrchr(#val, '=')]); //поиск в content= |
4411 | leency | 477 | strlwr(#val); |
5746 | leency | 478 | if (isval("utf-8")) || (isval("utf8")) meta_encoding = CH_UTF8; |
479 | else if (isval("koi8-r")) || (isval("koi8-u")) meta_encoding = CH_KOI8; |
||
5749 | leency | 480 | else if (isval("windows-1251")) || (isval("windows1251")) meta_encoding = CH_CP1251; |
5746 | leency | 481 | else if (isval("iso-8859-5")) || (isval("iso8859-5")) meta_encoding = CH_ISO8859_5; |
482 | else if (isval("dos")) || (isval("cp-866")) meta_encoding = CH_CP866; |
||
483 | if (cur_encoding!=meta_encoding) BufEncode(meta_encoding); |
||
484 | return; |
||
5749 | leency | 485 | } |
4636 | leency | 486 | } while(GetNextParam()); |
4411 | leency | 487 | return; |
488 | } |
||
489 | } |
||
490 | |||
491 | void TWebBrowser::BufEncode(int set_new_encoding) |
||
492 | |||
5749 | leency | 493 | int bufpointer_realsize; |
5704 | leency | 494 | cur_encoding = set_new_encoding; |
495 | if (o_bufpointer==0) |
||
496 | { |
||
497 | o_bufpointer = malloc(bufsize); |
||
498 | strcpy(o_bufpointer, bufpointer); |
||
499 | } |
||
500 | else |
||
501 | { |
||
502 | strcpy(bufpointer, o_bufpointer); |
||
503 | } |
||
504 | } |
||
505 | //============================================================================================ |
||
506 | void TWebBrowser::DrawScroller() |
||
5747 | leency | 507 | { |
4674 | leency | 508 | scroll_wv.max_area = list.count; |
4411 | leency | 509 | scroll_wv.cur_area = list.visible; |
4416 | leency | 510 | scroll_wv.position = list.first; |
511 | |||
512 | scroll_wv.all_redraw = 0; |
||
4411 | leency | 513 | |
5519 | leency | 514 | scroll_wv.start_y = list.y; |
4486 | leency | 515 | |
4508 | leency | 516 | scroll_wv.size_y = list.h; |
4411 | leency | 517 | |
5678 | leency | 518 | |
519 | scrollbar_v_draw(#scroll_wv); |
||
5519 | leency | 520 | |
4416 | leency | 521 | //============================================================================================ |
4411 | leency | 522 | void TWebBrowser::NewLine() |
5747 | leency | 523 | { |
4692 | leency | 524 | int onleft, ontop; |
4475 | leency | 525 | |
5678 | leency | 526 | onleft = list.x + 5; |
4692 | leency | 527 | |
528 | if (!stroka) DrawBar(list.x, list.y, draw_line_width, 5, bg_color); |
||
529 | if (t_html) && (!t_body) return; |
||
5519 | leency | 530 | if (stroka * list.line_h + 5 >= 0) && ( stroka + 1 * list.line_h + 5 < list.h) && (!anchor) |
4637 | leency | 531 | { |
5678 | leency | 532 | if (style.align == ALIGN_CENTER) && (DrawBuf.zoom==1) DrawBuf.AlignCenter(onleft,ontop,list.w,list.line_h,stolbec * list.font_w); |
4475 | leency | 533 | if (style.align == ALIGN_RIGHT) && (DrawBuf.zoom==1) DrawBuf.AlignRight(onleft,ontop,list.w,list.line_h,stolbec * list.font_w); |
5746 | leency | 534 | DrawBuf.bufy = ontop; |
535 | DrawBuf.Show(); |
||
4692 | leency | 536 | DrawBuf.Fill(bg_color); |
4666 | leency | 537 | } |
4475 | leency | 538 | stroka++; |
539 | if (style.blq) stolbec = 6; else stolbec = 0; |
||
540 | if (style.li) stolbec = style.li_tab * 5; |
||
5746 | leency | 541 | } |
542 | //============================================================================================ |
||
4488 | leency | 543 | int istag(dword text) { if (!strcmp(#tag,text)) return 1; else return 0; } |
5747 | leency | 544 | int isattr(dword text) { if (!strcmp(#attr,text)) return 1; else return 0; } |
5746 | leency | 545 | int isval(dword text) { if (!strcmp(#val,text)) return 1; else return 0; }>>>>>>=15)>>>>>=>!-->': |
546 | >7);>>')>> |
||
547 |