Subversion Repositories Kolibri OS

Rev

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.         unsigned int len;
  75.  
  76.         //Do we need a line break?
  77.  
  78.         if (!linebuf[0]) return;
  79.  
  80.         while (len = strlen(lbp)) && (len * list.font_w + draw_x - left_gap >= draw_w) {
  81.                 //Yes, we do. Lets calculate where...
  82.                 br = len;
  83.  
  84.                 //debugln("                \\n");
  85.  
  86.                 //Is a new line fits in the current line?
  87.                 if (br * list.font_w + draw_x - left_gap >= draw_w) {
  88.                         br = draw_w - draw_x + left_gap /list.font_w;
  89.                         while(br) {
  90.                                 if (ESBYTE[lbp + br]==' ') {
  91.                                         br++;
  92.                                         break;
  93.                                 }
  94.                                 br--;
  95.                         }
  96.                 }
  97.                 //Maybe a new line is too big for the whole new line? Then we have to split it
  98.                 if (!br) && (len * list.font_w >= draw_w) {
  99.                         br = draw_w - draw_x / list.font_w;
  100.                 }
  101.  
  102.                 if (br) {
  103.                         ESBYTE[lbp + br] >< nul;
  104.                         RenderLine(lbp);
  105.                         ESBYTE[lbp + br] >< nul;
  106.                         lbp += br;
  107.                         while (ESBYTE[lbp]==' ') && (ESBYTE[lbp]) lbp++;
  108.                         if (ESBYTE[lbp]) NewLine();
  109.                 } else {
  110.                         NewLine();
  111.                         RenderLine(lbp);
  112.                 }
  113.         }
  114.         RenderLine(lbp);
  115. }
  116.  
  117. void TWebBrowser::NewLine()
  118. {
  119.         static bool empty_line = true;
  120.  
  121.         if (draw_x==left_gap) && (draw_y==BODY_MARGIN) return;
  122.         if (t_html) && (!t_body) return;
  123.        
  124.         if (draw_x == style.tag_list.level * 5 * list.font_w + left_gap) {
  125.                 if (!empty_line) empty_line=true; else return;
  126.         } else {
  127.                 empty_line = false;
  128.         }
  129.  
  130.         draw_y += style.cur_line_h;
  131.         style.cur_line_h = list.item_h;
  132.         if (style.blq) draw_x = 6 * list.font_w; else draw_x = 0; //left_gap += style.tag_list.level * 5 * list.font_w ???
  133.         draw_x += style.tag_list.level * 5 * list.font_w + left_gap;
  134. }
  135.  
  136. bool TWebBrowser::RenderImage(dword cur_img)
  137. {
  138.         int img_x, img_y, img_w, img_h;
  139.         dword imgbuf[44];
  140.  
  141.         if (!cur_img) return false;
  142.  
  143.         img_h = ESDWORD[cur_img+8];
  144.         img_w = ESDWORD[cur_img+4];
  145.  
  146.         if (img_w + draw_x - left_gap >= draw_w) NewLine();
  147.         img_y = draw_y;
  148.         if (img_h < list.item_h) img_y += list.item_h - img_h / 2 - 1; else img_y -= 2;
  149.         style.cur_line_h = math.max(style.cur_line_h, img_h);
  150.  
  151.         img_w = math.min(img_w, canvas.bufw - draw_x);
  152.  
  153.         if (link) links.add_text(draw_x + list.x, img_y + list.y, img_w, img_h, 0);
  154.  
  155.         if (img_y + img_h >= canvas.bufh) canvas.IncreaseBufSize();
  156.  
  157.         if (secondrun)
  158.         {      
  159.                 if (ESDWORD[cur_img+20] != IMAGE_BPP32) {
  160.                         img_convert stdcall(cur_img, 0, IMAGE_BPP32, 0, 0);
  161.                         $push eax
  162.                         img_destroy stdcall(cur_img);
  163.                         $pop eax
  164.                         cur_img = EAX;
  165.                         if (!EAX) return false;
  166.                 }
  167.                 imgbuf[04] = canvas.bufw;
  168.                 imgbuf[08] = canvas.bufh;
  169.                 imgbuf[20] = IMAGE_BPP32;
  170.                 imgbuf[24] = buf_data+8;
  171.                 img_blend stdcall(#imgbuf, cur_img, draw_x, img_y, 0, 0, img_w, img_h);
  172.                 img_destroy stdcall(cur_img);
  173.         }
  174.  
  175.         draw_x += img_w;
  176.         if (draw_x - left_gap >= draw_w) NewLine();
  177.         return true;
  178. }