Beispiel #1
0
//does a timer event
static int _do_timer_event(AWE_EVENT *event)
{
    AWE_WIDGET *wgt = (AWE_WIDGET *)event->timer.data;
    if (!wgt) return 0;
    _DO(wgt, timer, (wgt, event));
    return 1;
}
Beispiel #2
0
int object_cmp(kv_t *k1, kv_t *k2)
{
	assert(k1->t == k2->t);
	assert (TKVOBJECT== k1->t);

	kvobj_t *o1;
	kvobj_t *o2;
	o1 = _DO(k1);
	o2 = _DO(k2);
	
	if (NULL != o1->cmp)
	{
		return o1->cmp(o1, o2);
	}
	else		
		return _DO(k1) - _DO(k2);
}
Beispiel #3
0
void object_print(kv_t *kv)
{
	assert (TKVOBJECT== kv->t);
	kvobj_t *kvobj;
	kvobj = _DO(kv);
	if (NULL != kvobj->print)
	{
		kvobj->print(kvobj);
	}
	else
		KVPRINT("object: %08x", (unsigned int)kvobj);
}
Beispiel #4
0
void object_free(kv_t *kv)
{
	assert (TKVOBJECT== kv->t);
	kvobj_t *kvobj;
	kvobj = _DO(kv);
	
	if (NULL != kvobj->free)
	{
		kvobj->free(kvobj);
	}

	FREE(kvobj);
}
Beispiel #5
0
//grab event procedure
int awe_grab_event_proc(AWE_EVENT_MODE_ACTION_TYPE action, AWE_EVENT *event, void *data)
{
    AWE_WIDGET *wgt;
    int p, c;

    //only the 'do event' action is interesting
    if (!event) return 0;

    //'grab widget' is stored in 'data'
    wgt = (AWE_WIDGET *)data;
    if (!wgt) return 0;

    switch (event->type) {
        //button down event
        case AWE_EVENT_BUTTON_DOWN:
            _DO_MOUSE_EVENT(wgt, button_down, event);
            _last_x = event->mouse.x;
            _last_y = event->mouse.y;
            return 1;

        //button up event
        case AWE_EVENT_BUTTON_UP:
            _DO_MOUSE_EVENT(wgt, button_up, event);
            _last_x = event->mouse.x;
            _last_y = event->mouse.y;
            return 1;

        //mouse moved event
        case AWE_EVENT_MOUSE_MOVE:
            p = _widget_includes_point(wgt, _last_x, _last_y);
            c = _widget_includes_point(wgt, event->mouse.x, event->mouse.y);
            if (p == c) {
                _DO_MOUSE_EVENT(wgt, mouse_move, event)
            }
            else if (c) {
                if (wgt) wgt->has_mouse = 1;
                _DO_MOUSE_EVENT(wgt, mouse_enter, event)
            }
            else {
                if (wgt) wgt->has_mouse = 0;
                _DO_MOUSE_EVENT(wgt, mouse_leave, event);
            }
            _last_x = event->mouse.x;
            _last_y = event->mouse.y;
            return 1;

        //mouse wheel event
        case AWE_EVENT_MOUSE_WHEEL:
            _DO_MOUSE_EVENT(wgt, mouse_wheel, event);
            _last_x = event->mouse.x;
            _last_y = event->mouse.y;
            return 1;

        //key down
        case AWE_EVENT_KEY_DOWN:
            _DO(wgt, key_down, (wgt, event));
            return 1;

        //key press
        case AWE_EVENT_KEY_UP:
            _DO(wgt, key_up, (wgt, event));
            return 1;

        //timer event
        case AWE_EVENT_TIMER:
            return _do_timer_event(event);

        //no event
        case AWE_EVENT_NONE:
            return 0;
    }
Beispiel #6
0
//does an event, starting from given 'root'
static int _do_event(AWE_WIDGET *root, AWE_EVENT *event, int force)
{
    AWE_WIDGET *curr, *prev, *focus;

    switch (event->type) {
        //button down event
        case AWE_EVENT_BUTTON_DOWN:
            curr = _widget_from_point(root, event->mouse.x, event->mouse.y);
            if (!curr) {
                if (!force) return 0;
                curr = root;
            }
            _DO_MOUSE_EVENT(curr, button_down, event);
            _last_x = event->mouse.x;
            _last_y = event->mouse.y;
            return 1;

        //button up event
        case AWE_EVENT_BUTTON_UP:
            curr = _widget_from_point(root, event->mouse.x, event->mouse.y);
            if (!curr) {
                if (!force) return 0;
                curr = root;
            }
            _DO_MOUSE_EVENT(curr, button_up, event);
            _last_x = event->mouse.x;
            _last_y = event->mouse.y;
            return 0;

        //mouse moved event
        case AWE_EVENT_MOUSE_MOVE:
            prev = _widget_from_point(root, _last_x, _last_y);
            curr = _widget_from_point(root, event->mouse.x, event->mouse.y);
            if (prev == 0 && curr == 0) {
                if (!force) {
                    _last_x = event->mouse.x;
                    _last_y = event->mouse.y;
                    return 0;
                }
                curr = prev = root;
            }
            if (prev != curr) {
                if (prev) prev->has_mouse = 0;
                if (curr) curr->has_mouse = 1;
                _DO_MOUSE_EVENT(prev, mouse_leave, event);
                _DO_MOUSE_EVENT(curr, mouse_enter, event);
            }
            else _DO_MOUSE_EVENT(curr, mouse_move, event);
            _last_x = event->mouse.x;
            _last_y = event->mouse.y;
            return 1;

        //mouse wheel event
        case AWE_EVENT_MOUSE_WHEEL:
            focus = awe_get_focus_widget();
            if (!focus) {
                if (!force) return 0;
                focus = root;
            }
            _DO_MOUSE_EVENT(focus, mouse_wheel, event);
            _last_x = event->mouse.x;
            _last_y = event->mouse.y;
            return 1;

        //key down
        case AWE_EVENT_KEY_DOWN:
            focus = awe_get_focus_widget();
            if (!focus) {
                if (!force) return 0;
                focus = root;
            }
            _DO(focus, key_down, (focus, event));
            return 1;

        //key press
        case AWE_EVENT_KEY_UP:
            focus = awe_get_focus_widget();
            if (!focus) {
                if (!force) return 0;
                focus = root;
            }
            _DO(focus, key_up, (focus, event));
            return 1;

        //timer event
        case AWE_EVENT_TIMER:
            return _do_timer_event(event);

        //no event
        case AWE_EVENT_NONE:
            return 0;
    }

    return 0;
}