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 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
|
GC gc, gc_invert;
Display *display;
int screen;
int i, j;
Drawable draw;
Window root, bidon;
Window fem;
Window item[nbFen];
unsigned long white_pixel, black_pixel;
int Ox=0;
XEvent ev;
XFontStruct * fd;
XGCValues gcv;
XSetWindowAttributes *gch;
int premier=1;
Pixmap mon_pix, tabPic[10];
int main() {
if ((display = XOpenDisplay ("")) == NULL) {
fprintf (stderr, "Can't open Display %s\n",XDisplayName(NULL));
exit (1);
}
gc = DefaultGC (display, screen);
screen = DefaultScreen (display);
root = RootWindow (display, screen);
white_pixel = WhitePixel (display, screen);
black_pixel = BlackPixel (display, screen);
fem = XCreateSimpleWindow (display, root, 20, 30, L, H, 2, black_pixel, white_pixel);
for(i=0; i < 4; i++)
item[i] = XCreateSimpleWindow (display, fem, 0, i*(hI+1), hI, hI, 1, black_pixel, white_pixel);
for(j=0; j < 4; i++,j++)
item[i] = XCreateSimpleWindow (display, fem, 51, j*(hI+1), hI, hI, 1, black_pixel, white_pixel);
// Ligne ZIG ZAG
mon_pix = XCreatePixmapFromBitmapData(display, item[0], lignebrisee_bits, lignebrisee_width, lignebrisee_height, black_pixel, white_pixel, DefaultDepth(display, screen));
XSetWindowBackgroundPixmap(display, item[0], mon_pix);
// Cercle sans centre
mon_pix = XCreatePixmapFromBitmapData(display, item[1], cercle_bits, cercle_width, cercle_height, black_pixel, white_pixel, DefaultDepth(display, screen));
XSetWindowBackgroundPixmap(display, item[1], mon_pix);
// D
mon_pix = XCreatePixmapFromBitmapData(display, item[2], d_bits, d_width, d_height, black_pixel, white_pixel, DefaultDepth(display, screen));
XSetWindowBackgroundPixmap(display, item[2], mon_pix);
........
XSelectInput (display, fem, ExposureMask);
for(i=0; i < nbFen; i++)
XSelectInput (display, item[i], ExposureMask|EnterWindowMask|LeaveWindowMask);
XStoreName (display, fem, "Dessin");
for(i=0; i < nbFen; i++)
XMapWindow (display, item[i]);
XMapWindow (display, fem);
while(1) {
XNextEvent(display, &ev);
bidon = ev.xany.window;
printf("%d \n", ev.type);
switch (ev.type) {
case Expose :
break;
case EnterNotify :
{
change(black_pixel, white_pixel, bidon);
break;
}
case LeaveNotify :
{
change(white_pixel, black_pixel, bidon);
break;
}
case ButtonPress :
{
// inversion
printf("ICI\n");
invertCouleur(black_pixel, white_pixel, bidon);
gcv.foreground = white_pixel;
gcv.function = GXinvert;
gc_invert = XCreateGC(display, bidon, GCFunction, &gcv);
//XChangeWindowAttributes(display, bidon, CWBackPixel, &gch);
XChangeGC(display, gc_invert, GCFunction, &gcv);
break;
}
case MotionNotify :
break;
default:
break;
}
}
XCloseDisplay(display);
} |
Partager