Subversion Repositories Kolibri OS

Rev

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

  1. #include "..\TWB\links.h"
  2.  
  3. dword bufpointer;
  4. dword o_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. struct TWebBrowser {
  14.         llist list;
  15.         DrawBufer DrawBuf;
  16.         void GetNewUrl();
  17.         void Prepare();
  18.         void Parse();
  19.         void WhatTextStyle();
  20.         void DrawPage();
  21.         void DrawScroller();
  22.         void TextGoDown();
  23. };
  24.  
  25. TWebBrowser WB1;
  26.  
  27. byte b_text, i_text, u_text, s_text, pre_text, blq_text, li_text, li_tab,
  28.         link, ignor_text, cur_encoding, text_align, t_html, t_body;
  29. byte condition_text_active, condition_text_val, condition_href, condition_max;
  30.  
  31. enum { _WIN, _DOS, _KOI, _UTF, _DEFAULT };
  32.  
  33. enum { ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT};
  34.  
  35. dword text_colors[300];
  36. dword text_color_index;
  37. dword link_color_inactive;
  38. dword link_color_active;
  39. dword bg_color;
  40.  
  41. int stroka;
  42. int stolbec;
  43. int tab_len;
  44. int anchor_line_num;
  45.  
  46. char line[500];
  47. char tag[100];
  48. char tagparam[10000];
  49. char parametr[1200];
  50. char options[4096];
  51. char anchor[256];
  52.  
  53. #include "..\TWB\history.h"
  54. #include "..\TWB\colors.h"
  55. #include "..\TWB\unicode_tags.h"
  56. #include "..\TWB\img_cache.h"
  57. #include "..\TWB\parce_tag.h"
  58. #include "..\TWB\table.h"
  59.  
  60.  
  61.  
  62. //=======================================================================
  63.  
  64.  
  65. void TWebBrowser::DrawPage()
  66. {
  67.         int start_x, start_y, line_length, magrin_left=5;
  68.        
  69.         if (!header)
  70.         {
  71.                 strcpy(#header, #line);
  72.                 strcat(#header, " -");
  73.                 strcat(#header, #version);
  74.                 line = 0;
  75.                 return;
  76.         }
  77.         if (t_html) && (!t_body) return;
  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. void BufEncode(int set_new_encoding)
  144. {
  145.         cur_encoding = set_new_encoding;
  146.         if (o_bufpointer==0)
  147.         {
  148.                 debugi(bufsize);
  149.                 bufsize = strlen(bufpointer);
  150.                 debugi(bufsize);
  151.                 o_bufpointer = malloc(bufsize);
  152.                 strcpy(o_bufpointer, bufpointer);
  153.         }
  154.         else
  155.         {
  156.                 strcpy(bufpointer, o_bufpointer);
  157.         }
  158.         if (set_new_encoding==_WIN) wintodos(bufpointer);
  159.         if (set_new_encoding==_UTF) utf8rutodos(bufpointer);
  160.         if (set_new_encoding==_KOI) koitodos(bufpointer);
  161. }
  162.  
  163. void TWebBrowser::Prepare(dword bufpos, in_filesize){
  164.         bufsize = in_filesize;
  165.         bufpointer = bufpos;
  166.         Parse();
  167. }
  168.  
  169.  
  170. void TWebBrowser::Parse(){
  171.         word bukva[2];
  172.         int j, perenos_num;
  173.         byte ignor_param;
  174.         char temp[768];
  175.         dword bufpos = bufpointer;
  176.        
  177.         b_text = i_text = u_text = s_text = blq_text = t_html = t_body =
  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.  
  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.                         line=NULL;
  303.                         if (tag) WhatTextStyle(list.x + 5, stroka * 10 + list.y + 5, list.w - 20); //îáðàáîòêà òåãîâ
  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.                 Parse();
  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.         byte meta_encoding;
  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.                 t_html = opened;
  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.                 t_body = opened;
  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("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.  
  486.         if(isTag("table")) {
  487.                 if (opened)
  488.                 {
  489.                         table.active = true;
  490.                         TextGoDown(left1, top1, width1);
  491.                         table.NewTable();
  492.                 }
  493.                 else
  494.                 {
  495.                         table.active = false;
  496.                         TextGoDown(left1, top1, width1);
  497.                 }
  498.         }
  499.         if(isTag("td")) {
  500.                 if (opened)
  501.                 {
  502.                         //
  503.                 }
  504.                 else
  505.                 {
  506.                         //
  507.                 }
  508.         }
  509.         if(isTag("tr")) {
  510.                 if (opened)
  511.                 {
  512.                         //
  513.                 }
  514.                 else
  515.                 {
  516.                         TextGoDown(left1, top1, width1);
  517.                         if (table.cur_row == 0) table.max_cols = table.cur_col;
  518.                         table.cur_row++;
  519.                 }
  520.         }
  521.         /*
  522.         if (isTag("center"))
  523.         {
  524.                 if (opened) text_align = ALIGN_CENTER;
  525.                 if (!opened)
  526.                 {
  527.                         TextGoDown(left1, top1, width1);
  528.                         text_align = ALIGN_LEFT;
  529.                 }
  530.                 return;
  531.         }
  532.         if (isTag("right"))
  533.         {
  534.                 if (opened) text_align = ALIGN_RIGHT;
  535.                 if (!opened)
  536.                 {
  537.                         TextGoDown(left1, top1, width1);
  538.                         text_align = ALIGN_LEFT;
  539.                 }
  540.                 return;
  541.         }
  542.         */
  543.         if (isTag("h1")) || (isTag("h2")) || (isTag("h3")) || (isTag("h4")) {
  544.                 TextGoDown(left1, top1, width1);
  545.                 if (opened) && (stroka>1) TextGoDown(left1, top1 + 10, width1);
  546.                 strcpy(#oldtag, #tag);
  547.                 if (opened)
  548.                 {
  549.                         if (!strcmp(#parametr, "align=")) && (!strcmp(#options,"center")) text_align = ALIGN_CENTER;
  550.                         if (!strcmp(#parametr, "align=")) && (!strcmp(#options,"right")) text_align = ALIGN_RIGHT;
  551.                         b_text = 1;
  552.                 }
  553.                 if (!opened)
  554.                 {
  555.                         text_align = ALIGN_LEFT;
  556.                         b_text = 0;
  557.                 }
  558.                 return;
  559.         }
  560.         else
  561.                 oldtag=NULL;
  562.                
  563.         if (isTag("b")) || (isTag("strong")) || (isTag("big")) {
  564.                 b_text = opened;
  565.                 return;
  566.         }
  567.         if(isTag("i")) || (isTag("em")) || (isTag("subtitle")) {
  568.                 i_text = opened;
  569.                 return;
  570.         }      
  571.         if (isTag("dt"))
  572.         {
  573.                 li_text = opened;
  574.                 IF(opened == 0) return;
  575.                 TextGoDown(left1, top1, width1);
  576.                 return;
  577.         }
  578.         if (isTag("condition"))
  579.         {
  580.                 condition_text_active = opened;
  581.                 if (opened) && (!strcmp(#parametr, "show_if=")) condition_text_val = atoi(#options);
  582.                 return;
  583.         }
  584.         if (isTag("li")) || (isTag("dt")) //íàäî ñäåëàòü âëîæåííûå ñïèñêè
  585.         {
  586.                 li_text = opened;
  587.                 if (opened)
  588.                 {
  589.                         TextGoDown(left1, top1, width1);
  590.                         if (stroka > -1) && (stroka - 2 < list.visible) DrawBuf.DrawBar(li_tab * 5 * 6 + left1 - 5, list.line_h/2-3, 2, 2, 0x555555);
  591.                 }
  592.                 return;
  593.         }
  594.         if (isTag("u")) || (isTag("ins")) u_text = opened;
  595.         if (isTag("s")) || (isTag("strike")) || (isTag("del")) s_text = opened;
  596.         if (isTag("ul")) || (isTag("ol")) IF(!opened)
  597.         {
  598.                 li_text = opened;
  599.                 li_tab--;
  600.                 TextGoDown(left1, top1, width1);
  601.         } ELSE li_tab++;
  602.         if (isTag("dd")) stolbec += 5;
  603.         if (isTag("blockquote")) blq_text = opened;
  604.         if (isTag("pre")) || (isTag("code")) pre_text = opened;
  605.         if (isTag("hr"))
  606.         {
  607.                 if (anchor) || (stroka < -1)
  608.                 {
  609.                         stroka+=2;
  610.                         return;
  611.                 }
  612.                 if (strcmp(#parametr, "color=") == 0) hr_color = GetColor(#options); else hr_color = 0x999999;
  613.                 TextGoDown(left1, top1, width1);
  614.                 DrawBuf.DrawBar(5, list.line_h/2, list.w-10, 1, hr_color);
  615.                 TextGoDown(left1, top1+list.line_h, width1);
  616.         }
  617.         if (isTag("img"))
  618.         {
  619.                 ImgCache.Images( left1, top1, width1);
  620.                 return;
  621.         }
  622.         if (isTag("meta")) || (isTag("?xml"))
  623.         {
  624.                 do{
  625.                         if (!strcmp(#parametr, "charset=")) || (!strcmp(#parametr, "content=")) || (!strcmp(#parametr, "encoding="))
  626.                         {
  627.                                 strcpy(#options, #options[strrchr(#options, '=')]); //ïîèñê â content=
  628.                                 strlwr(#options);
  629.                                 if (!strcmp(#options, "utf-8"))  || (!strcmp(#options,"utf8")) meta_encoding = _UTF;
  630.                                 if (!strcmp(#options, "koi8-r")) || (!strcmp(#options, "koi8-u")) meta_encoding = _KOI;
  631.                                 if (!strcmp(#options, "windows-1251")) || (!strcmp(#options, "windows1251")) meta_encoding = _WIN;
  632.                                 //if (!strcmp(#options, "dos"))    || (!strcmp(#options, "cp-866"))   meta_encoding = _DOS;
  633.                                 if ((cur_encoding==_DEFAULT) && (http_transfer==0)) BufEncode(meta_encoding);
  634.                                 return;
  635.                         }
  636.                 } while(GetNextParam());
  637.                 return;
  638.         }
  639. }
  640.  
  641. void TWebBrowser::DrawScroller() //íå îïòèìàëüíàÿ îòðèñîâêà, íî çàòî â îäíîì ìåñòå
  642. {
  643.         scroll_wv.max_area = list.count;
  644.         scroll_wv.cur_area = list.visible;
  645.         scroll_wv.position = list.first;
  646.  
  647.         scroll_wv.all_redraw=1;
  648.         scroll_wv.start_x = list.x + list.w;
  649.         scroll_wv.start_y = list.y;
  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 (t_html) && (!t_body) return;
  660.         if (top1>=list.y) && ( top1 < list.h+list.y-10)  && (!anchor)
  661.         {
  662.                 if (text_align == ALIGN_CENTER) DrawBuf.AlignCenter(left1,top1,list.w,list.line_h,stolbec * 6);
  663.                 if (text_align == ALIGN_RIGHT) DrawBuf.AlignRight(left1,top1,list.w,list.line_h,stolbec * 6);
  664.                 PutPaletteImage(buf_data+8, list.w, list.line_h, left1-5, top1, 32,0);
  665.                 DrawBuf.Fill(bg_color);
  666.         }
  667.         stroka++;
  668.         if (blq_text) stolbec = 6; else stolbec = 0;
  669.         if (li_text) stolbec = li_tab * 5;
  670. }
  671.  
  672.  
  673.  
  674. int isTag(dword text)
  675. {
  676.         if (!strcmp(#tag,text)) return 1; else return 0;
  677. }
  678.  
  679.  
  680.