Subversion Repositories Kolibri OS

Rev

Rev 4544 | 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 Parse();
  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, UNDERLINE);
  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::Parse(dword bufpos, in_filesize){
  170.         word bukva[2];
  171.         int j, perenos_num;
  172.         byte ignor_param;
  173.         char temp[768];
  174.         bufsize = in_filesize;
  175.         bufpointer = bufpos;
  176.        
  177.         b_text = i_text = u_text = s_text = blq_text =
  178.         li_text = link = ignor_text = text_color_index = text_colors[0] = li_tab =
  179.         condition_text_val = condition_text_active = 0; //îáíóëÿåì òåãè
  180.         condition_max = 255;
  181.         text_align = ALIGN_LEFT;
  182.         link_color_inactive = 0x0000FF;
  183.         link_color_active = 0xFF0000;
  184.         bg_color = 0xFFFFFF;
  185.         DrawBuf.Fill(bg_color);
  186.         PageLinks.Clear();
  187.         strcpy(#header, #version);
  188.         stroka = -list.first;
  189.         stolbec = 0;
  190.         line = 0;
  191.  
  192.         if (pre_text<>2)
  193.         {
  194.                 pre_text=0;
  195.                 if (!strcmp(#URL + strlen(#URL) - 4, ".txt")) pre_text = 1;
  196.                 if (!strcmp(#URL + strlen(#URL) - 4, ".mht")) ignor_text = 1;
  197.         }
  198.        
  199.         for ( ; bufpointer+bufsize > bufpos; bufpos++;)
  200.         {
  201.                 bukva = ESBYTE[bufpos];
  202.                 if (ignor_text) && (bukva!='<') continue;
  203.                 if (condition_text_active) && (condition_text_val != condition_href) && (bukva!='<') continue;
  204.                 switch (bukva)
  205.                 {
  206.                 case 0x0a:
  207.                         if (pre_text)
  208.                         {
  209.                                 bukva = temp = NULL;
  210.                                 goto NEXT_MARK;
  211.                         }
  212.                 case '\9':
  213.                         if (pre_text) //èíà÷å èä¸ì íà 0x0d     
  214.                         {
  215.                                 tab_len=strlen(#line)/8;
  216.                                 tab_len=tab_len*8;
  217.                                 tab_len=8+tab_len-strlen(#line);
  218.                                 for (j=0; j<tab_len; j++;) chrcat(#line,' ');
  219.                                 break;
  220.                         }
  221.                         goto DEFAULT_MARK;             
  222.                 case '=': //quoted printable
  223.                         if (strcmp(#URL + strlen(#URL) - 4, ".mht")<>0) goto DEFAULT_MARK;
  224.  
  225.                         temp[0] = ESBYTE[bufpos+1];
  226.                         temp[1] = ESBYTE[bufpos+2];
  227.                         temp[2] = '\0';
  228.                         if (bukva = Hex2Symb(#temp))
  229.                         {
  230.                                 bufpos+=2;
  231.                                 goto DEFAULT_MARK;
  232.                         }
  233.                         break;
  234.                        
  235.                 case '&': //&nbsp; and so on
  236.                         bufpos++;
  237.                         tag=0;
  238.                         for (j=0; (ESBYTE[bufpos]<>';') && (j<7);   j++, bufpos++;)
  239.                         {
  240.                                 bukva = ESBYTE[bufpos];
  241.                                 chrcat(#tag, bukva);
  242.                         }
  243.                         if (bukva = GetUnicodeSymbol()) goto DEFAULT_MARK;
  244.                         break;
  245.                 case '<':
  246.                         bufpos++; //ïðîìîòàåì ñèìâîë <
  247.                         tag = parametr = tagparam = ignor_param = NULL;
  248.                         if (ESBYTE[bufpos] == '!') //ôèëüòðàöèÿ âíóòðè <!-- -->, äåðçêî
  249.                         {
  250.                                 bufpos++;
  251.                                 if (ESBYTE[bufpos] == '-')
  252.                                 {
  253.                                 HH_:
  254.                                         do
  255.                                         {
  256.                                                 bufpos++;
  257.                                                 if (bufpointer + bufsize <= bufpos) break 2;
  258.                                         }
  259.                                         while (ESBYTE[bufpos] <>'-');
  260.                                        
  261.                                         bufpos++;
  262.                                         if (ESBYTE[bufpos] <>'-') goto HH_;
  263.                                 }
  264.                         }
  265.                         while (ESBYTE[bufpos] !='>') && (bufpos < bufpointer + bufsize) //ïîëó÷àåì òåã è åãî ïàðàìåòðû
  266.                         {
  267.                                 bukva = ESBYTE[bufpos];
  268.                                 if (bukva == '\9') || (bukva == '\x0a') || (bukva == '\x0d') bukva = ' ';
  269.                                 if (!ignor_param) && (bukva <>' ')
  270.                                 {
  271.                                         if (strlen(#tag)<sizeof(tag)) strcat(#tag, #bukva);
  272.                                 }
  273.                                 else
  274.                                 {
  275.                                         ignor_param = true;
  276.                                         if (!ignor_text) && (strlen(#tagparam)+1<sizeof(tagparam)) strcat(#tagparam, #bukva);
  277.                                 }
  278.                                 bufpos++;
  279.                         }
  280.                         strlwr(#tag);
  281.                         strlwr(#tagparam);
  282.  
  283.                         if (condition_text_active) && (condition_text_val != condition_href)
  284.                         {
  285.                                 if (strcmp(#tag, "/condition")!=0) break;
  286.                         }
  287.                         if (tag[strlen(#tag)-1]=='/') tag[strlen(#tag)-1]=NULL; //for br/
  288.                         if (tagparam) && (strlen(#tagparam) < 4000) GetNextParam();
  289.  
  290.                         if (stolbec + strlen(#line) > list.column_max) //============the same as NEXT_MARK
  291.                         {
  292.                                 perenos_num = strrchr(#line, ' ');
  293.                                 if (!perenos_num) && (strlen(#line)>list.column_max) perenos_num=list.column_max;
  294.                                 strcpy(#temp, #line + perenos_num); //ïåðåíîñ ïî ñëîâàì
  295.                                 line[perenos_num] = 0x00;
  296.                                 if (stroka-1 > list.visible) && (list.first <>0) break 1; //óõîäèì...
  297.                                 DrawPage();
  298.                                 strcpy(#line, #temp);                          
  299.                                 TextGoDown(list.x + 5, stroka * 10 + list.y + 5, list.w - 20); //çàêðàøèâàåì ñëåäóùóþ ñòðîêó
  300.                         }
  301.                         DrawPage();
  302.  
  303.                         line=NULL;
  304.                         if (tag) WhatTextStyle(list.x + 5, stroka * 10 + list.y + 5, list.w - 20); //îáðàáîòêà òåãîâ
  305.  
  306.                         tag = parametr = tagparam = ignor_param = NULL;
  307.                         break;
  308.                 default:
  309.                         DEFAULT_MARK:
  310.                         if (bukva<=15) bukva=' ';
  311.                         if (!pre_text) && (bukva == ' ')
  312.                         {
  313.                                 if (line[strlen(#line)-1]==' ') break; //óáðàòü 2 ïðîáåëà ïîäðÿä
  314.                                 if (!stolbec) && (!line) break; //ñòðîêà íå ìîæåò íà÷èíàòüñÿ ñ ïðîáåëà
  315.                         }
  316.                         if (strlen(#line)<sizeof(line)) chrcat(#line, bukva);
  317.  
  318.                         if (stolbec + strlen(#line) > list.column_max)
  319.                         {
  320.                         NEXT_MARK:
  321.                                 perenos_num = strrchr(#line, ' ');
  322.                                 if (!perenos_num) && (strlen(#line)>list.column_max) perenos_num=list.column_max;
  323.                                 strcpy(#temp, #line + perenos_num); //ïåðåíîñ ïî ñëîâàì
  324.                                 line[perenos_num] = 0x00;
  325.                                 if (stroka-1 > list.visible) && (list.first <>0) break 1; //óõîäèì...
  326.                                 DrawPage();
  327.                                 strcpy(#line, #temp);                  
  328.                                 TextGoDown(list.x + 5, stroka * 10 + list.y + 5, list.w - 20); //çàêðàøèâàåì ñëåäóùóþ ñòðîêó
  329.                         }
  330.                 }
  331.         }
  332.  
  333.         DrawPage(); //ðèñóåò ïîñëåäíþþ ñòðîêó, ïîòîì ýòî íàäî óáðàòü, îïòèìèçèðîâàâ êîä
  334.         TextGoDown(list.x + 5, stroka * 10 + list.y + 5, list.w - 20); //çàêðàøèâàåì ñëåäóùóþ ñòðîêó
  335.  
  336.         if (list.visible * 10 + 25 <= list.h)
  337.                 DrawBar(list.x, list.visible * 10 + list.y + 25, list.w, -list.visible * 10 + list.h - 25, bg_color);
  338.         if (stroka * 10 + 5 <= list.h)
  339.                 DrawBar(list.x, stroka * 10 + list.y + 5, list.w, -stroka * 10 + list.h - 5, bg_color); //çàêðàøèâàåì âñ¸ äî êîíöà
  340.         if (list.first == 0) list.count = stroka;
  341.         if (anchor) //åñëè ïîñðåäè òåêñòà ïîÿâèòñÿ íîâûé ÿêîðü - áóäåò áåñêîíå÷íûé öèêë
  342.         {
  343.                 anchor=NULL;
  344.                 list.first=anchor_line_num;
  345.                 Parse(bufpointer, bufsize);
  346.         }
  347.         DrawScroller();
  348. }
  349.  
  350.  
  351.  
  352. char oldtag[100];
  353. void TWebBrowser::WhatTextStyle(int left1, top1, width1) {
  354.         dword hr_color;
  355.         byte opened;
  356.  
  357.         //ïðîâåðÿåì òåã îòêðûâàåòñÿ èëè çàêðûâàåòñÿ
  358.         if (tag[0] == '/')
  359.         {
  360.                  opened = 0;
  361.                  strcpy(#tag, #tag+1);
  362.         }
  363.         else opened = 1;
  364.                
  365.         if (isTag("html"))
  366.         {
  367.                 IF(!strcmp(#URL + strlen(#URL) - 4, ".mht")) IF (opened==0) ignor_text = 1; ELSE ignor_text = 0;
  368.                 return;
  369.         }
  370.  
  371.         if (isTag("script")) || (isTag("style")) || (isTag("binary")) ignor_text = opened;
  372.  
  373.         if(isTag("title"))
  374.         {
  375.                 if (opened) header=NULL;
  376.                 else if (!stroka) DrawTitle(#header); //òåã çàêðûëñÿ - âûâåëè ñòðîêó
  377.                 return;
  378.         }
  379.  
  380.         if (ignor_text) return;
  381.        
  382.         IF(isTag("q"))
  383.         {
  384.                 if (opened)
  385.                 {
  386.                         TextGoDown(left1, top1, width1);
  387.                         strcat(#line, ' \"');
  388.                 }
  389.                 if (!opened)
  390.                 {
  391.                         chrcat(#line, '\"');
  392.                         TextGoDown(left1, top1, width1);
  393.                 }
  394.         }
  395.  
  396.         if (anchor) && (!strcmp(#parametr, "id=")) //î÷åíü ïëîõî!!! ïîòîìó ÷òî åñëè íå ïîñëåäíèé òåã, ðàáîòàòü íå áóäåò
  397.         {
  398.                 if (!strcmp(#anchor, #options)) anchor_line_num=list.first+stroka;
  399.         }
  400.        
  401.         if (isTag("body"))
  402.         {
  403.                 do{
  404.                         if (!strcmp(#parametr, "condition_max=")) condition_max = atoi(#options);
  405.                         if (!strcmp(#parametr, "link=")) link_color_inactive = GetColor(#options);
  406.                         if (!strcmp(#parametr, "alink=")) link_color_active = GetColor(#options);
  407.                         if (!strcmp(#parametr, "text=")) text_colors[0]=GetColor(#options);
  408.                         if (!strcmp(#parametr, "bgcolor="))
  409.                         {
  410.                                 bg_color=GetColor(#options);
  411.                                 DrawBuf.Fill(bg_color);
  412.                         }
  413.                 } while(GetNextParam());
  414.                 return;
  415.         }
  416.  
  417.         if (isTag("a"))
  418.         {
  419.                 if (opened)
  420.                 {
  421.                         if (link) IF(text_color_index > 0) text_color_index--; //åñëè ïðåäûäóùèé òåã à íå áûë çàêðûò
  422.  
  423.                         do{
  424.                                 if (!strcmp(#parametr, "href="))
  425.                                 {
  426.                                         if (stroka - 1 > list.visible) || (stroka < -2) return;
  427.                                        
  428.                                         text_color_index++;
  429.                                         text_colors[text_color_index] = text_colors[text_color_index-1];
  430.                                        
  431.                                         link = 1;
  432.                                         text_colors[text_color_index] = link_color_inactive;
  433.                                         PageLinks.AddLink(#options, stolbec*6+left1, top1);
  434.                                 }
  435.                                 if (anchor) && (!strcmp(#parametr, "name="))
  436.                                 {
  437.                                         if (!strcmp(#anchor, #options))
  438.                                         {
  439.                                                 anchor_line_num=list.first+stroka;
  440.                                         }
  441.                                 }
  442.                         } while(GetNextParam());
  443.                 }
  444.                 else {
  445.                         link = 0;
  446.                         IF(text_color_index > 0) text_color_index--;
  447.                 }
  448.                 return;
  449.         }
  450.  
  451.         if (isTag("font"))
  452.         {
  453.                 if (opened)
  454.                 {
  455.                         text_color_index++;
  456.                         text_colors[text_color_index] = text_colors[text_color_index-1];
  457.                
  458.                         do{
  459.                                 if (strcmp(#parametr, "color=") == 0) //&& (parametr[1] == '#')
  460.                                 {
  461.                                         text_colors[text_color_index] = GetColor(#options);
  462.                                 }
  463.                         } while(GetNextParam());
  464.                 }
  465.                 else
  466.                         if (text_color_index > 0) text_color_index--;
  467.                 return;
  468.         }
  469.         if(isTag("tr")) || (isTag("br")) {
  470.                 TextGoDown(left1, top1, width1);
  471.                 return;
  472.         }
  473.         if (isTag("div")) || (isTag("header")) || (isTag("footer")) {
  474.                 IF(oldtag[0] <>'h') TextGoDown(left1, top1, width1);
  475.                 return;
  476.         }
  477.         if (isTag("p")) {
  478.                 IF(oldtag[0] == 'h') return;
  479.                 TextGoDown(left1, top1, width1);
  480.                 IF(opened) TextGoDown(left1, top1 + 10, width1);
  481.                 return;
  482.         }
  483.         /*
  484.         if (isTag("center"))
  485.         {
  486.                 if (opened) text_align = ALIGN_CENTER;
  487.                 if (!opened)
  488.                 {
  489.                         TextGoDown(left1, top1, width1);
  490.                         text_align = ALIGN_LEFT;
  491.                 }
  492.                 return;
  493.         }
  494.         if (isTag("right"))
  495.         {
  496.                 if (opened) text_align = ALIGN_RIGHT;
  497.                 if (!opened)
  498.                 {
  499.                         TextGoDown(left1, top1, width1);
  500.                         text_align = ALIGN_LEFT;
  501.                 }
  502.                 return;
  503.         }
  504.         */
  505.         if (isTag("h1")) || (isTag("h2")) || (isTag("h3")) || (isTag("h4")) {
  506.                 TextGoDown(left1, top1, width1);
  507.                 if (opened) && (stroka>1) TextGoDown(left1, top1 + 10, width1);
  508.                 strcpy(#oldtag, #tag);
  509.                 if (opened)
  510.                 {
  511.                         if (!strcmp(#parametr, "align=")) && (!strcmp(#options,"center")) text_align = ALIGN_CENTER;
  512.                         if (!strcmp(#parametr, "align=")) && (!strcmp(#options,"right")) text_align = ALIGN_RIGHT;
  513.                         b_text = 1;
  514.                 }
  515.                 if (!opened)
  516.                 {
  517.                         text_align = ALIGN_LEFT;
  518.                         b_text = 0;
  519.                 }
  520.                 return;
  521.         }
  522.         else
  523.                 oldtag=NULL;
  524.                
  525.         if (isTag("b")) || (isTag("strong")) || (isTag("big")) {
  526.                 b_text = opened;
  527.                 return;
  528.         }
  529.         if(isTag("i")) || (isTag("em")) || (isTag("subtitle")) {
  530.                 i_text = opened;
  531.                 return;
  532.         }      
  533.         if (isTag("dt"))
  534.         {
  535.                 li_text = opened;
  536.                 IF(opened == 0) return;
  537.                 TextGoDown(left1, top1, width1);
  538.                 return;
  539.         }
  540.         if (isTag("condition"))
  541.         {
  542.                 condition_text_active = opened;
  543.                 if (opened) && (!strcmp(#parametr, "show_if=")) condition_text_val = atoi(#options);
  544.                 return;
  545.         }
  546.         if (isTag("li")) || (isTag("dt")) //íàäî ñäåëàòü âëîæåííûå ñïèñêè
  547.         {
  548.                 li_text = opened;
  549.                 if (opened)
  550.                 {
  551.                         TextGoDown(left1, top1, width1);
  552.                         if (stroka > -1) && (stroka - 2 < list.visible) DrawBuf.DrawBar(li_tab * 5 * 6 + left1 - 5, list.line_h/2-3, 2, 2, 0x555555);
  553.                 }
  554.                 return;
  555.         }
  556.         if (isTag("u")) || (isTag("ins")) u_text = opened;
  557.         if (isTag("s")) || (isTag("strike")) || (isTag("del")) s_text = opened;
  558.         if (isTag("ul")) || (isTag("ol")) IF(!opened)
  559.         {
  560.                 li_text = opened;
  561.                 li_tab--;
  562.                 TextGoDown(left1, top1, width1);
  563.         } ELSE li_tab++;
  564.         if (isTag("dd")) stolbec += 5;
  565.         if (isTag("blockquote")) blq_text = opened;
  566.         if (isTag("pre")) || (isTag("code")) pre_text = opened;
  567.         if (isTag("hr"))
  568.         {
  569.                 if (anchor) || (stroka < -1)
  570.                 {
  571.                         stroka+=2;
  572.                         return;
  573.                 }
  574.                 if (strcmp(#parametr, "color=") == 0) hr_color = GetColor(#options); else hr_color = 0x999999;
  575.                 TextGoDown(left1, top1, width1);
  576.                 DrawBuf.DrawBar(5, list.line_h/2, list.w-10, 1, hr_color);
  577.                 TextGoDown(left1, top1+list.line_h, width1);
  578.         }
  579.         if (isTag("img"))
  580.         {
  581.                 ImgCache.Images( left1, top1, width1);
  582.                 return;
  583.         }
  584.         if (isTag("meta")) || (isTag("?xml"))
  585.         {
  586.                 do{
  587.                         if (!strcmp(#parametr, "charset=")) || (!strcmp(#parametr, "content=")) || (!strcmp(#parametr, "encoding="))
  588.                         {
  589.                                 strcpy(#options, #options[strrchr(#options, '=')]); //ïîèñê â content=
  590.                                 if (!strcmp(#options, "utf-8"))  || (!strcmp(#options,"utf8"))      ReadHtml(_UTF);
  591.                                 if (!strcmp(#options, "koi8-r")) || (!strcmp(#options, "koi8-u"))   ReadHtml(_KOI);
  592.                                 if (!strcmp(#options, "dos"))    || (!strcmp(#options, "cp-866"))   ReadHtml(_DOS);
  593.                         }
  594.                 } while(GetNextParam());
  595.                 return;
  596.         }
  597. }
  598.  
  599. /*
  600. char *encodings = {
  601.         "utf-8",  _UTF,
  602.         "utf8",   _UTF,
  603.         "koi8-r", _KOI,
  604.         "koi8-u", _KOI,
  605.         "dos",    _DOS,
  606.         "cp-866", _DOS
  607. };
  608. */
  609.  
  610. void TWebBrowser::DrawScroller() //íå îïòèìàëüíàÿ îòðèñîâêà, íî çàòî â îäíîì ìåñòå
  611. {
  612.         scroll_wv.max_area = list.count;
  613.         scroll_wv.cur_area = list.visible;
  614.         scroll_wv.position = list.first;
  615.  
  616.         scroll_wv.all_redraw=1;
  617.         scroll_wv.start_x = list.x + list.w;
  618.         scroll_wv.start_y = list.y;
  619.         scroll_wv.size_y=list.h;
  620.  
  621.         scrollbar_v_draw(#scroll_wv);
  622. }
  623.  
  624.  
  625. void TWebBrowser::TextGoDown(int left1, top1, width1)
  626. {
  627.         if (!stroka) DrawBar(list.x, list.y, list.w, 5, bg_color); //çàêðàøèâàåì ôîí íàä ïåðâîé ñòðîêîé
  628.         if (top1>=list.y) && ( top1 < list.h+list.y-10)  && (!anchor)
  629.         {
  630.                 if (text_align == ALIGN_CENTER) DrawBuf.AlignCenter(left1,top1,list.w,list.line_h,stolbec * 6);
  631.                 if (text_align == ALIGN_RIGHT) DrawBuf.AlignRight(left1,top1,list.w,list.line_h,stolbec * 6);
  632.                 PutPaletteImage(buf_data+8, list.w, list.line_h, left1-5, top1, 32,0);
  633.                 DrawBuf.Fill(bg_color);
  634.         }
  635.         stroka++;
  636.         if (blq_text) stolbec = 6; else stolbec = 0;
  637.         if (li_text) stolbec = li_tab * 5;
  638. }
  639.  
  640.  
  641.  
  642. int isTag(dword text)
  643. {
  644.         if (!strcmp(#tag,text)) return 1; else return 0;
  645. }
  646.