Subversion Repositories Kolibri OS

Rev

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

  1. struct s_image
  2. {
  3.         dword *image;
  4.         char path[4096];
  5. };
  6. s_image pics[100]; //pics = mem_Alloc( 100*sizeof(s_image) );
  7. int num_of_pics;
  8.  
  9. int GetOrSetPicNum(dword i_path)
  10. {
  11.         int i;
  12.         for (i=0; i<num_of_pics; i++)
  13.         {
  14.                 if (!strcmp(#pics[i].path, i_path)) return i;
  15.         }
  16.         num_of_pics++;
  17.         return num_of_pics;
  18. }
  19.  
  20. void FreeImgCache()
  21. {
  22.         for ( ; num_of_pics>0; num_of_pics--)
  23.         {
  24.                 if (pics[num_of_pics].image) img_destroy stdcall (pics[num_of_pics].image);
  25.                 pics[num_of_pics].path = NULL;
  26.         }
  27.         notify(IMAGES_CACHE_CLEARED);
  28. }
  29.  
  30.  
  31. void Images(int left1, top1, width1)
  32. {
  33.         dword image;
  34.     char img_path[4096], alt[4096];
  35.     int w=0, h=0, img_lines_first=0, cur_pic=0;
  36.        
  37.         do{
  38.                 if (!strcmp(#parametr,"src="))   //íàäî îáúåäèíèòü ñ GetNewUrl()
  39.                 {
  40.                         if (downloader_id) strcpy(#img_path, #history_list[history_current-1].Item);
  41.                                 else strcpy(#img_path, BrowserHistory.CurrentUrl()); //äîñòà¸ì àäðåñ òåêóùåé ñòðàíèöû
  42.                        
  43.                         if (strcmpn(#img_path, "http:", 5)!=0) || (strcmpn(#options, "http:", 5)!=0)
  44.                         {
  45.                                 debug("image options:");
  46.                                 debug(#options);
  47.                                 //get path: absolute or relative
  48.                                 if (options[0]=='/')
  49.                                         strcpy(#img_path, #options);
  50.                                 else
  51.                                 {
  52.                                         img_path[strrchr(#img_path, '/')] = '\0';
  53.                                         strcat(#img_path, #options);
  54.                                 }              
  55.                                 debug("image img_path:");
  56.                                 debug(#img_path);
  57.                                 cur_pic=GetOrSetPicNum(#img_path);
  58.                                 if (!pics[cur_pic].path)
  59.                                 {
  60.                                         pics[cur_pic].image=load_image(#img_path);
  61.                                         strcpy(#pics[cur_pic].path, #img_path);
  62.                                 }
  63.                         }
  64.                 }
  65.                 if (!strcmp(#parametr,"alt="))
  66.                 {
  67.                         strcpy(#alt, "[");
  68.                         strcat(#alt, #options);
  69.                         strcat(#alt, "]");
  70.                 }
  71.  
  72.         } while(GetNextParam());
  73.        
  74.         if (!pics[cur_pic].image)
  75.         {
  76.                 if (alt) && (link) strcat(#line, #alt);
  77.                 return;
  78.         }
  79.        
  80.         w = DSWORD[pics[cur_pic].image+4];
  81.         h = DSWORD[pics[cur_pic].image+8];
  82.         if (w > width1) w = width1;
  83.        
  84.         if (stroka==0) DrawBar(WB1.list.x, WB1.list.y, WB1.list.w-15, 5, bg_color); //çàêðàøèâàåì ïåðâóþ ñòðîêó
  85.         stroka+=h/10;
  86.         if (top1+h<WB1.list.y) || (top1>WB1.list.y+WB1.list.h-10) return; //åñëè ÂѨ èçîáðàæåíèå óøëî ÂÅÐÕ èëè ÂÍÈÇ
  87.         if (top1<WB1.list.y) //åñëè ÷àñòü èçîáðàæåíèÿ ñâåðõó
  88.         {
  89.                 img_lines_first=WB1.list.y-top1;
  90.                 h=h-img_lines_first;
  91.                 top1=WB1.list.y;
  92.         }
  93.         if (top1>WB1.list.y+WB1.list.h-h-5) //åñëè ÷àñòü èçîáðàæåíèÿ ñíèçó
  94.         {
  95.                 h=WB1.list.y+WB1.list.h-top1-5;
  96.         }      
  97.         if (h<=0) return;
  98.         if (anchor) return;
  99.        
  100.         img_draw stdcall (pics[cur_pic].image, left1-5, top1, w, h,0,img_lines_first);
  101.         DrawBar(left1+w - 5, top1, WB1.list.w-w, h, bg_color);
  102.         IF (link) UnsafeDefineButton(left1 - 5, top1, w, h-1, blink + BT_HIDE, 0xB5BFC9);
  103. }