Subversion Repositories Kolibri OS

Rev

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