Rev 6931 | Rev 7086 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 6931 | Rev 7031 | ||
---|---|---|---|
1 | #ifndef INCLUDE_GUI_H |
1 | #ifndef INCLUDE_GUI_H |
2 | #define INCLUDE_GUI_H |
2 | #define INCLUDE_GUI_H |
3 | 3 | ||
4 | #ifndef INCLUDE_KOLIBRI_H |
4 | #ifndef INCLUDE_KOLIBRI_H |
5 | #include "../lib/kolibri.h" |
5 | #include "../lib/kolibri.h" |
6 | #endif |
6 | #endif |
7 | 7 | ||
8 | #ifndef INCLUDE_STRING_H |
8 | #ifndef INCLUDE_STRING_H |
9 | #include "../lib/strings.h" |
9 | #include "../lib/strings.h" |
10 | #endif |
10 | #endif |
11 | 11 | ||
12 | #ifndef INCLUDE_RGB_H |
12 | #ifndef INCLUDE_RGB_H |
13 | #include "../lib/patterns/rgb.h" |
13 | #include "../lib/patterns/rgb.h" |
14 | #endif |
14 | #endif |
15 | 15 | ||
16 | :void DrawRectangle(dword x,y,w,h,color1) |
16 | :void DrawRectangle(dword x,y,w,h,color1) |
17 | { |
17 | { |
18 | if (w<=0) || (h<=0) return; |
18 | if (w<=0) || (h<=0) return; |
19 | DrawBar(x,y,w,1,color1); |
19 | DrawBar(x,y,w,1,color1); |
20 | DrawBar(x,y+h,w,1,color1); |
20 | DrawBar(x,y+h,w,1,color1); |
21 | DrawBar(x,y,1,h,color1); |
21 | DrawBar(x,y,1,h,color1); |
22 | DrawBar(x+w,y,1,h+1,color1); |
22 | DrawBar(x+w,y,1,h+1,color1); |
23 | } |
23 | } |
24 | 24 | ||
25 | :void DrawWideRectangle(dword x,y,w,h,boder,color1) |
25 | :void DrawWideRectangle(dword x,y,w,h,boder,color1) |
26 | { |
26 | { |
27 | if (w<=0) || (h<=0) return; |
27 | if (w<=0) || (h<=0) return; |
28 | DrawBar(x, y, w, boder, color1); |
28 | DrawBar(x, y, w, boder, color1); |
29 | DrawBar(x, y+h-boder, w, boder, color1); |
29 | DrawBar(x, y+h-boder, w, boder, color1); |
30 | DrawBar(x, y+boder, boder, h-boder-boder, color1); |
30 | DrawBar(x, y+boder, boder, h-boder-boder, color1); |
31 | DrawBar(x+w-boder, y+boder, boder, h-boder-boder, color1); |
31 | DrawBar(x+w-boder, y+boder, boder, h-boder-boder, color1); |
32 | } |
32 | } |
33 | 33 | ||
34 | :void DrawRectangle3D(dword x,y,w,h,color1,color2) |
34 | :void DrawRectangle3D(dword x,y,w,h,color1,color2) |
35 | { |
35 | { |
36 | if (w<=0) || (h<=0) return; |
36 | if (w<=0) || (h<=0) return; |
37 | DrawBar(x,y,w+1,1,color1); |
37 | DrawBar(x,y,w+1,1,color1); |
38 | DrawBar(x,y+1,1,h-1,color1); |
38 | DrawBar(x,y+1,1,h-1,color1); |
39 | DrawBar(x+w,y+1,1,h,color2); |
39 | DrawBar(x+w,y+1,1,h,color2); |
40 | DrawBar(x,y+h,w,1,color2); |
40 | DrawBar(x,y+h,w,1,color2); |
41 | } |
41 | } |
42 | 42 | ||
43 | :void DrawCaptButton(dword x,y,w,h,id,color_b, color_t,text) |
43 | :void DrawCaptButton(dword x,y,w,h,id,color_b, color_t,text) |
44 | { |
44 | { |
45 | dword tx = -strlen(text)*8+w/2+x; |
45 | dword tx = -strlen(text)*8+w/2+x; |
46 | dword ty = h/2-7+y; |
46 | dword ty = h/2-7+y; |
47 | 47 | ||
48 | if (id>0) DefineButton(x,y,w,h,id,color_b); |
48 | if (id>0) DefineButton(x,y,w,h,id,color_b); |
49 | WriteText(tx+1,ty+1,0x90,MixColors(color_b,0,230),text); |
49 | WriteText(tx+1,ty+1,0x90,MixColors(color_b,0,230),text); |
50 | WriteText(tx,ty,0x90,color_t,text); |
50 | WriteText(tx,ty,0x90,color_t,text); |
51 | } |
51 | } |
- | 52 | ||
52 | 53 | :int active_button_id = 0; |
|
53 | :int DrawStandartCaptButton(dword x, y, id, text) |
54 | :int DrawStandartCaptButton(dword x, y, id, text) |
54 | { |
55 | { |
55 | int padding_v = 5; |
56 | int padding_v = 5; |
56 | int padding_h = 15; |
57 | int padding_h = 15; |
57 | int right_margin = 12; |
58 | int right_margin = 12; |
58 | int tx = x + padding_h; |
59 | int tx = x + padding_h; |
59 | int ty = y + padding_v+1; |
60 | int ty = y + padding_v+1; |
- | 61 | int tw = strlen(text)*8; |
|
60 | int h = padding_v + padding_v + 16; //16 font height |
62 | int h = padding_v + padding_v + 16; //16 font height |
61 | int w = strlen(text)*8 + padding_h + padding_h; |
63 | int w = tw + padding_h + padding_h; |
- | 64 | ||
62 | 65 | ||
- | 66 | if (id>0) DefineButton(x,y,w,h,id,system.color.work_button); |
|
63 | if (id>0) DefineButton(x,y,w,h,id,system.color.work_button); |
67 | |
64 | WriteText(tx+1,ty+1,0x90,MixColors(system.color.work_button,0,230),text); |
68 | WriteText(tx+1,ty+1,0x90,MixColors(system.color.work_button,0,230),text); |
- | 69 | WriteText(tx,ty,0x90,system.color.work_button_text,text); |
|
- | 70 | ||
- | 71 | if (active_button_id==id) { |
|
- | 72 | DrawBar(tx,ty+15,tw,1, MixColors(system.color.work_button,0,230)); |
|
- | 73 | DrawBar(tx,ty+14,tw,1, system.color.work_button_text); |
|
- | 74 | } |
|
65 | WriteText(tx,ty,0x90,system.color.work_button_text,text); |
75 | |
66 | return w + right_margin; |
76 | return w + right_margin; |
67 | } |
77 | } |
- | 78 | ||
- | 79 | :void ActiveButtonSwitch(int min, max) |
|
- | 80 | { |
|
- | 81 | active_button_id++; |
|
- | 82 | if (active_button_id>max) || (active_button_id |
|
- | 83 | } |
|
68 | 84 | ||
69 | :void WriteTextCenter(dword x,y,w,color_t,text) |
85 | :void WriteTextCenter(dword x,y,w,color_t,text) |
70 | { |
86 | { |
71 | WriteText(-strlen(text)*6+w/2+x+1,y,0x80,color_t,text); |
87 | WriteText(-strlen(text)*6+w/2+x+1,y,0x80,color_t,text); |
72 | } |
88 | } |
73 | 89 | ||
74 | :void DrawCircle(int x, y, r, color) |
90 | :void DrawCircle(int x, y, r, color) |
75 | { |
91 | { |
76 | int i; |
92 | int i; |
77 | float px=0, py=r, ii = r * 3.1415926 * 2; |
93 | float px=0, py=r, ii = r * 3.1415926 * 2; |
78 | FOR (i = 0; i < ii; i++) |
94 | FOR (i = 0; i < ii; i++) |
79 | { |
95 | { |
80 | PutPixel(px + x, y - py, color); |
96 | PutPixel(px + x, y - py, color); |
81 | px = py / r + px; |
97 | px = py / r + px; |
82 | py = -px / r + py; |
98 | py = -px / r + py; |
83 | } |
99 | } |
84 | } |
100 | } |
85 | 101 | ||
86 | :unsigned char checkbox_flag[507] = { |
102 | :unsigned char checkbox_flag[507] = { |
87 | 0xFC, 0xD4, 0x04, 0xFC, 0xD4, 0x04, 0xFC, 0xD4, 0x04, 0xFC, 0xD4, 0x04, 0xFC, 0xD4, 0x04, 0xFC, |
103 | 0xFC, 0xD4, 0x04, 0xFC, 0xD4, 0x04, 0xFC, 0xD4, 0x04, 0xFC, 0xD4, 0x04, 0xFC, 0xD4, 0x04, 0xFC, |
88 | 0xD4, 0x04, 0xFC, 0xD4, 0x04, 0xFC, 0xD4, 0x04, 0xFC, 0xD4, 0x04, 0xFC, 0xD4, 0x04, 0xFC, 0xD4, |
104 | 0xD4, 0x04, 0xFC, 0xD4, 0x04, 0xFC, 0xD4, 0x04, 0xFC, 0xD4, 0x04, 0xFC, 0xD4, 0x04, 0xFC, 0xD4, |
89 | 0x04, 0xFC, 0xD4, 0x04, 0xFC, 0xC8, 0x04, 0xFC, 0xDC, 0x04, 0xFC, 0xC8, 0x04, 0xFC, 0xC8, 0x04, |
105 | 0x04, 0xFC, 0xD4, 0x04, 0xFC, 0xC8, 0x04, 0xFC, 0xDC, 0x04, 0xFC, 0xC8, 0x04, 0xFC, 0xC8, 0x04, |
90 | 0xFC, 0xC8, 0x04, 0xFC, 0xC8, 0x04, 0xFC, 0xC8, 0x04, 0xFC, 0xC8, 0x04, 0xFC, 0xC8, 0x04, 0xFC, |
106 | 0xFC, 0xC8, 0x04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x98, 0x04, 0xBC, 0x64, 0x04, 0xBC, 0x64, 0x04, 0xF9, 0x98, 0x04, 0xFA, 0x9F, 0x04, 0xFC, 0xA9, |
128 | 0x98, 0x04, 0xBC, 0x64, 0x04, 0xBC, 0x64, 0x04, 0xF9, 0x98, 0x04, 0xFA, 0x9F, 0x04, 0xFC, 0xA9, |
113 | 0x04, 0xFC, 0xA9, 0x04, 0xFC, 0xA9, 0x04, 0xFA, 0x9F, 0x04, 0xFA, 0x9F, 0x04, 0xFC, 0xC8, 0x04, |
129 | 0x04, 0xFC, 0xA9, 0x04, 0xFC, 0xA9, 0x04, 0xFA, 0x9F, 0x04, 0xFA, 0x9F, 0x04, 0xFC, 0xC8, 0x04, |
114 | 0xFC, 0xA9, 0x04, 0xFC, 0xA9, 0x04, 0xFA, 0x9F, 0x04, 0xF9, 0x98, 0x04, 0xF9, 0x98, 0x04, 0xFA, |
130 | 0xFC, 0xA9, 0x04, 0xFC, 0xA9, 0x04, 0xFA, 0x9F, 0x04, 0xF9, 0x98, 0x04, 0xF9, 0x98, 0x04, 0xFA, |
115 | 0x9F, 0x04, 0xFC, 0xA9, 0x04, 0xFC, 0xA9, 0x04, 0xFC, 0xA9, 0x04, 0xFA, 0x9F, 0x04, 0xFA, 0x9F, |
131 | 0x9F, 0x04, 0xFC, 0xA9, 0x04, 0xFC, 0xA9, 0x04, 0xFC, 0xA9, 0x04, 0xFA, 0x9F, 0x04, 0xFA, 0x9F, |
116 | 0x04, 0xF9, 0x98, 0x04, 0xFC, 0xB4, 0x04, 0xF9, 0x98, 0x04, 0xF9, 0x98, 0x04, 0xF9, 0x98, 0x04, |
132 | 0x04, 0xF9, 0x98, 0x04, 0xFC, 0xB4, 0x04, 0xF9, 0x98, 0x04, 0xF9, 0x98, 0x04, 0xF9, 0x98, 0x04, |
117 | 0xF9, 0x98, 0x04, 0xF9, 0x98, 0x04, 0xF9, 0x98, 0x04, 0xF9, 0x98, 0x04, 0xF9, 0x98, 0x04, 0xF9, |
133 | 0xF9, 0x98, 0x04, 0xF9, 0x98, 0x04, 0xF9, 0x98, 0x04, 0xF9, 0x98, 0x04, 0xF9, 0x98, 0x04, 0xF9, |
118 | 0x98, 0x04, 0xF9, 0x98, 0x04, 0xF9, 0x98, 0x04, 0xF9, 0x98, 0x04 |
134 | 0x98, 0x04, 0xF9, 0x98, 0x04, 0xF9, 0x98, 0x04, 0xF9, 0x98, 0x04 |
119 | }; |
135 | }; |
120 | 136 | ||
121 | :void CheckBox(dword x,y,bt_id, text, is_checked) |
137 | :void CheckBox(dword x,y,bt_id, text, is_checked) |
122 | { |
138 | { |
123 | byte w=14, h=14; |
139 | byte w=14, h=14; |
124 | DefineButton(x-1, y-1, strlen(text)*8 + w + 17, h+2, bt_id+BT_HIDE+BT_NOFRAME, 0); |
140 | DefineButton(x-1, y-1, strlen(text)*8 + w + 17, h+2, bt_id+BT_HIDE+BT_NOFRAME, 0); |
125 | EDI = system.color.work; |
141 | EDI = system.color.work; |
126 | WriteText(x+w+8, h / 2 + y -7, 0xD0, system.color.work_text, text); |
142 | WriteText(x+w+8, h / 2 + y -7, 0xD0, system.color.work_text, text); |
127 | DrawRectangle(x, y, w, h, system.color.work_graph); |
143 | DrawRectangle(x, y, w, h, system.color.work_graph); |
128 | if (is_checked == 0) |
144 | if (is_checked == 0) |
129 | { |
145 | { |
130 | DrawRectangle3D(x+1, y+1, w-2, h-2, 0xDDDddd, 0xffffff); |
146 | DrawRectangle3D(x+1, y+1, w-2, h-2, 0xDDDddd, 0xffffff); |
131 | DrawBar(x+2, y+2, w-3, h-3, 0xffffff); |
147 | DrawBar(x+2, y+2, w-3, h-3, 0xffffff); |
132 | } |
148 | } |
133 | else if (is_checked == 1) |
149 | else if (is_checked == 1) |
134 | { |
150 | { |
135 | DrawWideRectangle(x+1, y+1, w-1, h-1, 2, 0xffffff); |
151 | DrawWideRectangle(x+1, y+1, w-1, h-1, 2, 0xffffff); |
136 | _PutImage(x+1, y+1, 13, 13, #checkbox_flag); |
152 | _PutImage(x+1, y+1, 13, 13, #checkbox_flag); |
137 | } |
153 | } |
138 | else if (is_checked == 2) //not active |
154 | else if (is_checked == 2) //not active |
139 | { |
155 | { |
140 | DrawWideRectangle(x+1, y+1, w-1, h-1, 2, 0xffffff); |
156 | DrawWideRectangle(x+1, y+1, w-1, h-1, 2, 0xffffff); |
141 | DrawBar(x+3, y+3, w-5, h-5, 0x888888); |
157 | DrawBar(x+3, y+3, w-5, h-5, 0x888888); |
142 | } |
158 | } |
143 | DrawRectangle3D(x-1,y-1,w+2,h+2,system.color.work_dark,system.color.work_light); |
159 | DrawRectangle3D(x-1,y-1,w+2,h+2,system.color.work_dark,system.color.work_light); |
144 | } |
160 | } |
145 | 161 | ||
146 | :void MoreLessBox(dword x,y, bt_id_more, bt_id_less, value, text) |
162 | :void MoreLessBox(dword x,y, bt_id_more, bt_id_less, value, text) |
147 | { |
163 | { |
148 | #define VALUE_FIELD_W 34 |
164 | #define VALUE_FIELD_W 34 |
149 | #define SIZE 18 |
165 | #define SIZE 18 |
150 | dword value_text = itoa(value); |
166 | dword value_text = itoa(value); |
151 | 167 | ||
152 | DrawRectangle(x, y, VALUE_FIELD_W+1, SIZE, system.color.work_graph); |
168 | DrawRectangle(x, y, VALUE_FIELD_W+1, SIZE, system.color.work_graph); |
153 | DrawRectangle3D(x+1, y+1, VALUE_FIELD_W-2, SIZE-2, 0xDDDddd, 0xffffff); |
169 | DrawRectangle3D(x+1, y+1, VALUE_FIELD_W-2, SIZE-2, 0xDDDddd, 0xffffff); |
154 | DrawBar(x+2, y+2, VALUE_FIELD_W-3, SIZE-3, 0xffffff); |
170 | DrawBar(x+2, y+2, VALUE_FIELD_W-3, SIZE-3, 0xffffff); |
155 | WriteText( -strlen(value_text)+3*8 + x+6, SIZE / 2 + y -6, 0x90, 0x333333, value_text); |
171 | WriteText( -strlen(value_text)+3*8 + x+6, SIZE / 2 + y -6, 0x90, 0x333333, value_text); |
156 | 172 | ||
157 | DrawCaptButton(VALUE_FIELD_W + x + 1, y, SIZE, SIZE, bt_id_more, system.color.work_button, system.color.work_button_text, "+"); |
173 | DrawCaptButton(VALUE_FIELD_W + x + 1, y, SIZE, SIZE, bt_id_more, system.color.work_button, system.color.work_button_text, "+"); |
158 | DrawCaptButton(VALUE_FIELD_W + x + SIZE, y, SIZE, SIZE, bt_id_less, system.color.work_button, system.color.work_button_text, "-"); |
174 | DrawCaptButton(VALUE_FIELD_W + x + SIZE, y, SIZE, SIZE, bt_id_less, system.color.work_button, system.color.work_button_text, "-"); |
159 | EDI = system.color.work; |
175 | EDI = system.color.work; |
160 | WriteText(x+VALUE_FIELD_W+SIZE+SIZE+10, SIZE / 2 + y -7, 0xD0, system.color.work_text, text); |
176 | WriteText(x+VALUE_FIELD_W+SIZE+SIZE+10, SIZE / 2 + y -7, 0xD0, system.color.work_text, text); |
161 | DrawRectangle3D(x-1,y-1,VALUE_FIELD_W+SIZE+SIZE+2,SIZE+2,system.color.work_dark,system.color.work_light); |
177 | DrawRectangle3D(x-1,y-1,VALUE_FIELD_W+SIZE+SIZE+2,SIZE+2,system.color.work_dark,system.color.work_light); |
162 | } |
178 | } |
163 | 179 | ||
164 | :void DrawEditBox(dword edit_box_pointer) |
180 | :void DrawEditBox(dword edit_box_pointer) |
165 | { |
181 | { |
166 | dword x,y,w,h,bg; |
182 | dword x,y,w,h,bg; |
167 | ESI = edit_box_pointer; |
183 | ESI = edit_box_pointer; |
168 | x = ESI.edit_box.left; |
184 | x = ESI.edit_box.left; |
169 | y = ESI.edit_box.top; |
185 | y = ESI.edit_box.top; |
170 | w = ESI.edit_box.width+1; |
186 | w = ESI.edit_box.width+1; |
171 | if (ESI.edit_box.flags & 100000000000b) bg = 0xCACACA; else bg = 0xFFFfff; |
187 | if (ESI.edit_box.flags & 100000000000b) bg = 0xCACACA; else bg = 0xFFFfff; |
172 | edit_box_draw stdcall (edit_box_pointer); |
188 | edit_box_draw stdcall (edit_box_pointer); |
173 | h = 22; |
189 | h = 22; |
174 | DrawRectangle(x-1, y-1, w+1, h+1, bg); |
190 | DrawRectangle(x-1, y-1, w+1, h+1, bg); |
175 | DrawRectangle3D(x-2, y-2, w+3, h+3, 0xDDDddd, bg); |
191 | DrawRectangle3D(x-2, y-2, w+3, h+3, 0xDDDddd, bg); |
176 | DrawRectangle(x-3, y-3, w+5, h+5, system.color.work_graph); |
192 | DrawRectangle(x-3, y-3, w+5, h+5, system.color.work_graph); |
177 | DrawRectangle3D(x-4, y-4, w+7, h+7, system.color.work_dark, system.color.work_light); |
193 | DrawRectangle3D(x-4, y-4, w+7, h+7, system.color.work_dark, system.color.work_light); |
178 | } |
194 | } |
179 | 195 | ||
180 | :void DrawProgressBar(dword st_x, st_y, st_w, st_h, col_fon, col_border, col_fill, col_text, progress_percent) |
196 | :void DrawProgressBar(dword st_x, st_y, st_w, st_h, col_fon, col_border, col_fill, col_text, progress_percent) |
181 | { |
197 | { |
182 | int progress_w; |
198 | int progress_w; |
183 | static int fill_old; |
199 | static int fill_old; |
184 | 200 | ||
185 | //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;} |
201 | //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;} |
186 | if (progress_percent<=0) || (progress_percent>=100) return; |
202 | if (progress_percent<=0) || (progress_percent>=100) return; |
187 | 203 | ||
188 | DrawRectangle(st_x, st_y, st_w,st_h, col_border); |
204 | DrawRectangle(st_x, st_y, st_w,st_h, col_border); |
189 | DrawRectangle3D(st_x+1, st_y+1, st_w-2,st_h-2, 0xFFFfff, 0xFFFfff); |
205 | DrawRectangle3D(st_x+1, st_y+1, st_w-2,st_h-2, 0xFFFfff, 0xFFFfff); |
190 | 206 | ||
191 | if (progress_percent>0) && (progress_percent<=100) |
207 | if (progress_percent>0) && (progress_percent<=100) |
192 | { |
208 | { |
193 | progress_w = st_w - 3 * progress_percent / 100; |
209 | progress_w = st_w - 3 * progress_percent / 100; |
194 | DrawBar(st_x+2, st_y+2, progress_w, st_h-3, col_fill); |
210 | DrawBar(st_x+2, st_y+2, progress_w, st_h-3, col_fill); |
195 | DrawBar(st_x+2+progress_w, st_y+2, st_w-progress_w-3, st_h-3, 0xFFFfff); |
211 | DrawBar(st_x+2+progress_w, st_y+2, st_w-progress_w-3, st_h-3, 0xFFFfff); |
196 | } |
212 | } |
197 | } |
213 | } |
198 | 214 | ||
199 | :void DrawLink(dword x,y,font_type,btn_id, inscription) |
215 | :void DrawLink(dword x,y,font_type,btn_id, inscription) |
200 | { |
216 | { |
201 | int w; |
217 | int w; |
202 | WriteText(x,y,font_type,0x4E00E7,inscription); |
218 | WriteText(x,y,font_type,0x4E00E7,inscription); |
203 | if (font_type==0x80) w = strlen(inscription)*6; else w = strlen(inscription)*7; |
219 | if (font_type==0x80) w = strlen(inscription)*6; else w = strlen(inscription)*8; |
204 | DefineButton(x-1,y-1,w,10,btn_id+BT_HIDE,0); |
220 | DefineButton(x-1,y-1,w,10,btn_id+BT_HIDE,0); |
205 | DrawBar(x,y+8,w,1,0x4E00E7); |
221 | DrawBar(x,y+8,w,1,0x4E00E7); |
206 | } |
222 | } |
207 | 223 | ||
208 | :void PutShadow(dword x,y,w,h,skinned,strength) |
224 | :void PutShadow(dword x,y,w,h,skinned,strength) |
209 | { |
225 | { |
210 | proc_info wForm; |
226 | proc_info wForm; |
211 | dword shadow_buf, skin_height; |
227 | dword shadow_buf, skin_height; |
212 | shadow_buf = mem_Alloc(w*h*3); |
228 | shadow_buf = mem_Alloc(w*h*3); |
213 | GetProcessInfo(#wForm, SelfInfo); |
229 | GetProcessInfo(#wForm, SelfInfo); |
214 | CopyScreen(shadow_buf, 5*skinned+x+wForm.left, GetSkinHeight()*skinned+y+wForm.top, w, h); |
230 | CopyScreen(shadow_buf, 5*skinned+x+wForm.left, GetSkinHeight()*skinned+y+wForm.top, w, h); |
215 | ShadowImage(shadow_buf, w, h, strength); |
231 | ShadowImage(shadow_buf, w, h, strength); |
216 | _PutImage(x,y,w,h,shadow_buf); |
232 | _PutImage(x,y,w,h,shadow_buf); |
217 | mem_Free(shadow_buf); |
233 | mem_Free(shadow_buf); |
218 | } |
234 | } |
219 | 235 | ||
220 | :void DrawPopup(dword x,y,w,h,skinned, col_work,col_border) |
236 | :void DrawPopup(dword x,y,w,h,skinned, col_work,col_border) |
221 | { |
237 | { |
222 | DrawRectangle(x,y,w,h,col_border); |
238 | DrawRectangle(x,y,w,h,col_border); |
223 | DrawBar(x+1,y+1,w-1,1,0xFFFfff); |
239 | DrawBar(x+1,y+1,w-1,1,0xFFFfff); |
224 | DrawBar(x+1,y+2,1,h-2,0xFFFfff); |
240 | DrawBar(x+1,y+2,1,h-2,0xFFFfff); |
225 | if (col_work!=-1) DrawBar(x+2,y+2,w-2,h-2,col_work); |
241 | if (col_work!=-1) DrawBar(x+2,y+2,w-2,h-2,col_work); |
226 | DrawPopupShadow(x,y,w,h-1,skinned); |
242 | DrawPopupShadow(x,y,w,h-1,skinned); |
227 | } |
243 | } |
228 | 244 | ||
229 | :void DrawPopupShadow(dword x,y,w,h,skinned) |
245 | :void DrawPopupShadow(dword x,y,w,h,skinned) |
230 | { |
246 | { |
231 | PutShadow(w+x+1,y,1,h+2,skinned,2); |
247 | PutShadow(w+x+1,y,1,h+2,skinned,2); |
232 | PutShadow(w+x+2,y+1,1,h+2,skinned,1); |
248 | PutShadow(w+x+2,y+1,1,h+2,skinned,1); |
233 | PutShadow(x,y+h+2,w+2,1,skinned,2); |
249 | PutShadow(x,y+h+2,w+2,1,skinned,2); |
234 | PutShadow(x+1,y+h+3,w+1,1,skinned,1); |
250 | PutShadow(x+1,y+h+3,w+1,1,skinned,1); |
235 | } |
251 | } |
236 | 252 | ||
237 | :void GrayScaleImage(dword color_image, w, h) |
253 | :void GrayScaleImage(dword color_image, w, h) |
238 | { |
254 | { |
239 | dword i,gray,to,rr,gg,bb; |
255 | dword i,gray,to,rr,gg,bb; |
240 | to = w*h*3 + color_image; |
256 | to = w*h*3 + color_image; |
241 | for (i = color_image; i < to; i+=3) |
257 | for (i = color_image; i < to; i+=3) |
242 | { |
258 | { |
243 | rr = DSBYTE[i]; |
259 | rr = DSBYTE[i]; |
244 | gg = DSBYTE[i+1]; |
260 | gg = DSBYTE[i+1]; |
245 | bb = DSBYTE[i+2]; |
261 | bb = DSBYTE[i+2]; |
246 | gray = rr*rr; |
262 | gray = rr*rr; |
247 | gray += gg*gg; |
263 | gray += gg*gg; |
248 | gray += bb*bb; |
264 | gray += bb*bb; |
249 | gray = sqrt(gray) / 3; |
265 | gray = sqrt(gray) / 3; |
250 | DSBYTE[i] = DSBYTE[i+1] = DSBYTE[i+2] = gray; |
266 | DSBYTE[i] = DSBYTE[i+1] = DSBYTE[i+2] = gray; |
251 | } |
267 | } |
252 | } |
268 | } |
253 | 269 | ||
254 | :void ShadowImage(dword color_image, w, h, strength) |
270 | :void ShadowImage(dword color_image, w, h, strength) |
255 | { |
271 | { |
256 | dword col, to; |
272 | dword col, to; |
257 | strength = 10 - strength; |
273 | strength = 10 - strength; |
258 | to = w*h*3 + color_image; |
274 | to = w*h*3 + color_image; |
259 | for ( ; color_image < to; color_image++) |
275 | for ( ; color_image < to; color_image++) |
260 | { |
276 | { |
261 | col = strength * DSBYTE[color_image] / 10; |
277 | col = strength * DSBYTE[color_image] / 10; |
262 | DSBYTE[color_image] = col; |
278 | DSBYTE[color_image] = col; |
263 | } |
279 | } |
264 | } |
280 | } |
265 | 281 | ||
266 | :void WriteTextLines(dword x,y,byte fontType, dword color, text_pointer, line_h) |
282 | :void WriteTextLines(dword x,y,byte fontType, dword color, text_pointer, line_h) |
267 | { |
283 | { |
268 | dword next_word_pointer = strchr(text_pointer, '\n'); |
284 | dword next_word_pointer = strchr(text_pointer, '\n'); |
269 | if (next_word_pointer) WriteTextLines(dword x, y+line_h, byte fontType, dword color, next_word_pointer+2, line_h); |
285 | if (next_word_pointer) WriteTextLines(dword x, y+line_h, byte fontType, dword color, next_word_pointer+2, line_h); |
270 | ESBYTE[next_word_pointer] = NULL; |
286 | ESBYTE[next_word_pointer] = NULL; |
271 | WriteText(dword x, y, byte fontType, dword color, text_pointer); |
287 | WriteText(dword x, y, byte fontType, dword color, text_pointer); |
272 | ESBYTE[next_word_pointer] = '\n'; |
288 | ESBYTE[next_word_pointer] = '\n'; |
273 | } |
289 | } |
274 | 290 | ||
275 | /* |
291 | /* |
276 | We have a long text and need to show it in block. |
292 | We have a long text and need to show it in block. |
277 | Normal line break '\n' must be applied. |
293 | Normal line break '\n' must be applied. |
278 | Long lines should be breaked by word. |
294 | Long lines should be breaked by word. |
279 | TODO: scroll |
295 | TODO: scroll |
280 | */ |
296 | */ |
281 | :int DrawTextViewArea(int x,y,w,h, dword buf_start, bg_col, text_col) |
297 | :int DrawTextViewArea(int x,y,w,h, dword buf_start, bg_col, text_col) |
282 | { |
298 | { |
283 | dword write_start; |
299 | dword write_start; |
284 | dword buf_end; |
300 | dword buf_end; |
285 | int line_h = 15; |
301 | int line_h = 15; |
286 | int label_length_max; |
302 | int label_length_max; |
287 | int write_length; |
303 | int write_length; |
288 | bool end_found; |
304 | bool end_found; |
289 | 305 | ||
290 | write_start = buf_start; |
306 | write_start = buf_start; |
291 | buf_end = strlen(buf_start) + buf_start; |
307 | buf_end = strlen(buf_start) + buf_start; |
292 | label_length_max = w / 8; // 8 big font char width |
308 | label_length_max = w / 8; // 8 big font char width |
293 | 309 | ||
294 | loop() |
310 | loop() |
295 | { |
311 | { |
296 | if (bg_col!=-1) DrawBar(x, y, w+1, line_h, bg_col); |
312 | if (bg_col!=-1) DrawBar(x, y, w+1, line_h, bg_col); |
297 | end_found = false; |
313 | end_found = false; |
298 | write_length = strchr(write_start, '\n') - write_start; //search normal line break |
314 | write_length = strchr(write_start, '\n') - write_start; //search normal line break |
299 | if (write_length > label_length_max) || (write_length<=0) //check its position: exceeds maximum line length or not found |
315 | if (write_length > label_length_max) || (write_length<=0) //check its position: exceeds maximum line length or not found |
300 | { |
316 | { |
301 | if (buf_end - write_start < label_length_max) //check does current line the last |
317 | if (buf_end - write_start < label_length_max) //check does current line the last |
302 | { |
318 | { |
303 | write_length = buf_end - write_start; |
319 | write_length = buf_end - write_start; |
304 | end_found = true; |
320 | end_found = true; |
305 | } |
321 | } |
306 | else |
322 | else |
307 | { |
323 | { |
308 | for (write_length=label_length_max; write_length>0; write_length--) { //search for white space to make the line break |
324 | for (write_length=label_length_max; write_length>0; write_length--) { //search for white space to make the line break |
309 | if (ESBYTE[write_start+write_length] == ' ') { |
325 | if (ESBYTE[write_start+write_length] == ' ') { |
310 | end_found = true; |
326 | end_found = true; |
311 | break; |
327 | break; |
312 | } |
328 | } |
313 | } |
329 | } |
314 | } |
330 | } |
315 | if (end_found != true) write_length = label_length_max; //no white space, so we write label_length_max |
331 | if (end_found != true) write_length = label_length_max; //no white space, so we write label_length_max |
316 | } |
332 | } |
317 | ESI = write_length; //set text length attribute for WriteText() |
333 | ESI = write_length; //set text length attribute for WriteText() |
318 | WriteText(x, y, 0x10, text_col, write_start); |
334 | WriteText(x, y, 0x10, text_col, write_start); |
319 | // if (editpos >= write_start-buf_start) && (editpos <= write_start-buf_start + write_length) { |
335 | // if (editpos >= write_start-buf_start) && (editpos <= write_start-buf_start + write_length) { |
320 | // WriteTextB(-write_start+buf_start+editpos * 8 + x - 5 +1, y, 0x90, 0xFF0000, "|"); |
336 | // WriteTextB(-write_start+buf_start+editpos * 8 + x - 5 +1, y, 0x90, 0xFF0000, "|"); |
321 | // } |
337 | // } |
322 | write_start += write_length + 1; |
338 | write_start += write_length + 1; |
323 | y += line_h; |
339 | y += line_h; |
324 | if (write_start >= buf_end) break; |
340 | if (write_start >= buf_end) break; |
325 | } |
341 | } |
326 | if (bg_col!=-1) DrawBar(x,y,w+1,h-y+line_h-4,bg_col); |
342 | if (bg_col!=-1) DrawBar(x,y,w+1,h-y+line_h-4,bg_col); |
327 | return y+line_h; |
343 | return y+line_h; |
328 | } |
344 | } |
329 | 345 | ||
330 | 346 | ||
331 | //this function increase falue and return it |
347 | //this function increase falue and return it |
332 | //useful for list of controls which goes one after one |
348 | //useful for list of controls which goes one after one |
333 | struct incn |
349 | struct incn |
334 | { |
350 | { |
335 | dword n; |
351 | dword n; |
336 | dword inc(dword _addition); |
352 | dword inc(dword _addition); |
337 | }; |
353 | }; |
338 | 354 | ||
339 | dword incn::inc(dword _addition) |
355 | dword incn::inc(dword _addition) |
340 | { |
356 | { |
341 | n+=_addition; |
357 | n+=_addition; |
342 | return n; |
358 | return n; |
343 | } |
359 | } |
344 | 360 | ||
345 | 361 | ||
346 | /*========================================================= |
362 | /*========================================================= |
347 | == |
363 | == |
348 | == TABS |
364 | == TABS |
349 | == |
365 | == |
350 | /========================================================*/ |
366 | /========================================================*/ |
351 | 367 | ||
352 | #define TAB_PADDING 25 |
368 | #define TAB_PADDING 25 |
353 | #define TAB_HEIGHT 25 |
369 | #define TAB_HEIGHT 25 |
354 | 370 | ||
355 | :struct _tabs |
371 | :struct _tabs |
356 | { |
372 | { |
357 | int active_tab; |
373 | int active_tab; |
358 | void draw(); |
374 | void draw(); |
359 | int click(); |
375 | int click(); |
360 | } tabs; |
376 | } tabs; |
361 | 377 | ||
362 | :void _tabs::draw(dword x,y, but_id, text) |
378 | :void _tabs::draw(dword x,y, but_id, text) |
363 | { |
379 | { |
364 | dword col_bg, col_text; |
380 | dword col_bg, col_text; |
365 | dword w=strlen(text)*8+TAB_PADDING, h=TAB_HEIGHT; |
381 | dword w=strlen(text)*8+TAB_PADDING, h=TAB_HEIGHT; |
366 | y -= h; |
382 | y -= h; |
367 | 383 | ||
368 | if (but_id==active_tab) |
384 | if (but_id==active_tab) |
369 | { |
385 | { |
370 | col_bg=system.color.work_button; |
386 | col_bg=system.color.work_button; |
371 | col_text=system.color.work_button_text; |
387 | col_text=system.color.work_button_text; |
372 | } |
388 | } |
373 | else |
389 | else |
374 | { |
390 | { |
375 | col_bg=system.color.work; |
391 | col_bg=system.color.work; |
376 | col_text=system.color.work_text; |
392 | col_text=system.color.work_text; |
377 | } |
393 | } |
378 | DrawCaptButton(x,y, w-1,h+1, but_id, col_bg, col_text, text); |
394 | DrawCaptButton(x,y, w-1,h+1, but_id, col_bg, col_text, text); |
379 | } |
395 | } |
380 | 396 | ||
381 | :int _tabs::click(int N) |
397 | :int _tabs::click(int N) |
382 | { |
398 | { |
383 | if (N==active_tab) return false; |
399 | if (N==active_tab) return false; |
384 | active_tab = N; |
400 | active_tab = N; |
385 | return true; |
401 | return true; |
386 | } |
402 | } |
387 | 403 | ||
388 | 404 | ||
389 | 405 | ||
390 | #endif=>>=0)>>>=100) |
406 | #endif=>>=0)>>>=100) |
391 | >=0)>=0)>>=0)>=0)>=0)>=0)>=0)>=0)> |
407 | >=0)>=0)>>=0)>=0)>=0)>=0)>=0)>=0)> |