Subversion Repositories Kolibri OS

Rev

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