Rev 5372 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4438 | Serge | 1 | |
2 | #include |
||
3 | #include |
||
4 | #include |
||
5 | #include "winlib.h" |
||
6 | |||
7 | |||
8 | extern int res_slider[]; |
||
9 | extern int res_vol_slider[]; |
||
10 | extern int res_progress_bar[]; |
||
11 | extern int res_prg_level[]; |
||
12 | |||
13 | |||
14 | uint32_t main_cursor; |
||
15 | |||
16 | |||
17 | static int spinbtn_proc(ctrl_t *btn, uint32_t msg, uint32_t arg1, uint32_t arg2); |
||
18 | void panel_set_layout(ctrl_t *panel, int layout); |
||
6144 | serge | 19 | |
4438 | Serge | 20 | |
21 | int w, int h, ctrl_t *parent) |
||
22 | { |
||
23 | ctrl_t *ctrl; |
||
24 | |||
25 | |||
26 | return NULL; |
||
27 | |||
28 | |||
29 | |||
30 | |||
31 | list_initialize(&ctrl->child); |
||
32 | |||
33 | |||
34 | |||
35 | |||
36 | ctrl->id = id; |
||
37 | |||
38 | |||
39 | ctrl->rc.t = y ; |
||
40 | |||
41 | |||
42 | ctrl->rc.b = y + h; |
||
43 | |||
44 | |||
45 | ctrl->h = h; |
||
46 | |||
47 | |||
48 | |||
49 | |||
50 | }; |
||
51 | |||
52 | |||
53 | |||
54 | int w, int h, ctrl_t *parent) |
||
55 | { |
||
56 | button_t *btn; |
||
57 | int len; |
||
58 | |||
59 | |||
60 | return NULL; |
||
61 | |||
62 | |||
63 | btn->ctrl.handler = button_proc; |
||
64 | btn->state = 0; |
||
65 | btn->caption = caption; |
||
66 | |||
67 | |||
68 | btn->capt_len = 0; |
||
69 | else |
||
70 | { |
||
71 | len = strlen(caption); |
||
72 | btn->capt_len = len; |
||
73 | if( len ) |
||
74 | btn->caption = strdup(caption); |
||
75 | else |
||
76 | btn->caption = NULL; |
||
77 | } |
||
78 | |||
79 | |||
80 | btn->img_hilite = NULL; |
||
81 | btn->img_pressed = NULL; |
||
82 | |||
83 | |||
84 | }; |
||
85 | |||
86 | |||
87 | int draw_button(button_t *btn) |
||
88 | { |
||
89 | void *bitmap; |
||
90 | |||
91 | |||
92 | |||
93 | |||
94 | bitmap = btn->img_pressed; |
||
95 | else if(btn->state & bHighlight) |
||
96 | bitmap = btn->img_hilite; |
||
97 | |||
98 | |||
99 | draw_bitmap(bitmap, btn->rc.l, btn->rc.t, btn->w, btn->h); |
||
100 | |||
101 | |||
102 | { |
||
103 | int txt_w; |
||
104 | int txt_x, txt_y; |
||
105 | txt_w = btn->capt_len*8-2; |
||
106 | |||
107 | |||
108 | txt_y = btn->rc.t + 9; |
||
109 | |||
110 | |||
111 | txt_x++; |
||
112 | txt_y++; |
||
113 | }; |
||
114 | draw_text(btn->caption, txt_x, txt_y, btn->capt_len, 0x10000000); |
||
115 | }; |
||
116 | return 0; |
||
117 | }; |
||
118 | #endif |
||
119 | |||
120 | |||
121 | { |
||
122 | int *src; |
||
123 | ctx_t *ctx; |
||
124 | int x, y; |
||
125 | |||
126 | |||
127 | |||
128 | |||
129 | y = btn->ctrl.rc.t - ctx->offset_y; |
||
130 | |||
131 | |||
132 | |||
133 | |||
134 | src = btn->img_pressed; |
||
135 | else if(btn->state & bHighlight) |
||
136 | src = btn->img_hilite; |
||
137 | |||
138 | |||
139 | |||
140 | |||
141 | }; |
||
142 | |||
143 | |||
144 | |||
145 | { |
||
146 | void *ctx; |
||
147 | |||
148 | |||
149 | }; |
||
150 | |||
151 | |||
152 | |||
153 | { |
||
154 | int x, y; |
||
155 | int state; |
||
156 | int old_state; |
||
157 | int action=0; |
||
158 | |||
159 | |||
160 | |||
161 | |||
162 | { |
||
163 | case MSG_PAINT: |
||
164 | draw_button_cairo(btn); |
||
165 | update_rect((ctrl_t*)btn); |
||
166 | break; |
||
167 | |||
168 | |||
169 | // printf("mouse enter\n"); |
||
170 | btn->state|= bHighlight; |
||
171 | send_message(&btn->ctrl, MSG_PAINT, 0, 0); |
||
172 | break; |
||
173 | |||
174 | |||
175 | // printf("mouse leave\n"); |
||
176 | if( (ctrl_t*)btn != mouse_capture) { |
||
177 | btn->state &= ~bHighlight; |
||
178 | send_message(&btn->ctrl, MSG_PAINT, 0, 0); |
||
179 | }; |
||
180 | break; |
||
181 | |||
182 | |||
183 | case MSG_LBTNDBLCLK: |
||
184 | // printf("push button\n"); |
||
185 | capture_mouse((ctrl_t*)btn); |
||
186 | btn->state|= bPressed; |
||
187 | send_message(&btn->ctrl, MSG_PAINT, 0, 0); |
||
188 | break; |
||
189 | |||
190 | |||
191 | |||
192 | |||
193 | if(btn->state & bPressed) |
||
194 | action = MSG_COMMAND; |
||
195 | |||
196 | |||
197 | |||
198 | |||
199 | y = ((pos_t)arg2).y; |
||
200 | |||
201 | |||
202 | state = bHighlight; |
||
203 | else |
||
204 | state = 0; |
||
205 | |||
206 | |||
207 | send_message(btn->ctrl.parent,MSG_COMMAND,btn->ctrl.id,(int)btn); |
||
208 | |||
209 | |||
210 | send_message(&btn->ctrl, MSG_PAINT, 0, 0); |
||
211 | break; |
||
212 | |||
213 | |||
214 | |||
215 | |||
216 | { |
||
217 | set_cursor(0); |
||
218 | main_cursor = 0; |
||
219 | } |
||
220 | |||
221 | |||
222 | { |
||
223 | btn->state|= bHighlight; |
||
224 | send_message(&btn->ctrl, MSG_PAINT, 0, 0); |
||
225 | }; |
||
226 | |||
227 | |||
228 | return 0; |
||
229 | |||
230 | |||
231 | y = ((pos_t)arg2).y; |
||
232 | |||
233 | |||
234 | |||
235 | |||
236 | btn->state |= bPressed; |
||
237 | else |
||
238 | btn->state &= ~bPressed; |
||
239 | |||
240 | |||
241 | send_message(&btn->ctrl, MSG_PAINT, 0, 0); |
||
242 | } |
||
243 | return 0; |
||
244 | }; |
||
245 | |||
246 | |||
247 | |||
248 | { |
||
249 | int *pixmap, *src; |
||
250 | ctx_t *ctx; |
||
251 | int i, j; |
||
252 | int x, y; |
||
253 | rect_t rc = prg->ctrl.rc; |
||
254 | |||
255 | |||
256 | |||
257 | |||
258 | |||
259 | |||
260 | y = prg->ctrl.rc.t - ctx->offset_y; |
||
261 | |||
262 | |||
263 | { |
||
264 | src = res_progress_bar; |
||
265 | |||
266 | |||
5372 | serge | 267 | pixmap+= y * ctx->pixmap_pitch/4 + x; |
268 | |||
4438 | Serge | 269 | |
270 | { |
||
271 | for(j = 0; j < len; j++) |
||
272 | pixmap[j] = *src; |
||
273 | |||
274 | |||
5372 | serge | 275 | src++; |
4438 | Serge | 276 | }; |
277 | }; |
||
278 | |||
279 | |||
280 | |||
281 | |||
282 | |||
283 | |||
5372 | serge | 284 | pixmap+= y*ctx->pixmap_pitch/4 + x; |
285 | |||
4438 | Serge | 286 | |
287 | { |
||
288 | for(j=0; j < len; j++) |
||
289 | pixmap[j] = *src; |
||
290 | pixmap+= ctx->pixmap_pitch/4; |
||
5372 | serge | 291 | src++; |
4438 | Serge | 292 | }; |
293 | |||
294 | |||
295 | }; |
||
296 | |||
297 | |||
298 | |||
299 | { |
||
300 | progress_t *prg = (progress_t*)ctrl; |
||
301 | int pos; |
||
302 | |||
303 | |||
304 | { |
||
305 | case MSG_PAINT: |
||
306 | draw_progress(prg, 1); |
||
307 | update_rect(ctrl); |
||
308 | break; |
||
309 | |||
310 | |||
311 | prg->pos = ((pos_t)arg2).x - ctrl->rc.l; |
||
312 | send_message(ctrl->parent,MSG_COMMAND,ctrl->id,(int)ctrl); |
||
313 | break; |
||
314 | |||
315 | |||
316 | draw_progress(prg, 0); |
||
317 | update_rect(ctrl); |
||
318 | break; |
||
319 | |||
320 | |||
321 | break; |
||
322 | } |
||
323 | return 0; |
||
324 | }; |
||
325 | |||
326 | |||
327 | |||
328 | int w, int h, ctrl_t *parent) |
||
329 | { |
||
330 | progress_t *prg; |
||
331 | int len; |
||
332 | |||
333 | |||
334 | return NULL; |
||
335 | |||
336 | |||
337 | |||
338 | |||
339 | |||
340 | |||
341 | prg->max = 1; |
||
342 | prg->current = 0; |
||
343 | prg->pos = 0; |
||
344 | |||
345 | |||
346 | }; |
||
347 | |||
348 | |||
349 | { |
||
350 | int *pixmap; |
||
5372 | serge | 351 | ctx_t *ctx; |
352 | int i, j; |
||
4438 | Serge | 353 | int x, y; |
354 | |||
355 | |||
356 | double level; |
||
357 | |||
358 | |||
359 | |||
360 | |||
361 | y = lvl->ctrl.rc.t - ctx->offset_y; |
||
362 | |||
363 | |||
364 | |||
365 | |||
366 | |||
367 | |||
368 | len = 0; |
||
369 | if(len > 96) |
||
370 | len = 96; |
||
371 | |||
372 | |||
5372 | serge | 373 | |
4438 | Serge | 374 | |
5372 | serge | 375 | |
4438 | Serge | 376 | |
377 | { |
||
378 | for(j = 0; j < 96; j++) |
||
379 | pixmap[j] = 0xFF1C1C1C; |
||
380 | pixmap+= ctx->pixmap_pitch/4; |
||
5372 | serge | 381 | }; |
4438 | Serge | 382 | |
383 | |||
384 | |||
385 | |||
386 | }; |
||
387 | |||
388 | |||
389 | |||
390 | { |
||
391 | level_t *lvl = (level_t*)ctrl; |
||
392 | |||
393 | |||
394 | { |
||
395 | case MSG_PAINT: |
||
396 | if(lvl->visible) |
||
397 | { |
||
398 | draw_level(lvl); |
||
399 | update_rect(ctrl); |
||
400 | }; |
||
401 | break; |
||
402 | |||
403 | |||
404 | // prg->pos = ((pos_t)arg2).x - ctrl->rc.l; |
||
405 | // send_message(ctrl->parent,MSG_COMMAND,ctrl->id,(int)ctrl); |
||
406 | // break; |
||
407 | |||
408 | |||
409 | break; |
||
410 | } |
||
411 | return 0; |
||
412 | }; |
||
413 | |||
414 | |||
415 | int w, int h, ctrl_t *parent) |
||
416 | { |
||
417 | level_t *lvl; |
||
418 | |||
419 | |||
420 | return NULL; |
||
421 | |||
422 | |||
423 | lvl->ctrl.handler = lvl_proc; |
||
424 | |||
425 | |||
426 | lvl->max = 1; |
||
427 | lvl->current = 0; |
||
428 | lvl->pos = 0; |
||
429 | lvl->visible = 0; |
||
430 | lvl->img_level = res_level; |
||
431 | |||
432 | |||
433 | }; |
||
434 | |||
435 | |||
436 | |||
437 | { |
||
438 | int *pixmap; |
||
5372 | serge | 439 | ctx_t *ctx; |
4438 | Serge | 440 | int i, j; |
441 | int x, y; |
||
442 | |||
443 | |||
444 | double level; |
||
445 | |||
446 | |||
447 | |||
448 | |||
449 | y = sld->ctrl.rc.t - ctx->offset_y; |
||
450 | |||
451 | |||
452 | |||
453 | |||
5372 | serge | 454 | pixmap+= y*ctx->pixmap_pitch/4 + x; |
455 | |||
4438 | Serge | 456 | |
457 | { |
||
458 | for(j = 0; j < len; j++) |
||
459 | pixmap[j] = 0xFF1C1C1C; |
||
460 | pixmap+= ctx->pixmap_pitch/4; |
||
5372 | serge | 461 | }; |
4438 | Serge | 462 | |
463 | |||
464 | blit_raw(ctx, res_slider, x+sld->pos, y, 12, 11, 12*4); |
||
465 | |||
466 | |||
467 | }; |
||
468 | |||
469 | |||
470 | |||
471 | { |
||
472 | slider_t *sld = (slider_t*)ctrl; |
||
473 | int pos; |
||
474 | |||
475 | |||
476 | { |
||
477 | case MSG_PAINT: |
||
478 | draw_slider(sld); |
||
479 | update_rect(ctrl); |
||
480 | break; |
||
481 | |||
482 | |||
483 | capture_mouse(ctrl); |
||
484 | sld->mode = 1; |
||
485 | |||
486 | |||
487 | if( pos < 0 ) |
||
488 | pos = 0; |
||
489 | else if(pos > 96) |
||
490 | pos = 96; |
||
491 | if( sld->pos != pos) |
||
492 | { |
||
493 | sld->pos = pos; |
||
494 | send_message(ctrl->parent,MSG_COMMAND,ctrl->id,(int)ctrl); |
||
495 | }; |
||
496 | break; |
||
497 | |||
498 | |||
499 | if(sld->mode) |
||
500 | { |
||
501 | release_mouse(); |
||
502 | sld->mode = 0; |
||
503 | }; |
||
504 | break; |
||
505 | |||
506 | |||
507 | if(sld->mode) |
||
508 | { |
||
509 | pos = ((pos_t)arg2).x - ctrl->rc.l - 6; |
||
510 | if( pos < 0 ) |
||
511 | pos = 0; |
||
512 | else if(pos > 96) |
||
513 | pos = 96; |
||
514 | if( sld->pos != pos) |
||
515 | { |
||
516 | sld->pos = pos; |
||
517 | // printf("slider pos %d\n", sld->pos); |
||
518 | send_message(ctrl->parent,MSG_COMMAND,ctrl->id,(int)ctrl); |
||
519 | } |
||
520 | }; |
||
521 | break; |
||
522 | |||
523 | |||
524 | panel_set_layout(ctrl->parent, 1); |
||
525 | // printf("level on\n"); |
||
526 | break; |
||
527 | |||
528 | |||
529 | panel_set_layout(ctrl->parent, 0); |
||
530 | // printf("level off\n"); |
||
531 | break; |
||
532 | |||
533 | |||
534 | |||
535 | break; |
||
536 | } |
||
537 | return 0; |
||
538 | }; |
||
539 | |||
540 | |||
541 | |||
542 | int w, int h, ctrl_t *parent) |
||
543 | { |
||
544 | |||
545 | |||
546 | |||
547 | |||
548 | return NULL; |
||
549 | |||
550 | |||
551 | sld->ctrl.handler = sld_proc; |
||
552 | |||
553 | |||
554 | sld->max = 0; |
||
555 | sld->current = 0; |
||
556 | sld->pos = 60; |
||
557 | sld->mode = 0; |
||
558 | sld->img_vol_slider = res_vol_slider; |
||
559 | |||
560 | |||
561 | };>>>>>>>>>>> |
||
562 |