Subversion Repositories Kolibri OS

Rev

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

  1. CANVAS canvas;
  2.  
  3. void TWebBrowser::RenderLine()
  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.                 line = 0;
  16.                 return;
  17.         }
  18.         if (t_html) && (!t_body) {
  19.                 line = 0;
  20.                 return;
  21.         }
  22.        
  23.         if (line)
  24.         {
  25.                 pw = strlen(#line) * list.font_w;
  26.                 zoom = list.font_w / BASIC_CHAR_W;
  27.  
  28.                 style.cur_line_h = math.max(style.cur_line_h, list.item_h);
  29.  
  30.                 if (bg_colors.get_last() - bg_colors.get(0)) {
  31.                         canvas.DrawBar(draw_x, draw_y, pw, list.item_h, bg_colors.get_last());
  32.                 }
  33.  
  34.                 if (style.image) {
  35.                         canvas.DrawBar(draw_x, draw_y, pw, list.item_h-1, 0xF9DBCB);
  36.                 }
  37.                 if (style.button) {
  38.                         canvas.DrawBar(draw_x, draw_y, pw, list.item_h - calc(zoom*2), 0xCCCccc);
  39.                         canvas.DrawBar(draw_x, draw_y + list.item_h - calc(zoom*2), pw, zoom, 0x999999);
  40.                 }
  41.  
  42.                 pc = text_colors.get_last();
  43.                 if (link) && (pc == text_colors.get(0)) pc = link_color_default;
  44.  
  45.                 canvas.WriteText(draw_x, draw_y, list.font_type, pc, #line, NULL);
  46.                 if (style.b) canvas.WriteText(draw_x+1, draw_y, list.font_type, pc, #line, NULL);
  47.                 if (style.s) canvas.DrawBar(draw_x, list.item_h / 2 - zoom + draw_y, pw, zoom, pc);
  48.                 if (style.u) canvas.DrawBar(draw_x, list.item_h - zoom - zoom + draw_y, pw, zoom, pc);
  49.                 if (link) {
  50.                         if (line[0]==' ') && (line[1]==NULL) {} else {
  51.                                 canvas.DrawBar(draw_x, draw_y + list.item_h - calc(zoom*2)-1, pw, zoom, link_color_default);
  52.                                 links.add_text(draw_x, draw_y + list.y, pw, list.item_h - calc(zoom*2)-1, zoom);                               
  53.                         }
  54.                 }
  55.                 draw_x += pw;
  56.                 if (debug_mode) debugln(#line);
  57.                 line = NULL;
  58.         }
  59. }
  60.  
  61. void TWebBrowser::RenderTextbuf()
  62. {
  63.         int break_pos;
  64.         char next_line[4096];
  65.         int zoom = list.font_w / BASIC_CHAR_W;
  66.  
  67.         //Do we need a line break?
  68.         while (strlen(#line) * list.font_w + draw_x >= draw_w) {
  69.                 //Yes, we do. Lets calculate where...
  70.                 break_pos = strrchr(#line, ' ');
  71.  
  72.                 //Is a new line fits in the current line?
  73.                 if (break_pos * list.font_w + draw_x > draw_w) {
  74.                         break_pos = draw_w - draw_x /list.font_w;
  75.                         while(break_pos) && (line[break_pos]!=' ') break_pos--;
  76.                 }
  77.                 //Maybe a new line is too big for the whole new line? Then we have to split it
  78.                 if (!break_pos) && (style.tag_list.level*5 + strlen(#line) * zoom >= list.column_max) {
  79.                         break_pos = draw_w  - draw_x / list.font_w;
  80.                 }
  81.  
  82.                 strcpy(#next_line, #line + break_pos);
  83.                 line[break_pos] = 0x00;        
  84.                
  85.                 RenderLine();
  86.  
  87.                 strcpy(#line, #next_line);
  88.                 NewLine();             
  89.         }
  90.         RenderLine();
  91. }
  92.  
  93. bool TWebBrowser::RenderImage(dword cur_img)
  94. {
  95.         int img_x, img_y, img_w, img_h;
  96.         dword imgbuf[44];
  97.  
  98.         if (!cur_img) return false;
  99.  
  100.         img_h = ESDWORD[cur_img+8];
  101.         img_w = ESDWORD[cur_img+4];
  102.  
  103.         if (img_w + draw_x >= draw_w) NewLine();
  104.         img_y = draw_y;
  105.         if (img_h < list.item_h) img_y += list.item_h - img_h / 2 - 1; else img_y -= 2;
  106.         style.cur_line_h = math.max(style.cur_line_h, img_h);
  107.  
  108.         img_w = math.min(img_w, canvas.bufw - draw_x);
  109.  
  110.         if (link) links.add_text(draw_x + list.x, img_y + list.y, img_w, img_h, 0);
  111.  
  112.         if (img_y + img_h >= canvas.bufh) canvas.IncreaseBufSize();
  113.  
  114.         if (ESDWORD[cur_img+20] != IMAGE_BPP32) {
  115.                 img_convert stdcall(cur_img, 0, IMAGE_BPP32, 0, 0);
  116.                 $push eax
  117.                 img_destroy stdcall(cur_img);
  118.                 $pop eax
  119.                 cur_img = EAX;
  120.                 if (!EAX) return false;
  121.         }
  122.         imgbuf[04] = canvas.bufw;
  123.         imgbuf[08] = canvas.bufh;
  124.         imgbuf[20] = IMAGE_BPP32;
  125.         imgbuf[24] = buf_data+8;
  126.         img_blend stdcall(#imgbuf, cur_img, draw_x, img_y, 0, 0, img_w, img_h);
  127.         img_destroy stdcall(cur_img);
  128.  
  129.         draw_x += img_w;
  130.         if (draw_x >= draw_w) NewLine();
  131.         return true;
  132. }