Rev 5997 | Rev 6191 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
5598 | pavelyakov | 1 | #ifndef INCLUDE_GUI_H |
2 | #define INCLUDE_GUI_H |
||
5676 | pavelyakov | 3 | #print "[include |
3107 | leency | 4 | |
5598 | pavelyakov | 5 | #ifndef INCLUDE_KOLIBRI_H |
6 | #include "../lib/kolibri.h" |
||
7 | #endif |
||
8 | |||
9 | #ifndef INCLUDE_STRING_H |
||
10 | #include "../lib/strings.h" |
||
11 | #endif |
||
12 | |||
6176 | leency | 13 | #ifndef INCLUDE_RGB_H |
14 | #include "../lib/patterns/rgb.h" |
||
15 | #endif |
||
16 | |||
4005 | leency | 17 | :void DrawRectangle(dword x,y,w,h,color1) |
3067 | leency | 18 | { |
3225 | leency | 19 | if (w<=0) || (h<=0) return; |
20 | DrawBar(x,y,w,1,color1); |
||
21 | DrawBar(x,y+h,w,1,color1); |
||
22 | DrawBar(x,y,1,h,color1); |
||
23 | DrawBar(x+w,y,1,h+1,color1); |
||
3067 | leency | 24 | } |
25 | |||
5738 | leency | 26 | :void DrawWideRectangle(dword x,y,w,h,boder,color1) |
27 | { |
||
28 | if (w<=0) || (h<=0) return; |
||
29 | DrawBar(x, y, w, boder, color1); |
||
30 | DrawBar(x, y+h-boder, w, boder, color1); |
||
31 | DrawBar(x, y+boder, boder, h-boder-boder, color1); |
||
32 | DrawBar(x+w-boder, y+boder, boder, h-boder-boder, color1); |
||
33 | } |
||
34 | |||
4005 | leency | 35 | :void DrawRectangle3D(dword x,y,w,h,color1,color2) |
3067 | leency | 36 | { |
3225 | leency | 37 | if (w<=0) || (h<=0) return; |
38 | DrawBar(x,y,w+1,1,color1); |
||
39 | DrawBar(x,y+1,1,h-1,color1); |
||
40 | DrawBar(x+w,y+1,1,h,color2); |
||
41 | DrawBar(x,y+h,w,1,color2); |
||
3067 | leency | 42 | } |
43 | |||
4005 | leency | 44 | :void DrawCaptButton(dword x,y,w,h,id,color_b, color_t,text) |
3067 | leency | 45 | { |
6176 | leency | 46 | word tx = -strlen(text)*6+w/2+x+1; |
47 | word ty = h/2-3+y; |
||
4846 | leency | 48 | if (id>0) DefineButton(x,y,w,h,id,color_b); |
6176 | leency | 49 | WriteText(tx+1,ty+1,0x80,MixColors(color_b,0,200),text); |
50 | WriteText(tx,ty,0x80,color_t,text); |
||
3067 | leency | 51 | } |
52 | |||
4846 | leency | 53 | :void WriteTextCenter(dword x,y,w,color_t,text) |
54 | { |
||
55 | WriteText(-strlen(text)*6+w/2+x+1,y,0x80,color_t,text); |
||
56 | } |
||
57 | |||
5519 | leency | 58 | :void DrawCircle(int x, y, r, color) |
3067 | leency | 59 | { |
60 | int i; |
||
61 | float px=0, py=r, ii = r * 3.1415926 * 2; |
||
62 | FOR (i = 0; i < ii; i++) |
||
63 | { |
||
5519 | leency | 64 | PutPixel(px + x, y - py, color); |
3067 | leency | 65 | px = py / r + px; |
66 | py = -px / r + py; |
||
67 | } |
||
3076 | leency | 68 | } |
3106 | leency | 69 | |
6176 | leency | 70 | :void CheckBox(dword x,y,bt_id, text, is_checked) |
3106 | leency | 71 | { |
6176 | leency | 72 | byte w=14, h=14; |
73 | DefineButton(x-1, y-1, strlen(text)*6 + w + 17, h+2, bt_id+BT_HIDE+BT_NOFRAME, 0); |
||
74 | WriteText(x+w+8, h / 2 + y -3, 0x80, system.color.work_text, text); |
||
75 | DrawRectangle(x, y, w, h, system.color.work_graph); |
||
5477 | leency | 76 | if (is_checked == 0) |
3106 | leency | 77 | { |
5477 | leency | 78 | DrawRectangle3D(x+1, y+1, w-2, h-2, 0xDDDddd, 0xffffff); |
79 | DrawBar(x+2, y+2, w-3, h-3, 0xffffff); |
||
80 | } |
||
81 | else if (is_checked == 1) |
||
82 | { |
||
6176 | leency | 83 | DrawWideRectangle(x+1, y+1, w-1, h-1, 2, 0xffffff); |
84 | DrawBar(x+3, y+3, w-5, h-5, system.color.work_button); //0x13A113 |
||
3106 | leency | 85 | } |
5477 | leency | 86 | else if (is_checked == 2) //not active |
3106 | leency | 87 | { |
6176 | leency | 88 | DrawWideRectangle(x+1, y+1, w-1, h-1, 2, 0xffffff); |
5526 | leency | 89 | DrawBar(x+3, y+3, w-5, h-5, 0x888888); |
5477 | leency | 90 | } |
3114 | leency | 91 | } |
92 | |||
6176 | leency | 93 | :void MoreLessBox(dword x,y, bt_id_more, bt_id_less, value, text) |
5477 | leency | 94 | { |
6176 | leency | 95 | #define VALUE_FIELD_W 26 |
96 | #define SIZE 18 |
||
5542 | leency | 97 | |
6176 | leency | 98 | DrawRectangle(x, y, VALUE_FIELD_W, SIZE, system.color.work_graph); |
99 | DrawRectangle3D(x+1, y+1, VALUE_FIELD_W-2, SIZE-2, 0xDDDddd, 0xffffff); |
||
100 | DrawBar(x+2, y+2, VALUE_FIELD_W-3, SIZE-3, 0xffffff); |
||
101 | WriteText(x+6, SIZE / 2 + y -3, 0x80, 0x000000, itoa(value)); |
||
5477 | leency | 102 | |
6176 | leency | 103 | DrawCaptButton(VALUE_FIELD_W + x + 1, y, SIZE, SIZE, bt_id_more, system.color.work_button, system.color.work_button_text, "+"); |
104 | DrawCaptButton(VALUE_FIELD_W + x + SIZE + 2, y, SIZE, SIZE, bt_id_less, system.color.work_button, system.color.work_button_text, "-"); |
||
105 | WriteText(x+VALUE_FIELD_W+SIZE+SIZE+10, SIZE / 2 + y -3, 0x80, system.color.work_text, text); |
||
5477 | leency | 106 | } |
107 | |||
4686 | leency | 108 | :void DrawProgressBar(dword st_x, st_y, st_w, st_h, col_fon, col_border, col_fill, col_text, progress_percent) |
3114 | leency | 109 | { |
3225 | leency | 110 | int progress_w; |
3114 | leency | 111 | static int fill_old; |
112 | |||
3363 | leency | 113 | //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;} |
114 | if (progress_percent<=0) || (progress_percent>=100) return; |
||
3114 | leency | 115 | |
116 | DrawRectangle(st_x, st_y, st_w,st_h, col_border); |
||
117 | DrawRectangle3D(st_x+1, st_y+1, st_w-2,st_h-2, 0xFFFfff, 0xFFFfff); |
||
3225 | leency | 118 | |
119 | if (progress_percent>0) && (progress_percent<=100) |
||
120 | { |
||
121 | progress_w = st_w - 3 * progress_percent / 100; |
||
122 | DrawBar(st_x+2, st_y+2, progress_w, st_h-3, col_fill); |
||
123 | DrawBar(st_x+2+progress_w, st_y+2, st_w-progress_w-3, st_h-3, 0xFFFfff); |
||
124 | } |
||
3363 | leency | 125 | } |
126 | |||
127 | :void DrawLink(dword x,y,font_type,btn_id, inscription) |
||
128 | { |
||
129 | int w; |
||
130 | WriteText(x,y,font_type,0x4E00E7,inscription); |
||
131 | if (font_type==0x80) w = strlen(inscription)*6; else w = strlen(inscription)*7; |
||
132 | DefineButton(x-1,y-1,w,10,btn_id+BT_HIDE,0); |
||
133 | DrawBar(x,y+8,w,1,0x4E00E7); |
||
134 | } |
||
135 | |||
3991 | leency | 136 | :void PutShadow(dword x,y,w,h,skinned,strength) |
3363 | leency | 137 | { |
138 | proc_info wForm; |
||
139 | dword shadow_buf, skin_height; |
||
140 | shadow_buf = mem_Alloc(w*h*3); |
||
141 | GetProcessInfo(#wForm, SelfInfo); |
||
3991 | leency | 142 | CopyScreen(shadow_buf, 5*skinned+x+wForm.left, GetSkinHeight()*skinned+y+wForm.top, w, h); |
3363 | leency | 143 | ShadowImage(shadow_buf, w, h, strength); |
144 | _PutImage(x,y,w,h,shadow_buf); |
||
145 | mem_Free(shadow_buf); |
||
146 | } |
||
147 | |||
3991 | leency | 148 | :void DrawPopup(dword x,y,w,h,skinned, col_work,col_border) |
149 | { |
||
150 | DrawRectangle(x,y,w,h,col_border); |
||
3992 | leency | 151 | DrawBar(x+1,y+1,w-1,1,0xFFFfff); |
4029 | leency | 152 | DrawBar(x+1,y+2,1,h-2,0xFFFfff); |
3992 | leency | 153 | if (col_work!=-1) DrawBar(x+2,y+2,w-2,h-2,col_work); |
3991 | leency | 154 | DrawPopupShadow(x,y,w,h-1,skinned); |
155 | } |
||
156 | |||
5499 | leency | 157 | :void DrawPopupShadow(dword x,y,w,h,skinned) |
158 | { |
||
159 | PutShadow(w+x+1,y,1,h+2,skinned,2); |
||
160 | PutShadow(w+x+2,y+1,1,h+2,skinned,1); |
||
161 | PutShadow(x,y+h+2,w+2,1,skinned,2); |
||
162 | PutShadow(x+1,y+h+3,w+1,1,skinned,1); |
||
163 | } |
||
164 | |||
3363 | leency | 165 | :void GrayScaleImage(dword color_image, w, h) |
166 | { |
||
5761 | leency | 167 | dword i,gray,to,rr,gg,bb; |
168 | to = w*h*3 + color_image; |
||
169 | for (i = color_image; i < to; i+=3) |
||
3363 | leency | 170 | { |
5761 | leency | 171 | rr = DSBYTE[i]; |
172 | gg = DSBYTE[i+1]; |
||
173 | bb = DSBYTE[i+2]; |
||
3363 | leency | 174 | gray = rr*rr; |
175 | gray += gg*gg; |
||
176 | gray += bb*bb; |
||
177 | gray = sqrt(gray) / 3; |
||
5761 | leency | 178 | DSBYTE[i] = DSBYTE[i+1] = DSBYTE[i+2] = gray; |
3363 | leency | 179 | } |
180 | } |
||
181 | |||
182 | :void ShadowImage(dword color_image, w, h, strength) |
||
183 | { |
||
184 | dword col, to; |
||
185 | strength = 10 - strength; |
||
186 | to = w*h*3 + color_image; |
||
187 | for ( ; color_image < to; color_image++) |
||
188 | { |
||
189 | col = strength * DSBYTE[color_image] / 10; |
||
190 | DSBYTE[color_image] = col; |
||
191 | } |
||
5598 | pavelyakov | 192 | } |
193 | |||
5962 | leency | 194 | :void WriteTextLines(dword x,y,byte fontType, dword color, text_pointer, line_h) |
195 | { |
||
196 | dword next_word_pointer = strchr(text_pointer, '\n'); |
||
197 | if (next_word_pointer) WriteTextLines(dword x, y+line_h, byte fontType, dword color, next_word_pointer+2, line_h); |
||
198 | ESBYTE[next_word_pointer] = NULL; |
||
199 | WriteText(dword x, y, byte fontType, dword color, text_pointer); |
||
200 | ESBYTE[next_word_pointer] = '\n'; |
||
201 | } |
||
202 | |||
5598 | pavelyakov | 203 | #endif>>=100) |