home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / windows / x / 21065 < prev    next >
Encoding:
Text File  |  1993-01-12  |  1.3 KB  |  57 lines

  1. Path: sparky!uunet!dziuxsolim.rutgers.edu!caip.rutgers.edu!jayesh
  2. From: jayesh@caip.rutgers.edu (jayesh patel)
  3. Newsgroups: comp.windows.x
  4. Subject: Help in using XDrawLine()
  5. Message-ID: <Jan.12.15.49.54.1993.10085@caip.rutgers.edu>
  6. Date: 12 Jan 93 20:49:55 GMT
  7. Organization: Rutgers Univ., New Brunswick, N.J.
  8. Lines: 47
  9.  
  10. Hi Friends,
  11. I am novice to x-window programming. Can anyone tell me
  12. why line does'nt appear in the window when i run the following program.
  13.  
  14. #include <stdio.h>
  15. #include <X11/Xlib.h>
  16. #include <X11/Xutil.h>
  17.  
  18. main(argc,argv)
  19.      int argc;
  20.      char **argv;
  21. {
  22.   int x,y,width,height;
  23.   Display *display;
  24.   Window win,root;
  25.   XEvent event;
  26.   int screen;
  27.   XGCValues value;
  28.   GC gc;
  29.  
  30.   x=atoi(argv[1]);
  31.   y=atoi(argv[2]);
  32.   width=atoi(argv[3]);
  33.   height=atoi(argv[4]);
  34.   
  35.   display = XOpenDisplay(NULL);
  36.   root = XDefaultRootWindow(display);
  37.   win = XCreateSimpleWindow(display,root,x,y,width,height,0,0,0);
  38.  
  39.   XMapWindow(display,win);
  40.   gc = XCreateGC(display,win,0,0);
  41.   screen = DefaultScreen(display);
  42.   XSetForeground(display,gc,BlackPixel(display,screen));
  43.   XSetBackground(display,gc,WhitePixel(display,screen));
  44.  
  45.   while(1)
  46.     {
  47.       XNextEvent(display,&event);
  48.       switch(event.type){
  49.       case Expose:
  50.     XDrawPoint(display,win,gc,10,10);
  51.     XDrawPoint(display,win,gc,20,20);
  52.     XDrawLine(display,win,gc,10,10,20,20);
  53.         break;
  54.       }
  55.     }
  56. }
  57.