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 / mswin.h < prev    next >
Text File  |  1996-03-22  |  6KB  |  195 lines

  1. /*
  2.  * mswin.h - macros and types used in the MS Windows graphics interface.
  3.  */
  4.  
  5. #define DRAWOP_AND            R2_MASKPEN
  6. #define DRAWOP_ANDINVERTED        R2_MASKNOTPEN
  7. #define DRAWOP_ANDREVERSE        R2_NOTMASKPEN
  8. #define DRAWOP_CLEAR            R2_BLACK
  9. #define DRAWOP_COPY            R2_COPYPEN
  10. #define DRAWOP_COPYINVERTED        R2_NOTCOPYPEN
  11. #define DRAWOP_EQUIV            R2_NOTXORPEN
  12. #define DRAWOP_INVERT            R2_NOT
  13. #define DRAWOP_NAND            R2_MASKNOTPEN
  14. #define DRAWOP_NOOP            R2_NOP
  15. #define DRAWOP_NOR            R2_MERGENOTPEN
  16. #define DRAWOP_OR            R2_MERGEPEN
  17. #define DRAWOP_ORINVERTED        R2_MERGEPENNOT
  18. #define DRAWOP_ORREVERSE        R2_NOTMERGEPEN
  19. #define DRAWOP_REVERSE            R2_USER1
  20. #define DRAWOP_SET            R2_WHITE
  21. #define DRAWOP_XOR            R2_XORPEN
  22.  
  23. #define TEXTWIDTH(w,s,n) textWidth(w, s, n)
  24. #define SCREENDEPTH(w) getdepth(w)
  25. #define ASCENT(w)  ((w)->context->font->ascent)
  26. #define DESCENT(w) ((w)->context->font->descent)
  27. #define LEADING(w) ((w)->context->leading)
  28. #define FHEIGHT(w) ((w)->context->font->height)
  29. #define FWIDTH(w)  ((w)->context->font->charwidth)
  30. #define LINEWIDTH(w) ((w)->context->pen.lopnWidth.x)
  31. #define DISPLAYHEIGHT(w) devicecaps(w, VERTRES)
  32. #define DISPLAYWIDTH(w) devicecaps(w, HORZRES)
  33. #define wflush(w) 0 /* noop */
  34. #define wsync(w) /* noop */
  35. #define SysColor unsigned long
  36. #define RED(x) GetRValue(x)
  37. #define GREEN(x) GetGValue(x)
  38. #define BLUE(x) GetBValue(x)
  39. #define ARCWIDTH(arc) (arc).width
  40. #define ARCHEIGHT(arc) (arc).height
  41. /*
  42.  * These get fixed up in the window-system-specific code
  43.  */
  44. #define RECX(rec) (rec).left
  45. #define RECY(rec) (rec).top
  46. #define RECWIDTH(rec) (rec).right
  47. #define RECHEIGHT(rec) (rec).bottom
  48. /*
  49.  *
  50.  */
  51. #define ANGLE(ang) (ang)
  52. #define EXTENT(ang) (ang)
  53. #define FULLARC 2 * Pi
  54. #define ISICONIC(w) (IsIconic((w)->window->iconwin))
  55. #define ISFULLSCREEN(w) 0
  56. #define ISROOTWIN(w) (0) 0
  57. #define ISNORMALWINDOW(w) 0
  58. #define ICONFILENAME(w) ""
  59. #define ICONLABEL(w) ((w)->window->iconlabel)
  60. #define WINDOWLABEL(w) ((w)->window->windowlabel)
  61.  
  62. #define MAXLABEL    128
  63.  
  64. #define MAXDESCENDER(w) 0
  65.  
  66. /*
  67.  * gemeotry bitmasks
  68.  */
  69. #define GEOM_WIDTH           1
  70. #define GEOM_HEIGHT          2
  71. #define GEOM_POSX            4
  72. #define GEOM_POSY            8
  73. /*
  74.  * fill styles
  75.  */
  76. #define FS_SOLID             1
  77. #define FS_STIPPLE           2
  78. #define FS_OPAQUESTIPPLE     4
  79. /*
  80.  * the special ROP code for mode reverse
  81.  */
  82. #define R2_USER1            (R2_LAST << 1)
  83. /*
  84.  * window states
  85.  */
  86. #define WS_NORMAL            0
  87. #define WS_MIN               1
  88. #define WS_MAX               2
  89.  
  90. /*
  91.  * something I think should be #defined
  92.  */
  93. #define EOS                  '\0'
  94.  
  95. /* size of the working buffer, used for dialog messages and such */
  96. #define PMSTRBUFSIZE         2048
  97. /*
  98.  * the bitmasks for the modifier keys
  99.  */
  100. #define ControlMask          (1L << 16L)
  101. #define Mod1Mask             (2L << 16L)
  102. #define ShiftMask            (4L << 16L)
  103. #define VirtKeyMask          (8L << 16L)
  104.  
  105. /* some macros for Windows */
  106.  
  107. #define MAKERGB(r,g,b) RGB(r,g,b)
  108. #define RGB16TO8(x) if ((x) > 0xff) (x) = (((x) >> 8) & 0xff)
  109. #define hidecrsr(ws) /* noop */
  110. #define showcrsr(ws) /* noop */
  111. #define FNTWIDTH(size) ((size) & 0xFFFF)
  112. #define FNTHEIGHT(size) ((size) >> 16)
  113. #define MAKEFNTSIZE(height, width) (((height) << 16) | (width))
  114. #define WaitForEvent(msgnum, msgstruc) ObtainEvents(NULL, WAIT_EVT, msgnum, msgstruc)
  115.  
  116. /*
  117.  * "get" means remove them from the Icon list and put them on the ghost que
  118.  */
  119. #define EVQUEGET(ws,d) { \
  120.   int i;\
  121.   if (!c_get((struct b_list *)BlkLoc((ws)->listp),&d)) fatalerr(0,NULL); \
  122.   if (Qual(d)) {\
  123.       (ws)->eventQueue[(ws)->eQfront++] = *StrLoc(d); \
  124.       if ((ws)->eQfront >= EQUEUELEN) (ws)->eQfront = 0; \
  125.       (ws)->eQback = (ws)->eQfront; \
  126.       } \
  127.   }
  128. #define EVQUEEMPTY(ws) (BlkLoc((ws)->listp)->list.size == 0)
  129.  
  130. #define SHARED          0
  131. #define MUTABLE         1
  132. #define MAXCOLORNAME    40
  133. /*
  134.  * color structure, inspired by X code (xwin.h)
  135.  */
  136. typedef struct wcolor {
  137.   int        refcount;
  138.   char        name[6+MAXCOLORNAME];    /* name for WAttrib & WColor reads */
  139.   SysColor    c;
  140.   int           type;            /* SHARED or MUTABLE */
  141. } *wclrp;
  142.  
  143. /*
  144.  * we make the segment structure look like this so that we can
  145.  * cast it to POINTL structures that can be passed to GpiPolyLineDisjoint
  146.  */
  147. typedef struct {
  148.    LONG x1, y1;
  149.    LONG x2, y2;
  150.    } XSegment;
  151.  
  152. typedef POINT XPoint;
  153. typedef RECT XRectangle;
  154.  
  155. typedef struct {
  156.   LONG x, y;
  157.   LONG width, height;
  158.   double angle1, angle2;
  159.   } XArc;
  160.  
  161. /*
  162.  * macros performing row/column to pixel y,x translations
  163.  * computation is 1-based and depends on the current font's size.
  164.  * exception: XTOCOL as defined is 0-based, because that's what its
  165.  * clients seem to need.
  166.  */
  167. #define ROWTOY(wb, row)  ((row - 1) * LEADING(wb) + ASCENT(wb))
  168. #define COLTOX(wb, col)  ((col - 1) * FWIDTH(wb))
  169. #define YTOROW(wb, y)    ((y) /  LEADING(wb) + 1)
  170. #define XTOCOL(w,x)  (!FWIDTH(w) ? (x) : ((x) / FWIDTH(w)))
  171.  
  172. /*
  173.  * system size values
  174.  */
  175. #define BORDERWIDTH      (WinQuerySysValue(HWND_DESKTOP, SV_CXSIZEBORDER))
  176. #define BORDERHEIGHT     (WinQuerySysValue(HWND_DESKTOP, SV_CYSIZEBORDER))
  177. #define TITLEHEIGHT      (WinQuerySysValue(HWND_DESKTOP, SV_CYTITLEBAR))
  178.  
  179. #define STDLOCALS(w) \
  180.    wcp wc = (w)->context;\
  181.    wsp ws = (w)->window;\
  182.    HWND stdwin = ws->win;\
  183.    HBITMAP stdpix = ws->pix;\
  184.    HDC stddc = CreateWinDC(w);\
  185.    HDC pixdc = CreatePixDC(w, stddc);
  186.  
  187. #define STDFONT \
  188.    { if(stdwin)SelectObject(stddc, wc->font->font); SelectObject(pixdc,wc->font->font); }
  189.  
  190. #define FREE_STDLOCALS(w) ReleaseDC((w)->window->iconwin, stddc); DeleteDC(pixdc);
  191.  
  192. #define MAXXOBJS 8
  193.  
  194. #define GammaCorrection 1.0
  195.