예제 #1
0
파일: window.c 프로젝트: zdgaoyu/RTGUI
void rtgui_win_end_modal(struct rtgui_win* win, rtgui_modal_code_t modal_code)
{
	if (win == RT_NULL || !(win->flag & RTGUI_WIN_FLAG_MODAL))
		return;

	rtgui_app_exit(rtgui_app_self(), modal_code);

	/* remove modal mode */
	win->flag &= ~RTGUI_WIN_FLAG_MODAL;
}
예제 #2
0
파일: rtgui_app.c 프로젝트: zdgaoyu/RTGUI
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);
}
예제 #3
0
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_VPAINT_REQ:
    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_WIN_SHOW:
    case RTGUI_EVENT_WIN_HIDE:
    case RTGUI_EVENT_KBD:
    case RTGUI_EVENT_GESTURE:
        _rtgui_application_dest_handle(app, event);
        break;

    case RTGUI_EVENT_APP_ACTIVATE:
        if (app->main_object != RT_NULL)
        {
            /* Let the polymorphism work. */
            struct rtgui_event_win_show wev;

            RTGUI_EVENT_WIN_SHOW_INIT(&wev);
            wev.wid = (struct rtgui_win*)app->main_object;

            rtgui_object_handle(app->main_object, &wev.parent);
        }
        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;
        timer->pending_cnt--;
        RT_ASSERT(timer->pending_cnt >= 0);
        if (timer->state == RTGUI_TIMER_ST_DESTROY_PENDING)
        {
            /* Truly destroy the timer when there is no pending event. */
            if (timer->pending_cnt == 0)
                rtgui_timer_destory(timer);
        }
        else if (timer->state == RTGUI_TIMER_ST_RUNNING && 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;
}
예제 #4
0
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;
}