Rev 2693 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2693 | Rev 3068 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | #include "system.h" |
1 | #include "system.h" |
2 | #include |
2 | #include |
3 | #include |
3 | #include |
- | 4 | #include |
|
4 | #include "winlib.h" |
5 | #include "winlib.h" |
Line -... | Line 6... | ||
- | 6 | ||
- | 7 | extern int res_level[]; |
|
- | 8 | extern int res_slider[]; |
|
- | 9 | extern int res_vol_slider[]; |
|
- | 10 | extern int res_progress_bar[]; |
|
Line 5... | Line 11... | ||
5 | 11 | extern int res_prg_level[]; |
|
6 | 12 | ||
Line 7... | Line 13... | ||
7 | extern ctrl_t *mouse_capture; |
13 | extern ctrl_t *mouse_capture; |
8 | uint32_t main_cursor; |
14 | uint32_t main_cursor; |
Line 9... | Line -... | ||
9 | - | ||
10 | static int button_proc(ctrl_t *btn, uint32_t msg, uint32_t arg1, uint32_t arg2); |
15 | |
11 | static int spinbtn_proc(ctrl_t *btn, uint32_t msg, uint32_t arg1, uint32_t arg2); |
16 | static int button_proc(ctrl_t *btn, uint32_t msg, uint32_t arg1, uint32_t arg2); |
12 | 17 | static int spinbtn_proc(ctrl_t *btn, uint32_t msg, uint32_t arg1, uint32_t arg2); |
|
- | 18 | ||
13 | 19 | ctrl_t *create_control(size_t size, int id, int x, int y, |
|
14 | button_t *create_button(char *caption, int id, int x, int y, |
- | |
Line 15... | Line 20... | ||
15 | int w, int h, ctrl_t *parent) |
20 | int w, int h, ctrl_t *parent) |
16 | { |
21 | { |
Line 17... | Line 22... | ||
17 | button_t *btn; |
22 | |
Line 18... | Line 23... | ||
18 | int len; |
23 | ctrl_t *ctrl; |
19 | 24 | ||
Line 20... | Line -... | ||
20 | if( !parent ) |
- | |
21 | return NULL; |
25 | if( !parent ) |
Line 22... | Line 26... | ||
22 | 26 | return NULL; |
|
23 | btn = (button_t*)malloc(sizeof(button_t)); |
27 | |
24 | - | ||
Line 25... | Line 28... | ||
25 | link_initialize(&btn->link); |
28 | ctrl = (ctrl_t*)malloc(size); |
26 | list_initialize(&btn->child); |
29 | |
Line 27... | Line 30... | ||
27 | 30 | link_initialize(&ctrl->link); |
|
28 | btn->handler = button_proc; |
31 | list_initialize(&ctrl->child); |
Line 29... | Line 32... | ||
29 | btn->parent = parent; |
32 | |
30 | 33 | ctrl->parent = parent; |
|
Line -... | Line 34... | ||
- | 34 | ||
- | 35 | ctrl->ctx = parent->ctx; |
|
- | 36 | ctrl->id = id; |
|
- | 37 | ||
- | 38 | ctrl->rc.l = x; |
|
- | 39 | ctrl->rc.t = y ; |
|
- | 40 | ||
- | 41 | ctrl->rc.r = x + w; |
|
- | 42 | ctrl->rc.b = y + h; |
|
31 | btn->ctx = parent->ctx; |
43 | |
- | 44 | ctrl->w = w; |
|
Line -... | Line 45... | ||
- | 45 | ctrl->h = h; |
|
- | 46 | ||
- | 47 | list_append(&ctrl->link, &parent->child); |
|
- | 48 | ||
- | 49 | return ctrl; |
|
- | 50 | }; |
|
32 | btn->id = id; |
51 | |
Line 33... | Line 52... | ||
33 | btn->style = 0; |
52 | |
34 | 53 | button_t *create_button(char *caption, int id, int x, int y, |
|
35 | btn->rc.l = x; |
54 | int w, int h, ctrl_t *parent) |
Line 60... | Line 79... | ||
60 | btn->img_default = NULL; |
79 | btn->img_default = NULL; |
61 | btn->img_hilite = NULL; |
80 | btn->img_hilite = NULL; |
62 | btn->img_pressed = NULL; |
81 | btn->img_pressed = NULL; |
Line 63... | Line -... | ||
63 | - | ||
64 | list_append(&btn->link, &parent->child); |
- | |
65 | 82 | ||
66 | return btn; |
83 | return btn; |
Line 67... | Line 84... | ||
67 | }; |
84 | }; |
68 | 85 | ||
Line 106... | Line 123... | ||
106 | ctx_t *ctx; |
123 | ctx_t *ctx; |
107 | int i, j; |
124 | int i, j; |
108 | int x, y; |
125 | int x, y; |
109 | 126 | ||
Line 110... | Line 127... | ||
110 | ctx = btn->ctx; |
127 | ctx = btn->ctrl.ctx; |
Line 111... | Line 128... | ||
111 | 128 | ||
112 | x = btn->rc.l - ctx->offset_x; |
129 | x = btn->ctrl.rc.l - ctx->offset_x; |
Line 113... | Line 130... | ||
113 | y = btn->rc.t - ctx->offset_y; |
130 | y = btn->ctrl.rc.t - ctx->offset_y; |
Line 114... | Line 131... | ||
114 | 131 | ||
Line 122... | Line 139... | ||
122 | src = btn->img_pressed; |
139 | src = btn->img_pressed; |
123 | else if(btn->state & bHighlight) |
140 | else if(btn->state & bHighlight) |
124 | src = btn->img_hilite; |
141 | src = btn->img_hilite; |
125 | 142 | ||
Line 126... | Line 143... | ||
126 | for(i=0; i < btn->h ;i++) |
143 | for(i=0; i < btn->ctrl.h ;i++) |
127 | { |
144 | { |
128 | for(j=0; j |
145 | for(j = 0; j < btn->ctrl.w; j++) |
129 | pixmap[j] = src[j]; |
146 | pixmap[j] = src[j]; |
130 | pixmap+= ctx->stride/4; |
147 | pixmap+= ctx->stride/4; |
131 | src+=btn->w; |
148 | src+= btn->ctrl.w; |
132 | }; |
149 | }; |
Line 133... | Line 150... | ||
133 | 150 | ||
134 | return 0; |
151 | return 0; |
Line 161... | Line 178... | ||
161 | 178 | ||
Line 162... | Line 179... | ||
162 | case MSG_MOUSEENTER: |
179 | case MSG_MOUSEENTER: |
163 | // printf("mouse enter\n"); |
180 | // printf("mouse enter\n"); |
164 | btn->state|= bHighlight; |
181 | btn->state|= bHighlight; |
165 | send_message(btn, MSG_PAINT, 0, 0); |
182 | send_message(&btn->ctrl, MSG_PAINT, 0, 0); |
166 | break; |
183 | break; |
Line 167... | Line 184... | ||
167 | 184 | ||
168 | case MSG_MOUSELEAVE: |
185 | case MSG_MOUSELEAVE: |
169 | // printf("mouse leave\n"); |
186 | // printf("mouse leave\n"); |
170 | if( (ctrl_t*)btn != mouse_capture) { |
187 | if( (ctrl_t*)btn != mouse_capture) { |
171 | btn->state &= ~bHighlight; |
188 | btn->state &= ~bHighlight; |
172 | send_message(btn, MSG_PAINT, 0, 0); |
189 | send_message(&btn->ctrl, MSG_PAINT, 0, 0); |
173 | }; |
190 | }; |
Line 174... | Line 191... | ||
174 | break; |
191 | break; |
175 | 192 | ||
176 | case MSG_LBTNDOWN: |
193 | case MSG_LBTNDOWN: |
177 | case MSG_LBTNDBLCLK: |
194 | case MSG_LBTNDBLCLK: |
178 | // printf("push button\n"); |
195 | // printf("push button\n"); |
179 | capture_mouse((ctrl_t*)btn); |
196 | capture_mouse((ctrl_t*)btn); |
180 | btn->state|= bPressed; |
197 | btn->state|= bPressed; |
Line 181... | Line 198... | ||
181 | send_message(btn, MSG_PAINT, 0, 0); |
198 | send_message(&btn->ctrl, MSG_PAINT, 0, 0); |
Line 182... | Line 199... | ||
182 | break; |
199 | break; |
Line 191... | Line 208... | ||
191 | 208 | ||
Line 192... | Line 209... | ||
192 | x = ((pos_t)arg2).x; |
209 | x = ((pos_t)arg2).x; |
193 | y = ((pos_t)arg2).y; |
210 | y = ((pos_t)arg2).y; |
Line 194... | Line 211... | ||
194 | 211 | ||
195 | if( pt_in_rect( &btn->rc, x, y) ) |
212 | if( pt_in_rect( &btn->ctrl.rc, x, y) ) |
196 | state = bHighlight; |
213 | state = bHighlight; |
197 | else |
214 | else |
Line 198... | Line 215... | ||
198 | state = 0; |
215 | state = 0; |
199 | 216 | ||
Line 200... | Line 217... | ||
200 | if(action) |
217 | if(action) |
201 | send_message(btn->parent,MSG_COMMAND,btn->id,(int)btn); |
218 | send_message(btn->ctrl.parent,MSG_COMMAND,btn->ctrl.id,(int)btn); |
202 | 219 | ||
Line 203... | Line 220... | ||
203 | btn->state = state; |
220 | btn->state = state; |
Line 204... | Line 221... | ||
204 | send_message(btn, MSG_PAINT, 0, 0); |
221 | send_message(&btn->ctrl, MSG_PAINT, 0, 0); |
Line 214... | Line 231... | ||
214 | 231 | ||
Line 215... | Line 232... | ||
215 | if( ! (btn->state & bHighlight)) |
232 | if( ! (btn->state & bHighlight)) |
216 | { |
233 | { |
217 | btn->state|= bHighlight; |
234 | btn->state|= bHighlight; |
218 | send_message(btn, MSG_PAINT, 0, 0); |
235 | send_message(&btn->ctrl, MSG_PAINT, 0, 0); |
219 | }; |
236 | }; |
Line 220... | Line 237... | ||
220 | 237 | ||
221 | if( (ctrl_t*)btn != mouse_capture) |
238 | if( (ctrl_t*)btn != mouse_capture) |
Line 222... | Line 239... | ||
222 | return 0; |
239 | return 0; |
223 | 240 | ||
Line 224... | Line 241... | ||
224 | x = ((pos_t)arg2).x; |
241 | x = ((pos_t)arg2).x; |
Line 225... | Line 242... | ||
225 | y = ((pos_t)arg2).y; |
242 | y = ((pos_t)arg2).y; |
226 | 243 | ||
227 | old_state = btn->state; |
244 | old_state = btn->state; |
228 | 245 | ||
Line 229... | Line 246... | ||
229 | if( pt_in_rect(&btn->rc, x, y) ) |
246 | if( pt_in_rect(&btn->ctrl.rc, x, y) ) |
230 | btn->state |= bPressed; |
247 | btn->state |= bPressed; |
231 | else |
248 | else |
232 | btn->state &= ~bPressed; |
249 | btn->state &= ~bPressed; |
233 | 250 | ||
Line 234... | Line 251... | ||
234 | if( old_state ^ btn->state) |
251 | if( old_state ^ btn->state) |
235 | send_message(btn, MSG_PAINT, 0, 0); |
252 | send_message(&btn->ctrl, MSG_PAINT, 0, 0); |
236 | } |
253 | } |
237 | return 0; |
254 | return 0; |
238 | }; |
255 | }; |
239 | 256 | ||
Line 240... | Line 257... | ||
240 | 257 | ||
Line 241... | Line 258... | ||
241 | int draw_progress(progress_t *prg) |
258 | int draw_progress(progress_t *prg, int background) |
Line 242... | Line 259... | ||
242 | { |
259 | { |
243 | int *pixmap, src; |
260 | int *pixmap, *src; |
Line -... | Line 261... | ||
- | 261 | ctx_t *ctx; |
|
- | 262 | int i, j; |
|
- | 263 | int x, y; |
|
Line 244... | Line -... | ||
244 | ctx_t *ctx; |
- | |
245 | int i, j; |
264 | |
246 | int x, y; |
- | |
247 | 265 | int len = prg->ctrl.w; |
|
Line -... | Line 266... | ||
- | 266 | ||
- | 267 | ctx = prg->ctrl.ctx; |
|
- | 268 | ||
- | 269 | x = prg->ctrl.rc.l - ctx->offset_x; |
|
- | 270 | y = prg->ctrl.rc.t - ctx->offset_y; |
|
- | 271 | ||
- | 272 | if( background ) |
|
- | 273 | { |
|
- | 274 | src = res_progress_bar; |
|
- | 275 | ||
- | 276 | pixmap = ctx->pixmap; |
|
- | 277 | pixmap+= y * ctx->stride/4 + x; |
|
- | 278 | ||
248 | int len; |
279 | for(i=0; i < 10; i++) |
- | 280 | { |
|
- | 281 | for(j = 0; j < len; j++) |
|
- | 282 | pixmap[j] = *src; |
|
Line 249... | Line 283... | ||
249 | 283 | ||
250 | ctx = prg->ctrl.ctx; |
284 | pixmap+= ctx->stride/4; |
251 | 285 | src++; |
|
252 | x = prg->ctrl.rc.l - ctx->offset_x; |
286 | }; |
253 | y = prg->ctrl.rc.t - ctx->offset_y; |
287 | }; |
- | 288 | ||
254 | 289 | ||
Line 255... | Line 290... | ||
255 | 290 | len = prg->current*prg->ctrl.w/(prg->max - prg->min); |
|
256 | len = prg->current*prg->ctrl.w/(prg->max - prg->min); |
291 | |
Line 278... | Line 313... | ||
278 | 313 | ||
Line 279... | Line 314... | ||
279 | switch( msg ) |
314 | switch( msg ) |
280 | { |
315 | { |
281 | case MSG_PAINT: |
316 | case MSG_PAINT: |
282 | draw_progress(prg); |
317 | draw_progress(prg, 1); |
283 | update_rect(ctrl); |
318 | update_rect(ctrl); |
284 | break; |
319 | break; |
Line 285... | Line 320... | ||
285 | 320 | ||
286 | case MSG_LBTNDOWN: |
321 | case MSG_LBTNDOWN: |
287 | prg->pos = ((pos_t)arg2).x - ctrl->rc.l; |
322 | prg->pos = ((pos_t)arg2).x - ctrl->rc.l; |
288 | send_message(ctrl->parent,MSG_COMMAND,ctrl->id,(int)ctrl); |
323 | send_message(ctrl->parent,MSG_COMMAND,ctrl->id,(int)ctrl); |
Line -... | Line 324... | ||
- | 324 | break; |
|
- | 325 | ||
- | 326 | case PRG_PROGRESS: |
|
- | 327 | draw_progress(prg, 0); |
|
- | 328 | update_rect(ctrl); |
|
289 | break; |
329 | break; |
290 | 330 | ||
291 | default: |
331 | default: |
292 | break; |
332 | break; |
293 | } |
333 | } |
Line 303... | Line 343... | ||
303 | 343 | ||
Line 304... | Line 344... | ||
304 | if( !parent ) |
344 | if( !parent ) |
305 | return NULL; |
345 | return NULL; |
Line 306... | Line 346... | ||
306 | 346 | ||
307 | prg = (progress_t*)malloc(sizeof(progress_t)); |
- | |
308 | - | ||
309 | link_initialize(&prg->ctrl.link); |
- | |
Line 310... | Line 347... | ||
310 | list_initialize(&prg->ctrl.child); |
347 | prg = (progress_t*)create_control(sizeof(progress_t), id, x, y, w, h, parent); |
311 | - | ||
312 | prg->ctrl.handler = prg_proc; |
- | |
313 | prg->ctrl.parent = parent; |
- | |
314 | - | ||
315 | prg->ctrl.ctx = parent->ctx; |
- | |
316 | prg->ctrl.id = id; |
- | |
317 | - | ||
318 | prg->ctrl.rc.l = x; |
- | |
319 | prg->ctrl.rc.t = y ; |
- | |
320 | - | ||
321 | prg->ctrl.rc.r = x + w; |
- | |
322 | prg->ctrl.rc.b = y + h; |
- | |
323 | - | ||
Line 324... | Line 348... | ||
324 | prg->ctrl.w = w; |
348 | |
325 | prg->ctrl.h = h; |
349 | prg->ctrl.handler = prg_proc; |
326 | 350 | ||
327 | prg->min = 0; |
351 | prg->min = 0; |
Line 328... | Line -... | ||
328 | prg->max = 1; |
- | |
329 | prg->current = 0; |
- | |
330 | prg->pos = 0; |
352 | prg->max = 1; |
331 | 353 | prg->current = 0; |
|
Line -... | Line 354... | ||
- | 354 | prg->pos = 0; |
|
- | 355 | ||
- | 356 | return prg; |
|
- | 357 | }; |
|
- | 358 | ||
- | 359 | int draw_level(level_t *lvl) |
|
- | 360 | { |
|
- | 361 | int *pixmap, *src; |
|
- | 362 | ctx_t *ctx; |
|
- | 363 | int i, j; |
|
- | 364 | int x, y; |
|
- | 365 | ||
- | 366 | int len; |
|
- | 367 | double level; |
|
- | 368 | ||
- | 369 | ctx = lvl->ctrl.ctx; |
|
- | 370 | ||
- | 371 | x = lvl->ctrl.rc.l - ctx->offset_x; |
|
- | 372 | y = lvl->ctrl.rc.t - ctx->offset_y; |
|
- | 373 | ||
- | 374 | level = (log2(lvl->current+1)-7)*12 + lvl->vol/50 ; |
|
- | 375 | ||
- | 376 | len = level; |
|
- | 377 | ||
- | 378 | if(len < 0) |
|
- | 379 | len = 0; |
|
- | 380 | if(len > 96) |
|
- | 381 | len = 96; |
|
- | 382 | ||
- | 383 | pixmap = ctx->pixmap; |
|
- | 384 | ||
- | 385 | pixmap+= y*ctx->stride/4 + x; |
|
- | 386 | ||
- | 387 | // for(i=0; i < prg->ctrl.h ;i++) |
|
- | 388 | // { |
|
- | 389 | // for(j=0; j < len; j++) |
|
- | 390 | // pixmap[j] = src; |
|
- | 391 | // pixmap+= ctx->stride/4; |
|
- | 392 | // }; |
|
- | 393 | ||
- | 394 | src = lvl->img_level; |
|
- | 395 | ||
- | 396 | for(i=0; i < 10; i++) |
|
- | 397 | { |
|
- | 398 | for(j = 0; j < 96; j++) |
|
- | 399 | pixmap[j] = 0xFF1C1C1C; |
|
- | 400 | pixmap+= ctx->stride/4; |
|
- | 401 | }; |
|
- | 402 | ||
- | 403 | pixmap = ctx->pixmap; |
|
- | 404 | pixmap+= y*ctx->stride/4 + x; |
|
- | 405 | ||
- | 406 | for(i=0; i < 10; i++) |
|
- | 407 | { |
|
- | 408 | for(j = 0; j < len; j++) |
|
- | 409 | pixmap[j] = src[j]; |
|
- | 410 | pixmap+= ctx->stride/4; |
|
- | 411 | src+= 96; |
|
- | 412 | }; |
|
- | 413 | ||
- | 414 | return 0; |
|
- | 415 | }; |
|
- | 416 | ||
- | 417 | ||
- | 418 | int lvl_proc(ctrl_t *ctrl, uint32_t msg, uint32_t arg1, uint32_t arg2) |
|
- | 419 | { |
|
- | 420 | level_t *lvl = (level_t*)ctrl; |
|
- | 421 | // int pos; |
|
- | 422 | ||
- | 423 | switch( msg ) |
|
- | 424 | { |
|
- | 425 | case MSG_PAINT: |
|
- | 426 | if(lvl->visible) |
|
- | 427 | { |
|
- | 428 | draw_level(lvl); |
|
- | 429 | update_rect(ctrl); |
|
- | 430 | }; |
|
- | 431 | break; |
|
- | 432 | ||
- | 433 | // case MSG_LBTNDOWN: |
|
- | 434 | // prg->pos = ((pos_t)arg2).x - ctrl->rc.l; |
|
- | 435 | // send_message(ctrl->parent,MSG_COMMAND,ctrl->id,(int)ctrl); |
|
- | 436 | // break; |
|
- | 437 | ||
- | 438 | default: |
|
- | 439 | break; |
|
- | 440 | } |
|
- | 441 | return 0; |
|
- | 442 | }; |
|
- | 443 | ||
- | 444 | level_t *create_level(char *caption, int id, int x, int y, |
|
- | 445 | int w, int h, ctrl_t *parent) |
|
- | 446 | { |
|
- | 447 | level_t *lvl; |
|
- | 448 | ||
- | 449 | if( !parent ) |
|
- | 450 | return NULL; |
|
- | 451 | ||
- | 452 | lvl = (level_t*)create_control(sizeof(level_t), id, x, y, w, h, parent); |
|
- | 453 | lvl->ctrl.handler = lvl_proc; |
|
- | 454 | ||
- | 455 | lvl->min = 0; |
|
- | 456 | lvl->max = 1; |
|
- | 457 | lvl->current = 0; |
|
- | 458 | lvl->pos = 0; |
|
- | 459 | lvl->visible = 0; |
|
- | 460 | lvl->img_level = res_level; |
|
- | 461 | ||
- | 462 | return lvl; |
|
- | 463 | }; |
|
- | 464 | ||
- | 465 | ||
- | 466 | int draw_slider(slider_t *sld) |
|
- | 467 | { |
|
- | 468 | int *pixmap, *src; |
|
- | 469 | ctx_t *ctx; |
|
- | 470 | int i, j; |
|
- | 471 | int x, y; |
|
- | 472 | ||
- | 473 | int32_t len; |
|
- | 474 | double level; |
|
- | 475 | ||
- | 476 | ctx = sld->ctrl.ctx; |
|
- | 477 | ||
- | 478 | x = sld->ctrl.rc.l - ctx->offset_x; |
|
- | 479 | y = sld->ctrl.rc.t - ctx->offset_y; |
|
- | 480 | ||
- | 481 | ||
- | 482 | len = 96 + 12; |
|
- | 483 | ||
- | 484 | pixmap = ctx->pixmap; |
|
- | 485 | pixmap+= y*ctx->stride/4 + x; |
|
- | 486 | ||
- | 487 | for(i=0; i < 11; i++) |
|
- | 488 | { |
|
- | 489 | for(j = 0; j < len; j++) |
|
- | 490 | pixmap[j] = 0xFF1C1C1C; |
|
- | 491 | pixmap+= ctx->stride/4; |
|
- | 492 | }; |
|
- | 493 | ||
- | 494 | pixmap = ctx->pixmap; |
|
- | 495 | pixmap+= (y+4)*ctx->stride/4 + x + 6; |
|
- | 496 | ||
- | 497 | src = sld->img_vol_slider; |
|
- | 498 | ||
- | 499 | for(i = 0; i < 4; i++) |
|
- | 500 | { |
|
- | 501 | for(j = 0; j < 96; j++) |
|
- | 502 | pixmap[j] = src[j]; |
|
- | 503 | pixmap+= ctx->stride/4; |
|
- | 504 | src+= 96; |
|
- | 505 | }; |
|
- | 506 | ||
- | 507 | pixmap = ctx->pixmap; |
|
- | 508 | pixmap+= y*ctx->stride/4 + x + sld->pos; |
|
- | 509 | ||
- | 510 | src = res_slider; |
|
- | 511 | ||
- | 512 | for(i = 0; i < 11; i++) |
|
- | 513 | { |
|
- | 514 | for(j = 0; j < 12; j++) |
|
- | 515 | pixmap[j] = src[j]; |
|
- | 516 | pixmap+= ctx->stride/4; |
|
- | 517 | src+= 12; |
|
- | 518 | }; |
|
- | 519 | ||
- | 520 | return 0; |
|
- | 521 | }; |
|
- | 522 | ||
- | 523 | ||
- | 524 | int sld_proc(ctrl_t *ctrl, uint32_t msg, uint32_t arg1, uint32_t arg2) |
|
- | 525 | { |
|
- | 526 | slider_t *sld = (slider_t*)ctrl; |
|
- | 527 | int pos; |
|
- | 528 | ||
- | 529 | switch( msg ) |
|
- | 530 | { |
|
- | 531 | case MSG_PAINT: |
|
- | 532 | draw_slider(sld); |
|
- | 533 | update_rect(ctrl); |
|
- | 534 | break; |
|
- | 535 | ||
- | 536 | case MSG_LBTNDOWN: |
|
- | 537 | capture_mouse(ctrl); |
|
- | 538 | sld->mode = 1; |
|
- | 539 | ||
- | 540 | pos = ((pos_t)arg2).x - ctrl->rc.l - 6; |
|
- | 541 | if( pos < 0 ) |
|
- | 542 | pos = 0; |
|
- | 543 | else if(pos > 96) |
|
- | 544 | pos = 96; |
|
- | 545 | if( sld->pos != pos) |
|
- | 546 | { |
|
- | 547 | sld->pos = pos; |
|
- | 548 | send_message(ctrl->parent,MSG_COMMAND,ctrl->id,(int)ctrl); |
|
- | 549 | }; |
|
- | 550 | break; |
|
- | 551 | ||
- | 552 | case MSG_LBTNUP: |
|
- | 553 | if(sld->mode) |
|
- | 554 | { |
|
- | 555 | release_mouse(); |
|
- | 556 | sld->mode = 0; |
|
- | 557 | }; |
|
- | 558 | break; |
|
- | 559 | ||
- | 560 | case MSG_MOUSEMOVE: |
|
- | 561 | if(sld->mode) |
|
- | 562 | { |
|
- | 563 | pos = ((pos_t)arg2).x - ctrl->rc.l - 6; |
|
- | 564 | if( pos < 0 ) |
|
- | 565 | pos = 0; |
|
- | 566 | else if(pos > 96) |
|
- | 567 | pos = 96; |
|
- | 568 | if( sld->pos != pos) |
|
- | 569 | { |
|
- | 570 | sld->pos = pos; |
|
- | 571 | // printf("slider pos %d\n", sld->pos); |
|
- | 572 | send_message(ctrl->parent,MSG_COMMAND,ctrl->id,(int)ctrl); |
|
- | 573 | } |
|
- | 574 | }; |
|
- | 575 | break; |
|
- | 576 | ||
- | 577 | case MSG_MOUSEENTER: |
|
- | 578 | panel_set_layout(ctrl->parent, 1); |
|
- | 579 | // printf("level on\n"); |
|
- | 580 | break; |
|
- | 581 | ||
- | 582 | case MSG_MOUSELEAVE: |
|
- | 583 | panel_set_layout(ctrl->parent, 0); |
|
- | 584 | // printf("level off\n"); |
|
- | 585 | break; |
|
- | 586 | ||
- | 587 | ||
- | 588 | default: |
|
- | 589 | break; |
|
- | 590 | } |
|
- | 591 | return 0; |
|
- | 592 | }; |
|
- | 593 | ||
- | 594 | ||
- | 595 | slider_t *create_slider(char *caption, int id, int x, int y, |
|
- | 596 | int w, int h, ctrl_t *parent) |
|
- | 597 | { |
|
- | 598 | ||
- | 599 | slider_t *sld; |
|
- | 600 | ||
- | 601 | if( !parent ) |
|
- | 602 | return NULL; |
|
- | 603 | ||
- | 604 | sld = (slider_t*)create_control(sizeof(slider_t), id, x, y, w, h, parent); |
|
- | 605 | sld->ctrl.handler = sld_proc; |
|
- | 606 | ||
- | 607 | sld->min = -5000; |
|
- | 608 | sld->max = 0; |
|
- | 609 | sld->current = 0; |
|
- | 610 | sld->pos = 60; |
|
- | 611 | sld->mode = 0; |