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

  1. /*
  2.     dispinit.c
  3.  
  4.     % Display manager initialization code.
  5.  
  6.     5/16/88  by Ted.
  7.  
  8.     OWL 1.1
  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.  
  22. #include "oakhead.h"
  23. #include "disppriv.h"
  24.  
  25. OGLOBAL dmgr_struct curr_dmgrstruc;    /* the current display manager structure */
  26.  
  27. OGLOBAL int num_dmgrs = 0;            /* the number of dmgrs that have been initted */
  28. static char copyr[] = "OWL 1.1 Copyright (c) 1989 by Oakland Group, Inc.";
  29. /* -------------------------------------------------------------------------- */
  30.  
  31. boolean disp_Init(dmode, backwin)
  32.     dmode_fptr dmode;        /* Display mode initialization function */
  33.     class_fptr backwin;        /* Background window type */
  34. /*
  35.     Initialize the current display manager structure and its
  36.     Device Interface Group functions.
  37.     Returns TRUE if successful, FALSE if unable to initialize the device
  38.     interface.
  39. */
  40. {
  41.     /* Initialize the display and hardware Device Interface Group. */
  42.     if (!dispsetup(dmode)) {
  43.         return(FALSE);
  44.     }
  45.     curr_dmgr->id = copyr[0];    /* To suppress unused-copyr compiler warning */
  46.  
  47.     /* Keep track of how many dmgrs have been initted, */
  48.     /* and assign them consecutive id numbers starting from 1. */
  49.  
  50.     curr_dmgr->id = ++num_dmgrs;
  51.  
  52.     /* Initialize the window manager, w/ tiler and background window */
  53.     if (!wmgr_Init(backwin)) {
  54.         curr_dmgr->id = --num_dmgrs;
  55.         return(FALSE);
  56.     }
  57.     /* Initialize the display */
  58.     disp_Repaint();
  59.  
  60.     return(TRUE);
  61. }
  62. /* -------------------------------------------------------------------------- */
  63.  
  64. void disp_Close()
  65. /*
  66.     Close the current display manager.
  67. */
  68. {
  69.     static boolean inclose = FALSE;
  70.  
  71.     /* Prevent re-entrant calls from going through this function */
  72.     if (inclose) {
  73.         return;
  74.     }
  75.     inclose = TRUE;
  76.  
  77.     if (!disp_Ok()) {        /* if curr_dmgr is not valid, don't close it */
  78.         return;
  79.     }
  80.     disp_Cache();                /* hide mouse */
  81.     wmgr_Wrapup();                /* free all windows */
  82.     disp_RestoreMode();            /* restore hardware display mode */
  83.     disp_CloseDIG();            /* close down device interface Group */
  84.  
  85.     /* Wipe the dmgr data structure clean again */
  86.     memset(curr_dmgr, 0, sizeof(dmgr_struct));
  87.  
  88.     inclose = FALSE;
  89. }
  90. /* -------------------------------------------------------------------------- */
  91.  
  92. boolean OWLPRIV dispsetup(dmode)
  93.     dmode_fptr dmode;
  94. /*
  95.     Do the work of initializing the display manager device interface stuff.
  96. */
  97. {
  98. /* Init disp data pointers to NULL */
  99.     curr_dmgr->disp.info = NULL;
  100.     curr_dmgr->disp.dig.data = NULL;
  101.  
  102. /* Call the disp_struct's open ptr to set up dig structure and display mode */
  103.     if (!(*dmode)(&curr_dmgr->disp.dig)) {        /* Set up driver structure */
  104.         return(FALSE);
  105.     }
  106. /* Get device info struct ptr */
  107.     disp_Control(DC_GETINFO, NULL, &curr_dmgr->disp.info);
  108.  
  109.     curr_dmgr->disp.mouse_timeout = 30;    /* n/100 sec dclick/dhold time */
  110.     curr_dmgr->disp.mouse_distout = ofont_GetWidth(disp_GetDefFont());
  111.  
  112.     return(TRUE);
  113. }
  114. /* -------------------------------------------------------------------------- */
  115.  
  116.