Rev 4636 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4636 | Rev 4674 | ||
---|---|---|---|
1 | struct s_image |
1 | struct s_image |
2 | { |
2 | { |
3 | dword *image; |
3 | dword *image; |
4 | char path[4096]; |
4 | char path[4096]; |
5 | }; |
5 | }; |
6 | 6 | ||
7 | s_image pics[100]; //pics = mem_Alloc( 100*sizeof(s_image) ); |
7 | s_image pics[100]; //pics = mem_Alloc( 100*sizeof(s_image) ); |
8 | 8 | ||
9 | struct ImageCache { |
9 | struct ImageCache { |
10 | int pics_count; |
10 | int pics_count; |
11 | void Free(); |
11 | void Free(); |
12 | int GetImageNumber(); |
12 | int GetImageNumber(); |
13 | void Images(); |
13 | void Images(); |
14 | }; |
14 | }; |
15 | 15 | ||
16 | void ImageCache::Free() |
16 | void ImageCache::Free() |
17 | { |
17 | { |
18 | for ( ; pics_count>0; pics_count--) |
18 | for ( ; pics_count>0; pics_count--) |
19 | { |
19 | { |
20 | if (pics[pics_count].image) img_destroy stdcall (pics[pics_count].image); |
20 | if (pics[pics_count].image) img_destroy stdcall (pics[pics_count].image); |
21 | pics[pics_count].path = NULL; |
21 | pics[pics_count].path = NULL; |
22 | } |
22 | } |
23 | } |
23 | } |
24 | 24 | ||
25 | int ImageCache::GetImageNumber(dword i_path) |
25 | int ImageCache::GetImageNumber(dword i_path) |
26 | { |
26 | { |
27 | int i; |
27 | int i; |
28 | for (i=0; i<=pics_count; i++) if (!strcmp(#pics[i].path, i_path)) return i; //image exists |
28 | for (i=0; i<=pics_count; i++) if (!strcmp(#pics[i].path, i_path)) return i; //image exists |
29 | // Load image and add it to Cache |
29 | // Load image and add it to Cache |
30 | pics_count++; |
30 | pics_count++; |
31 | pics[pics_count].image = load_image(i_path); |
31 | pics[pics_count].image = load_image(i_path); |
32 | strcpy(#pics[pics_count].path, i_path); |
32 | strcpy(#pics[pics_count].path, i_path); |
33 | return pics_count; |
33 | return pics_count; |
34 | } |
34 | } |
35 | 35 | ||
36 | 36 | ||
37 | void ImageCache::Images(int left1, top1, width1) |
37 | void ImageCache::Images(int left1, top1, width1) |
38 | { |
38 | { |
39 | dword image; |
39 | dword image; |
40 | char img_path[4096], alt[4096]; |
40 | char img_path[4096], alt[4096]; |
41 | int w=0, h=0, img_lines_first=0, cur_pic=0; |
41 | int imgw=0, imgh=0, img_lines_first=0, cur_pic=0; |
42 | 42 | ||
43 | do{ |
43 | do{ |
44 | if (!strcmp(#parametr,"src=")) //íàäî îáúåäèíèòü ñ GetNewUrl() |
44 | if (!strcmp(#parametr,"src=")) //íàäî îáúåäèíèòü ñ GetNewUrl() |
45 | { |
45 | { |
46 | if (http_transfer<>0) strcpy(#img_path, #history_list[BrowserHistory.current-1].Item); else |
46 | if (http_transfer<>0) strcpy(#img_path, #history_list[BrowserHistory.current-1].Item); else |
47 | strcpy(#img_path, BrowserHistory.CurrentUrl()); |
47 | strcpy(#img_path, BrowserHistory.CurrentUrl()); |
48 | if (strcmpn(#img_path, "http:", 5)!=0) || (strcmpn(#options, "http:", 5)!=0) |
48 | if (strcmpn(#img_path, "http:", 5)!=0) || (strcmpn(#options, "http:", 5)!=0) |
49 | { |
49 | { |
50 | //get path: absolute or relative |
50 | //get path: absolute or relative |
51 | if (options[0]=='/') |
51 | if (options[0]=='/') |
52 | strcpy(#img_path, #options); |
52 | strcpy(#img_path, #options); |
53 | else |
53 | else |
54 | { |
54 | { |
55 | img_path[strrchr(#img_path, '/')] = '\0'; |
55 | img_path[strrchr(#img_path, '/')] = '\0'; |
56 | strcat(#img_path, #options); |
56 | strcat(#img_path, #options); |
57 | } |
57 | } |
58 | cur_pic = GetImageNumber(#img_path); |
58 | cur_pic = GetImageNumber(#img_path); |
59 | } |
59 | } |
60 | } |
60 | } |
61 | if (!strcmp(#parametr,"alt=")) |
61 | if (!strcmp(#parametr,"alt=")) |
62 | { |
62 | { |
63 | strcpy(#alt, "["); |
63 | strcpy(#alt, "["); |
64 | strcat(#alt, #options); |
64 | strcat(#alt, #options); |
65 | strcat(#alt, "]"); |
65 | strcat(#alt, "]"); |
66 | } |
66 | } |
67 | 67 | ||
68 | } while(GetNextParam()); |
68 | } while(GetNextParam()); |
69 | 69 | ||
70 | if (!pics[cur_pic].image) |
70 | if (!pics[cur_pic].image) |
71 | { |
71 | { |
72 | if (alt) && (link) strcat(#line, #alt); |
72 | if (alt) && (link) strcat(#line, #alt); |
73 | return; |
73 | return; |
74 | } |
74 | } |
75 | 75 | ||
76 | w = DSWORD[pics[cur_pic].image+4]; |
76 | imgw = DSWORD[pics[cur_pic].image+4]; |
77 | h = DSWORD[pics[cur_pic].image+8]; |
77 | imgh = DSWORD[pics[cur_pic].image+8]; |
78 | if (w > width1) w = width1; |
78 | if (imgw > width1) imgw = width1; |
79 | 79 | ||
80 | if (stroka==0) DrawBar(WB1.list.x, WB1.list.y, WB1.list.w-15, 5, bg_color); //çàêðàøèâàåì ïåðâóþ ñòðîêó |
80 | if (stroka==0) DrawBar(WB1.list.x, WB1.list.y, WB1.list.w-15, 5, bg_color); //çàêðàøèâàåì ïåðâóþ ñòðîêó |
81 | stroka += h/10; |
81 | stroka += imgh/10; |
82 | if (top1+h |
82 | if (top1+imgh |
83 | if (top1 |
83 | if (top1 |
84 | { |
84 | { |
85 | img_lines_first=WB1.list.y-top1; |
85 | img_lines_first=WB1.list.y-top1; |
86 | h=h-img_lines_first; |
86 | imgh=imgh-img_lines_first; |
87 | top1=WB1.list.y; |
87 | top1=WB1.list.y; |
88 | } |
88 | } |
89 | if (top1>WB1.list.y+WB1.list.h-h-5) //åñëè ÷àñòü èçîáðàæåíèÿ ñíèçó |
89 | if (top1>WB1.list.y+WB1.list.h-imgh-5) //åñëè ÷àñòü èçîáðàæåíèÿ ñíèçó |
90 | { |
90 | { |
91 | h=WB1.list.y+WB1.list.h-top1-5; |
91 | imgh=WB1.list.y+WB1.list.h-top1-5; |
92 | } |
92 | } |
93 | if (h<=0) return; |
93 | if (imgh<=0) return; |
94 | if (anchor) return; |
94 | if (anchor) return; |
95 | 95 | ||
96 | img_draw stdcall (pics[cur_pic].image, left1-5, top1, w, h,0,img_lines_first); |
96 | img_draw stdcall (pics[cur_pic].image, left1-5, top1, imgw, imgh,0,img_lines_first); |
97 | DrawBar(left1+w - 5, top1, WB1.list.w-w, h, bg_color); |
97 | DrawBar(left1+imgw - 5, top1, WB1.list.w-imgw, imgh, bg_color); |
98 | IF (link) |
98 | IF (link) |
99 | { |
99 | { |
100 | UnsafeDefineButton(left1 - 5, top1, w, h-1, PageLinks.count + 400 + BT_HIDE, 0xB5BFC9); |
100 | UnsafeDefineButton(left1 - 5, top1, imgw, imgh-1, PageLinks.count + 400 + BT_HIDE, 0xB5BFC9); |
101 | PageLinks.AddText(0, w, h-1, NOLINE); |
101 | PageLinks.AddText(0, imgw, imgh-1, NOLINE); |
102 | // WB1.DrawPage(); |
102 | // WB1.DrawPage(); |
103 | } |
103 | } |
104 | } |
104 | } |
105 | 105 | ||
106 | ImageCache ImgCache;=0)>>=pics_count;> |
106 | ImageCache ImgCache;=0)>>=pics_count;> |