Rev 3991 | Rev 4005 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3991 | Rev 3992 | ||
---|---|---|---|
1 | //#include "strings.h" |
1 | //#include "strings.h" |
2 | 2 | ||
3 | void DrawRectangle(dword x,y,w,h,color1) |
3 | void DrawRectangle(dword x,y,w,h,color1) |
4 | { |
4 | { |
5 | if (w<=0) || (h<=0) return; |
5 | if (w<=0) || (h<=0) return; |
6 | DrawBar(x,y,w,1,color1); |
6 | DrawBar(x,y,w,1,color1); |
7 | DrawBar(x,y+h,w,1,color1); |
7 | DrawBar(x,y+h,w,1,color1); |
8 | DrawBar(x,y,1,h,color1); |
8 | DrawBar(x,y,1,h,color1); |
9 | DrawBar(x+w,y,1,h+1,color1); |
9 | DrawBar(x+w,y,1,h+1,color1); |
10 | } |
10 | } |
11 | 11 | ||
12 | void DrawRectangle3D(dword x,y,w,h,color1,color2) |
12 | void DrawRectangle3D(dword x,y,w,h,color1,color2) |
13 | { |
13 | { |
14 | if (w<=0) || (h<=0) return; |
14 | if (w<=0) || (h<=0) return; |
15 | DrawBar(x,y,w+1,1,color1); |
15 | DrawBar(x,y,w+1,1,color1); |
16 | DrawBar(x,y+1,1,h-1,color1); |
16 | DrawBar(x,y+1,1,h-1,color1); |
17 | DrawBar(x+w,y+1,1,h,color2); |
17 | DrawBar(x+w,y+1,1,h,color2); |
18 | DrawBar(x,y+h,w,1,color2); |
18 | DrawBar(x,y+h,w,1,color2); |
19 | } |
19 | } |
20 | 20 | ||
21 | void DrawCaptButton(dword x,y,w,h,id,color_b, color_t,text) |
21 | void DrawCaptButton(dword x,y,w,h,id,color_b, color_t,text) |
22 | { |
22 | { |
23 | DefineButton(x,y,w,h,id,color_b); |
23 | DefineButton(x,y,w,h,id,color_b); |
24 | WriteText(-strlen(text)*6+w/2+x+1,h/2-3+y,0x80,color_t,text); |
24 | WriteText(-strlen(text)*6+w/2+x+1,h/2-3+y,0x80,color_t,text); |
25 | } |
25 | } |
26 | 26 | ||
27 | :void DrawCircle(int x, y, r) |
27 | :void DrawCircle(int x, y, r) |
28 | { |
28 | { |
29 | int i; |
29 | int i; |
30 | float px=0, py=r, ii = r * 3.1415926 * 2; |
30 | float px=0, py=r, ii = r * 3.1415926 * 2; |
31 | FOR (i = 0; i < ii; i++) |
31 | FOR (i = 0; i < ii; i++) |
32 | { |
32 | { |
33 | PutPixel(px + x, y - py, 0); |
33 | PutPixel(px + x, y - py, 0); |
34 | px = py / r + px; |
34 | px = py / r + px; |
35 | py = -px / r + py; |
35 | py = -px / r + py; |
36 | } |
36 | } |
37 | } |
37 | } |
38 | 38 | ||
39 | :void CheckBox(dword x,y,w,h, bt_id, text, graph_color, text_color, is_checked) |
39 | :void CheckBox(dword x,y,w,h, bt_id, text, graph_color, text_color, is_checked) |
40 | { |
40 | { |
41 | DefineButton(x-1, y-1, strlen(text)*6 + w + 17, h+2, bt_id+BT_HIDE+BT_NOFRAME, graph_color); |
41 | DefineButton(x-1, y-1, strlen(text)*6 + w + 17, h+2, bt_id+BT_HIDE+BT_NOFRAME, graph_color); |
42 | WriteText(x+w+10, h / 2 + y -3, 0x80, text_color, text); |
42 | WriteText(x+w+10, h / 2 + y -3, 0x80, text_color, text); |
43 | DrawRectangle(x, y, w, h, graph_color); |
43 | DrawRectangle(x, y, w, h, graph_color); |
44 | if (is_checked == 1) |
44 | if (is_checked == 1) |
45 | { |
45 | { |
46 | DrawRectangle(x+1, y+1, w-2, h-2, 0xffffff); |
46 | DrawRectangle(x+1, y+1, w-2, h-2, 0xffffff); |
47 | DrawBar(x+2, y+2, w-3, h-3, graph_color); |
47 | DrawBar(x+2, y+2, w-3, h-3, graph_color); |
48 | return; //не дадим стрелять себе в ногу |
48 | return; //не дадим стрелять себе в ногу |
49 | } |
49 | } |
50 | if (is_checked == 2) //not active |
50 | if (is_checked == 2) //not active |
51 | { |
51 | { |
52 | DrawRectangle(x+1, y+1, w-2, h-2, 0xffffff); |
52 | DrawRectangle(x+1, y+1, w-2, h-2, 0xffffff); |
53 | DrawBar(x+2, y+2, w-3, h-3, 0x888888); |
53 | DrawBar(x+2, y+2, w-3, h-3, 0x888888); |
54 | return; |
54 | return; |
55 | } |
55 | } |
56 | else |
56 | else |
57 | { |
57 | { |
58 | DrawRectangle3D(x+1, y+1, w-2, h-2, 0xDDDddd, 0xffffff); |
58 | DrawRectangle3D(x+1, y+1, w-2, h-2, 0xDDDddd, 0xffffff); |
59 | DrawBar(x+2, y+2, w-3, h-3, 0xffffff); |
59 | DrawBar(x+2, y+2, w-3, h-3, 0xffffff); |
60 | } |
60 | } |
61 | } |
61 | } |
62 | 62 | ||
63 | :void DrawProgressBar(dword st_x, st_y, st_w, st_h, col_fon, col_border, col_fill, col_text, progress_percent, status_text) |
63 | :void DrawProgressBar(dword st_x, st_y, st_w, st_h, col_fon, col_border, col_fill, col_text, progress_percent, status_text) |
64 | { |
64 | { |
65 | int progress_w; |
65 | int progress_w; |
66 | static int fill_old; |
66 | static int fill_old; |
67 | 67 | ||
68 | //if (progress_percent<=0) {DrawBar(st_x,st_y, st_x + st_w + fill_old + 15,st_h+1, col_fon); fill_old=0; return;} |
68 | //if (progress_percent<=0) {DrawBar(st_x,st_y, st_x + st_w + fill_old + 15,st_h+1, col_fon); fill_old=0; return;} |
69 | if (progress_percent<=0) || (progress_percent>=100) return; |
69 | if (progress_percent<=0) || (progress_percent>=100) return; |
70 | 70 | ||
71 | DrawRectangle(st_x, st_y, st_w,st_h, col_border); |
71 | DrawRectangle(st_x, st_y, st_w,st_h, col_border); |
72 | DrawRectangle3D(st_x+1, st_y+1, st_w-2,st_h-2, 0xFFFfff, 0xFFFfff); |
72 | DrawRectangle3D(st_x+1, st_y+1, st_w-2,st_h-2, 0xFFFfff, 0xFFFfff); |
73 | 73 | ||
74 | if (progress_percent>0) && (progress_percent<=100) |
74 | if (progress_percent>0) && (progress_percent<=100) |
75 | { |
75 | { |
76 | progress_w = st_w - 3 * progress_percent / 100; |
76 | progress_w = st_w - 3 * progress_percent / 100; |
77 | DrawBar(st_x+2, st_y+2, progress_w, st_h-3, col_fill); |
77 | DrawBar(st_x+2, st_y+2, progress_w, st_h-3, col_fill); |
78 | DrawBar(st_x+2+progress_w, st_y+2, st_w-progress_w-3, st_h-3, 0xFFFfff); |
78 | DrawBar(st_x+2+progress_w, st_y+2, st_w-progress_w-3, st_h-3, 0xFFFfff); |
79 | } |
79 | } |
80 | 80 | ||
81 | if (status_text) |
81 | if (status_text) |
82 | { |
82 | { |
83 | DrawBar(st_x+st_w+15, st_h/2-4+st_y, fill_old, 9, col_fon); |
83 | DrawBar(st_x+st_w+15, st_h/2-4+st_y, fill_old, 9, col_fon); |
84 | WriteText(st_x+st_w+15, st_h/2-4+st_y, 0x80, col_text, status_text); |
84 | WriteText(st_x+st_w+15, st_h/2-4+st_y, 0x80, col_text, status_text); |
85 | fill_old = strlen(status_text) * 6; |
85 | fill_old = strlen(status_text) * 6; |
86 | } |
86 | } |
87 | } |
87 | } |
88 | 88 | ||
89 | :void DrawLink(dword x,y,font_type,btn_id, inscription) |
89 | :void DrawLink(dword x,y,font_type,btn_id, inscription) |
90 | { |
90 | { |
91 | int w; |
91 | int w; |
92 | WriteText(x,y,font_type,0x4E00E7,inscription); |
92 | WriteText(x,y,font_type,0x4E00E7,inscription); |
93 | if (font_type==0x80) w = strlen(inscription)*6; else w = strlen(inscription)*7; |
93 | if (font_type==0x80) w = strlen(inscription)*6; else w = strlen(inscription)*7; |
94 | DefineButton(x-1,y-1,w,10,btn_id+BT_HIDE,0); |
94 | DefineButton(x-1,y-1,w,10,btn_id+BT_HIDE,0); |
95 | DrawBar(x,y+8,w,1,0x4E00E7); |
95 | DrawBar(x,y+8,w,1,0x4E00E7); |
96 | } |
96 | } |
97 | 97 | ||
98 | 98 | ||
99 | :void PutShadow(dword x,y,w,h,skinned,strength) |
99 | :void PutShadow(dword x,y,w,h,skinned,strength) |
100 | { |
100 | { |
101 | proc_info wForm; |
101 | proc_info wForm; |
102 | dword shadow_buf, skin_height; |
102 | dword shadow_buf, skin_height; |
103 | shadow_buf = mem_Alloc(w*h*3); |
103 | shadow_buf = mem_Alloc(w*h*3); |
104 | GetProcessInfo(#wForm, SelfInfo); |
104 | GetProcessInfo(#wForm, SelfInfo); |
105 | CopyScreen(shadow_buf, 5*skinned+x+wForm.left, GetSkinHeight()*skinned+y+wForm.top, w, h); |
105 | CopyScreen(shadow_buf, 5*skinned+x+wForm.left, GetSkinHeight()*skinned+y+wForm.top, w, h); |
106 | ShadowImage(shadow_buf, w, h, strength); |
106 | ShadowImage(shadow_buf, w, h, strength); |
107 | _PutImage(x,y,w,h,shadow_buf); |
107 | _PutImage(x,y,w,h,shadow_buf); |
108 | mem_Free(shadow_buf); |
108 | mem_Free(shadow_buf); |
109 | } |
109 | } |
110 | 110 | ||
111 | :void DrawPopupShadow(dword x,y,w,h,skinned) |
111 | :void DrawPopupShadow(dword x,y,w,h,skinned) |
112 | { |
112 | { |
113 | PutShadow(w+x+1,y,1,h+2,skinned,2); |
113 | PutShadow(w+x+1,y,1,h+2,skinned,2); |
114 | PutShadow(w+x+2,y+1,1,h+2,skinned,1); |
114 | PutShadow(w+x+2,y+1,1,h+2,skinned,1); |
115 | PutShadow(x,y+h+2,w+2,1,skinned,2); |
115 | PutShadow(x,y+h+2,w+2,1,skinned,2); |
116 | PutShadow(x+1,y+h+3,w+1,1,skinned,1); |
116 | PutShadow(x+1,y+h+3,w+1,1,skinned,1); |
117 | } |
117 | } |
118 | 118 | ||
119 | :void DrawPopup(dword x,y,w,h,skinned, col_work,col_border) |
119 | :void DrawPopup(dword x,y,w,h,skinned, col_work,col_border) |
120 | { |
120 | { |
121 | DrawRectangle(x,y,w,h,col_border); |
121 | DrawRectangle(x,y,w,h,col_border); |
122 | DrawRectangle3D(x+1,y+1,w-2,h-2,0xFFFfff,col_work); |
122 | DrawBar(x+1,y+1,w-1,1,0xFFFfff); |
123 | DrawBar(x+2,y+2,w-3,h-3,col_work); |
123 | DrawBar(x+1,y+2,1,h-3,0xFFFfff); |
- | 124 | if (col_work!=-1) DrawBar(x+2,y+2,w-2,h-2,col_work); |
|
124 | DrawPopupShadow(x,y,w,h-1,skinned); |
125 | DrawPopupShadow(x,y,w,h-1,skinned); |
125 | } |
126 | } |
126 | 127 | ||
127 | :void GrayScaleImage(dword color_image, w, h) |
128 | :void GrayScaleImage(dword color_image, w, h) |
128 | { |
129 | { |
129 | dword i,j, gray,rr,gg,bb; |
130 | dword i,j, gray,rr,gg,bb; |
130 | for (i = 0; i < w*h*3; i+=3) |
131 | for (i = 0; i < w*h*3; i+=3) |
131 | { |
132 | { |
132 | rr = DSBYTE[i+color_image]; |
133 | rr = DSBYTE[i+color_image]; |
133 | gg = DSBYTE[i+1+color_image]; |
134 | gg = DSBYTE[i+1+color_image]; |
134 | bb = DSBYTE[i+2+color_image]; |
135 | bb = DSBYTE[i+2+color_image]; |
135 | gray = rr*rr; |
136 | gray = rr*rr; |
136 | gray += gg*gg; |
137 | gray += gg*gg; |
137 | gray += bb*bb; |
138 | gray += bb*bb; |
138 | gray = sqrt(gray) / 3; |
139 | gray = sqrt(gray) / 3; |
139 | DSBYTE[i +color_image] = DSBYTE[i+1+color_image] = DSBYTE[i+2+color_image] = gray; |
140 | DSBYTE[i +color_image] = DSBYTE[i+1+color_image] = DSBYTE[i+2+color_image] = gray; |
140 | } |
141 | } |
141 | } |
142 | } |
142 | 143 | ||
143 | :void ShadowImage(dword color_image, w, h, strength) |
144 | :void ShadowImage(dword color_image, w, h, strength) |
144 | { |
145 | { |
145 | dword col, to; |
146 | dword col, to; |
146 | strength = 10 - strength; |
147 | strength = 10 - strength; |
147 | to = w*h*3 + color_image; |
148 | to = w*h*3 + color_image; |
148 | for ( ; color_image < to; color_image++) |
149 | for ( ; color_image < to; color_image++) |
149 | { |
150 | { |
150 | col = strength * DSBYTE[color_image] / 10; |
151 | col = strength * DSBYTE[color_image] / 10; |
151 | DSBYTE[color_image] = col; |
152 | DSBYTE[color_image] = col; |
152 | } |
153 | } |
153 | }>>=100) |
154 | }>>=100) |
154 | >=0)>=0)>>=0)>=0)>=0)>=0)> |
155 | >=0)>=0)>>=0)>=0)>=0)>=0)> |