Subversion Repositories Kolibri OS

Rev

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

  1. #include "..\TWB\links.h"
  2.  
  3.  
  4. dword buf;
  5. dword filesize;
  6.  
  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.  
  11. char header[2048];
  12.  
  13. int     downloader_id;
  14.  
  15. char download_path[]="/rd/1/.download";
  16.  
  17. struct TWebBrowser {
  18.         llist list; //need #include "..\lib\list_box.h"
  19.         DrawBufer DrawBuf;
  20.         void GetNewUrl();
  21.         void ReadHtml();
  22.         void ParseHTML();
  23.         void WhatTextStyle();
  24.         void DrawPage();
  25.         void DrawScroller();
  26.         void TextGoDown();
  27. };
  28.  
  29. TWebBrowser WB1;
  30.  
  31. byte b_text, i_text, u_text, s_text, pre_text, blq_text, li_text, li_tab,
  32.         link, ignor_text, cur_encoding, text_align;
  33. byte condition_text_active, condition_text_val, condition_href, condition_max;
  34.  
  35. enum { _WIN, _DOS, _KOI, _UTF };
  36.  
  37. enum { ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT};
  38.  
  39. dword text_colors[300];
  40. dword text_color_index;
  41. dword link_color_inactive;
  42. dword link_color_active;
  43. dword bg_color;
  44.  
  45. int stroka;
  46. int stolbec;
  47. int tab_len;
  48. int anchor_line_num;
  49.        
  50. char line[500];
  51. char tag[100];
  52. char tagparam[10000];
  53. char parametr[1200];
  54. char options[4096];
  55. char anchor[256];
  56.  
  57. #include "..\TWB\history.h"
  58. #include "..\TWB\colors.h"
  59. #include "..\TWB\unicode_tags.h"
  60. #include "..\TWB\img_cache.h"
  61. #include "..\TWB\parce_tag.h"
  62.  
  63.  
  64.  
  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.        
  81.         if (stroka >= 0) && (stroka - 2 < list.visible) && (line) && (!anchor)
  82.         {
  83.                 start_x = stolbec * 6 + list.x + magrin_left;
  84.                 start_y = stroka * 10 + list.y + magrin_left;
  85.                 line_length = strlen(#line) * 6;
  86.  
  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]);
  92.                 IF (link) {
  93.                         UnsafeDefineButton(start_x-2, start_y, line_length + 3, 9, PageLinks.count + 400 + BT_HIDE, 0xB5BFC9);
  94.                         DrawBuf.DrawBar(start_x, 8, line_length, 1, text_colors[text_color_index]);
  95.                         PageLinks.AddText(#line, line_length, list.line_h);
  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;
  107.         char newurl[4096];
  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.                
  115.         IF (!strcmpn(#URL,"./", 2)) strcpy(#URL, #URL+2);
  116.         strcpy(#newurl, BrowserHistory.CurrentUrl());
  117.  
  118.         if (URL[0] == '/')
  119.         {
  120.                 i = strchr(#newurl+8, '/');
  121.                 newurl[i+7]=0;
  122.                 strcpy(#URL, #URL+1);
  123.         }
  124.                
  125.         _CUT_ST_LEVEL_MARK:
  126.                
  127.                 if (newurl[strrchr(#newurl, '/')-2]<>'/')
  128.                 {
  129.                         newurl[strrchr(#newurl, '/')] = 0x00;
  130.                 }
  131.                
  132.                 IF (!strncmp(#URL,"../",3))
  133.                 {
  134.                         strcpy(#URL,#URL+3);
  135.                         newurl[strrchr(#newurl, '/')-1] = 0x00;
  136.                         goto _CUT_ST_LEVEL_MARK;
  137.                 }
  138.                
  139.                 if (newurl[strlen(#newurl)-1]<>'/') strcat(#newurl, "/");
  140.                
  141.                 strcat(#newurl, #URL);
  142.                 strcpy(#URL, #newurl);
  143. }
  144.  
  145.  
  146.        
  147. void TWebBrowser::ReadHtml(byte encoding)
  148. {
  149.         if (!strncmp(#URL,"http:",5))
  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);
  159.         if (!strncmp(#URL,"http:",5))
  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.  
  171. void TWebBrowser::ParseHTML(dword bufpos){
  172.         word bukva[2];
  173.         int j, perenos_num;
  174.         byte ignor_param;
  175.         char temp[768];
  176.         dword bufstart = bufpos;
  177.        
  178.         b_text = i_text = u_text = s_text = blq_text =
  179.         li_text = link = ignor_text = text_color_index = text_colors[0] = li_tab =
  180.         condition_text_val = condition_text_active = 0; //îáíóëÿåì òåãè
  181.         condition_max = 255;
  182.         text_align = ALIGN_LEFT;
  183.         link_color_inactive = 0x0000FF;
  184.         link_color_active = 0xFF0000;
  185.         bg_color = 0xFFFFFF;
  186.         DrawBuf.Fill(bg_color);
  187.         PageLinks.Clear();
  188.         strcpy(#header, #version);
  189.         stroka = -list.first;
  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.        
  200.         for ( ; bufstart+filesize > bufpos; bufpos++;)
  201.         {
  202.                 bukva = ESBYTE[bufpos];
  203.                 if (ignor_text) && (bukva!='<') continue;
  204.                 if (condition_text_active) && (condition_text_val != condition_href) && (bukva!='<') continue;
  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<tab_len; j++;) chrcat(#line,' ');
  220.                                 break;
  221.                         }
  222.                         goto DEFAULT_MARK;             
  223.                 case '=': //quoted printable
  224.                         if (strcmp(#URL + strlen(#URL) - 4, ".mht")<>0) goto DEFAULT_MARK;
  225.  
  226.                         temp[0] = ESBYTE[bufpos+1];
  227.                         temp[1] = ESBYTE[bufpos+2];
  228.                         temp[2] = '\0';
  229.                         if (bukva = Hex2Symb(#temp))
  230.                         {
  231.                                 bufpos+=2;
  232.                                 goto DEFAULT_MARK;
  233.                         }
  234.                         break;
  235.                        
  236.                 case '&': //&nbsp; and so on
  237.                         bufpos++;
  238.                         tag=0;
  239.                         for (j=0; (ESBYTE[bufpos]<>';') && (j<7);   j++, bufpos++;)
  240.                         {
  241.                                 bukva = ESBYTE[bufpos];
  242.                                 chrcat(#tag, bukva);
  243.                         }
  244.                         if (bukva = GetUnicodeSymbol()) goto DEFAULT_MARK;
  245.                         break;
  246.                 case '<':
  247.                         bufpos++; //ïðîìîòàåì ñèìâîë <
  248.                         tag = parametr = tagparam = ignor_param = NULL;
  249.                         if (ESBYTE[bufpos] == '!') //ôèëüòðàöèÿ âíóòðè <!-- -->, äåðçêî
  250.                         {
  251.                                 bufpos++;
  252.                                 if (ESBYTE[bufpos] == '-')
  253.                                 {
  254.                                 HH_:
  255.                                         do
  256.                                         {
  257.                                                 bufpos++;
  258.                                                 if (bufstart + filesize <= bufpos) break 2;
  259.                                         }
  260.                                         while (ESBYTE[bufpos] <>'-');
  261.                                        
  262.                                         bufpos++;
  263.                                         if (ESBYTE[bufpos] <>'-') goto HH_;
  264.                                 }
  265.                         }
  266.                         while (ESBYTE[bufpos] !='>') && (bufpos < bufstart + filesize) //ïîëó÷àåì òåã è åãî ïàðàìåòðû
  267.                         {
  268.                                 bukva = ESBYTE[bufpos];
  269.                                 if (bukva == '\9') || (bukva == '\x0a') || (bukva == '\x0d') bukva = ' ';
  270.                                 if (!ignor_param) && (bukva <>' ')
  271.                                 {
  272.                                         if (strlen(#tag)<sizeof(tag)) strcat(#tag, #bukva);
  273.                                 }
  274.                                 else
  275.                                 {
  276.                                         ignor_param = true;
  277.                                         if (!ignor_text) && (strlen(#tagparam)+1<sizeof(tagparam)) strcat(#tagparam, #bukva);
  278.                                 }
  279.                                 bufpos++;
  280.                         }
  281.                         strlwr(#tag);
  282.                         strlwr(#tagparam);
  283.  
  284.                         if (condition_text_active) && (condition_text_val != condition_href)
  285.                         {
  286.                                 if (strcmp(#tag, "/condition")!=0) break;
  287.                         }
  288.                         if (tag[strlen(#tag)-1]=='/') tag[strlen(#tag)-1]=NULL; //for br/
  289.                         if (tagparam) && (strlen(#tagparam) < 4000) GetNextParam();
  290.  
  291.                         if (stolbec + strlen(#line) > list.column_max) //============the same as NEXT_MARK
  292.                         {
  293.                                 perenos_num = strrchr(#line, ' ');
  294.                                 if (!perenos_num) && (strlen(#line)>list.column_max) perenos_num=list.column_max;
  295.                                 strcpy(#temp, #line + perenos_num); //ïåðåíîñ ïî ñëîâàì
  296.                                 line[perenos_num] = 0x00;
  297.                                 if (stroka-1 > list.visible) && (list.first <>0) break 1; //óõîäèì...
  298.                                 DrawPage();
  299.                                 strcpy(#line, #temp);                          
  300.                                 TextGoDown(list.x + 5, stroka * 10 + list.y + 5, list.w - 20); //çàêðàøèâàåì ñëåäóùóþ ñòðîêó
  301.                         }
  302.                         DrawPage();
  303.  
  304.                         if (tag) WhatTextStyle(list.x + 5, stroka * 10 + list.y + 5, list.w - 20); //îáðàáîòêà òåãîâ
  305.                         line=NULL;
  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)<sizeof(line)) chrcat(#line, bukva);
  318.  
  319.                         if (stolbec + strlen(#line) > list.column_max)
  320.                         {
  321.                         NEXT_MARK:
  322.                                 perenos_num = strrchr(#line, ' ');
  323.                                 if (!perenos_num) && (strlen(#line)>list.column_max) perenos_num=list.column_max;
  324.                                 strcpy(#temp, #line + perenos_num); //ïåðåíîñ ïî ñëîâàì
  325.                                 line[perenos_num] = 0x00;
  326.                                 if (stroka-1 > list.visible) && (list.first <>0) break 1; //óõîäèì...
  327.                                 DrawPage();
  328.                                 strcpy(#line, #temp);                  
  329.                                 TextGoDown(list.x + 5, stroka * 10 + list.y + 5, list.w - 20); //çàêðàøèâàåì ñëåäóùóþ ñòðîêó
  330.                         }
  331.                 }
  332.         }
  333.  
  334.         DrawPage(); //ðèñóåò ïîñëåäíþþ ñòðîêó, ïîòîì ýòî íàäî óáðàòü, îïòèìèçèðîâàâ êîä
  335.         TextGoDown(list.x + 5, stroka * 10 + list.y + 5, list.w - 20); //çàêðàøèâàåì ñëåäóùóþ ñòðîêó
  336.  
  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);
  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); //çàêðàøèâàåì âñ¸ äî êîíöà
  341.         if (list.first == 0) list.count = stroka;
  342.         if (anchor) //åñëè ïîñðåäè òåêñòà ïîÿâèòñÿ íîâûé ÿêîðü - áóäåò áåñêîíå÷íûé öèêë
  343.         {
  344.                 anchor=NULL;
  345.                 list.first=anchor_line_num;
  346.                 ParseHTML(bufstart);
  347.         }
  348.         DrawScroller();
  349. }
  350.  
  351.  
  352.  
  353. char oldtag[100];
  354. void TWebBrowser::WhatTextStyle(int left1, top1, width1) {
  355.         dword hr_color;
  356.         byte opened;
  357.  
  358.         //ïðîâåðÿåì òåã îòêðûâàåòñÿ èëè çàêðûâàåòñÿ
  359.         if (tag[0] == '/')
  360.         {
  361.                  opened = 0;
  362.                  strcpy(#tag, #tag+1);
  363.         }
  364.         else opened = 1;
  365.                
  366.         if (isTag("html"))
  367.         {
  368.                 IF(!strcmp(#URL + strlen(#URL) - 4, ".mht")) IF (opened==0) ignor_text = 1; ELSE ignor_text = 0;
  369.                 return;
  370.         }
  371.  
  372.         if (isTag("script")) || (isTag("style")) || (isTag("binary")) ignor_text = opened;
  373.  
  374.         if(isTag("title"))
  375.         {
  376.                 if (opened) header=NULL;
  377.                 else if (!stroka) DrawTitle(#header); //òåã çàêðûëñÿ - âûâåëè ñòðîêó
  378.                 return;
  379.         }
  380.  
  381.         if (ignor_text) return;
  382.        
  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.         }
  396.  
  397.         if (anchor) && (!strcmp(#parametr, "id=")) //î÷åíü ïëîõî!!! ïîòîìó ÷òî åñëè íå ïîñëåäíèé òåã, ðàáîòàòü íå áóäåò
  398.         {
  399.                 if (!strcmp(#anchor, #options)) anchor_line_num=list.first+stroka;
  400.         }
  401.        
  402.         if (isTag("body"))
  403.         {
  404.                 do{
  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);
  408.                         if (!strcmp(#parametr, "text=")) text_colors[0]=GetColor(#options);
  409.                         if (!strcmp(#parametr, "bgcolor="))
  410.                         {
  411.                                 bg_color=GetColor(#options);
  412.                                 DrawBuf.Fill(bg_color);
  413.                         }
  414.                 } while(GetNextParam());
  415.                 return;
  416.         }
  417.  
  418.         if (isTag("a"))
  419.         {
  420.                 if (opened)
  421.                 {
  422.                         if (link) IF(text_color_index > 0) text_color_index--; //åñëè ïðåäûäóùèé òåã à íå áûë çàêðûò
  423.  
  424.                         do{
  425.                                 if (!strcmp(#parametr, "href="))
  426.                                 {
  427.                                         if (stroka - 1 > list.visible) || (stroka < -2) return;
  428.                                        
  429.                                         text_color_index++;
  430.                                         text_colors[text_color_index] = text_colors[text_color_index-1];
  431.                                        
  432.                                         link = 1;
  433.                                         text_colors[text_color_index] = link_color_inactive;
  434.                                         PageLinks.AddLink(#options, stolbec*6+left1, top1);
  435.                                 }
  436.                                 if (anchor) && (!strcmp(#parametr, "name="))
  437.                                 {
  438.                                         if (!strcmp(#anchor, #options))
  439.                                         {
  440.                                                 anchor_line_num=list.first+stroka;
  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.  
  452.         if (isTag("font"))
  453.         {
  454.                 if (opened)
  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.         }
  470.         if(isTag("tr")) || (isTag("br")) {
  471.                 TextGoDown(left1, top1, width1);
  472.                 return;
  473.         }
  474.         if (isTag("div")) || (isTag("header")) || (isTag("footer")) {
  475.                 IF(oldtag[0] <>'h') TextGoDown(left1, top1, width1);
  476.                 return;
  477.         }
  478.         if (isTag("p")) {
  479.                 IF(oldtag[0] == 'h') return;
  480.                 TextGoDown(left1, top1, width1);
  481.                 IF(opened) TextGoDown(left1, top1 + 10, width1);
  482.                 return;
  483.         }
  484.         /*
  485.         if (isTag("center"))
  486.         {
  487.                 if (opened) text_align = ALIGN_CENTER;
  488.                 if (!opened)
  489.                 {
  490.                         TextGoDown(left1, top1, width1);
  491.                         text_align = ALIGN_LEFT;
  492.                 }
  493.                 return;
  494.         }
  495.         if (isTag("right"))
  496.         {
  497.                 if (opened) text_align = ALIGN_RIGHT;
  498.                 if (!opened)
  499.                 {
  500.                         TextGoDown(left1, top1, width1);
  501.                         text_align = ALIGN_LEFT;
  502.                 }
  503.                 return;
  504.         }
  505.         */
  506.         if (isTag("h1")) || (isTag("h2")) || (isTag("h3")) || (isTag("h4")) {
  507.                 TextGoDown(left1, top1, width1);
  508.                 if (opened) && (stroka>1) TextGoDown(left1, top1 + 10, width1);
  509.                 strcpy(#oldtag, #tag);
  510.                 if (opened)
  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.                 }
  516.                 if (!opened)
  517.                 {
  518.                         text_align = ALIGN_LEFT;
  519.                         b_text = 0;
  520.                 }
  521.                 return;
  522.         }
  523.         else
  524.                 oldtag=NULL;
  525.                
  526.         if (isTag("b")) || (isTag("strong")) || (isTag("big")) {
  527.                 b_text = opened;
  528.                 return;
  529.         }
  530.         if(isTag("i")) || (isTag("em")) || (isTag("subtitle")) {
  531.                 i_text = opened;
  532.                 return;
  533.         }      
  534.         if (isTag("dt"))
  535.         {
  536.                 li_text = opened;
  537.                 IF(opened == 0) return;
  538.                 TextGoDown(left1, top1, width1);
  539.                 return;
  540.         }
  541.         if (isTag("condition"))
  542.         {
  543.                 condition_text_active = opened;
  544.                 if (opened) && (!strcmp(#parametr, "show_if=")) condition_text_val = atoi(#options);
  545.                 return;
  546.         }
  547.         if (isTag("li")) || (isTag("dt")) //íàäî ñäåëàòü âëîæåííûå ñïèñêè
  548.         {
  549.                 li_text = opened;
  550.                 if (opened)
  551.                 {
  552.                         TextGoDown(left1, top1, width1);
  553.                         if (stroka > -1) && (stroka - 2 < list.visible) DrawBuf.DrawBar(li_tab * 5 * 6 + left1 - 5, list.line_h/2-3, 2, 2, 0x555555);
  554.                 }
  555.                 return;
  556.         }
  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)
  560.         {
  561.                 li_text = opened;
  562.                 li_tab--;
  563.                 TextGoDown(left1, top1, width1);
  564.         } ELSE li_tab++;
  565.         if (isTag("dd")) stolbec += 5;
  566.         if (isTag("blockquote")) blq_text = opened;
  567.         if (isTag("pre")) || (isTag("code")) pre_text = opened;
  568.         if (isTag("hr"))
  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);
  577.                 DrawBuf.DrawBar(5, list.line_h/2, list.w-10, 1, hr_color);
  578.                 TextGoDown(left1, top1+list.line_h, width1);
  579.         }
  580.         if (isTag("img"))
  581.         {
  582.                 ImgCache.Images( left1, top1, width1);
  583.                 return;
  584.         }
  585.         if (isTag("meta")) || (isTag("?xml"))
  586.         {
  587.                 do{
  588.                         if (!strcmp(#parametr, "charset=")) || (!strcmp(#parametr, "content=")) || (!strcmp(#parametr, "encoding="))
  589.                         {
  590.                                 strcpy(#options, #options[strrchr(#options, '=')]); //ïîèñê â content=
  591.                                 if (!strcmp(#options, "utf-8"))  || (!strcmp(#options,"utf8"))      ReadHtml(_UTF);
  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.  
  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. */
  610.  
  611. void TWebBrowser::DrawScroller() //íå îïòèìàëüíàÿ îòðèñîâêà, íî çàòî â îäíîì ìåñòå
  612. {
  613.         scroll_wv.max_area = list.count;
  614.         scroll_wv.cur_area = list.visible;
  615.         scroll_wv.position = list.first;
  616.  
  617.         scroll_wv.all_redraw=1;
  618.         scroll_wv.start_x = list.x + list.w;
  619.         scroll_wv.start_y = list.y;
  620.         scroll_wv.size_y=list.h;
  621.  
  622.         scrollbar_v_draw(#scroll_wv);
  623. }
  624.  
  625.  
  626. void TWebBrowser::TextGoDown(int left1, top1, width1)
  627. {
  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)
  630.         {
  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);
  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;
  639. }
  640.  
  641.  
  642.  
  643. int isTag(dword text)
  644. {
  645.         if (!strcmp(#tag,text)) return 1; else return 0;
  646. }
  647.