Subversion Repositories Kolibri OS

Rev

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

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