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