home *** CD-ROM | disk | FTP | other *** search
- /*
- disp.c
-
- % Display object hardware-independent code.
-
- 5/16/88 by Ted.
-
- OWL 1.1
- 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
- 01/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.
- */
-
- #include "oakhead.h"
- #include "disppriv.h"
-
- /* -------------------------------------------------------------------------- */
-
- boolean disp_Ok()
- /*
- 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()
- /*
- 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()
- /*
- 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(fontreq)
- fontreq_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(font)
- 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(attr, bg, fg)
- 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(attr)
- byte attr;
- {
- opixval fg;
-
- fg = 0;
- disp_getattrfg(&attr, &fg);
- return(fg);
- }
- /* -------------------------------------------------------------------------- */
-
- opixval disp_GetAttrBgColor(attr)
- byte attr;
- {
- opixval bg;
-
- bg = 0;
- disp_getattrbg(&attr, &bg);
- return(bg);
- }
- /* -------------------------------------------------------------------------- */
-
- void disp_SetColMapEntry(icol, red, green, blue)
- 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, inptd, inboxp)
- 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(inptd, 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);
- }
- /* -------------------------------------------------------------------------- */
-
-