Subversion Repositories Kolibri OS

Rev

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