2013-12-27 03:36:17 +04:00
|
|
|
struct s_image
|
|
|
|
{
|
|
|
|
dword *image;
|
|
|
|
char path[4096];
|
|
|
|
};
|
2014-01-19 21:12:45 +04:00
|
|
|
|
2013-12-27 03:36:17 +04:00
|
|
|
s_image pics[100]; //pics = mem_Alloc( 100*sizeof(s_image) );
|
|
|
|
|
2014-01-20 02:46:58 +04:00
|
|
|
struct ImageCache {
|
2014-01-19 21:12:45 +04:00
|
|
|
int pics_count;
|
|
|
|
void Free();
|
2015-08-13 15:23:35 +03:00
|
|
|
int GetImage();
|
2014-01-19 21:12:45 +04:00
|
|
|
void Images();
|
2014-01-20 02:46:58 +04:00
|
|
|
};
|
2014-01-19 21:12:45 +04:00
|
|
|
|
2014-01-20 02:46:58 +04:00
|
|
|
void ImageCache::Free()
|
2013-12-27 03:36:17 +04:00
|
|
|
{
|
2014-01-19 21:12:45 +04:00
|
|
|
for ( ; pics_count>0; pics_count--)
|
2013-12-27 03:36:17 +04:00
|
|
|
{
|
2014-01-19 21:12:45 +04:00
|
|
|
if (pics[pics_count].image) img_destroy stdcall (pics[pics_count].image);
|
|
|
|
pics[pics_count].path = NULL;
|
2013-12-27 03:36:17 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-13 15:23:35 +03:00
|
|
|
int ImageCache::GetImage(dword i_path)
|
2013-12-27 03:36:17 +04:00
|
|
|
{
|
2014-01-19 21:12:45 +04:00
|
|
|
int i;
|
2014-01-30 22:28:50 +04:00
|
|
|
for (i=0; i<=pics_count; i++) if (!strcmp(#pics[i].path, i_path)) return i; //image exists
|
2014-01-19 21:12:45 +04:00
|
|
|
// Load image and add it to Cache
|
|
|
|
pics_count++;
|
|
|
|
pics[pics_count].image = load_image(i_path);
|
|
|
|
strcpy(#pics[pics_count].path, i_path);
|
|
|
|
return pics_count;
|
2013-12-27 03:36:17 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-01-20 02:46:58 +04:00
|
|
|
void ImageCache::Images(int left1, top1, width1)
|
2013-12-27 03:36:17 +04:00
|
|
|
{
|
|
|
|
dword image;
|
2015-08-19 15:48:31 +03:00
|
|
|
char img_path[4096], alt[4096]=0;
|
2014-03-22 01:21:11 +04:00
|
|
|
int imgw=0, imgh=0, img_lines_first=0, cur_pic=0;
|
2013-12-27 03:36:17 +04:00
|
|
|
|
|
|
|
do{
|
2015-08-19 15:48:31 +03:00
|
|
|
if (isattr("src="))
|
2013-12-27 03:36:17 +04:00
|
|
|
{
|
2015-08-19 15:48:31 +03:00
|
|
|
strcpy(#img_path, #val);
|
2014-03-30 15:57:13 +04:00
|
|
|
PageLinks.GetAbsoluteURL(#img_path);
|
2015-08-13 15:23:35 +03:00
|
|
|
cur_pic = GetImage(#img_path);
|
2013-12-27 03:36:17 +04:00
|
|
|
}
|
2015-08-19 15:48:31 +03:00
|
|
|
if (isattr("alt="))
|
2013-12-27 03:36:17 +04:00
|
|
|
{
|
|
|
|
strcpy(#alt, "[");
|
2015-08-19 15:48:31 +03:00
|
|
|
strcat(#alt, #val);
|
2013-12-27 03:36:17 +04:00
|
|
|
strcat(#alt, "]");
|
|
|
|
}
|
|
|
|
|
|
|
|
} while(GetNextParam());
|
|
|
|
|
|
|
|
if (!pics[cur_pic].image)
|
|
|
|
{
|
|
|
|
if (alt) && (link) strcat(#line, #alt);
|
2015-08-19 15:48:31 +03:00
|
|
|
//cur_pic = GetImage("/sys/network/noimg.png");
|
2013-12-27 03:36:17 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-03-22 01:21:11 +04:00
|
|
|
imgw = DSWORD[pics[cur_pic].image+4];
|
|
|
|
imgh = DSWORD[pics[cur_pic].image+8];
|
|
|
|
if (imgw > width1) imgw = width1;
|
2013-12-27 03:36:17 +04:00
|
|
|
|
2015-08-13 15:23:35 +03:00
|
|
|
if (stroka==0) DrawBar(WB1.list.x, WB1.list.y, WB1.list.w-15, 5, bg_color); //fill first line
|
2015-09-09 17:24:42 +03:00
|
|
|
stroka += imgh / WB1.list.item_h;
|
|
|
|
if (imgh % WB1.list.item_h) stroka++;
|
2015-08-13 15:23:35 +03:00
|
|
|
if (top1+imgh<WB1.list.y) || (top1>WB1.list.y+WB1.list.h-10) return; //if all image is out of visible area
|
|
|
|
if (top1<WB1.list.y) //if image partly visible (at the top)
|
2013-12-27 03:36:17 +04:00
|
|
|
{
|
2013-12-27 05:08:50 +04:00
|
|
|
img_lines_first=WB1.list.y-top1;
|
2014-03-22 01:21:11 +04:00
|
|
|
imgh=imgh-img_lines_first;
|
2013-12-27 05:08:50 +04:00
|
|
|
top1=WB1.list.y;
|
2013-12-27 03:36:17 +04:00
|
|
|
}
|
2015-08-13 15:23:35 +03:00
|
|
|
if (top1>WB1.list.y+WB1.list.h-imgh-5) //if image partly visible (at the bottom)
|
2013-12-27 03:36:17 +04:00
|
|
|
{
|
2014-03-22 01:21:11 +04:00
|
|
|
imgh=WB1.list.y+WB1.list.h-top1-5;
|
2013-12-27 03:36:17 +04:00
|
|
|
}
|
2014-03-22 01:21:11 +04:00
|
|
|
if (imgh<=0) return;
|
2013-12-27 03:36:17 +04:00
|
|
|
if (anchor) return;
|
|
|
|
|
2014-03-22 01:21:11 +04:00
|
|
|
img_draw stdcall (pics[cur_pic].image, left1-5, top1, imgw, imgh,0,img_lines_first);
|
|
|
|
DrawBar(left1+imgw - 5, top1, WB1.list.w-imgw, imgh, bg_color);
|
2015-09-09 17:24:42 +03:00
|
|
|
DrawBar(WB1.list.x, top1+imgh, WB1.list.w, -imgh % WB1.list.item_h + WB1.list.item_h, bg_color);
|
2015-08-13 15:23:35 +03:00
|
|
|
if (link)
|
2014-01-30 22:28:50 +04:00
|
|
|
{
|
2014-03-22 01:21:11 +04:00
|
|
|
UnsafeDefineButton(left1 - 5, top1, imgw, imgh-1, PageLinks.count + 400 + BT_HIDE, 0xB5BFC9);
|
|
|
|
PageLinks.AddText(0, imgw, imgh-1, NOLINE);
|
2014-03-30 15:57:13 +04:00
|
|
|
//WB1.DrawPage();
|
2014-01-30 22:28:50 +04:00
|
|
|
}
|
2014-01-20 02:46:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
ImageCache ImgCache;
|