Exemple #1
0
int ui_radio_do( UI_DIALOG *dlg, UI_GADGET_RADIO * radio, d_event *event )
{
	UI_GADGET * tmp;
	UI_GADGET_RADIO * tmpr;
	int rval = 0;
	
	radio->oldposition = radio->position;
	radio->pressed = 0;

	if (event->type == EVENT_MOUSE_BUTTON_DOWN || event->type == EVENT_MOUSE_BUTTON_UP)
	{
		int OnMe;
		
		OnMe = ui_mouse_on_gadget( (UI_GADGET *)radio );

		if ( B1_JUST_PRESSED && OnMe)
		{
			radio->position = 1;
			rval = 1;
		} 
		else if (B1_JUST_RELEASED)
		{
			if ((radio->position==1) && OnMe)
				radio->pressed = 1;
			
			radio->position = 0;
		}
	}

	
	if (event->type == EVENT_KEY_COMMAND)
	{
		int key;
		
		key = event_key_get(event);
		
		if ((dlg->keyboard_focus_gadget==(UI_GADGET *)radio) && ((key==KEY_SPACEBAR) || (key==KEY_ENTER)) )
		{
			radio->position = 2;
			rval = 1;
		}
	}
	else if (event->type == EVENT_KEY_RELEASE)
	{
		int key;
		
		key = event_key_get(event);
		
		radio->position = 0;
		
		if ((dlg->keyboard_focus_gadget==(UI_GADGET *)radio) && ((key==KEY_SPACEBAR) || (key==KEY_ENTER)) )
			radio->pressed = 1;
	}
		
	if ((radio->pressed == 1) && (radio->flag==0))
	{
		tmp = (UI_GADGET *)radio->next;

		while (tmp != (UI_GADGET *)radio )
		{
			if (tmp->kind==4)
			{
				tmpr = (UI_GADGET_RADIO *)tmp;
				if ((tmpr->group == radio->group ) && (tmpr->flag) )
				{
					tmpr->flag = 0;
					tmpr->status = 1;
					tmpr->pressed = 0;
				}
			}
			tmp = tmp->next;
		}
		radio->flag = 1;
		ui_gadget_send_event(dlg, EVENT_UI_GADGET_PRESSED, (UI_GADGET *)radio);
		rval = 1;
	}

	if (event->type == EVENT_WINDOW_DRAW)
		ui_draw_radio( dlg, radio );

	return rval;
}
Exemple #2
0
Fichier : radio.c Projet : btb/d1x
void ui_radio_do( UI_GADGET_RADIO * radio, int keypress )
{
	UI_GADGET * tmp;
	UI_GADGET_RADIO * tmpr;
	int OnMe, ButtonLastSelected;
	keypress  = keypress;

	OnMe = ui_mouse_on_gadget( (UI_GADGET *)radio );

	radio->oldposition = radio->position;

	if (selected_gadget != NULL)
	{
		if (selected_gadget->kind==4)
			ButtonLastSelected = 1;
		else
			ButtonLastSelected = 0;
	} else
		ButtonLastSelected = 1;


	if ( B1_PRESSED && OnMe && ButtonLastSelected )
	{

		radio->position = 1;
	} else  {
		radio->position = 0;
	}


	if ((CurWindow->keyboard_focus_gadget==(UI_GADGET *)radio) && (keyd_pressed[KEY_SPACEBAR] || keyd_pressed[KEY_ENTER] ) )
		radio->position = 2;

	if ((radio->position==0) && (radio->oldposition==1) && OnMe )
		radio->pressed = 1;
	else if ((radio->position==0) && (radio->oldposition==2) && (CurWindow->keyboard_focus_gadget==(UI_GADGET *)radio) )
		radio->pressed = 1;
	else
		radio->pressed = 0;

	if ((radio->pressed == 1) && (radio->flag==0))
	{
		tmp = (UI_GADGET *)radio->next;

		while (tmp != (UI_GADGET *)radio )
		{
			if (tmp->kind==4)
			{
				tmpr = (UI_GADGET_RADIO *)tmp;
				if ((tmpr->group == radio->group ) && (tmpr->flag) )
				{
					tmpr->flag = 0;
					tmpr->status = 1;
					tmpr->pressed = 0;
				}
			}
			tmp = tmp->next;
		}
		radio->flag = 1;
	}

	ui_draw_radio( radio );

}