Subversion Repositories Kolibri OS

Rev

Rev 4491 | Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

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