Subversion Repositories Kolibri OS

Rev

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

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