home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0020 - 0029 / ibm0020-0029 / ibm0028.tar / ibm0028 / CSCAP323.ZIP / OWLSRC.EXE / WINLOAD.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-10-31  |  4.9 KB  |  202 lines

  1. /*
  2.     winload.c
  3.  
  4.     % winreq_load
  5.  
  6.     OWL 1.2
  7.     Copyright (c) 1988, 1989 by Oakland Group, Inc.
  8.     ALL RIGHTS RESERVED.
  9.  
  10.     Revision History:
  11.     -----------------
  12.      9/01/89 jdc    added win_IsCharSize
  13.     10/24/89 jmd    added static to function
  14.  
  15.     12/11/89 jmd    removed os-list headers
  16.     12/17/89 jdc    fixed attrs
  17.      1/23/89 jdc    added default defines
  18.      3/28/90 jmd    ansi-fied
  19.      4/16/90 jdc    renamed _bfile_gets to bf_gets
  20.      5/10/90 jdc    added win_GoFunc
  21.      5/18/90 jmd    converted nul_funcptr from OSTATIC to static
  22.      6/27/90 jdc    preened the GoFunc code
  23.      8/08/90 jdc    moved aux function down to window level
  24.      9/24/90 jdc    removed gofunc code
  25. */
  26.  
  27. #include "oakhead.h"
  28. #include "disppriv.h"
  29.  
  30. #include "bordobj.h"
  31. #include "winod.h"
  32. #include "winsfile.h"
  33. #include "winspriv.h"
  34.  
  35. OSTATIC objreq_func (winreq_load);
  36. static  VOID_FPTR null_funcptr = FNULL;
  37.  
  38. #define    DEFAULT_BORD        bd_prompt
  39. #define    DEFAULT_MOUSE        (mouhandler_fptr)null_funcptr
  40. #define    DEFAULT_EXP            (exp_fptr)null_funcptr
  41. #define DEFAULT_AUX            (aux_fptr)null_funcptr;
  42.  
  43. void win_LoadInit(void)
  44. {
  45.     winreq_loadfptr = winreq_load;
  46. }
  47.  
  48. static int winreq_load(VOID *objdata, int msg, VOID *indata, VOID *outdata)
  49. {
  50.     ocbox box;
  51.     opbox pbox;
  52.     int shadow_x, shadow_y, shadow_attr, clip;
  53.     int bd_attr, handle;
  54.     unsigned bd_feature;
  55.     bd_fptr border;
  56.     mouhandler_fptr mouse;
  57.     exp_fptr explode;
  58.     aux_fptr auxfunc;
  59.     char *sbuf;
  60.     bfile_type bfile;
  61.     sfile_type sfile;
  62.     win_type win;
  63.     int attr = -1;
  64.  
  65.     oak_notused(msg);
  66.     oak_notused(outdata);
  67.  
  68.     win = winod_GetSelf((win_od *)objdata);
  69.     sfile = (sfile_type)indata;
  70.  
  71.     bfile = sfile->bfile;
  72.     sbuf = sfile->buf;
  73.  
  74. /* win info:
  75.         new for 3.2! go func,
  76.         ymin, xmin, ymax, xmax, parent clip,
  77.         shadow x, shadow y, shadow attr, border attr, border features,
  78.         attr,
  79.         font, border, border title, mouse, explode
  80. */
  81.     if (bf_gets(bfile, sbuf, SFILE_BUFLEN, '\0') == 0) {
  82.         return(FALSE);
  83.     }
  84.     while (sscanf(sbuf, "%d %d %d %d %d %d %d %d %d %d %d", 
  85.         &box.toprow, &box.leftcol, &box.botrow, &box.rightcol, &clip, 
  86.         &shadow_x, &shadow_y, &shadow_attr, 
  87.         &bd_attr, &bd_feature, &attr) < 10) {
  88.  
  89.         /* ver 3.2 file: used to have gofunc here, now empty */
  90.  
  91.         if (*sbuf == '1') {
  92.             /* ver 3.2.1 file (aux function) */
  93.  
  94.             if (bf_gets(bfile, sbuf, SFILE_BUFLEN, '\0') == 0) {
  95.                 return(FALSE);
  96.             }
  97.             if ((auxfunc = sfile_FindAuxFunc(sfile, sbuf + V32LEN, &handle)) == FNULL) {
  98.                 auxfunc = DEFAULT_AUX;
  99.             }
  100.             obj_SetAux(win, auxfunc);
  101.             if (handle == -1) {
  102.                 handle = sfile_PutAuxFunc(sfile, sbuf + V32LEN, auxfunc);
  103.             }
  104.             win_SetAuxHandle(win, handle);
  105.         }
  106.  
  107.         /* let's try that fscanf again */
  108.         if (bf_gets(bfile, sbuf, SFILE_BUFLEN, '\0') == 0) {
  109.             return(FALSE);
  110.         }
  111.     }
  112.  
  113. /* ignore font for now */
  114.     if (bf_gets(bfile, sbuf, SFILE_BUFLEN, '\0') == 0) {
  115.         return(FALSE);
  116.     }
  117.     win_SetFont(win, disp_GetDefFont());
  118.  
  119.     win_SetParentClip(win, clip);
  120.     win_SetShadowAttr(win, (byte)shadow_attr);
  121.  
  122.     if (attr != -1) {                    /* old file format */
  123.         win_SetAttr(win, (byte)attr);
  124.     }
  125.  
  126. /* border */
  127.     if (bf_gets(bfile, sbuf, SFILE_BUFLEN, '\0') == 0) {
  128.         return(FALSE);
  129.     }
  130.     if (*sbuf == '\0') {
  131.         border = FNULL;
  132.         handle = -1;
  133.     }
  134.     else if ((border = sfile_FindBorderFunc(sfile, sbuf, &handle)) == FNULL) {
  135.         border = DEFAULT_BORD;
  136.     }
  137.     win_SetBorder(win, border);
  138.     if (handle == -1) {
  139.         handle = sfile_PutBorderFunc(sfile, sbuf, border);
  140.     }
  141.     win_SetBorderHandle(win, handle);
  142.  
  143. /* win init */
  144.     if (win_IsCharSize(win)) {
  145.         ocbox_pixcoords(&box, win_GetFont(win), &pbox);
  146.         shadow_x *= win_GetFontWidth(win);
  147.         shadow_y *= win_GetFontHeight(win);
  148.     }
  149.     else {
  150.         pbox.ymin = box.toprow;
  151.         pbox.xmin = box.leftcol;
  152.         pbox.ymax = box.botrow;
  153.         pbox.xmax = box.rightcol;
  154.     }
  155.     win_ReallySetPixPosition(win, pbox.xmin, pbox.ymin);
  156.     win_ReallySetPixSize(win, opbox_GetWidth(&pbox), opbox_GetHeight(&pbox));
  157.  
  158.     win_SetPixShadow(win, shadow_x, shadow_y);
  159.  
  160.     bord_SetAttr(win, (byte)bd_attr);
  161.     bord_SetFeature(win, bd_feature);
  162.  
  163. /* border title */
  164.     if (bf_gets(bfile, sbuf, SFILE_BUFLEN, '\0') == 0) {
  165.         return(FALSE);
  166.     }
  167.     if (strcmp(sbuf, FSYM_NULLSTR) != 0) {
  168.         bord_SetTitle(win, sbuf);
  169.     }
  170.  
  171. /* mouse */
  172.     if (bf_gets(bfile, sbuf, SFILE_BUFLEN, '\0') == 0) {
  173.         return(FALSE);
  174.     }
  175.     if ((mouse = sfile_FindMouseFunc(sfile, sbuf, &handle)) == FNULL) {
  176.         mouse = DEFAULT_MOUSE;
  177.     }
  178.     win_SetMouse(win, mouse);
  179.     if (handle == -1) {
  180.         handle = sfile_PutMouseFunc(sfile, sbuf, mouse);
  181.     }
  182.     win_SetMouseHandle(win, handle);
  183.  
  184. /* explode */
  185.     if (bf_gets(bfile, sbuf, SFILE_BUFLEN, '\0') == 0) {
  186.         return(FALSE);
  187.     }
  188.     if ((explode = sfile_FindExplodeFunc(sfile, sbuf, &handle)) == FNULL) {
  189.         explode = DEFAULT_EXP;
  190.     }
  191.     win_SetExplode(win, explode);
  192.     if (handle == -1) {
  193.         handle = sfile_PutExplodeFunc(sfile, sbuf, explode);
  194.     }
  195.     win_SetExplodeHandle(win, handle);
  196.  
  197. /* Put window into unemployed list (at the top) */
  198.     win_ListAdd(wmgr_unemployedhead(), win);
  199.  
  200.     return(TRUE);
  201. }
  202.