Subversion Repositories Kolibri OS

Rev

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