home *** CD-ROM | disk | FTP | other *** search
/ Dream 52 / Amiga_Dream_52.iso / Linux / Divers / xgalaga-2_0_tar.gz / xgalaga-2_0_tar / xgalaga-2.0 / libsprite / border.c < prev    next >
C/C++ Source or Header  |  1998-04-12  |  3KB  |  89 lines

  1. #include "allincludes.h"
  2.  
  3. void
  4. W_ChangeBorder(window, color)
  5.     W_Window window;
  6.     int     color;
  7. {
  8. #ifdef DEBUG
  9.     printf("Changing border of %d\n", window);
  10. #endif
  11.  
  12. #if 0
  13.     /* fix inexplicable color bug */
  14.     if (DisplayCells(W_Display, W_Screen) <= 2)
  15.     XSetWindowBorderPixmap(W_Display, W_Void2Window(window)->window,
  16.                    colortable[color].pixmap);
  17.     else
  18.     XSetWindowBorder(W_Display, W_Void2Window(window)->window,
  19.              colortable[color].pixelValue);
  20. #endif /*0*/
  21.  
  22.     struct window *border = W_Void2Window(W_Void2Window(window)->borderwin);
  23.  
  24.     border->border_color = color;
  25.     redrawBorder(border);
  26. }
  27.  
  28. /* this function will redraw a border window [BDyess] */
  29.  void
  30. redrawBorder(win)
  31.     struct window *win;
  32. {
  33.     XPoint points[3];
  34.     XGCValues val;
  35.  
  36.     if(win->border == 0) return;
  37.     val.line_width = win->border*2 + 1;
  38.     if(win->border_color == NONE) {
  39.       /* GC is set up so that lines are drawn with thickness BORDER, so only one
  40.      line is needed for each side.  The background is set to DARK_GREY,
  41.      which is the color of the left and top sides, so only two other
  42.      lines need to be drawn. [BDyess] */
  43.       XChangeGC(W_Display, borderGC, GCLineWidth, &val);
  44.       points[0].x = win->border/2;
  45.       points[0].y = win->height;
  46.       points[1].x = win->width;
  47.       points[1].y = win->height;
  48.       points[2].x = win->width;
  49.       points[2].y = win->border/2;
  50.       XDrawLines(W_Display, win->drawable, borderGC, points, 3,
  51.                  CoordModeOrigin);
  52.     } else {    /* draw a color border */
  53.       val.foreground = colortable[win->border_color].pixelValue;
  54.       XChangeGC(W_Display, borderGC, GCLineWidth | GCForeground, &val);
  55.       XDrawRectangle(W_Display, win->drawable, borderGC, win->border - 1,
  56.              win->border - 1, 
  57.              win->width - 2 * win->border + 2,
  58.              win->height - 2 * win->border + 2);
  59.       XSetForeground(W_Display, borderGC, colortable[LIGHT_GREY].pixelValue);
  60.     }
  61. }
  62.  
  63. /* this function will redraw the main (background) window, which contains a 
  64.    reverse-border.  [BDyess] */
  65. #if NOTUSED
  66.  void
  67. redrawReversedBorder(win)
  68.     struct window *win;
  69. {
  70.     XPoint points[3];
  71.     XGCValues val;
  72.  
  73.     /* GC is set up so that lines are drawn with thickness BORDER, so only one
  74.        line is needed for each side.  The background is set to DARK_GREY,
  75.        which is the color of the left and top sides, so only two other
  76.        lines need to be drawn. [BDyess] */
  77.     val.line_width = BORDER*2 + 1;
  78.     XChangeGC(W_Display, borderGC, GCLineWidth, &val);
  79.     points[0].x = 0;
  80.     points[0].y = win->height - BORDER/2;
  81.     points[1].x = 0;
  82.     points[1].y = 0;
  83.     points[2].x = win->width - BORDER/2;
  84.     points[2].y = 0; 
  85.     XDrawLines(W_Display, win->drawable, borderGC, points, 3, CoordModeOrigin);
  86. }
  87. #endif
  88.  
  89.