Subversion Repositories Kolibri OS

Rev

Rev 8500 | Rev 9294 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. CANVAS canvas;
  2.  
  3. void TWebBrowser::RenderLine(dword _line)
  4. {
  5.         unsigned px; //paint x coordinate
  6.         unsigned pw; //paint y coordinate
  7.            dword pc; //paint color
  8.            int zoom;
  9.  
  10.         if (style.title)
  11.         {
  12.                 strncpy(#header, _line, sizeof(TWebBrowser.header)-1);
  13.                 strncat(#header, " - ", sizeof(TWebBrowser.header)-1);
  14.                 strncat(#header, #version, sizeof(TWebBrowser.header)-1);
  15.         }
  16.         else if (t_html) && (!t_body) {
  17.                 //
  18.         }
  19.         else if (ESBYTE[_line])
  20.         {
  21.                 pw = strlen(_line) * list.font_w;
  22.                 zoom = list.font_w / BASIC_CHAR_W;
  23.  
  24.                 //there is some shit happens!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  25.                 if (pw > draw_w) {
  26.                         //draw_w = pw;
  27.                         NewLine();
  28.                 }
  29.  
  30.                 if (debug_mode) {
  31.                         canvas.DrawBar(draw_x, draw_y, pw, list.item_h, 0xCCCccc);
  32.                         debugln(_line);
  33.                 }
  34.  
  35.                 style.cur_line_h = math.max(style.cur_line_h, list.item_h);
  36.  
  37.                 if (!secondrun) goto _SKIP_DRAW;
  38.                 if (bg_colors.get_last() - bg_colors.get(0)) {
  39.                         canvas.DrawBar(draw_x, draw_y, pw, list.item_h, bg_colors.get_last());
  40.                 }
  41.  
  42.                 if (style.image) {
  43.                         canvas.DrawBar(draw_x, draw_y, pw, list.item_h-1, 0xF9DBCB);
  44.                 }
  45.                 if (style.button) {
  46.                         canvas.DrawBar(draw_x, draw_y, pw, list.item_h - calc(zoom*2), 0xCCCccc);
  47.                         canvas.DrawBar(draw_x, draw_y + list.item_h - calc(zoom*2), pw, zoom, 0x999999);
  48.                 }
  49.  
  50.                 pc = text_colors.get_last();
  51.                 if (link) && (pc == text_colors.get(0)) pc = link_color_default;
  52.  
  53.                 canvas.WriteText(draw_x, draw_y, list.font_type, pc, _line, NULL);
  54.                 if (style.b) canvas.WriteText(draw_x+1, draw_y, list.font_type, pc, _line, NULL);
  55.                 if (style.s) canvas.DrawBar(draw_x, list.item_h / 2 - zoom + draw_y, pw, zoom, pc);
  56.                 if (style.u) canvas.DrawBar(draw_x, list.item_h - zoom - zoom + draw_y, pw, zoom, pc);
  57.                 if (link) {
  58.                         if (ESBYTE[_line]==' ') && (ESBYTE[_line+1]==NULL) {} else {
  59.                                 canvas.DrawBar(draw_x, draw_y + list.item_h - calc(zoom*2)-1, pw, zoom, link_color_default);
  60.                                 links.add_text(draw_x, draw_y + list.y, pw, list.item_h - calc(zoom*2)-1, zoom);                               
  61.                         }
  62.                 }
  63.                 _SKIP_DRAW:
  64.                 draw_x += pw;
  65.         }
  66.         ESBYTE[_line] = NULL;
  67. }
  68.  
  69. void TWebBrowser::RenderTextbuf()
  70. {
  71.         dword lbp = #linebuf;
  72.         int br; //break position
  73.         char nul = '\0';
  74.         int len;
  75.  
  76.         //Do we need a line break?
  77.              
  78.         while (len = strlen(lbp)) && (len * list.font_w + draw_x - left_gap >= draw_w) {
  79.                 //Yes, we do. Lets calculate where...
  80.                 br = len;
  81.  
  82.                 //debugln("                \\n");
  83.  
  84.                 //Is a new line fits in the current line?
  85.                 if (br * list.font_w + draw_x - left_gap >= draw_w) {
  86.                         br = draw_w - draw_x + left_gap /list.font_w;
  87.                         while(br) {
  88.                                 if (ESBYTE[lbp + br]==' ') {
  89.                                         br++;
  90.                                         break;
  91.                                 }
  92.                                 br--;
  93.                         }
  94.                 }
  95.                 //Maybe a new line is too big for the whole new line? Then we have to split it
  96.                 if (!br) && (len * list.font_w >= draw_w) {
  97.                         br = draw_w - draw_x / list.font_w;
  98.                 }
  99.  
  100.                 if (br) {
  101.                         ESBYTE[lbp + br] >< nul;
  102.                         RenderLine(lbp);
  103.                         ESBYTE[lbp + br] >< nul;
  104.                         lbp += br;
  105.                         while (ESBYTE[lbp]==' ') && (ESBYTE[lbp]) lbp++;
  106.                         if (ESBYTE[lbp]) NewLine();
  107.                 } else {
  108.                         NewLine();
  109.                         RenderLine(lbp);
  110.                 }
  111.         }
  112.         RenderLine(lbp);
  113. }
  114.  
  115. void TWebBrowser::NewLine()
  116. {
  117.         static bool empty_line = true;
  118.  
  119.         if (draw_x==left_gap) && (draw_y==BODY_MARGIN) return;
  120.         if (t_html) && (!t_body) return;
  121.        
  122.         if (draw_x == style.tag_list.level * 5 * list.font_w + left_gap) {
  123.                 if (!empty_line) empty_line=true; else return;
  124.         } else {
  125.                 empty_line = false;
  126.         }
  127.  
  128.         draw_y += style.cur_line_h;
  129.         style.cur_line_h = list.item_h;
  130.         if (style.blq) draw_x = 6 * list.font_w; else draw_x = 0; //left_gap += style.tag_list.level * 5 * list.font_w ???
  131.         draw_x += style.tag_list.level * 5 * list.font_w + left_gap;
  132. }
  133.  
  134. bool TWebBrowser::RenderImage(dword cur_img)
  135. {
  136.         int img_x, img_y, img_w, img_h;
  137.         dword imgbuf[44];
  138.  
  139.         if (!cur_img) return false;
  140.  
  141.         img_h = ESDWORD[cur_img+8];
  142.         img_w = ESDWORD[cur_img+4];
  143.  
  144.         if (img_w + draw_x - left_gap >= draw_w) NewLine();
  145.         img_y = draw_y;
  146.         if (img_h < list.item_h) img_y += list.item_h - img_h / 2 - 1; else img_y -= 2;
  147.         style.cur_line_h = math.max(style.cur_line_h, img_h);
  148.  
  149.         img_w = math.min(img_w, canvas.bufw - draw_x);
  150.  
  151.         if (link) links.add_text(draw_x + list.x, img_y + list.y, img_w, img_h, 0);
  152.  
  153.         if (img_y + img_h >= canvas.bufh) canvas.IncreaseBufSize();
  154.  
  155.         if (secondrun)
  156.         {      
  157.                 if (ESDWORD[cur_img+20] != IMAGE_BPP32) {
  158.                         img_convert stdcall(cur_img, 0, IMAGE_BPP32, 0, 0);
  159.                         $push eax
  160.                         img_destroy stdcall(cur_img);
  161.                         $pop eax
  162.                         cur_img = EAX;
  163.                         if (!EAX) return false;
  164.                 }
  165.                 imgbuf[04] = canvas.bufw;
  166.                 imgbuf[08] = canvas.bufh;
  167.                 imgbuf[20] = IMAGE_BPP32;
  168.                 imgbuf[24] = buf_data+8;
  169.                 img_blend stdcall(#imgbuf, cur_img, draw_x, img_y, 0, 0, img_w, img_h);
  170.                 img_destroy stdcall(cur_img);
  171.         }
  172.  
  173.         draw_x += img_w;
  174.         if (draw_x - left_gap >= draw_w) NewLine();
  175.         return true;
  176. }