Subversion Repositories Kolibri OS

Rev

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