Subversion Repositories Kolibri OS

Rev

Rev 4415 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
4411 leency 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
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
			{
4414 leency 44
				//get path: absolute or relative
45
				if (options[0]=='/')
46
					strcpy(#img_path, #options);
47
				else
48
				{
49
					img_path[strrchr(#img_path, '/')] = '\0';
50
					strcat(#img_path, #options);
4416 leency 51
				}
4411 leency 52
				cur_pic=GetOrSetPicNum(#img_path);
53
				if (!pics[cur_pic].path)
54
				{
55
					pics[cur_pic].image=load_image(#img_path);
56
					strcpy(#pics[cur_pic].path, #img_path);
57
				}
58
			}
59
		}
4414 leency 60
		if (!strcmp(#parametr,"alt="))
4411 leency 61
		{
62
			strcpy(#alt, "[");
63
			strcat(#alt, #options);
64
			strcat(#alt, "]");
65
		}
66
 
67
	} while(GetNextParam());
68
 
69
	if (!pics[cur_pic].image)
70
	{
71
		if (alt) && (link) strcat(#line, #alt);
72
		return;
73
	}
74
 
75
	w = DSWORD[pics[cur_pic].image+4];
76
	h = DSWORD[pics[cur_pic].image+8];
77
	if (w > width1) w = width1;
78
 
4414 leency 79
	if (stroka==0) DrawBar(WB1.list.x, WB1.list.y, WB1.list.w-15, 5, bg_color); //закрашиваем первую строку
4411 leency 80
	stroka+=h/10;
4414 leency 81
	if (top1+hWB1.list.y+WB1.list.h-10) return; //если ВСЁ изображение ушло ВЕРХ или ВНИЗ
82
	if (top1
4411 leency 83
	{
4414 leency 84
		img_lines_first=WB1.list.y-top1;
4411 leency 85
		h=h-img_lines_first;
4414 leency 86
		top1=WB1.list.y;
4411 leency 87
	}
4414 leency 88
	if (top1>WB1.list.y+WB1.list.h-h-5) //если часть изображения снизу
4411 leency 89
	{
4414 leency 90
		h=WB1.list.y+WB1.list.h-top1-5;
4411 leency 91
	}
92
	if (h<=0) return;
93
	if (anchor) return;
94
 
95
	img_draw stdcall (pics[cur_pic].image, left1-5, top1, w, h,0,img_lines_first);
4414 leency 96
	DrawBar(left1+w - 5, top1, WB1.list.w-w, h, bg_color);
4411 leency 97
	IF (link) UnsafeDefineButton(left1 - 5, top1, w, h-1, blink + BT_HIDE, 0xB5BFC9);
98
}