Rev 6133 | 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 | |||
9 | |||
10 | static int draw_window(window_t *win); |
||
11 | |||
12 | |||
13 | uint32_t cursor_ns; |
||
14 | uint32_t cursor_we; |
||
15 | uint32_t cursor_nwse; |
||
16 | uint32_t cursor_nesw; |
||
17 | |||
18 | |||
19 | |||
20 | |||
4446 | Serge | 21 | |
4438 | Serge | 22 | |
23 | |||
24 | |||
25 | |||
26 | |||
4446 | Serge | 27 | static uint32_t realtime; |
4438 | Serge | 28 | static uint32_t wait_time; |
29 | static uint32_t exp_time; |
||
30 | |||
31 | |||
32 | |||
33 | |||
34 | |||
35 | |||
36 | |||
37 | void blit_panel(panel_t *panel); |
||
6133 | serge | 38 | void update_panel_size(window_t *win); |
39 | void update_caption_size(window_t *win); |
||
40 | int init_fontlib(); |
||
6144 | serge | 41 | |
4438 | Serge | 42 | |
4446 | Serge | 43 | ctrl_t *win_get_child(window_t *win, int x, int y) |
44 | { |
||
45 | ctrl_t *child = NULL; |
||
46 | |||
4438 | Serge | 47 | |
4446 | Serge | 48 | { |
49 | if(pt_in_rect(&win->client, x, y)) |
||
50 | { |
||
51 | ctrl_t *tmp = (ctrl_t*)win->child.next; |
||
52 | |||
4438 | Serge | 53 | |
4446 | Serge | 54 | { |
55 | if(pt_in_rect(&tmp->rc, x, y)) |
||
56 | { |
||
57 | child = get_child(tmp, x, y); |
||
58 | return child == NULL ? tmp : child; |
||
59 | }; |
||
60 | tmp = (ctrl_t*)tmp->link.next; |
||
61 | }; |
||
62 | } |
||
63 | else child = (ctrl_t*)(&win->frame); |
||
64 | }; |
||
65 | return child; |
||
66 | }; |
||
67 | |||
4438 | Serge | 68 | |
69 | |||
70 | |||
71 | |||
72 | int w, int h, handler_t handler) |
||
73 | { |
||
74 | char proc_info[1024]; |
||
75 | int stride; |
||
76 | |||
77 | |||
78 | |||
79 | |||
80 | |||
81 | |||
82 | |||
83 | |||
84 | |||
85 | DrawWindow(x, y, w, h, |
||
5372 | serge | 86 | NULL,0,0x41); |
4438 | Serge | 87 | EndDraw(); |
88 | |||
89 | |||
90 | |||
91 | |||
92 | y = *(uint32_t*)(proc_info+38); |
||
93 | w = *(uint32_t*)(proc_info+42)+1; |
||
94 | h = *(uint32_t*)(proc_info+46)+1; |
||
95 | |||
96 | |||
97 | // Window.ctx = ctx; |
||
98 | |||
99 | |||
100 | list_initialize(&Window.child); |
||
101 | |||
102 | |||
103 | |||
104 | // Window.bitmap.height = 1080; |
||
105 | // Window.bitmap.flags = 0; |
||
106 | |||
107 | |||
108 | // { |
||
109 | // printf("not enough memory for window bitmap\n"); |
||
110 | // return 0; |
||
111 | // } |
||
112 | |||
113 | |||
114 | // ctx->offset_x = 0; |
||
115 | // ctx->offset_y = 0; |
||
116 | |||
117 | |||
118 | Window.rc.t = y; |
||
119 | Window.rc.r = x + w; |
||
120 | Window.rc.b = y + h; |
||
121 | |||
122 | |||
123 | Window.h = h; |
||
124 | |||
125 | |||
126 | Window.style = style; |
||
127 | |||
128 | |||
129 | Window.child_focus = NULL; |
||
130 | |||
131 | |||
132 | init_panel(&Window); |
||
133 | init_frame(&Window); |
||
134 | send_message((ctrl_t*)&Window, MSG_SIZE, 0, 0); |
||
135 | return &Window; |
||
136 | }; |
||
137 | |||
138 | |||
139 | |||
140 | { |
||
141 | ctrl_t *child; |
||
142 | |||
143 | |||
144 | |||
145 | |||
146 | { |
||
147 | case MSG_PAINT: |
||
148 | draw_window(win); |
||
149 | break; |
||
150 | |||
151 | |||
152 | child = (ctrl_t*)win->child.next; |
||
153 | while( &child->link != &win->child) |
||
154 | { |
||
155 | send_message(child, 2, arg1, arg2); |
||
156 | child = (ctrl_t*)child->link.next; |
||
157 | }; |
||
158 | break; |
||
159 | |||
160 | |||
161 | child = win_get_child(win, arg2 & 0xFFFF, (arg2>>16)); |
||
162 | if( win->child_over ) |
||
163 | { |
||
164 | if(child == win->child_over) |
||
165 | send_message(child, msg, 0, arg2); |
||
166 | else |
||
167 | send_message(win->child_over, MSG_MOUSELEAVE, 0, arg2); |
||
168 | } |
||
169 | else if( child ) |
||
170 | send_message(child, MSG_MOUSEENTER, 0, arg2); |
||
171 | |||
172 | |||
173 | if( child ) |
||
174 | send_message(child,msg,0,arg2); |
||
175 | else if(main_cursor != 0) |
||
176 | { |
||
177 | set_cursor(0); |
||
178 | main_cursor = 0; |
||
179 | } |
||
180 | break; |
||
181 | |||
182 | |||
183 | break; |
||
184 | |||
185 | |||
186 | child = win_get_child(win, arg2 & 0xFFFF, (arg2>>16)); |
||
187 | win->child_over = child; |
||
188 | if(child) send_message(child, msg, 0, arg2); |
||
189 | }; |
||
190 | |||
191 | |||
192 | } |
||
193 | |||
194 | |||
195 | { |
||
196 | ctrl_t *child; |
||
197 | void *ctx; |
||
198 | rect_t *rc = &win->client; |
||
199 | |||
200 | |||
201 | draw_panel(&win->panel); |
||
202 | send_message(win, MSG_DRAW_CLIENT,0,0); |
||
203 | |||
204 | |||
205 | |||
206 | |||
207 | |||
208 | |||
209 | // { |
||
210 | // send_message(child, 1, 0, 0); |
||
211 | // child = (ctrl_t*)child->link.next; |
||
212 | // }; |
||
213 | |||
214 | |||
215 | }; |
||
216 | |||
217 | |||
218 | { |
||
219 | ctx_t *ctx = &win->ctx; |
||
5372 | serge | 220 | int w, h; |
4438 | Serge | 221 | |
222 | |||
223 | h = win->client.b - win->client.t; |
||
224 | |||
225 | |||
5372 | serge | 226 | 0, 0, w, h, w, h, ctx->pixmap_pitch); |
227 | }; |
||
4438 | Serge | 228 | |
229 | |||
230 | |||
231 | { |
||
232 | win->win_state = state; |
||
233 | |||
234 | |||
235 | |||
236 | |||
237 | DrawWindow(win->rc.l, win->rc.t, win->w-1, win->h-1, |
||
238 | NULL,0,0x41); |
||
239 | EndDraw(); |
||
240 | |||
241 | |||
242 | blit_panel(&win->panel); |
||
243 | // blit_client(win); |
||
244 | return 0; |
||
245 | } |
||
246 | |||
247 | |||
248 | { |
||
249 | char proc_info[1024]; |
||
250 | |||
251 | |||
252 | uint8_t state; |
||
253 | |||
254 | |||
255 | |||
256 | |||
257 | |||
258 | |||
259 | |||
260 | |||
261 | winy = *(uint32_t*)(proc_info+38); |
||
262 | winw = *(uint32_t*)(proc_info+42)+1; |
||
263 | winh = *(uint32_t*)(proc_info+46)+1; |
||
264 | |||
265 | |||
266 | |||
267 | |||
268 | { win->win_state = MINIMIZED; |
||
269 | return; |
||
270 | } |
||
271 | if(state & 4) |
||
272 | { |
||
273 | win->win_state = ROLLED; |
||
274 | return; |
||
275 | }; |
||
276 | |||
277 | |||
278 | state = MAXIMIZED; |
||
279 | else |
||
280 | state = NORMAL; |
||
281 | |||
282 | |||
283 | { |
||
284 | win->rc.l = winx; |
||
285 | win->rc.t = winy; |
||
286 | win->rc.r = winx + win->w; |
||
287 | win->rc.b = winy + win->h; |
||
288 | }; |
||
289 | |||
290 | |||
291 | // winh == win->h && |
||
292 | // state == win->win_state) |
||
293 | // return; |
||
294 | |||
295 | |||
296 | win->win_state = state; |
||
297 | |||
298 | |||
299 | int old_size; |
||
300 | int new_size; |
||
301 | int pitch; |
||
302 | |||
303 | |||
304 | |||
305 | old_size = (old_size+4095) & ~4095; |
||
306 | |||
307 | |||
308 | |||
309 | |||
310 | new_size = (new_size+4095) & ~4095; |
||
311 | |||
312 | |||
313 | user_unmap(win->bitmap.data, new_size, old_size-new_size); |
||
314 | |||
315 | |||
316 | win->bitmap.pitch = pitch; |
||
317 | #endif |
||
318 | |||
319 | |||
320 | win->rc.b = winy + winh; |
||
321 | win->w = winw; |
||
322 | win->h = winh; |
||
323 | |||
324 | |||
325 | update_panel_size(win); |
||
326 | adjust_frame(win); |
||
327 | |||
328 | |||
329 | draw_window(win); |
||
330 | }; |
||
331 | |||
332 | |||
333 | |||
334 | { |
||
335 | ctrl_t *child; |
||
336 | |||
337 | |||
338 | return send_message(mouse_capture, msg, 0, old_pos.val); |
||
339 | |||
340 | |||
341 | return send_message((ctrl_t*)win, msg, 0, old_pos.val); |
||
342 | |||
343 | |||
344 | return 0; |
||
345 | |||
346 | |||
347 | { |
||
348 | return send_message(&win->caption.ctrl, msg, 0, old_pos.val); |
||
349 | } |
||
350 | |||
351 | |||
352 | { |
||
353 | // old_pos.x-= win->panel.ctrl.rc.l; |
||
354 | // old_pos.y-= win->panel.ctrl.rc.t; |
||
355 | return send_message(&win->panel.ctrl, msg, 0, old_pos.val); |
||
356 | } |
||
357 | |||
358 | |||
359 | |||
360 | |||
361 | |||
362 | // send_message((ctrl_t*)win, msg, 0, old_pos.val); |
||
363 | }; |
||
364 | |||
365 | |||
366 | { |
||
367 | // printf("%s win:%x\n", __FUNCTION__, win); |
||
368 | |||
369 | |||
370 | |||
371 | |||
372 | DrawWindow(0,0,0,0, NULL, 0x000000,0x41); |
||
373 | EndDraw(); |
||
374 | |||
375 | |||
376 | |||
377 | |||
378 | { |
||
379 | need_update=0; |
||
380 | return; |
||
381 | }; |
||
382 | |||
383 | |||
384 | blit_panel(&win->panel); |
||
385 | |||
386 | |||
387 | need_update=0; |
||
388 | }; |
||
389 | |||
390 | |||
391 | { |
||
392 | static uint32_t mouse_click_time; |
||
393 | static int mouse_action; |
||
394 | static int old_buttons; |
||
395 | int buttons; |
||
396 | uint32_t wheels; |
||
397 | uint32_t click_time; |
||
398 | int action; |
||
399 | |||
400 | |||
401 | |||
402 | |||
403 | pos = GetMousePos(POS_WINDOW); |
||
5061 | serge | 404 | |
4438 | Serge | 405 | |
406 | { |
||
407 | mouse_action = 0x80000000; |
||
408 | old_pos = pos; |
||
409 | }; |
||
410 | // printf("pos x%d y%d\n", pos.x, pos.y); |
||
411 | |||
412 | |||
5061 | serge | 413 | wheels = get_mouse_wheels(); |
4438 | Serge | 414 | |
415 | |||
416 | wheels = (short)wheels>0 ? MSG_WHEELDOWN : MSG_WHEELUP; |
||
417 | send_mouse_message(win, wheels); |
||
418 | } |
||
419 | |||
420 | |||
421 | { |
||
422 | mouse_action|= action<<3; |
||
423 | mouse_action|= buttons & ~old_buttons; |
||
424 | } |
||
425 | old_buttons = buttons; |
||
426 | |||
427 | |||
428 | DBG("mouse move \n\r"); |
||
429 | send_mouse_message(win, MSG_MOUSEMOVE); |
||
430 | }; |
||
431 | |||
432 | |||
433 | { |
||
434 | if((mouse_action & 0x09)==0x09) |
||
435 | { |
||
436 | // printf("left button down x= %d y= %d\n\r", old_x.x, old_x.y); |
||
437 | click_time = get_tick_count(); |
||
438 | if(click_time < mouse_click_time+35) { |
||
439 | mouse_click_time = click_time; |
||
440 | send_mouse_message(win,MSG_LBTNDBLCLK); |
||
441 | } |
||
442 | else { |
||
443 | mouse_click_time = click_time; |
||
444 | send_mouse_message(win,MSG_LBTNDOWN); |
||
445 | }; |
||
446 | } |
||
447 | else { |
||
448 | // printf("left button up \n\r"); |
||
449 | send_mouse_message(win,MSG_LBTNUP); |
||
450 | } |
||
451 | }; |
||
452 | |||
453 | |||
454 | { |
||
455 | if((mouse_action & 0x12)==0x12) { |
||
456 | DBG("right button down \n\r"); |
||
457 | send_mouse_message(win,MSG_RBTNDOWN); |
||
458 | } |
||
459 | else { |
||
460 | DBG("right button up \n\r"); |
||
461 | send_mouse_message(win,MSG_RBTNUP); |
||
462 | }; |
||
463 | }; |
||
464 | if(mouse_action & 0x24) |
||
465 | { |
||
466 | if((mouse_action & 0x24)==0x24){ |
||
467 | DBG("middle button down \n\r"); |
||
468 | send_mouse_message(win,MSG_MBTNDOWN); |
||
469 | } |
||
470 | else { |
||
471 | DBG("middle button up \n\r"); |
||
472 | send_mouse_message(win,MSG_MBTNUP); |
||
473 | }; |
||
474 | }; |
||
475 | |||
476 | |||
477 | |||
478 | |||
479 | |||
480 | |||
481 | { |
||
482 | int ev; |
||
483 | oskey_t key; |
||
484 | |||
485 | |||
486 | // wheels = get_mouse_wheels(); |
||
487 | realtime = get_tick_count(); |
||
488 | exp_time = -1; |
||
489 | |||
490 | |||
491 | { |
||
492 | wait_time = exp_time - realtime; |
||
493 | |||
494 | |||
495 | |||
496 | |||
497 | |||
498 | |||
499 | // exp_time = update_timers(realtime); |
||
500 | |||
501 | |||
502 | { |
||
503 | case MSG_PAINT: |
||
504 | do_sys_draw(win); |
||
505 | continue; |
||
506 | |||
507 | |||
508 | printf("key pressed\n"); |
||
509 | key = get_key(); |
||
510 | if( key.state == 0) |
||
511 | send_message((ctrl_t*)win, ev, 0, key.code); |
||
512 | continue; |
||
513 | |||
514 | |||
515 | printf("Button pressed\n"); |
||
516 | continue; |
||
517 | |||
518 | |||
519 | do_sys_mouse(win); |
||
520 | continue; |
||
521 | |||
522 | |||
523 | printf("event %d\n", ev); |
||
524 | continue; |
||
525 | }; |
||
526 | }; |
||
527 | } |
||
528 | |||
529 | |||
530 | |||
531 | |||
532 | { |
||
533 | int ev; |
||
534 | oskey_t key; |
||
535 | int button; |
||
536 | |||
537 | |||
538 | exp_time = -1; |
||
539 | |||
540 | |||
541 | { |
||
542 | wait_time = exp_time - realtime; |
||
543 | |||
544 | |||
545 | |||
546 | |||
547 | |||
548 | |||
549 | // exp_time = update_timers(realtime); |
||
550 | |||
551 | |||
552 | { |
||
553 | case MSG_PAINT: |
||
554 | do_sys_draw(win); |
||
555 | break; |
||
556 | |||
557 | |||
558 | key = get_key(); |
||
559 | if( key.state == 0) |
||
560 | send_message((ctrl_t*)win, ev, 0, key.code); |
||
561 | break; |
||
562 | |||
563 | |||
564 | button = get_os_button(); |
||
565 | if(button == 1) |
||
566 | win->win_command = WIN_CLOSED; |
||
567 | break; |
||
568 | |||
569 | |||
570 | do_sys_mouse(win); |
||
571 | break; |
||
572 | |||
573 | |||
574 | break; |
||
575 | }; |
||
576 | |||
577 | |||
578 | }; |
||
579 | }; |
||
580 | |||
581 | |||
582 | |||
583 | |||
584 | extern unsigned char res_cursor_we[]; |
||
585 | extern unsigned char res_cursor_nwse[]; |
||
586 | extern unsigned char res_cursor_nesw[]; |
||
587 | |||
588 | |||
589 | { |
||
590 | cursor_ns = load_cursor(res_cursor_ns, LOAD_FROM_MEM); |
||
591 | cursor_we = load_cursor(res_cursor_we, LOAD_FROM_MEM); |
||
592 | cursor_nwse = load_cursor(res_cursor_nwse, LOAD_FROM_MEM); |
||
593 | cursor_nesw = load_cursor(res_cursor_nesw, LOAD_FROM_MEM); |
||
594 | |||
595 | |||
596 | |||
597 | |||
598 | } |
||
599 | |||
600 | |||
601 | { |
||
602 | int ret; |
||
603 | |||
604 | |||
605 | ret |= destroy_cursor(cursor_nwse); |
||
606 | ret |= destroy_cursor(cursor_we); |
||
607 | ret |= destroy_cursor(cursor_ns); |
||
608 | |||
609 | |||
610 | }; |
||
611 | |||
612 | |||
613 | |||
614 | |||
615 | { |
||
616 | __asm__ __volatile__( |
||
617 | "int $0x40" |
||
618 | ::"a"(40), "b"(0xC0000027)); |
||
619 | __asm__ __volatile__( |
||
620 | "int $0x40" |
||
621 | ::"a"(66), "b"(1),"c"(1)); |
||
622 | |||
623 | |||
624 | list_initialize(&timers); |
||
625 | }; |
||
626 | |||
627 | |||
628 | //{ |
||
629 | // return &Window.client_ctx; |
||
630 | //}; |
||
631 | |||
632 | |||
633 | { |
||
634 | ctx_t *ctx = ctrl->ctx; |
||
5372 | serge | 635 | |
636 | |||
4438 | Serge | 637 | int src_x, src_y; |
638 | |||
639 | |||
640 | src_y = ctrl->rc.t - ctrl->ctx->offset_y; |
||
641 | |||
642 | |||
643 | ctx_h = ctrl->parent->h; |
||
644 | |||
645 | |||
5372 | serge | 646 | ctrl->w, ctrl->h, ctx_w, ctx_h, ctx->pixmap_pitch); |
647 | |||
4438 | Serge | 648 | |
649 | }; |
||
650 | |||
651 | |||
652 | { |
||
653 | ctrl_t *child = NULL; |
||
654 | |||
655 | |||
656 | |||
657 | |||
658 | { |
||
659 | if(pt_in_rect(&tmp->rc, x, y)) |
||
660 | { |
||
661 | child = get_child(tmp, x, y); |
||
662 | return child == NULL ? tmp : child; |
||
663 | }; |
||
664 | tmp = (ctrl_t*)tmp->link.next; |
||
665 | }; |
||
666 | return child; |
||
667 | }; |
||
668 | |||
669 | |||
670 | { |
||
671 | ctrl_t *old = mouse_capture; |
||
672 | |||
673 | |||
674 | |||
675 | |||
676 | "int $0x40" |
||
677 | ::"a"(40), "b"(0x80000027)); |
||
678 | |||
679 | |||
680 | } |
||
681 | |||
682 | |||
683 | { |
||
684 | mouse_capture = NULL; |
||
685 | __asm__ __volatile__( |
||
686 | "int $0x40" |
||
687 | ::"a"(40), "b"(0xC0000027)); |
||
688 | }>>>3; |
||
689 | ><3; |