Subversion Repositories Kolibri OS

Rev

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