home *** CD-ROM | disk | FTP | other *** search
- /*
- disp.c
-
- % Display object hardware-independent code.
-
- 5/16/88 by Ted.
-
- OWL 1.2
- Copyright (c) 1988, 1989 by Oakland Group, Inc.
- ALL RIGHTS RESERVED.
-
- Revision History:
- -----------------
- 11/15/88 ted: put in new ptd_SetInner function
- 12/16/88 jmd made ddisp_GetWidth/Height into functions
- 1/15/89 ted: made ddisp_GetFont omalloc its own font structure.
- 4/04/89 ted Added FreeFont function.
- 8/22/89 ted Made disp_OpenFont use ocalloc.
-
- 11/29/89 jmd added casts for DG
- 2/14/90 ted Got rid of fontreq_struct. Just use fontdesc_struct.
- 3/28/90 jmd ansi-fied
- 6/22/90 ted added "void"s to no-parameter functions per ansii.
- */
-
- #include "oakhead.h"
- #include "disppriv.h"
-
- /* -------------------------------------------------------------------------- */
-
- boolean disp_Ok(void)
- /*
- This disp_Ok function assumes that no valid display will:
- Have an invalid id number.
- Have a NULL dig data pointer.
- Have a NULL info structure pointer.
- Have an invalid display map.
- */
- {
- OEXTERN int num_dmgrs;
-
- if (curr_dmgr->id > 0 && curr_dmgr->id <= num_dmgrs &&
- curr_dmgr->disp.dig.data != NULL &&
- curr_dmgr->disp.info != NULL &&
- pmap_Ok(disp_dispmap())) {
- return(TRUE);
- }
- return(FALSE);
- }
- /* -------------------------------------------------------------------------- */
-
- int disp_GetHeight(void)
- /*
- Get the height of the display in characters
- */
- {
- owl_Assert(disp_Ok(), OE_GH_DISP);
- return((int)(disp_GetPixHeight() / ofont_GetHeight(disp_GetDefFont())));
- }
- /* -------------------------------------------------------------------------- */
-
- int disp_GetWidth(void)
- /*
- Get the width of the display in characters
- */
- {
- owl_Assert(disp_Ok(), OE_GW_DISP);
- return((int)(disp_GetPixWidth() / ofont_GetWidth(disp_GetDefFont())));
- }
- /* -------------------------------------------------------------------------- */
-
- ofont_type disp_OpenFont(fontdesc_struct *fontreq)
- /*
- Request a reference to the font the device interface can supply that
- is closest to the desired width, height, and other attributes.
- */
- {
- ofont_type font;
-
- owl_Assert(disp_Ok(), OE_GF_DISP);
-
- if ((font = (ofont_type) ocalloc(OA_FONT, sizeof(struct ofont_struct), sizeof(byte)))
- == NULL) {
- return(NULL);
- }
- if (!disp_Control(DC_OPENFONT, fontreq, font)) {
- ofree(OA_FONT, font);
- font = NULL;
- }
- return(font);
- }
- /* -------------------------------------------------------------------------- */
-
- void disp_CloseFont(ofont_type font)
- /*
- Release a font previously requested from disp_GetFont().
- */
- {
- disp_Control(DC_CLOSEFONT, font, NULL);
- ofree(OA_FONT, (VOID *) font);
- }
- /* -------------------------------------------------------------------------- */
-
- void disp_SetAttrColors(byte attr, opixval bg, opixval fg)
- {
- setattr_struct pvs;
-
- pvs.attr = attr;
- pvs.bg = bg;
- pvs.fg = fg;
- disp_Control(DC_SETATTRCOLS, &pvs, NULL);
- }
- /* -------------------------------------------------------------------------- */
-
- opixval disp_GetAttrFgColor(byte attr)
- {
- opixval fg;
-
- fg = 0;
- disp_getattrfg(&attr, &fg);
- return(fg);
- }
- /* -------------------------------------------------------------------------- */
-
- opixval disp_GetAttrBgColor(byte attr)
- {
- opixval bg;
-
- bg = 0;
- disp_getattrbg(&attr, &bg);
- return(bg);
- }
- /* -------------------------------------------------------------------------- */
-
- void disp_SetColMapEntry(opixval icol, olevel red, olevel green, olevel blue)
- /*
- */
- {
- ocolmap_struct(1) color;
-
- color.firstpix = icol;
- color.nentries = 1;
- color.rgbs[0].rgb[ORED] = red;
- color.rgbs[0].rgb[OGREEN] = green;
- color.rgbs[0].rgb[OBLUE] = blue;
-
- disp_Control(DC_SETCOLMAP, &color, NULL);
- }
- /* -------------------------------------------------------------------------- */
-
- boolean ptd_SetInner(ptd_struct *ptd, ptd_struct *inptd, opbox *inboxp)
- /*
- Make inptd a copy of ptd but with its relboxp pointing to inboxp.
- Clip inboxp within the ptd window's inner box.
- Returns TRUE if the new relbox is not empty.
- Sets inptd->relboxp even if it fails.
- Leaves ptd unaltered.
- */
- {
- memmove((VOID *) inptd, (VOID *) ptd, sizeof(ptd_struct));
- opbox_copy(inboxp, ptd->relboxp);
- inptd->relboxp = inboxp;
- return(opwh_clipbox(win_GetPixWidth(ptd->win),
- win_GetPixHeight(ptd->win),
- inboxp) != 0);
- }
- /* -------------------------------------------------------------------------- */
-
-