1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
   |  
#include </usr/X11R6/include/X11/Xlib.h>
#include </usr/X11R6/include/X11/Xutil.h>
 
char	hello[]="How do you do ?";
char	texte_clic[]="-yau de poêle!";
 
int main (int argc,char **argv)
{
	Display *canal_aff;
	Window *fenetre;
	GC contx_graph;
	XEvent evenem;
	KeySym touche;
	XSizeHints infos_fen;
	XWMHints infos_WM;
	int test_boucle,ecran,i;
	unsigned long couleur_AVplan,couleur_ARRplan;
	char frappe[10];
 
	canal_aff=XOpenDisplay("");
	ecran=DefaultScreen(canal_aff);
 
	couleur_ARRplan=WhitePixel(canal_aff,ecran);
	couleur_AVplan=BlackPixel(canal_aff,ecran);
 
	infos_fen.x=200;
	infos_fen.y=300;
	infos_fen.width=350;
	infos_fen.height=250;
	infos_fen.flags=PPosition | PSize;
	infos_WM.flags=InputHint;
	infos_WM.input=True;
 
	fenetre=XCreateSimpleWindow(canal_aff,DefaultRootWindow(canal_aff),
			infos_fen.x,infos_fen.y,
			infos_fen.width,infos_fen.height,5,
			couleur_AVplan,couleur_ARRplan);
	XSetStandardProperties(canal_aff,fenetre,hello,hello,None,
			argv,argc,&infos_fen);
	XSetWMHints(canal_aff,fenetre,&infos_WM);
 
	contx_graph=XCreateGC(canal_aff,fenetre,0,0);
	XSetBackground(canal_aff,contx_graph,couleur_ARRplan);
	XSetForeground(canal_aff,contx_graph,couleur_AVplan);
 
	XSelectInput=(canal_aff,fenetre,
		ButtonPressMask | KeyPressMask | ExposureMask);
 
	XMapRaised(canal_aff,fenetre);
 
	test_boucle=0;
	while(test_boucle == 0)
	{
		XNextEvent(canal_aff,&evenem);
		switch(evenem.type)
		{
			case Expose:
				if(evenem.xexpose.count == 0)
					XDrawImage(evenem.xexpose.display,
					 evenem.xexpose.window,contx_graph,
				 	 50,50,hello,strlen(hello));
		       		break;
			case MappingNotify:
				XRefreshKeyboardMapping(&evenem);
				break;
			case ButtonPress:
				XDrawImageString(evenem.xbutton.display,
				 evenem.xbutton.window,contx_graph,
		 		 evenem.xbutton.x,evenem.xbutton.y,
				 texte_clic,strlen(texte_clic));
	       			break;
			case KeyPress:
				i=XLookupString(&evenem,frappe,10,&touche,0);
				if(i==1 && frappe[0]=='q') test_boucle=1;
				break;
		}
	}
	XFreeGC(canal_aff,contx_graph);
	XDestroyWindow(canal_aff,fenetre);
	XCloseDisplay(canal_aff);
 
	exit(0);
} | 
Partager