Subversion Repositories Kolibri OS

Rev

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

  1. #include "..\TWB\colors.h"
  2. #include "..\TWB\anchors.h"
  3. #include "..\TWB\parse_tag.h"
  4. #include "..\TWB\special.h"
  5. #include "..\TWB\img_cache.h"
  6. #include "..\TWB\tag_list.h"
  7. dword page_bg;
  8. dword link_color_default;
  9. dword link_color_active;
  10. #include "..\TWB\links.h"
  11.  
  12. #define BODY_MARGIN 6
  13. #define BASIC_LINE_H 18
  14.  
  15. DrawBufer DrawBuf;
  16. char line[500];
  17.  
  18. struct _style {
  19.         bool
  20.         b, u, s, h,
  21.         pre,
  22.         blq,
  23.         button,
  24.         image;
  25.         dword bg_color;
  26.         LIST tag_list;
  27.         dword tag_title;
  28. };
  29.  
  30. struct TWebBrowser {
  31.         llist list;
  32.         _style style;
  33.         dword draw_y, stolbec;
  34.         int zoom;
  35.         dword o_bufpointer;
  36.         int cur_encoding, custom_encoding;
  37.         bool link, t_html, t_body;
  38.         dword link_bg;
  39.         dword bufpointer;
  40.         dword bufsize;
  41.         dword is_html;
  42.  
  43.         void Paint();
  44.         void SetPageDefaults();
  45.         void AddCharToTheLine();
  46.         void ParseHtml();
  47.         void SetStyle();
  48.         bool CheckForLineBreak();
  49.         void NewLine();
  50.         void DrawScroller();
  51.         void ChangeEncoding();
  52.         void DrawPage();
  53.         char header[150];
  54. };
  55.  
  56. scroll_bar scroll_wv = { 15,NULL,NULL,NULL,0,2,NULL,0,0,0xeeeeee,0xBBBbbb,0xeeeeee};
  57.  
  58. //============================================================================================
  59. void TWebBrowser::Paint()
  60. {
  61.         dword start_x, line_length, stolbec_len;
  62.         dword text_color__;
  63.        
  64.         if (style.tag_title)
  65.         {
  66.                 strncpy(#header, #line, sizeof(TWebBrowser.header)-1);
  67.                 strncat(#header, " - ", sizeof(TWebBrowser.header)-1);
  68.                 strncat(#header, #version, sizeof(TWebBrowser.header)-1);
  69.                 line = 0;
  70.                 return;
  71.         }
  72.         if (t_html) && (!t_body) {
  73.                 line = 0;
  74.                 return;
  75.         }
  76.        
  77.         if (line)
  78.         {
  79.                 start_x = stolbec * list.font_w + BODY_MARGIN + list.x;
  80.                 stolbec_len = strlen(#line) * zoom;
  81.                 line_length = stolbec_len * list.font_w;
  82.  
  83.                 if (debug_mode) {
  84.                         DrawBuf.DrawBar(start_x, draw_y, line_length, list.item_h, 0xDDDddd);
  85.                 }
  86.  
  87.                 if (style.bg_color!=page_bg) {
  88.                         DrawBuf.DrawBar(start_x, draw_y, line_length, list.item_h, style.bg_color);
  89.                 }
  90.  
  91.                 if (style.image) {
  92.                         DrawBuf.DrawBar(start_x, draw_y, line_length, list.item_h-1, 0xF9DBCB);
  93.                 }
  94.                 if (style.button) {
  95.                         DrawBuf.DrawBar(start_x, draw_y, line_length, list.item_h - calc(zoom*2), 0xCCCccc);
  96.                         DrawBuf.DrawBar(start_x, draw_y + list.item_h - calc(zoom*2), line_length, zoom, 0x999999);
  97.                 }
  98.  
  99.                 text_color__ = text_colors[text_color_index];
  100.                 if (link) && (text_colors[text_color_index]==text_colors[0]) text_color__ = link_color_default;
  101.  
  102.                 DrawBuf.WriteText(start_x, draw_y, list.font_type, text_color__, #line, NULL);
  103.                 if (style.b) DrawBuf.WriteText(start_x+1, draw_y, list.font_type, text_color__, #line, NULL);
  104.                 if (style.s) DrawBuf.DrawBar(start_x, list.item_h / 2 - zoom + draw_y, line_length, zoom, text_color__);
  105.                 if (style.u) DrawBuf.DrawBar(start_x, list.item_h - zoom - zoom + draw_y, line_length, zoom, text_color__);
  106.                 if (link) {
  107.                         if (line[0]==' ') && (line[1]==NULL) {} else {
  108.                                 DrawBuf.DrawBar(start_x, draw_y + list.item_h - calc(zoom*2)-1, line_length, zoom, link_color_default);
  109.                                 PageLinks.AddText(start_x, draw_y + list.y, line_length, list.item_h - calc(zoom*2)-1, UNDERLINE, zoom);                               
  110.                         }
  111.                 }
  112.                 stolbec += stolbec_len;
  113.                 if (debug_mode) debug(#line);
  114.                 line = NULL;
  115.         }
  116. }
  117. //============================================================================================
  118. void TWebBrowser::SetPageDefaults()
  119. {
  120.         style.b = style.u = style.s = style.h = style.blq = t_html = t_body = style.pre =
  121.         link = text_color_index = text_colors[0] = style.tag_title = false;
  122.         style.tag_list.reset();
  123.         link_color_default = 0x0000FF;
  124.         link_color_active = 0xFF0000;
  125.         page_bg = 0xFFFFFF;
  126.         link_bg = 0xFFFFFF;
  127.         style.bg_color = page_bg;
  128.         DrawBuf.Fill(0, page_bg);
  129.         PageLinks.Clear();
  130.         anchors.clear();
  131.         header = NULL;
  132.         cur_encoding = CH_CP866;
  133.         draw_y = BODY_MARGIN;
  134.         stolbec = 0;
  135.         line = 0;
  136.         zoom = 1;
  137.         //hold original buffer
  138.         if (o_bufpointer) o_bufpointer=free(o_bufpointer);
  139.         o_bufpointer = malloc(bufsize);
  140.         memmov(o_bufpointer, bufpointer, bufsize);
  141.         if (custom_encoding != -1) {
  142.                 cur_encoding = custom_encoding;
  143.                 bufpointer = ChangeCharset(cur_encoding, "CP866", bufpointer);
  144.         }
  145. }
  146. //============================================================================================
  147. void TWebBrowser::AddCharToTheLine(unsigned char _char)
  148. {
  149.         dword line_len;
  150.         if (_char<=15) _char=' ';
  151.         line_len = strlen(#line);
  152.         if (!style.pre) && (_char == ' ')
  153.         {
  154.                 if (line[line_len-1]==' ') return; //no double spaces
  155.                 if (!stolbec) && (!line) return; //no paces at the beginning of the line
  156.         }
  157.         if (line_len < sizeof(line)) chrcat(#line, _char);
  158.         CheckForLineBreak();
  159. }
  160. //============================================================================================
  161. void TWebBrowser::ParseHtml(dword _bufpointer, _bufsize){
  162.         word bukva[2];
  163.         char unicode_symbol[10];
  164.         dword unicode_symbol_result;
  165.         dword j;
  166.         bool ignor_param=false;
  167.         int tab_len;
  168.         dword bufpos;
  169.         bufsize = _bufsize;
  170.         if (bufpointer != _bufpointer) {
  171.                 bufpointer = malloc(bufsize);
  172.                 memmov(bufpointer, _bufpointer, bufsize);
  173.         } else {
  174.                 custom_encoding = CH_CP866;    
  175.         }
  176.         SetPageDefaults();
  177.         is_html = true;
  178.         if (!strstri(bufpointer, "<body")) {
  179.                 t_body = true;
  180.                 if (!strstri(bufpointer, "<html")) {
  181.                         style.pre = true; //show linebreaks for a plaint text
  182.                         is_html = false;
  183.                 }
  184.         }
  185.         for (bufpos=bufpointer ; (bufpos < bufpointer+bufsize) && (ESBYTE[bufpos]!=0) ; bufpos++;)
  186.         {
  187.                 bukva = ESBYTE[bufpos];
  188.                 switch (bukva)
  189.                 {
  190.                 case 0x0a:
  191.                         if (style.pre) {
  192.                                 Paint();
  193.                                 NewLine();
  194.                         } else {
  195.                                 AddCharToTheLine(0x0a);
  196.                         }
  197.                         break;
  198.                 case 0x09:
  199.                         if (style.pre) {
  200.                                 tab_len = strlen(#line) + stolbec % 4;
  201.                                 if (!tab_len) tab_len = 4; else tab_len = 4 - tab_len;
  202.                                 for (j=0; j<tab_len; j++;) chrcat(#line,' ');
  203.                         } else {
  204.                                 AddCharToTheLine(0x09);
  205.                         }
  206.                         break;
  207.                 case '&': //&nbsp; and so on
  208.                         for (j=1, unicode_symbol=0; (ESBYTE[bufpos+j]<>';') && (j<8); j++)
  209.                         {
  210.                                 bukva = ESBYTE[bufpos+j];
  211.                                 chrcat(#unicode_symbol, bukva);
  212.                         }
  213.                         if (GetUnicodeSymbol(#line, #unicode_symbol, sizeof(line)-1)) {
  214.                                 bufpos += j;
  215.                                 CheckForLineBreak();
  216.                         } else {
  217.                                 AddCharToTheLine('&');
  218.                         }
  219.                         break;
  220.                 case '<':
  221.                         if (!is_html) goto _default;
  222.                         bufpos++;
  223.                         if (!strncmp(bufpos,"!--",3))
  224.                         {
  225.                                 bufpos+=3;
  226.                                 while (strncmp(bufpos,"-->",3)!=0) && (bufpos < bufpointer + bufsize)
  227.                                 {
  228.                                         bufpos++;
  229.                                 }
  230.                                 bufpos+=2;
  231.                                 break;
  232.                         }
  233.                         tag.reset();
  234.                         if (ESBYTE[bufpos] == '/') {
  235.                                 tag.opened = false;
  236.                                 bufpos++;
  237.                         }
  238.  
  239.                         ignor_param=false;
  240.                         while (ESBYTE[bufpos] !='>') && (bufpos < bufpointer + bufsize) //ïîëó÷àåì òåã è åãî ïàðàìåòðû
  241.                         {
  242.                                 bukva = ESBYTE[bufpos];
  243.                                 if (bukva == '\x9') || (bukva == '\x0a') || (bukva == '\x0d') bukva = ' ';
  244.                                 if (!ignor_param) && (bukva <>' ')
  245.                                 {
  246.                                         if (strlen(#tag.name)+1<sizeof(tag.name)) chrcat(#tag.name, bukva);
  247.                                 }
  248.                                 else
  249.                                 {
  250.                                         ignor_param = true;
  251.                                         if (strlen(#tag.params)+1<sizeof(tag.params)) strcat(#tag.params, #bukva);
  252.                                         //chrncat(#tag.params, bukva, sizeof(tag.params)-1);
  253.                                 }
  254.                                 bufpos++;
  255.                         }
  256.                         strlwr(#tag.name);
  257.  
  258.                         // ignore text inside the next tags
  259.                         if (tag.is("script")) || (tag.is("style")) || (tag.is("binary")) || (tag.is("select"))  {
  260.                                 sprintf(#tag.params, "</%s>", #tag.name);
  261.                                 if (j = strstri(bufpos, #tag.params)) bufpos = j-1;
  262.                                 break;
  263.                         }
  264.  
  265.                         if (tag.name[strlen(#tag.name)-1]=='/') tag.name[strlen(#tag.name)-1]=NULL; //for br/ !!!!!!!!
  266.                         if (tag.params) tag.parse_params();
  267.  
  268.                         if (tag.name) {
  269.                                 CheckForLineBreak();
  270.                                 Paint();
  271.                                 if (tag.name) SetStyle();
  272.                         }
  273.                         break;
  274.                 default:
  275.                         _default:
  276.                         AddCharToTheLine(ESBYTE[bufpos]);
  277.                 }
  278.         }
  279.         Paint();
  280.         NewLine();
  281.         list.count = draw_y;
  282.         list.CheckDoesValuesOkey();
  283.         anchors.current = NULL;
  284.         custom_encoding = -1;
  285.         if (!header) {
  286.                 strncpy(#header, #version, sizeof(TWebBrowser.header)-1);
  287.                 DrawTitle(#header);
  288.         }
  289. }
  290. //============================================================================================
  291. bool TWebBrowser::CheckForLineBreak()
  292. {
  293.         int line_break_pos;
  294.         char new_line_text[4096];
  295.         //Do we need a line break?
  296.         if (strlen(#line)*zoom + stolbec < list.column_max) return false;
  297.         //Yes, we do. Lets calculate where...
  298.         line_break_pos = strrchr(#line, ' ');
  299.         //Is a new line fits in the current line?
  300.         if (line_break_pos*zoom + stolbec > list.column_max) {
  301.                 line_break_pos = list.column_max/zoom - stolbec;
  302.                 while(line_break_pos) && (line[line_break_pos]!=' ') line_break_pos--;
  303.         }
  304.         //Maybe a new line is too big for the whole new line? Then we have to split it
  305.         if (!line_break_pos) && (style.tag_list.level*5 + strlen(#line) * zoom >= list.column_max) {
  306.                 line_break_pos = list.column_max/zoom - stolbec;
  307.         }
  308.         strcpy(#new_line_text, #line + line_break_pos);
  309.         line[line_break_pos] = 0x00;           
  310.        
  311.         Paint();
  312.  
  313.         strcpy(#line, #new_line_text);
  314.         NewLine();
  315.         //while (CheckForLineBreak()==true) {};
  316.         return true;
  317. }
  318. //============================================================================================
  319. void TWebBrowser::SetStyle() {
  320.         char img_path[4096]=0;
  321.  
  322.         dword value;
  323.  
  324.         if (value = tag.get_value_of("name=")) || (value = tag.get_value_of("id=")) {
  325.                 anchors.add(value, draw_y);
  326.                 if (anchors.current) && (streq(value, #anchors.current+1)) {
  327.                         list.first = draw_y;
  328.                         anchors.current = NULL;
  329.                 }
  330.         }
  331.         if (tag.is("html")) {
  332.                 t_html = tag.opened;
  333.                 return;
  334.         }
  335.         if (tag.is("title")) {
  336.                 style.tag_title = tag.opened;
  337.                 if (!tag.opened) DrawTitle(#header);
  338.                 return;
  339.         }
  340.         if (tag.is("body")) {
  341.                 t_body = tag.opened;
  342.                 if (value = tag.get_value_of("link="))   link_color_default = GetColor(value);
  343.                 if (value = tag.get_value_of("alink="))  link_color_active = GetColor(value);
  344.                 if (value = tag.get_value_of("bglink=")) link_bg=GetColor(value);
  345.                 if (value = tag.get_value_of("text="))   text_colors[0]=GetColor(value);
  346.                 if (value = tag.get_value_of("bgcolor=")) {
  347.                         style.bg_color = page_bg = link_bg = GetColor(value);
  348.                         DrawBuf.Fill(0, page_bg);
  349.                 }
  350.                 // Autodetecting encoding if no encoding was set
  351.                 if (tag.opened) && (custom_encoding==-1) && (cur_encoding == CH_CP866) {
  352.                         if (strstr(bufpointer, "\208\190")) ChangeEncoding(CH_UTF8);
  353.                         else if (chrnum(bufpointer, '\246')>5) ChangeEncoding(CH_CP1251);
  354.                 }
  355.                 return;
  356.         }
  357.         if (tag.is("br")) { NewLine(); return; }
  358.         if (tag.is("b")) || (tag.is("strong")) || (tag.is("big")) || (tag.is("w:b")) {
  359.                 style.b = tag.opened;
  360.                 return;
  361.         }
  362.         if (tag.is("w:r")) && (!tag.opened) { style.b = false; return; }
  363.         if (tag.is("a")) {
  364.                 if (tag.opened)
  365.                 {
  366.                         if (value = tag.get_value_of("href=")) && (!strstr(value,"javascript:"))
  367.                         {
  368.                                 link = true;
  369.                                 PageLinks.AddLink(value);
  370.                                 style.bg_color = link_bg;
  371.                         }
  372.                 } else {
  373.                         link = false;
  374.                         style.bg_color = page_bg;
  375.                 }
  376.                 return;
  377.         }
  378.         if (tag.is("iframe")) && (value = tag.get_value_of("src=")) {
  379.                 NewLine();
  380.                 strcpy(#line, "IFRAME: ");
  381.                 Paint();
  382.                 link=true;
  383.                 PageLinks.AddLink(value);
  384.                 strncpy(#line, value, sizeof(line)-1);
  385.                 while (CheckForLineBreak()) {};
  386.                 Paint();
  387.                 link=false;
  388.                 NewLine();
  389.         }
  390.         if (tag.is("font")) {
  391.                 style.bg_color = page_bg;
  392.                 if (tag.opened)
  393.                 {
  394.                         text_color_index++;
  395.                         text_colors[text_color_index] = text_colors[text_color_index-1];
  396.                         if (value = tag.get_value_of("color=")) text_colors[text_color_index] = GetColor(value);
  397.                         if (value = tag.get_value_of("bg=")) style.bg_color = GetColor(value);
  398.                 }
  399.                 else if (text_color_index > 0) text_color_index--;
  400.                 return;
  401.         }
  402.         if (tag.is("div")) {
  403.                 if (streq(#tag.prior,"div")) && (tag.opened) return;
  404.                 NewLine();
  405.                 return;
  406.         }
  407.         if (tag.is("header")) || (tag.is("article")) || (tag.is("footer")) || (tag.is("figure")) {
  408.                 NewLine();
  409.                 return;
  410.         }
  411.         if (tag.is("p")) || (tag.is("w:p"))  {
  412.                 IF (tag.prior[0] == 'h') || (streq(#tag.prior,"td")) || (streq(#tag.prior,"p")) return;
  413.                 NewLine();
  414.                 return;
  415.         }
  416.         if (tag.is("pre")) { style.pre = tag.opened; return; }
  417.         if (tag.is("td")) { if (tag.opened) AddCharToTheLine(' '); return; }
  418.         if (tag.is("tr")) { if (tag.opened) NewLine(); return; }
  419.         if (tag.is("button")) { style.button = tag.opened; stolbec++; return; }
  420.         if (tag.is("u")) || (tag.is("ins")) { style.u=tag.opened; return;}
  421.         if (tag.is("s")) || (tag.is("strike")) || (tag.is("del")) { style.s=tag.opened; return; }
  422.         if (tag.is("dl")) {
  423.                 if (tag.opened) NewLine();
  424.                 return;
  425.         }
  426.         if (tag.is("dd")) {
  427.                 //NewLine();
  428.                 //if (tag.opened) stolbec += 5;  //stolbec overflow!
  429.                 return;
  430.         }
  431.         if (tag.is("blockquote")) { style.blq = tag.opened; return; }
  432.         if (tag.is("code")) {
  433.                 if (tag.opened) style.bg_color = 0xe4ffcb; else style.bg_color = page_bg;
  434.                 style.pre = tag.opened; return;
  435.         }
  436.         if (tag.is("img")) {
  437.                 if (value = tag.get_value_of("src=")) strlcpy(#img_path, value, sizeof(img_path)-1);
  438.                 if (value = tag.get_value_of("title=")) && (strlen(value)<sizeof(line)-3) && (value) sprintf(#line, "[%s]", value);
  439.                 if (value = tag.get_value_of("alt=")) && (strlen(value)<sizeof(line)-3) && (value) sprintf(#line, "[%s]", value);
  440.                 if (!img_path) { line=0; return; }
  441.                 style.image = true;
  442.                 text_color_index++;
  443.                 text_colors[text_color_index] = 0x9A6F29;
  444.                 if (!line) {
  445.                         if (!strncmp(#img_path, "data:", 5)) img_path=0;
  446.                         replace_char(#img_path, '?', NULL, strlen(#img_path));
  447.                         sprintf(#line, "[%s]", #img_path+strrchr(#img_path, '/'));
  448.                         line[50]= NULL;
  449.                 }
  450.                 while (CheckForLineBreak()) {};
  451.                 Paint();
  452.                 text_color_index--;
  453.                 style.image = false;
  454.                 //ImgCache.Images( list.x, draw_y, list.w);
  455.                 return;
  456.         }
  457.         if (tag.is("h4")) {
  458.                 NewLine();
  459.                 NewLine();
  460.                 style.h = tag.opened;
  461.                 style.b = tag.opened;
  462.         }
  463.         if (tag.is("h1")) || (tag.is("h2")) || (tag.is("h3")) || (tag.is("caption")) {
  464.                 style.h = tag.opened;
  465.                 if (tag.opened) {
  466.                         if (!style.pre) NewLine();
  467.                         draw_y += 10;
  468.                         zoom=2;
  469.                         list.font_type |= 10011001b;
  470.                         list.item_h = BASIC_LINE_H * 2 - 2;
  471.                         if (tag.is("h1")) style.b = true;
  472.                 } else {
  473.                         if (tag.is("h1")) style.b = false;
  474.                         NewLine();
  475.                         zoom=1;
  476.                         list.font_type = 10011000b;
  477.                         list.item_h = BASIC_LINE_H;
  478.                 }
  479.                 return;
  480.         }
  481.         if (tag.is("dt")) {
  482.                 style.tag_list.upd_level(tag.opened, DT);
  483.                 if (tag.opened) NewLine();
  484.                 return;
  485.         }
  486.         if (tag.is("ul")) {
  487.                 style.tag_list.upd_level(tag.opened, UL);
  488.                 if (!tag.opened) && (!style.pre) NewLine();
  489.                 return;
  490.         }
  491.         if (tag.is("ol")) {
  492.                 style.tag_list.upd_level(tag.opened, OL);      
  493.                 if (!tag.opened) && (!style.pre) NewLine();
  494.                 return;
  495.         }
  496.         if (tag.is("li")) && (tag.opened)
  497.         {
  498.                 if (!style.tag_list.level) style.tag_list.upd_level(1, UL);
  499.                 if (!style.pre) NewLine();
  500.                 if (style.tag_list.get_order_type() == UL) {
  501.                         strcpy(#line, "\31 ");
  502.                         stolbec = style.tag_list.level * 5 - 2;
  503.                 }
  504.                 if (style.tag_list.get_order_type() == OL) {
  505.                         sprintf(#line, "%i. ", style.tag_list.inc_counter());
  506.                         stolbec = style.tag_list.level * 5 - strlen(#line);
  507.                 }
  508.                 return;
  509.         }
  510.         if (tag.is("q"))
  511.         {
  512.                 if (tag.opened) {
  513.                         EAX = strlen(#line);
  514.                         if (line[EAX-1] != ' ') chrcat(#line, ' ');
  515.                         chrcat(#line, '\"');
  516.                 }
  517.                 if (!tag.opened) strcat(#line, "\" ");
  518.                 return;
  519.         }
  520.         if (tag.is("hr")) {
  521.                 if (value = tag.get_value_of("color=")) EDI = GetColor(value); else EDI = 0x999999;
  522.                 $push edi;
  523.                 NewLine();
  524.                 $pop edi;
  525.                 draw_y += 10;
  526.                 DrawBuf.DrawBar(5, draw_y - 1, list.w-10, 1, EDI);
  527.                 NewLine();
  528.                 draw_y += 10;
  529.                 return;
  530.         }
  531.         if (custom_encoding == -1) && (tag.is("meta")) || (tag.is("?xml")) {
  532.                 if (value = tag.get_value_of("charset=")) || (value = tag.get_value_of("content=")) || (value = tag.get_value_of("encoding="))
  533.                 {
  534.                         value += strrchr(value, '='); //search in content=
  535.                         strlwr(value);
  536.                         if      (streq(value,"utf-8"))        || (streq(value,"utf8"))        ChangeEncoding(CH_UTF8);
  537.                         else if (streq(value,"windows-1251")) || (streq(value,"windows1251")) ChangeEncoding(CH_CP1251);
  538.                         else if (streq(value,"dos"))          || (streq(value,"cp-866"))      ChangeEncoding(CH_CP866);
  539.                         else if (streq(value,"iso-8859-5"))   || (streq(value,"iso8859-5"))   ChangeEncoding(CH_ISO8859_5);
  540.                         else if (streq(value,"koi8-r"))       || (streq(value,"koi8-u"))      ChangeEncoding(CH_KOI8);
  541.                 }
  542.                 return;
  543.         }
  544. }
  545. //============================================================================================
  546. void TWebBrowser::DrawScroller()
  547. {
  548.         scroll_wv.max_area = list.count;
  549.         scroll_wv.cur_area = list.visible;
  550.         scroll_wv.position = list.first;
  551.         scroll_wv.all_redraw = 0;
  552.         scroll_wv.start_x = list.x + list.w;
  553.         scroll_wv.start_y = list.y;
  554.         scroll_wv.size_y = list.h;
  555.         scrollbar_v_draw(#scroll_wv);
  556. }
  557. //============================================================================================
  558. void TWebBrowser::ChangeEncoding(int _new_encoding)
  559. {
  560.         if (cur_encoding == _new_encoding) return;
  561.         cur_encoding = _new_encoding;
  562.         bufpointer = ChangeCharset(cur_encoding, "CP866", bufpointer);
  563.         if (header) {
  564.                 ChangeCharset(cur_encoding, "CP866", #header);
  565.                 DrawTitle(#header);
  566.         }
  567. }
  568. //============================================================================================
  569. void TWebBrowser::NewLine()
  570. {
  571.         dword onleft, ontop;
  572.         static int empty_line=0;
  573.  
  574.         if (!stolbec) && (draw_y==BODY_MARGIN) return;
  575.        
  576.         if (style.tag_list.level) && (stolbec == style.tag_list.level * 5) {
  577.                 if (empty_line<1) empty_line++;
  578.                 else return;
  579.         } else if (!stolbec) {
  580.                 if (empty_line<1) empty_line++;
  581.                 else return;
  582.         } else {
  583.                 empty_line=0;
  584.         }
  585.  
  586.         onleft = list.x + BODY_MARGIN;
  587.         ontop = draw_y + list.y;
  588.         if (t_html) && (!t_body) return;
  589.         draw_y += list.item_h;
  590.         if (style.blq) stolbec = 6; else stolbec = 0;
  591.         stolbec += style.tag_list.level * 5;
  592.         if (debug_mode) debugln(NULL);
  593. }
  594. //============================================================================================
  595. void TWebBrowser::DrawPage()
  596. {
  597.         PutPaletteImage(list.first * DrawBuf.bufw * 4 + buf_data+8, DrawBuf.bufw, list.h, DrawBuf.bufx, DrawBuf.bufy, 32, 0);  
  598.         DrawScroller();
  599. }