Subversion Repositories Kolibri OS

Rev

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