Rev 5372 | Go to most recent revision | Details | 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 | |||
19 | |||
20 | int w, int h, ctrl_t *parent) |
||
21 | { |
||
22 | |||
23 | |||
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 | |||
130 | |||
131 | y = btn->ctrl.rc.t - ctx->offset_y; |
||
132 | |||
133 | |||
134 | |||
135 | |||
136 | src = btn->img_pressed; |
||
137 | else if(btn->state & bHighlight) |
||
138 | src = btn->img_hilite; |
||
139 | |||
140 | |||
141 | |||
142 | |||
143 | }; |
||
144 | |||
145 | |||
146 | |||
147 | { |
||
148 | void *ctx; |
||
149 | |||
150 | |||
151 | }; |
||
152 | |||
153 | |||
154 | |||
155 | { |
||
156 | int x, y; |
||
157 | int state; |
||
158 | int old_state; |
||
159 | int action=0; |
||
160 | |||
161 | |||
162 | |||
163 | |||
164 | { |
||
165 | case MSG_PAINT: |
||
166 | draw_button_cairo(btn); |
||
167 | update_rect((ctrl_t*)btn); |
||
168 | break; |
||
169 | |||
170 | |||
171 | // printf("mouse enter\n"); |
||
172 | btn->state|= bHighlight; |
||
173 | send_message(&btn->ctrl, MSG_PAINT, 0, 0); |
||
174 | break; |
||
175 | |||
176 | |||
177 | // printf("mouse leave\n"); |
||
178 | if( (ctrl_t*)btn != mouse_capture) { |
||
179 | btn->state &= ~bHighlight; |
||
180 | send_message(&btn->ctrl, MSG_PAINT, 0, 0); |
||
181 | }; |
||
182 | break; |
||
183 | |||
184 | |||
185 | case MSG_LBTNDBLCLK: |
||
186 | // printf("push button\n"); |
||
187 | capture_mouse((ctrl_t*)btn); |
||
188 | btn->state|= bPressed; |
||
189 | send_message(&btn->ctrl, MSG_PAINT, 0, 0); |
||
190 | break; |
||
191 | |||
192 | |||
193 | |||
194 | |||
195 | if(btn->state & bPressed) |
||
196 | action = MSG_COMMAND; |
||
197 | |||
198 | |||
199 | |||
200 | |||
201 | y = ((pos_t)arg2).y; |
||
202 | |||
203 | |||
204 | state = bHighlight; |
||
205 | else |
||
206 | state = 0; |
||
207 | |||
208 | |||
209 | send_message(btn->ctrl.parent,MSG_COMMAND,btn->ctrl.id,(int)btn); |
||
210 | |||
211 | |||
212 | send_message(&btn->ctrl, MSG_PAINT, 0, 0); |
||
213 | break; |
||
214 | |||
215 | |||
216 | |||
217 | |||
218 | { |
||
219 | set_cursor(0); |
||
220 | main_cursor = 0; |
||
221 | } |
||
222 | |||
223 | |||
224 | { |
||
225 | btn->state|= bHighlight; |
||
226 | send_message(&btn->ctrl, MSG_PAINT, 0, 0); |
||
227 | }; |
||
228 | |||
229 | |||
230 | return 0; |
||
231 | |||
232 | |||
233 | y = ((pos_t)arg2).y; |
||
234 | |||
235 | |||
236 | |||
237 | |||
238 | btn->state |= bPressed; |
||
239 | else |
||
240 | btn->state &= ~bPressed; |
||
241 | |||
242 | |||
243 | send_message(&btn->ctrl, MSG_PAINT, 0, 0); |
||
244 | } |
||
245 | return 0; |
||
246 | }; |
||
247 | |||
248 | |||
249 | |||
250 | { |
||
251 | int *pixmap, *src; |
||
252 | ctx_t *ctx; |
||
253 | int i, j; |
||
254 | int x, y; |
||
255 | rect_t rc = prg->ctrl.rc; |
||
256 | |||
257 | |||
258 | |||
259 | |||
260 | |||
261 | |||
262 | |||
263 | |||
264 | y = prg->ctrl.rc.t - ctx->offset_y; |
||
265 | |||
266 | |||
267 | { |
||
268 | src = res_progress_bar; |
||
269 | |||
270 | |||
271 | pixmap+= y * ctx->pixmap->pitch/4 + x; |
||
272 | |||
273 | |||
274 | { |
||
275 | for(j = 0; j < len; j++) |
||
276 | pixmap[j] = *src; |
||
277 | |||
278 | |||
279 | src++; |
||
280 | }; |
||
281 | }; |
||
282 | |||
283 | |||
284 | |||
285 | |||
286 | |||
287 | |||
288 | |||
289 | pixmap+= y*ctx->pixmap->pitch/4 + x; |
||
290 | |||
291 | |||
292 | { |
||
293 | for(j=0; j < len; j++) |
||
294 | pixmap[j] = *src; |
||
295 | pixmap+= ctx->pixmap->pitch/4; |
||
296 | src++; |
||
297 | }; |
||
298 | |||
299 | |||
300 | }; |
||
301 | |||
302 | |||
303 | |||
304 | { |
||
305 | progress_t *prg = (progress_t*)ctrl; |
||
306 | int pos; |
||
307 | |||
308 | |||
309 | { |
||
310 | case MSG_PAINT: |
||
311 | draw_progress(prg, 1); |
||
312 | update_rect(ctrl); |
||
313 | break; |
||
314 | |||
315 | |||
316 | prg->pos = ((pos_t)arg2).x - ctrl->rc.l; |
||
317 | send_message(ctrl->parent,MSG_COMMAND,ctrl->id,(int)ctrl); |
||
318 | break; |
||
319 | |||
320 | |||
321 | draw_progress(prg, 0); |
||
322 | update_rect(ctrl); |
||
323 | break; |
||
324 | |||
325 | |||
326 | break; |
||
327 | } |
||
328 | return 0; |
||
329 | }; |
||
330 | |||
331 | |||
332 | |||
333 | int w, int h, ctrl_t *parent) |
||
334 | { |
||
335 | progress_t *prg; |
||
336 | int len; |
||
337 | |||
338 | |||
339 | return NULL; |
||
340 | |||
341 | |||
342 | |||
343 | |||
344 | |||
345 | |||
346 | prg->max = 1; |
||
347 | prg->current = 0; |
||
348 | prg->pos = 0; |
||
349 | |||
350 | |||
351 | }; |
||
352 | |||
353 | |||
354 | { |
||
355 | int *pixmap; |
||
356 | ctx_t *ctx; |
||
357 | int i, j; |
||
358 | int x, y; |
||
359 | |||
360 | |||
361 | double level; |
||
362 | |||
363 | |||
364 | |||
365 | |||
366 | |||
367 | |||
368 | y = lvl->ctrl.rc.t - ctx->offset_y; |
||
369 | |||
370 | |||
371 | |||
372 | |||
373 | |||
374 | |||
375 | len = 0; |
||
376 | if(len > 96) |
||
377 | len = 96; |
||
378 | |||
379 | |||
380 | |||
381 | |||
382 | |||
383 | |||
384 | { |
||
385 | for(j = 0; j < 96; j++) |
||
386 | pixmap[j] = 0xFF1C1C1C; |
||
387 | pixmap+= ctx->pixmap->pitch/4; |
||
388 | }; |
||
389 | |||
390 | |||
391 | |||
392 | |||
393 | }; |
||
394 | |||
395 | |||
396 | |||
397 | { |
||
398 | level_t *lvl = (level_t*)ctrl; |
||
399 | // int pos; |
||
400 | |||
401 | |||
402 | { |
||
403 | case MSG_PAINT: |
||
404 | if(lvl->visible) |
||
405 | { |
||
406 | draw_level(lvl); |
||
407 | update_rect(ctrl); |
||
408 | }; |
||
409 | break; |
||
410 | |||
411 | |||
412 | // prg->pos = ((pos_t)arg2).x - ctrl->rc.l; |
||
413 | // send_message(ctrl->parent,MSG_COMMAND,ctrl->id,(int)ctrl); |
||
414 | // break; |
||
415 | |||
416 | |||
417 | break; |
||
418 | } |
||
419 | return 0; |
||
420 | }; |
||
421 | |||
422 | |||
423 | int w, int h, ctrl_t *parent) |
||
424 | { |
||
425 | level_t *lvl; |
||
426 | |||
427 | |||
428 | return NULL; |
||
429 | |||
430 | |||
431 | lvl->ctrl.handler = lvl_proc; |
||
432 | |||
433 | |||
434 | lvl->max = 1; |
||
435 | lvl->current = 0; |
||
436 | lvl->pos = 0; |
||
437 | lvl->visible = 0; |
||
438 | lvl->img_level = res_level; |
||
439 | |||
440 | |||
441 | }; |
||
442 | |||
443 | |||
444 | |||
445 | { |
||
446 | int *pixmap; |
||
447 | ctx_t *ctx; |
||
448 | int i, j; |
||
449 | int x, y; |
||
450 | |||
451 | |||
452 | double level; |
||
453 | |||
454 | |||
455 | |||
456 | |||
457 | |||
458 | |||
459 | y = sld->ctrl.rc.t - ctx->offset_y; |
||
460 | |||
461 | |||
462 | |||
463 | |||
464 | pixmap+= y*ctx->pixmap->pitch/4 + x; |
||
465 | |||
466 | |||
467 | { |
||
468 | for(j = 0; j < len; j++) |
||
469 | pixmap[j] = 0xFF1C1C1C; |
||
470 | pixmap+= ctx->pixmap->pitch/4; |
||
471 | }; |
||
472 | |||
473 | |||
474 | |||
475 | |||
476 | |||
477 | |||
478 | }; |
||
479 | |||
480 | |||
481 | |||
482 | { |
||
483 | slider_t *sld = (slider_t*)ctrl; |
||
484 | int pos; |
||
485 | |||
486 | |||
487 | { |
||
488 | case MSG_PAINT: |
||
489 | draw_slider(sld); |
||
490 | update_rect(ctrl); |
||
491 | break; |
||
492 | |||
493 | |||
494 | capture_mouse(ctrl); |
||
495 | sld->mode = 1; |
||
496 | |||
497 | |||
498 | if( pos < 0 ) |
||
499 | pos = 0; |
||
500 | else if(pos > 96) |
||
501 | pos = 96; |
||
502 | if( sld->pos != pos) |
||
503 | { |
||
504 | sld->pos = pos; |
||
505 | send_message(ctrl->parent,MSG_COMMAND,ctrl->id,(int)ctrl); |
||
506 | }; |
||
507 | break; |
||
508 | |||
509 | |||
510 | if(sld->mode) |
||
511 | { |
||
512 | release_mouse(); |
||
513 | sld->mode = 0; |
||
514 | }; |
||
515 | break; |
||
516 | |||
517 | |||
518 | if(sld->mode) |
||
519 | { |
||
520 | pos = ((pos_t)arg2).x - ctrl->rc.l - 6; |
||
521 | if( pos < 0 ) |
||
522 | pos = 0; |
||
523 | else if(pos > 96) |
||
524 | pos = 96; |
||
525 | if( sld->pos != pos) |
||
526 | { |
||
527 | sld->pos = pos; |
||
528 | // printf("slider pos %d\n", sld->pos); |
||
529 | send_message(ctrl->parent,MSG_COMMAND,ctrl->id,(int)ctrl); |
||
530 | } |
||
531 | }; |
||
532 | break; |
||
533 | |||
534 | |||
535 | panel_set_layout(ctrl->parent, 1); |
||
536 | // printf("level on\n"); |
||
537 | break; |
||
538 | |||
539 | |||
540 | panel_set_layout(ctrl->parent, 0); |
||
541 | // printf("level off\n"); |
||
542 | break; |
||
543 | |||
544 | |||
545 | |||
546 | break; |
||
547 | } |
||
548 | return 0; |
||
549 | }; |
||
550 | |||
551 | |||
552 | |||
553 | int w, int h, ctrl_t *parent) |
||
554 | { |
||
555 | |||
556 | |||
557 | |||
558 | |||
559 | return NULL; |
||
560 | |||
561 | |||
562 | sld->ctrl.handler = sld_proc; |
||
563 | |||
564 | |||
565 | sld->max = 0; |
||
566 | sld->current = 0; |
||
567 | sld->pos = 60; |
||
568 | sld->mode = 0; |
||
569 | sld->img_vol_slider = res_vol_slider; |
||
570 | |||
571 | |||
572 | };>>>>>>>>>>> |
||
573 |