home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / x / xlibpr3.zip / winman / box.c next >
C/C++ Source or Header  |  1989-11-27  |  2KB  |  97 lines

  1. /*
  2.  * Copyright 1989 O'Reilly and Associates, Inc.
  3.  * See ../Copyright for complete rights and liability information.
  4.  */
  5. #include <X11/Xlib.h>
  6. #include <stdio.h>
  7.  
  8. extern Display *display;
  9. extern int screen_num;
  10.  
  11. /*
  12. draw_box(left, top, right, bottom)
  13. int left, top, right, bottom;
  14. {
  15.     GC gcontext;
  16.     XPoint points[4];
  17.     int npoints = 4;
  18.     int mode = CoordModeOrigin;
  19.  
  20.     points[0].x = left;
  21.     points[0].y = top;
  22.  
  23.     points[1].x = left;
  24.     points[1].y = bottom;
  25.  
  26.     points[2].x = right;
  27.     points[2].y = bottom;
  28.  
  29.     points[3].x = right;
  30.     points[3].y = top;
  31.  
  32.         gcontext = XCreateGC(display, RootWindow(display,screen_num), 
  33.             0, NULL);  
  34.  
  35.     XSetForeground(display,gcontext,BlackPixel(display,screen_num));
  36.     XDrawLines(display, RootWindow(display, screen_num), gcontext, 
  37.             points, npoints, mode);
  38.  
  39.  
  40.     XFlush(display);
  41. }
  42. */
  43.  
  44. undraw_box(gc, left, top, right, bottom)
  45. GC gc;
  46. int left,top,right,bottom;
  47.     {
  48.     draw_box(gc, left,top,right,bottom);
  49.     }
  50.  
  51. draw_box(gc, left, top, right, bottom)
  52. GC gc;
  53. int left, top, right, bottom;
  54. {
  55.  
  56.     XSetForeground(display, gc, WhitePixel(display, screen_num) ^ BlackPixel(display, screen_num));
  57.     XDrawRectangle(display, RootWindow(display,screen_num), gc, left, 
  58.             top, right - left, bottom - top);
  59. }
  60.  
  61. /*
  62. draw_box(left,top,right,bottom)
  63. int left,top,right,bottom;
  64. {
  65.     Vertex corner[5];
  66.     int vertexcount = 5;
  67.     int bwidth = 1, bheight = 1; 
  68.     int pixel = WhitePixel;
  69.     int func = GXxor;
  70.     int planes = 1;
  71.     
  72.     corner[0].x = left;
  73.     corner[0].y = top;
  74.     corner[0].flags = 0;
  75.     
  76.     corner[1].x = left;
  77.     corner[1].y = bottom;
  78.     corner[1].flags = 0;
  79.     
  80.     corner[2].x = right;
  81.     corner[2].y = bottom;
  82.     corner[2].flags = 0;
  83.     
  84.     corner[3].x = right;
  85.     corner[3].y = top;
  86.     corner[3].flags = 0;
  87.     
  88.     corner[4].x = left;
  89.     corner[4].y = top;
  90.     corner[4].flags = 0;
  91.     
  92.     XDraw(RootWindow, corner, vertexcount , bwidth, bheight, pixel, 
  93.             func, planes);
  94.     XFlush(display);
  95. }
  96. */
  97.