Subversion Repositories Kolibri OS

Rev

Rev 3466 | 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. }
  28.  
  29.  
  30. void Images(int left1, top1, width1)
  31. {
  32.         dword image;
  33.     char img_path[4096], alt[4096];
  34.     int w=0, h=0, img_lines_first=0, cur_pic=0;
  35.        
  36.         do{
  37.                 if (!strcmp(#parametr,"src="))   //íàäî îáúåäèíèòü ñ GetNewUrl()
  38.                 {
  39.                         if (downloader_id) strcpy(#img_path, #history_list[history_current-1].Item);
  40.                                 else strcpy(#img_path, BrowserHistory.CurrentUrl()); //äîñòà¸ì àäðåñ òåêóùåé ñòðàíèöû
  41.                        
  42.                         if (strcmpn(#img_path, "http:", 5)!=0) || (strcmpn(#options, "http:", 5)!=0)
  43.                         {
  44.                                 img_path[strrchr(#img_path, '/')] = '\0'; //îáðåçàåì å¸ óðë äî ïîñëåäíåãî /
  45.                                 strcat(#img_path, #options);
  46.                                
  47.                                 cur_pic=GetOrSetPicNum(#img_path);
  48.                                 if (!pics[cur_pic].path)
  49.                                 {
  50.                                         pics[cur_pic].image=load_image(#img_path);
  51.                                         strcpy(#pics[cur_pic].path, #img_path);
  52.                                 }
  53.                         }
  54.                 }
  55.                         if (!strcmp(#parametr,"alt="))
  56.                 {
  57.                         strcpy(#alt, "[");
  58.                         strcat(#alt, #options);
  59.                         strcat(#alt, "]");
  60.                 }
  61.  
  62.         } while(GetNextParam());
  63.        
  64.         if (!pics[cur_pic].image)
  65.         {
  66.                 if (alt) && (link) strcat(#line, #alt);
  67.                 return;
  68.         }
  69.        
  70.         w = DSWORD[pics[cur_pic].image+4];
  71.         h = DSWORD[pics[cur_pic].image+8];
  72.         if (w > width1) w = width1;
  73.        
  74.         if (stroka==0) DrawBar(WB1.left, WB1.top, WB1.width-15, 5, bg_color); //çàêðàøèâàåì ïåðâóþ ñòðîêó
  75.         stroka+=h/10;
  76.         if (top1+h<WB1.top) || (top1>WB1.top+WB1.height-10) return; //åñëè ÂѨ èçîáðàæåíèå óøëî ÂÅÐÕ èëè ÂÍÈÇ
  77.         if (top1<WB1.top) //åñëè ÷àñòü èçîáðàæåíèÿ ñâåðõó
  78.         {
  79.                 img_lines_first=WB1.top-top1;
  80.                 h=h-img_lines_first;
  81.                 top1=WB1.top;
  82.         }
  83.         if (top1>WB1.top+WB1.height-h-5) //åñëè ÷àñòü èçîáðàæåíèÿ ñíèçó
  84.         {
  85.                 h=WB1.top+WB1.height-top1-5;
  86.         }      
  87.         if (h<=0) return;
  88.         if (anchor) return;
  89.        
  90.         img_draw stdcall (pics[cur_pic].image, left1-5, top1, w, h,0,img_lines_first);
  91.         DrawBar(left1+w - 5, top1, WB1.width-w, h, bg_color);
  92.         IF (link) UnsafeDefineButton(left1 - 5, top1, w, h-1, blink + BT_HIDE, 0xB5BFC9);
  93. }