/* 触发正常窗口显示 */ static void demo_normal_window_onbutton(struct rtgui_object *object, rtgui_event_t *event) { rt_sprintf(normal_window_label_text, "第 %d 次显示", normal_window_show_count); rtgui_label_set_text(normal_window_label, normal_window_label_text); if (RTGUI_WIDGET_IS_HIDE(normal_window)) rtgui_win_show(normal_window, RT_FALSE); else rtgui_win_activate(normal_window); }
rt_bool_t rtgui_app_event_handler(struct rtgui_object* object, rtgui_event_t* event) { struct rtgui_app* app; RT_ASSERT(object != RT_NULL); RT_ASSERT(event != RT_NULL); app = RTGUI_APP(object); switch (event->type) { case RTGUI_EVENT_PAINT: case RTGUI_EVENT_CLIP_INFO: case RTGUI_EVENT_WIN_ACTIVATE: case RTGUI_EVENT_WIN_DEACTIVATE: case RTGUI_EVENT_WIN_CLOSE: case RTGUI_EVENT_WIN_MOVE: case RTGUI_EVENT_KBD: _rtgui_application_dest_handle(app, event); break; case RTGUI_EVENT_APP_ACTIVATE: if (app->main_object != RT_NULL) { rtgui_win_activate(RTGUI_WIN(app->main_object)); if (app->modal_object != RT_NULL) rtgui_win_activate(RTGUI_WIN(app->modal_object)); } else if (app->modal_object != RT_NULL) { rtgui_win_activate(RTGUI_WIN(app->modal_object)); } break; case RTGUI_EVENT_APP_DESTROY: rtgui_app_exit(app, 0); break; case RTGUI_EVENT_MOUSE_BUTTON: case RTGUI_EVENT_MOUSE_MOTION: { struct rtgui_event_win* wevent = (struct rtgui_event_win*)event; struct rtgui_object* dest_object = RTGUI_OBJECT(wevent->wid); // FIXME: let application determine the dest_wiget but not in sever // so we can combine this handler with above one if (app->modal_object != RT_NULL && dest_object != app->modal_object) { // rt_kprintf("discard event %s that is not sent to modal object\n", // event_string[event->type]); } else { _rtgui_application_dest_handle(app, event); } } break; case RTGUI_EVENT_TIMER: { struct rtgui_timer* timer; struct rtgui_event_timer* etimer = (struct rtgui_event_timer*) event; timer = etimer->timer; if (timer->timeout != RT_NULL) { /* call timeout function */ timer->timeout(timer, timer->user_data); } } break; case RTGUI_EVENT_COMMAND: { struct rtgui_event_command *ecmd = (struct rtgui_event_command*)event; if (ecmd->wid != RT_NULL) return _rtgui_application_dest_handle(app, event); } } return rtgui_object_event_handler(object, event); }
rt_bool_t rtgui_app_event_handler(struct rtgui_object *object, rtgui_event_t *event) { struct rtgui_app *app; RT_ASSERT(object != RT_NULL); RT_ASSERT(event != RT_NULL); app = RTGUI_APP(object); switch (event->type) { case RTGUI_EVENT_PAINT: case RTGUI_EVENT_MOUSE_BUTTON: case RTGUI_EVENT_MOUSE_MOTION: case RTGUI_EVENT_CLIP_INFO: case RTGUI_EVENT_WIN_ACTIVATE: case RTGUI_EVENT_WIN_DEACTIVATE: case RTGUI_EVENT_WIN_CLOSE: case RTGUI_EVENT_WIN_MOVE: case RTGUI_EVENT_KBD: _rtgui_application_dest_handle(app, event); break; case RTGUI_EVENT_APP_ACTIVATE: if (app->main_object != RT_NULL) { rtgui_win_activate(RTGUI_WIN(app->main_object)); } break; case RTGUI_EVENT_APP_DESTROY: rtgui_app_exit(app, 0); break; case RTGUI_EVENT_TIMER: { struct rtgui_timer *timer; struct rtgui_event_timer *etimer = (struct rtgui_event_timer *) event; timer = etimer->timer; if (timer->timeout != RT_NULL) { /* call timeout function */ timer->timeout(timer, timer->user_data); } } break; case RTGUI_EVENT_MV_MODEL: { struct rtgui_event_mv_model *emodel = (struct rtgui_event_mv_model *)event; RT_ASSERT(emodel->view); return rtgui_object_handle(RTGUI_OBJECT(emodel->view), event); } case RTGUI_EVENT_COMMAND: { struct rtgui_event_command *ecmd = (struct rtgui_event_command *)event; if (ecmd->wid != RT_NULL) return _rtgui_application_dest_handle(app, event); } default: return rtgui_object_event_handler(object, event); } return RT_TRUE; }