Subversion Repositories Kolibri OS

Rev

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

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