home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / historic / v92.tgz / v92.tar / v92 / src / h / xwin.h < prev   
C/C++ Source or Header  |  1996-03-22  |  7KB  |  196 lines

  1. #ifdef XWindows
  2.  
  3. #define DRAWOP_AND            GXand
  4. #define DRAWOP_ANDINVERTED        GXandInverted
  5. #define DRAWOP_ANDREVERSE        GXandReverse
  6. #define DRAWOP_CLEAR            GXclear
  7. #define DRAWOP_COPY            GXcopy
  8. #define DRAWOP_COPYINVERTED        GXcopyInverted
  9. #define DRAWOP_EQUIV            GXequiv
  10. #define DRAWOP_INVERT            GXinvert
  11. #define DRAWOP_NAND            GXnand
  12. #define DRAWOP_NOOP            GXnoop
  13. #define DRAWOP_NOR            GXnor
  14. #define DRAWOP_OR            GXor
  15. #define DRAWOP_ORINVERTED        GXorInverted
  16. #define DRAWOP_ORREVERSE        GXorReverse
  17. #define DRAWOP_REVERSE            0x10
  18. #define DRAWOP_SET            GXset
  19. #define DRAWOP_XOR            GXxor
  20.  
  21. #define XLFD_Foundry     1
  22. #define XLFD_Family     2
  23. #define XLFD_Weight     3
  24. #define XLFD_Slant     4
  25. #define XLFD_SetWidth     5
  26. #define XLFD_AddStyle     6
  27. #define XLFD_Size     7
  28. #define XLFD_PointSize     8
  29. #define XLFD_Spacing    11
  30. #define XLFD_CharSet    13
  31.  
  32. #define TEXTWIDTH(w,s,n) XTextWidth((w)->context->font->fsp, s, n)
  33. #define SCREENDEPTH(w)\
  34.     DefaultDepth((w)->window->display->display, w->window->display->screen)
  35. #define ASCENT(w) ((w)->context->font->fsp->ascent)
  36. #define DESCENT(w) ((w)->context->font->fsp->descent)
  37. #define LEADING(w) ((w)->context->leading)
  38. #define FHEIGHT(w) ((w)->context->font->height)
  39. #define FWIDTH(w) ((w)->context->font->fsp->max_bounds.width)
  40. #define LINEWIDTH(w) ((w)->context->linewidth)
  41. #define DISPLAYHEIGHT(w)\
  42.     DisplayHeight(w->window->display->display, w->window->display->screen)
  43. #define DISPLAYWIDTH(w)\
  44.     DisplayWidth(w->window->display->display, w->window->display->screen)
  45. #define FS_SOLID FillSolid
  46. #define FS_STIPPLE FillStippled
  47. #define hidecrsr(x) /* noop */
  48. #define UpdateCursorPos(x, y) /* noop */
  49. #define showcrsr(x) /* noop */
  50. #define SysColor XColor
  51. #define ARCWIDTH(arc) ((arc).width)
  52. #define ARCHEIGHT(arc) ((arc).height)
  53. #define RECX(rec) ((rec).x)
  54. #define RECY(rec) ((rec).y)
  55. #define RECWIDTH(rec) ((rec).width)
  56. #define RECHEIGHT(rec) ((rec).height)
  57. #define ANGLE(ang) (-(ang) * 180 / Pi * 64)
  58. #define EXTENT(ang) (-(ang) * 180 / Pi * 64)
  59. #define ISICONIC(w) ((w)->window->iconic == IconicState)
  60. #define ISFULLSCREEN(w) (0)
  61. #define ISROOTWIN(w) ((w)->window->iconic == RootState)
  62. #define ISNORMALWINDOW(w) ((w)->window->iconic == NormalState)
  63. #define ICONFILENAME(w) ((w)->window->iconimage)
  64. #define ICONLABEL(w) ((w)->window->iconlabel)
  65. #define WINDOWLABEL(w) ((w)->window->windowlabel)
  66. #define RootState IconicState+1
  67. #define MaximizedState IconicState+2
  68. #define HiddenState IconicState+3
  69.  
  70. /*
  71.  * The following constants define limitations in the system, gradually being
  72.  * removed as this code is rewritten to use dynamic allocation.
  73.  */
  74. #define DMAXCOLORS    256
  75. #define WMAXCOLORS    256
  76. #define MAXCOLORNAME    40
  77. #define MAXDISPLAYNAME    64
  78. #define SHARED          0
  79. #define MUTABLE         1
  80. #define NUMCURSORSYMS    78
  81.  
  82. /*
  83.  * Macros to ease coding in which every X call must be done twice.
  84.  */
  85. #define RENDER2(func,v1,v2) {\
  86.    if (stdwin) func(stddpy, stdwin, stdgc, v1, v2); \
  87.    func(stddpy, stdpix, stdgc, v1, v2);}
  88. #define RENDER3(func,v1,v2,v3) {\
  89.    if (stdwin) func(stddpy, stdwin, stdgc, v1, v2, v3); \
  90.    func(stddpy, stdpix, stdgc, v1, v2, v3);}
  91. #define RENDER4(func,v1,v2,v3,v4) {\
  92.    if (stdwin) func(stddpy, stdwin, stdgc, v1, v2, v3, v4); \
  93.    func(stddpy, stdpix, stdgc, v1, v2, v3, v4);}
  94. #define RENDER6(func,v1,v2,v3,v4,v5,v6) {\
  95.    if (stdwin) func(stddpy, stdwin, stdgc, v1, v2, v3, v4, v5, v6); \
  96.    func(stddpy, stdpix, stdgc, v1, v2, v3, v4, v5, v6);}
  97. #define RENDER7(func,v1,v2,v3,v4,v5,v6,v7) {\
  98.    if (stdwin) func(stddpy, stdwin, stdgc, v1, v2, v3, v4, v5, v6, v7); \
  99.    func(stddpy, stdpix, stdgc, v1, v2, v3, v4, v5, v6, v7);}
  100.  
  101. #define MAXDESCENDER(w) (w->context->font->fsp->max_bounds.descent)
  102.  
  103. /*
  104.  * Macros to perform direct window system calls from graphics routines
  105.  */
  106. #define STDLOCALS(w) \
  107.    wcp wc = (w)->context; \
  108.    wsp ws = (w)->window; \
  109.    wdp wd = ws->display; \
  110.    GC      stdgc  = wc->gc; \
  111.    Display *stddpy = wd->display; \
  112.    Window  stdwin  = ws->win; \
  113.    Pixmap  stdpix  = ws->pix;
  114.  
  115. #define drawarcs(w, arcs, narcs) \
  116.    { STDLOCALS(w); RENDER2(XDrawArcs,arcs,narcs); }
  117. #define drawlines(w, points, npoints) \
  118.    { STDLOCALS(w); RENDER3(XDrawLines,points,npoints,CoordModeOrigin); }
  119. #define drawpoints(w, points, npoints) \
  120.    { STDLOCALS(w); RENDER3(XDrawPoints,points,npoints,CoordModeOrigin); }
  121. #define drawrectangles(w, recs, nrecs) { \
  122.    STDLOCALS(w); \
  123.    for(i=0; i<nrecs; i++) { \
  124.      RENDER4(XDrawRectangle,recs[i].x,recs[i].y,recs[i].width,recs[i].height);\
  125.      }}
  126.  
  127. #define drawsegments(w, segs, nsegs) \
  128.    { STDLOCALS(w); RENDER2(XDrawSegments,segs,nsegs); }
  129. #define drawstrng(w, x, y, s, slen) \
  130.    { STDLOCALS(w); RENDER4(XDrawString, x, y, s, slen); }
  131. #define fillarcs(w, arcs, narcs) \
  132.    { STDLOCALS(w); RENDER2(XFillArcs, arcs, narcs); }
  133. #define fillpolygon(w, points, npoints) \
  134.    { STDLOCALS(w); RENDER4(XFillPolygon, points, npoints, Complex, CoordModeOrigin); }
  135.  
  136. /*
  137.  * "get" means remove them from the Icon list and put them on the ghost queue
  138.  */
  139. #define EVQUEGET(w,d) { \
  140.   int i;\
  141.   wsp ws = (w)->window; \
  142.   if (!c_get((struct b_list *)BlkLoc(ws->listp),&d)) fatalerr(0,NULL); \
  143.   if (Qual(d)) {\
  144.       ws->eventQueue[ws->eQfront++] = *StrLoc(d); \
  145.       if (ws->eQfront >= EQUEUELEN) ws->eQfront = 0; \
  146.       ws->eQback = ws->eQfront; \
  147.       } \
  148.   }
  149. #define EVQUEEMPTY(w) (BlkLoc((w)->window->listp)->list.size == 0)
  150.  
  151. /*
  152.  * Colors.  These are allocated within displays; they are currently
  153.  * statically bounded to DMAXCOLORS colors per display.  Pointers
  154.  * into the display's color table are also kept on a per-window
  155.  * basis so that they may be (de)allocated when a window is cleared.
  156.  * Colors are aliased by r,g,b value.  Allocations by name and r,g,b
  157.  * share when appropriate.
  158.  *
  159.  * Color (de)allocation comprises a simple majority of the space
  160.  * requirements of the current implementation.  A monochrome-only
  161.  * version would take a lot less space.
  162.  *
  163.  * The name field is the string returned by WAttrib.  For a mutable
  164.  * color this is of the form "-47" followed by a second C string
  165.  * containing the current color setting.
  166.  */
  167. typedef struct wcolor {
  168.   int        refcount;
  169.   char        name[6+MAXCOLORNAME];    /* name for WAttrib & WColor reads */
  170.   unsigned short r, g, b;        /* rgb for colorsearch */
  171.   unsigned long    c;            /* X pixel value */
  172.   int           type;            /* SHARED or MUTABLE */
  173. } *wclrp;
  174.  
  175. /*
  176.  * macros performing row/column to pixel y,x translations
  177.  * computation is 1-based and depends on the current font's size.
  178.  * exception: XTOCOL as defined is 0-based, because that's what its
  179.  * clients seem to need.
  180.  */
  181. #define ROWTOY(w,row) ((row-1) * LEADING(w) + ASCENT(w))
  182. #define COLTOX(w,col) ((col-1) * FWIDTH(w))
  183. #define YTOROW(w,y)   (((y) - ASCENT(w)) / LEADING(w) + 1)
  184. #define XTOCOL(w,x)  (!FWIDTH(w) ? (x) : ((x) / FWIDTH(w)))
  185.  
  186. #define STDLOCALS(w) \
  187.    wcp wc = (w)->context; \
  188.    wsp ws = (w)->window; \
  189.    wdp wd = ws->display; \
  190.    GC      stdgc  = wc->gc; \
  191.    Display *stddpy = wd->display; \
  192.    Window  stdwin  = ws->win; \
  193.    Pixmap  stdpix  = ws->pix;
  194.  
  195. #endif                    /* XWindows */
  196.