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