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