示例#1
0
	// 3.5 Attend que l'on clique et renvoie dans button le bouton cliqué :
	// *button vaut soit 'G' (pour Gauche), soit 'M' (pour milieu),
	// soit 'D' (pour Droit) en fonction du bouton cliqué
	// Instruction bloquante
POINT wait_clic_GMD(char *button)
	{
	int encore = 1;
	POINT P;
	SDL_Event event;
	P.x = 0;
	P.y = 0;
	#ifdef SDL_TTF_OK
		POINT E,F;
		char S[16];
		E.x = WIDTH - 55; E.y = 15;
		F.x = WIDTH; F.y = 0;
	#endif
	affiche_all();
	printf("Cliquer dans la fenêtre...");
	while (SDL_WaitEvent(&event) && encore)
		{
		/* Si l'utilisateur a demandé à fermer la fenêtre, on quitte */
		if (event.type == SDL_QUIT) exit(0);
	
		/* Si l'utilisateur a cliqué avec la souris */
		if ((event.type == SDL_MOUSEBUTTONDOWN))
			{
			#ifdef SDL_TTF_OK
				if (!police[10]) 
					{
					draw_fill_rectangle(E,F,noir);
					sprintf(S,"%4d %4d",event.motion.x,HEIGHT - event.motion.y);
					aff_pol(S,10,E,gris);
					affiche_all();
					}
			#endif
			printf("%cCliquer dans la fenêtre ... %4d %4d           %c",13,event.motion.x,HEIGHT - event.motion.y,13);
			fflush(stdout);
			encore=0;
			P.x = event.button.x;
			P.y = HEIGHT-event.button.y;
			if (event.button.button == SDL_BUTTON_LEFT)   *button = 'G';
			if (event.button.button == SDL_BUTTON_MIDDLE) *button = 'M';
			if (event.button.button == SDL_BUTTON_RIGHT)  *button = 'D';
			}
		}
	#ifdef SDL_TTF_OK
		draw_fill_rectangle(E,F,noir);
	#endif
	printf("Clic '%c' en %4d %4d                                           \n",*button,P.x,P.y);
	___MOUSE_POSITION = P;
	return P;
	}
示例#2
0
	// 3.4 Attend que l'utilisateur clique sur le bouton gauche
	// Renvoie les coordonnées du point cliqué
	// Instruction bloquante
POINT wait_clic()
	{
	int encore = 1;
	POINT P;
	SDL_Event event;
	P.x = 0;
	P.y = 0;
#ifdef EN_LOCAL
// A ne mettre que si on est en local, sur les ordi des étudiants, c'est trop lent
	#ifdef SDL_TTF_OK
		POINT E,F;
		char S[16];
		E.x = WIDTH - 55; E.y = 15;
		F.x = WIDTH; F.y = 0;
	#endif
#endif
	while (SDL_WaitEvent(&event) && encore)
		{
		/* Si l'utilisateur clique avec la souris */
		if ((event.type == SDL_MOUSEBUTTONDOWN) && (event.button.button == SDL_BUTTON_LEFT))
			{
			encore=0;
			P.x = event.button.x;
			P.y = HEIGHT-event.button.y;
			}
		/* Si l'utilisateur déplace la souris */
		if (event.type == SDL_MOUSEMOTION)
			{
#ifdef EN_LOCAL
// A ne mettre que si on est en local, sur les ordi des étudiants, c'est trop lent
			#ifdef SDL_TTF_OK
				if (police[10]) 
					{
					draw_fill_rectangle(E,F,noir);
					sprintf(S,"%4d %4d",event.motion.x,HEIGHT - event.motion.y);
					aff_pol(S,10,E,gris);
					affiche_all();
					}
			#endif
#endif
			printf("%cEn attente de clic ... %4d %4d           %c",13,event.motion.x,HEIGHT - event.motion.y,13);
			fflush(stdout);
			}
		/* Si l'utilisateur a demandé à fermer la fenêtre, on quitte */
		if (event.type == SDL_QUIT) exit(0);
	
		}
#ifdef EN_LOCAL
// A ne mettre que si on est en local, sur les ordi des étudiants, c'est trop lent
	#ifdef SDL_TTF_OK
		aff_pol(S,10,E,noir);
		//draw_fill_rectangle(E,F,jaune);
		affiche_all();
	#endif
#endif
	printf("%cClic en %4d %4d                                           \n",13,P.x,P.y);
	___MOUSE_POSITION = P;
	return P;
	}
示例#3
0
文件: affichage.c 项目: Mzem/Ski
void afficheBoutonRecommencer()
{
	POINT P1 = {730,530};
	POINT P2 = {860,580};
	draw_fill_rectangle(P1,P2,couleur_RGB(38,196,236));
	draw_rectangle(P1,P2,black);
	P1.x = 737;
	P1.y = 566;
	aff_pol("RECOMMENCER",15,P1,noir);
	affiche_all();
}
示例#4
0
文件: affichage.c 项目: Mzem/Ski
void afficheBoutonRecommencerSombre()
{
	POINT P1 = {730,530};
	POINT P2 = {860,580};
	draw_fill_rectangle(P1,P2,couleur_RGB(25,180,220));
	draw_rectangle(P1,P2,black);
	P1.x = 737;
	P1.y = 566;
	aff_pol("RECOMMENCER",15,P1,noir);
	affiche_all();
	attendre(150);
}