home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / historic / v941.tgz / icon.v941src.tar / icon.v941src / src / h / mswin.h < prev    next >
Text File  |  2000-08-17  |  6KB  |  202 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 ASCENTC(wc)  ((wc)->font->ascent)
  27. #define DESCENT(w) ((w)->context->font->descent)
  28. #define LEADING(w) ((w)->context->leading)
  29. #define FHEIGHT(w) ((w)->context->font->height)
  30. #define FHEIGHTC(wc) ((wc)->font->height)
  31. #define FWIDTH(w)  ((w)->context->font->charwidth)
  32. #define FWIDTHC(wc)  ((wc)->font->charwidth)
  33. #define LINEWIDTH(w) ((w)->context->pen.lopnWidth.x)
  34. #define DISPLAYHEIGHT(w) devicecaps(w, VERTRES)
  35. #define DISPLAYWIDTH(w) devicecaps(w, HORZRES)
  36. #define wsync(w) /* noop */
  37. #define SysColor unsigned long
  38. #define RED(x) GetRValue(x)
  39. #define GREEN(x) GetGValue(x)
  40. #define BLUE(x) GetBValue(x)
  41. #define ARCWIDTH(arc) (arc).width
  42. #define ARCHEIGHT(arc) (arc).height
  43. /*
  44.  * These get fixed up in the window-system-specific code
  45.  */
  46. #define RECX(rec) (rec).left
  47. #define RECY(rec) (rec).top
  48. #define RECWIDTH(rec) (rec).right
  49. #define RECHEIGHT(rec) (rec).bottom
  50. /*
  51.  *
  52.  */
  53. #define ANGLE(ang) (ang)
  54. #define EXTENT(ang) (ang)
  55. #define FULLARC 2 * Pi
  56. #define ISICONIC(w) (IsIconic((w)->window->iconwin))
  57. #define ISFULLSCREEN(w) 0
  58. #define ISROOTWIN(w) (0) 0
  59. #define ISNORMALWINDOW(w) 0
  60. #define ICONFILENAME(w) ""
  61. #define ICONLABEL(w) ((w)->window->iconlabel)
  62. #define WINDOWLABEL(w) ((w)->window->windowlabel)
  63.  
  64. #define MAXDESCENDER(w) DESCENT(w)
  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.  * input masks
  92.  */
  93. #define PointerMotionMask    1
  94.  
  95. /*
  96.  * something I think should be #defined
  97.  */
  98. #define EOS                  '\0'
  99.  
  100. /* size of the working buffer, used for dialog messages and such */
  101. #define PMSTRBUFSIZE         2048
  102. /*
  103.  * the bitmasks for the modifier keys
  104.  */
  105. #define ControlMask          (1L << 16L)
  106. #define Mod1Mask             (2L << 16L)
  107. #define ShiftMask            (4L << 16L)
  108. #define VirtKeyMask          (8L << 16L)
  109.  
  110. /* some macros for Windows */
  111.  
  112. #define MAKERGB(r,g,b) RGB(r,g,b)
  113. #define RGB16TO8(x) if ((x) > 0xff) (x) = (((x) >> 8) & 0xff)
  114. #define hidecrsr(ws) if (ws->hasCaret) HideCaret(ws->iconwin)
  115. #define showcrsr(ws) if (ws->hasCaret) ShowCaret(ws->iconwin)
  116. #define FNTWIDTH(size) ((size) & 0xFFFF)
  117. #define FNTHEIGHT(size) ((size) >> 16)
  118. #define MAKEFNTSIZE(height, width) (((height) << 16) | (width))
  119. #define WaitForEvent(msgnum, msgstruc) ObtainEvents(NULL, WAIT_EVT, msgnum, msgstruc)
  120.  
  121. /*
  122.  * "get" means remove them from the Icon list and put them on the ghost que
  123.  */
  124. #define EVQUEGET(ws,d) { \
  125.   int i;\
  126.   if (!c_get((struct b_list *)BlkLoc((ws)->listp),&d)) fatalerr(0,NULL); \
  127.   if (Qual(d)) {\
  128.       (ws)->eventQueue[(ws)->eQfront++] = *StrLoc(d); \
  129.       if ((ws)->eQfront >= EQUEUELEN) (ws)->eQfront = 0; \
  130.       (ws)->eQback = (ws)->eQfront; \
  131.       } \
  132.   }
  133. #define EVQUEEMPTY(ws) (BlkLoc((ws)->listp)->list.size == 0)
  134.  
  135. #define SHARED          0
  136. #define MUTABLE         1
  137. #define MAXCOLORNAME    40
  138. /*
  139.  * color structure, inspired by X code (xwin.h)
  140.  */
  141. typedef struct wcolor {
  142.   int        refcount;
  143.   char        name[6+MAXCOLORNAME];    /* name for WAttrib & WColor reads */
  144.   SysColor    c;
  145.   int           type;            /* SHARED or MUTABLE */
  146. } *wclrp;
  147.  
  148. /*
  149.  * we make the segment structure look like this so that we can
  150.  * cast it to POINTL structures that can be passed to GpiPolyLineDisjoint
  151.  */
  152. typedef struct {
  153.    LONG x1, y1;
  154.    LONG x2, y2;
  155.    } XSegment;
  156.  
  157. typedef POINT XPoint;
  158. typedef RECT XRectangle;
  159.  
  160. typedef struct {
  161.   LONG x, y;
  162.   LONG width, height;
  163.   double angle1, angle2;
  164.   } XArc;
  165.  
  166. /*
  167.  * macros performing row/column to pixel y,x translations
  168.  * computation is 1-based and depends on the current font's size.
  169.  * exception: XTOCOL as defined is 0-based, because that's what its
  170.  * clients seem to need.
  171.  */
  172. #define ROWTOY(wb, row)  ((row - 1) * LEADING(wb) + ASCENT(wb))
  173. #define COLTOX(wb, col)  ((col - 1) * FWIDTH(wb))
  174. #define YTOROW(wb, y)    (((y) - ASCENT(w)) /  LEADING(wb) + 1)
  175. #define XTOCOL(w,x)  (!FWIDTH(w) ? (x) : ((x) / FWIDTH(w)))
  176.  
  177. /*
  178.  * system size values
  179.  */
  180. #define BORDERWIDTH      (GetSystemMetrics(SM_CXBORDER)) /* 1 */
  181. #define BORDERHEIGHT     (GetSystemMetrics(SM_CYBORDER)) /* 1 */
  182. #define TITLEHEIGHT      (GetSystemMetrics(SM_CYCAPTION)) /* 20 */
  183. #define FRAMEWIDTH     (GetSystemMetrics(SM_CXFRAME))   /* 4 */
  184. #define FRAMEHEIGHT     (GetSystemMetrics(SM_CYFRAME))   /* 4 */
  185.  
  186. #define STDLOCALS(w) \
  187.    wcp wc = (w)->context;\
  188.    wsp ws = (w)->window;\
  189.    HWND stdwin = ws->win;\
  190.    HBITMAP stdpix = ws->pix;\
  191.    HDC stddc = CreateWinDC(w);\
  192.    HDC pixdc = CreatePixDC(w, stddc);
  193.  
  194. #define STDFONT \
  195.    { if(stdwin)SelectObject(stddc, wc->font->font); SelectObject(pixdc,wc->font->font); }
  196.  
  197. #define FREE_STDLOCALS(w) do { SelectObject(pixdc, (w)->window->theOldPix); ReleaseDC((w)->window->iconwin, stddc); DeleteDC(pixdc); } while (0)
  198.  
  199. #define MAXXOBJS 8
  200.  
  201. #define GammaCorrection 1.0
  202.