Rev 5519 | Rev 5542 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5519 | Rev 5526 | ||
---|---|---|---|
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 | if (id>0) DefineButton(x,y,w,h,id,color_b); |
23 | if (id>0) 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 WriteTextCenter(dword x,y,w,color_t,text) |
27 | :void WriteTextCenter(dword x,y,w,color_t,text) |
28 | { |
28 | { |
29 | WriteText(-strlen(text)*6+w/2+x+1,y,0x80,color_t,text); |
29 | WriteText(-strlen(text)*6+w/2+x+1,y,0x80,color_t,text); |
30 | } |
30 | } |
31 | 31 | ||
32 | :void DrawCircle(int x, y, r, color) |
32 | :void DrawCircle(int x, y, r, color) |
33 | { |
33 | { |
34 | int i; |
34 | int i; |
35 | float px=0, py=r, ii = r * 3.1415926 * 2; |
35 | float px=0, py=r, ii = r * 3.1415926 * 2; |
36 | FOR (i = 0; i < ii; i++) |
36 | FOR (i = 0; i < ii; i++) |
37 | { |
37 | { |
38 | PutPixel(px + x, y - py, color); |
38 | PutPixel(px + x, y - py, color); |
39 | px = py / r + px; |
39 | px = py / r + px; |
40 | py = -px / r + py; |
40 | py = -px / r + py; |
41 | } |
41 | } |
42 | } |
42 | } |
43 | 43 | ||
44 | :void CheckBox(dword x,y,w,h, bt_id, text, graph_color, text_color, is_checked) |
44 | :void CheckBox(dword x,y,w,h, bt_id, text, graph_color, text_color, is_checked) |
45 | { |
45 | { |
46 | DefineButton(x-1, y-1, strlen(text)*6 + w + 17, h+2, bt_id+BT_HIDE+BT_NOFRAME, graph_color); |
46 | DefineButton(x-1, y-1, strlen(text)*6 + w + 17, h+2, bt_id+BT_HIDE+BT_NOFRAME, graph_color); |
47 | WriteText(x+w+8, h / 2 + y -3, 0x80, text_color, text); |
47 | WriteText(x+w+8, h / 2 + y -3, 0x80, text_color, text); |
48 | DrawRectangle(x, y, w, h, graph_color); |
48 | DrawRectangle(x, y, w, h, graph_color); |
49 | if (is_checked == 0) |
49 | if (is_checked == 0) |
50 | { |
50 | { |
51 | DrawRectangle3D(x+1, y+1, w-2, h-2, 0xDDDddd, 0xffffff); |
51 | DrawRectangle3D(x+1, y+1, w-2, h-2, 0xDDDddd, 0xffffff); |
52 | DrawBar(x+2, y+2, w-3, h-3, 0xffffff); |
52 | DrawBar(x+2, y+2, w-3, h-3, 0xffffff); |
53 | } |
53 | } |
54 | else if (is_checked == 1) |
54 | else if (is_checked == 1) |
55 | { |
55 | { |
56 | DrawRectangle(x+1, y+1, w-2, h-2, 0xffffff); |
56 | DrawRectangle(x+1, y+1, w-2, h-2, 0xffffff); |
- | 57 | DrawRectangle(x+2, y+2, w-4, h-4, 0xffffff); |
|
57 | DrawBar(x+2, y+2, w-3, h-3, graph_color); |
58 | DrawBar(x+3, y+3, w-5, h-5, graph_color); |
58 | } |
59 | } |
59 | else if (is_checked == 2) //not active |
60 | else if (is_checked == 2) //not active |
60 | { |
61 | { |
61 | DrawRectangle(x+1, y+1, w-2, h-2, 0xffffff); |
62 | DrawRectangle(x+1, y+1, w-2, h-2, 0xffffff); |
- | 63 | DrawRectangle(x+2, y+2, w-4, h-4, 0xffffff); |
|
62 | DrawBar(x+2, y+2, w-3, h-3, 0x888888); |
64 | DrawBar(x+3, y+3, w-5, h-5, 0x888888); |
63 | } |
65 | } |
64 | } |
66 | } |
65 | 67 | ||
66 | :void MoreLessBox(dword x,y,s, bt_id_more, bt_id_less, color_border, color_button, color_text, value, text) |
68 | :void MoreLessBox(dword x,y,s, bt_id_more, bt_id_less, color_border, color_button, color_text, value, text) |
67 | { |
69 | { |
68 | #define VALUE_FIELD_W 26; |
70 | #define VALUE_FIELD_W 26; |
69 | DrawRectangle(x, y, VALUE_FIELD_W, s, color_border); |
71 | DrawRectangle(x, y, VALUE_FIELD_W, s, color_border); |
70 | DrawRectangle3D(x+1, y+1, VALUE_FIELD_W-2, s-2, 0xDDDddd, 0xffffff); |
72 | DrawRectangle3D(x+1, y+1, VALUE_FIELD_W-2, s-2, 0xDDDddd, 0xffffff); |
71 | DrawBar(x+2, y+2, VALUE_FIELD_W-3, s-3, 0xffffff); |
73 | DrawBar(x+2, y+2, VALUE_FIELD_W-3, s-3, 0xffffff); |
72 | WriteText(x+6, s / 2 + y -3, 0x80, color_text, itoa(value)); |
74 | WriteText(x+6, s / 2 + y -3, 0x80, 0x000000, itoa(value)); |
73 | 75 | ||
74 | DrawCaptButton(VALUE_FIELD_W + x + 1, y, s, s, bt_id_more, color_button, color_text, "+"); |
76 | DrawCaptButton(VALUE_FIELD_W + x + 1, y, s, s, bt_id_more, color_button, color_text, "+"); |
75 | DrawCaptButton(VALUE_FIELD_W + x + s + 2, y, s, s, bt_id_less, color_button, color_text, "-"); |
77 | DrawCaptButton(VALUE_FIELD_W + x + s + 2, y, s, s, bt_id_less, color_button, color_text, "-"); |
76 | WriteText(x+VALUE_FIELD_W+s+s+10, s / 2 + y -3, 0x80, color_text, text); |
78 | WriteText(x+VALUE_FIELD_W+s+s+10, s / 2 + y -3, 0x80, color_text, text); |
77 | } |
79 | } |
78 | 80 | ||
79 | :void DrawProgressBar(dword st_x, st_y, st_w, st_h, col_fon, col_border, col_fill, col_text, progress_percent) |
81 | :void DrawProgressBar(dword st_x, st_y, st_w, st_h, col_fon, col_border, col_fill, col_text, progress_percent) |
80 | { |
82 | { |
81 | int progress_w; |
83 | int progress_w; |
82 | static int fill_old; |
84 | static int fill_old; |
83 | 85 | ||
84 | //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;} |
86 | //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;} |
85 | if (progress_percent<=0) || (progress_percent>=100) return; |
87 | if (progress_percent<=0) || (progress_percent>=100) return; |
86 | 88 | ||
87 | DrawRectangle(st_x, st_y, st_w,st_h, col_border); |
89 | DrawRectangle(st_x, st_y, st_w,st_h, col_border); |
88 | DrawRectangle3D(st_x+1, st_y+1, st_w-2,st_h-2, 0xFFFfff, 0xFFFfff); |
90 | DrawRectangle3D(st_x+1, st_y+1, st_w-2,st_h-2, 0xFFFfff, 0xFFFfff); |
89 | 91 | ||
90 | if (progress_percent>0) && (progress_percent<=100) |
92 | if (progress_percent>0) && (progress_percent<=100) |
91 | { |
93 | { |
92 | progress_w = st_w - 3 * progress_percent / 100; |
94 | progress_w = st_w - 3 * progress_percent / 100; |
93 | DrawBar(st_x+2, st_y+2, progress_w, st_h-3, col_fill); |
95 | DrawBar(st_x+2, st_y+2, progress_w, st_h-3, col_fill); |
94 | DrawBar(st_x+2+progress_w, st_y+2, st_w-progress_w-3, st_h-3, 0xFFFfff); |
96 | DrawBar(st_x+2+progress_w, st_y+2, st_w-progress_w-3, st_h-3, 0xFFFfff); |
95 | } |
97 | } |
96 | } |
98 | } |
97 | 99 | ||
98 | :void DrawLink(dword x,y,font_type,btn_id, inscription) |
100 | :void DrawLink(dword x,y,font_type,btn_id, inscription) |
99 | { |
101 | { |
100 | int w; |
102 | int w; |
101 | WriteText(x,y,font_type,0x4E00E7,inscription); |
103 | WriteText(x,y,font_type,0x4E00E7,inscription); |
102 | if (font_type==0x80) w = strlen(inscription)*6; else w = strlen(inscription)*7; |
104 | if (font_type==0x80) w = strlen(inscription)*6; else w = strlen(inscription)*7; |
103 | DefineButton(x-1,y-1,w,10,btn_id+BT_HIDE,0); |
105 | DefineButton(x-1,y-1,w,10,btn_id+BT_HIDE,0); |
104 | DrawBar(x,y+8,w,1,0x4E00E7); |
106 | DrawBar(x,y+8,w,1,0x4E00E7); |
105 | } |
107 | } |
106 | 108 | ||
107 | :void PutShadow(dword x,y,w,h,skinned,strength) |
109 | :void PutShadow(dword x,y,w,h,skinned,strength) |
108 | { |
110 | { |
109 | proc_info wForm; |
111 | proc_info wForm; |
110 | dword shadow_buf, skin_height; |
112 | dword shadow_buf, skin_height; |
111 | shadow_buf = mem_Alloc(w*h*3); |
113 | shadow_buf = mem_Alloc(w*h*3); |
112 | GetProcessInfo(#wForm, SelfInfo); |
114 | GetProcessInfo(#wForm, SelfInfo); |
113 | CopyScreen(shadow_buf, 5*skinned+x+wForm.left, GetSkinHeight()*skinned+y+wForm.top, w, h); |
115 | CopyScreen(shadow_buf, 5*skinned+x+wForm.left, GetSkinHeight()*skinned+y+wForm.top, w, h); |
114 | ShadowImage(shadow_buf, w, h, strength); |
116 | ShadowImage(shadow_buf, w, h, strength); |
115 | _PutImage(x,y,w,h,shadow_buf); |
117 | _PutImage(x,y,w,h,shadow_buf); |
116 | mem_Free(shadow_buf); |
118 | mem_Free(shadow_buf); |
117 | } |
119 | } |
118 | 120 | ||
119 | :void DrawPopup(dword x,y,w,h,skinned, col_work,col_border) |
121 | :void DrawPopup(dword x,y,w,h,skinned, col_work,col_border) |
120 | { |
122 | { |
121 | DrawRectangle(x,y,w,h,col_border); |
123 | DrawRectangle(x,y,w,h,col_border); |
122 | DrawBar(x+1,y+1,w-1,1,0xFFFfff); |
124 | DrawBar(x+1,y+1,w-1,1,0xFFFfff); |
123 | DrawBar(x+1,y+2,1,h-2,0xFFFfff); |
125 | DrawBar(x+1,y+2,1,h-2,0xFFFfff); |
124 | if (col_work!=-1) DrawBar(x+2,y+2,w-2,h-2,col_work); |
126 | if (col_work!=-1) DrawBar(x+2,y+2,w-2,h-2,col_work); |
125 | DrawPopupShadow(x,y,w,h-1,skinned); |
127 | DrawPopupShadow(x,y,w,h-1,skinned); |
126 | } |
128 | } |
127 | 129 | ||
128 | :void DrawPopupShadow(dword x,y,w,h,skinned) |
130 | :void DrawPopupShadow(dword x,y,w,h,skinned) |
129 | { |
131 | { |
130 | PutShadow(w+x+1,y,1,h+2,skinned,2); |
132 | PutShadow(w+x+1,y,1,h+2,skinned,2); |
131 | PutShadow(w+x+2,y+1,1,h+2,skinned,1); |
133 | PutShadow(w+x+2,y+1,1,h+2,skinned,1); |
132 | PutShadow(x,y+h+2,w+2,1,skinned,2); |
134 | PutShadow(x,y+h+2,w+2,1,skinned,2); |
133 | PutShadow(x+1,y+h+3,w+1,1,skinned,1); |
135 | PutShadow(x+1,y+h+3,w+1,1,skinned,1); |
134 | } |
136 | } |
135 | 137 | ||
136 | :void GrayScaleImage(dword color_image, w, h) |
138 | :void GrayScaleImage(dword color_image, w, h) |
137 | { |
139 | { |
138 | dword i,gray,rr,gg,bb; |
140 | dword i,gray,rr,gg,bb; |
139 | for (i = 0; i < w*h*3; i+=3) |
141 | for (i = 0; i < w*h*3; i+=3) |
140 | { |
142 | { |
141 | rr = DSBYTE[i+color_image]; |
143 | rr = DSBYTE[i+color_image]; |
142 | gg = DSBYTE[i+1+color_image]; |
144 | gg = DSBYTE[i+1+color_image]; |
143 | bb = DSBYTE[i+2+color_image]; |
145 | bb = DSBYTE[i+2+color_image]; |
144 | gray = rr*rr; |
146 | gray = rr*rr; |
145 | gray += gg*gg; |
147 | gray += gg*gg; |
146 | gray += bb*bb; |
148 | gray += bb*bb; |
147 | gray = sqrt(gray) / 3; |
149 | gray = sqrt(gray) / 3; |
148 | DSBYTE[i +color_image] = DSBYTE[i+1+color_image] = DSBYTE[i+2+color_image] = gray; |
150 | DSBYTE[i +color_image] = DSBYTE[i+1+color_image] = DSBYTE[i+2+color_image] = gray; |
149 | } |
151 | } |
150 | } |
152 | } |
151 | 153 | ||
152 | :void ShadowImage(dword color_image, w, h, strength) |
154 | :void ShadowImage(dword color_image, w, h, strength) |
153 | { |
155 | { |
154 | dword col, to; |
156 | dword col, to; |
155 | strength = 10 - strength; |
157 | strength = 10 - strength; |
156 | to = w*h*3 + color_image; |
158 | to = w*h*3 + color_image; |
157 | for ( ; color_image < to; color_image++) |
159 | for ( ; color_image < to; color_image++) |
158 | { |
160 | { |
159 | col = strength * DSBYTE[color_image] / 10; |
161 | col = strength * DSBYTE[color_image] / 10; |
160 | DSBYTE[color_image] = col; |
162 | DSBYTE[color_image] = col; |
161 | } |
163 | } |
162 | }>>=100) |
164 | }>>=100) |
163 | >=0)>=0)>>=0)>=0)>=0)>=0)> |
165 | >=0)>=0)>>=0)>=0)>=0)>=0)> |