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

  1. /*
  2.     dispprot.h
  3.  
  4.     % Header for display manager
  5.  
  6.     5/16/88  by Ted.
  7.  
  8.     OWL 1.1
  9.     Copyright (c) 1988, by Oakland Group, Inc.
  10.     ALL RIGHTS RESERVED.
  11.  
  12.     Revision History:
  13.     -----------------
  14.      8/24/88 Ted    Merged driver and mode in to one stub function pointer.
  15.     11/22/88 Ted    Added CheckMouse and ReadEvent functions
  16.     12/07/88 Ted    Put init function into dControl structure.
  17.     12/12/88 Ted    Merged CheckKey and CheckMouse into CheckEvent.
  18.     12/16/88 jmd    made ddisp_GetWidth/Height into functions
  19.      1/18/89 Ted    Changed call to PlotText for simplified interface.
  20.      3/20/89 Ted    Made everything refer to static curr_dmgr.
  21.      5/09/89 ted    Changed Alloc/Free terms to Open/Close.
  22.      5/11/89 ted    Added macros for setting and getting the CloseDIG fptr.
  23.      7/29/89 ted    Resurrected disp_GetInfo() macro.
  24.      8/07/89 ted    Made GetShift() related macros return 1 or 0, nothing else.
  25.      8/14/89 jmd    Added disp_EvCheck() macros
  26.      8/31/89 jmd    Added disp_EvCheck() macros (again)
  27.      9/11/89 jmd    Added disp_IsMouseTrapped() macro
  28. */
  29. /* -------------------------------------------------------------------------- */
  30. /* Global display manager structure declarations */
  31.  
  32. OEXTERN dmgr_struct curr_dmgrstruc;
  33. #define curr_dmgr     (&curr_dmgrstruc)
  34. #define curr_wmgr     (&curr_dmgrstruc.wmgr)
  35. #define disp_id()    (curr_dmgr->id)
  36. /* -------------------------------------------------------------------------- */
  37. /* Prototypes */
  38.  
  39. /* dispinit.c */
  40. extern boolean        disp_Init(_arg2(dmode_fptr dmode, class_fptr backwin));
  41. extern void            disp_Close(_arg1(void));
  42.  
  43. /* dispreinit.c */
  44. extern boolean        disp_ReInit(_arg1(dmode_fptr dmode));
  45.  
  46. /* dispcurr.c */
  47. extern VOID *disp_GetCurrent(_arg1(void));
  48. extern boolean disp_SetCurrent(_arg1(VOID *dmgrp));
  49.  
  50. /* disp.c */
  51. extern boolean        disp_Ok(_arg1(void));
  52. extern int             disp_GetHeight(_arg1(void));
  53. extern int             disp_GetWidth(_arg1(void));
  54. extern ofont_type    disp_OpenFont(_arg1(fontreq_struct *fontreq));
  55. extern void            disp_CloseFont(_arg1(ofont_type font));
  56.  
  57. /* Character attribute mapping */
  58. extern void            disp_SetAttrColors(_arg3(byte attr, opixval bg, opixval fg));
  59. extern opixval        disp_GetAttrFgColor(_arg1(byte attr));
  60. extern opixval        disp_GetAttrBgColor(_arg1(byte attr));
  61.  
  62. #define disp_SetMapEntry(attr, bg, fg)                \
  63.     disp_SetAttrColors(attr, bg, fg)
  64. #define disp_GetMapEntry(attr, bgp, fgp)            \
  65.     disp_GetAttrColors(attr, bgp, fgp)
  66.  
  67. /* Hardware pixval-to-RGB color palette mapping */
  68. extern void            disp_SetColMapEntry(_arg4(opixval icol,
  69.                                         olevel red, olevel green, olevel blue));
  70. /* border-to-window coordinate mapping */
  71. extern boolean        ptd_SetInner(_arg3(ptd_struct *ptd, ptd_struct *inptd, opbox *inboxp));
  72.  
  73. /* dispmono.c */
  74. extern void            disp_MapMono(_arg1(boolean));
  75.  
  76. /* dispclr.c */
  77. extern void            disp_Clear(_arg1(opixval color));
  78. extern void            disp_Repaint(_arg1(void));
  79. /* -------------------------------------------------------------------------- */
  80. /* Device info request macros */
  81.  
  82. #define disp_GetInfo()                (curr_dmgr->disp.info)
  83. #define disp_GetMode()                (disp_GetInfo()->mode)
  84. #define disp_GetPixWidth()            pmap_GetWidth(disp_GetInfo()->dispmap)
  85. #define disp_GetPixHeight()            pmap_GetHeight(disp_GetInfo()->dispmap)
  86. #define disp_GetColMapNentries()    (disp_GetInfo()->defcolmap.nentries)
  87. #define disp_GetDefColMapp()        (disp_GetInfo()->defcolmap)
  88. #define disp_GetColors()            (disp_GetInfo()->ncolors)
  89. #define disp_hardcursor()            (disp_GetInfo()->hardcursor)
  90. #define disp_GetByteOrder()            (disp_GetInfo()->byteorder)
  91. #define disp_dispmap()                (disp_GetInfo()->dispmap)
  92. #define disp_GetDefFont()            (&disp_GetInfo()->def_font)
  93.  
  94. #define disp_vtscroll()                ((boolean) curr_dmgr->disp.dig.vtscroll)
  95. #define disp_hzscroll()                ((boolean) curr_dmgr->disp.dig.hzscroll)
  96. #define disp_TextFree()                ((boolean) curr_dmgr->disp.dig.textfree)
  97. #define disp_type()                    (curr_dmgr->disp.dig.type)
  98. #define disp_version()                (curr_dmgr->disp.dig.version)
  99.  
  100. #define disp_EvCheck()                ((boolean) curr_dmgr->disp.dig.evcheck)
  101. #define disp_SetEvCheck(c)            (curr_dmgr->disp.dig.evcheck = (c))
  102.  
  103. #define disp_MouseDistout()            (curr_dmgr->disp.mouse_distout)
  104. #define disp_MouseTimeout()            (curr_dmgr->disp.mouse_timeout)
  105.  
  106. #define disp_clipbox(boxp)            pmap_clipbox(disp_dispmap(), boxp)
  107. #define disp_clippoint(xp, yp)        pmap_clippoint(disp_dispmap(), xp, yp)
  108. /* -------------------------------------------------------------------------- */
  109. /* DIG control function ptr macros */
  110.  
  111. #define    disp_Control(msg, indata, outdata)        \
  112.     (*curr_dmgr->disp.dig.dControl)(msg, (VOID *)(indata), (VOID *)(outdata))
  113.  
  114. #define    pmap_Control(msg, indata, outdata)        \
  115.     (*curr_dmgr->disp.dig.pControl)(msg, (VOID *)(indata), (VOID *)(outdata))
  116.  
  117. #define    hard_Control(msg, indata, outdata)            \
  118.     (*curr_dmgr->disp.dig.hControl)(msg, (VOID *)(indata), (VOID *)(outdata))
  119.  
  120. #define    disp_CloseDIG()                                \
  121.     ((*curr_dmgr->disp.dig.CloseDIG)(&curr_dmgr->disp.dig), curr_dmgr->disp.dig.data = NULL)
  122.  
  123. /* Macros for getting and setting the CloseDIG function ptr */
  124. #define disp_GetCloseDIG()            (curr_dmgr->disp.dig.CloseDIG)
  125. #define disp_SetCloseDIG(cd)        (curr_dmgr->disp.dig.CloseDIG = (cd))
  126. /* -------------------------------------------------------------------------- */
  127. /* DIG ptd function ptr macros */
  128.  
  129. #define ptd_DrawCursor(ptd, ctype)    (*curr_dmgr->disp.dig.pDrawCursor)(ptd, ctype)
  130.  
  131. #define ptd_PlotText(ptd, x, y, cbuf, rc, ra, slen)            \
  132.     (*curr_dmgr->disp.dig.pPlotText)(ptd, x, y, cbuf, rc, ra, slen)
  133.  
  134. #define ptd_Clear(ptd, color)        (*curr_dmgr->disp.dig.pClear)(ptd, color)
  135.  
  136. #define ptd_ScrollBoxVt(ptd, n)        (*curr_dmgr->disp.dig.pScrollBoxVt)(ptd, n)
  137.  
  138. #define ptd_ScrollBoxHz(ptd, n)        (*curr_dmgr->disp.dig.pScrollBoxHz)(ptd, n)
  139.  
  140. #define ptd_DrawPixmap(ptd, pixmap, pmboxp)                    \
  141.     (*curr_dmgr->disp.dig.pDrawPixmap)(ptd, pixmap, pmboxp)
  142.  
  143. #define ptd_ReadPixmap(ptd, pixmap, pmboxp)                    \
  144.     (*curr_dmgr->disp.dig.pReadPixmap)(ptd, pixmap, pmboxp)
  145.  
  146. #define ptd_PlotTextbuf(ptd, x, y, cbuf, ra, slen)            \
  147.     ptd_PlotText(ptd, x, y, cbuf, 0, ra, slen)
  148.  
  149. #define ptd_PlotChar(ptd, x, y, rc, ra, slen)                \
  150.     ptd_PlotText(ptd, x, y, NULL, rc, ra, slen)
  151.  
  152. #define ptd_EraseCursor(ptd)                                \
  153.     ptd_DrawCursor(ptd, CURSOR_NONE)
  154. /* -------------------------------------------------------------------------- */
  155. /* Disp function macros */
  156.  
  157. #define disp_InitMode()                disp_Control(DC_INITMODE, NULL, NULL)
  158. #define disp_RestoreMode()            disp_Control(DC_RESTOREMODE, NULL, NULL)
  159.  
  160. #define disp_Cache()                disp_Control(DC_CACHE, NULL, NULL)
  161. #define disp_Flush()                disp_Control(DC_FLUSH, NULL, NULL)
  162. #define disp_HideMouse()            disp_Cache()
  163. #define disp_ShowMouse()            disp_Flush()
  164.  
  165. #define disp_IsTrappedMouse()        (curr_wmgr->trapmousewin != NULL)
  166.  
  167. /* Character attribute mapping */
  168. #define disp_GetAttrColors(attr, bgp, fgp)            \
  169.     (*(bgp) = disp_GetAttrBgColor(attr),            \
  170.      *(fgp) = disp_GetAttrFgColor(attr))
  171.  
  172. #define disp_getattrbg(attrp, bgp) disp_Control(DC_GETATTRBG, attrp, bgp)
  173. #define disp_getattrfg(attrp, fgp) disp_Control(DC_GETATTRFG, attrp, fgp)
  174.  
  175. /* Hardware pixval-to-RGB color palette mapping */
  176. #define disp_SetColMap(colmap)        disp_Control(DC_SETCOLMAP, (VOID *)colmap, NULL)
  177. #define disp_GetColMap(colmap)        disp_Control(DC_GETCOLMAP, NULL, (VOID *)colmap)
  178. #define disp_SetColMapDefault()        disp_SetColMap(disp_GetDefColMapp())
  179. /* -------------------------------------------------------------------------- */
  180. /* Hardware functions and function ptr macros */
  181.  
  182. /* kbread.c */
  183. extern unsigned    kb_Read(_arg1(void));
  184. extern boolean    kb_CheckWait(_arg1(unsigned wait));
  185. extern void        kb_Clear(_arg1(void));        /* clear keyboard buffer function */
  186.  
  187. /* mouseini.c */
  188. extern boolean     hard_InitMouse(_arg1(void));
  189. extern void     hard_DeinitMouse(_arg1(void));
  190.  
  191. #define hard_GetMouseTimeout()        (curr_dmgr->disp.mouse_timeout)
  192. #define hard_SetMouseTimeout(t)     (curr_dmgr->disp.mouse_timeout = (t))
  193.  
  194. #define kb_Check()                    kb_CheckWait(0)
  195. #define hard_CheckEvent(wait)        (*curr_dmgr->disp.dig.hCheckEvent)(wait)
  196. #define hard_ReadEvent(evp)            (*curr_dmgr->disp.dig.hReadEvent)(evp)
  197. #define kb_GetShift()                (*curr_dmgr->disp.dig.hGetShift)()
  198.  
  199. #define kb_Shift()                    ((kb_GetShift() & 0x03) != 0)
  200. #define kb_Control()                ((kb_GetShift() & 0x04) != 0)
  201. #define kb_Alt()                    ((kb_GetShift() & 0x08) != 0)
  202. #define kb_ScrollLock()                ((kb_GetShift() & 0x10) != 0)
  203. #define kb_NumLock()                ((kb_GetShift() & 0x20) != 0)
  204. #define kb_CapsLock()                ((kb_GetShift() & 0x40) != 0)
  205. #define kb_Insert()                    ((kb_GetShift() & 0x80) != 0)
  206. #define    ascii(key)                    ((char)((key) & 0x00FF))
  207.  
  208. #define TIMER_LIMIT        ((unsigned)(10*60*100))    /* Ten minutes in hundredths */
  209.  
  210. #define    hard_Timer()                (*curr_dmgr->disp.dig.hTimer)()
  211. #define    hard_Pause(duration)        (*curr_dmgr->disp.dig.hPause)(duration)
  212. #define    hard_Sound(pitch, duration)                    \
  213.     (*curr_dmgr->disp.dig.hSound)(pitch, duration)
  214.  
  215. #define hard_Tone()                    hard_Sound(1500, 1)
  216.  
  217. /* Alias hard_Speaker to hard_Sound */
  218. #define    hard_Speaker(pitch, dur)    hard_Sound(pitch, dur)
  219. #define    tone()                        hard_Tone()
  220.  
  221. #define    hard_SetSound(on)                            \
  222.     ((on) ? hard_Control(HC_SETSOUNDON, NULL, NULL) : \
  223.             hard_Control(HC_SETSOUNDOFF, NULL, NULL))
  224.  
  225. #define    hard_IsSoundOn()            ((boolean)hard_Control(HC_GETSOUNDON, NULL, NULL))
  226. #define    hard_IsMouseOn()            ((boolean)hard_Control(HC_ISMOUSEON, NULL, NULL))
  227.  
  228. /** reentrancy protection functions **/
  229. #define hard_ProtectDmgr()            hard_Control(HC_PROTECT, NULL, NULL)
  230. #define hard_UnProtectDmgr()        hard_Control(HC_UNPROTECT, NULL, NULL)
  231. /* -------------------------------------------------------------------------- */
  232.  
  233.