Subversion Repositories Kolibri OS

Rev

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