home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 4 / FreshFish_May-June1994.bin / bbs / may94 / util / edit / jade.lha / Jade / src / x11_windowsys.h < prev   
C/C++ Source or Header  |  1994-04-16  |  3KB  |  105 lines

  1. /* x11_windowsys.h -- X11 window-system data and macros
  2.    Copyright (C) 1993, 1994 John Harper <jsh@ukc.ac.uk>
  3.  
  4. This file is part of Jade.
  5.  
  6. Jade is free software; you can redistribute it and/or modify it
  7. under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2, or (at your option)
  9. any later version.
  10.  
  11. Jade is distributed in the hope that it will be useful, but
  12. WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with Jade; see the file COPYING.  If not, write to
  18. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19.  
  20. #ifndef _X11_WINDOWSYS_H
  21. #define _X11_WINDOWSYS_H
  22.  
  23. typedef struct {
  24.     Window        ws_Window;
  25.     GC            ws_TextFontGC, ws_BlkFontGC;
  26.     int            ws_PenX, ws_PenY;
  27.     XFontStruct           *ws_Font;
  28.     int            ws_Width, ws_Height;
  29.     int            ws_MessageLineY;
  30.     int            ws_MessageFontY;
  31. } VW_WindowSys;
  32.  
  33. #define vw_Window    vw_WindowSys.ws_Window
  34. #define vw_Font        vw_WindowSys.ws_Font
  35. #define WINDOW_NIL    (0)
  36.  
  37. #if 0
  38. typedef struct {
  39.     /* ... */
  40. } ScrollBar;
  41. #endif
  42.  
  43. /* Pen colours. */
  44. #define P_TEXT    0
  45. #define P_BLOCK 1
  46.  
  47. /*
  48.  * Macros for drawing operations. These are mainly used in render.c for
  49.  * system-independant rendering.
  50.  */
  51.  
  52. /* Move to position (X,Y). The next DRAW() will happen at this position. */
  53. #define MOVE(vw,x,y) \
  54.     do { \
  55.     (vw)->vw_WindowSys.ws_PenX = (x); \
  56.     (vw)->vw_WindowSys.ws_PenY = (y); \
  57.     } while(0)
  58.  
  59. #define PEN_X(vw) ((vw)->vw_WindowSys.ws_PenX)
  60. #define PEN_Y(vw) ((vw)->vw_WindowSys.ws_PenY)
  61.  
  62. /* Draw LEN bytes of the string STR with colour COL (P_TEXT or P_BLOCK)
  63.    at the position set by the MOVE() macro.  */
  64. #define TEXT(vw,col,str,len) \
  65.     do { \
  66.     XDrawImageString(XDisplay, (vw)->vw_Window, \
  67.              ((col) == P_TEXT) \
  68.               ? (vw)->vw_WindowSys.ws_TextFontGC \
  69.               : (vw)->vw_WindowSys.ws_BlkFontGC, \
  70.              (vw)->vw_WindowSys.ws_PenX, (vw)->vw_WindowSys.ws_PenY, \
  71.              (str), (len)); \
  72.     (vw)->vw_WindowSys.ws_PenX += (len) * vw->vw_FontX; \
  73.     } while(0)
  74.  
  75. /* Clear a rectangle from (X,Y) to (X+W,Y+H).  */
  76. #define CLR_AREA(vw,x,y,w,h) \
  77.     XClearArea(XDisplay, (vw)->vw_Window, (x), (y), (w), (h), False)
  78.  
  79. #define CLR_RECT(vw,x1,y1,x2,y2) \
  80.     XClearArea(XDisplay, (vw)->vw_Window, (x1), (y1), \
  81.            (x2) - (x1), (y2) - (y1), False)
  82.  
  83. /* Fill a rectangle from (X,Y) to (X+W,Y+H).  */
  84. #define SET_AREA(vw,x,y,w,h) \
  85.     XFillRectangle(XDisplay, (vw)->vw_Window, (vw)->vw_WindowSys.ws_TextFontGC, \
  86.            (x), (y), (w), (h))
  87.  
  88. #define SET_RECT(vw,x1,y1,x2,y2) \
  89.     XFillRectangle(XDisplay, (vw)->vw_Window, (vw)->vw_WindowSys.ws_TextFontGC, \
  90.            (x1), (y1), (x2) - (x1), (y2) - (y1))
  91.  
  92. /* Copy pixels from (X1,Y1),(X1+W,Y1+H) to (X2,Y2)  */
  93. #define COPY_AREA(vw,x1,y1,w,h,x2,y2) \
  94.     do { \
  95.     XCopyArea(XDisplay, (vw)->vw_Window, (vw)->vw_Window, \
  96.           (vw)->vw_WindowSys.ws_TextFontGC, \
  97.           (x1), (y1), (w), (h), (x2), (y2)); \
  98.     handlegexposures(vw); \
  99.     } while(0)
  100.  
  101. /* Number of pixels from top of font to its baseline.  */
  102. #define FONT_ASCENT(vw) ((vw)->vw_Font->ascent)
  103.  
  104. #endif /* _X11_WINDOWSYS_H */
  105.