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