Subversion Repositories Kolibri OS

Rev

Rev 8011 | Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. struct _img
  2. {
  3.         collection url;
  4.         collection_int xywh;
  5.         collection_int data;
  6.         int getid;
  7.         dword add();
  8.         void clear();
  9.         dword current_url();
  10.         bool next_url();
  11.         void set_data();
  12.         void draw();
  13. };
  14.  
  15. dword _img::add(dword _path, _x, _y)
  16. {
  17.         char full_path[URL_SIZE];
  18.         strncpy(#full_path, _path, URL_SIZE);
  19.         GetAbsoluteURL(#full_path, history.current());         
  20.  
  21.         url.add(#full_path);
  22.         xywh.add(_x);
  23.         xywh.add(_y);
  24.         xywh.add(0);
  25.         xywh.add(0);
  26.         return full_path;
  27. }
  28.  
  29. void _img::clear()
  30. {
  31.         url.drop();
  32.         xywh.drop();
  33.         data.drop();
  34.         getid = 0;
  35. }
  36.  
  37. dword _img::current_url()
  38. {
  39.         return url.get(getid);
  40. }
  41.  
  42. bool _img::next_url()
  43. {
  44.         if (getid < url.count-1) {
  45.                 getid++;
  46.                 return 1;
  47.         }
  48.         return 0;
  49. }
  50.  
  51. void _img::set_data(dword _data, _data_len)
  52. {
  53.         data.set(getid, _data);
  54. }
  55.  
  56. void DrawLibimgImage(dword _x, _y, _data, _data_len)
  57. {
  58.         libimg_image im;
  59.         img_decode stdcall (_data, _data_len, 0);
  60.         $or      eax, eax
  61.         $jz      __ERROR__
  62.        
  63.         im.image = EAX;
  64.         im.set_vars();
  65.         im.draw(_x, _y, im.w, im.h, 0, 0);     
  66. __ERROR__:
  67. }
  68.  
  69. void _img::draw(int _x, _y, _start, _height)
  70. {
  71.         int i, img_x, img_y;
  72.  
  73.         for (i=0; i<url.count; i++)
  74.         {
  75.                 img_x = xywh.get(i*4);
  76.                 img_y = xywh.get(i*4 + 1);
  77.  
  78.                 if (img_y > _start) && (img_y < _start + _height)
  79.                 {
  80.                         if (cache.has(url.get(i)))
  81.                         DrawLibimgImage(img_x + _x, img_y-_start + _y, cache.current_buf, cache.current_size);
  82.                 }
  83.         }
  84. }
  85.  
  86. /*
  87.  
  88. void ImageCache::Images(dword left1, top1, width1)
  89. {
  90.         dword image;
  91.     dword imgw=0, imgh=0, img_lines_first=0, cur_pic=0;
  92.        
  93.         //GetAbsoluteURL(#img_path);
  94.         //cur_pic = GetImage(#img_path);
  95.  
  96.         if (!pics[cur_pic].image)
  97.         {
  98.                 //cur_pic = GetImage("/sys/network/noimg.png");
  99.                 return;
  100.         }
  101.        
  102.         imgw = DSWORD[pics[cur_pic].image+4];
  103.         imgh = DSWORD[pics[cur_pic].image+8];
  104.         if (imgw > width1) imgw = width1;
  105.        
  106.         draw_y += imgh + 5; TEMPORARY TURN OFF!!!
  107.        
  108.         if (top1+imgh<WB1.list.y) || (top1>WB1.list.y+WB1.list.h-10) return; //if all image is out of visible area
  109.         if (top1<WB1.list.y) //if image partly visible (at the top)
  110.         {
  111.                 img_lines_first=WB1.list.y-top1;
  112.                 imgh=imgh-img_lines_first;
  113.                 top1=WB1.list.y;
  114.         }
  115.         if (top1>WB1.list.y+WB1.list.h-imgh-5) //if image partly visible (at the bottom)
  116.         {
  117.                 imgh=WB1.list.y+WB1.list.h-top1-5;
  118.         }      
  119.         if (imgh<=0) return;
  120.        
  121.         img_draw stdcall (pics[cur_pic].image, left1-5, top1, imgw, imgh,0,img_lines_first);
  122.         DrawBar(left1+imgw - 5, top1, WB1.list.w-imgw, imgh, page_bg);
  123.         DrawBar(WB1.list.x, top1+imgh, WB1.list.w, -imgh % WB1.list.item_h + WB1.list.item_h, page_bg);
  124.         if (link)
  125.         {
  126.                 UnsafeDefineButton(left1 - 5, top1, imgw, imgh-1, links.count + 400 + BT_HIDE, 0xB5BFC9);
  127.                 links.AddText(0, imgw, imgh-1, NOLINE, 1);
  128.                 WB1.DrawPage();
  129.         }
  130. }
  131.  
  132. ImageCache ImgCache;
  133.  
  134. */