home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / Samples / CSAPE32.ARJ / SOURCE / OWLSCR / DISPINIT.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-10-12  |  4.3 KB  |  146 lines

  1. /*
  2.     dispinit.c
  3.  
  4.     % Display manager initialization code.
  5.  
  6.     5/16/88  by Ted.
  7.  
  8.     OWL 1.2
  9.     Copyright (c) 1988, 1989 by Oakland Group, Inc.
  10.     ALL RIGHTS RESERVED.
  11.  
  12.     Revision History:
  13.     -----------------
  14.      8/09/88 jmd    revised to use new object stuff
  15.      8/12/88 ted    tested return value of ddisp_open()
  16.      8/17/88 jmd      removed  eNOMEM
  17.      8/24/88 ted    merged driver and mode in to one stub function pointer.
  18.      3/20/89 ted    made curr_dmgr a static structure
  19.      8/18/89 ted    added disp_Repaint to end of disp_Init.
  20.  
  21.     11/29/89 jmd    added casts for DG
  22.      1/10/90 ted    Added check for re-init and fixed inclose/disp_Ok logic.
  23.      1/18/90 ted    Added dpref structure.
  24.      2/22/90 ted    Added call to HC_DEINITMOUSE for turning off MGR interrupt.
  25.      3/28/90 jmd    ansi-fied
  26.      5/03/90 jmd    Added meta key elements to dpref structure.
  27.      6/22/90 ted    added "void" to no-parameter function per ansii.
  28.      7/07/90 pmcm    added initial value of FALSE for new softflow dpref member
  29.      7/31/90 bkd    changed softflow to default to TRUE
  30.      9/28/90 pmcm    added ctrlmeta and altmeta defaults
  31.     10/11/90 ted    added initialization for pccbrk dpref element.
  32. */
  33.  
  34. #include "oakhead.h"
  35. #include "disppriv.h"
  36. #include "dpref.h"
  37. #include "scancode.h"    /* for KEY_NONE */
  38.  
  39. /* The display preferences structure */
  40. OGLOBAL dpref_struct curr_dprefstruc = {
  41.     80, 25, FALSE, CTRL_A, CTRL_X, TRUE, FALSE
  42. };
  43.  
  44. /* The current display manager structure */
  45. OGLOBAL dmgr_struct curr_dmgrstruc;
  46.  
  47. /* The number of dmgrs that have been initted */
  48. OGLOBAL int num_dmgrs = 0;
  49.  
  50. static char copyr[] = "OWL 1.2 Copyright (c) 1989 by Oakland Group, Inc.";
  51. /* -------------------------------------------------------------------------- */
  52.  
  53. boolean disp_Init(dmode_fptr dmode, class_fptr backwin)
  54. /*
  55.     Initialize the current display manager structure and its
  56.     Device Interface Group functions.
  57.     Returns TRUE if successful, FALSE if unable to initialize the device
  58.     interface.
  59.  
  60.     'dmode'        Display mode initialization function
  61.     'backwin'    Background window type
  62. */
  63. {
  64.     if (disp_Ok()) {    /* if curr_dmgr is already valid, don't open another */
  65.         return(FALSE);
  66.     }
  67.     /* Initialize the display and hardware Device Interface Group. */
  68.     if (!dispsetup(dmode)) {
  69.         return(FALSE);
  70.     }
  71.     curr_dmgr->id = copyr[0];    /* To suppress unused-copyr compiler warning */
  72.  
  73.     /* Keep track of how many dmgrs have been initted, */
  74.     /* and assign them consecutive id numbers starting from 1. */
  75.  
  76.     curr_dmgr->id = ++num_dmgrs;
  77.  
  78.     /* Initialize the window manager, w/ tiler and background window */
  79.     if (!wmgr_Init(backwin)) {
  80.         curr_dmgr->id = --num_dmgrs;
  81.         return(FALSE);
  82.     }
  83.     /* Initialize the display */
  84.     disp_Repaint();
  85.  
  86.     return(TRUE);
  87. }
  88. /* -------------------------------------------------------------------------- */
  89.  
  90. void disp_Close(void)
  91. /*
  92.     Close the current display manager.
  93. */
  94. {
  95.     static boolean inclose = FALSE;
  96.  
  97.     /* Prevent re-entrant calls from going through this function */
  98.     if (inclose) {
  99.         return;
  100.     }
  101.     if (!disp_Ok()) {        /* if curr_dmgr is not valid, don't close it */
  102.         return;
  103.     }
  104.     inclose = TRUE;
  105.  
  106.     disp_HideMouse();            /* hide mouse */
  107.     hard_Control(HC_DEINITMOUSE, NULL, NULL);    /* turn mouse off */
  108.  
  109.     wmgr_Wrapup();                /* free all windows */
  110.  
  111.     disp_RestoreMode();            /* restore hardware display mode */
  112.     disp_CloseDIG();            /* close down Device Interface Group */
  113.  
  114.     /* Wipe the dmgr data structure clean again */
  115.     /* curr_dmgr->id == 0 is the element that we actually look at. */
  116.     memset((VOID *) curr_dmgr, 0, sizeof(dmgr_struct));
  117.  
  118.     inclose = FALSE;
  119. }
  120. /* -------------------------------------------------------------------------- */
  121.  
  122. boolean OWLPRIV dispsetup(dmode_fptr dmode)
  123. /*
  124.     Do the work of initializing the display manager device interface stuff.
  125. */
  126. {
  127.     /* Init disp data pointers to NULL */
  128.     curr_dmgr->disp.info = NULL;
  129.     curr_dmgr->disp.dig.data = NULL;
  130.  
  131.     /* Call the disp_struct's open ptr to set up dig structure and display mode */
  132.     if (!(*dmode)(&curr_dmgr->disp.dig)) {        /* Set up driver structure */
  133.         return(FALSE);
  134.     }
  135.  
  136.     /* Get device info struct ptr */
  137.     disp_Control(DC_GETINFO, NULL, &curr_dmgr->disp.info);
  138.  
  139.     curr_dmgr->disp.mouse_timeout = 30;    /* n/100 sec dclick/dhold time */
  140.     curr_dmgr->disp.mouse_distout = ofont_GetWidth(disp_GetDefFont());
  141.  
  142.     return(TRUE);
  143. }
  144. /* -------------------------------------------------------------------------- */
  145.  
  146.