Exemple #1
0
static void
KeyUp(AG_Event *event)
{
	AG_Button *bu = AG_SELF();
	AG_Variable *binding;
	void *pState;
	int keysym = AG_INT(1);
	
	if (AG_WidgetDisabled(bu)) {
		return;
	}
	if (bu->flags & AG_BUTTON_REPEAT) {
		AG_DelTimer(bu, &bu->delayTo);
		AG_DelTimer(bu, &bu->repeatTo);
	}
	if (keysym != AG_KEY_RETURN &&		/* TODO AG_Action */
	    keysym != AG_KEY_KP_ENTER &&
	    keysym != AG_KEY_SPACE) {
		return;
	}
	binding = AG_GetVariable(bu, "state", &pState);
	SetState(bu, binding, pState, 0);
	AG_UnlockVariable(binding);

	if (bu->flags & AG_BUTTON_KEYDOWN) {
		bu->flags &= ~(AG_BUTTON_KEYDOWN);
		AG_PostEvent(NULL, bu, "button-pushed", "%i", 0);
	}
}
Exemple #2
0
static void
MouseButtonUp(AG_Event *event)
{
	AG_Button *bu = AG_SELF();
	int button = AG_INT(1);
	AG_Variable *binding;
	void *pState;
	int x = AG_INT(2);
	int y = AG_INT(3);
		
	if (bu->flags & AG_BUTTON_REPEAT) {
		AG_DelTimer(bu, &bu->repeatTo);
		AG_DelTimer(bu, &bu->delayTo);
		return;
	}
	
	if (AG_WidgetDisabled(bu) ||
	    x < 0 || y < 0 ||
	    x > WIDGET(bu)->w || y > WIDGET(bu)->h) {
		return;
	}
	
	binding = AG_GetVariable(bu, "state", &pState);
	if (GetState(bu, binding, pState) && button == AG_MOUSE_LEFT &&
	    !(bu->flags & AG_BUTTON_STICKY)) {
	    	SetState(bu, binding, pState, 0);
		AG_PostEvent(NULL, bu, "button-pushed", "%i", 0);
	}
	AG_UnlockVariable(binding);
}
Exemple #3
0
void
AG_ButtonSetRepeatMode(AG_Button *bu, int repeat)
{
	AG_ObjectLock(bu);
	if (repeat) {
		bu->flags |= (AG_BUTTON_REPEAT);
	} else {
		AG_DelTimer(bu, &bu->repeatTo);
		AG_DelTimer(bu, &bu->delayTo);
		bu->flags &= ~(AG_BUTTON_REPEAT);
	}
	AG_ObjectUnlock(bu);
}
Exemple #4
0
static void
OnFocusLoss(AG_Event *event)
{
	AG_Slider *sl = AG_SELF();

	AG_DelTimer(sl, &sl->moveTo);
}
Exemple #5
0
static void
MouseButtonDown(AG_Event *event)
{
	AG_Button *bu = AG_SELF();
	int button = AG_INT(1);
	AG_Variable *binding;
	void *pState;
	int newState;
	
	if (AG_WidgetDisabled(bu))
		return;

	if (!AG_WidgetIsFocused(bu))
		AG_WidgetFocus(bu);

	if (button != AG_MOUSE_LEFT)
		return;
	
	binding = AG_GetVariable(bu, "state", &pState);
	if (!(bu->flags & AG_BUTTON_STICKY)) {
		SetState(bu, binding, pState, 1);
	} else {
		newState = !GetState(bu, binding, pState);
		SetState(bu, binding, pState, newState);
		AG_PostEvent(NULL, bu, "button-pushed", "%i", newState);
	}
	AG_UnlockVariable(binding);

	if (bu->flags & AG_BUTTON_REPEAT) {
		AG_DelTimer(bu, &bu->repeatTo);
		AG_PostEvent(NULL, bu, "button-pushed", "%i", 1);
		AG_AddTimer(bu, &bu->delayTo, agMouseSpinDelay,
		    ExpireDelay, "%i", agMouseSpinIval);
	}
}
Exemple #6
0
static void
KeyUp(AG_Event *event)
{
	AG_Slider *sl = AG_SELF();
	int keysym = AG_INT(1);

	switch (keysym) {
	case AG_KEY_UP:
	case AG_KEY_LEFT:
	case AG_KEY_DOWN:
	case AG_KEY_RIGHT:
		AG_DelTimer(sl, &sl->moveTo);
		break;
	}
}