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