home *** CD-ROM | disk | FTP | other *** search
- /*
- dispprot.h
-
- % Header for display manager
-
- 5/16/88 by Ted.
-
- OWL 1.2
- Copyright (c) 1988, by Oakland Group, Inc.
- ALL RIGHTS RESERVED.
-
- Revision History:
- -----------------
- 8/24/88 Ted Merged driver and mode in to one stub function pointer.
- 11/22/88 Ted Added CheckMouse and ReadEvent functions
- 12/07/88 Ted Put init function into dControl structure.
- 12/12/88 Ted Merged CheckKey and CheckMouse into CheckEvent.
- 12/16/88 jmd made ddisp_GetWidth/Height into functions
- 1/18/89 Ted Changed call to PlotText for simplified interface.
- 3/20/89 Ted Made everything refer to static curr_dmgr.
- 5/09/89 ted Changed Alloc/Free terms to Open/Close.
- 5/11/89 ted Added macros for setting and getting the CloseDIG fptr.
- 7/29/89 ted Resurrected disp_GetInfo() macro.
- 8/07/89 ted Made GetShift() related macros return 1 or 0, nothing else.
- 8/14/89 jmd Added disp_EvCheck() macros
- 8/31/89 jmd Added disp_EvCheck() macros (again)
- 9/11/89 jmd Added disp_IsMouseTrapped() macro
- 11/27/89 ted Moved disp_IsMouseTrapped() macro to winproto where it can be happy with its sisters.
- 2/14/90 ted Got rid of fontreq_struct. Just use fontdesc_struct.
- 3/11/90 ted Added prototypes for disp_GetBiggerFont & disp_MapPcColors.
- 3/21/90 ted disp_HideMouse disp_ShowMouse macros now use DC_HIDE/SHOWMOUSE msgs.
- 3/28/90 jmd ansi-fied
- 5/12/90 jmd changed the ascii macro, converted scancodes to ints
- 9/06/90 jmd converted the ascii macro into a function
- 10/10/90 ted Added disp_IsTextMode macro.
- 11/06/90 ted moved pmapioreq stuff here from pmapdecl.h
- */
- /* -------------------------------------------------------------------------- */
- /* Global display manager structure declarations */
-
- OEXTERN dmgr_struct curr_dmgrstruc;
- #define curr_dmgr (&curr_dmgrstruc)
- #define curr_wmgr (&curr_dmgrstruc.wmgr)
- #define disp_id() (curr_dmgr->id)
- /* -------------------------------------------------------------------------- */
- /* Prototypes */
-
- /* DISPINIT.C */
- extern boolean disp_Init(dmode_fptr dmode, class_fptr backwin);
- extern void disp_Close(void);
-
- /* DISPREIN.C */
- extern boolean disp_ReInit(dmode_fptr dmode);
-
- /* DISPCURR.C */
- extern VOID *disp_GetCurrent(void);
- extern boolean disp_SetCurrent(VOID *dispp);
- extern boolean disp_RestoreCurrent(VOID *dispp);
-
- /* DISP.C */
- extern boolean disp_Ok(void);
- extern int disp_GetHeight(void);
- extern int disp_GetWidth(void);
- extern ofont_type disp_OpenFont(fontdesc_struct *fontreq);
- extern void disp_CloseFont(ofont_type font);
- extern void disp_SetAttrColors(byte attr, opixval bg, opixval fg);
- extern opixval disp_GetAttrFgColor(byte attr);
- extern opixval disp_GetAttrBgColor(byte attr);
- extern void disp_SetColMapEntry(opixval icol, olevel red, olevel green, olevel blue);
- extern boolean ptd_SetInner(ptd_struct *ptd, ptd_struct *inptd, opbox *inboxp);
-
- /* Character attribute mapping */
- #define disp_SetMapEntry(attr, bg, fg) \
- disp_SetAttrColors(attr, bg, fg)
- #define disp_GetMapEntry(attr, bgp, fgp) \
- disp_GetAttrColors(attr, bgp, fgp)
-
- /* DISPCLR.C */
- extern void disp_Clear(opixval color);
- extern void disp_Repaint(void);
-
- /* DISPMONO.C */
- extern void disp_MapMono(boolean mono);
-
- /* DISPPCCO.C */
- extern void disp_MapPcColors(void);
- extern void disp_MapAttrColors(ocolmap_type cmap);
-
- /* DISPBFON.C */
- extern ofont_type disp_GetBiggerFont(ofont_type font);
- extern ofont_type disp_GetSmallerFont(ofont_type font);
-
- /* PMAPLOAD.C */
- extern void pmap_IoInitFunc(pmapioreq_fptr iofunc);
- extern pmapioreq_func (pmap_IoNullReq);
-
- /* pmap input/output enabling initialization function */
- #define pmap_IoInit() pmap_IoInitFunc(def_PmapIoReq)
- /* -------------------------------------------------------------------------- */
- /* Device info request macros */
-
- #define disp_GetInfo() (curr_dmgr->disp.info)
- #define disp_GetMode() (disp_GetInfo()->mode)
- #define disp_GetPixWidth() pmap_GetWidth(disp_GetInfo()->dispmap)
- #define disp_GetPixHeight() pmap_GetHeight(disp_GetInfo()->dispmap)
- #define disp_GetColMapNentries() (disp_GetInfo()->defcolmap.nentries)
- #define disp_GetDefColMapp() (disp_GetInfo()->defcolmap)
- #define disp_GetColors() (disp_GetInfo()->ncolors)
- #define disp_hardcursor() (disp_GetInfo()->hardcursor)
- #define disp_GetByteOrder() (disp_GetInfo()->byteorder)
- #define disp_dispmap() (disp_GetInfo()->dispmap)
- #define disp_GetDefFont() (&disp_GetInfo()->def_font)
- #define disp_IsTextMode() (ofont_GetHeight(disp_GetDefFont()) == 1)
-
- #define disp_vtscroll() ((boolean) curr_dmgr->disp.dig.vtscroll)
- #define disp_hzscroll() ((boolean) curr_dmgr->disp.dig.hzscroll)
- #define disp_TextFree() ((boolean) curr_dmgr->disp.dig.textfree)
- #define disp_type() (curr_dmgr->disp.dig.type)
- #define disp_version() (curr_dmgr->disp.dig.version)
-
- #define disp_EvCheck() ((boolean) curr_dmgr->disp.dig.evcheck)
- #define disp_SetEvCheck(c) (curr_dmgr->disp.dig.evcheck = (c))
-
- #define disp_MouseDistout() (curr_dmgr->disp.mouse_distout)
- #define disp_MouseTimeout() (curr_dmgr->disp.mouse_timeout)
-
- #define disp_clipbox(boxp) pmap_clipbox(disp_dispmap(), boxp)
- #define disp_clippoint(xp, yp) pmap_clippoint(disp_dispmap(), xp, yp)
- /* -------------------------------------------------------------------------- */
- /* DIG control function ptr macros */
-
- #define disp_Control(msg, indata, outdata) \
- (*curr_dmgr->disp.dig.dControl)(msg, (VOID *)(indata), (VOID *)(outdata))
-
- #define pmap_Control(msg, indata, outdata) \
- (*curr_dmgr->disp.dig.pControl)(msg, (VOID *)(indata), (VOID *)(outdata))
-
- #define hard_Control(msg, indata, outdata) \
- (*curr_dmgr->disp.dig.hControl)(msg, (VOID *)(indata), (VOID *)(outdata))
-
- #define disp_CloseDIG() \
- ((*curr_dmgr->disp.dig.CloseDIG)(&curr_dmgr->disp.dig), curr_dmgr->disp.dig.data = NULL)
-
- /* Macros for getting and setting the CloseDIG function ptr */
- #define disp_GetCloseDIG() (curr_dmgr->disp.dig.CloseDIG)
- #define disp_SetCloseDIG(cd) (curr_dmgr->disp.dig.CloseDIG = (cd))
- /* -------------------------------------------------------------------------- */
- /* DIG ptd function ptr macros */
-
- #define ptd_DrawCursor(ptd, ctype) (*curr_dmgr->disp.dig.pDrawCursor)(ptd, ctype)
-
- #define ptd_PlotText(ptd, x, y, cbuf, rc, ra, slen) \
- (*curr_dmgr->disp.dig.pPlotText)(ptd, x, y, cbuf, rc, ra, slen)
-
- #define ptd_Clear(ptd, color) (*curr_dmgr->disp.dig.pClear)(ptd, color)
-
- #define ptd_ScrollBoxVt(ptd, n) (*curr_dmgr->disp.dig.pScrollBoxVt)(ptd, n)
-
- #define ptd_ScrollBoxHz(ptd, n) (*curr_dmgr->disp.dig.pScrollBoxHz)(ptd, n)
-
- #define ptd_DrawPixmap(ptd, pixmap, pmboxp) \
- (*curr_dmgr->disp.dig.pDrawPixmap)(ptd, pixmap, pmboxp)
-
- #define ptd_ReadPixmap(ptd, pixmap, pmboxp) \
- (*curr_dmgr->disp.dig.pReadPixmap)(ptd, pixmap, pmboxp)
-
- #define ptd_PlotTextbuf(ptd, x, y, cbuf, ra, slen) \
- ptd_PlotText(ptd, x, y, cbuf, 0, ra, slen)
-
- #define ptd_PlotChar(ptd, x, y, rc, ra, slen) \
- ptd_PlotText(ptd, x, y, NULL, rc, ra, slen)
-
- #define ptd_EraseCursor(ptd) \
- ptd_DrawCursor(ptd, CURSOR_NONE)
- /* -------------------------------------------------------------------------- */
- /* Disp function macros */
-
- #define disp_InitMode() disp_Control(DC_INITMODE, NULL, NULL)
- #define disp_RestoreMode() disp_Control(DC_RESTOREMODE, NULL, NULL)
-
- #define disp_Cache() disp_Control(DC_CACHE, NULL, NULL)
- #define disp_Flush() disp_Control(DC_FLUSH, NULL, NULL)
- #define disp_HideMouse() disp_Control(DC_HIDEMOUSE, NULL, NULL)
- #define disp_ShowMouse() disp_Control(DC_SHOWMOUSE, NULL, NULL)
-
- /* Character attribute mapping */
- #define disp_GetAttrColors(attr, bgp, fgp) \
- (*(bgp) = disp_GetAttrBgColor(attr), \
- *(fgp) = disp_GetAttrFgColor(attr))
-
- #define disp_getattrbg(attrp, bgp) disp_Control(DC_GETATTRBG, attrp, bgp)
- #define disp_getattrfg(attrp, fgp) disp_Control(DC_GETATTRFG, attrp, fgp)
-
- /* Hardware pixval-to-RGB color palette mapping */
- #define disp_SetColMap(colmap) disp_Control(DC_SETCOLMAP, (VOID *)colmap, NULL)
- #define disp_GetColMap(colmap) disp_Control(DC_GETCOLMAP, NULL, (VOID *)colmap)
- #define disp_SetColMapDefault() disp_SetColMap(disp_GetDefColMapp())
- /* -------------------------------------------------------------------------- */
- /* Hardware functions and function ptr macros */
-
- /* KBREAD.C */
- extern int kb_Read(void);
- extern boolean kb_CheckWait(unsigned wait);
- extern void kb_Clear(void);
- extern int ascii(int scancode);
-
- /* MOUSEINI.C */
- extern boolean hard_InitMouse(void);
- extern void hard_DeinitMouse(void);
-
- #define hard_GetMouseTimeout() (curr_dmgr->disp.mouse_timeout)
- #define hard_SetMouseTimeout(t) (curr_dmgr->disp.mouse_timeout = (t))
-
- #define kb_Check() kb_CheckWait(0)
- #define hard_CheckEvent(wait) (*curr_dmgr->disp.dig.hCheckEvent)(wait)
- #define hard_ReadEvent(evp) (*curr_dmgr->disp.dig.hReadEvent)(evp)
- #define kb_GetShift() (*curr_dmgr->disp.dig.hGetShift)()
-
- #define kb_Shift() ((kb_GetShift() & 0x03) != 0)
- #define kb_Control() ((kb_GetShift() & 0x04) != 0)
- #define kb_Alt() ((kb_GetShift() & 0x08) != 0)
- #define kb_ScrollLock() ((kb_GetShift() & 0x10) != 0)
- #define kb_NumLock() ((kb_GetShift() & 0x20) != 0)
- #define kb_CapsLock() ((kb_GetShift() & 0x40) != 0)
- #define kb_Insert() ((kb_GetShift() & 0x80) != 0)
-
- #define TIMER_LIMIT ((unsigned)(10*60*100)) /* Ten minutes in hundredths */
-
- #define hard_Timer() (*curr_dmgr->disp.dig.hTimer)()
- #define hard_Pause(duration) (*curr_dmgr->disp.dig.hPause)(duration)
- #define hard_Sound(pitch, duration) \
- (*curr_dmgr->disp.dig.hSound)(pitch, duration)
-
- #define hard_Tone() hard_Sound(1500, 1)
-
- /* Alias hard_Speaker to hard_Sound */
- #define hard_Speaker(pitch, dur) hard_Sound(pitch, dur)
- #define tone() hard_Tone()
-
- #define hard_SetSound(on) \
- ((on) ? hard_Control(HC_SETSOUNDON, NULL, NULL) : \
- hard_Control(HC_SETSOUNDOFF, NULL, NULL))
-
- #define hard_IsSoundOn() ((boolean)hard_Control(HC_GETSOUNDON, NULL, NULL))
- #define hard_IsMouseOn() ((boolean)hard_Control(HC_ISMOUSEON, NULL, NULL))
-
- /* reentrancy protection functions */
- #define hard_ProtectDmgr() hard_Control(HC_PROTECT, NULL, NULL)
- #define hard_UnProtectDmgr() hard_Control(HC_UNPROTECT, NULL, NULL)
- /* -------------------------------------------------------------------------- */
-
-