home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c185 / 2.ddi / OWLSRC.EXE / CSCAPE / SOURCE / PMAPDECL.H < prev    next >
Encoding:
C/C++ Source or Header  |  1989-09-06  |  3.7 KB  |  95 lines

  1. /*
  2.     pmapdecl.h
  3.  
  4.     % declarations for pixel maps
  5.  
  6.     OWL 1.1
  7.     Copyright (c) 1988 by Oakland Group, Inc.
  8.     ALL RIGHTS RESERVED.
  9.  
  10.     Revision History:
  11.     -----------------
  12.      2/04/89 ted:    Moved device-specific stuff into dig level (dpmap_Control)
  13.      2/23/88 ted:    Added pmap_Copy.
  14.      5/09/89 ted    Changed Alloc/Free terms to Open/Close.
  15.      7/05/89 ted    Added pmap_IoInit macros and related stuff.
  16.      7/12/89 ted    Converted '_func' prototypes from typedef to macro.
  17.      8/08/89 ted    Added bmap stuff.
  18. */
  19. /* -------------------------------------------------------------------------- */
  20. /* Bitmap stuff */
  21. #define bmap_GetArraySize(w,h)        ((h) * (((w) + 7) / 8))
  22. #define bmap_GetSize(w,h)            (bmap_GetArraySize(w, h) + 2*sizeof(odim))
  23. #define bmap_GetLineBytes(bm)        (((bm)->width + 7) / 8)
  24. #define bmap_GetLine(bm,l)            ((bm)->array + (l) * bmap_GetLineBytes(bm))
  25.  
  26. #define bmap_struct(w, h)                            \
  27.             struct {odim width; odim height; byte array[bmap_GetArraySize(w, h)];}
  28.  
  29. typedef bmap_struct(1,1) *bmap_type;
  30. /* -------------------------------------------------------------------------- */
  31.  
  32. typedef struct pmap_struct {
  33.     odim width;            /* width  of pixmap in pixels */
  34.     odim height;        /* height of pixmap in pixels */
  35.     boolean onboard;    /* to request pixmap in display memory */
  36.     boolean onscreen;    /* if onboard, to request pixmap in visible display */
  37.     opcoord xpos, ypos;    /* if onscreen, position of requested pixmap on screen */
  38.     VOID *xdata;        /* pointer to implementation-specific data */
  39. } *pmap_type;
  40.  
  41. typedef struct pmap_struct pmapreq_struct;
  42.  
  43. typedef struct {
  44.     pmap_type pmap;
  45.     opixval color;
  46. } pmapclearreq_struct;
  47.  
  48. typedef struct {
  49.     pmap_type spmap;
  50.     pmap_type dpmap;
  51. } pmapcopyreq_struct;
  52.  
  53. #define pmapioreq_func(fname)        int fname(_arg3(int msg, VOID *indata, VOID *outdata))
  54. typedef pmapioreq_func ((*pmapioreq_fptr));
  55. /* -------------------------------------------------------------------------- */
  56. /* pmap.c */
  57. extern pmap_type pmap_OpenOnboard(_arg6(odim width, odim height,
  58.                 boolean onboard, boolean onscreen, opcoord xpos, opcoord ypos));
  59. extern void pmap_Clear(_arg2(pmap_type pmap, opixval color));
  60. extern void pmap_Copy(_arg2(pmap_type dpmap, pmap_type spmap));
  61.  
  62. /* pmapload.c */
  63. extern pmap_type pmap_LoadBfile(_arg3(VOID *bfile, char *name, ocolmap_type crange));
  64. extern pmap_type pmap_Load(_arg2(FILE *fd, ocolmap_type crange));
  65. extern boolean pmap_SaveBfile(_arg4(VOID *bfile, char *name, pmap_type pmap, ocolmap_type crange));
  66. extern boolean pmap_Save(_arg3(FILE *fd, pmap_type pmap, ocolmap_type crange));
  67. extern void pmap_IoInitFunc(_arg1(pmapioreq_fptr iofunc));
  68. extern pmapioreq_func (pmap_IoNullReq);
  69. /* -------------------------------------------------------------------------- */
  70.  
  71. #define pmap_Open(width, height)    pmap_OpenOnboard(width, height, FALSE, FALSE, 0, 0)
  72. #define pmap_Close(pmap)            pmap_Control(PC_CLOSEPMAP, pmap, NULL)
  73.  
  74. #define pmap_GetWidth(pmap)            ((pmap)->width)
  75. #define pmap_GetHeight(pmap)        ((pmap)->height)
  76.  
  77. #define pmap_clippoint(pmap,xp,yp)                    \
  78.     opwh_clippoint(pmap_GetWidth(pmap), pmap_GetHeight(pmap), (xp), (yp))
  79. #define pmap_clipbox(pmap,boxp)                        \
  80.     opwh_clipbox(pmap_GetWidth(pmap), pmap_GetHeight(pmap), (boxp))
  81.  
  82. /*    This pmap_Ok macro assumes that a valid pixel map will:
  83.         - have its boolean variable values either 0 or 1.
  84.         - have its xpos set non-negative.
  85.         - have its xpos non-zero if onboard is FALSE
  86. */
  87. #define pmap_Ok(pm)                    ((pm) != NULL && \
  88.     ((unsigned)(pm)->onboard) <= 1 &&                \
  89.     ((unsigned)(pm)->onscreen) <= 1 &&                \
  90.     ( ((pm)->onboard == FALSE) ? ((pm)->xpos > 0) : ((pm)->xpos >= 0) ))
  91.  
  92. #define pmap_IoInit()                pmap_IoInitFunc(def_PmapIoReq)
  93. /* -------------------------------------------------------------------------- */
  94.  
  95.