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 / cleararea.c < prev    next >
C/C++ Source or Header  |  1998-04-12  |  2KB  |  95 lines

  1. #include "allincludes.h"
  2.  
  3. /* XFIX */
  4.  
  5. static XRectangle _rcache[MAXCACHE];
  6. static int _rcache_index;
  7.  
  8.  void
  9. FlushClearAreaCache(window)
  10.     W_Window  window;
  11. {
  12.     struct window *win = W_Void2Window(window);
  13.     XFillRectangles(W_Display, win->drawable, colortable[backColor].contexts[0],
  14.             _rcache, _rcache_index);
  15.     _rcache_index = 0;
  16. }
  17.  
  18. /* local window only */
  19. void
  20. W_CacheClearArea(window, x, y, width, height)
  21.     W_Window window;
  22.     int     x, y, width, height;
  23. {
  24.     register XRectangle *r;
  25.  
  26.     if (_rcache_index == MAXCACHE)
  27.     FlushClearAreaCache(window);
  28.  
  29.     r = &_rcache[_rcache_index++];
  30.     r->x = (short) x;
  31.     r->y = (short) y;
  32.     r->width = (unsigned short) width;
  33.     r->height = (unsigned short) height;
  34. }
  35.  
  36. void
  37. W_FlushClearAreaCache(window)
  38.     W_Window window;
  39. {
  40.     if (_rcache_index)
  41.     FlushClearAreaCache(window);
  42. }
  43.  
  44. /* XFIX: clears now instead of filling. */
  45. /* not any more.  Can't clear a drawable. [BDyess] */
  46. void
  47. W_ClearArea(window, x, y, width, height)
  48.     W_Window window;
  49.     int     x, y;
  50.     unsigned int width, height;
  51. {
  52.     struct window *win;
  53.  
  54. #ifdef DEBUG
  55.     printf("Clearing (%d %d) x (%d %d) with %d on %d\n", x, y, width, height,
  56.        color, window);
  57. #endif
  58.     win = W_Void2Window(window);
  59.     switch (win->type) {
  60.     case WIN_GRAPH:
  61.     /* XFIX: changed */
  62.     XFillRectangle(W_Display, win->drawable, 
  63.         colortable[backColor].contexts[0], x, y, width, height);
  64.     break;
  65.     default:
  66.     /* XFIX: changed */
  67.     XFillRectangle(W_Display, win->drawable, 
  68.        colortable[backColor].contexts[0], WIN_EDGE + x * W_Textwidth,
  69.        MENU_PAD + y * W_Textheight, width * W_Textwidth, 
  70.        W_Textheight * height);
  71.     break;
  72.     }
  73. }
  74.  
  75. void
  76. W_ClearWindow(window)
  77.     W_Window window;
  78. {
  79.     struct window * win = W_Void2Window(window);
  80.  
  81. #ifdef DEBUG
  82.     printf("Clearing %d\n", window);
  83. #endif
  84. #ifdef BUFFERING
  85.     if(win->isbuffered) {
  86.       W_ClearBuffer(window);
  87.     } else {
  88.       XClearWindow(W_Display, win->window);
  89.     }
  90. #else 
  91.     XClearWindow(W_Display, win->window);
  92. #endif /*BUFFERING [BDyess]*/
  93. }
  94.  
  95.