678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840
| rt_bool_t rtgui_win_event_handler(struct rtgui_object *object, struct rtgui_event *event) { struct rtgui_win *win;
RT_ASSERT(object != RT_NULL); RT_ASSERT(event != RT_NULL);
win = RTGUI_WIN(object);
switch (event->type) { case RTGUI_EVENT_WIN_SHOW: rtgui_win_do_show(win); break;
case RTGUI_EVENT_WIN_HIDE: rtgui_win_hide(win); break;
case RTGUI_EVENT_WIN_CLOSE: _rtgui_win_deal_close(win, event, RT_FALSE); return RT_TRUE;
case RTGUI_EVENT_WIN_MOVE: { struct rtgui_event_win_move *emove = (struct rtgui_event_win_move *)event;
rtgui_win_move(win, emove->x, emove->y); } break;
case RTGUI_EVENT_WIN_ACTIVATE: if (win->flag & RTGUI_WIN_FLAG_UNDER_MODAL || RTGUI_WIDGET_IS_HIDE(win)) { return RT_TRUE; }
win->flag |= RTGUI_WIN_FLAG_ACTIVATE;
if (win->_title_wgt) rtgui_widget_update(RTGUI_WIDGET(win->_title_wgt));
if (win->on_activate != RT_NULL) { win->on_activate(RTGUI_OBJECT(object), event); } break;
case RTGUI_EVENT_WIN_DEACTIVATE: win->flag &= ~RTGUI_WIN_FLAG_ACTIVATE;
if (win->_title_wgt) rtgui_widget_update(RTGUI_WIDGET(win->_title_wgt));
if (win->on_deactivate != RT_NULL) win->on_deactivate(RTGUI_OBJECT(object), event);
break;
case RTGUI_EVENT_WIN_UPDATE_END: break;
case RTGUI_EVENT_CLIP_INFO: rtgui_win_update_clip(win); break;
case RTGUI_EVENT_PAINT: if (win->_title_wgt) rtgui_widget_update(RTGUI_WIDGET(win->_title_wgt)); rtgui_win_ondraw(win); break;
#ifdef GUIENGIN_USING_VFRAMEBUFFER case RTGUI_EVENT_VPAINT_REQ: { struct rtgui_event_vpaint_req *req = (struct rtgui_event_vpaint_req *)event; struct rtgui_dc *dc;
dc = rtgui_win_get_drawing(win);
req->sender->buffer = dc; rt_completion_done(req->sender->cmp);
break; } #endif
case RTGUI_EVENT_MOUSE_BUTTON: { struct rtgui_event_mouse *emouse = (struct rtgui_event_mouse*)event;
if (rtgui_rect_contains_point(&RTGUI_WIDGET(win)->extent, emouse->x, emouse->y) == RT_EOK) return _win_handle_mouse_btn(win, event);
if (win->_title_wgt) { struct rtgui_object *tobj = RTGUI_OBJECT(win->_title_wgt); return tobj->event_handler(tobj, event); } } break;
case RTGUI_EVENT_MOUSE_MOTION: return rtgui_container_dispatch_mouse_event(RTGUI_CONTAINER(win), (struct rtgui_event_mouse *)event);
case RTGUI_EVENT_KBD: if (!(win->flag & RTGUI_WIN_FLAG_HANDLE_KEY)) { struct rtgui_widget *widget; rt_bool_t res = RT_FALSE;
win->flag |= RTGUI_WIN_FLAG_HANDLE_KEY;
for (widget = win->focused_widget; widget && !res; widget = widget->parent) { if (RTGUI_OBJECT(widget)->event_handler != RT_NULL) res = RTGUI_OBJECT(widget)->event_handler( RTGUI_OBJECT(widget), event); }
win->flag &= ~RTGUI_WIN_FLAG_HANDLE_KEY; return res; } else {
if (win->on_key != RT_NULL) return win->on_key(RTGUI_OBJECT(win), event); } break;
case RTGUI_EVENT_COMMAND: if (rtgui_container_dispatch_event(RTGUI_CONTAINER(object), event) != RT_TRUE) { } else return RT_TRUE; break;
default: return rtgui_container_event_handler(object, event); }
return RT_FALSE; } RTM_EXPORT(rtgui_win_event_handler);
|